[Python-checkins] python/dist/src/Lib/test bad_coding.py, NONE, 1.1.2.2 test_cmd_line.py, NONE, 1.2.2.2 test_coding.py, NONE, 1.1.2.2 test_float.py, NONE, 1.2.2.2 test_functional.py, NONE, 1.4.2.2 test_hashlib.py, NONE, 1.1.2.2 test_hashlib_speed.py, NONE, 1.2.2.2 test_xdrlib.py, NONE, 1.2.2.2 inspect_fodder2.py, 1.2.2.1, 1.2.2.2 list_tests.py, 1.5.4.1, 1.5.4.2 regrtest.py, 1.87.2.2, 1.87.2.3 seq_tests.py, 1.3.4.1, 1.3.4.2 string_tests.py, 1.18.2.2, 1.18.2.3 test_StringIO.py, 1.13.2.2, 1.13.2.3 test__locale.py, 1.8.4.1, 1.8.4.2 test_al.py, 1.6.26.1, 1.6.26.2 test_array.py, 1.16.2.2, 1.16.2.3 test_asynchat.py, 1.4.24.1, 1.4.24.2 test_base64.py, 1.2.2.2, 1.2.2.3 test_binop.py, 1.6.14.1, 1.6.14.2 test_bisect.py, 1.1.26.2, 1.1.26.3 test_builtin.py, 1.1.36.2, 1.1.36.3 test_bz2.py, 1.12.8.2, 1.12.8.3 test_cd.py, 1.5.26.1, 1.5.26.2 test_cl.py, 1.5.26.1, 1.5.26.2 test_class.py, 1.8.2.2, 1.8.2.3 test_codeccallbacks.py, 1.10.8.2, 1.10.8.3 test_codecs.py, 1.2.14.2, 1.2.14.3 test_compiler.py, 1.10.4.1, 1.10.4.2 test_complex.py, 1.8.2.2, 1.8.2.3 test_cookie.py, 1.11.14.2, 1.11.14.3 test_cookielib.py, 1.1.6.1, 1.1.6.2 test_csv.py, 1.5.4.2, 1.5.4.3 test_curses.py, 1.1.10.2, 1.1.10.3 test_datetime.py, 1.41.4.2, 1.41.4.3 test_decimal.py, 1.16.2.1, 1.16.2.2 test_deque.py, 1.18.4.1, 1.18.4.2 test_descr.py, 1.144.2.2, 1.144.2.3 test_descrtut.py, 1.13.2.2, 1.13.2.3 test_doctest.py, 1.4.14.3, 1.4.14.4 test_doctest2.py, 1.3.12.2, 1.3.12.3 test_dumbdbm.py, 1.6.2.2, 1.6.2.3 test_enumerate.py, 1.2.2.2, 1.2.2.3 test_fcntl.py, 1.23.2.2, 1.23.2.3 test_file.py, 1.9.2.2, 1.9.2.3 test_funcattrs.py, 1.11.10.2, 1.11.10.3 test_generators.py, 1.34.2.2, 1.34.2.3 test_genexps.py, 1.7.4.2, 1.7.4.3 test_getargs2.py, 1.4.4.2, 1.4.4.3 test_glob.py, 1.3.14.2, 1.3.14.3 test_grammar.py, 1.40.8.4, 1.40.8.5 test_gzip.py, 1.9.2.2, 1.9.2.3 test_hmac.py, 1.4.2.2, 1.4.2.3 test_inspect.py, 1.7.12.2, 1.7.12.3 test_ioctl.py, 1.2.6.1, 1.2.6.2 test_isinstance.py, 1.3.2.2, 1.3.2.3 test_iterlen.py, 1.2.6.1, 1.2.6.2 test_itertools.py, 1.5.6.2, 1.5.6.3 test_locale.py, 1.3.20.2, 1.3.20.3 test_long.py, 1.16.2.2, 1.16.2.3 test_macfs.py, 1.7.4.1, 1.7.4.2 test_marshal.py, 1.1.16.2, 1.1.16.3 test_minidom.py, 1.32.2.2, 1.32.2.3 test_mmap.py, 1.22.2.1, 1.22.2.2 test_mutants.py, 1.6.22.1, 1.6.22.2 test_new.py, 1.14.8.2, 1.14.8.3 test_operator.py, 1.8.14.2, 1.8.14.3 test_os.py, 1.11.2.2, 1.11.2.3 test_ossaudiodev.py, 1.4.8.2, 1.4.8.3 test_parser.py, 1.11.2.3, 1.11.2.4 test_popen2.py, 1.6.2.2, 1.6.2.3 test_posix.py, 1.5.6.2, 1.5.6.3 test_posixpath.py, 1.4.26.2, 1.4.26.3 test_profile.py, 1.2.14.1, 1.2.14.2 test_re.py, 1.31.18.2, 1.31.18.3 test_richcmp.py, 1.6.20.2, 1.6.20.3 test_set.py, 1.16.4.1, 1.16.4.2 test_sets.py, 1.23.6.2, 1.23.6.3 test_site.py, 1.6.6.1, 1.6.6.2 test_socket.py, 1.39.2.2, 1.39.2.3 test_str.py, 1.2.4.2, 1.2.4.3 test_strptime.py, 1.11.4.2, 1.11.4.3 test_subprocess.py, 1.17.2.1, 1.17.2.2 test_sundry.py, 1.10.2.2, 1.10.2.3 test_support.py, 1.41.2.2, 1.41.2.3 test_sys.py, 1.6.6.2, 1.6.6.3 test_tarfile.py, 1.7.4.2, 1.7.4.3 test_tempfile.py, 1.1.10.2, 1.1.10.3 test_textwrap.py, 1.18.10.2, 1.18.10.3 test_threading.py, 1.2.18.1, 1.2.18.2 test_tokenize.py, 1.6.10.2, 1.6.10.3 test_trace.py, 1.7.10.3, 1.7.10.4 test_unicode.py, 1.58.2.2, 1.58.2.3 test_unicode_file.py, 1.4.2.2, 1.4.2.3 test_unicodedata.py, 1.5.26.2, 1.5.26.3 test_urllib.py, 1.8.26.2, 1.8.26.3 test_urllib2.py, 1.6.10.2, 1.6.10.3 test_urlparse.py, 1.5.2.2, 1.5.2.3 test_userdict.py, 1.5.10.2, 1.5.10.3 test_userstring.py, 1.6.2.2, 1.6.2.3 test_weakref.py, 1.19.2.2, 1.19.2.3 test_xmlrpc.py, 1.2.10.2, 1.2.10.3 test_zlib.py, 1.17.2.2, 1.17.2.3

jhylton@users.sourceforge.net jhylton at users.sourceforge.net
Sun Oct 16 07:24:41 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27718/Lib/test

Modified Files:
      Tag: ast-branch
	inspect_fodder2.py list_tests.py regrtest.py seq_tests.py 
	string_tests.py test_StringIO.py test__locale.py test_al.py 
	test_array.py test_asynchat.py test_base64.py test_binop.py 
	test_bisect.py test_builtin.py test_bz2.py test_cd.py 
	test_cl.py test_class.py test_codeccallbacks.py test_codecs.py 
	test_compiler.py test_complex.py test_cookie.py 
	test_cookielib.py test_csv.py test_curses.py test_datetime.py 
	test_decimal.py test_deque.py test_descr.py test_descrtut.py 
	test_doctest.py test_doctest2.py test_dumbdbm.py 
	test_enumerate.py test_fcntl.py test_file.py test_funcattrs.py 
	test_generators.py test_genexps.py test_getargs2.py 
	test_glob.py test_grammar.py test_gzip.py test_hmac.py 
	test_inspect.py test_ioctl.py test_isinstance.py 
	test_iterlen.py test_itertools.py test_locale.py test_long.py 
	test_macfs.py test_marshal.py test_minidom.py test_mmap.py 
	test_mutants.py test_new.py test_operator.py test_os.py 
	test_ossaudiodev.py test_parser.py test_popen2.py 
	test_posix.py test_posixpath.py test_profile.py test_re.py 
	test_richcmp.py test_set.py test_sets.py test_site.py 
	test_socket.py test_str.py test_strptime.py test_subprocess.py 
	test_sundry.py test_support.py test_sys.py test_tarfile.py 
	test_tempfile.py test_textwrap.py test_threading.py 
	test_tokenize.py test_trace.py test_unicode.py 
	test_unicode_file.py test_unicodedata.py test_urllib.py 
	test_urllib2.py test_urlparse.py test_userdict.py 
	test_userstring.py test_weakref.py test_xmlrpc.py test_zlib.py 
Added Files:
      Tag: ast-branch
	bad_coding.py test_cmd_line.py test_coding.py test_float.py 
	test_functional.py test_hashlib.py test_hashlib_speed.py 
	test_xdrlib.py 
Log Message:
Merge head to branch (for the last time)


--- NEW FILE: bad_coding.py ---
# -*- coding: uft-8 -*-

--- NEW FILE: test_cmd_line.py ---

import test.test_support, unittest
import sys
import popen2

class CmdLineTest(unittest.TestCase):
    def start_python(self, cmd_line):
        outfp, infp = popen2.popen4('%s %s' % (sys.executable, cmd_line))
        infp.close()
        data = outfp.read()
        outfp.close()
        return data

    def test_directories(self):
        self.assertTrue('is a directory' in self.start_python('.'))
        self.assertTrue('is a directory' in self.start_python('< .'))

    def verify_valid_flag(self, cmd_line):
        data = self.start_python(cmd_line)
        self.assertTrue(data == '' or data.endswith('\n'))
        self.assertTrue('Traceback' not in data)

    def test_environment(self):
        self.verify_valid_flag('-E')

    def test_optimize(self):
        self.verify_valid_flag('-O')
        self.verify_valid_flag('-OO')

    def test_q(self):
        self.verify_valid_flag('-Qold')
        self.verify_valid_flag('-Qnew')
        self.verify_valid_flag('-Qwarn')
        self.verify_valid_flag('-Qwarnall')

    def test_site_flag(self):
        self.verify_valid_flag('-S')

    def test_usage(self):
        self.assertTrue('usage' in self.start_python('-h'))

    def test_version(self):
        version = 'Python %d.%d' % sys.version_info[:2]
        self.assertTrue(self.start_python('-V').startswith(version))

def test_main():
    test.test_support.run_unittest(CmdLineTest)

if __name__ == "__main__":
    test_main()

--- NEW FILE: test_coding.py ---

import test.test_support, unittest
import os

class CodingTest(unittest.TestCase):
    def test_bad_coding(self):
        module_name = 'bad_coding'
        self.assertRaises(SyntaxError, __import__, 'test.' + module_name)

        path = os.path.dirname(__file__)
        filename = os.path.join(path, module_name + '.py')
        fp = open(filename)
        text = fp.read()
        fp.close()
        self.assertRaises(SyntaxError, compile, text, filename, 'exec')

def test_main():
    test.test_support.run_unittest(CodingTest)

if __name__ == "__main__":
    test_main()

--- NEW FILE: test_float.py ---

import unittest, struct
from test import test_support

class FormatFunctionsTestCase(unittest.TestCase):

    def setUp(self):
        self.save_formats = {'double':float.__getformat__('double'),
                             'float':float.__getformat__('float')}

    def tearDown(self):
        float.__setformat__('double', self.save_formats['double'])
        float.__setformat__('float', self.save_formats['float'])

    def test_getformat(self):
        self.assert_(float.__getformat__('double') in
                     ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
        self.assert_(float.__getformat__('float') in
                     ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
        self.assertRaises(ValueError, float.__getformat__, 'chicken')
        self.assertRaises(TypeError, float.__getformat__, 1)

    def test_setformat(self):
        for t in 'double', 'float':
            float.__setformat__(t, 'unknown')
            if self.save_formats[t] == 'IEEE, big-endian':
                self.assertRaises(ValueError, float.__setformat__,
                                  t, 'IEEE, little-endian')
            elif self.save_formats[t] == 'IEEE, little-endian':
                self.assertRaises(ValueError, float.__setformat__,
                                  t, 'IEEE, big-endian')
            else:
                self.assertRaises(ValueError, float.__setformat__,
                                  t, 'IEEE, big-endian')
                self.assertRaises(ValueError, float.__setformat__,
                                  t, 'IEEE, little-endian')
            self.assertRaises(ValueError, float.__setformat__,
                              t, 'chicken')
        self.assertRaises(ValueError, float.__setformat__,
                          'chicken', 'unknown')

BE_DOUBLE_INF = '\x7f\xf0\x00\x00\x00\x00\x00\x00'
LE_DOUBLE_INF = ''.join(reversed(BE_DOUBLE_INF))
BE_DOUBLE_NAN = '\x7f\xf8\x00\x00\x00\x00\x00\x00'
LE_DOUBLE_NAN = ''.join(reversed(BE_DOUBLE_NAN))

BE_FLOAT_INF = '\x7f\x80\x00\x00'
LE_FLOAT_INF = ''.join(reversed(BE_FLOAT_INF))
BE_FLOAT_NAN = '\x7f\xc0\x00\x00'
LE_FLOAT_NAN = ''.join(reversed(BE_FLOAT_NAN))

# on non-IEEE platforms, attempting to unpack a bit pattern
# representing an infinity or a NaN should raise an exception.

class UnknownFormatTestCase(unittest.TestCase):
    def setUp(self):
        self.save_formats = {'double':float.__getformat__('double'),
                             'float':float.__getformat__('float')}
        float.__setformat__('double', 'unknown')
        float.__setformat__('float', 'unknown')

    def tearDown(self):
        float.__setformat__('double', self.save_formats['double'])
        float.__setformat__('float', self.save_formats['float'])

    def test_double_specials_dont_unpack(self):
        for fmt, data in [('>d', BE_DOUBLE_INF),
                          ('>d', BE_DOUBLE_NAN),
                          ('<d', LE_DOUBLE_INF),
                          ('<d', LE_DOUBLE_NAN)]:
            self.assertRaises(ValueError, struct.unpack, fmt, data)

    def test_float_specials_dont_unpack(self):
        for fmt, data in [('>f', BE_FLOAT_INF),
                          ('>f', BE_FLOAT_NAN),
                          ('<f', LE_FLOAT_INF),
                          ('<f', LE_FLOAT_NAN)]:
            self.assertRaises(ValueError, struct.unpack, fmt, data)


# on an IEEE platform, all we guarantee is that bit patterns
# representing infinities or NaNs do not raise an exception; all else
# is accident (today).

class IEEEFormatTestCase(unittest.TestCase):
    if float.__getformat__("double").startswith("IEEE"):
        def test_double_specials_do_unpack(self):
            for fmt, data in [('>d', BE_DOUBLE_INF),
                              ('>d', BE_DOUBLE_NAN),
                              ('<d', LE_DOUBLE_INF),
                              ('<d', LE_DOUBLE_NAN)]:
                struct.unpack(fmt, data)

    if float.__getformat__("float").startswith("IEEE"):
        def test_float_specials_do_unpack(self):
            for fmt, data in [('>f', BE_FLOAT_INF),
                              ('>f', BE_FLOAT_NAN),
                              ('<f', LE_FLOAT_INF),
                              ('<f', LE_FLOAT_NAN)]:
                struct.unpack(fmt, data)


def test_main():
    test_support.run_unittest(
        FormatFunctionsTestCase,
        UnknownFormatTestCase,
        IEEEFormatTestCase)

if __name__ == '__main__':
    test_main()

--- NEW FILE: test_functional.py ---
import functional
import unittest
from test import test_support
from weakref import proxy

@staticmethod
def PythonPartial(func, *args, **keywords):
    'Pure Python approximation of partial()'
    def newfunc(*fargs, **fkeywords):
        newkeywords = keywords.copy()
        newkeywords.update(fkeywords)
        return func(*(args + fargs), **newkeywords)
    newfunc.func = func
    newfunc.args = args
    newfunc.keywords = keywords
    return newfunc

def capture(*args, **kw):
    """capture all positional and keyword arguments"""
    return args, kw

class TestPartial(unittest.TestCase):

    thetype = functional.partial

    def test_basic_examples(self):
        p = self.thetype(capture, 1, 2, a=10, b=20)
        self.assertEqual(p(3, 4, b=30, c=40),
                         ((1, 2, 3, 4), dict(a=10, b=30, c=40)))
        p = self.thetype(map, lambda x: x*10)
        self.assertEqual(p([1,2,3,4]), [10, 20, 30, 40])

    def test_attributes(self):
        p = self.thetype(capture, 1, 2, a=10, b=20)
        # attributes should be readable
        self.assertEqual(p.func, capture)
        self.assertEqual(p.args, (1, 2))
        self.assertEqual(p.keywords, dict(a=10, b=20))
        # attributes should not be writable
        if not isinstance(self.thetype, type):
            return
        self.assertRaises(TypeError, setattr, p, 'func', map)
        self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
        self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))

    def test_argument_checking(self):
        self.assertRaises(TypeError, self.thetype)     # need at least a func arg
        try:
            self.thetype(2)()
        except TypeError:
            pass
        else:
            self.fail('First arg not checked for callability')

    def test_protection_of_callers_dict_argument(self):
        # a caller's dictionary should not be altered by partial
        def func(a=10, b=20):
            return a
        d = {'a':3}
        p = self.thetype(func, a=5)
        self.assertEqual(p(**d), 3)
        self.assertEqual(d, {'a':3})
        p(b=7)
        self.assertEqual(d, {'a':3})

    def test_arg_combinations(self):
        # exercise special code paths for zero args in either partial
        # object or the caller
        p = self.thetype(capture)
        self.assertEqual(p(), ((), {}))
        self.assertEqual(p(1,2), ((1,2), {}))
        p = self.thetype(capture, 1, 2)
        self.assertEqual(p(), ((1,2), {}))
        self.assertEqual(p(3,4), ((1,2,3,4), {}))

    def test_kw_combinations(self):
        # exercise special code paths for no keyword args in
        # either the partial object or the caller
        p = self.thetype(capture)
        self.assertEqual(p(), ((), {}))
        self.assertEqual(p(a=1), ((), {'a':1}))
        p = self.thetype(capture, a=1)
        self.assertEqual(p(), ((), {'a':1}))
        self.assertEqual(p(b=2), ((), {'a':1, 'b':2}))
        # keyword args in the call override those in the partial object
        self.assertEqual(p(a=3, b=2), ((), {'a':3, 'b':2}))

    def test_positional(self):
        # make sure positional arguments are captured correctly
        for args in [(), (0,), (0,1), (0,1,2), (0,1,2,3)]:
            p = self.thetype(capture, *args)
            expected = args + ('x',)
            got, empty = p('x')
            self.failUnless(expected == got and empty == {})

    def test_keyword(self):
        # make sure keyword arguments are captured correctly
        for a in ['a', 0, None, 3.5]:
            p = self.thetype(capture, a=a)
            expected = {'a':a,'x':None}
            empty, got = p(x=None)
            self.failUnless(expected == got and empty == ())

    def test_no_side_effects(self):
        # make sure there are no side effects that affect subsequent calls
        p = self.thetype(capture, 0, a=1)
        args1, kw1 = p(1, b=2)
        self.failUnless(args1 == (0,1) and kw1 == {'a':1,'b':2})
        args2, kw2 = p()
        self.failUnless(args2 == (0,) and kw2 == {'a':1})

    def test_error_propagation(self):
        def f(x, y):
            x / y
        self.assertRaises(ZeroDivisionError, self.thetype(f, 1, 0))
        self.assertRaises(ZeroDivisionError, self.thetype(f, 1), 0)
        self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0)
        self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1)

    def test_attributes(self):
        p = self.thetype(hex)
        try:
            del p.__dict__
        except TypeError:
            pass
        else:
            self.fail('partial object allowed __dict__ to be deleted')

    def test_weakref(self):
        f = self.thetype(int, base=16)
        p = proxy(f)
        self.assertEqual(f.func, p.func)
        f = None
        self.assertRaises(ReferenceError, getattr, p, 'func')

    def test_with_bound_and_unbound_methods(self):
        data = map(str, range(10))
        join = self.thetype(str.join, '')
        self.assertEqual(join(data), '0123456789')
        join = self.thetype(''.join)
        self.assertEqual(join(data), '0123456789')

class PartialSubclass(functional.partial):
    pass

class TestPartialSubclass(TestPartial):

    thetype = PartialSubclass


class TestPythonPartial(TestPartial):

    thetype = PythonPartial



def test_main(verbose=None):
    import sys
    test_classes = (
        TestPartial,
        TestPartialSubclass,
        TestPythonPartial,
    )
    test_support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts

if __name__ == '__main__':
    test_main(verbose=True)

--- NEW FILE: test_hashlib.py ---
# Test hashlib module
#
# $Id: test_hashlib.py,v 1.1.2.2 2005/10/16 05:24:00 jhylton Exp $
#
#  Copyright (C) 2005   Gregory P. Smith (greg at electricrain.com)
#  Licensed to PSF under a Contributor Agreement.
#

import hashlib
import unittest
from test import test_support


def hexstr(s):
    import string
    h = string.hexdigits
    r = ''
    for c in s:
        i = ord(c)
        r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
    return r


class HashLibTestCase(unittest.TestCase):
    supported_hash_names = ( 'md5', 'MD5', 'sha1', 'SHA1',
                             'sha224', 'SHA224', 'sha256', 'SHA256',
                             'sha384', 'SHA384', 'sha512', 'SHA512' )

    def test_unknown_hash(self):
        try:
            hashlib.new('spam spam spam spam spam')
        except ValueError:
            pass
        else:
            self.assert_(0 == "hashlib didn't reject bogus hash name")

    def test_hexdigest(self):
        for name in self.supported_hash_names:
            h = hashlib.new(name)
            self.assert_(hexstr(h.digest()) == h.hexdigest())


    def test_large_update(self):
        aas = 'a' * 128
        bees = 'b' * 127
        cees = 'c' * 126

        for name in self.supported_hash_names:
            m1 = hashlib.new(name)
            m1.update(aas)
            m1.update(bees)
            m1.update(cees)

            m2 = hashlib.new(name)
            m2.update(aas + bees + cees)
            self.assertEqual(m1.digest(), m2.digest())


    def check(self, name, data, digest):
        # test the direct constructors
        computed = getattr(hashlib, name)(data).hexdigest()
        self.assert_(computed == digest)
        # test the general new() interface
        computed = hashlib.new(name, data).hexdigest()
        self.assert_(computed == digest)


    def test_case_md5_0(self):
        self.check('md5', '', 'd41d8cd98f00b204e9800998ecf8427e')

    def test_case_md5_1(self):
        self.check('md5', 'abc', '900150983cd24fb0d6963f7d28e17f72')

    def test_case_md5_2(self):
        self.check('md5', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
                   'd174ab98d277d9f5a5611c2c9f419d9f')


    # use the three examples from Federal Information Processing Standards
    # Publication 180-1, Secure Hash Standard,  1995 April 17
    # http://www.itl.nist.gov/div897/pubs/fip180-1.htm

    def test_case_sha1_0(self):
        self.check('sha1', "",
                   "da39a3ee5e6b4b0d3255bfef95601890afd80709")

    def test_case_sha1_1(self):
        self.check('sha1', "abc",
                   "a9993e364706816aba3e25717850c26c9cd0d89d")

    def test_case_sha1_2(self):
        self.check('sha1', "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
                   "84983e441c3bd26ebaae4aa1f95129e5e54670f1")

    def test_case_sha1_3(self):
        self.check('sha1', "a" * 1000000,
                   "34aa973cd4c4daa4f61eeb2bdbad27316534016f")


    # use the examples from Federal Information Processing Standards
    # Publication 180-2, Secure Hash Standard,  2002 August 1
    # http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf

    def test_case_sha224_0(self):
        self.check('sha224', "",
          "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f")

    def test_case_sha224_1(self):
        self.check('sha224', "abc",
          "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7")

    def test_case_sha224_2(self):
        self.check('sha224',
          "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
          "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525")

    def test_case_sha224_3(self):
        self.check('sha224', "a" * 1000000,
          "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67")


    def test_case_sha256_0(self):
        self.check('sha256', "",
          "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")

    def test_case_sha256_1(self):
        self.check('sha256', "abc",
          "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad")

    def test_case_sha256_2(self):
        self.check('sha256',
          "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
          "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1")

    def test_case_sha256_3(self):
        self.check('sha256', "a" * 1000000,
          "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0")


    def test_case_sha384_0(self):
        self.check('sha384', "",
          "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da"+
          "274edebfe76f65fbd51ad2f14898b95b")

    def test_case_sha384_1(self):
        self.check('sha384', "abc",
          "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed"+
          "8086072ba1e7cc2358baeca134c825a7")

    def test_case_sha384_2(self):
        self.check('sha384',
                   "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
                   "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
          "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712"+
          "fcc7c71a557e2db966c3e9fa91746039")

    def test_case_sha384_3(self):
        self.check('sha384', "a" * 1000000,
          "9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b"+
          "07b8b3dc38ecc4ebae97ddd87f3d8985")


    def test_case_sha512_0(self):
        self.check('sha512', "",
          "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce"+
          "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e")

    def test_case_sha512_1(self):
        self.check('sha512', "abc",
          "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"+
          "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f")

    def test_case_sha512_2(self):
        self.check('sha512',
                   "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
                   "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
          "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"+
          "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909")

    def test_case_sha512_3(self):
        self.check('sha512', "a" * 1000000,
          "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb"+
          "de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b")


def test_main():
    test_support.run_unittest(HashLibTestCase)


if __name__ == "__main__":
    test_main()

--- NEW FILE: test_hashlib_speed.py ---

import sys, time
import hashlib
from test import test_support


def creatorFunc():
    raise RuntimeError, "eek, creatorFunc not overridden"


def test_scaled_msg(scale, name):

    iterations = 106201/scale * 20
    longStr = 'Z'*scale

    localCF = creatorFunc
    start = time.time()
    for f in xrange(iterations):
        x = localCF(longStr).digest()
    end = time.time()

    print ('%2.2f' % (end-start)), "seconds", iterations, "x", len(longStr), "bytes", name

def test_create():
    start = time.time()
    for f in xrange(20000):
        d = creatorFunc()
    end = time.time()

    print ('%2.2f' % (end-start)), "seconds", '[20000 creations]'

def test_zero():
    start = time.time()
    for f in xrange(20000):
        x = creatorFunc().digest()
    end = time.time()

    print ('%2.2f' % (end-start)), "seconds", '[20000 "" digests]'



### this 'test' is not normally run.  skip it if the test runner finds it
if __name__ != '__main__':
    raise test_support.TestSkipped, "not a unit test (stand alone benchmark)"

hName = sys.argv[1]

#
# setup our creatorFunc to test the requested hash
#
if hName in ('_md5', '_sha'):
    exec 'import '+hName
    exec 'creatorFunc = '+hName+'.new'
    print "testing speed of old", hName, "legacy interface"
elif hName == '_hashlib' and len(sys.argv) > 3:
    import _hashlib
    exec 'creatorFunc = _hashlib.%s' % sys.argv[2]
    print "testing speed of _hashlib.%s" % sys.argv[2], getattr(_hashlib, sys.argv[2])
elif hName == '_hashlib' and len(sys.argv) == 3:
    import _hashlib
    exec 'creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2]
    print "testing speed of _hashlib.new(%r)" % sys.argv[2]
elif hasattr(hashlib, hName) and callable(getattr(hashlib, hName)):
    creatorFunc = getattr(hashlib, hName)
    print "testing speed of hashlib."+hName, getattr(hashlib, hName)
else:
    exec "creatorFunc = lambda x=hashlib.new : x(%r)" % hName
    print "testing speed of hashlib.new(%r)" % hName

try:
    test_create()
except ValueError:
    print
    print "pass argument(s) naming the hash to run a speed test on:"
    print " '_md5' and '_sha' test the legacy builtin md5 and sha"
    print " '_hashlib' 'openssl_hName' 'fast' tests the builtin _hashlib"
    print " '_hashlib' 'hName' tests builtin _hashlib.new(shaFOO)"
    print " 'hName' tests the hashlib.hName() implementation if it exists"
    print "         otherwise it uses hashlib.new(hName)."
    print
    raise

test_zero()
test_scaled_msg(scale=106201, name='[huge data]')
test_scaled_msg(scale=10620, name='[large data]')
test_scaled_msg(scale=1062, name='[medium data]')
test_scaled_msg(scale=424, name='[4*small data]')
test_scaled_msg(scale=336, name='[3*small data]')
test_scaled_msg(scale=212, name='[2*small data]')
test_scaled_msg(scale=106, name='[small data]')
test_scaled_msg(scale=creatorFunc().digest_size, name='[digest_size data]')
test_scaled_msg(scale=10, name='[tiny data]')

--- NEW FILE: test_xdrlib.py ---
import xdrlib

xdrlib._test()

Index: inspect_fodder2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/inspect_fodder2.py,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -d -r1.2.2.1 -r1.2.2.2
--- inspect_fodder2.py	7 Jan 2005 06:58:48 -0000	1.2.2.1
+++ inspect_fodder2.py	16 Oct 2005 05:24:00 -0000	1.2.2.2
@@ -1,25 +1,25 @@
 # line 1
 def wrap(foo=None):
-  def wrapper(func):
-    return func
-  return wrapper
+    def wrapper(func):
+        return func
+    return wrapper
 
 # line 7
 def replace(func):
-  def insteadfunc():
-    print 'hello'
-  return insteadfunc
+    def insteadfunc():
+        print 'hello'
+    return insteadfunc
 
 # line 13
 @wrap()
 @wrap(wrap)
 def wrapped():
-  pass
+    pass
 
 # line 19
 @replace
 def gone():
-  pass
+    pass
 
 # line 24
 oll = lambda m: m
@@ -53,3 +53,38 @@
 def setfunc(func):
     globals()["anonymous"] = func
 setfunc(lambda x, y: x*y)
+
+# line 57
+def with_comment():  # hello
+    world
+
+# line 61
+multiline_sig = [
+    lambda (x,
+            y): x+y,
+    None,
+    ]
+
+# line 68
+def func69():
+    class cls70:
+        def func71():
+            pass
+    return cls70
+extra74 = 74
+
+# line 76
+def func77(): pass
+(extra78, stuff78) = 'xy'
+extra79 = 'stop'
+
+# line 81
+class cls82:
+    def func83(): pass
+(extra84, stuff84) = 'xy'
+extra85 = 'stop'
+
+# line 87
+def func88():
+    # comment
+    return 90

Index: list_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/list_tests.py,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -d -r1.5.4.1 -r1.5.4.2
--- list_tests.py	7 Jan 2005 06:58:48 -0000	1.5.4.1
+++ list_tests.py	16 Oct 2005 05:24:00 -0000	1.5.4.2
@@ -309,6 +309,26 @@
         a = self.type2test([0, 1, 2, 3])
         self.assertRaises(BadExc, a.remove, BadCmp())
 
+        class BadCmp2:
+            def __eq__(self, other):
+                raise BadExc()
+
+        d = self.type2test('abcdefghcij')
+        d.remove('c')
+        self.assertEqual(d, self.type2test('abdefghcij'))
+        d.remove('c')
+        self.assertEqual(d, self.type2test('abdefghij'))
+        self.assertRaises(ValueError, d.remove, 'c')
+        self.assertEqual(d, self.type2test('abdefghij'))
+
+        # Handle comparison errors
+        d = self.type2test(['a', 'b', BadCmp2(), 'c'])
+        e = self.type2test(d)
+        self.assertRaises(BadExc, d.remove, 'c')
+        for x, y in zip(d, e):
+            # verify that original order and values are retained.
+            self.assert_(x is y)
+
     def test_count(self):
         a = self.type2test([0, 1, 2])*3
         self.assertEqual(a.count(0), 3)
@@ -494,3 +514,12 @@
         a = self.type2test(range(10))
         a[::2] = tuple(range(5))
         self.assertEqual(a, self.type2test([0, 1, 1, 3, 2, 5, 3, 7, 4, 9]))
+
+    def test_constructor_exception_handling(self):
+        # Bug #1242657
+        class F(object):
+            def __iter__(self):
+                yield 23
+            def __len__(self):
+                raise KeyboardInterrupt
+        self.assertRaises(KeyboardInterrupt, list, F())

Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.87.2.2
retrieving revision 1.87.2.3
diff -u -d -r1.87.2.2 -r1.87.2.3
--- regrtest.py	7 Jan 2005 06:58:48 -0000	1.87.2.2
+++ regrtest.py	16 Oct 2005 05:24:00 -0000	1.87.2.3
@@ -91,7 +91,11 @@
 
     compiler -  Test the compiler package by compiling all the source
                 in the standard library and test suite.  This takes
-                a long time.
+                a long time.  Enabling this resource also allows
+                test_tokenize to verify round-trip lexing on every
+                file in the test library.
+
+    subprocess  Run all tests for the subprocess module.
 
 To enable all resources except one, use '-uall,-<resource>'.  For
 example, to run all the tests except for the bsddb tests, give the
@@ -136,7 +140,7 @@
 from test import test_support
 
 RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
-                  'decimal', 'compiler')
+                  'decimal', 'compiler', 'subprocess')
 
 
 def usage(code, msg=''):
@@ -487,6 +491,7 @@
                 import gc
                 def cleanup():
                     import _strptime, urlparse, warnings, dircache
+                    import linecache
                     from distutils.dir_util import _path_created
                     _path_created.clear()
                     warnings.filters[:] = fs
@@ -499,6 +504,7 @@
                     sys.path_importer_cache.clear()
                     sys.path_importer_cache.update(pic)
                     dircache.reset()
+                    linecache.clearcache()
                 if indirect_test:
                     def run_the_test():
                         indirect_test()
@@ -1064,9 +1070,38 @@
         test_winreg
         test_winsound
         """,
+    'aix5':
+        """
+        test_aepack
+        test_al
+        test_applesingle
+        test_bsddb
+        test_bsddb185
+        test_bsddb3
+        test_bz2
+        test_cd
+        test_cl
+        test_dl
+        test_gdbm
+        test_gl
+        test_gzip
+        test_imgfile
+        test_linuxaudiodev
+        test_macfs
+        test_macostools
+        test_nis
+        test_ossaudiodev
+        test_sunaudiodev
+        test_tcl
+        test_winreg
+        test_winsound
+        test_zipimport
+        test_zlib
+        """,
 }
 _expectations['freebsd5'] = _expectations['freebsd4']
 _expectations['freebsd6'] = _expectations['freebsd4']
+_expectations['freebsd7'] = _expectations['freebsd4']
 
 class _ExpectedSkips:
     def __init__(self):
@@ -1083,6 +1118,9 @@
             s = _expectations[sys.platform]
             self.expected = set(s.split())
 
+            # this isn't a regularly run unit test, it is always skipped
+            self.expected.add('test_hashlib_speed')
+
             if not os.path.supports_unicode_filenames:
                 self.expected.add('test_pep277')
 

Index: seq_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/seq_tests.py,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -u -d -r1.3.4.1 -r1.3.4.2
--- seq_tests.py	7 Jan 2005 06:58:49 -0000	1.3.4.1
+++ seq_tests.py	16 Oct 2005 05:24:00 -0000	1.3.4.2
@@ -5,6 +5,85 @@
 import unittest
 from test import test_support
 
+# Various iterables
+# This is used for checking the constructor (here and in test_deque.py)
+def iterfunc(seqn):
+    'Regular generator'
+    for i in seqn:
+        yield i
+
+class Sequence:
+    'Sequence using __getitem__'
+    def __init__(self, seqn):
+        self.seqn = seqn
+    def __getitem__(self, i):
+        return self.seqn[i]
+
+class IterFunc:
+    'Sequence using iterator protocol'
+    def __init__(self, seqn):
+        self.seqn = seqn
+        self.i = 0
+    def __iter__(self):
+        return self
+    def next(self):
+        if self.i >= len(self.seqn): raise StopIteration
+        v = self.seqn[self.i]
+        self.i += 1
+        return v
+
+class IterGen:
+    'Sequence using iterator protocol defined with a generator'
+    def __init__(self, seqn):
+        self.seqn = seqn
+        self.i = 0
+    def __iter__(self):
+        for val in self.seqn:
+            yield val
+
+class IterNextOnly:
+    'Missing __getitem__ and __iter__'
+    def __init__(self, seqn):
+        self.seqn = seqn
+        self.i = 0
+    def next(self):
+        if self.i >= len(self.seqn): raise StopIteration
+        v = self.seqn[self.i]
+        self.i += 1
+        return v
+
+class IterNoNext:
+    'Iterator missing next()'
+    def __init__(self, seqn):
+        self.seqn = seqn
+        self.i = 0
+    def __iter__(self):
+        return self
+
+class IterGenExc:
+    'Test propagation of exceptions'
+    def __init__(self, seqn):
+        self.seqn = seqn
+        self.i = 0
+    def __iter__(self):
+        return self
+    def next(self):
+        3 // 0
+
+class IterFuncStop:
+    'Test immediate stop'
+    def __init__(self, seqn):
+        pass
+    def __iter__(self):
+        return self
+    def next(self):
+        raise StopIteration
+
+from itertools import chain, imap
+def itermulti(seqn):
+    'Test multiple tiers of iterators'
+    return chain(imap(lambda x:x, iterfunc(IterGen(Sequence(seqn)))))
+
 class CommonTest(unittest.TestCase):
     # The type to be tested
     type2test = None
@@ -40,6 +119,17 @@
         vv = self.type2test(s)
         self.assertEqual(len(vv), len(s))
 
+        # Create from various iteratables
+        for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+            for g in (Sequence, IterFunc, IterGen,
+                      itermulti, iterfunc):
+                self.assertEqual(self.type2test(g(s)), self.type2test(s))
+            self.assertEqual(self.type2test(IterFuncStop(s)), self.type2test())
+            self.assertEqual(self.type2test(c for c in "123"), self.type2test("123"))
+            self.assertRaises(TypeError, self.type2test, IterNextOnly(s))
+            self.assertRaises(TypeError, self.type2test, IterNoNext(s))
+            self.assertRaises(ZeroDivisionError, self.type2test, IterGenExc(s))
+
     def test_truth(self):
         self.assert_(not self.type2test())
         self.assert_(self.type2test([42]))
@@ -117,6 +207,33 @@
 
         self.assertRaises(TypeError, u.__contains__)
 
+    def test_contains_fake(self):
+        class AllEq:
+            # Sequences must use rich comparison against each item
+            # (unless "is" is true, or an earlier item answered)
+            # So instances of AllEq must be found in all non-empty sequences.
+            def __eq__(self, other):
+                return True
+            def __hash__(self):
+                raise NotImplemented
+        self.assert_(AllEq() not in self.type2test([]))
+        self.assert_(AllEq() in self.type2test([1]))
+
+    def test_contains_order(self):
+        # Sequences must test in-order.  If a rich comparison has side
+        # effects, these will be visible to tests against later members.
+        # In this test, the "side effect" is a short-circuiting raise.
+        class DoNotTestEq(Exception):
+            pass
+        class StopCompares:
+            def __eq__(self, other):
+                raise DoNotTestEq
+
+        checkfirst = self.type2test([1, StopCompares()])
+        self.assert_(1 in checkfirst)
+        checklast = self.type2test([StopCompares(), 1])
+        self.assertRaises(DoNotTestEq, checklast.__contains__, 1)
+
     def test_len(self):
         self.assertEqual(len(self.type2test()), 0)
         self.assertEqual(len(self.type2test([])), 0)

Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.18.2.2
retrieving revision 1.18.2.3
diff -u -d -r1.18.2.2 -r1.18.2.3
--- string_tests.py	7 Jan 2005 06:58:49 -0000	1.18.2.2
+++ string_tests.py	16 Oct 2005 05:24:00 -0000	1.18.2.3
@@ -114,6 +114,33 @@
         self.checkraises(TypeError, 'hello', 'count')
         self.checkraises(TypeError, 'hello', 'count', 42)
 
+        # For a variety of combinations,
+        #    verify that str.count() matches an equivalent function
+        #    replacing all occurrences and then differencing the string lengths
+        charset = ['', 'a', 'b']
+        digits = 7
+        base = len(charset)
+        teststrings = set()
+        for i in xrange(base ** digits):
+            entry = []
+            for j in xrange(digits):
+                i, m = divmod(i, base)
+                entry.append(charset[m])
+            teststrings.add(''.join(entry))
+        teststrings = list(teststrings)
+        for i in teststrings:
+            i = self.fixtype(i)
+            n = len(i)
+            for j in teststrings:
+                r1 = i.count(j)
+                if j:
+                    r2, rem = divmod(n - len(i.replace(j, '')), len(j))
+                else:
+                    r2, rem = len(i)+1, 0
+                if rem or r1 != r2:
+                    self.assertEqual(rem, 0)
+                    self.assertEqual(r1, r2)
+
     def test_find(self):
         self.checkequal(0, 'abcdefghiabc', 'find', 'abc')
         self.checkequal(9, 'abcdefghiabc', 'find', 'abc', 1)
@@ -122,6 +149,31 @@
         self.checkraises(TypeError, 'hello', 'find')
         self.checkraises(TypeError, 'hello', 'find', 42)
 
+        # For a variety of combinations,
+        #    verify that str.find() matches __contains__
+        #    and that the found substring is really at that location
+        charset = ['', 'a', 'b', 'c']
+        digits = 5
+        base = len(charset)
+        teststrings = set()
+        for i in xrange(base ** digits):
+            entry = []
+            for j in xrange(digits):
+                i, m = divmod(i, base)
+                entry.append(charset[m])
+            teststrings.add(''.join(entry))
+        teststrings = list(teststrings)
+        for i in teststrings:
+            i = self.fixtype(i)
+            for j in teststrings:
+                loc = i.find(j)
+                r1 = (loc != -1)
+                r2 = j in i
+                if r1 != r2:
+                    self.assertEqual(r1, r2)
+                if loc != -1:
+                    self.assertEqual(i[loc:loc+len(j)], j)
+
     def test_rfind(self):
         self.checkequal(9,  'abcdefghiabc', 'rfind', 'abc')
         self.checkequal(12, 'abcdefghiabc', 'rfind', '')
@@ -685,26 +737,27 @@
     # Additional tests that only work with
     # 8bit compatible object, i.e. str and UserString
 
-    def test_encoding_decoding(self):
-        codecs = [('rot13', 'uryyb jbeyq'),
-                  ('base64', 'aGVsbG8gd29ybGQ=\n'),
-                  ('hex', '68656c6c6f20776f726c64'),
-                  ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')]
-        for encoding, data in codecs:
-            self.checkequal(data, 'hello world', 'encode', encoding)
-            self.checkequal('hello world', data, 'decode', encoding)
-        # zlib is optional, so we make the test optional too...
-        try:
-            import zlib
-        except ImportError:
-            pass
-        else:
-            data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]'
-            self.checkequal(data, 'hello world', 'encode', 'zlib')
-            self.checkequal('hello world', data, 'decode', 'zlib')
+    if test_support.have_unicode:
+        def test_encoding_decoding(self):
+            codecs = [('rot13', 'uryyb jbeyq'),
+                      ('base64', 'aGVsbG8gd29ybGQ=\n'),
+                      ('hex', '68656c6c6f20776f726c64'),
+                      ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')]
+            for encoding, data in codecs:
+                self.checkequal(data, 'hello world', 'encode', encoding)
+                self.checkequal('hello world', data, 'decode', encoding)
+            # zlib is optional, so we make the test optional too...
+            try:
+                import zlib
+            except ImportError:
+                pass
+            else:
+                data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]'
+                self.checkequal(data, 'hello world', 'encode', 'zlib')
+                self.checkequal('hello world', data, 'decode', 'zlib')
 
-        self.checkraises(TypeError, 'xyz', 'decode', 42)
-        self.checkraises(TypeError, 'xyz', 'encode', 42)
+            self.checkraises(TypeError, 'xyz', 'decode', 42)
+            self.checkraises(TypeError, 'xyz', 'encode', 42)
 
 
 class MixinStrUnicodeTest:

Index: test_StringIO.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_StringIO.py,v
retrieving revision 1.13.2.2
retrieving revision 1.13.2.3
diff -u -d -r1.13.2.2 -r1.13.2.3
--- test_StringIO.py	7 Jan 2005 06:58:49 -0000	1.13.2.2
+++ test_StringIO.py	16 Oct 2005 05:24:00 -0000	1.13.2.3
@@ -44,6 +44,13 @@
         f.seek(0)
         self.assertEqual(f.getvalue(), 'abc')
 
+    def test_writelines_error(self):
+        def errorGen():
+            yield 'a'
+            raise KeyboardInterrupt()
+        f = self.MODULE.StringIO()
+        self.assertRaises(KeyboardInterrupt, f.writelines, errorGen())
+
     def test_truncate(self):
         eq = self.assertEqual
         f = self.MODULE.StringIO()

Index: test__locale.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test__locale.py,v
retrieving revision 1.8.4.1
retrieving revision 1.8.4.2
diff -u -d -r1.8.4.1 -r1.8.4.2
--- test__locale.py	7 Jan 2005 06:58:49 -0000	1.8.4.1
+++ test__locale.py	16 Oct 2005 05:24:00 -0000	1.8.4.2
@@ -2,6 +2,12 @@
 from _locale import (setlocale, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo,
                     localeconv, Error)
 import unittest
+from platform import uname
+
+if uname()[0] == "Darwin":
+    maj, min, mic = [int(part) for part in uname()[2].split(".")]
+    if (maj, min, mic) < (8, 0, 0):
+        raise TestSkipped("locale support broken for OS X < 10.4")
 
 candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT',
     'et_EE', 'es_PY', 'no_NO', 'nl_NL', 'lv_LV', 'el_GR', 'be_BY', 'fr_BE',
@@ -11,9 +17,14 @@
     'da_DK', 'nn_NO', 'cs_CZ', 'de_LU', 'es_BO', 'sq_AL', 'sk_SK', 'fr_CH',
     'de_DE', 'sr_YU', 'br_FR', 'nl_BE', 'sv_FI', 'pl_PL', 'fr_CA', 'fo_FO',
     'bs_BA', 'fr_LU', 'kl_GL', 'fa_IR', 'de_BE', 'sv_SE', 'it_CH', 'uk_UA',
-    'eu_ES', 'vi_VN', 'af_ZA', 'nb_NO', 'en_DK', 'tg_TJ',
+    'eu_ES', 'vi_VN', 'af_ZA', 'nb_NO', 'en_DK', 'tg_TJ', 'en_US',
     'es_ES.ISO8859-1', 'fr_FR.ISO8859-15', 'ru_RU.KOI8-R', 'ko_KR.eucKR']
 
+# List known locale values to test against when available.
+# Dict formatted as ``<locale> : (<decimal_point>, <thousands_sep>)``.  If a
+# value is not known, use '' .
+known_numerics = {'fr_FR' : (',', ''), 'en_US':('.', ',')}
+
 class _LocaleTests(unittest.TestCase):
 
     def setUp(self):
@@ -22,7 +33,50 @@
     def tearDown(self):
         setlocale(LC_NUMERIC, self.oldlocale)
 
-    def test_lc_numeric(self):
+    # Want to know what value was calculated, what it was compared against,
+    # what function was used for the calculation, what type of data was used,
+    # the locale that was supposedly set, and the actual locale that is set.
+    lc_numeric_err_msg = "%s != %s (%s for %s; set to %s, using %s)"
+
+    def numeric_tester(self, calc_type, calc_value, data_type, used_locale):
+        """Compare calculation against known value, if available"""
+        try:
+            set_locale = setlocale(LC_NUMERIC)
+        except Error:
+            set_locale = "<not able to determine>"
+        known_value = known_numerics.get(used_locale,
+                                    ('', ''))[data_type is 'thousands_sep']
+        if known_value and calc_value:
+            self.assertEquals(calc_value, known_value,
+                                self.lc_numeric_err_msg % (
+                                    calc_value, known_value,
+                                    calc_type, data_type, set_locale,
+                                    used_locale))
+
+    def test_lc_numeric_nl_langinfo(self):
+        # Test nl_langinfo against known values
+        for loc in candidate_locales:
+            try:
+                setlocale(LC_NUMERIC, loc)
+            except Error:
+                continue
+            for li, lc in ((RADIXCHAR, "decimal_point"),
+                            (THOUSEP, "thousands_sep")):
+                self.numeric_tester('nl_langinfo', nl_langinfo(li), lc, loc)
+
+    def test_lc_numeric_localeconv(self):
+        # Test localeconv against known values
+        for loc in candidate_locales:
+            try:
+                setlocale(LC_NUMERIC, loc)
+            except Error:
+                continue
+            for li, lc in ((RADIXCHAR, "decimal_point"),
+                            (THOUSEP, "thousands_sep")):
+                self.numeric_tester('localeconv', localeconv()[lc], lc, loc)
+
+    def test_lc_numeric_basic(self):
+        # Test nl_langinfo against localeconv
         for loc in candidate_locales:
             try:
                 setlocale(LC_NUMERIC, loc)
@@ -32,18 +86,17 @@
                             (THOUSEP, "thousands_sep")):
                 nl_radixchar = nl_langinfo(li)
                 li_radixchar = localeconv()[lc]
-                # Both with seeing what the locale is set to in order to detect
-                # when setlocale lies and says it accepted the locale setting
-                # but in actuality didn't use it (as seen in OS X 10.3)
                 try:
                     set_locale = setlocale(LC_NUMERIC)
                 except Error:
                     set_locale = "<not able to determine>"
                 self.assertEquals(nl_radixchar, li_radixchar,
-                                    "%s != %s (%s); "
-                                    "supposed to be %s, set to %s" %
-                                        (nl_radixchar, li_radixchar, lc,
-                                         loc, set_locale))
+                                "%s (nl_langinfo) != %s (localeconv) "
+                                "(set to %s, using %s)" % (
+                                                nl_radixchar, li_radixchar,
+                                                loc, set_locale))
+
+
 
 def test_main():
     run_unittest(_LocaleTests)

Index: test_al.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_al.py,v
retrieving revision 1.6.26.1
retrieving revision 1.6.26.2
diff -u -d -r1.6.26.1 -r1.6.26.2
--- test_al.py	28 Apr 2003 17:29:11 -0000	1.6.26.1
+++ test_al.py	16 Oct 2005 05:24:00 -0000	1.6.26.2
@@ -8,7 +8,7 @@
 alattrs = ['__doc__', '__name__', 'getdefault', 'getminmax', 'getname', 'getparams',
            'newconfig', 'openport', 'queryparams', 'setparams']
 
-# This is a very unobtrusive test for the existence of the al module and all it's
+# This is a very unobtrusive test for the existence of the al module and all its
 # attributes.  More comprehensive examples can be found in Demo/al
 
 def main():

Index: test_array.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -d -r1.16.2.2 -r1.16.2.3
--- test_array.py	7 Jan 2005 06:58:49 -0000	1.16.2.2
+++ test_array.py	16 Oct 2005 05:24:00 -0000	1.16.2.3
@@ -428,6 +428,11 @@
         )
 
         self.assertEqual(
+            a[2:1],
+            array.array(self.typecode)
+        )
+
+        self.assertEqual(
             a[1000:],
             array.array(self.typecode)
         )

Index: test_asynchat.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_asynchat.py,v
retrieving revision 1.4.24.1
retrieving revision 1.4.24.2
diff -u -d -r1.4.24.1 -r1.4.24.2
--- test_asynchat.py	7 Jan 2005 06:58:49 -0000	1.4.24.1
+++ test_asynchat.py	16 Oct 2005 05:24:00 -0000	1.4.24.2
@@ -2,9 +2,11 @@
 
 import thread # If this fails, we can't test this module
 import asyncore, asynchat, socket, threading, time
+import unittest
+from test import test_support
 
 HOST = "127.0.0.1"
-PORT = 54321
+PORT = 54322
 
 class echo_server(threading.Thread):
 
@@ -16,7 +18,7 @@
         conn, client = sock.accept()
         buffer = ""
         while "\n" not in buffer:
-            data = conn.recv(10)
+            data = conn.recv(1)
             if not data:
                 break
             buffer = buffer + data
@@ -28,31 +30,63 @@
 
 class echo_client(asynchat.async_chat):
 
-    def __init__(self):
+    def __init__(self, terminator):
         asynchat.async_chat.__init__(self)
+        self.contents = None
         self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
         self.connect((HOST, PORT))
-        self.set_terminator("\n")
+        self.set_terminator(terminator)
         self.buffer = ""
 
     def handle_connect(self):
-        print "Connected"
+        pass
+        ##print "Connected"
 
     def collect_incoming_data(self, data):
         self.buffer = self.buffer + data
 
     def found_terminator(self):
-        print "Received:", repr(self.buffer)
+        #print "Received:", repr(self.buffer)
+        self.contents = self.buffer
         self.buffer = ""
         self.close()
 
-def main():
-    s = echo_server()
-    s.start()
-    time.sleep(1) # Give server time to initialize
-    c = echo_client()
-    c.push("hello ")
-    c.push("world\n")
-    asyncore.loop()
 
-main()
+class TestAsynchat(unittest.TestCase):
+    def setUp (self):
+        pass
+
+    def tearDown (self):
+        pass
+
+    def test_line_terminator(self):
+        s = echo_server()
+        s.start()
+        time.sleep(1) # Give server time to initialize
+        c = echo_client('\n')
+        c.push("hello ")
+        c.push("world\n")
+        asyncore.loop()
+        s.join()
+
+        self.assertEqual(c.contents, 'hello world')
+
+    def test_numeric_terminator(self):
+        # Try reading a fixed number of bytes
+        s = echo_server()
+        s.start()
+        time.sleep(1) # Give server time to initialize
+        c = echo_client(6L)
+        c.push("hello ")
+        c.push("world\n")
+        asyncore.loop()
+        s.join()
+
+        self.assertEqual(c.contents, 'hello ')
+
+
+def test_main(verbose=None):
+    test_support.run_unittest(TestAsynchat)
+
+if __name__ == "__main__":
+    test_main(verbose=True)

Index: test_base64.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_base64.py,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -d -r1.2.2.2 -r1.2.2.3
--- test_base64.py	7 Jan 2005 06:58:49 -0000	1.2.2.2
+++ test_base64.py	16 Oct 2005 05:24:00 -0000	1.2.2.3
@@ -60,6 +60,7 @@
         eq = self.assertEqual
         # Test default alphabet
         eq(base64.b64encode("www.python.org"), "d3d3LnB5dGhvbi5vcmc=")
+        eq(base64.b64encode('\x00'), 'AA==')
         eq(base64.b64encode("a"), "YQ==")
         eq(base64.b64encode("ab"), "YWI=")
         eq(base64.b64encode("abc"), "YWJj")
@@ -90,6 +91,7 @@
     def test_b64decode(self):
         eq = self.assertEqual
         eq(base64.b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
+        eq(base64.b64decode('AA=='), '\x00')
         eq(base64.b64decode("YQ=="), "a")
         eq(base64.b64decode("YWI="), "ab")
         eq(base64.b64decode("YWJj"), "abc")
@@ -123,6 +125,7 @@
     def test_b32encode(self):
         eq = self.assertEqual
         eq(base64.b32encode(''), '')
+        eq(base64.b32encode('\x00'), 'AA======')
         eq(base64.b32encode('a'), 'ME======')
         eq(base64.b32encode('ab'), 'MFRA====')
         eq(base64.b32encode('abc'), 'MFRGG===')
@@ -132,6 +135,7 @@
     def test_b32decode(self):
         eq = self.assertEqual
         eq(base64.b32decode(''), '')
+        eq(base64.b32decode('AA======'), '\x00')
         eq(base64.b32decode('ME======'), 'a')
         eq(base64.b32decode('MFRA===='), 'ab')
         eq(base64.b32decode('MFRGG==='), 'abc')
@@ -166,10 +170,12 @@
     def test_b16encode(self):
         eq = self.assertEqual
         eq(base64.b16encode('\x01\x02\xab\xcd\xef'), '0102ABCDEF')
+        eq(base64.b16encode('\x00'), '00')
 
     def test_b16decode(self):
         eq = self.assertEqual
         eq(base64.b16decode('0102ABCDEF'), '\x01\x02\xab\xcd\xef')
+        eq(base64.b16decode('00'), '\x00')
         # Lower case is not allowed without a flag
         self.assertRaises(TypeError, base64.b16decode, '0102abcdef')
         # Case fold

Index: test_binop.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binop.py,v
retrieving revision 1.6.14.1
retrieving revision 1.6.14.2
diff -u -d -r1.6.14.1 -r1.6.14.2
--- test_binop.py	28 Apr 2003 17:29:08 -0000	1.6.14.1
+++ test_binop.py	16 Oct 2005 05:24:00 -0000	1.6.14.2
@@ -178,7 +178,7 @@
         return (x, self - other * x)
 
     def __rdivmod__(self, other):
-        "Divide two Rats, returning quotient and remainder (reversed args)."""
+        """Divide two Rats, returning quotient and remainder (reversed args)."""
         if isint(other):
             other = Rat(other)
         elif not isRat(other):

Index: test_bisect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bisect.py,v
retrieving revision 1.1.26.2
retrieving revision 1.1.26.3
diff -u -d -r1.1.26.2 -r1.1.26.3
--- test_bisect.py	7 Jan 2005 06:58:49 -0000	1.1.26.2
+++ test_bisect.py	16 Oct 2005 05:24:00 -0000	1.1.26.3
@@ -130,6 +130,16 @@
     def test_backcompatibility(self):
         self.assertEqual(bisect, bisect_right)
 
+    def test_keyword_args(self):
+        data = [10, 20, 30, 40, 50]
+        self.assertEqual(bisect_left(a=data, x=25, lo=1, hi=3), 2)
+        self.assertEqual(bisect_right(a=data, x=25, lo=1, hi=3), 2)
+        self.assertEqual(bisect(a=data, x=25, lo=1, hi=3), 2)
+        insort_left(a=data, x=25, lo=1, hi=3)
+        insort_right(a=data, x=25, lo=1, hi=3)
+        insort(a=data, x=25, lo=1, hi=3)
+        self.assertEqual(data, [10, 20, 25, 25, 25, 30, 40, 50])
+
 #==============================================================================
 
 class TestInsort(unittest.TestCase):

Index: test_builtin.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v
retrieving revision 1.1.36.2
retrieving revision 1.1.36.3
diff -u -d -r1.1.36.2 -r1.1.36.3
--- test_builtin.py	7 Jan 2005 06:58:49 -0000	1.1.36.2
+++ test_builtin.py	16 Oct 2005 05:24:00 -0000	1.1.36.3
@@ -92,6 +92,14 @@
         (unichr(0x200), ValueError),
 ]
 
+class TestFailingBool:
+    def __nonzero__(self):
+        raise RuntimeError
+
+class TestFailingIter:
+    def __iter__(self):
+        raise RuntimeError
+
 class BuiltinTest(unittest.TestCase):
 
     def test_import(self):
@@ -117,6 +125,34 @@
         # str
         self.assertRaises(TypeError, abs, 'a')
 
+    def test_all(self):
+        self.assertEqual(all([2, 4, 6]), True)
+        self.assertEqual(all([2, None, 6]), False)
+        self.assertRaises(RuntimeError, all, [2, TestFailingBool(), 6])
+        self.assertRaises(RuntimeError, all, TestFailingIter())
+        self.assertRaises(TypeError, all, 10)               # Non-iterable
+        self.assertRaises(TypeError, all)                   # No args
+        self.assertRaises(TypeError, all, [2, 4, 6], [])    # Too many args
+        self.assertEqual(all([]), True)                     # Empty iterator
+        S = [50, 60]
+        self.assertEqual(all(x > 42 for x in S), True)
+        S = [50, 40, 60]
+        self.assertEqual(all(x > 42 for x in S), False)
+
+    def test_any(self):
+        self.assertEqual(any([None, None, None]), False)
+        self.assertEqual(any([None, 4, None]), True)
+        self.assertRaises(RuntimeError, any, [None, TestFailingBool(), 6])
+        self.assertRaises(RuntimeError, all, TestFailingIter())
+        self.assertRaises(TypeError, any, 10)               # Non-iterable
+        self.assertRaises(TypeError, any)                   # No args
+        self.assertRaises(TypeError, any, [2, 4, 6], [])    # Too many args
+        self.assertEqual(any([]), False)                    # Empty iterator
+        S = [40, 60, 30]
+        self.assertEqual(any(x > 42 for x in S), True)
+        S = [10, 20, 30]
+        self.assertEqual(any(x > 42 for x in S), False)
+
     def test_apply(self):
         def f0(*args):
             self.assertEqual(args, ())
@@ -509,20 +545,53 @@
             self.assertEqual(float(unicode("  3.14  ")), 3.14)
             self.assertEqual(float(unicode("  \u0663.\u0661\u0664  ",'raw-unicode-escape')), 3.14)
 
+    def test_floatconversion(self):
+        # Make sure that calls to __float__() work properly
+        class Foo0:
+            def __float__(self):
+                return 42.
+
+        class Foo1(object):
+            def __float__(self):
+                return 42.
+
+        class Foo2(float):
+            def __float__(self):
+                return 42.
+
+        class Foo3(float):
+            def __new__(cls, value=0.):
+                return float.__new__(cls, 2*value)
+
+            def __float__(self):
+                return self
+
+        class Foo4(float):
+            def __float__(self):
+                return 42
+
+        self.assertAlmostEqual(float(Foo0()), 42.)
+        self.assertAlmostEqual(float(Foo1()), 42.)
+        self.assertAlmostEqual(float(Foo2()), 42.)
+        self.assertAlmostEqual(float(Foo3(21)), 42.)
+        self.assertRaises(TypeError, float, Foo4(42))
+
     def test_getattr(self):
         import sys
         self.assert_(getattr(sys, 'stdout') is sys.stdout)
         self.assertRaises(TypeError, getattr, sys, 1)
         self.assertRaises(TypeError, getattr, sys, 1, "foo")
         self.assertRaises(TypeError, getattr)
-        self.assertRaises(UnicodeError, getattr, sys, unichr(sys.maxunicode))
+        if have_unicode:
+            self.assertRaises(UnicodeError, getattr, sys, unichr(sys.maxunicode))
 
     def test_hasattr(self):
         import sys
         self.assert_(hasattr(sys, 'stdout'))
         self.assertRaises(TypeError, hasattr, sys, 1)
         self.assertRaises(TypeError, hasattr)
-        self.assertRaises(UnicodeError, hasattr, sys, unichr(sys.maxunicode))
+        if have_unicode:
+            self.assertRaises(UnicodeError, hasattr, sys, unichr(sys.maxunicode))
 
     def test_hash(self):
         hash(None)
@@ -614,6 +683,39 @@
 
         self.assertEqual(int('0123', 0), 83)
 
+    def test_intconversion(self):
+        # Test __int__()
+        class Foo0:
+            def __int__(self):
+                return 42
+
+        class Foo1(object):
+            def __int__(self):
+                return 42
+
+        class Foo2(int):
+            def __int__(self):
+                return 42
+
+        class Foo3(int):
+            def __int__(self):
+                return self
+
+        class Foo4(int):
+            def __int__(self):
+                return 42L
+
+        class Foo5(int):
+            def __int__(self):
+                return 42.
+
+        self.assertEqual(int(Foo0()), 42)
+        self.assertEqual(int(Foo1()), 42)
+        self.assertEqual(int(Foo2()), 42)
+        self.assertEqual(int(Foo3()), 0)
+        self.assertEqual(int(Foo4()), 42L)
+        self.assertRaises(TypeError, int, Foo5())
+
     def test_intern(self):
         self.assertRaises(TypeError, intern)
         s = "never interned before"
@@ -774,6 +876,39 @@
         self.assertRaises(ValueError, long, '53', 40)
         self.assertRaises(TypeError, long, 1, 12)
 
+    def test_longconversion(self):
+        # Test __long__()
+        class Foo0:
+            def __long__(self):
+                return 42L
+
+        class Foo1(object):
+            def __long__(self):
+                return 42L
+
+        class Foo2(long):
+            def __long__(self):
+                return 42L
+
+        class Foo3(long):
+            def __long__(self):
+                return self
+
+        class Foo4(long):
+            def __long__(self):
+                return 42
+
+        class Foo5(long):
+            def __long__(self):
+                return 42.
+
+        self.assertEqual(long(Foo0()), 42L)
+        self.assertEqual(long(Foo1()), 42L)
+        self.assertEqual(long(Foo2()), 42L)
+        self.assertEqual(long(Foo3()), 0)
+        self.assertEqual(long(Foo4()), 42)
+        self.assertRaises(TypeError, long, Foo5())
+
     def test_map(self):
         self.assertEqual(
             map(None, 'hello world'),
@@ -968,7 +1103,8 @@
         if have_unicode:
             self.assertEqual(ord(unichr(sys.maxunicode)), sys.maxunicode)
         self.assertRaises(TypeError, ord, 42)
-        self.assertRaises(TypeError, ord, unicode("12"))
+        if have_unicode:
+            self.assertRaises(TypeError, ord, unicode("12"))
 
     def test_pow(self):
         self.assertEqual(pow(0,0), 1)
@@ -1274,17 +1410,18 @@
             self.assertRaises(ValueError, unichr, sys.maxunicode+1)
             self.assertRaises(TypeError, unichr)
 
+    # We don't want self in vars(), so these are static methods
+
+    @staticmethod
     def get_vars_f0():
         return vars()
-    # we don't want self in vars(), so use staticmethod
-    get_vars_f0 = staticmethod(get_vars_f0)
 
+    @staticmethod
     def get_vars_f2():
         BuiltinTest.get_vars_f0()
         a = 1
         b = 2
         return vars()
-    get_vars_f2 = staticmethod(get_vars_f2)
 
     def test_vars(self):
         self.assertEqual(set(vars()), set(dir()))
@@ -1360,11 +1497,17 @@
 
     def test_inputtypes(self):
         s = 'abracadabra'
-        for T in [unicode, list, tuple]:
+        types = [list, tuple]
+        if have_unicode:
+            types.insert(0, unicode)
+        for T in types:
             self.assertEqual(sorted(s), sorted(T(s)))
 
         s = ''.join(dict.fromkeys(s).keys())  # unique letters only
-        for T in [unicode, set, frozenset, list, tuple, dict.fromkeys]:
+        types = [set, frozenset, list, tuple, dict.fromkeys]
+        if have_unicode:
+            types.insert(0, unicode)
+        for T in types:
             self.assertEqual(sorted(s), sorted(T(s)))
 
     def test_baddecorator(self):

Index: test_bz2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bz2.py,v
retrieving revision 1.12.8.2
retrieving revision 1.12.8.3
diff -u -d -r1.12.8.2 -r1.12.8.3
--- test_bz2.py	7 Jan 2005 06:58:49 -0000	1.12.8.2
+++ test_bz2.py	16 Oct 2005 05:24:00 -0000	1.12.8.3
@@ -37,7 +37,7 @@
             return bz2.decompress(data)
 
 class BZ2FileTest(BaseTest):
-    "Test MCRYPT type miscelaneous methods."
+    "Test BZ2File type miscellaneous methods."
 
     def setUp(self):
         self.filename = TESTFN
@@ -235,6 +235,32 @@
         # "Test opening a nonexistent file"
         self.assertRaises(IOError, BZ2File, "/non/existent")
 
+    def testModeU(self):
+        # Bug #1194181: bz2.BZ2File opened for write with mode "U"
+        self.createTempFile()
+        bz2f = BZ2File(self.filename, "U")
+        bz2f.close()
+        f = file(self.filename)
+        f.seek(0, 2)
+        self.assertEqual(f.tell(), len(self.DATA))
+        f.close()
+
+    def testBug1191043(self):
+        # readlines() for files containing no newline
+        data = 'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t'
+        f = open(self.filename, "wb")
+        f.write(data)
+        f.close()
+        bz2f = BZ2File(self.filename)
+        lines = bz2f.readlines()
+        bz2f.close()
+        self.assertEqual(lines, ['Test'])
+        bz2f = BZ2File(self.filename)
+        xlines = list(bz2f.xreadlines())
+        bz2f.close()
+        self.assertEqual(lines, ['Test'])
+
+
 class BZ2CompressorTest(BaseTest):
     def testCompress(self):
         # "Test BZ2Compressor.compress()/flush()"

Index: test_cd.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cd.py,v
retrieving revision 1.5.26.1
retrieving revision 1.5.26.2
diff -u -d -r1.5.26.1 -r1.5.26.2
--- test_cd.py	28 Apr 2003 17:29:04 -0000	1.5.26.1
+++ test_cd.py	16 Oct 2005 05:24:00 -0000	1.5.26.2
@@ -10,7 +10,7 @@
            'ident', 'index', 'msftoframe', 'open', 'pnum', 'ptime']
 
 
-# This is a very inobtrusive test for the existence of the cd module and all it's
+# This is a very inobtrusive test for the existence of the cd module and all its
 # attributes.  More comprehensive examples can be found in Demo/cd and
 # require that you have a CD and a CD ROM drive
 

Index: test_cl.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cl.py,v
retrieving revision 1.5.26.1
retrieving revision 1.5.26.2
diff -u -d -r1.5.26.1 -r1.5.26.2
--- test_cl.py	28 Apr 2003 17:29:02 -0000	1.5.26.1
+++ test_cl.py	16 Oct 2005 05:24:00 -0000	1.5.26.2
@@ -64,7 +64,7 @@
 
 
 # This is a very inobtrusive test for the existence of the cl
-# module and all it's attributes.
+# module and all its attributes.
 
 def main():
     # touch all the attributes of al without doing anything

Index: test_class.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_class.py,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -u -d -r1.8.2.2 -r1.8.2.3
--- test_class.py	7 Jan 2005 06:58:50 -0000	1.8.2.2
+++ test_class.py	16 Oct 2005 05:24:00 -0000	1.8.2.3
@@ -353,7 +353,7 @@
 try:
     A().a # Raised AttributeError: A instance has no attribute 'a'
 except AttributeError, x:
-    if str(x) is not "booh":
+    if str(x) != "booh":
         print "attribute error for A().a got masked:", str(x)
 
 class E:

Index: test_codeccallbacks.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codeccallbacks.py,v
retrieving revision 1.10.8.2
retrieving revision 1.10.8.3
diff -u -d -r1.10.8.2 -r1.10.8.3
--- test_codeccallbacks.py	7 Jan 2005 06:58:50 -0000	1.10.8.2
+++ test_codeccallbacks.py	16 Oct 2005 05:24:00 -0000	1.10.8.3
@@ -111,7 +111,7 @@
             sout += "\\U%08x" % sys.maxunicode
         self.assertEqual(sin.encode("iso-8859-15", "backslashreplace"), sout)
 
-    def test_relaxedutf8(self):
+    def test_decoderelaxedutf8(self):
         # This is the test for a decoding callback handler,
         # that relaxes the UTF-8 minimal encoding restriction.
         # A null byte that is encoded as "\xc0\x80" will be
@@ -158,6 +158,35 @@
         charmap[ord("?")] = u"XYZ"
         self.assertRaises(TypeError, codecs.charmap_encode, sin, "replace", charmap)
 
+    def test_decodeunicodeinternal(self):
+        self.assertRaises(
+            UnicodeDecodeError,
+            "\x00\x00\x00\x00\x00".decode,
+            "unicode-internal",
+        )
+        if sys.maxunicode > 0xffff:
+            def handler_unicodeinternal(exc):
+                if not isinstance(exc, UnicodeDecodeError):
+                    raise TypeError("don't know how to handle %r" % exc)
+                return (u"\x01", 1)
+
+            self.assertEqual(
+                "\x00\x00\x00\x00\x00".decode("unicode-internal", "ignore"),
+                u"\u0000"
+            )
+
+            self.assertEqual(
+                "\x00\x00\x00\x00\x00".decode("unicode-internal", "replace"),
+                u"\u0000\ufffd"
+            )
+
+            codecs.register_error("test.hui", handler_unicodeinternal)
+
+            self.assertEqual(
+                "\x00\x00\x00\x00\x00".decode("unicode-internal", "test.hui"),
+                u"\u0000\u0001\u0000"
+            )
+
     def test_callbacks(self):
         def handler1(exc):
             if not isinstance(exc, UnicodeEncodeError) \
@@ -503,7 +532,8 @@
             for (enc, bytes) in (
                 ("ascii", "\xff"),
                 ("utf-8", "\xff"),
-                ("utf-7", "+x-")
+                ("utf-7", "+x-"),
+                ("unicode-internal", "\x00"),
             ):
                 self.assertRaises(
                     TypeError,

Index: test_codecs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v
retrieving revision 1.2.14.2
retrieving revision 1.2.14.3
diff -u -d -r1.2.14.2 -r1.2.14.3
--- test_codecs.py	7 Jan 2005 06:58:50 -0000	1.2.14.2
+++ test_codecs.py	16 Oct 2005 05:24:00 -0000	1.2.14.3
@@ -1,7 +1,7 @@
 from test import test_support
 import unittest
 import codecs
-import StringIO
+import sys, StringIO
 
 class Queue(object):
     """
@@ -73,15 +73,88 @@
         # reader has to look ahead whether this is a lone \r or a \r\n
         for size in xrange(80):
             for lineend in u"\n \r\n \r \u2028".split():
-                s = size*u"a" + lineend + u"xxx\n"
-                self.assertEqual(
-                    getreader(s).readline(keepends=True),
-                    size*u"a" + lineend,
-                )
-                self.assertEqual(
-                    getreader(s).readline(keepends=False),
-                    size*u"a",
-                )
+                s = 10*(size*u"a" + lineend + u"xxx\n")
+                reader = getreader(s)
+                for i in xrange(10):
+                    self.assertEqual(
+                        reader.readline(keepends=True),
+                        size*u"a" + lineend,
+                    )
+                reader = getreader(s)
+                for i in xrange(10):
+                    self.assertEqual(
+                        reader.readline(keepends=False),
+                        size*u"a",
+                    )
+
+    def test_bug1175396(self):
+        s = [
+            '<%!--===================================================\r\n',
+            '    BLOG index page: show recent articles,\r\n',
+            '    today\'s articles, or articles of a specific date.\r\n',
+            '========================================================--%>\r\n',
+            '<%@inputencoding="ISO-8859-1"%>\r\n',
+            '<%@pagetemplate=TEMPLATE.y%>\r\n',
+            '<%@import=import frog.util, frog%>\r\n',
+            '<%@import=import frog.objects%>\r\n',
+            '<%@import=from frog.storageerrors import StorageError%>\r\n',
+            '<%\r\n',
+            '\r\n',
+            'import logging\r\n',
+            'log=logging.getLogger("Snakelets.logger")\r\n',
+            '\r\n',
+            '\r\n',
+            'user=self.SessionCtx.user\r\n',
+            'storageEngine=self.SessionCtx.storageEngine\r\n',
+            '\r\n',
+            '\r\n',
+            'def readArticlesFromDate(date, count=None):\r\n',
+            '    entryids=storageEngine.listBlogEntries(date)\r\n',
+            '    entryids.reverse() # descending\r\n',
+            '    if count:\r\n',
+            '        entryids=entryids[:count]\r\n',
+            '    try:\r\n',
+            '        return [ frog.objects.BlogEntry.load(storageEngine, date, Id) for Id in entryids ]\r\n',
+            '    except StorageError,x:\r\n',
+            '        log.error("Error loading articles: "+str(x))\r\n',
+            '        self.abort("cannot load articles")\r\n',
+            '\r\n',
+            'showdate=None\r\n',
+            '\r\n',
+            'arg=self.Request.getArg()\r\n',
+            'if arg=="today":\r\n',
+            '    #-------------------- TODAY\'S ARTICLES\r\n',
+            '    self.write("<h2>Today\'s articles</h2>")\r\n',
+            '    showdate = frog.util.isodatestr() \r\n',
+            '    entries = readArticlesFromDate(showdate)\r\n',
+            'elif arg=="active":\r\n',
+            '    #-------------------- ACTIVE ARTICLES redirect\r\n',
+            '    self.Yredirect("active.y")\r\n',
+            'elif arg=="login":\r\n',
+            '    #-------------------- LOGIN PAGE redirect\r\n',
+            '    self.Yredirect("login.y")\r\n',
+            'elif arg=="date":\r\n',
+            '    #-------------------- ARTICLES OF A SPECIFIC DATE\r\n',
+            '    showdate = self.Request.getParameter("date")\r\n',
+            '    self.write("<h2>Articles written on %s</h2>"% frog.util.mediumdatestr(showdate))\r\n',
+            '    entries = readArticlesFromDate(showdate)\r\n',
+            'else:\r\n',
+            '    #-------------------- RECENT ARTICLES\r\n',
+            '    self.write("<h2>Recent articles</h2>")\r\n',
+            '    dates=storageEngine.listBlogEntryDates()\r\n',
+            '    if dates:\r\n',
+            '        entries=[]\r\n',
+            '        SHOWAMOUNT=10\r\n',
+            '        for showdate in dates:\r\n',
+            '            entries.extend( readArticlesFromDate(showdate, SHOWAMOUNT-len(entries)) )\r\n',
+            '            if len(entries)>=SHOWAMOUNT:\r\n',
+            '                break\r\n',
+            '                \r\n',
+        ]
+        stream = StringIO.StringIO("".join(s).encode(self.encoding))
+        reader = codecs.getreader(self.encoding)(stream)
+        for (i, line) in enumerate(reader):
+            self.assertEqual(line, s[i])
 
     def test_readlinequeue(self):
         q = Queue()
@@ -92,6 +165,7 @@
         writer.write(u"foo\r")
         self.assertEqual(reader.readline(keepends=False), u"foo")
         writer.write(u"\nbar\r")
+        self.assertEqual(reader.readline(keepends=False), u"")
         self.assertEqual(reader.readline(keepends=False), u"bar")
         writer.write(u"baz")
         self.assertEqual(reader.readline(keepends=False), u"baz")
@@ -101,6 +175,7 @@
         writer.write(u"foo\r")
         self.assertEqual(reader.readline(keepends=True), u"foo\r")
         writer.write(u"\nbar\r")
+        self.assertEqual(reader.readline(keepends=True), u"\n")
         self.assertEqual(reader.readline(keepends=True), u"bar\r")
         writer.write(u"baz")
         self.assertEqual(reader.readline(keepends=True), u"baz")
@@ -108,6 +183,36 @@
         writer.write(u"foo\r\n")
         self.assertEqual(reader.readline(keepends=True), u"foo\r\n")
 
+    def test_bug1098990_a(self):
+        s1 = u"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\r\n"
+        s2 = u"offending line: ladfj askldfj klasdj fskla dfzaskdj fasklfj laskd fjasklfzzzzaa%whereisthis!!!\r\n"
+        s3 = u"next line.\r\n"
+
+        s = (s1+s2+s3).encode(self.encoding)
+        stream = StringIO.StringIO(s)
+        reader = codecs.getreader(self.encoding)(stream)
+        self.assertEqual(reader.readline(), s1)
+        self.assertEqual(reader.readline(), s2)
+        self.assertEqual(reader.readline(), s3)
+        self.assertEqual(reader.readline(), u"")
+
+    def test_bug1098990_b(self):
+        s1 = u"aaaaaaaaaaaaaaaaaaaaaaaa\r\n"
+        s2 = u"bbbbbbbbbbbbbbbbbbbbbbbb\r\n"
+        s3 = u"stillokay:bbbbxx\r\n"
+        s4 = u"broken!!!!badbad\r\n"
+        s5 = u"againokay.\r\n"
+
+        s = (s1+s2+s3+s4+s5).encode(self.encoding)
+        stream = StringIO.StringIO(s)
+        reader = codecs.getreader(self.encoding)(stream)
+        self.assertEqual(reader.readline(), s1)
+        self.assertEqual(reader.readline(), s2)
+        self.assertEqual(reader.readline(), s3)
+        self.assertEqual(reader.readline(), s4)
+        self.assertEqual(reader.readline(), s5)
+        self.assertEqual(reader.readline(), u"")
+
 class UTF16Test(ReadTest):
     encoding = "utf-16"
 
@@ -129,6 +234,15 @@
         f = reader(s)
         self.assertEquals(f.read(), u"spamspam")
 
+    def test_badbom(self):
+        s = StringIO.StringIO("\xff\xff")
+        f = codecs.getreader(self.encoding)(s)
+        self.assertRaises(UnicodeError, f.read)
+
+        s = StringIO.StringIO("\xff\xff\xff\xff")
+        f = codecs.getreader(self.encoding)(s)
+        self.assertRaises(UnicodeError, f.read)
+
     def test_partial(self):
         self.check_partial(
             u"\x00\xff\u0100\uffff",
@@ -339,6 +453,54 @@
         for uni, puny in punycode_testcases:
             self.assertEquals(uni, puny.decode("punycode"))
 
+class UnicodeInternalTest(unittest.TestCase):
+    def test_bug1251300(self):
+        # Decoding with unicode_internal used to not correctly handle "code
+        # points" above 0x10ffff on UCS-4 builds.
+        if sys.maxunicode > 0xffff:
+            ok = [
+                ("\x00\x10\xff\xff", u"\U0010ffff"),
+                ("\x00\x00\x01\x01", u"\U00000101"),
+                ("", u""),
+            ]
+            not_ok = [
+                "\x7f\xff\xff\xff",
+                "\x80\x00\x00\x00",
+                "\x81\x00\x00\x00",
+                "\x00",
+                "\x00\x00\x00\x00\x00",
+            ]
+            for internal, uni in ok:
+                if sys.byteorder == "little":
+                    internal = "".join(reversed(internal))
+                self.assertEquals(uni, internal.decode("unicode_internal"))
+            for internal in not_ok:
+                if sys.byteorder == "little":
+                    internal = "".join(reversed(internal))
+                self.assertRaises(UnicodeDecodeError, internal.decode,
+                    "unicode_internal")
+
+    def test_decode_error_attributes(self):
+        if sys.maxunicode > 0xffff:
+            try:
+                "\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal")
+            except UnicodeDecodeError, ex:
+                self.assertEquals("unicode_internal", ex.encoding)
+                self.assertEquals("\x00\x00\x00\x00\x00\x11\x11\x00", ex.object)
+                self.assertEquals(4, ex.start)
+                self.assertEquals(8, ex.end)
+            else:
+                self.fail()
+
+    def test_decode_callback(self):
+        if sys.maxunicode > 0xffff:
+            codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
+            decoder = codecs.getdecoder("unicode_internal")
+            ab = u"ab".encode("unicode_internal")
+            ignored = decoder("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]),
+                "UnicodeInternalTest")
+            self.assertEquals((u"ab", 12), ignored)
+
 # From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
 nameprep_tests = [
     # 3.1 Map to nothing.
@@ -516,6 +678,12 @@
     def test_builtin(self):
         self.assertEquals(unicode("python.org", "idna"), u"python.org")
 
+    def test_stream(self):
+        import StringIO
+        r = codecs.getreader("idna")(StringIO.StringIO("abc"))
+        r.read(3)
+        self.assertEquals(r.read(), u"")
+
 class CodecsModuleTest(unittest.TestCase):
 
     def test_decode(self):
@@ -549,6 +717,22 @@
         f = self.reader(self.stream)
         self.assertEquals(f.readlines(), [u'\ud55c\n', u'\uae00'])
 
+class Str2StrTest(unittest.TestCase):
+
+    def test_read(self):
+        sin = "\x80".encode("base64_codec")
+        reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
+        sout = reader.read()
+        self.assertEqual(sout, "\x80")
+        self.assert_(isinstance(sout, str))
+
+    def test_readline(self):
+        sin = "\x80".encode("base64_codec")
+        reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
+        sout = reader.readline()
+        self.assertEqual(sout, "\x80")
+        self.assert_(isinstance(sout, str))
+
 all_unicode_encodings = [
     "ascii",
     "base64_codec",
@@ -716,6 +900,21 @@
                     decodedresult += reader.read()
                 self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
 
+    def test_seek(self):
+        # all codecs should be able to encode these
+        s = u"%s\n%s\n" % (100*u"abc123", 100*u"def456")
+        for encoding in all_unicode_encodings:
+            if encoding == "idna": # FIXME: See SF bug #1163178
+                continue
+            if encoding in broken_unicode_with_streams:
+                continue
+            reader = codecs.getreader(encoding)(StringIO.StringIO(s.encode(encoding)))
+            for t in xrange(5):
+                # Test that calling seek resets the internal codec state and buffers
+                reader.seek(0, 0)
+                line = reader.readline()
+                self.assertEqual(s[:len(line)], line)
+
 class BasicStrTest(unittest.TestCase):
     def test_basics(self):
         s = "abc123"
@@ -725,6 +924,40 @@
             (chars, size) = codecs.getdecoder(encoding)(bytes)
             self.assertEqual(chars, s, "%r != %r (encoding=%r)" % (chars, s, encoding))
 
+class CharmapTest(unittest.TestCase):
+    def test_decode_with_string_map(self):
+        self.assertEquals(
+            codecs.charmap_decode("\x00\x01\x02", "strict", u"abc"),
+            (u"abc", 3)
+        )
+
+        self.assertEquals(
+            codecs.charmap_decode("\x00\x01\x02", "replace", u"ab"),
+            (u"ab\ufffd", 3)
+        )
+
+        self.assertEquals(
+            codecs.charmap_decode("\x00\x01\x02", "replace", u"ab\ufffe"),
+            (u"ab\ufffd", 3)
+        )
+
+        self.assertEquals(
+            codecs.charmap_decode("\x00\x01\x02", "ignore", u"ab"),
+            (u"ab", 3)
+        )
+
+        self.assertEquals(
+            codecs.charmap_decode("\x00\x01\x02", "ignore", u"ab\ufffe"),
+            (u"ab", 3)
+        )
+
+        allbytes = "".join(chr(i) for i in xrange(256))
+        self.assertEquals(
+            codecs.charmap_decode(allbytes, "ignore", u""),
+            (u"", len(allbytes))
+        )
+
+
 def test_main():
     test_support.run_unittest(
         UTF16Test,
@@ -734,12 +967,15 @@
         EscapeDecodeTest,
         RecodingTest,
         PunycodeTest,
+        UnicodeInternalTest,
         NameprepTest,
         CodecTest,
         CodecsModuleTest,
         StreamReaderTest,
+        Str2StrTest,
         BasicUnicodeTest,
-        BasicStrTest
+        BasicStrTest,
+        CharmapTest
     )
 
 

Index: test_compiler.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compiler.py,v
retrieving revision 1.10.4.1
retrieving revision 1.10.4.2
diff -u -d -r1.10.4.1 -r1.10.4.2
--- test_compiler.py	7 Jan 2005 06:58:50 -0000	1.10.4.1
+++ test_compiler.py	16 Oct 2005 05:24:00 -0000	1.10.4.2
@@ -1,4 +1,5 @@
 import compiler
+from compiler.ast import flatten
 import os
 import test.test_support
 import unittest
@@ -33,6 +34,9 @@
                 else:
                     compiler.compile(buf, basename, "exec")
 
+    def testNewClassSyntax(self):
+        compiler.compile("class foo():pass\n\n","<string>","exec")
+
     def testLineNo(self):
         # Test that all nodes except Module have a correct lineno attribute.
         filename = __file__
@@ -57,6 +61,10 @@
         for child in node.getChildNodes():
             self.check_lineno(child)
 
+    def testFlatten(self):
+        self.assertEquals(flatten([1, [2]]), [1, 2])
+        self.assertEquals(flatten((1, (2,))), [1, 2])
+
 NOLINENO = (compiler.ast.Module, compiler.ast.Stmt, compiler.ast.Discard)
 
 ###############################################################################

Index: test_complex.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_complex.py,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -u -d -r1.8.2.2 -r1.8.2.3
--- test_complex.py	7 Jan 2005 06:58:50 -0000	1.8.2.2
+++ test_complex.py	16 Oct 2005 05:24:00 -0000	1.8.2.3
@@ -273,6 +273,28 @@
         self.assertAlmostEqual(complex(real=float2(17.), imag=float2(23.)), 17+23j)
         self.assertRaises(TypeError, complex, float2(None))
 
+        class complex0(complex):
+            """Test usage of __complex__() when inheriting from 'complex'"""
+            def __complex__(self):
+                return 42j
+
+        class complex1(complex):
+            """Test usage of __complex__() with a __new__() method"""
+            def __new__(self, value=0j):
+                return complex.__new__(self, 2*value)
+            def __complex__(self):
+                return self
+
+        class complex2(complex):
+            """Make sure that __complex__() calls fail if anything other than a
+            complex is returned"""
+            def __complex__(self):
+                return None
+
+        self.assertAlmostEqual(complex(complex0(1j)), 42j)
+        self.assertAlmostEqual(complex(complex1(1j)), 2j)
+        self.assertRaises(TypeError, complex, complex2(1j))
+
     def test_hash(self):
         for x in xrange(-30, 30):
             self.assertEqual(hash(x), hash(complex(x, 0)))
@@ -288,6 +310,8 @@
         self.assertEqual(repr(1+6j), '(1+6j)')
         self.assertEqual(repr(1-6j), '(1-6j)')
 
+        self.assertNotEqual(repr(-(1+0j)), '(-1+-0j)')
+
     def test_neg(self):
         self.assertEqual(-(1+6j), -1-6j)
 

Index: test_cookie.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookie.py,v
retrieving revision 1.11.14.2
retrieving revision 1.11.14.3
diff -u -d -r1.11.14.2 -r1.11.14.3
--- test_cookie.py	7 Jan 2005 06:58:50 -0000	1.11.14.2
+++ test_cookie.py	16 Oct 2005 05:24:00 -0000	1.11.14.3
@@ -12,17 +12,17 @@
 
 cases = [
     ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}),
-    ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;";',
+    ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
      {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}),
 
     # Check illegal cookies that have an '=' char in an unquoted value
-    ('keebler=E=mc2;', {'keebler' : 'E=mc2'})
+    ('keebler=E=mc2', {'keebler' : 'E=mc2'})
     ]
 
 for data, dict in cases:
     C = Cookie.SimpleCookie() ; C.load(data)
     print repr(C)
-    print str(C)
+    print C.output(sep='\n')
     for k, v in sorted(dict.iteritems()):
         print ' ', k, repr( C[k].value ), repr(v)
         verify(C[k].value == v)

Index: test_cookielib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookielib.py,v
retrieving revision 1.1.6.1
retrieving revision 1.1.6.2
diff -u -d -r1.1.6.1 -r1.1.6.2
--- test_cookielib.py	7 Jan 2005 06:58:50 -0000	1.1.6.1
+++ test_cookielib.py	16 Oct 2005 05:24:00 -0000	1.1.6.2
@@ -103,13 +103,23 @@
         from cookielib import parse_ns_headers
 
         # quotes should be stripped
-        expected = [[('expires', 2209069412L), ('version', '0')]]
+        expected = [[('foo', 'bar'), ('expires', 2209069412L), ('version', '0')]]
         for hdr in [
-            'expires=01 Jan 2040 22:23:32 GMT',
-            'expires="01 Jan 2040 22:23:32 GMT"',
+            'foo=bar; expires=01 Jan 2040 22:23:32 GMT',
+            'foo=bar; expires="01 Jan 2040 22:23:32 GMT"',
             ]:
             self.assertEquals(parse_ns_headers([hdr]), expected)
 
+    def test_parse_ns_headers_special_names(self):
+        # names such as 'expires' are not special in first name=value pair
+        # of Set-Cookie: header
+        from cookielib import parse_ns_headers
+
+        # Cookie with name 'expires'
+        hdr = 'expires=01 Jan 2040 22:23:32 GMT'
+        expected = [[("expires", "01 Jan 2040 22:23:32 GMT"), ("version", "0")]]
+        self.assertEquals(parse_ns_headers([hdr]), expected)
+
     def test_join_header_words(self):
         from cookielib import join_header_words
 
@@ -221,6 +231,24 @@
     return cookie_hdr
 
 
+class FileCookieJarTests(TestCase):
+    def test_lwp_valueless_cookie(self):
+        # cookies with no value should be saved and loaded consistently
+        from cookielib import LWPCookieJar
+        filename = test_support.TESTFN
+        c = LWPCookieJar()
+        interact_netscape(c, "http://www.acme.com/", 'boo')
+        self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
+        try:
+            c.save(filename, ignore_discard=True)
+            c = LWPCookieJar()
+            c.load(filename, ignore_discard=True)
+        finally:
+            try: os.unlink(filename)
+            except OSError: pass
+        self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
+
+
 class CookieTests(TestCase):
     # XXX
     # Get rid of string comparisons where not actually testing str / repr.
@@ -370,6 +398,19 @@
         self.assert_(foo.expires is None)
         self.assert_(spam.expires is None)
 
+    def test_ns_parser_special_names(self):
+        # names such as 'expires' are not special in first name=value pair
+        # of Set-Cookie: header
+        from cookielib import CookieJar
+
+        c = CookieJar()
+        interact_netscape(c, "http://www.acme.com/", 'expires=eggs')
+        interact_netscape(c, "http://www.acme.com/", 'version=eggs; spam=eggs')
+
+        cookies = c._cookies["www.acme.com"]["/"]
+        self.assert_('expires' in cookies)
+        self.assert_('version' in cookies)
+
     def test_expires(self):
         from cookielib import time2netscape, CookieJar
 
@@ -1613,6 +1654,7 @@
         DateTimeTests,
         HeaderTests,
         CookieTests,
+        FileCookieJarTests,
         LWPCookieTests,
         )
 

Index: test_csv.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v
retrieving revision 1.5.4.2
retrieving revision 1.5.4.3
diff -u -d -r1.5.4.2 -r1.5.4.3
--- test_csv.py	7 Jan 2005 06:58:50 -0000	1.5.4.2
+++ test_csv.py	16 Oct 2005 05:24:00 -0000	1.5.4.3
@@ -17,44 +17,104 @@
     from the high level interface. Further tests of this nature are done
     in TestDialectRegistry.
     """
+    def _test_arg_valid(self, ctor, arg):
+        self.assertRaises(TypeError, ctor)
+        self.assertRaises(TypeError, ctor, None)
+        self.assertRaises(TypeError, ctor, arg, bad_attr = 0)
+        self.assertRaises(TypeError, ctor, arg, delimiter = 0)
+        self.assertRaises(TypeError, ctor, arg, delimiter = 'XX')
+        self.assertRaises(csv.Error, ctor, arg, 'foo')
+        self.assertRaises(TypeError, ctor, arg, delimiter=None)
+        self.assertRaises(TypeError, ctor, arg, delimiter=1)
+        self.assertRaises(TypeError, ctor, arg, quotechar=1)
+        self.assertRaises(TypeError, ctor, arg, lineterminator=None)
+        self.assertRaises(TypeError, ctor, arg, lineterminator=1)
+        self.assertRaises(TypeError, ctor, arg, quoting=None)
+        self.assertRaises(TypeError, ctor, arg,
+                          quoting=csv.QUOTE_ALL, quotechar='')
+        self.assertRaises(TypeError, ctor, arg,
+                          quoting=csv.QUOTE_ALL, quotechar=None)
+
     def test_reader_arg_valid(self):
-        self.assertRaises(TypeError, csv.reader)
-        self.assertRaises(TypeError, csv.reader, None)
-        self.assertRaises(AttributeError, csv.reader, [], bad_attr = 0)
-        self.assertRaises(csv.Error, csv.reader, [], 'foo')
-        class BadClass:
-            def __init__(self):
-                raise IOError
-        self.assertRaises(IOError, csv.reader, [], BadClass)
-        self.assertRaises(TypeError, csv.reader, [], None)
-        class BadDialect:
-            bad_attr = 0
-        self.assertRaises(AttributeError, csv.reader, [], BadDialect)
+        self._test_arg_valid(csv.reader, [])
 
     def test_writer_arg_valid(self):
-        self.assertRaises(TypeError, csv.writer)
-        self.assertRaises(TypeError, csv.writer, None)
-        self.assertRaises(AttributeError, csv.writer, StringIO(), bad_attr = 0)
+        self._test_arg_valid(csv.writer, StringIO())
 
-    def _test_attrs(self, obj):
+    def _test_default_attrs(self, ctor, *args):
+        obj = ctor(*args)
+        # Check defaults
         self.assertEqual(obj.dialect.delimiter, ',')
-        obj.dialect.delimiter = '\t'
-        self.assertEqual(obj.dialect.delimiter, '\t')
-        self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter')
-        self.assertRaises(TypeError, setattr, obj.dialect,
-                          'lineterminator', None)
-        obj.dialect.escapechar = None
+        self.assertEqual(obj.dialect.doublequote, True)
         self.assertEqual(obj.dialect.escapechar, None)
-        self.assertRaises(TypeError, delattr, obj.dialect, 'quoting')
-        self.assertRaises(TypeError, setattr, obj.dialect, 'quoting', None)
-        obj.dialect.quoting = csv.QUOTE_MINIMAL
+        self.assertEqual(obj.dialect.lineterminator, "\r\n")
+        self.assertEqual(obj.dialect.quotechar, '"')
         self.assertEqual(obj.dialect.quoting, csv.QUOTE_MINIMAL)
+        self.assertEqual(obj.dialect.skipinitialspace, False)
+        self.assertEqual(obj.dialect.strict, False)
+        # Try deleting or changing attributes (they are read-only)
+        self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter')
+        self.assertRaises(TypeError, setattr, obj.dialect, 'delimiter', ':')
+        self.assertRaises(AttributeError, delattr, obj.dialect, 'quoting')
+        self.assertRaises(AttributeError, setattr, obj.dialect,
+                          'quoting', None)
 
     def test_reader_attrs(self):
-        self._test_attrs(csv.reader([]))
+        self._test_default_attrs(csv.reader, [])
 
     def test_writer_attrs(self):
-        self._test_attrs(csv.writer(StringIO()))
+        self._test_default_attrs(csv.writer, StringIO())
+
+    def _test_kw_attrs(self, ctor, *args):
+        # Now try with alternate options
+        kwargs = dict(delimiter=':', doublequote=False, escapechar='\\',
+                      lineterminator='\r', quotechar='*',
+                      quoting=csv.QUOTE_NONE, skipinitialspace=True,
+                      strict=True)
+        obj = ctor(*args, **kwargs)
+        self.assertEqual(obj.dialect.delimiter, ':')
+        self.assertEqual(obj.dialect.doublequote, False)
+        self.assertEqual(obj.dialect.escapechar, '\\')
+        self.assertEqual(obj.dialect.lineterminator, "\r")
+        self.assertEqual(obj.dialect.quotechar, '*')
+        self.assertEqual(obj.dialect.quoting, csv.QUOTE_NONE)
+        self.assertEqual(obj.dialect.skipinitialspace, True)
+        self.assertEqual(obj.dialect.strict, True)
+
+    def test_reader_kw_attrs(self):
+        self._test_kw_attrs(csv.reader, [])
+
+    def test_writer_kw_attrs(self):
+        self._test_kw_attrs(csv.writer, StringIO())
+
+    def _test_dialect_attrs(self, ctor, *args):
+        # Now try with dialect-derived options
+        class dialect:
+            delimiter='-'
+            doublequote=False
+            escapechar='^'
+            lineterminator='$'
+            quotechar='#'
+            quoting=csv.QUOTE_ALL
+            skipinitialspace=True
+            strict=False
+        args = args + (dialect,)
+        obj = ctor(*args)
+        self.assertEqual(obj.dialect.delimiter, '-')
+        self.assertEqual(obj.dialect.doublequote, False)
+        self.assertEqual(obj.dialect.escapechar, '^')
+        self.assertEqual(obj.dialect.lineterminator, "$")
+        self.assertEqual(obj.dialect.quotechar, '#')
+        self.assertEqual(obj.dialect.quoting, csv.QUOTE_ALL)
+        self.assertEqual(obj.dialect.skipinitialspace, True)
+        self.assertEqual(obj.dialect.strict, False)
+
+    def test_reader_dialect_attrs(self):
+        self._test_dialect_attrs(csv.reader, [])
+
+    def test_writer_dialect_attrs(self):
+        self._test_dialect_attrs(csv.writer, StringIO())
+
 
     def _write_test(self, fields, expect, **kwargs):
         fd, name = tempfile.mkstemp()
@@ -95,25 +155,35 @@
                          (bigstring, bigstring))
 
     def test_write_quoting(self):
-        self._write_test(['a','1','p,q'], 'a,1,"p,q"')
+        self._write_test(['a',1,'p,q'], 'a,1,"p,q"')
         self.assertRaises(csv.Error,
                           self._write_test,
-                          ['a','1','p,q'], 'a,1,"p,q"',
+                          ['a',1,'p,q'], 'a,1,p,q',
                           quoting = csv.QUOTE_NONE)
-        self._write_test(['a','1','p,q'], 'a,1,"p,q"',
+        self._write_test(['a',1,'p,q'], 'a,1,"p,q"',
                          quoting = csv.QUOTE_MINIMAL)
-        self._write_test(['a','1','p,q'], '"a",1,"p,q"',
+        self._write_test(['a',1,'p,q'], '"a",1,"p,q"',
                          quoting = csv.QUOTE_NONNUMERIC)
-        self._write_test(['a','1','p,q'], '"a","1","p,q"',
+        self._write_test(['a',1,'p,q'], '"a","1","p,q"',
                          quoting = csv.QUOTE_ALL)
 
     def test_write_escape(self):
-        self._write_test(['a','1','p,q'], 'a,1,"p,q"',
+        self._write_test(['a',1,'p,q'], 'a,1,"p,q"',
                          escapechar='\\')
-# FAILED - needs to be fixed [am]:
-#        self._write_test(['a','1','p,"q"'], 'a,1,"p,\\"q\\"',
-#                         escapechar='\\', doublequote = 0)
-        self._write_test(['a','1','p,q'], 'a,1,p\\,q',
+        self.assertRaises(csv.Error,
+                          self._write_test,
+                          ['a',1,'p,"q"'], 'a,1,"p,\\"q\\""',
+                          escapechar=None, doublequote=False)
+        self._write_test(['a',1,'p,"q"'], 'a,1,"p,\\"q\\""',
+                         escapechar='\\', doublequote = False)
+        self._write_test(['"'], '""""',
+                         escapechar='\\', quoting = csv.QUOTE_MINIMAL)
+        self._write_test(['"'], '\\"',
+                         escapechar='\\', quoting = csv.QUOTE_MINIMAL,
+                         doublequote = False)
+        self._write_test(['"'], '\\"',
+                         escapechar='\\', quoting = csv.QUOTE_NONE)
+        self._write_test(['a',1,'p,q'], 'a,1,p\\,q',
                          escapechar='\\', quoting = csv.QUOTE_NONE)
 
     def test_writerows(self):
@@ -159,18 +229,56 @@
         self.assertRaises(csv.Error, self._read_test, ['a,b\r\nc,d'], [])
 
     def test_read_escape(self):
-        self._read_test(['a,\\b,c'], [['a', '\\b', 'c']], escapechar='\\')
+        self._read_test(['a,\\b,c'], [['a', 'b', 'c']], escapechar='\\')
         self._read_test(['a,b\\,c'], [['a', 'b,c']], escapechar='\\')
         self._read_test(['a,"b\\,c"'], [['a', 'b,c']], escapechar='\\')
-        self._read_test(['a,"b,\\c"'], [['a', 'b,\\c']], escapechar='\\')
+        self._read_test(['a,"b,\\c"'], [['a', 'b,c']], escapechar='\\')
         self._read_test(['a,"b,c\\""'], [['a', 'b,c"']], escapechar='\\')
         self._read_test(['a,"b,c"\\'], [['a', 'b,c\\']], escapechar='\\')
 
+    def test_read_quoting(self):
+        self._read_test(['1,",3,",5'], [['1', ',3,', '5']])
+        self._read_test(['1,",3,",5'], [['1', '"', '3', '"', '5']],
+                        quotechar=None, escapechar='\\')
+        self._read_test(['1,",3,",5'], [['1', '"', '3', '"', '5']],
+                        quoting=csv.QUOTE_NONE, escapechar='\\')
+        # will this fail where locale uses comma for decimals?
+        self._read_test([',3,"5",7.3, 9'], [['', 3, '5', 7.3, 9]],
+                        quoting=csv.QUOTE_NONNUMERIC)
+        self.assertRaises(ValueError, self._read_test,
+                          ['abc,3'], [[]],
+                          quoting=csv.QUOTE_NONNUMERIC)
+
     def test_read_bigfield(self):
-        # This exercises the buffer realloc functionality
-        bigstring = 'X' * 50000
-        bigline = '%s,%s' % (bigstring, bigstring)
-        self._read_test([bigline], [[bigstring, bigstring]])
+        # This exercises the buffer realloc functionality and field size
+        # limits.
+        limit = csv.field_size_limit()
+        try:
+            size = 50000
+            bigstring = 'X' * size
+            bigline = '%s,%s' % (bigstring, bigstring)
+            self._read_test([bigline], [[bigstring, bigstring]])
+            csv.field_size_limit(size)
+            self._read_test([bigline], [[bigstring, bigstring]])
+            self.assertEqual(csv.field_size_limit(), size)
+            csv.field_size_limit(size-1)
+            self.assertRaises(csv.Error, self._read_test, [bigline], [])
+            self.assertRaises(TypeError, csv.field_size_limit, None)
+            self.assertRaises(TypeError, csv.field_size_limit, 1, None)
+        finally:
+            csv.field_size_limit(limit)
+
+    def test_read_linenum(self):
+        r = csv.reader(['line,1', 'line,2', 'line,3'])
+        self.assertEqual(r.line_num, 0)
+        r.next()
+        self.assertEqual(r.line_num, 1)
+        r.next()
+        self.assertEqual(r.line_num, 2)
+        r.next()
+        self.assertEqual(r.line_num, 3)
+        self.assertRaises(StopIteration, r.next)
+        self.assertEqual(r.line_num, 3)
 
 class TestDialectRegistry(unittest.TestCase):
     def test_registry_badargs(self):
@@ -183,11 +291,12 @@
         self.assertRaises(csv.Error, csv.unregister_dialect, "nonesuch")
         self.assertRaises(TypeError, csv.register_dialect, None)
         self.assertRaises(TypeError, csv.register_dialect, None, None)
-        self.assertRaises(TypeError, csv.register_dialect, "nonesuch", None)
-        class bogus:
-            def __init__(self):
-                raise KeyError
-        self.assertRaises(KeyError, csv.register_dialect, "nonesuch", bogus)
+        self.assertRaises(TypeError, csv.register_dialect, "nonesuch", 0, 0)
+        self.assertRaises(TypeError, csv.register_dialect, "nonesuch",
+                          badargument=None)
+        self.assertRaises(TypeError, csv.register_dialect, "nonesuch",
+                          quoting=None)
+        self.assertRaises(TypeError, csv.register_dialect, [])
 
     def test_registry(self):
         class myexceltsv(csv.excel):
@@ -197,13 +306,22 @@
         expected_dialects.sort()
         csv.register_dialect(name, myexceltsv)
         try:
-            self.failUnless(isinstance(csv.get_dialect(name), myexceltsv))
+            self.failUnless(csv.get_dialect(name).delimiter, '\t')
             got_dialects = csv.list_dialects()
             got_dialects.sort()
             self.assertEqual(expected_dialects, got_dialects)
         finally:
             csv.unregister_dialect(name)
 
+    def test_register_kwargs(self):
+        name = 'fedcba'
+        csv.register_dialect(name, delimiter=';')
+        try:
+            self.failUnless(csv.get_dialect(name).delimiter, '\t')
+            self.failUnless(list(csv.reader('X;Y;Z', name)), ['X', 'Y', 'Z'])
+        finally:
+            csv.unregister_dialect(name)
+
     def test_incomplete_dialect(self):
         class myexceltsv(csv.Dialect):
             delimiter = "\t"
@@ -297,7 +415,7 @@
 
     def test_bad_dialect(self):
         # Unknown parameter
-        self.assertRaises(AttributeError, csv.reader, [], bad_attr = 0)
+        self.assertRaises(TypeError, csv.reader, [], bad_attr = 0)
         # Bad values
         self.assertRaises(TypeError, csv.reader, [], delimiter = None)
         self.assertRaises(TypeError, csv.reader, [], quoting = -1)
@@ -661,10 +779,6 @@
         mydialect.quoting = None
         self.assertRaises(csv.Error, mydialect)
 
-        mydialect.quoting = csv.QUOTE_NONE
-        mydialect.escapechar = None
-        self.assertRaises(csv.Error, mydialect)
-
         mydialect.doublequote = True
         mydialect.quoting = csv.QUOTE_ALL
         mydialect.quotechar = '"'

Index: test_curses.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_curses.py,v
retrieving revision 1.1.10.2
retrieving revision 1.1.10.3
diff -u -d -r1.1.10.2 -r1.1.10.3
--- test_curses.py	7 Jan 2005 06:58:50 -0000	1.1.10.2
+++ test_curses.py	16 Oct 2005 05:24:00 -0000	1.1.10.3
@@ -107,6 +107,7 @@
     stdscr.scroll(2)
     stdscr.scroll(-3)
 
+    stdscr.move(12, 2)
     stdscr.setscrreg(10,15)
     win3 = stdscr.subwin(10,10)
     win3 = stdscr.subwin(10,10, 5,5)
@@ -179,7 +180,7 @@
         curses.init_pair(2, 1,1)
         curses.color_content(1)
         curses.color_pair(2)
-        curses.pair_content(curses.COLOR_PAIRS)
+        curses.pair_content(curses.COLOR_PAIRS - 1)
         curses.pair_number(0)
 
         if hasattr(curses, 'use_default_colors'):

Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.41.4.2
retrieving revision 1.41.4.3
diff -u -d -r1.41.4.2 -r1.41.4.3
--- test_datetime.py	7 Jan 2005 06:58:50 -0000	1.41.4.2
+++ test_datetime.py	16 Oct 2005 05:24:00 -0000	1.41.4.3
@@ -446,9 +446,9 @@
     def test_subclass_timedelta(self):
 
         class T(timedelta):
+            @staticmethod
             def from_td(td):
                 return T(td.days, td.seconds, td.microseconds)
-            from_td = staticmethod(from_td)
 
             def as_hours(self):
                 sum = (self.days * 24 +
@@ -1421,6 +1421,15 @@
             # Else try again a few times.
         self.failUnless(abs(from_timestamp - from_now) <= tolerance)
 
+    def test_strptime(self):
+        import time
+
+        string = '2004-12-01 13:02:47'
+        format = '%Y-%m-%d %H:%M:%S'
+        expected = self.theclass(*(time.strptime(string, format)[0:6]))
+        got = self.theclass.strptime(string, format)
+        self.assertEqual(expected, got)
+
     def test_more_timetuple(self):
         # This tests fields beyond those tested by the TestDate.test_timetuple.
         t = self.theclass(2004, 12, 31, 6, 22, 33)

Index: test_decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -d -r1.16.2.1 -r1.16.2.2
--- test_decimal.py	7 Jan 2005 06:58:50 -0000	1.16.2.1
+++ test_decimal.py	16 Oct 2005 05:24:00 -0000	1.16.2.2
@@ -24,8 +24,6 @@
 with the corresponding argument.
 """
 
-from __future__ import division
-
 import unittest
 import glob
 import os, sys
@@ -54,9 +52,9 @@
 else:
     file = __file__
 testdir = os.path.dirname(file) or os.curdir
-dir = testdir + os.sep + TESTDATADIR + os.sep
+directory = testdir + os.sep + TESTDATADIR + os.sep
 
-skip_expected = not os.path.isdir(dir)
+skip_expected = not os.path.isdir(directory)
 
 # Make sure it actually raises errors when not expected and caught in flags
 # Slower, since it runs some things several times.
@@ -109,7 +107,6 @@
     Changed for unittest.
     """
     def setUp(self):
-        global dir
         self.context = Context()
         for key in DefaultContext.traps.keys():
             DefaultContext.traps[key] = 1
@@ -302,11 +299,11 @@
 # Dynamically build custom test definition for each file in the test
 # directory and add the definitions to the DecimalTest class.  This
 # procedure insures that new files do not get skipped.
-for filename in os.listdir(dir):
+for filename in os.listdir(directory):
     if '.decTest' not in filename:
         continue
     head, tail = filename.split('.')
-    tester = lambda self, f=filename: self.eval_file(dir + f)
+    tester = lambda self, f=filename: self.eval_file(directory + f)
     setattr(DecimalTest, 'test_' + head, tester)
     del filename, head, tail, tester
 
@@ -476,6 +473,52 @@
     def test_implicit_from_Decimal(self):
         self.assertEqual(Decimal(5) + Decimal(45), Decimal(50))
 
+    def test_rop(self):
+        # Allow other classes to be trained to interact with Decimals
+        class E:
+            def __divmod__(self, other):
+                return 'divmod ' + str(other)
+            def __rdivmod__(self, other):
+                return str(other) + ' rdivmod'
+            def __lt__(self, other):
+                return 'lt ' + str(other)
+            def __gt__(self, other):
+                return 'gt ' + str(other)
+            def __le__(self, other):
+                return 'le ' + str(other)
+            def __ge__(self, other):
+                return 'ge ' + str(other)
+            def __eq__(self, other):
+                return 'eq ' + str(other)
+            def __ne__(self, other):
+                return 'ne ' + str(other)
+
+        self.assertEqual(divmod(E(), Decimal(10)), 'divmod 10')
+        self.assertEqual(divmod(Decimal(10), E()), '10 rdivmod')
+        self.assertEqual(eval('Decimal(10) < E()'), 'gt 10')
+        self.assertEqual(eval('Decimal(10) > E()'), 'lt 10')
+        self.assertEqual(eval('Decimal(10) <= E()'), 'ge 10')
+        self.assertEqual(eval('Decimal(10) >= E()'), 'le 10')
+        self.assertEqual(eval('Decimal(10) == E()'), 'eq 10')
+        self.assertEqual(eval('Decimal(10) != E()'), 'ne 10')
+
+        # insert operator methods and then exercise them
+        for sym, lop, rop in (
+                ('+', '__add__', '__radd__'),
+                ('-', '__sub__', '__rsub__'),
+                ('*', '__mul__', '__rmul__'),
+                ('/', '__div__', '__rdiv__'),
+                ('%', '__mod__', '__rmod__'),
+                ('//', '__floordiv__', '__rfloordiv__'),
+                ('**', '__pow__', '__rpow__'),
+            ):
+
+            setattr(E, lop, lambda self, other: 'str' + lop + str(other))
+            setattr(E, rop, lambda self, other: str(other) + rop + 'str')
+            self.assertEqual(eval('E()' + sym + 'Decimal(10)'),
+                             'str' + lop + '10')
+            self.assertEqual(eval('Decimal(10)' + sym + 'E()'),
+                             '10' + rop + 'str')
 
 class DecimalArithmeticOperatorsTest(unittest.TestCase):
     '''Unit tests for all arithmetic operators, binary and unary.'''
@@ -811,6 +854,9 @@
         hash(Decimal(23))
         #the same hash that to an int
         self.assertEqual(hash(Decimal(23)), hash(23))
+        self.assertRaises(TypeError, hash, Decimal('NaN'))
+        self.assert_(hash(Decimal('Inf')))
+        self.assert_(hash(Decimal('-Inf')))
 
     def test_min_and_max_methods(self):
 

Index: test_deque.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v
retrieving revision 1.18.4.1
retrieving revision 1.18.4.2
diff -u -d -r1.18.4.1 -r1.18.4.2
--- test_deque.py	7 Jan 2005 06:58:51 -0000	1.18.4.1
+++ test_deque.py	16 Oct 2005 05:24:00 -0000	1.18.4.2
@@ -1,6 +1,6 @@
 from collections import deque
 import unittest
-from test import test_support
+from test import test_support, seq_tests
 from weakref import proxy
 import copy
 import cPickle as pickle
@@ -14,6 +14,18 @@
     raise SyntaxError
     yield 1
 
+class BadCmp:
+    def __eq__(self, other):
+        raise RuntimeError
+
+class MutateCmp:
+    def __init__(self, deque, result):
+        self.deque = deque
+        self.result = result
+    def __eq__(self, other):
+        self.deque.clear()
+        return self.result
+
 class TestBasic(unittest.TestCase):
 
     def test_basics(self):
@@ -197,6 +209,30 @@
         d.clear()               # clear an emtpy deque
         self.assertEqual(list(d), [])
 
+    def test_remove(self):
+        d = deque('abcdefghcij')
+        d.remove('c')
+        self.assertEqual(d, deque('abdefghcij'))
+        d.remove('c')
+        self.assertEqual(d, deque('abdefghij'))
+        self.assertRaises(ValueError, d.remove, 'c')
+        self.assertEqual(d, deque('abdefghij'))
+
+        # Handle comparison errors
+        d = deque(['a', 'b', BadCmp(), 'c'])
+        e = deque(d)
+        self.assertRaises(RuntimeError, d.remove, 'c')
+        for x, y in zip(d, e):
+            # verify that original order and values are retained.
+            self.assert_(x is y)
+
+        # Handle evil mutator
+        for match in (True, False):
+            d = deque(['ab'])
+            d.extend([MutateCmp(d, match), 'c'])
+            self.assertRaises(IndexError, d.remove, 'c')
+            self.assertEqual(d, deque())
+
     def test_repr(self):
         d = deque(xrange(200))
         e = eval(repr(d))
@@ -342,93 +378,17 @@
             d.append(1)
             gc.collect()
 
-def R(seqn):
-    'Regular generator'
-    for i in seqn:
-        yield i
-
-class G:
-    'Sequence using __getitem__'
-    def __init__(self, seqn):
-        self.seqn = seqn
-    def __getitem__(self, i):
-        return self.seqn[i]
-
-class I:
-    'Sequence using iterator protocol'
-    def __init__(self, seqn):
-        self.seqn = seqn
-        self.i = 0
-    def __iter__(self):
-        return self
-    def next(self):
-        if self.i >= len(self.seqn): raise StopIteration
-        v = self.seqn[self.i]
-        self.i += 1
-        return v
-
-class Ig:
-    'Sequence using iterator protocol defined with a generator'
-    def __init__(self, seqn):
-        self.seqn = seqn
-        self.i = 0
-    def __iter__(self):
-        for val in self.seqn:
-            yield val
-
-class X:
-    'Missing __getitem__ and __iter__'
-    def __init__(self, seqn):
-        self.seqn = seqn
-        self.i = 0
-    def next(self):
-        if self.i >= len(self.seqn): raise StopIteration
-        v = self.seqn[self.i]
-        self.i += 1
-        return v
-
-class N:
-    'Iterator missing next()'
-    def __init__(self, seqn):
-        self.seqn = seqn
-        self.i = 0
-    def __iter__(self):
-        return self
-
-class E:
-    'Test propagation of exceptions'
-    def __init__(self, seqn):
-        self.seqn = seqn
-        self.i = 0
-    def __iter__(self):
-        return self
-    def next(self):
-        3 // 0
-
-class S:
-    'Test immediate stop'
-    def __init__(self, seqn):
-        pass
-    def __iter__(self):
-        return self
-    def next(self):
-        raise StopIteration
-
-from itertools import chain, imap
-def L(seqn):
-    'Test multiple tiers of iterators'
-    return chain(imap(lambda x:x, R(Ig(G(seqn)))))
-
-
 class TestVariousIteratorArgs(unittest.TestCase):
 
     def test_constructor(self):
         for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
-            for g in (G, I, Ig, S, L, R):
+            for g in (seq_tests.Sequence, seq_tests.IterFunc,
+                      seq_tests.IterGen, seq_tests.IterFuncStop,
+                      seq_tests.itermulti, seq_tests.iterfunc):
                 self.assertEqual(list(deque(g(s))), list(g(s)))
-            self.assertRaises(TypeError, deque, X(s))
-            self.assertRaises(TypeError, deque, N(s))
-            self.assertRaises(ZeroDivisionError, deque, E(s))
+            self.assertRaises(TypeError, deque, seq_tests.IterNextOnly(s))
+            self.assertRaises(TypeError, deque, seq_tests.IterNoNext(s))
+            self.assertRaises(ZeroDivisionError, deque, seq_tests.IterGenExc(s))
 
     def test_iter_with_altered_data(self):
         d = deque('abcdefg')

Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.144.2.2
retrieving revision 1.144.2.3
diff -u -d -r1.144.2.2 -r1.144.2.3
--- test_descr.py	7 Jan 2005 06:58:51 -0000	1.144.2.2
+++ test_descr.py	16 Oct 2005 05:24:00 -0000	1.144.2.3
@@ -691,13 +691,13 @@
     class _instance(object):
         pass
     class M2(object):
+        @staticmethod
         def __new__(cls, name, bases, dict):
             self = object.__new__(cls)
             self.name = name
             self.bases = bases
             self.dict = dict
             return self
-        __new__ = staticmethod(__new__)
         def __call__(self):
             it = _instance()
             # Early binding of methods
@@ -2071,9 +2071,9 @@
         aProp = property(lambda self: "foo")
 
     class Sub(Base):
+        @classmethod
         def test(klass):
             return super(Sub,klass).aProp
-        test = classmethod(test)
 
     veris(Sub.test(), Base.aProp)
 
@@ -2712,7 +2712,7 @@
     def cant(x, dict):
         try:
             x.__dict__ = dict
-        except TypeError:
+        except (AttributeError, TypeError):
             pass
         else:
             raise TestFailed, "shouldn't allow %r.__dict__ = %r" % (x, dict)
@@ -3965,6 +3965,18 @@
     import gc; gc.collect()
     vereq(hasattr(c, 'attr'), False)
 
+def test_init():
+    # SF 1155938
+    class Foo(object):
+        def __init__(self):
+            return 10
+    try:
+        Foo()
+    except TypeError:
+        pass
+    else:
+        raise TestFailed, "did not test __init__() for None return"
+
 
 def test_main():
     weakref_segfault() # Must be first, somehow
@@ -4058,6 +4070,7 @@
     carloverre()
     filefault()
     vicious_descriptor_nonsense()
+    test_init()
 
     if verbose: print "All OK"
 

Index: test_descrtut.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v
retrieving revision 1.13.2.2
retrieving revision 1.13.2.3
diff -u -d -r1.13.2.2 -r1.13.2.3
--- test_descrtut.py	7 Jan 2005 06:58:51 -0000	1.13.2.2
+++ test_descrtut.py	16 Oct 2005 05:24:00 -0000	1.13.2.3
@@ -246,9 +246,9 @@
 
     >>> class C:
     ...
+    ...     @staticmethod
     ...     def foo(x, y):
     ...         print "staticmethod", x, y
-    ...     foo = staticmethod(foo)
 
     >>> C.foo(1, 2)
     staticmethod 1 2
@@ -260,9 +260,9 @@
 implicit first argument that is the *class* for which they are invoked.
 
     >>> class C:
+    ...     @classmethod
     ...     def foo(cls, y):
     ...         print "classmethod", cls, y
-    ...     foo = classmethod(foo)
 
     >>> C.foo(1)
     classmethod test.test_descrtut.C 1
@@ -286,10 +286,10 @@
 But notice this:
 
     >>> class E(C):
+    ...     @classmethod
     ...     def foo(cls, y): # override C.foo
     ...         print "E.foo() called"
     ...         C.foo(y)
-    ...     foo = classmethod(foo)
 
     >>> E.foo(1)
     E.foo() called

Index: test_doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v
retrieving revision 1.4.14.3
retrieving revision 1.4.14.4
diff -u -d -r1.4.14.3 -r1.4.14.4
--- test_doctest.py	10 Oct 2005 15:50:41 -0000	1.4.14.3
+++ test_doctest.py	16 Oct 2005 05:24:00 -0000	1.4.14.4
@@ -1517,6 +1517,7 @@
     ## 44
     #
     # Yee ha!
+    <BLANKLINE>
 
     >>> name = 'test.test_doctest.SampleNewStyleClass'
     >>> print doctest.testsource(test.test_doctest, name)
@@ -1525,6 +1526,7 @@
     ## 1
     ## 2
     ## 3
+    <BLANKLINE>
 
     >>> name = 'test.test_doctest.SampleClass.a_classmethod'
     >>> print doctest.testsource(test.test_doctest, name)
@@ -1534,6 +1536,7 @@
     print SampleClass(0).a_classmethod(10)
     # Expected:
     ## 12
+    <BLANKLINE>
 """
 
 def test_debug(): r"""

Index: test_doctest2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest2.py,v
retrieving revision 1.3.12.2
retrieving revision 1.3.12.3
diff -u -d -r1.3.12.2 -r1.3.12.3
--- test_doctest2.py	7 Jan 2005 06:58:52 -0000	1.3.12.2
+++ test_doctest2.py	16 Oct 2005 05:24:00 -0000	1.3.12.3
@@ -80,6 +80,7 @@
         -12
         """)
 
+    @staticmethod
     def statm():
         """
         A static method.
@@ -91,8 +92,7 @@
         """
         return 666
 
-    statm = staticmethod(statm)
-
+    @classmethod
     def clsm(cls, val):
         """
         A class method.
@@ -104,8 +104,6 @@
         """
         return val
 
-    clsm = classmethod(clsm)
-
 def test_main():
     from test import test_doctest2
     EXPECTED = 19

Index: test_dumbdbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dumbdbm.py,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -u -d -r1.6.2.2 -r1.6.2.3
--- test_dumbdbm.py	7 Jan 2005 06:58:52 -0000	1.6.2.2
+++ test_dumbdbm.py	16 Oct 2005 05:24:00 -0000	1.6.2.3
@@ -74,6 +74,24 @@
         self.assertEqual(f['1'], 'hello2')
         f.close()
 
+    def test_line_endings(self):
+        # test for bug #1172763: dumbdbm would die if the line endings
+        # weren't what was expected.
+        f = dumbdbm.open(_fname)
+        f['1'] = 'hello'
+        f['2'] = 'hello2'
+        f.close()
+
+        # Mangle the file by adding \r before each newline
+        data = open(_fname + '.dir').read()
+        data = data.replace('\n', '\r\n')
+        open(_fname + '.dir', 'wb').write(data)
+
+        f = dumbdbm.open(_fname)
+        self.assertEqual(f['1'], 'hello')
+        self.assertEqual(f['2'], 'hello2')
+
+
     def read_helper(self, f):
         keys = self.keys_helper(f)
         for key in self._dict:

Index: test_enumerate.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_enumerate.py,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -d -r1.2.2.2 -r1.2.2.3
--- test_enumerate.py	7 Jan 2005 06:58:52 -0000	1.2.2.2
+++ test_enumerate.py	16 Oct 2005 05:24:00 -0000	1.2.2.3
@@ -1,4 +1,5 @@
 import unittest
+import sys
 
 from test import test_support
 
@@ -143,6 +144,7 @@
 
     def test_len(self):
         # This is an implementation detail, not an interface requirement
+        from test.test_iterlen import len
         for s in ('hello', tuple('hello'), list('hello'), xrange(5)):
             self.assertEqual(len(reversed(s)), len(s))
             r = reversed(s)
@@ -175,6 +177,25 @@
         self.assertRaises(TypeError, reversed)
         self.assertRaises(TypeError, reversed, [], 'extra')
 
+    def test_bug1229429(self):
+        # this bug was never in reversed, it was in
+        # PyObject_CallMethod, and reversed_new calls that sometimes.
+        if not hasattr(sys, "getrefcount"):
+            return
+        def f():
+            pass
+        r = f.__reversed__ = object()
+        rc = sys.getrefcount(r)
+        for i in range(10):
+            try:
+                reversed(f)
+            except TypeError:
+                pass
+            else:
+                self.fail("non-callable __reversed__ didn't raise!")
+        self.assertEqual(rc, sys.getrefcount(r))
+
+
 def test_main(verbose=None):
     testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig,
                    TestReversed)

Index: test_fcntl.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_fcntl.py,v
retrieving revision 1.23.2.2
retrieving revision 1.23.2.3
diff -u -d -r1.23.2.2 -r1.23.2.3
--- test_fcntl.py	7 Jan 2005 06:58:52 -0000	1.23.2.2
+++ test_fcntl.py	16 Oct 2005 05:24:00 -0000	1.23.2.3
@@ -22,9 +22,16 @@
 
 if sys.platform in ('netbsd1', 'Darwin1.2', 'darwin',
                     'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6',
+                    'freebsd7',
                     'bsdos2', 'bsdos3', 'bsdos4',
                     'openbsd', 'openbsd2', 'openbsd3'):
-    lockdata = struct.pack('lxxxxlxxxxlhh', 0, 0, 0, fcntl.F_WRLCK, 0)
+    if struct.calcsize('l') == 8:
+        off_t = 'l'
+        pid_t = 'i'
+    else:
+        off_t = 'lxxxx'
+        pid_t = 'l'
+    lockdata = struct.pack(off_t+off_t+pid_t+'hh', 0, 0, 0, fcntl.F_WRLCK, 0)
 elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']:
     lockdata = struct.pack('hhlllii', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
 elif sys.platform in ['os2emx']:
@@ -39,7 +46,7 @@
 f = open(filename, 'w')
 rv = fcntl.fcntl(f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
 if verbose:
-    print 'Status from fnctl with O_NONBLOCK: ', rv
+    print 'Status from fcntl with O_NONBLOCK: ', rv
 
 if sys.platform not in ['os2emx']:
     rv = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW, lockdata)

Index: test_file.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_file.py,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.3
diff -u -d -r1.9.2.2 -r1.9.2.3
--- test_file.py	7 Jan 2005 06:58:52 -0000	1.9.2.2
+++ test_file.py	16 Oct 2005 05:24:00 -0000	1.9.2.3
@@ -34,12 +34,22 @@
 for attr in 'name', 'mode', 'closed':
     try:
         setattr(f, attr, 'oops')
-    except TypeError:
+    except (AttributeError, TypeError):
         pass
     else:
-        raise TestFailed('expected TypeError setting file attr %r' % attr)
+        raise TestFailed('expected exception setting file attr %r' % attr)
 f.close()
 
+# check invalid mode strings
+for mode in ("", "aU", "wU+"):
+    try:
+        f = file(TESTFN, mode)
+    except ValueError:
+        pass
+    else:
+        f.close()
+        raise TestFailed('%r is an invalid file mode' % mode)
+
 # verify writelines with instance sequence
 l = UserList(['1', '2'])
 f = open(TESTFN, 'wb')

Index: test_funcattrs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v
retrieving revision 1.11.10.2
retrieving revision 1.11.10.3
diff -u -d -r1.11.10.2 -r1.11.10.3
--- test_funcattrs.py	7 Jan 2005 06:58:52 -0000	1.11.10.2
+++ test_funcattrs.py	16 Oct 2005 05:24:00 -0000	1.11.10.3
@@ -276,6 +276,9 @@
     verify(f.func_name == "h")
     cantset(f, "func_globals", 1)
     cantset(f, "__name__", 1)
+    # test that you can access func.__name__ in restricted mode
+    s = """def f(): pass\nf.__name__"""
+    exec s in {'__builtins__':{}}
 
 
 def test_func_code():

Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.34.2.2
retrieving revision 1.34.2.3
diff -u -d -r1.34.2.2 -r1.34.2.3
--- test_generators.py	7 Jan 2005 06:58:52 -0000	1.34.2.2
+++ test_generators.py	16 Oct 2005 05:24:00 -0000	1.34.2.3
@@ -382,7 +382,7 @@
 >>> type(i)
 <type 'generator'>
 >>> [s for s in dir(i) if not s.startswith('_')]
-['gi_frame', 'gi_running', 'next']
+['close', 'gi_frame', 'gi_running', 'next', 'send', 'throw']
 >>> print i.next.__doc__
 x.next() -> the next value, or raise StopIteration
 >>> iter(i) is i
@@ -421,6 +421,7 @@
 ...         self.name = name
 ...         self.parent = None
 ...         self.generator = self.generate()
+...         self.close = self.generator.close
 ...
 ...     def generate(self):
 ...         while not self.parent:
@@ -482,6 +483,9 @@
 A->A B->G C->A D->G E->G F->A G->G H->G I->A J->G K->A L->A M->G
 merged A into G
 A->G B->G C->G D->G E->G F->G G->G H->G I->G J->G K->G L->G M->G
+
+>>> for s in sets: s.close()    # break cycles
+
 """
 # Emacs turd '
 
@@ -589,6 +593,7 @@
 ...     def __init__(self, g):
 ...         self.sofar = []
 ...         self.fetch = g.next
+...         self.close = g.close
 ...
 ...     def __getitem__(self, i):
 ...         sofar, fetch = self.sofar, self.fetch
@@ -619,6 +624,7 @@
 [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384]
 [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675]
 
+>>> m235.close()
 
 Ye olde Fibonacci generator, LazyList style.
 
@@ -642,6 +648,85 @@
 >>> fib = LazyList(fibgen(1, 2))
 >>> firstn(iter(fib), 17)
 [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584]
+>>> fib.close()
+
+
+Running after your tail with itertools.tee (new in version 2.4)
+
+The algorithms "m235" (Hamming) and Fibonacci presented above are both
+examples of a whole family of FP (functional programming) algorithms
+where a function produces and returns a list while the production algorithm
+suppose the list as already produced by recursively calling itself.
+For these algorithms to work, they must:
+
+- produce at least a first element without presupposing the existence of
+  the rest of the list
+- produce their elements in a lazy manner
+
+To work efficiently, the beginning of the list must not be recomputed over
+and over again. This is ensured in most FP languages as a built-in feature.
+In python, we have to explicitly maintain a list of already computed results
+and abandon genuine recursivity.
+
+This is what had been attempted above with the LazyList class. One problem
+with that class is that it keeps a list of all of the generated results and
+therefore continually grows. This partially defeats the goal of the generator
+concept, viz. produce the results only as needed instead of producing them
+all and thereby wasting memory.
+
+Thanks to itertools.tee, it is now clear "how to get the internal uses of
+m235 to share a single generator".
+
+>>> from itertools import tee
+>>> def m235():
+...     def _m235():
+...         yield 1
+...         for n in merge(times(2, m2),
+...                        merge(times(3, m3),
+...                              times(5, m5))):
+...             yield n
+...     m2, m3, m5, mRes = tee(_m235(), 4)
+...     return mRes
+
+>>> it = m235()
+>>> for i in range(5):
+...     print firstn(it, 15)
+[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
+[25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
+[81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
+[200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384]
+[400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675]
+
+The "tee" function does just what we want. It internally keeps a generated
+result for as long as it has not been "consumed" from all of the duplicated
+iterators, whereupon it is deleted. You can therefore print the hamming
+sequence during hours without increasing memory usage, or very little.
+
+The beauty of it is that recursive running after their tail FP algorithms
+are quite straightforwardly expressed with this Python idiom.
+
+
+Ye olde Fibonacci generator, tee style.
+
+>>> def fib():
+...
+...     def _isum(g, h):
+...         while 1:
+...             yield g.next() + h.next()
+...
+...     def _fib():
+...         yield 1
+...         yield 2
+...         fibTail.next() # throw first away
+...         for res in _isum(fibHead, fibTail):
+...             yield res
+...
+...     fibHead, fibTail, fibRes = tee(_fib(), 3)
+...     return fibRes
+
+>>> firstn(fib(), 17)
+[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584]
+
 """
 
 # syntax_tests mostly provokes SyntaxErrors.  Also fiddling with #if 0
@@ -672,7 +757,7 @@
   ..
 SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[2]>, line 3)
 
-This one is fine:
+These are fine:
 
 >>> def f():
 ...     yield 1
@@ -683,25 +768,17 @@
 ...         yield 1
 ...     finally:
 ...         pass
-Traceback (most recent call last):
-  ..
-SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.__test__.syntax[4]>, line 3)
 
 >>> def f():
 ...     try:
 ...         try:
 ...             1//0
 ...         except ZeroDivisionError:
-...             yield 666  # bad because *outer* try has finally
+...             yield 666 
 ...         except:
 ...             pass
 ...     finally:
 ...         pass
-Traceback (most recent call last):
-  ...
-SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.__test__.syntax[5]>, line 6)
-
-But this is fine:
 
 >>> def f():
 ...     try:
@@ -722,14 +799,16 @@
 
 >>> def f():
 ...    yield
-Traceback (most recent call last):
-SyntaxError: invalid syntax
+>>> type(f())
+<type 'generator'>
+
 
 >>> def f():
 ...    if 0:
 ...        yield
-Traceback (most recent call last):
-SyntaxError: invalid syntax
+>>> type(f())
+<type 'generator'>
+
 
 >>> def f():
 ...     if 0:
@@ -805,7 +884,7 @@
 ...     if 0:
 ...         yield 2             # because it's a generator
 Traceback (most recent call last):
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[22]>, line 8)
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[24]>, line 8)
 
 This one caused a crash (see SF bug 567538):
 
@@ -1383,6 +1462,250 @@
 
 """
 
+coroutine_tests = """\
+Sending a value into a started generator:
+
+>>> def f():
+...     print (yield 1)
+...     yield 2
+>>> g = f()
+>>> g.next()
+1
+>>> g.send(42)
+42
+2
+
+Sending a value into a new generator produces a TypeError:
+
+>>> f().send("foo")
+Traceback (most recent call last):
+...
+TypeError: can't send non-None value to a just-started generator
+
+
+Yield by itself yields None:
+
+>>> def f(): yield
+>>> list(f())
+[None]
+
+
+
+An obscene abuse of a yield expression within a generator expression:
+
+>>> list((yield 21) for i in range(4))
+[21, None, 21, None, 21, None, 21, None]
+
+And a more sane, but still weird usage:
+
+>>> def f(): list(i for i in [(yield 26)])
+>>> type(f())
+<type 'generator'>
+
+
+Check some syntax errors for yield expressions:
+
+>>> f=lambda: (yield 1),(yield 2)
+Traceback (most recent call last):
+  ...
+SyntaxError: 'yield' outside function (<doctest test.test_generators.__test__.coroutine[10]>, line 1)
+
+>>> def f(): return lambda x=(yield): 1
+Traceback (most recent call last):
+  ...
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[11]>, line 1)
+
+>>> def f(): x = yield = y
+Traceback (most recent call last):
+  ...
+SyntaxError: assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[12]>, line 1)
+
+
+Now check some throw() conditions:
+
+>>> def f():
+...     while True:
+...         try:
+...             print (yield)
+...         except ValueError,v:
+...             print "caught ValueError (%s)" % (v),
+>>> import sys
+>>> g = f()
+>>> g.next()
+
+>>> g.throw(ValueError) # type only
+caught ValueError ()
+
+>>> g.throw(ValueError("xyz"))  # value only
+caught ValueError (xyz)
+
+>>> g.throw(ValueError, ValueError(1))   # value+matching type
+caught ValueError (1)
+
+>>> g.throw(ValueError, TypeError(1))  # mismatched type, rewrapped
+caught ValueError (1)
+
+>>> g.throw(ValueError(1), "foo")       # bad args
+Traceback (most recent call last):
+  ...
+TypeError: instance exception may not have a separate value
+
+>>> g.throw(ValueError, "foo", 23)      # bad args
+Traceback (most recent call last):
+  ...
+TypeError: throw() third argument must be a traceback object
+
+>>> def throw(g,exc):
+...     try:
+...         raise exc
+...     except:
+...         g.throw(*sys.exc_info())
+>>> throw(g,ValueError) # do it with traceback included
+caught ValueError ()
+
+>>> g.send(1)
+1
+
+>>> throw(g,TypeError)  # terminate the generator
+Traceback (most recent call last):
+  ...
+TypeError
+
+>>> print g.gi_frame
+None
+
+>>> g.send(2)
+Traceback (most recent call last):
+  ...
+StopIteration
+
+>>> g.throw(ValueError,6)       # throw on closed generator
+Traceback (most recent call last):
+  ...
+ValueError: 6
+
+>>> f().throw(ValueError,7)     # throw on just-opened generator
+Traceback (most recent call last):
+  ...
+ValueError: 7
+
+
+Now let's try closing a generator:
+
+>>> def f():
+...     try: yield
+...     except GeneratorExit:
+...         print "exiting"
+
+>>> g = f()
+>>> g.next()
+>>> g.close()
+exiting
+>>> g.close()  # should be no-op now
+
+>>> f().close()  # close on just-opened generator should be fine
+
+>>> def f(): yield      # an even simpler generator
+>>> f().close()         # close before opening
+>>> g = f()
+>>> g.next()
+>>> g.close()           # close normally
+
+And finalization:
+
+>>> def f():
+...     try: yield
+...     finally:
+...         print "exiting"
+
+>>> g = f()
+>>> g.next()
+>>> del g
+exiting
+
+
+Now let's try some ill-behaved generators:
+
+>>> def f():
+...     try: yield
+...     except GeneratorExit:
+...         yield "foo!"
+>>> g = f()
+>>> g.next()
+>>> g.close()
+Traceback (most recent call last):
+  ...
+RuntimeError: generator ignored GeneratorExit
+>>> g.close()
+
+
+Our ill-behaved code should be invoked during GC:
+
+>>> import sys, StringIO
+>>> old, sys.stderr = sys.stderr, StringIO.StringIO()
+>>> g = f()
+>>> g.next()
+>>> del g
+>>> sys.stderr.getvalue().startswith(
+...     "Exception exceptions.RuntimeError: 'generator ignored GeneratorExit' in "
+... )
+True
+>>> sys.stderr = old
+
+
+And errors thrown during closing should propagate:
+
+>>> def f():
+...     try: yield
+...     except GeneratorExit:
+...         raise TypeError("fie!")
+>>> g = f()
+>>> g.next()
+>>> g.close()
+Traceback (most recent call last):
+  ...
+TypeError: fie!
+
+
+Ensure that various yield expression constructs make their
+enclosing function a generator:
+
+>>> def f(): x += yield
+>>> type(f())
+<type 'generator'>
+
+>>> def f(): x = yield
+>>> type(f())
+<type 'generator'>
+
+>>> def f(): lambda x=(yield): 1
+>>> type(f())
+<type 'generator'>
+
+>>> def f(): x=(i for i in (yield) if (yield))
+>>> type(f())
+<type 'generator'>
+
+>>> def f(d): d[(yield "a")] = d[(yield "b")] = 27
+>>> data = [1,2]
+>>> g = f(data)
+>>> type(g)
+<type 'generator'>
+>>> g.send(None)
+'a'
+>>> data
+[1, 2]
+>>> g.send(0)
+'b'
+>>> data
+[27, 2]
+>>> try: g.send(1)
+... except StopIteration: pass
+>>> data
+[27, 27]
+
+"""
+
 __test__ = {"tut":      tutorial_tests,
             "pep":      pep_tests,
             "email":    email_tests,
@@ -1390,6 +1713,7 @@
             "syntax":   syntax_tests,
             "conjoin":  conjoin_tests,
             "weakref":  weakref_tests,
+            "coroutine":  coroutine_tests,
             }
 
 # Magic test name that regrtest.py invokes *after* importing this module.

Index: test_genexps.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_genexps.py,v
retrieving revision 1.7.4.2
retrieving revision 1.7.4.3
diff -u -d -r1.7.4.2 -r1.7.4.3
--- test_genexps.py	13 Oct 2005 16:11:15 -0000	1.7.4.2
+++ test_genexps.py	16 Oct 2005 05:24:00 -0000	1.7.4.3
@@ -133,8 +133,6 @@
     SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_genexps.__test__.doctests[39]>, line 1)
 
 
-
-
 ########### Tests borrowed from or inspired by test_generators.py ############
 
 Make a generator that acts like range()

Index: test_getargs2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getargs2.py,v
retrieving revision 1.4.4.2
retrieving revision 1.4.4.3
diff -u -d -r1.4.4.2 -r1.4.4.3
--- test_getargs2.py	7 Jan 2005 06:59:09 -0000	1.4.4.2
+++ test_getargs2.py	16 Oct 2005 05:24:00 -0000	1.4.4.3
@@ -187,16 +187,10 @@
     def test_L(self):
         from _testcapi import getargs_L
         # L returns 'long long', and does range checking (LLONG_MIN ... LLONG_MAX)
-
-        # XXX There's a bug in getargs.c, format code "L":
-        # If you pass something else than a Python long, you
-        # get "Bad argument to internal function".
-
-        # So these three tests are commented out:
-
-##        self.failUnlessEqual(3, getargs_L(3.14))
-##        self.failUnlessEqual(99, getargs_L(Long()))
-##        self.failUnlessEqual(99, getargs_L(Int()))
+        self.failUnlessRaises(TypeError, getargs_L, "Hello")
+        self.failUnlessEqual(3, getargs_L(3.14))
+        self.failUnlessEqual(99, getargs_L(Long()))
+        self.failUnlessEqual(99, getargs_L(Int()))
 
         self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1)
         self.failUnlessEqual(LLONG_MIN, getargs_L(LLONG_MIN))

Index: test_glob.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_glob.py,v
retrieving revision 1.3.14.2
retrieving revision 1.3.14.3
diff -u -d -r1.3.14.2 -r1.3.14.3
--- test_glob.py	7 Jan 2005 06:59:09 -0000	1.3.14.2
+++ test_glob.py	16 Oct 2005 05:24:00 -0000	1.3.14.3
@@ -2,35 +2,7 @@
 from test.test_support import run_unittest, TESTFN
 import glob
 import os
-
-def mkdirs(fname):
-    if os.path.exists(fname) or fname == '':
-        return
-    base, file = os.path.split(fname)
-    mkdirs(base)
-    os.mkdir(fname)
-
-def touchfile(fname):
-    base, file = os.path.split(fname)
-    mkdirs(base)
-    f = open(fname, 'w')
-    f.close()
-
-def deltree(fname):
-    for f in os.listdir(fname):
-        fullname = os.path.join(fname, f)
-        if os.path.isdir(fullname):
-            deltree(fullname)
-        else:
-            try:
-                os.unlink(fullname)
-            except:
-                pass
-    try:
-        os.rmdir(fname)
-    except:
-        pass
-
+import shutil
 
 class GlobTests(unittest.TestCase):
 
@@ -38,7 +10,12 @@
         return os.path.normpath(os.path.join(self.tempdir, *parts))
 
     def mktemp(self, *parts):
-        touchfile(self.norm(*parts))
+        filename = self.norm(*parts)
+        base, file = os.path.split(filename)
+        if not os.path.exists(base):
+            os.makedirs(base)
+        f = open(filename, 'w')
+        f.close()
 
     def setUp(self):
         self.tempdir = TESTFN+"_dir"
@@ -53,7 +30,7 @@
             os.symlink(self.norm('broken'), self.norm('sym2'))
 
     def tearDown(self):
-        deltree(self.tempdir)
+        shutil.rmtree(self.tempdir)
 
     def glob(self, *parts):
         if len(parts) == 1:
@@ -61,7 +38,9 @@
         else:
             pattern = os.path.join(*parts)
         p = os.path.join(self.tempdir, pattern)
-        return glob.glob(p)
+        res = glob.glob(p)
+        self.assertEqual(list(glob.iglob(p)), res)
+        return res
 
     def assertSequencesEqual_noorder(self, l1, l2):
         self.assertEqual(set(l1), set(l2))

Index: test_grammar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v
retrieving revision 1.40.8.4
retrieving revision 1.40.8.5
diff -u -d -r1.40.8.4 -r1.40.8.5
--- test_grammar.py	2 Jun 2005 05:14:34 -0000	1.40.8.4
+++ test_grammar.py	16 Oct 2005 05:24:00 -0000	1.40.8.5
@@ -692,8 +692,9 @@
 ### testlist: test (',' test)* [',']
 # These have been exercised enough above
 
-print 'classdef' # 'class' NAME ['(' testlist ')'] ':' suite
+print 'classdef' # 'class' NAME ['(' [testlist] ')'] ':' suite
 class B: pass
+class B2(): pass
 class C1(B): pass
 class C2(B): pass
 class D(C1, C2, B): pass

Index: test_gzip.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gzip.py,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.3
diff -u -d -r1.9.2.2 -r1.9.2.3
--- test_gzip.py	7 Jan 2005 06:59:09 -0000	1.9.2.2
+++ test_gzip.py	16 Oct 2005 05:24:00 -0000	1.9.2.3
@@ -1,8 +1,12 @@
-from test.test_support import verify, TESTFN
+#! /usr/bin/env python
+"""Test script for the gzip module.
+"""
+
+import unittest
+from test import test_support
 import sys, os
 import gzip
 
-filename = TESTFN
 
 data1 = """  int length=DEFAULTALLOC, err = Z_OK;
   PyObject *RetVal;
@@ -16,75 +20,130 @@
 /* See http://www.winimage.com/zLibDll for Windows */
 """
 
-f = gzip.GzipFile(filename, 'wb') ; f.write(data1 * 50)
 
-# Try flush and fileno.
-f.flush()
-f.fileno()
-if hasattr(os, 'fsync'):
-    os.fsync(f.fileno())
-f.close()
+class TestGzip(unittest.TestCase):
+    filename = test_support.TESTFN
 
-# Try reading.
-f = gzip.GzipFile(filename, 'r') ; d = f.read() ; f.close()
-verify(d == data1*50)
+    def setUp (self):
+        pass
 
-# Append to the previous file
-f = gzip.GzipFile(filename, 'ab') ; f.write(data2 * 15) ; f.close()
+    def tearDown (self):
+        try:
+            os.unlink(self.filename)
+        except os.error:
+            pass
 
-f = gzip.GzipFile(filename, 'rb') ; d = f.read() ; f.close()
-verify(d == (data1*50) + (data2*15))
 
-# Try .readline() with varying line lengths
+    def test_write (self):
+        f = gzip.GzipFile(self.filename, 'wb') ; f.write(data1 * 50)
 
-f = gzip.GzipFile(filename, 'rb')
-line_length = 0
-while 1:
-    L = f.readline(line_length)
-    if L == "" and line_length != 0: break
-    verify(len(L) <= line_length)
-    line_length = (line_length + 1) % 50
-f.close()
+        # Try flush and fileno.
+        f.flush()
+        f.fileno()
+        if hasattr(os, 'fsync'):
+            os.fsync(f.fileno())
+        f.close()
 
-# Try .readlines()
+    def test_read(self):
+        self.test_write()
+        # Try reading.
+        f = gzip.GzipFile(self.filename, 'r') ; d = f.read() ; f.close()
+        self.assertEqual(d, data1*50)
 
-f = gzip.GzipFile(filename, 'rb')
-L = f.readlines()
-f.close()
+    def test_append(self):
+        self.test_write()
+        # Append to the previous file
+        f = gzip.GzipFile(self.filename, 'ab') ; f.write(data2 * 15) ; f.close()
 
-f = gzip.GzipFile(filename, 'rb')
-while 1:
-    L = f.readlines(150)
-    if L == []: break
-f.close()
+        f = gzip.GzipFile(self.filename, 'rb') ; d = f.read() ; f.close()
+        self.assertEqual(d, (data1*50) + (data2*15))
 
-# Try seek, read test
+    def test_many_append(self):
+        # Bug #1074261 was triggered when reading a file that contained
+        # many, many members.  Create such a file and verify that reading it
+        # works.
+        f = gzip.open(self.filename, 'wb', 9)
+        f.write('a')
+        f.close()
+        for i in range(0,200):
+            f = gzip.open(self.filename, "ab", 9) # append
+            f.write('a')
+            f.close()
 
-f = gzip.GzipFile(filename)
-while 1:
-    oldpos = f.tell()
-    line1 = f.readline()
-    if not line1: break
-    newpos = f.tell()
-    f.seek(oldpos)  # negative seek
-    if len(line1)>10:
-        amount = 10
-    else:
-        amount = len(line1)
-    line2 = f.read(amount)
-    verify(line1[:amount] == line2)
-    f.seek(newpos)  # positive seek
-f.close()
+        # Try reading the file
+        zgfile = gzip.open(self.filename, "rb")
+        contents = ""
+        while 1:
+            ztxt = zgfile.read(8192)
+            contents += ztxt
+            if not ztxt: break
+        zgfile.close()
+        self.assertEquals(contents, 'a'*201)
 
-# Try seek, write test
-f = gzip.GzipFile(filename, 'w')
-for pos in range(0, 256, 16):
-    f.seek(pos)
-    f.write('GZ\n')
-f.close()
 
-f = gzip.GzipFile(filename, 'r')
-verify(f.myfileobj.mode == 'rb')
-f.close()
+    def test_readline(self):
+        self.test_write()
+        # Try .readline() with varying line lengths
 
-os.unlink(filename)
+        f = gzip.GzipFile(self.filename, 'rb')
+        line_length = 0
+        while 1:
+            L = f.readline(line_length)
+            if L == "" and line_length != 0: break
+            self.assert_(len(L) <= line_length)
+            line_length = (line_length + 1) % 50
+        f.close()
+
+    def test_readlines(self):
+        self.test_write()
+        # Try .readlines()
+
+        f = gzip.GzipFile(self.filename, 'rb')
+        L = f.readlines()
+        f.close()
+
+        f = gzip.GzipFile(self.filename, 'rb')
+        while 1:
+            L = f.readlines(150)
+            if L == []: break
+        f.close()
+
+    def test_seek_read(self):
+        self.test_write()
+        # Try seek, read test
+
+        f = gzip.GzipFile(self.filename)
+        while 1:
+            oldpos = f.tell()
+            line1 = f.readline()
+            if not line1: break
+            newpos = f.tell()
+            f.seek(oldpos)  # negative seek
+            if len(line1)>10:
+                amount = 10
+            else:
+                amount = len(line1)
+            line2 = f.read(amount)
+            self.assertEqual(line1[:amount], line2)
+            f.seek(newpos)  # positive seek
+        f.close()
+
+    def test_seek_write(self):
+        # Try seek, write test
+        f = gzip.GzipFile(self.filename, 'w')
+        for pos in range(0, 256, 16):
+            f.seek(pos)
+            f.write('GZ\n')
+        f.close()
+
+    def test_mode(self):
+        self.test_write()
+        f = gzip.GzipFile(self.filename, 'r')
+        self.assertEqual(f.myfileobj.mode, 'rb')
+        f.close()
+
+def test_main(verbose=None):
+    test_support.run_unittest(TestGzip)
+
+if __name__ == "__main__":
+    test_main(verbose=True)

Index: test_hmac.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_hmac.py,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -u -d -r1.4.2.2 -r1.4.2.3
--- test_hmac.py	7 Jan 2005 06:59:09 -0000	1.4.2.2
+++ test_hmac.py	16 Oct 2005 05:24:00 -0000	1.4.2.3
@@ -105,9 +105,10 @@
 
     def test_default_is_md5(self):
         # Testing if HMAC defaults to MD5 algorithm.
-        import md5
+        # NOTE: this whitebox test depends on the hmac class internals
+        import hashlib
         h = hmac.HMAC("key")
-        self.failUnless(h.digestmod == md5)
+        self.failUnless(h.digest_cons == hashlib.md5)
 
     def test_exercise_all_methods(self):
         # Exercising all methods once.
@@ -127,8 +128,8 @@
         # Testing if attributes are of same type.
         h1 = hmac.HMAC("key")
         h2 = h1.copy()
-        self.failUnless(h1.digestmod == h2.digestmod,
-            "Modules don't match.")
+        self.failUnless(h1.digest_cons == h2.digest_cons,
+            "digest constructors don't match.")
         self.failUnless(type(h1.inner) == type(h2.inner),
             "Types of inner don't match.")
         self.failUnless(type(h1.outer) == type(h2.outer),

Index: test_inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v
retrieving revision 1.7.12.2
retrieving revision 1.7.12.3
diff -u -d -r1.7.12.2 -r1.7.12.3
--- test_inspect.py	7 Jan 2005 06:59:09 -0000	1.7.12.2
+++ test_inspect.py	16 Oct 2005 05:24:00 -0000	1.7.12.3
@@ -31,11 +31,11 @@
     predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode,
                       inspect.isframe, inspect.isfunction, inspect.ismethod,
                       inspect.ismodule, inspect.istraceback])
-    
+
     def istest(self, predicate, exp):
         obj = eval(exp)
         self.failUnless(predicate(obj), '%s(%s)' % (predicate.__name__, exp))
-        
+
         for other in self.predicates - set([predicate]):
             self.failIf(other(obj), 'not %s(%s)' % (other.__name__, exp))
 
@@ -44,7 +44,7 @@
         # Doc/lib/libinspect.tex claims there are 11 such functions
         count = len(filter(lambda x:x.startswith('is'), dir(inspect)))
         self.assertEqual(count, 11, "There are %d (not 11) is* functions" % count)
-    
+
     def test_excluding_predicates(self):
         self.istest(inspect.isbuiltin, 'sys.exit')
         self.istest(inspect.isbuiltin, '[].append')
@@ -66,7 +66,7 @@
 class TestInterpreterStack(IsTestBase):
     def __init__(self, *args, **kwargs):
         unittest.TestCase.__init__(self, *args, **kwargs)
-    
+
         git.abuse(7, 8, 9)
 
     def test_abuse_done(self):
@@ -76,7 +76,7 @@
     def test_stack(self):
         self.assert_(len(mod.st) >= 5)
         self.assertEqual(mod.st[0][1:],
-             (modfile, 16, 'eggs', ['    st = inspect.stack()\n'], 0))             
+             (modfile, 16, 'eggs', ['    st = inspect.stack()\n'], 0))
         self.assertEqual(mod.st[1][1:],
              (modfile, 9, 'spam', ['    eggs(b + d, c + f)\n'], 0))
         self.assertEqual(mod.st[2][1:],
@@ -113,7 +113,7 @@
 class GetSourceBase(unittest.TestCase):
     # Subclasses must override.
     fodderFile = None
-    
+
     def __init__(self, *args, **kwargs):
         unittest.TestCase.__init__(self, *args, **kwargs)
 
@@ -126,10 +126,10 @@
     def assertSourceEqual(self, obj, top, bottom):
         self.assertEqual(inspect.getsource(obj),
                          self.sourcerange(top, bottom))
-    
+
 class TestRetrievingSourceCode(GetSourceBase):
     fodderFile = mod
-    
+
     def test_getclasses(self):
         classes = inspect.getmembers(mod, inspect.isclass)
         self.assertEqual(classes,
@@ -147,7 +147,7 @@
                             ]
                            ]
                           ])
-        
+
     def test_getfunctions(self):
         functions = inspect.getmembers(mod, inspect.isfunction)
         self.assertEqual(functions, [('eggs', mod.eggs),
@@ -172,8 +172,8 @@
         self.assertSourceEqual(mod.StupidGit, 21, 46)
 
     def test_getsourcefile(self):
-         self.assertEqual(inspect.getsourcefile(mod.spam), modfile)
-         self.assertEqual(inspect.getsourcefile(git.abuse), modfile)
+        self.assertEqual(inspect.getsourcefile(mod.spam), modfile)
+        self.assertEqual(inspect.getsourcefile(git.abuse), modfile)
 
     def test_getfile(self):
         self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
@@ -192,48 +192,69 @@
     def test_oneline_lambda(self):
         # Test inspect.getsource with a one-line lambda function.
         self.assertSourceEqual(mod2.oll, 25, 25)
-    
+
     def test_threeline_lambda(self):
         # Test inspect.getsource with a three-line lambda function,
         # where the second and third lines are _not_ indented.
-        self.assertSourceEqual(mod2.tll, 28, 30)        
-    
+        self.assertSourceEqual(mod2.tll, 28, 30)
+
     def test_twoline_indented_lambda(self):
         # Test inspect.getsource with a two-line lambda function,
         # where the second line _is_ indented.
         self.assertSourceEqual(mod2.tlli, 33, 34)
-    
+
     def test_onelinefunc(self):
         # Test inspect.getsource with a regular one-line function.
         self.assertSourceEqual(mod2.onelinefunc, 37, 37)
-    
+
     def test_manyargs(self):
         # Test inspect.getsource with a regular function where
         # the arguments are on two lines and _not_ indented and
         # the body on the second line with the last arguments.
         self.assertSourceEqual(mod2.manyargs, 40, 41)
-    
+
     def test_twolinefunc(self):
         # Test inspect.getsource with a regular function where
         # the body is on two lines, following the argument list and
         # continued on the next line by a \\.
         self.assertSourceEqual(mod2.twolinefunc, 44, 45)
-    
+
     def test_lambda_in_list(self):
         # Test inspect.getsource with a one-line lambda function
         # defined in a list, indented.
         self.assertSourceEqual(mod2.a[1], 49, 49)
-    
+
     def test_anonymous(self):
         # Test inspect.getsource with a lambda function defined
         # as argument to another function.
         self.assertSourceEqual(mod2.anonymous, 55, 55)
 
+class TestBuggyCases(GetSourceBase):
+    fodderFile = mod2
+
+    def test_with_comment(self):
+        self.assertSourceEqual(mod2.with_comment, 58, 59)
+
+    def test_multiline_sig(self):
+        self.assertSourceEqual(mod2.multiline_sig[0], 63, 64)
+
+    def test_nested_class(self):
+        self.assertSourceEqual(mod2.func69().func71, 71, 72)
+
+    def test_one_liner_followed_by_non_name(self):
+        self.assertSourceEqual(mod2.func77, 77, 77)
+
+    def test_one_liner_dedent_non_name(self):
+        self.assertSourceEqual(mod2.cls82.func83, 83, 83)
+
+    def test_with_comment_instead_of_docstring(self):
+        self.assertSourceEqual(mod2.func88, 88, 90)
+
 # Helper for testing classify_class_attrs.
 def attrs_wo_objs(cls):
     return [t[:3] for t in inspect.classify_class_attrs(cls)]
 
-class TestClassesAndFunctions(unittest.TestCase):    
+class TestClassesAndFunctions(unittest.TestCase):
     def test_classic_mro(self):
         # Test classic-class method resolution order.
         class A:    pass
@@ -284,7 +305,7 @@
 
     def test_getargspec_sublistofone(self):
         def sublistOfOne((foo)): return 1
-        
+
         self.assertArgSpecEquals(sublistOfOne, [['foo']])
 
     def test_classify_oldstyle(self):
@@ -414,8 +435,8 @@
 
 def test_main():
     run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners,
+                 TestBuggyCases,
                  TestInterpreterStack, TestClassesAndFunctions, TestPredicates)
 
 if __name__ == "__main__":
     test_main()
-    

Index: test_ioctl.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ioctl.py,v
retrieving revision 1.2.6.1
retrieving revision 1.2.6.2
diff -u -d -r1.2.6.1 -r1.2.6.2
--- test_ioctl.py	28 Apr 2003 17:28:39 -0000	1.2.6.1
+++ test_ioctl.py	16 Oct 2005 05:24:00 -0000	1.2.6.2
@@ -1,5 +1,5 @@
 import unittest
-from test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest
 import os, struct
 try:
     import fcntl, termios
@@ -16,19 +16,23 @@
 
 class IoctlTests(unittest.TestCase):
     def test_ioctl(self):
-        pgrp = os.getpgrp()
+        # If this process has been put into the background, TIOCGPGRP returns
+        # the session ID instead of the process group id.
+        ids = (os.getpgrp(), os.getsid(0))
         tty = open("/dev/tty", "r")
         r = fcntl.ioctl(tty, termios.TIOCGPGRP, "    ")
-        self.assertEquals(pgrp, struct.unpack("i", r)[0])
+        rpgrp = struct.unpack("i", r)[0]
+        self.assert_(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
 
     def test_ioctl_mutate(self):
         import array
         buf = array.array('i', [0])
-        pgrp = os.getpgrp()
+        ids = (os.getpgrp(), os.getsid(0))
         tty = open("/dev/tty", "r")
         r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
+        rpgrp = buf[0]
         self.assertEquals(r, 0)
-        self.assertEquals(pgrp, buf[0])
+        self.assert_(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
 
 def test_main():
     run_unittest(IoctlTests)

Index: test_isinstance.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_isinstance.py,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -d -r1.3.2.2 -r1.3.2.3
--- test_isinstance.py	7 Jan 2005 06:59:09 -0000	1.3.2.2
+++ test_isinstance.py	16 Oct 2005 05:24:01 -0000	1.3.2.3
@@ -243,7 +243,8 @@
         self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,))))
 
         self.assertEqual(True, issubclass(int, (long, (float, int))))
-        self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
+        if test_support.have_unicode:
+            self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
 
     def test_subclass_recursion_limit(self):
         # make sure that issubclass raises RuntimeError before the C stack is

Index: test_iterlen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_iterlen.py,v
retrieving revision 1.2.6.1
retrieving revision 1.2.6.2
diff -u -d -r1.2.6.1 -r1.2.6.2
--- test_iterlen.py	7 Jan 2005 06:59:09 -0000	1.2.6.1
+++ test_iterlen.py	16 Oct 2005 05:24:01 -0000	1.2.6.2
@@ -43,12 +43,22 @@
 
 import unittest
 from test import test_support
-from itertools import repeat, count
+from itertools import repeat
 from collections import deque
 from UserList import UserList
+from __builtin__ import len as _len
 
 n = 10
 
+def len(obj):
+    try:
+        return _len(obj)
+    except TypeError:
+        try:
+            return obj._length_cue()
+        except AttributeError:
+            raise TypeError
+
 class TestInvariantWithoutMutations(unittest.TestCase):
 
     def test_invariant(self):

Index: test_itertools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v
retrieving revision 1.5.6.2
retrieving revision 1.5.6.3
diff -u -d -r1.5.6.2 -r1.5.6.3
--- test_itertools.py	7 Jan 2005 06:59:09 -0000	1.5.6.2
+++ test_itertools.py	16 Oct 2005 05:24:01 -0000	1.5.6.3
@@ -265,6 +265,11 @@
         self.assertEqual(list(islice(xrange(10), 2, None)), range(2, 10))
         self.assertEqual(list(islice(xrange(10), 1, None, 2)), range(1, 10, 2))
 
+        # Test number of items consumed     SF #1171417
+        it = iter(range(10))
+        self.assertEqual(list(islice(it, 3)), range(3))
+        self.assertEqual(list(it), range(3, 10))
+
         # Test invalid arguments
         self.assertRaises(TypeError, islice, xrange(10))
         self.assertRaises(TypeError, islice, xrange(10), 1, 2, 3, 4)
@@ -665,6 +670,7 @@
 class LengthTransparency(unittest.TestCase):
 
     def test_repeat(self):
+        from test.test_iterlen import len
         self.assertEqual(len(repeat(None, 50)), 50)
         self.assertRaises(TypeError, len, repeat(None))
 
@@ -799,26 +805,26 @@
 ...     "Returns the nth item"
 ...     return list(islice(iterable, n, n+1))
 
->>> def all(seq, pred=bool):
-...     "Returns True if pred(x) is True for every element in the iterable"
+>>> def all(seq, pred=None):
+...     "Returns True if pred(x) is true for every element in the iterable"
 ...     for elem in ifilterfalse(pred, seq):
 ...         return False
 ...     return True
 
->>> def any(seq, pred=bool):
-...     "Returns True if pred(x) is True for at least one element in the iterable"
+>>> def any(seq, pred=None):
+...     "Returns True if pred(x) is true for at least one element in the iterable"
 ...     for elem in ifilter(pred, seq):
 ...         return True
 ...     return False
 
->>> def no(seq, pred=bool):
-...     "Returns True if pred(x) is False for every element in the iterable"
+>>> def no(seq, pred=None):
+...     "Returns True if pred(x) is false for every element in the iterable"
 ...     for elem in ifilter(pred, seq):
 ...         return False
 ...     return True
 
->>> def quantify(seq, pred=bool):
-...     "Count how many times the predicate is True in the sequence"
+>>> def quantify(seq, pred=None):
+...     "Count how many times the predicate is true in the sequence"
 ...     return sum(imap(pred, seq))
 
 >>> def padnone(seq):

Index: test_locale.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_locale.py,v
retrieving revision 1.3.20.2
retrieving revision 1.3.20.3
diff -u -d -r1.3.20.2 -r1.3.20.3
--- test_locale.py	7 Jan 2005 06:59:09 -0000	1.3.20.2
+++ test_locale.py	16 Oct 2005 05:24:01 -0000	1.3.20.3
@@ -7,16 +7,18 @@
 oldlocale = locale.setlocale(locale.LC_NUMERIC)
 
 if sys.platform.startswith("win"):
-    tloc = "en"
-elif sys.platform.startswith("freebsd"):
-    tloc = "en_US.US-ASCII"
+    tlocs = ("en",)
 else:
-    tloc = "en_US"
+    tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US")
 
-try:
-    locale.setlocale(locale.LC_NUMERIC, tloc)
-except locale.Error:
-    raise ImportError, "test locale %s not supported" % tloc
+for tloc in tlocs:
+    try:
+        locale.setlocale(locale.LC_NUMERIC, tloc)
+        break
+    except locale.Error:
+        continue
+else:
+    raise ImportError, "test locale not supported (tried %s)"%(', '.join(tlocs))
 
 def testformat(formatstr, value, grouping = 0, output=None):
     if verbose:

Index: test_long.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_long.py,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -d -r1.16.2.2 -r1.16.2.3
--- test_long.py	7 Jan 2005 06:59:09 -0000	1.16.2.2
+++ test_long.py	16 Oct 2005 05:24:01 -0000	1.16.2.3
@@ -1,6 +1,16 @@
-from test.test_support import verify, verbose, TestFailed, fcmp
-from string import join
-from random import random, randint
+import unittest
+from test import test_support
+
+import random
+
+# Used for lazy formatting of failure messages
+class Frm(object):
+    def __init__(self, format, *args):
+        self.format = format
+        self.args = args
+
+    def __str__(self):
+        return self.format % self.args
 
 # SHIFT should match the value in longintrepr.h for best testing.
 SHIFT = 15
@@ -26,518 +36,451 @@
 special = special + map(lambda x: ~x, special) + \
                     map(lambda x: -x, special)
 
-# ------------------------------------------------------------ utilities
-
-# Use check instead of assert so the test still does something
-# under -O.
-
-def check(ok, *args):
-    if not ok:
-        raise TestFailed, join(map(str, args), " ")
-
-# Get quasi-random long consisting of ndigits digits (in base BASE).
-# quasi == the most-significant digit will not be 0, and the number
-# is constructed to contain long strings of 0 and 1 bits.  These are
-# more likely than random bits to provoke digit-boundary errors.
-# The sign of the number is also random.
-
-def getran(ndigits):
-    verify(ndigits > 0)
-    nbits_hi = ndigits * SHIFT
-    nbits_lo = nbits_hi - SHIFT + 1
-    answer = 0L
-    nbits = 0
-    r = int(random() * (SHIFT * 2)) | 1  # force 1 bits to start
-    while nbits < nbits_lo:
-        bits = (r >> 1) + 1
-        bits = min(bits, nbits_hi - nbits)
-        verify(1 <= bits <= SHIFT)
-        nbits = nbits + bits
-        answer = answer << bits
-        if r & 1:
-            answer = answer | ((1 << bits) - 1)
-        r = int(random() * (SHIFT * 2))
-    verify(nbits_lo <= nbits <= nbits_hi)
-    if random() < 0.5:
-        answer = -answer
-    return answer
-
-# Get random long consisting of ndigits random digits (relative to base
-# BASE).  The sign bit is also random.
 
-def getran2(ndigits):
-    answer = 0L
-    for i in range(ndigits):
-        answer = (answer << SHIFT) | randint(0, MASK)
-    if random() < 0.5:
-        answer = -answer
-    return answer
+class LongTest(unittest.TestCase):
 
-# --------------------------------------------------------------- divmod
+    # Get quasi-random long consisting of ndigits digits (in base BASE).
+    # quasi == the most-significant digit will not be 0, and the number
+    # is constructed to contain long strings of 0 and 1 bits.  These are
+    # more likely than random bits to provoke digit-boundary errors.
+    # The sign of the number is also random.
 
-def test_division_2(x, y):
-    q, r = divmod(x, y)
-    q2, r2 = x//y, x%y
-    pab, pba = x*y, y*x
-    check(pab == pba, "multiplication does not commute for", x, y)
-    check(q == q2, "divmod returns different quotient than / for", x, y)
-    check(r == r2, "divmod returns different mod than % for", x, y)
-    check(x == q*y + r, "x != q*y + r after divmod on", x, y)
-    if y > 0:
-        check(0 <= r < y, "bad mod from divmod on", x, y)
-    else:
-        check(y < r <= 0, "bad mod from divmod on", x, y)
+    def getran(self, ndigits):
+        self.assert_(ndigits > 0)
+        nbits_hi = ndigits * SHIFT
+        nbits_lo = nbits_hi - SHIFT + 1
+        answer = 0L
+        nbits = 0
+        r = int(random.random() * (SHIFT * 2)) | 1  # force 1 bits to start
+        while nbits < nbits_lo:
+            bits = (r >> 1) + 1
+            bits = min(bits, nbits_hi - nbits)
+            self.assert_(1 <= bits <= SHIFT)
+            nbits = nbits + bits
+            answer = answer << bits
+            if r & 1:
+                answer = answer | ((1 << bits) - 1)
+            r = int(random.random() * (SHIFT * 2))
+        self.assert_(nbits_lo <= nbits <= nbits_hi)
+        if random.random() < 0.5:
+            answer = -answer
+        return answer
 
-def test_division(maxdigits=MAXDIGITS):
-    if verbose:
-        print "long / * % divmod"
-    digits = range(1, maxdigits+1) + range(KARATSUBA_CUTOFF,
-                                           KARATSUBA_CUTOFF + 14)
-    digits.append(KARATSUBA_CUTOFF * 3)
-    for lenx in digits:
-        x = getran(lenx)
-        for leny in digits:
-            y = getran(leny) or 1L
-            test_division_2(x, y)
-# ------------------------------------------------------------ karatsuba
+    # Get random long consisting of ndigits random digits (relative to base
+    # BASE).  The sign bit is also random.
 
-def test_karatsuba():
+    def getran2(ndigits):
+        answer = 0L
+        for i in xrange(ndigits):
+            answer = (answer << SHIFT) | random.randint(0, MASK)
+        if random.random() < 0.5:
+            answer = -answer
+        return answer
 
-    if verbose:
-        print "Karatsuba"
+    def check_division(self, x, y):
+        eq = self.assertEqual
+        q, r = divmod(x, y)
+        q2, r2 = x//y, x%y
+        pab, pba = x*y, y*x
+        eq(pab, pba, Frm("multiplication does not commute for %r and %r", x, y))
+        eq(q, q2, Frm("divmod returns different quotient than / for %r and %r", x, y))
+        eq(r, r2, Frm("divmod returns different mod than %% for %r and %r", x, y))
+        eq(x, q*y + r, Frm("x != q*y + r after divmod on x=%r, y=%r", x, y))
+        if y > 0:
+            self.assert_(0 <= r < y, Frm("bad mod from divmod on %r and %r", x, y))
+        else:
+            self.assert_(y < r <= 0, Frm("bad mod from divmod on %r and %r", x, y))
 
-    digits = range(1, 5) + range(KARATSUBA_CUTOFF, KARATSUBA_CUTOFF + 10)
-    digits.extend([KARATSUBA_CUTOFF * 10, KARATSUBA_CUTOFF * 100])
+    def test_division(self):
+        digits = range(1, MAXDIGITS+1) + range(KARATSUBA_CUTOFF,
+                                               KARATSUBA_CUTOFF + 14)
+        digits.append(KARATSUBA_CUTOFF * 3)
+        for lenx in digits:
+            x = self.getran(lenx)
+            for leny in digits:
+                y = self.getran(leny) or 1L
+                self.check_division(x, y)
 
-    bits = [digit * SHIFT for digit in digits]
+    def test_karatsuba(self):
+        digits = range(1, 5) + range(KARATSUBA_CUTOFF, KARATSUBA_CUTOFF + 10)
+        digits.extend([KARATSUBA_CUTOFF * 10, KARATSUBA_CUTOFF * 100])
 
-    # Test products of long strings of 1 bits -- (2**x-1)*(2**y-1) ==
-    # 2**(x+y) - 2**x - 2**y + 1, so the proper result is easy to check.
-    for abits in bits:
-        a = (1L << abits) - 1
-        for bbits in bits:
-            if bbits < abits:
-                continue
-            b = (1L << bbits) - 1
-            x = a * b
-            y = ((1L << (abits + bbits)) -
-                 (1L << abits) -
-                 (1L << bbits) +
-                 1)
-            check(x == y, "bad result for", a, "*", b, x, y)
-# -------------------------------------------------------------- ~ & | ^
+        bits = [digit * SHIFT for digit in digits]
 
-def test_bitop_identities_1(x):
-    check(x & 0 == 0, "x & 0 != 0 for", x)
-    check(x | 0 == x, "x | 0 != x for", x)
-    check(x ^ 0 == x, "x ^ 0 != x for", x)
-    check(x & -1 == x, "x & -1 != x for", x)
-    check(x | -1 == -1, "x | -1 != -1 for", x)
-    check(x ^ -1 == ~x, "x ^ -1 != ~x for", x)
-    check(x == ~~x, "x != ~~x for", x)
-    check(x & x == x, "x & x != x for", x)
-    check(x | x == x, "x | x != x for", x)
-    check(x ^ x == 0, "x ^ x != 0 for", x)
-    check(x & ~x == 0, "x & ~x != 0 for", x)
-    check(x | ~x == -1, "x | ~x != -1 for", x)
-    check(x ^ ~x == -1, "x ^ ~x != -1 for", x)
-    check(-x == 1 + ~x == ~(x-1), "not -x == 1 + ~x == ~(x-1) for", x)
-    for n in range(2*SHIFT):
-        p2 = 2L ** n
-        check(x << n >> n == x, "x << n >> n != x for", x, n)
-        check(x // p2 == x >> n, "x // p2 != x >> n for x n p2", x, n, p2)
-        check(x * p2 == x << n, "x * p2 != x << n for x n p2", x, n, p2)
-        check(x & -p2 == x >> n << n == x & ~(p2 - 1),
-            "not x & -p2 == x >> n << n == x & ~(p2 - 1) for x n p2",
-            x, n, p2)
+        # Test products of long strings of 1 bits -- (2**x-1)*(2**y-1) ==
+        # 2**(x+y) - 2**x - 2**y + 1, so the proper result is easy to check.
+        for abits in bits:
+            a = (1L << abits) - 1
+            for bbits in bits:
+                if bbits < abits:
+                    continue
+                b = (1L << bbits) - 1
+                x = a * b
+                y = ((1L << (abits + bbits)) -
+                     (1L << abits) -
+                     (1L << bbits) +
+                     1)
+                self.assertEqual(x, y,
+                    Frm("bad result for a*b: a=%r, b=%r, x=%r, y=%r", a, b, x, y))
 
-def test_bitop_identities_2(x, y):
-    check(x & y == y & x, "x & y != y & x for", x, y)
-    check(x | y == y | x, "x | y != y | x for", x, y)
-    check(x ^ y == y ^ x, "x ^ y != y ^ x for", x, y)
-    check(x ^ y ^ x == y, "x ^ y ^ x != y for", x, y)
-    check(x & y == ~(~x | ~y), "x & y != ~(~x | ~y) for", x, y)
-    check(x | y == ~(~x & ~y), "x | y != ~(~x & ~y) for", x, y)
-    check(x ^ y == (x | y) & ~(x & y),
-         "x ^ y != (x | y) & ~(x & y) for", x, y)
-    check(x ^ y == (x & ~y) | (~x & y),
-         "x ^ y == (x & ~y) | (~x & y) for", x, y)
-    check(x ^ y == (x | y) & (~x | ~y),
-         "x ^ y == (x | y) & (~x | ~y) for", x, y)
+    def check_bitop_identities_1(self, x):
+        eq = self.assertEqual
+        eq(x & 0, 0, Frm("x & 0 != 0 for x=%r", x))
+        eq(x | 0, x, Frm("x | 0 != x for x=%r", x))
+        eq(x ^ 0, x, Frm("x ^ 0 != x for x=%r", x))
+        eq(x & -1, x, Frm("x & -1 != x for x=%r", x))
+        eq(x | -1, -1, Frm("x | -1 != -1 for x=%r", x))
+        eq(x ^ -1, ~x, Frm("x ^ -1 != ~x for x=%r", x))
+        eq(x, ~~x, Frm("x != ~~x for x=%r", x))
+        eq(x & x, x, Frm("x & x != x for x=%r", x))
+        eq(x | x, x, Frm("x | x != x for x=%r", x))
+        eq(x ^ x, 0, Frm("x ^ x != 0 for x=%r", x))
+        eq(x & ~x, 0, Frm("x & ~x != 0 for x=%r", x))
+        eq(x | ~x, -1, Frm("x | ~x != -1 for x=%r", x))
+        eq(x ^ ~x, -1, Frm("x ^ ~x != -1 for x=%r", x))
+        eq(-x, 1 + ~x, Frm("not -x == 1 + ~x for x=%r", x))
+        eq(-x, ~(x-1), Frm("not -x == ~(x-1) forx =%r", x))
+        for n in xrange(2*SHIFT):
+            p2 = 2L ** n
+            eq(x << n >> n, x,
+                Frm("x << n >> n != x for x=%r, n=%r", (x, n)))
+            eq(x // p2, x >> n,
+                Frm("x // p2 != x >> n for x=%r n=%r p2=%r", (x, n, p2)))
+            eq(x * p2, x << n,
+                Frm("x * p2 != x << n for x=%r n=%r p2=%r", (x, n, p2)))
+            eq(x & -p2, x >> n << n,
+                Frm("not x & -p2 == x >> n << n for x=%r n=%r p2=%r", (x, n, p2)))
+            eq(x & -p2, x & ~(p2 - 1),
+                Frm("not x & -p2 == x & ~(p2 - 1) for x=%r n=%r p2=%r", (x, n, p2)))
 
-def test_bitop_identities_3(x, y, z):
-    check((x & y) & z == x & (y & z),
-         "(x & y) & z != x & (y & z) for", x, y, z)
-    check((x | y) | z == x | (y | z),
-         "(x | y) | z != x | (y | z) for", x, y, z)
-    check((x ^ y) ^ z == x ^ (y ^ z),
-         "(x ^ y) ^ z != x ^ (y ^ z) for", x, y, z)
-    check(x & (y | z) == (x & y) | (x & z),
-         "x & (y | z) != (x & y) | (x & z) for", x, y, z)
-    check(x | (y & z) == (x | y) & (x | z),
-         "x | (y & z) != (x | y) & (x | z) for", x, y, z)
+    def check_bitop_identities_2(self, x, y):
+        eq = self.assertEqual
+        eq(x & y, y & x, Frm("x & y != y & x for x=%r, y=%r", (x, y)))
+        eq(x | y, y | x, Frm("x | y != y | x for x=%r, y=%r", (x, y)))
+        eq(x ^ y, y ^ x, Frm("x ^ y != y ^ x for x=%r, y=%r", (x, y)))
+        eq(x ^ y ^ x, y, Frm("x ^ y ^ x != y for x=%r, y=%r", (x, y)))
+        eq(x & y, ~(~x | ~y), Frm("x & y != ~(~x | ~y) for x=%r, y=%r", (x, y)))
+        eq(x | y, ~(~x & ~y), Frm("x | y != ~(~x & ~y) for x=%r, y=%r", (x, y)))
+        eq(x ^ y, (x | y) & ~(x & y),
+             Frm("x ^ y != (x | y) & ~(x & y) for x=%r, y=%r", (x, y)))
+        eq(x ^ y, (x & ~y) | (~x & y),
+             Frm("x ^ y == (x & ~y) | (~x & y) for x=%r, y=%r", (x, y)))
+        eq(x ^ y, (x | y) & (~x | ~y),
+             Frm("x ^ y == (x | y) & (~x | ~y) for x=%r, y=%r", (x, y)))
 
-def test_bitop_identities(maxdigits=MAXDIGITS):
-    if verbose:
-        print "long bit-operation identities"
-    for x in special:
-        test_bitop_identities_1(x)
-    digits = range(1, maxdigits+1)
-    for lenx in digits:
-        x = getran(lenx)
-        test_bitop_identities_1(x)
-        for leny in digits:
-            y = getran(leny)
-            test_bitop_identities_2(x, y)
-            test_bitop_identities_3(x, y, getran((lenx + leny)//2))
+    def check_bitop_identities_3(self, x, y, z):
+        eq = self.assertEqual
+        eq((x & y) & z, x & (y & z),
+             Frm("(x & y) & z != x & (y & z) for x=%r, y=%r, z=%r", (x, y, z)))
+        eq((x | y) | z, x | (y | z),
+             Frm("(x | y) | z != x | (y | z) for x=%r, y=%r, z=%r", (x, y, z)))
+        eq((x ^ y) ^ z, x ^ (y ^ z),
+             Frm("(x ^ y) ^ z != x ^ (y ^ z) for x=%r, y=%r, z=%r", (x, y, z)))
+        eq(x & (y | z), (x & y) | (x & z),
+             Frm("x & (y | z) != (x & y) | (x & z) for x=%r, y=%r, z=%r", (x, y, z)))
+        eq(x | (y & z), (x | y) & (x | z),
+             Frm("x | (y & z) != (x | y) & (x | z) for x=%r, y=%r, z=%r", (x, y, z)))
 
-# ------------------------------------------------- hex oct repr str atol
+    def test_bitop_identities(self):
+        for x in special:
+            self.check_bitop_identities_1(x)
+        digits = xrange(1, MAXDIGITS+1)
+        for lenx in digits:
+            x = self.getran(lenx)
+            self.check_bitop_identities_1(x)
+            for leny in digits:
+                y = self.getran(leny)
+                self.check_bitop_identities_2(x, y)
+                self.check_bitop_identities_3(x, y, self.getran((lenx + leny)//2))
 
-def slow_format(x, base):
-    if (x, base) == (0, 8):
-        # this is an oddball!
-        return "0L"
-    digits = []
-    sign = 0
-    if x < 0:
-        sign, x = 1, -x
-    while x:
-        x, r = divmod(x, base)
-        digits.append(int(r))
-    digits.reverse()
-    digits = digits or [0]
-    return '-'[:sign] + \
-           {8: '0', 10: '', 16: '0x'}[base] + \
-           join(map(lambda i: "0123456789ABCDEF"[i], digits), '') + \
-           "L"
+    def slow_format(self, x, base):
+        if (x, base) == (0, 8):
+            # this is an oddball!
+            return "0L"
+        digits = []
+        sign = 0
+        if x < 0:
+            sign, x = 1, -x
+        while x:
+            x, r = divmod(x, base)
+            digits.append(int(r))
+        digits.reverse()
+        digits = digits or [0]
+        return '-'[:sign] + \
+               {8: '0', 10: '', 16: '0x'}[base] + \
+               "".join(map(lambda i: "0123456789abcdef"[i], digits)) + "L"
 
-def test_format_1(x):
-    from string import atol
-    for base, mapper in (8, oct), (10, repr), (16, hex):
-        got = mapper(x)
-        expected = slow_format(x, base)
-        check(got == expected, mapper.__name__, "returned",
-              got, "but expected", expected, "for", x)
-        check(atol(got, 0) == x, 'atol("%s", 0) !=' % got, x)
-    # str() has to be checked a little differently since there's no
-    # trailing "L"
-    got = str(x)
-    expected = slow_format(x, 10)[:-1]
-    check(got == expected, mapper.__name__, "returned",
-          got, "but expected", expected, "for", x)
+    def check_format_1(self, x):
+        for base, mapper in (8, oct), (10, repr), (16, hex):
+            got = mapper(x)
+            expected = self.slow_format(x, base)
+            msg = Frm("%s returned %r but expected %r for %r",
+                mapper.__name__, got, expected, x)
+            self.assertEqual(got, expected, msg)
+            self.assertEqual(long(got, 0), x, Frm('long("%s", 0) != %r', got, x))
+        # str() has to be checked a little differently since there's no
+        # trailing "L"
+        got = str(x)
+        expected = self.slow_format(x, 10)[:-1]
+        msg = Frm("%s returned %r but expected %r for %r",
+            mapper.__name__, got, expected, x)
+        self.assertEqual(got, expected, msg)
 
-def test_format(maxdigits=MAXDIGITS):
-    if verbose:
-        print "long str/hex/oct/atol"
-    for x in special:
-        test_format_1(x)
-    for i in range(10):
-        for lenx in range(1, maxdigits+1):
-            x = getran(lenx)
-            test_format_1(x)
+    def test_format(self):
+        for x in special:
+            self.check_format_1(x)
+        for i in xrange(10):
+            for lenx in xrange(1, MAXDIGITS+1):
+                x = self.getran(lenx)
+                self.check_format_1(x)
 
-# ----------------------------------------------------------------- misc
+    def test_misc(self):
+        import sys
 
-def test_misc(maxdigits=MAXDIGITS):
-    if verbose:
-        print "long miscellaneous operations"
-    import sys
+        # check the extremes in int<->long conversion
+        hugepos = sys.maxint
+        hugeneg = -hugepos - 1
+        hugepos_aslong = long(hugepos)
+        hugeneg_aslong = long(hugeneg)
+        self.assertEqual(hugepos, hugepos_aslong, "long(sys.maxint) != sys.maxint")
+        self.assertEqual(hugeneg, hugeneg_aslong,
+            "long(-sys.maxint-1) != -sys.maxint-1")
 
-    # check the extremes in int<->long conversion
-    hugepos = sys.maxint
-    hugeneg = -hugepos - 1
-    hugepos_aslong = long(hugepos)
-    hugeneg_aslong = long(hugeneg)
-    check(hugepos == hugepos_aslong, "long(sys.maxint) != sys.maxint")
-    check(hugeneg == hugeneg_aslong,
-        "long(-sys.maxint-1) != -sys.maxint-1")
+        # long -> int should not fail for hugepos_aslong or hugeneg_aslong
+        try:
+            self.assertEqual(int(hugepos_aslong), hugepos,
+                  "converting sys.maxint to long and back to int fails")
+        except OverflowError:
+            self.fail("int(long(sys.maxint)) overflowed!")
+        try:
+            self.assertEqual(int(hugeneg_aslong), hugeneg,
+                  "converting -sys.maxint-1 to long and back to int fails")
+        except OverflowError:
+            self.fail("int(long(-sys.maxint-1)) overflowed!")
 
-    # long -> int should not fail for hugepos_aslong or hugeneg_aslong
-    try:
-        check(int(hugepos_aslong) == hugepos,
-              "converting sys.maxint to long and back to int fails")
-    except OverflowError:
-        raise TestFailed, "int(long(sys.maxint)) overflowed!"
-    try:
-        check(int(hugeneg_aslong) == hugeneg,
-              "converting -sys.maxint-1 to long and back to int fails")
-    except OverflowError:
-        raise TestFailed, "int(long(-sys.maxint-1)) overflowed!"
+        # but long -> int should overflow for hugepos+1 and hugeneg-1
+        x = hugepos_aslong + 1
+        try:
+            y = int(x)
+        except OverflowError:
+            self.fail("int(long(sys.maxint) + 1) mustn't overflow")
+        self.assert_(isinstance(y, long),
+            "int(long(sys.maxint) + 1) should have returned long")
 
-    # but long -> int should overflow for hugepos+1 and hugeneg-1
-    x = hugepos_aslong + 1
-    try:
-        y = int(x)
-    except OverflowError:
-        raise TestFailed, "int(long(sys.maxint) + 1) mustn't overflow"
-    if not isinstance(y, long):
-        raise TestFailed("int(long(sys.maxint) + 1) should have returned long")
+        x = hugeneg_aslong - 1
+        try:
+            y = int(x)
+        except OverflowError:
+            self.fail("int(long(-sys.maxint-1) - 1) mustn't overflow")
+        self.assert_(isinstance(y, long),
+               "int(long(-sys.maxint-1) - 1) should have returned long")
 
-    x = hugeneg_aslong - 1
-    try:
+        class long2(long):
+            pass
+        x = long2(1L<<100)
         y = int(x)
-    except OverflowError:
-        raise TestFailed, "int(long(-sys.maxint-1) - 1) mustn't overflow"
-    if not isinstance(y, long):
-        raise TestFailed("int(long(-sys.maxint-1) - 1) should have returned long")
+        self.assert_(type(y) is long,
+            "overflowing int conversion must return long not long subtype")
 
-    class long2(long):
-        pass
-    x = long2(1L<<100)
-    y = int(x)
-    if type(y) is not long:
-        raise TestFailed("overflowing int conversion must return long not long subtype")
 # ----------------------------------- tests of auto int->long conversion
 
-def test_auto_overflow():
-    import math, sys
-
-    if verbose:
-        print "auto-convert int->long on overflow"
+    def test_auto_overflow(self):
+        import math, sys
 
-    special = [0, 1, 2, 3, sys.maxint-1, sys.maxint, sys.maxint+1]
-    sqrt = int(math.sqrt(sys.maxint))
-    special.extend([sqrt-1, sqrt, sqrt+1])
-    special.extend([-i for i in special])
+        special = [0, 1, 2, 3, sys.maxint-1, sys.maxint, sys.maxint+1]
+        sqrt = int(math.sqrt(sys.maxint))
+        special.extend([sqrt-1, sqrt, sqrt+1])
+        special.extend([-i for i in special])
 
-    def checkit(*args):
-        # Heavy use of nested scopes here!
-        verify(got == expected, "for %r expected %r got %r" %
-                                (args, expected, got))
+        def checkit(*args):
+            # Heavy use of nested scopes here!
+            self.assertEqual(got, expected,
+                Frm("for %r expected %r got %r", args, expected, got))
 
-    for x in special:
-        longx = long(x)
+        for x in special:
+            longx = long(x)
 
-        expected = -longx
-        got = -x
-        checkit('-', x)
+            expected = -longx
+            got = -x
+            checkit('-', x)
 
-        for y in special:
-            longy = long(y)
+            for y in special:
+                longy = long(y)
 
-            expected = longx + longy
-            got = x + y
-            checkit(x, '+', y)
+                expected = longx + longy
+                got = x + y
+                checkit(x, '+', y)
 
-            expected = longx - longy
-            got = x - y
-            checkit(x, '-', y)
+                expected = longx - longy
+                got = x - y
+                checkit(x, '-', y)
 
-            expected = longx * longy
-            got = x * y
-            checkit(x, '*', y)
+                expected = longx * longy
+                got = x * y
+                checkit(x, '*', y)
 
-            if y:
-                expected = longx / longy
-                got = x / y
-                checkit(x, '/', y)
+                if y:
+                    expected = longx / longy
+                    got = x / y
+                    checkit(x, '/', y)
 
-                expected = longx // longy
-                got = x // y
-                checkit(x, '//', y)
+                    expected = longx // longy
+                    got = x // y
+                    checkit(x, '//', y)
 
-                expected = divmod(longx, longy)
-                got = divmod(longx, longy)
-                checkit(x, 'divmod', y)
+                    expected = divmod(longx, longy)
+                    got = divmod(longx, longy)
+                    checkit(x, 'divmod', y)
 
-            if abs(y) < 5 and not (x == 0 and y < 0):
-                expected = longx ** longy
-                got = x ** y
-                checkit(x, '**', y)
+                if abs(y) < 5 and not (x == 0 and y < 0):
+                    expected = longx ** longy
+                    got = x ** y
+                    checkit(x, '**', y)
 
-                for z in special:
-                    if z != 0 :
-                        if y >= 0:
-                            expected = pow(longx, longy, long(z))
-                            got = pow(x, y, z)
-                            checkit('pow', x, y, '%', z)
-                        else:
-                            try:
-                                pow(longx, longy, long(z))
-                            except TypeError:
-                                pass
+                    for z in special:
+                        if z != 0 :
+                            if y >= 0:
+                                expected = pow(longx, longy, long(z))
+                                got = pow(x, y, z)
+                                checkit('pow', x, y, '%', z)
                             else:
-                                raise TestFailed("pow%r should have raised "
-                                "TypeError" % ((longx, longy, long(z)),))
-
-# ---------------------------------------- tests of long->float overflow
-
-def test_float_overflow():
-    import math
-
-    if verbose:
-        print "long->float overflow"
-
-    for x in -2.0, -1.0, 0.0, 1.0, 2.0:
-        verify(float(long(x)) == x)
-
-    shuge = '12345' * 120
-    huge = 1L << 30000
-    mhuge = -huge
-    namespace = {'huge': huge, 'mhuge': mhuge, 'shuge': shuge, 'math': math}
-    for test in ["float(huge)", "float(mhuge)",
-                 "complex(huge)", "complex(mhuge)",
-                 "complex(huge, 1)", "complex(mhuge, 1)",
-                 "complex(1, huge)", "complex(1, mhuge)",
-                 "1. + huge", "huge + 1.", "1. + mhuge", "mhuge + 1.",
-                 "1. - huge", "huge - 1.", "1. - mhuge", "mhuge - 1.",
-                 "1. * huge", "huge * 1.", "1. * mhuge", "mhuge * 1.",
-                 "1. // huge", "huge // 1.", "1. // mhuge", "mhuge // 1.",
-                 "1. / huge", "huge / 1.", "1. / mhuge", "mhuge / 1.",
-                 "1. ** huge", "huge ** 1.", "1. ** mhuge", "mhuge ** 1.",
-                 "math.sin(huge)", "math.sin(mhuge)",
-                 "math.sqrt(huge)", "math.sqrt(mhuge)", # should do better
-                 "math.floor(huge)", "math.floor(mhuge)"]:
-
-        try:
-            eval(test, namespace)
-        except OverflowError:
-            pass
-        else:
-            raise TestFailed("expected OverflowError from %s" % test)
-
-        # XXX Perhaps float(shuge) can raise OverflowError on some box?
-        # The comparison should not.
-        if float(shuge) == int(shuge):
-            raise TestFailed("float(shuge) should not equal int(shuge)")
-
-# ---------------------------------------------- test huge log and log10
+                                self.assertRaises(TypeError, pow,longx, longy, long(z))
 
-def test_logs():
-    import math
+    def test_float_overflow(self):
+        import math
 
-    if verbose:
-        print "log and log10"
+        for x in -2.0, -1.0, 0.0, 1.0, 2.0:
+            self.assertEqual(float(long(x)), x)
 
-    LOG10E = math.log10(math.e)
+        shuge = '12345' * 120
+        huge = 1L << 30000
+        mhuge = -huge
+        namespace = {'huge': huge, 'mhuge': mhuge, 'shuge': shuge, 'math': math}
+        for test in ["float(huge)", "float(mhuge)",
+                     "complex(huge)", "complex(mhuge)",
+                     "complex(huge, 1)", "complex(mhuge, 1)",
+                     "complex(1, huge)", "complex(1, mhuge)",
+                     "1. + huge", "huge + 1.", "1. + mhuge", "mhuge + 1.",
+                     "1. - huge", "huge - 1.", "1. - mhuge", "mhuge - 1.",
+                     "1. * huge", "huge * 1.", "1. * mhuge", "mhuge * 1.",
+                     "1. // huge", "huge // 1.", "1. // mhuge", "mhuge // 1.",
+                     "1. / huge", "huge / 1.", "1. / mhuge", "mhuge / 1.",
+                     "1. ** huge", "huge ** 1.", "1. ** mhuge", "mhuge ** 1.",
+                     "math.sin(huge)", "math.sin(mhuge)",
+                     "math.sqrt(huge)", "math.sqrt(mhuge)", # should do better
+                     "math.floor(huge)", "math.floor(mhuge)"]:
 
-    for exp in range(10) + [100, 1000, 10000]:
-        value = 10 ** exp
-        log10 = math.log10(value)
-        verify(fcmp(log10, exp) == 0)
+            self.assertRaises(OverflowError, eval, test, namespace)
 
-        # log10(value) == exp, so log(value) == log10(value)/log10(e) ==
-        # exp/LOG10E
-        expected = exp / LOG10E
-        log = math.log(value)
-        verify(fcmp(log, expected) == 0)
+            # XXX Perhaps float(shuge) can raise OverflowError on some box?
+            # The comparison should not.
+            self.assertNotEqual(float(shuge), int(shuge),
+                "float(shuge) should not equal int(shuge)")
 
-    for bad in -(1L << 10000), -2L, 0L:
-        try:
-            math.log(bad)
-            raise TestFailed("expected ValueError from log(<= 0)")
-        except ValueError:
-            pass
+    def test_logs(self):
+        import math
 
-        try:
-            math.log10(bad)
-            raise TestFailed("expected ValueError from log10(<= 0)")
-        except ValueError:
-            pass
+        LOG10E = math.log10(math.e)
 
-# ----------------------------------------------- test mixed comparisons
+        for exp in range(10) + [100, 1000, 10000]:
+            value = 10 ** exp
+            log10 = math.log10(value)
+            self.assertAlmostEqual(log10, exp)
 
-def test_mixed_compares():
-    import math
-    import sys
+            # log10(value) == exp, so log(value) == log10(value)/log10(e) ==
+            # exp/LOG10E
+            expected = exp / LOG10E
+            log = math.log(value)
+            self.assertAlmostEqual(log, expected)
 
-    if verbose:
-        print "mixed comparisons"
+        for bad in -(1L << 10000), -2L, 0L:
+            self.assertRaises(ValueError, math.log, bad)
+            self.assertRaises(ValueError, math.log10, bad)
 
-    # We're mostly concerned with that mixing floats and longs does the
-    # right stuff, even when longs are too large to fit in a float.
-    # The safest way to check the results is to use an entirely different
-    # method, which we do here via a skeletal rational class (which
-    # represents all Python ints, longs and floats exactly).
-    class Rat:
-        def __init__(self, value):
-            if isinstance(value, (int, long)):
-                self.n = value
-                self.d = 1
+    def test_mixed_compares(self):
+        eq = self.assertEqual
+        import math
+        import sys
 
-            elif isinstance(value, float):
-                # Convert to exact rational equivalent.
-                f, e = math.frexp(abs(value))
-                assert f == 0 or 0.5 <= f < 1.0
-                # |value| = f * 2**e exactly
+        # We're mostly concerned with that mixing floats and longs does the
+        # right stuff, even when longs are too large to fit in a float.
+        # The safest way to check the results is to use an entirely different
+        # method, which we do here via a skeletal rational class (which
+        # represents all Python ints, longs and floats exactly).
+        class Rat:
+            def __init__(self, value):
+                if isinstance(value, (int, long)):
+                    self.n = value
+                    self.d = 1
+                elif isinstance(value, float):
+                    # Convert to exact rational equivalent.
+                    f, e = math.frexp(abs(value))
+                    assert f == 0 or 0.5 <= f < 1.0
+                    # |value| = f * 2**e exactly
 
-                # Suck up CHUNK bits at a time; 28 is enough so that we suck
-                # up all bits in 2 iterations for all known binary double-
-                # precision formats, and small enough to fit in an int.
-                CHUNK = 28
-                top = 0
-                # invariant: |value| = (top + f) * 2**e exactly
-                while f:
-                    f = math.ldexp(f, CHUNK)
-                    digit = int(f)
-                    assert digit >> CHUNK == 0
-                    top = (top << CHUNK) | digit
-                    f -= digit
-                    assert 0.0 <= f < 1.0
-                    e -= CHUNK
+                    # Suck up CHUNK bits at a time; 28 is enough so that we suck
+                    # up all bits in 2 iterations for all known binary double-
+                    # precision formats, and small enough to fit in an int.
+                    CHUNK = 28
+                    top = 0
+                    # invariant: |value| = (top + f) * 2**e exactly
+                    while f:
+                        f = math.ldexp(f, CHUNK)
+                        digit = int(f)
+                        assert digit >> CHUNK == 0
+                        top = (top << CHUNK) | digit
+                        f -= digit
+                        assert 0.0 <= f < 1.0
+                        e -= CHUNK
 
-                # Now |value| = top * 2**e exactly.
-                if e >= 0:
-                    n = top << e
-                    d = 1
+                    # Now |value| = top * 2**e exactly.
+                    if e >= 0:
+                        n = top << e
+                        d = 1
+                    else:
+                        n = top
+                        d = 1 << -e
+                    if value < 0:
+                        n = -n
+                    self.n = n
+                    self.d = d
+                    assert float(n) / float(d) == value
                 else:
-                    n = top
-                    d = 1 << -e
-                if value < 0:
-                    n = -n
-                self.n = n
-                self.d = d
-                assert float(n) / float(d) == value
-
-            else:
-                raise TypeError("can't deal with %r" % val)
+                    raise TypeError("can't deal with %r" % val)
 
-        def __cmp__(self, other):
-            if not isinstance(other, Rat):
-                other = Rat(other)
-            return cmp(self.n * other.d, self.d * other.n)
+            def __cmp__(self, other):
+                if not isinstance(other, Rat):
+                    other = Rat(other)
+                return cmp(self.n * other.d, self.d * other.n)
 
-    cases = [0, 0.001, 0.99, 1.0, 1.5, 1e20, 1e200]
-    # 2**48 is an important boundary in the internals.  2**53 is an
-    # important boundary for IEEE double precision.
-    for t in 2.0**48, 2.0**50, 2.0**53:
-        cases.extend([t - 1.0, t - 0.3, t, t + 0.3, t + 1.0,
-                      long(t-1), long(t), long(t+1)])
-    cases.extend([0, 1, 2, sys.maxint, float(sys.maxint)])
-    # 1L<<20000 should exceed all double formats.  long(1e200) is to
-    # check that we get equality with 1e200 above.
-    t = long(1e200)
-    cases.extend([0L, 1L, 2L, 1L << 20000, t-1, t, t+1])
-    cases.extend([-x for x in cases])
-    for x in cases:
-        Rx = Rat(x)
-        for y in cases:
-            Ry = Rat(y)
-            Rcmp = cmp(Rx, Ry)
-            xycmp = cmp(x, y)
-            if Rcmp != xycmp:
-                raise TestFailed('%r %r %d %d' % (x, y, Rcmp, xycmp))
-            if (x == y) != (Rcmp == 0):
-                raise TestFailed('%r == %r %d' % (x, y, Rcmp))
-            if (x != y) != (Rcmp != 0):
-                raise TestFailed('%r != %r %d' % (x, y, Rcmp))
-            if (x < y) != (Rcmp < 0):
-                raise TestFailed('%r < %r %d' % (x, y, Rcmp))
-            if (x <= y) != (Rcmp <= 0):
-                raise TestFailed('%r <= %r %d' % (x, y, Rcmp))
-            if (x > y) != (Rcmp > 0):
-                raise TestFailed('%r > %r %d' % (x, y, Rcmp))
-            if (x >= y) != (Rcmp >= 0):
-                raise TestFailed('%r >= %r %d' % (x, y, Rcmp))
+        cases = [0, 0.001, 0.99, 1.0, 1.5, 1e20, 1e200]
+        # 2**48 is an important boundary in the internals.  2**53 is an
+        # important boundary for IEEE double precision.
+        for t in 2.0**48, 2.0**50, 2.0**53:
+            cases.extend([t - 1.0, t - 0.3, t, t + 0.3, t + 1.0,
+                          long(t-1), long(t), long(t+1)])
+        cases.extend([0, 1, 2, sys.maxint, float(sys.maxint)])
+        # 1L<<20000 should exceed all double formats.  long(1e200) is to
+        # check that we get equality with 1e200 above.
+        t = long(1e200)
+        cases.extend([0L, 1L, 2L, 1L << 20000, t-1, t, t+1])
+        cases.extend([-x for x in cases])
+        for x in cases:
+            Rx = Rat(x)
+            for y in cases:
+                Ry = Rat(y)
+                Rcmp = cmp(Rx, Ry)
+                xycmp = cmp(x, y)
+                eq(Rcmp, xycmp, Frm("%r %r %d %d", x, y, Rcmp, xycmp))
+                eq(x == y, Rcmp == 0, Frm("%r == %r %d", x, y, Rcmp))
+                eq(x != y, Rcmp != 0, Frm("%r != %r %d", x, y, Rcmp))
+                eq(x < y, Rcmp < 0, Frm("%r < %r %d", x, y, Rcmp))
+                eq(x <= y, Rcmp <= 0, Frm("%r <= %r %d", x, y, Rcmp))
+                eq(x > y, Rcmp > 0, Frm("%r > %r %d", x, y, Rcmp))
+                eq(x >= y, Rcmp >= 0, Frm("%r >= %r %d", x, y, Rcmp))
 
-# ---------------------------------------------------------------- do it
+def test_main():
+    test_support.run_unittest(LongTest)
 
-test_division()
-test_karatsuba()
-test_bitop_identities()
-test_format()
-test_misc()
-test_auto_overflow()
-test_float_overflow()
-test_logs()
-test_mixed_compares()
+if __name__ == "__main__":
+    test_main()

Index: test_macfs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_macfs.py,v
retrieving revision 1.7.4.1
retrieving revision 1.7.4.2
diff -u -d -r1.7.4.1 -r1.7.4.2
--- test_macfs.py	28 Apr 2003 17:28:36 -0000	1.7.4.1
+++ test_macfs.py	16 Oct 2005 05:24:01 -0000	1.7.4.2
@@ -48,9 +48,9 @@
         import time
         fss = macfs.FSSpec(test_support.TESTFN)
         now = int(time.time())
-        fss.SetDates(now, now-1, now-2)
+        fss.SetDates(now, now+1, now+2)
         dates = fss.GetDates()
-        self.assertEqual(dates, (now, now-1, now-2))
+        self.assertEqual(dates, (now, now+1, now+2))
 
     def test_ctor_type(self):
         fss = macfs.FSSpec(test_support.TESTFN)

Index: test_marshal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_marshal.py,v
retrieving revision 1.1.16.2
retrieving revision 1.1.16.3
diff -u -d -r1.1.16.2 -r1.1.16.3
--- test_marshal.py	7 Jan 2005 06:59:09 -0000	1.1.16.2
+++ test_marshal.py	16 Oct 2005 05:24:01 -0000	1.1.16.3
@@ -73,7 +73,11 @@
             n /= 123.4567
 
         f = 0.0
-        s = marshal.dumps(f)
+        s = marshal.dumps(f, 2)
+        got = marshal.loads(s)
+        self.assertEqual(f, got)
+        # and with version <= 1 (floats marshalled differently then)
+        s = marshal.dumps(f, 1)
         got = marshal.loads(s)
         self.assertEqual(f, got)
 
@@ -81,12 +85,22 @@
         while n < small:
             for expected in (-n, n):
                 f = float(expected)
+
                 s = marshal.dumps(f)
                 got = marshal.loads(s)
                 self.assertEqual(f, got)
+
+                s = marshal.dumps(f, 1)
+                got = marshal.loads(s)
+                self.assertEqual(f, got)
+
                 marshal.dump(f, file(test_support.TESTFN, "wb"))
                 got = marshal.load(file(test_support.TESTFN, "rb"))
                 self.assertEqual(f, got)
+
+                marshal.dump(f, file(test_support.TESTFN, "wb"), 1)
+                got = marshal.load(file(test_support.TESTFN, "rb"))
+                self.assertEqual(f, got)
             n *= 123.4567
         os.unlink(test_support.TESTFN)
 
@@ -97,7 +111,7 @@
             self.assertEqual(s, new)
             self.assertEqual(type(s), type(new))
             marshal.dump(s, file(test_support.TESTFN, "wb"))
-            marshal.load(file(test_support.TESTFN, "rb"))
+            new = marshal.load(file(test_support.TESTFN, "rb"))
             self.assertEqual(s, new)
             self.assertEqual(type(s), type(new))
         os.unlink(test_support.TESTFN)
@@ -108,7 +122,7 @@
             self.assertEqual(s, new)
             self.assertEqual(type(s), type(new))
             marshal.dump(s, file(test_support.TESTFN, "wb"))
-            marshal.load(file(test_support.TESTFN, "rb"))
+            new = marshal.load(file(test_support.TESTFN, "rb"))
             self.assertEqual(s, new)
             self.assertEqual(type(s), type(new))
         os.unlink(test_support.TESTFN)
@@ -119,7 +133,7 @@
             new = marshal.loads(marshal.dumps(b))
             self.assertEqual(s, new)
             marshal.dump(b, file(test_support.TESTFN, "wb"))
-            marshal.load(file(test_support.TESTFN, "rb"))
+            new = marshal.load(file(test_support.TESTFN, "rb"))
             self.assertEqual(s, new)
         os.unlink(test_support.TESTFN)
 
@@ -148,7 +162,7 @@
         new = marshal.loads(marshal.dumps(self.d))
         self.assertEqual(self.d, new)
         marshal.dump(self.d, file(test_support.TESTFN, "wb"))
-        marshal.load(file(test_support.TESTFN, "rb"))
+        new = marshal.load(file(test_support.TESTFN, "rb"))
         self.assertEqual(self.d, new)
         os.unlink(test_support.TESTFN)
 
@@ -157,7 +171,7 @@
         new = marshal.loads(marshal.dumps(lst))
         self.assertEqual(lst, new)
         marshal.dump(lst, file(test_support.TESTFN, "wb"))
-        marshal.load(file(test_support.TESTFN, "rb"))
+        new = marshal.load(file(test_support.TESTFN, "rb"))
         self.assertEqual(lst, new)
         os.unlink(test_support.TESTFN)
 
@@ -166,10 +180,22 @@
         new = marshal.loads(marshal.dumps(t))
         self.assertEqual(t, new)
         marshal.dump(t, file(test_support.TESTFN, "wb"))
-        marshal.load(file(test_support.TESTFN, "rb"))
+        new = marshal.load(file(test_support.TESTFN, "rb"))
         self.assertEqual(t, new)
         os.unlink(test_support.TESTFN)
 
+    def test_sets(self):
+        for constructor in (set, frozenset):
+            t = constructor(self.d.keys())
+            new = marshal.loads(marshal.dumps(t))
+            self.assertEqual(t, new)
+            self.assert_(isinstance(new, constructor))
+            self.assertNotEqual(id(t), id(new))
+            marshal.dump(t, file(test_support.TESTFN, "wb"))
+            new = marshal.load(file(test_support.TESTFN, "rb"))
+            self.assertEqual(t, new)
+            os.unlink(test_support.TESTFN)
+
 class BugsTestCase(unittest.TestCase):
     def test_bug_5888452(self):
         # Simple-minded check for SF 588452: Debug build crashes
@@ -185,6 +211,15 @@
         self.assertEquals(marshal.loads(marshal.dumps(5, 0)), 5)
         self.assertEquals(marshal.loads(marshal.dumps(5, 1)), 5)
 
+    def test_fuzz(self):
+        # simple test that it's at least not *totally* trivial to
+        # crash from bad marshal data
+        for c in [chr(i) for i in range(256)]:
+            try:
+                marshal.loads(c)
+            except Exception:
+                pass
+
 def test_main():
     test_support.run_unittest(IntTestCase,
                               FloatTestCase,

Index: test_minidom.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v
retrieving revision 1.32.2.2
retrieving revision 1.32.2.3
diff -u -d -r1.32.2.2 -r1.32.2.3
--- test_minidom.py	7 Jan 2005 06:59:10 -0000	1.32.2.2
+++ test_minidom.py	16 Oct 2005 05:24:01 -0000	1.32.2.3
@@ -413,12 +413,19 @@
 def testTextNodeRepr(): pass
 
 def testWriteXML():
-    str = '<?xml version="1.0" ?>\n<a b="c"/>'
+    str = '<?xml version="1.0" ?><a b="c"/>'
     dom = parseString(str)
     domstr = dom.toxml()
     dom.unlink()
     confirm(str == domstr)
 
+def testAltNewline():
+    str = '<?xml version="1.0" ?>\n<a b="c"/>\n'
+    dom = parseString(str)
+    domstr = dom.toprettyxml(newl="\r\n")
+    dom.unlink()
+    confirm(domstr == str.replace("\n", "\r\n"))
+
 def testProcessingInstruction():
     dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
     pi = dom.documentElement.firstChild
@@ -878,10 +885,19 @@
 
 def testEncodings():
     doc = parseString('<foo>&#x20ac;</foo>')
-    confirm(doc.toxml() == u'<?xml version="1.0" ?>\n<foo>\u20ac</foo>'
-            and doc.toxml('utf-8') == '<?xml version="1.0" encoding="utf-8"?>\n<foo>\xe2\x82\xac</foo>'
-            and doc.toxml('iso-8859-15') == '<?xml version="1.0" encoding="iso-8859-15"?>\n<foo>\xa4</foo>',
+    confirm(doc.toxml() == u'<?xml version="1.0" ?><foo>\u20ac</foo>'
+            and doc.toxml('utf-8') == '<?xml version="1.0" encoding="utf-8"?><foo>\xe2\x82\xac</foo>'
+            and doc.toxml('iso-8859-15') == '<?xml version="1.0" encoding="iso-8859-15"?><foo>\xa4</foo>',
             "testEncodings - encoding EURO SIGN")
+
+    # Verify that character decoding errors throw exceptions instead of crashing
+    try:
+        doc = parseString('<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
+    except UnicodeDecodeError:
+        pass
+    else:
+        print 'parsing with bad encoding should raise a UnicodeDecodeError'
+
     doc.unlink()
 
 class UserDataHandler:
@@ -1199,7 +1215,7 @@
             and not a1.isId
             and a2.isId
             and not a3.isId)
-    # renaming an attribute should not affect it's ID-ness:
+    # renaming an attribute should not affect its ID-ness:
     doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
     confirm(e.isSameNode(doc.getElementById("w"))
             and a2.isId)
@@ -1235,7 +1251,7 @@
     confirm(a2.isId)
     confirm(not a3.isId)
     confirm(doc.getElementById("v") is None)
-    # renaming an attribute should not affect it's ID-ness:
+    # renaming an attribute should not affect its ID-ness:
     doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
     confirm(e.isSameNode(doc.getElementById("w"))
             and a2.isId)
@@ -1271,7 +1287,7 @@
     confirm(a2.isId)
     confirm(not a3.isId)
     confirm(doc.getElementById("v") is None)
-    # renaming an attribute should not affect it's ID-ness:
+    # renaming an attribute should not affect its ID-ness:
     doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
     confirm(e.isSameNode(doc.getElementById("w"))
             and a2.isId)

Index: test_mmap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v
retrieving revision 1.22.2.1
retrieving revision 1.22.2.2
diff -u -d -r1.22.2.1 -r1.22.2.2
--- test_mmap.py	28 Apr 2003 17:28:32 -0000	1.22.2.1
+++ test_mmap.py	16 Oct 2005 05:24:01 -0000	1.22.2.2
@@ -120,6 +120,14 @@
             else:
                 verify(0, 'Could seek beyond the new size')
 
+            # Check that the underlying file is truncated too
+            # (bug #728515)
+            f = open(TESTFN)
+            f.seek(0, 2)
+            verify(f.tell() == 512, 'Underlying file not truncated')
+            f.close()
+            verify(m.size() == 512, 'New size not reflected in file')
+
         m.close()
 
     finally:
@@ -311,6 +319,42 @@
     finally:
         os.unlink(TESTFN)
 
+    # test mapping of entire file by passing 0 for map length
+    if hasattr(os, "stat"):
+        print "  Ensuring that passing 0 as map length sets map size to current file size."
+        f = open(TESTFN, "w+")
+
+        try:
+            f.write(2**16 * 'm') # Arbitrary character
+            f.close()
+
+            f = open(TESTFN, "rb+")
+            mf = mmap.mmap(f.fileno(), 0)
+            verify(len(mf) == 2**16, "Map size should equal file size.")
+            vereq(mf.read(2**16), 2**16 * "m")
+            mf.close()
+            f.close()
+
+        finally:
+            os.unlink(TESTFN)
+
+    # test mapping of entire file by passing 0 for map length
+    if hasattr(os, "stat"):
+        print "  Ensuring that passing 0 as map length sets map size to current file size."
+        f = open(TESTFN, "w+")
+        try:
+            f.write(2**16 * 'm') # Arbitrary character
+            f.close()
+
+            f = open(TESTFN, "rb+")
+            mf = mmap.mmap(f.fileno(), 0)
+            verify(len(mf) == 2**16, "Map size should equal file size.")
+            vereq(mf.read(2**16), 2**16 * "m")
+            mf.close()
+            f.close()
+
+        finally:
+            os.unlink(TESTFN)
 
     print ' Test passed'
 

Index: test_mutants.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mutants.py,v
retrieving revision 1.6.22.1
retrieving revision 1.6.22.2
diff -u -d -r1.6.22.1 -r1.6.22.2
--- test_mutants.py	28 Apr 2003 17:28:31 -0000	1.6.22.1
+++ test_mutants.py	16 Oct 2005 05:24:01 -0000	1.6.22.2
@@ -69,14 +69,12 @@
 
     elif keys:
         # Delete a key at random.
+        mutate = 0   # disable mutation until key deleted
         i = random.randrange(len(keys))
         key = keys[i]
         del target[key]
-        # CAUTION:  don't use keys.remove(key) here.  Or do <wink>.  The
-        # point is that .remove() would trigger more comparisons, and so
-        # also more calls to this routine.  We're mutating often enough
-        # without that.
         del keys[i]
+        mutate = 1
 
 # A horrid class that triggers random mutations of dict1 and dict2 when
 # instances are compared.

Index: test_new.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v
retrieving revision 1.14.8.2
retrieving revision 1.14.8.3
diff -u -d -r1.14.8.2 -r1.14.8.3
--- test_new.py	7 Jan 2005 06:59:10 -0000	1.14.8.2
+++ test_new.py	16 Oct 2005 05:24:01 -0000	1.14.8.3
@@ -47,6 +47,16 @@
 verify(c.get_yolks() == 1 and c.get_more_yolks() == 4,
        'Broken call of hand-crafted instance method')
 
+im = new.instancemethod(break_yolks, c)
+im()
+verify(c.get_yolks() == -1)
+try:
+    new.instancemethod(break_yolks, None)
+except TypeError:
+    pass
+else:
+    raise TestFailed, "dangerous instance method creation allowed"
+
 # It's unclear what the semantics should be for a code object compiled at
 # module scope, but bound and run in a function.  In CPython, `c' is global
 # (by accident?) while in Jython, `c' is local.  The intent of the test

Index: test_operator.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_operator.py,v
retrieving revision 1.8.14.2
retrieving revision 1.8.14.3
diff -u -d -r1.8.14.2 -r1.8.14.3
--- test_operator.py	7 Jan 2005 06:59:10 -0000	1.8.14.2
+++ test_operator.py	16 Oct 2005 05:24:01 -0000	1.8.14.3
@@ -324,7 +324,14 @@
         f = operator.attrgetter(2)
         self.assertRaises(TypeError, f, a)
         self.assertRaises(TypeError, operator.attrgetter)
-        self.assertRaises(TypeError, operator.attrgetter, 1, 2)
+
+        # multiple gets
+        record = A()
+        record.x = 'X'
+        record.y = 'Y'
+        record.z = 'Z'
+        self.assertEqual(operator.attrgetter('x','z','y')(record), ('X', 'Z', 'Y'))
+        self.assertRaises(TypeError, operator.attrgetter('x', (), 'y'), record)
 
         class C(object):
             def __getattr(self, name):
@@ -346,7 +353,6 @@
         f = operator.itemgetter('name')
         self.assertRaises(TypeError, f, a)
         self.assertRaises(TypeError, operator.itemgetter)
-        self.assertRaises(TypeError, operator.itemgetter, 1, 2)
 
         d = dict(key='val')
         f = operator.itemgetter('key')
@@ -361,9 +367,29 @@
         self.assertEqual(sorted(inventory, key=getcount),
             [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)])
 
-def test_main():
-    test_support.run_unittest(OperatorTestCase)
+        # multiple gets
+        data = map(str, range(20))
+        self.assertEqual(operator.itemgetter(2,10,5)(data), ('2', '10', '5'))
+        self.assertRaises(TypeError, operator.itemgetter(2, 'x', 5), data)
+
+
+def test_main(verbose=None):
+    import sys
+    test_classes = (
+        OperatorTestCase,
+    )
 
+    test_support.run_unittest(*test_classes)
+
+    # verify reference counting
+    if verbose and hasattr(sys, "gettotalrefcount"):
+        import gc
+        counts = [None] * 5
+        for i in xrange(len(counts)):
+            test_support.run_unittest(*test_classes)
+            gc.collect()
+            counts[i] = sys.gettotalrefcount()
+        print counts
 
 if __name__ == "__main__":
-    test_main()
+    test_main(verbose=True)

Index: test_os.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v
retrieving revision 1.11.2.2
retrieving revision 1.11.2.3
diff -u -d -r1.11.2.2 -r1.11.2.3
--- test_os.py	7 Jan 2005 06:59:10 -0000	1.11.2.2
+++ test_os.py	16 Oct 2005 05:24:01 -0000	1.11.2.3
@@ -111,7 +111,11 @@
         for name in dir(stat):
             if name[:3] == 'ST_':
                 attr = name.lower()
-                self.assertEquals(getattr(result, attr),
+                if name.endswith("TIME"):
+                    def trunc(x): return int(x)
+                else:
+                    def trunc(x): return x
+                self.assertEquals(trunc(getattr(result, attr)),
                                   result[getattr(stat, name)])
                 self.assert_(attr in members)
 
@@ -222,6 +226,13 @@
         os.environ.clear()
         os.environ.update(self.__save)
 
+    # Bug 1110478
+    def test_update2(self):
+        if os.path.exists("/bin/sh"):
+            os.environ.update(HELLO="World")
+            value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
+            self.assertEquals(value, "World")
+
 class WalkTests(unittest.TestCase):
     """Tests for os.walk()."""
 

Index: test_ossaudiodev.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ossaudiodev.py,v
retrieving revision 1.4.8.2
retrieving revision 1.4.8.3
diff -u -d -r1.4.8.2 -r1.4.8.3
--- test_ossaudiodev.py	7 Jan 2005 06:59:10 -0000	1.4.8.2
+++ test_ossaudiodev.py	16 Oct 2005 05:24:01 -0000	1.4.8.3
@@ -56,6 +56,19 @@
     dsp.getptr()
     dsp.fileno()
 
+    # Make sure the read-only attributes work.
+    assert dsp.closed is False, "dsp.closed is not False"
+    assert dsp.name == "/dev/dsp"
+    assert dsp.mode == 'w', "bad dsp.mode: %r" % dsp.mode
+
+    # And make sure they're really read-only.
+    for attr in ('closed', 'name', 'mode'):
+        try:
+            setattr(dsp, attr, 42)
+            raise RuntimeError("dsp.%s not read-only" % attr)
+        except TypeError:
+            pass
+
     # set parameters based on .au file headers
     dsp.setparameters(AFMT_S16_NE, nchannels, rate)
     t1 = time.time()
@@ -65,9 +78,7 @@
     t2 = time.time()
     print "elapsed time: %.1f sec" % (t2-t1)
 
-def test_setparameters():
-    dsp = ossaudiodev.open("w")
-
+def test_setparameters(dsp):
     # Two configurations for testing:
     #   config1 (8-bit, mono, 8 kHz) should work on even the most
     #      ancient and crufty sound card, but maybe not on special-
@@ -96,11 +107,16 @@
     assert result == (fmt, channels, rate), \
            "setparameters%r: returned %r" % (config + result)
 
+def test_bad_setparameters(dsp):
+
     # Now try some configurations that are presumably bogus: eg. 300
     # channels currently exceeds even Hollywood's ambitions, and
     # negative sampling rate is utter nonsense.  setparameters() should
     # accept these in non-strict mode, returning something other than
     # was requested, but should barf in strict mode.
+    fmt = AFMT_S16_NE
+    rate = 44100
+    channels = 2
     for config in [(fmt, 300, rate),       # ridiculous nchannels
                    (fmt, -5, rate),        # impossible nchannels
                    (fmt, channels, -50),   # impossible rate
@@ -119,6 +135,16 @@
 def test():
     (data, rate, ssize, nchannels) = read_sound_file(findfile('audiotest.au'))
     play_sound_file(data, rate, ssize, nchannels)
-    test_setparameters()
+
+    dsp = ossaudiodev.open("w")
+    try:
+        test_setparameters(dsp)
+
+        # Disabled because it fails under Linux 2.6 with ALSA's OSS
+        # emulation layer.
+        #test_bad_setparameters(dsp)
+    finally:
+        dsp.close()
+        assert dsp.closed is True, "dsp.closed is not True"
 
 test()

Index: test_parser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_parser.py,v
retrieving revision 1.11.2.3
retrieving revision 1.11.2.4
diff -u -d -r1.11.2.3 -r1.11.2.4
--- test_parser.py	11 Oct 2005 21:37:28 -0000	1.11.2.3
+++ test_parser.py	16 Oct 2005 05:24:01 -0000	1.11.2.4
@@ -29,11 +29,22 @@
 
     def test_yield_statement(self):
         self.check_suite("def f(): yield 1")
+        self.check_suite("def f(): yield")
+        self.check_suite("def f(): x += yield")
+        self.check_suite("def f(): x = yield 1")
+        self.check_suite("def f(): x = y = yield 1")
+        self.check_suite("def f(): x = yield")
+        self.check_suite("def f(): x = y = yield")
+        self.check_suite("def f(): 1 + (yield)*2")
+        self.check_suite("def f(): (yield 1)*2")
         self.check_suite("def f(): return; yield 1")
         self.check_suite("def f(): yield 1; return")
         self.check_suite("def f():\n"
                          "    for x in range(30):\n"
                          "        yield x\n")
+        self.check_suite("def f():\n"
+                         "    if (yield):\n"
+                         "        yield x\n")
 
     def test_expressions(self):
         self.check_expr("foo(1)")
@@ -127,6 +138,9 @@
         self.check_suite("@funcattrs()\n"
                          "def f(): pass")
 
+    def test_class_defs(self):
+        self.check_suite("class foo():pass")
+
     def test_import_from_statement(self):
         self.check_suite("from sys.path import *")
         self.check_suite("from sys.path import dirname")

Index: test_popen2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_popen2.py,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -u -d -r1.6.2.2 -r1.6.2.3
--- test_popen2.py	7 Jan 2005 06:59:10 -0000	1.6.2.2
+++ test_popen2.py	16 Oct 2005 05:24:01 -0000	1.6.2.3
@@ -62,7 +62,7 @@
         raise ValueError("wrote %r read %r" % (teststr, got))
     got = e.read()
     if got:
-        raise ValueError("unexected %r on stderr" % (got,))
+        raise ValueError("unexpected %r on stderr" % (got,))
     for inst in popen2._active[:]:
         inst.wait()
     if popen2._active:

Index: test_posix.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_posix.py,v
retrieving revision 1.5.6.2
retrieving revision 1.5.6.3
diff -u -d -r1.5.6.2 -r1.5.6.3
--- test_posix.py	7 Jan 2005 06:59:10 -0000	1.5.6.2
+++ test_posix.py	16 Oct 2005 05:24:01 -0000	1.5.6.3
@@ -94,6 +94,37 @@
             self.fdopen_helper('r')
             self.fdopen_helper('r', 100)
 
+    def test_osexlock(self):
+        if hasattr(posix, "O_EXLOCK"):
+            fd = os.open(test_support.TESTFN,
+                         os.O_WRONLY|os.O_EXLOCK|os.O_CREAT)
+            self.assertRaises(OSError, os.open, test_support.TESTFN,
+                              os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
+            os.close(fd)
+
+            if hasattr(posix, "O_SHLOCK"):
+                fd = os.open(test_support.TESTFN,
+                             os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+                self.assertRaises(OSError, os.open, test_support.TESTFN,
+                                  os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
+                os.close(fd)
+
+    def test_osshlock(self):
+        if hasattr(posix, "O_SHLOCK"):
+            fd1 = os.open(test_support.TESTFN,
+                         os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+            fd2 = os.open(test_support.TESTFN,
+                          os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+            os.close(fd2)
+            os.close(fd1)
+
+            if hasattr(posix, "O_EXLOCK"):
+                fd = os.open(test_support.TESTFN,
+                             os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+                self.assertRaises(OSError, os.open, test_support.TESTFN,
+                                  os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK)
+                os.close(fd)
+
     def test_fstat(self):
         if hasattr(posix, 'fstat'):
             fp = open(test_support.TESTFN)

Index: test_posixpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_posixpath.py,v
retrieving revision 1.4.26.2
retrieving revision 1.4.26.3
diff -u -d -r1.4.26.2 -r1.4.26.3
--- test_posixpath.py	7 Jan 2005 06:59:10 -0000	1.4.26.2
+++ test_posixpath.py	16 Oct 2005 05:24:01 -0000	1.4.26.3
@@ -477,6 +477,26 @@
                 self.safe_rmdir(ABSTFN + "/k")
                 self.safe_rmdir(ABSTFN)
 
+        def test_realpath_resolve_first(self):
+            # Bug #1213894: The first component of the path, if not absolute,
+            # must be resolved too.
+
+            try:
+                old_path = abspath('.')
+                os.mkdir(ABSTFN)
+                os.mkdir(ABSTFN + "/k")
+                os.symlink(ABSTFN, ABSTFN + "link")
+                os.chdir(dirname(ABSTFN))
+
+                base = basename(ABSTFN)
+                self.assertEqual(realpath(base + "link"), ABSTFN)
+                self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
+            finally:
+                os.chdir(old_path)
+                self.safe_remove(ABSTFN + "link")
+                self.safe_rmdir(ABSTFN + "/k")
+                self.safe_rmdir(ABSTFN)
+
         # Convenience functions for removing temporary files.
         def pass_os_error(self, func, filename):
             try: func(filename)

Index: test_profile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_profile.py,v
retrieving revision 1.2.14.1
retrieving revision 1.2.14.2
diff -u -d -r1.2.14.1 -r1.2.14.2
--- test_profile.py	7 Jan 2005 06:59:10 -0000	1.2.14.1
+++ test_profile.py	16 Oct 2005 05:24:01 -0000	1.2.14.2
@@ -10,7 +10,7 @@
 # included in the profile and would appear to consume all the time.)
 ticks = 0
 
-def test_main():
+def test_1():
     global ticks
     ticks = 0
     prof = profile.Profile(timer)
@@ -95,6 +95,25 @@
     vereq (x, 1)
     os.unlink (TESTFN)
 
+def test_3():
+    result = []
+    def testfunc1():
+        try: len(None)
+        except: pass
+        try: len(None)
+        except: pass
+        result.append(True)
+    def testfunc2():
+        testfunc1()
+        testfunc1()
+    profile.runctx("testfunc2()", locals(), locals(), TESTFN)
+    vereq(result, [True, True])
+    os.unlink(TESTFN)
+
+def test_main():
+    test_1()
+    test_2()
+    test_3()
+
 if __name__ == "__main__":
     test_main()
-    test_2()

Index: test_re.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v
retrieving revision 1.31.18.2
retrieving revision 1.31.18.3
diff -u -d -r1.31.18.2 -r1.31.18.3
--- test_re.py	7 Jan 2005 06:59:10 -0000	1.31.18.2
+++ test_re.py	16 Oct 2005 05:24:01 -0000	1.31.18.3
@@ -235,6 +235,16 @@
         self.assertEqual(re.match('^(?:(a)|c)((?(1)|d))$', 'a').groups(),
                          ('a', ''))
 
+        # Tests for bug #1177831: exercise groups other than the first group
+        p = re.compile('(?P<g1>a)(?P<g2>b)?((?(g2)c|d))')
+        self.assertEqual(p.match('abc').groups(),
+                         ('a', 'b', 'c'))
+        self.assertEqual(p.match('ad').groups(),
+                         ('a', None, 'd'))
+        self.assertEqual(p.match('abd'), None)
+        self.assertEqual(p.match('ac'), None)
+
+
     def test_re_groupref(self):
         self.assertEqual(re.match(r'^(\|)?([^()]+)\1$', '|a|').groups(),
                          ('|', 'a'))
@@ -287,6 +297,9 @@
         self.assertNotEqual(re.match("^x{1,4}?$", "xxx"), None)
         self.assertNotEqual(re.match("^x{3,4}?$", "xxx"), None)
 
+        self.assertEqual(re.match("^x{}$", "xxx"), None)
+        self.assertNotEqual(re.match("^x{}$", "x{}"), None)
+
     def test_getattr(self):
         self.assertEqual(re.match("(a)", "a").pos, 0)
         self.assertEqual(re.match("(a)", "a").endpos, 1)

Index: test_richcmp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_richcmp.py,v
retrieving revision 1.6.20.2
retrieving revision 1.6.20.3
diff -u -d -r1.6.20.2 -r1.6.20.3
--- test_richcmp.py	7 Jan 2005 06:59:10 -0000	1.6.20.2
+++ test_richcmp.py	16 Oct 2005 05:24:01 -0000	1.6.20.3
@@ -259,8 +259,8 @@
 
     def test_dicts(self):
         # Verify that __eq__ and __ne__ work for dicts even if the keys and
-        # values don't support anything other than __eq__ and __ne__.  Complex
-        # numbers are a fine example of that.
+        # values don't support anything other than __eq__ and __ne__ (and
+        # __hash__).  Complex numbers are a fine example of that.
         import random
         imag1a = {}
         for i in range(50):

Index: test_set.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v
retrieving revision 1.16.4.1
retrieving revision 1.16.4.2
diff -u -d -r1.16.4.1 -r1.16.4.2
--- test_set.py	7 Jan 2005 06:59:10 -0000	1.16.4.1
+++ test_set.py	16 Oct 2005 05:24:01 -0000	1.16.4.2
@@ -5,6 +5,8 @@
 import copy
 import pickle
 import os
+from random import randrange, shuffle
+import sys
 
 class PassThru(Exception):
     pass
@@ -13,6 +15,12 @@
     raise PassThru
     yield 1
 
+class BadCmp:
+    def __hash__(self):
+        return 1
+    def __cmp__(self, other):
+        raise RuntimeError
+
 class TestJointOps(unittest.TestCase):
     # Tests common to both set and frozenset
 
@@ -202,6 +210,40 @@
         self.assertNotEqual(id(t), id(newt))
         self.assertEqual(t.value + 1, newt.value)
 
+    def test_gc(self):
+        # Create a nest of cycles to exercise overall ref count check
+        class A:
+            pass
+        s = set(A() for i in xrange(1000))
+        for elem in s:
+            elem.cycle = s
+            elem.sub = elem
+            elem.set = set([elem])
+
+    def test_subclass_with_custom_hash(self):
+        # Bug #1257731
+        class H(self.thetype):
+            def __hash__(self):
+                return id(self)
+        s=H()
+        f=set()
+        f.add(s)
+        self.assert_(s in f)
+        f.remove(s)
+        f.add(s)
+        f.discard(s)
+
+    def test_badcmp(self):
+        s = self.thetype([BadCmp()])
+        # Detect comparison errors during insertion and lookup
+        self.assertRaises(RuntimeError, self.thetype, [BadCmp(), BadCmp()])
+        self.assertRaises(RuntimeError, s.__contains__, BadCmp())
+        # Detect errors during mutating operations
+        if hasattr(s, 'add'):
+            self.assertRaises(RuntimeError, s.add, BadCmp())
+            self.assertRaises(RuntimeError, s.discard, BadCmp())
+            self.assertRaises(RuntimeError, s.remove, BadCmp())
+
 class TestSet(TestJointOps):
     thetype = set
 
@@ -359,6 +401,18 @@
             else:
                 self.assert_(c not in self.s)
 
+    def test_inplace_on_self(self):
+        t = self.s.copy()
+        t |= t
+        self.assertEqual(t, self.s)
+        t &= t
+        self.assertEqual(t, self.s)
+        t -= t
+        self.assertEqual(t, self.thetype())
+        t = self.s.copy()
+        t ^= t
+        self.assertEqual(t, self.thetype())
+
     def test_weakref(self):
         s = self.thetype('gallahad')
         p = proxy(s)
@@ -366,6 +420,11 @@
         s = None
         self.assertRaises(ReferenceError, str, p)
 
+    # C API test only available in a debug build
+    if hasattr(sys, "gettotalrefcount"):
+        def test_c_api(self):
+            self.assertEqual(set('abc').test_c_api(), True)
+
 class SetSubclass(set):
     pass
 
@@ -380,6 +439,15 @@
         s.__init__(self.otherword)
         self.assertEqual(s, set(self.word))
 
+    def test_singleton_empty_frozenset(self):
+        f = frozenset()
+        efs = [frozenset(), frozenset([]), frozenset(()), frozenset(''),
+               frozenset(), frozenset([]), frozenset(()), frozenset(''),
+               frozenset(xrange(0)), frozenset(frozenset()),
+               frozenset(f), f]
+        # All of the empty frozensets should have just one id()
+        self.assertEqual(len(set(map(id, efs))), 1)
+
     def test_constructor_identity(self):
         s = self.thetype(range(3))
         t = self.thetype(s)
@@ -389,6 +457,15 @@
         self.assertEqual(hash(self.thetype('abcdeb')),
                          hash(self.thetype('ebecda')))
 
+        # make sure that all permutations give the same hash value
+        n = 100
+        seq = [randrange(n) for i in xrange(n)]
+        results = set()
+        for i in xrange(200):
+            shuffle(seq)
+            results.add(hash(self.thetype(seq)))
+        self.assertEqual(len(results), 1)
+
     def test_copy(self):
         dup = self.s.copy()
         self.assertEqual(id(self.s), id(dup))
@@ -436,6 +513,17 @@
         t = self.thetype(s)
         self.assertEqual(s, t)
 
+    def test_singleton_empty_frozenset(self):
+        Frozenset = self.thetype
+        f = frozenset()
+        F = Frozenset()
+        efs = [Frozenset(), Frozenset([]), Frozenset(()), Frozenset(''),
+               Frozenset(), Frozenset([]), Frozenset(()), Frozenset(''),
+               Frozenset(xrange(0)), Frozenset(Frozenset()),
+               Frozenset(frozenset()), f, F, Frozenset(f), Frozenset(F)]
+        # All empty frozenset subclass instances should have different ids
+        self.assertEqual(len(set(map(id, efs))), len(efs))
+
 # Tests taken from test_sets.py =============================================
 
 empty_set = set()
@@ -1307,7 +1395,6 @@
 #==============================================================================
 
 def test_main(verbose=None):
-    import sys
     from test import test_sets
     test_classes = (
         TestSet,

Index: test_sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sets.py,v
retrieving revision 1.23.6.2
retrieving revision 1.23.6.3
diff -u -d -r1.23.6.2 -r1.23.6.3
--- test_sets.py	7 Jan 2005 06:59:11 -0000	1.23.6.2
+++ test_sets.py	16 Oct 2005 05:24:01 -0000	1.23.6.3
@@ -243,6 +243,19 @@
         self.assertRaises(TypeError, cmp, a, 12)
         self.assertRaises(TypeError, cmp, "abc", a)
 
+    def test_inplace_on_self(self):
+        t = self.set.copy()
+        t |= t
+        self.assertEqual(t, self.set)
+        t &= t
+        self.assertEqual(t, self.set)
+        t -= t
+        self.assertEqual(len(t), 0)
+        t = self.set.copy()
+        t ^= t
+        self.assertEqual(len(t), 0)
+
+
 #==============================================================================
 
 class TestUpdateOps(unittest.TestCase):

Index: test_site.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_site.py,v
retrieving revision 1.6.6.1
retrieving revision 1.6.6.2
diff -u -d -r1.6.6.1 -r1.6.6.2
--- test_site.py	7 Jan 2005 06:59:12 -0000	1.6.6.1
+++ test_site.py	16 Oct 2005 05:24:01 -0000	1.6.6.2
@@ -117,7 +117,7 @@
         Make sure to call self.cleanup() to undo anything done by this method.
 
         """
-        FILE = open(self.file_path, 'wU')
+        FILE = open(self.file_path, 'w')
         try:
             print>>FILE, "#import @bad module name"
             print>>FILE, "\n"

Index: test_socket.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v
retrieving revision 1.39.2.2
retrieving revision 1.39.2.3
diff -u -d -r1.39.2.2 -r1.39.2.3
--- test_socket.py	7 Jan 2005 06:59:12 -0000	1.39.2.2
+++ test_socket.py	16 Oct 2005 05:24:01 -0000	1.39.2.3
@@ -267,7 +267,7 @@
         except socket.error:
             # Probably a similar problem as above; skip this test
             return
-        all_host_names = [hname] + aliases
+        all_host_names = [hostname, hname] + aliases
         fqhn = socket.getfqdn()
         if not fqhn in all_host_names:
             self.fail("Error testing host resolution mechanisms.")
@@ -312,7 +312,7 @@
         # I've ordered this by protocols that have both a tcp and udp
         # protocol, at least for modern Linuxes.
         if sys.platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
-                            'darwin'):
+                            'freebsd7', 'darwin'):
             # avoid the 'echo' service on this platform, as there is an
             # assumption breaking non-standard port/protocol entry
             services = ('daytime', 'qotd', 'domain')
@@ -380,10 +380,12 @@
         self.assertEquals('\xff\x00\xff\x00', f('255.0.255.0'))
         self.assertEquals('\xaa\xaa\xaa\xaa', f('170.170.170.170'))
         self.assertEquals('\x01\x02\x03\x04', f('1.2.3.4'))
+        self.assertEquals('\xff\xff\xff\xff', f('255.255.255.255'))
 
         self.assertEquals('\x00\x00\x00\x00', g('0.0.0.0'))
         self.assertEquals('\xff\x00\xff\x00', g('255.0.255.0'))
         self.assertEquals('\xaa\xaa\xaa\xaa', g('170.170.170.170'))
+        self.assertEquals('\xff\xff\xff\xff', g('255.255.255.255'))
 
     def testIPv6toString(self):
         if not hasattr(socket, 'inet_pton'):

Index: test_str.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_str.py,v
retrieving revision 1.2.4.2
retrieving revision 1.2.4.3
diff -u -d -r1.2.4.2 -r1.2.4.3
--- test_str.py	7 Jan 2005 06:59:12 -0000	1.2.4.2
+++ test_str.py	16 Oct 2005 05:24:01 -0000	1.2.4.3
@@ -19,6 +19,69 @@
         string_tests.MixinStrUnicodeUserStringTest.test_formatting(self)
         self.assertRaises(OverflowError, '%c'.__mod__, 0x1234)
 
+    def test_conversion(self):
+        # Make sure __str__() behaves properly
+        class Foo0:
+            def __unicode__(self):
+                return u"foo"
+
+        class Foo1:
+            def __str__(self):
+                return "foo"
+
+        class Foo2(object):
+            def __str__(self):
+                return "foo"
+
+        class Foo3(object):
+            def __str__(self):
+                return u"foo"
+
+        class Foo4(unicode):
+            def __str__(self):
+                return u"foo"
+
+        class Foo5(str):
+            def __str__(self):
+                return u"foo"
+
+        class Foo6(str):
+            def __str__(self):
+                return "foos"
+
+            def __unicode__(self):
+                return u"foou"
+
+        class Foo7(unicode):
+            def __str__(self):
+                return "foos"
+            def __unicode__(self):
+                return u"foou"
+
+        class Foo8(str):
+            def __new__(cls, content=""):
+                return str.__new__(cls, 2*content)
+            def __str__(self):
+                return self
+
+        class Foo9(str):
+            def __str__(self):
+                return "string"
+            def __unicode__(self):
+                return "not unicode"
+
+        self.assert_(str(Foo0()).startswith("<")) # this is different from __unicode__
+        self.assertEqual(str(Foo1()), "foo")
+        self.assertEqual(str(Foo2()), "foo")
+        self.assertEqual(str(Foo3()), "foo")
+        self.assertEqual(str(Foo4("bar")), "foo")
+        self.assertEqual(str(Foo5("bar")), "foo")
+        self.assertEqual(str(Foo6("bar")), "foos")
+        self.assertEqual(str(Foo7("bar")), "foos")
+        self.assertEqual(str(Foo8("foo")), "foofoo")
+        self.assertEqual(str(Foo9("foo")), "string")
+        self.assertEqual(unicode(Foo9("foo")), u"not unicode")
+
 def test_main():
     test_support.run_unittest(StrTest)
 

Index: test_strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v
retrieving revision 1.11.4.2
retrieving revision 1.11.4.3
diff -u -d -r1.11.4.2 -r1.11.4.3
--- test_strptime.py	7 Jan 2005 06:59:12 -0000	1.11.4.2
+++ test_strptime.py	16 Oct 2005 05:24:01 -0000	1.11.4.3
@@ -462,10 +462,12 @@
         # Make sure cache is recreated when current locale does not match what
         # cached object was created with.
         _strptime.strptime("10", "%d")
+        _strptime.strptime("2005", "%Y")
         _strptime._TimeRE_cache.locale_time.lang = "Ni"
         original_time_re = id(_strptime._TimeRE_cache)
         _strptime.strptime("10", "%d")
         self.failIfEqual(original_time_re, id(_strptime._TimeRE_cache))
+        self.failUnlessEqual(len(_strptime._regex_cache), 1)
 
     def test_regex_cleanup(self):
         # Make sure cached regexes are discarded when cache becomes "full".

Index: test_subprocess.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v
retrieving revision 1.17.2.1
retrieving revision 1.17.2.2
diff -u -d -r1.17.2.1 -r1.17.2.2
--- test_subprocess.py	7 Jan 2005 06:59:12 -0000	1.17.2.1
+++ test_subprocess.py	16 Oct 2005 05:24:01 -0000	1.17.2.2
@@ -248,6 +248,31 @@
                          env=newenv)
         self.assertEqual(p.stdout.read(), "orange")
 
+    def test_communicate_stdin(self):
+        p = subprocess.Popen([sys.executable, "-c",
+                              'import sys; sys.exit(sys.stdin.read() == "pear")'],
+                             stdin=subprocess.PIPE)
+        p.communicate("pear")
+        self.assertEqual(p.returncode, 1)
+
+    def test_communicate_stdout(self):
+        p = subprocess.Popen([sys.executable, "-c",
+                              'import sys; sys.stdout.write("pineapple")'],
+                             stdout=subprocess.PIPE)
+        (stdout, stderr) = p.communicate()
+        self.assertEqual(stdout, "pineapple")
+        self.assertEqual(stderr, None)
+
+    def test_communicate_stderr(self):
+        p = subprocess.Popen([sys.executable, "-c",
+                              'import sys; sys.stderr.write("pineapple")'],
+                             stderr=subprocess.PIPE)
+        (stdout, stderr) = p.communicate()
+        self.assertEqual(stdout, None)
+        # When running with a pydebug build, the # of references is outputted
+        # to stderr, so just check if stderr at least started with "pinapple"
+        self.assert_(stderr.startswith("pineapple"))
+
     def test_communicate(self):
         p = subprocess.Popen([sys.executable, "-c",
                           'import sys,os;' \
@@ -359,9 +384,10 @@
 
     def test_no_leaking(self):
         # Make sure we leak no resources
-        max_handles = 1026 # too much for most UNIX systems
-        if mswindows:
-            max_handles = 65 # a full test is too slow on Windows
+        if test_support.is_resource_enabled("subprocess") and not mswindows:
+            max_handles = 1026 # too much for most UNIX systems
+        else:
+            max_handles = 65
         for i in range(max_handles):
             p = subprocess.Popen([sys.executable, "-c",
                     "import sys;sys.stdout.write(sys.stdin.read())"],

Index: test_sundry.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sundry.py,v
retrieving revision 1.10.2.2
retrieving revision 1.10.2.3
diff -u -d -r1.10.2.2 -r1.10.2.3
--- test_sundry.py	7 Jan 2005 06:59:12 -0000	1.10.2.2
+++ test_sundry.py	16 Oct 2005 05:24:01 -0000	1.10.2.3
@@ -93,5 +93,4 @@
 #import user
 import webbrowser
 import whichdb
-import xdrlib
 import xml

Index: test_support.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v
retrieving revision 1.41.2.2
retrieving revision 1.41.2.3
diff -u -d -r1.41.2.2 -r1.41.2.3
--- test_support.py	7 Jan 2005 06:59:12 -0000	1.41.2.2
+++ test_support.py	16 Oct 2005 05:24:01 -0000	1.41.2.3
@@ -144,7 +144,7 @@
             TESTFN_UNICODE_UNENCODEABLE = None
         else:
             # Japanese characters (I think - from bug 846133)
-            TESTFN_UNICODE_UNENCODEABLE = u"@test-\u5171\u6709\u3055\u308c\u308b"
+            TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"')
             try:
                 # XXX - Note - should be using TESTFN_ENCODING here - but for
                 # Windows, "mbcs" currently always operates as if in

Index: test_sys.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sys.py,v
retrieving revision 1.6.6.2
retrieving revision 1.6.6.3
diff -u -d -r1.6.6.2 -r1.6.6.3
--- test_sys.py	7 Jan 2005 06:59:12 -0000	1.6.6.2
+++ test_sys.py	16 Oct 2005 05:24:01 -0000	1.6.6.3
@@ -161,6 +161,18 @@
         else:
             self.fail("no exception")
 
+        # test that the exit machinery handles SystemExits properly
+        import subprocess
+        # both unnormalized...
+        rc = subprocess.call([sys.executable, "-c",
+                              "raise SystemExit, 46"])
+        self.assertEqual(rc, 46)
+        # ... and normalized
+        rc = subprocess.call([sys.executable, "-c",
+                              "raise SystemExit(47)"])
+        self.assertEqual(rc, 47)
+
+
     def test_getdefaultencoding(self):
         if test.test_support.have_unicode:
             self.assertRaises(TypeError, sys.getdefaultencoding, 42)
@@ -235,7 +247,8 @@
         self.assert_(isinstance(sys.executable, basestring))
         self.assert_(isinstance(sys.hexversion, int))
         self.assert_(isinstance(sys.maxint, int))
-        self.assert_(isinstance(sys.maxunicode, int))
+        if test.test_support.have_unicode:
+            self.assert_(isinstance(sys.maxunicode, int))
         self.assert_(isinstance(sys.platform, basestring))
         self.assert_(isinstance(sys.prefix, basestring))
         self.assert_(isinstance(sys.version, basestring))

Index: test_tarfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v
retrieving revision 1.7.4.2
retrieving revision 1.7.4.3
diff -u -d -r1.7.4.2 -r1.7.4.3
--- test_tarfile.py	7 Jan 2005 06:59:12 -0000	1.7.4.2
+++ test_tarfile.py	16 Oct 2005 05:24:01 -0000	1.7.4.3
@@ -91,6 +91,16 @@
             self.assert_(lines1 == lines2,
                          "_FileObject.readline() does not work correctly")
 
+    def test_iter(self):
+        # Test iteration over ExFileObject.
+        if self.sep != "|":
+            filename = "0-REGTYPE-TEXT"
+            self.tar.extract(filename, dirname())
+            lines1 = file(os.path.join(dirname(), filename), "rU").readlines()
+            lines2 = [line for line in self.tar.extractfile(filename)]
+            self.assert_(lines1 == lines2,
+                         "ExFileObject iteration does not work correctly")
+
     def test_seek(self):
         """Test seek() method of _FileObject, incl. random reading.
         """
@@ -171,6 +181,18 @@
 
         stream.close()
 
+class ReadAsteriskTest(ReadTest):
+
+    def setUp(self):
+        mode = self.mode + self.sep + "*"
+        self.tar = tarfile.open(tarname(self.comp), mode)
+
+class ReadStreamAsteriskTest(ReadStreamTest):
+
+    def setUp(self):
+        mode = self.mode + self.sep + "*"
+        self.tar = tarfile.open(tarname(self.comp), mode)
+
 class WriteTest(BaseTest):
     mode = 'w'
 
@@ -208,6 +230,40 @@
             else:
                 self.dst.addfile(tarinfo, f)
 
+class WriteSize0Test(BaseTest):
+    mode = 'w'
+
+    def setUp(self):
+        self.tmpdir = dirname()
+        self.dstname = tmpname()
+        self.dst = tarfile.open(self.dstname, "w")
+
+    def tearDown(self):
+        self.dst.close()
+
+    def test_file(self):
+        path = os.path.join(self.tmpdir, "file")
+        file(path, "w")
+        tarinfo = self.dst.gettarinfo(path)
+        self.assertEqual(tarinfo.size, 0)
+        file(path, "w").write("aaa")
+        tarinfo = self.dst.gettarinfo(path)
+        self.assertEqual(tarinfo.size, 3)
+
+    def test_directory(self):
+        path = os.path.join(self.tmpdir, "directory")
+        os.mkdir(path)
+        tarinfo = self.dst.gettarinfo(path)
+        self.assertEqual(tarinfo.size, 0)
+
+    def test_symlink(self):
+        if hasattr(os, "symlink"):
+            path = os.path.join(self.tmpdir, "symlink")
+            os.symlink("link_target", path)
+            tarinfo = self.dst.gettarinfo(path)
+            self.assertEqual(tarinfo.size, 0)
+
+
 class WriteStreamTest(WriteTest):
     sep = '|'
 
@@ -326,6 +382,11 @@
     comp = "gz"
 class WriteStreamTestGzip(WriteStreamTest):
     comp = "gz"
+class ReadAsteriskTestGzip(ReadAsteriskTest):
+    comp = "gz"
+class ReadStreamAsteriskTestGzip(ReadStreamAsteriskTest):
+    comp = "gz"
+
 
 # Filemode test cases
 
@@ -345,6 +406,10 @@
         comp = "bz2"
     class WriteStreamTestBzip2(WriteStreamTestGzip):
         comp = "bz2"
+    class ReadAsteriskTestBzip2(ReadAsteriskTest):
+        comp = "bz2"
+    class ReadStreamAsteriskTestBzip2(ReadStreamAsteriskTest):
+        comp = "bz2"
 
 # If importing gzip failed, discard the Gzip TestCases.
 if not gzip:
@@ -365,7 +430,10 @@
         FileModeTest,
         ReadTest,
         ReadStreamTest,
+        ReadAsteriskTest,
+        ReadStreamAsteriskTest,
         WriteTest,
+        WriteSize0Test,
         WriteStreamTest,
         WriteGNULongTest,
     ]
@@ -376,13 +444,15 @@
     if gzip:
         tests.extend([
             ReadTestGzip, ReadStreamTestGzip,
-            WriteTestGzip, WriteStreamTestGzip
+            WriteTestGzip, WriteStreamTestGzip,
+            ReadAsteriskTestGzip, ReadStreamAsteriskTestGzip
         ])
 
     if bz2:
         tests.extend([
             ReadTestBzip2, ReadStreamTestBzip2,
-            WriteTestBzip2, WriteStreamTestBzip2
+            WriteTestBzip2, WriteStreamTestBzip2,
+            ReadAsteriskTestBzip2, ReadStreamAsteriskTestBzip2
         ])
     try:
         test_support.run_unittest(*tests)

Index: test_tempfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tempfile.py,v
retrieving revision 1.1.10.2
retrieving revision 1.1.10.3
diff -u -d -r1.1.10.2 -r1.1.10.3
--- test_tempfile.py	7 Jan 2005 06:59:12 -0000	1.1.10.2
+++ test_tempfile.py	16 Oct 2005 05:24:01 -0000	1.1.10.3
@@ -307,7 +307,7 @@
         retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
         self.failIf(retval < 0,
                     "child process caught fatal signal %d" % -retval)
-        self.failIf(retval > 0, "child process reports failure")
+        self.failIf(retval > 0, "child process reports failure %d"%retval)
 
     def test_textmode(self):
         # _mkstemp_inner can create files in text mode

Index: test_textwrap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_textwrap.py,v
retrieving revision 1.18.10.2
retrieving revision 1.18.10.3
diff -u -d -r1.18.10.2 -r1.18.10.3
--- test_textwrap.py	7 Jan 2005 06:59:12 -0000	1.18.10.2
+++ test_textwrap.py	16 Oct 2005 05:24:01 -0000	1.18.10.3
@@ -165,6 +165,24 @@
                         ["this-is-a-useful-feature-for-reformatting-",
                          "posts-from-tim-peters'ly"])
 
+    def test_hyphenated_numbers(self):
+        # Test that hyphenated numbers (eg. dates) are not broken like words.
+        text = ("Python 1.0.0 was released on 1994-01-26.  Python 1.0.1 was\n"
+                "released on 1994-02-15.")
+
+        self.check_wrap(text, 30, ['Python 1.0.0 was released on',
+                                   '1994-01-26.  Python 1.0.1 was',
+                                   'released on 1994-02-15.'])
+        self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.',
+                                   'Python 1.0.1 was released on 1994-02-15.'])
+
+        text = "I do all my shopping at 7-11."
+        self.check_wrap(text, 25, ["I do all my shopping at",
+                                   "7-11."])
+        self.check_wrap(text, 27, ["I do all my shopping at",
+                                   "7-11."])
+        self.check_wrap(text, 29, ["I do all my shopping at 7-11."])
+
     def test_em_dash(self):
         # Test text with em-dashes
         text = "Em-dashes should be written -- thus."
@@ -310,17 +328,18 @@
         self.check_wrap(text, 30,
                         [" This is a sentence with", "leading whitespace."])
 
-    def test_unicode(self):
-        # *Very* simple test of wrapping Unicode strings.  I'm sure
-        # there's more to it than this, but let's at least make
-        # sure textwrap doesn't crash on Unicode input!
-        text = u"Hello there, how are you today?"
-        self.check_wrap(text, 50, [u"Hello there, how are you today?"])
-        self.check_wrap(text, 20, [u"Hello there, how are", "you today?"])
-        olines = self.wrapper.wrap(text)
-        assert isinstance(olines, list) and isinstance(olines[0], unicode)
-        otext = self.wrapper.fill(text)
-        assert isinstance(otext, unicode)
+    if test_support.have_unicode:
+        def test_unicode(self):
+            # *Very* simple test of wrapping Unicode strings.  I'm sure
+            # there's more to it than this, but let's at least make
+            # sure textwrap doesn't crash on Unicode input!
+            text = u"Hello there, how are you today?"
+            self.check_wrap(text, 50, [u"Hello there, how are you today?"])
+            self.check_wrap(text, 20, [u"Hello there, how are", "you today?"])
+            olines = self.wrapper.wrap(text)
+            assert isinstance(olines, list) and isinstance(olines[0], unicode)
+            otext = self.wrapper.fill(text)
+            assert isinstance(otext, unicode)
 
     def test_split(self):
         # Ensure that the standard _split() method works as advertised

Index: test_threading.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threading.py,v
retrieving revision 1.2.18.1
retrieving revision 1.2.18.2
diff -u -d -r1.2.18.1 -r1.2.18.2
--- test_threading.py	28 Apr 2003 17:27:47 -0000	1.2.18.1
+++ test_threading.py	16 Oct 2005 05:24:01 -0000	1.2.18.2
@@ -1,55 +1,112 @@
 # Very rudimentary test of threading module
 
-# Create a bunch of threads, let each do some work, wait until all are done
-
+import test.test_support
 from test.test_support import verbose
 import random
 import threading
+import thread
 import time
+import unittest
 
-# This takes about n/3 seconds to run (about n/3 clumps of tasks, times
-# about 1 second per clump).
-numtasks = 10
-
-# no more than 3 of the 10 can run at once
-sema = threading.BoundedSemaphore(value=3)
-mutex = threading.RLock()
-running = 0
+# A trivial mutable counter.
+class Counter(object):
+    def __init__(self):
+        self.value = 0
+    def inc(self):
+        self.value += 1
+    def dec(self):
+        self.value -= 1
+    def get(self):
+        return self.value
 
 class TestThread(threading.Thread):
+    def __init__(self, name, testcase, sema, mutex, nrunning):
+        threading.Thread.__init__(self, name=name)
+        self.testcase = testcase
+        self.sema = sema
+        self.mutex = mutex
+        self.nrunning = nrunning
+
     def run(self):
-        global running
         delay = random.random() * 2
         if verbose:
             print 'task', self.getName(), 'will run for', delay, 'sec'
-        sema.acquire()
-        mutex.acquire()
-        running = running + 1
+
+        self.sema.acquire()
+
+        self.mutex.acquire()
+        self.nrunning.inc()
         if verbose:
-            print running, 'tasks are running'
-        mutex.release()
+            print self.nrunning.get(), 'tasks are running'
+        self.testcase.assert_(self.nrunning.get() <= 3)
+        self.mutex.release()
+
         time.sleep(delay)
         if verbose:
             print 'task', self.getName(), 'done'
-        mutex.acquire()
-        running = running - 1
+
+        self.mutex.acquire()
+        self.nrunning.dec()
+        self.testcase.assert_(self.nrunning.get() >= 0)
         if verbose:
-            print self.getName(), 'is finished.', running, 'tasks are running'
-        mutex.release()
-        sema.release()
+            print self.getName(), 'is finished.', self.nrunning.get(), \
+                  'tasks are running'
+        self.mutex.release()
 
-threads = []
-def starttasks():
-    for i in range(numtasks):
-        t = TestThread(name="<thread %d>"%i)
-        threads.append(t)
-        t.start()
+        self.sema.release()
 
-starttasks()
+class ThreadTests(unittest.TestCase):
 
-if verbose:
-    print 'waiting for all tasks to complete'
-for t in threads:
-    t.join()
-if verbose:
-    print 'all tasks done'
+    # Create a bunch of threads, let each do some work, wait until all are
+    # done.
+    def test_various_ops(self):
+        # This takes about n/3 seconds to run (about n/3 clumps of tasks,
+        # times about 1 second per clump).
+        NUMTASKS = 10
+
+        # no more than 3 of the 10 can run at once
+        sema = threading.BoundedSemaphore(value=3)
+        mutex = threading.RLock()
+        numrunning = Counter()
+
+        threads = []
+
+        for i in range(NUMTASKS):
+            t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
+            threads.append(t)
+            t.start()
+
+        if verbose:
+            print 'waiting for all tasks to complete'
+        for t in threads:
+            t.join(NUMTASKS)
+            self.assert_(not t.isAlive())
+        if verbose:
+            print 'all tasks done'
+        self.assertEqual(numrunning.get(), 0)
+
+    def test_foreign_thread(self):
+        # Check that a "foreign" thread can use the threading module.
+        def f(mutex):
+            # Acquiring an RLock forces an entry for the foreign
+            # thread to get made in the threading._active map.
+            r = threading.RLock()
+            r.acquire()
+            r.release()
+            mutex.release()
+
+        mutex = threading.Lock()
+        mutex.acquire()
+        tid = thread.start_new_thread(f, (mutex,))
+        # Wait for the thread to finish.
+        mutex.acquire()
+        self.assert_(tid in threading._active)
+        self.assert_(isinstance(threading._active[tid],
+                                threading._DummyThread))
+        del threading._active[tid]
+
+def test_main():
+    test.test_support.run_unittest(ThreadTests)
+
+if __name__ == "__main__":
+    test_main()

Index: test_tokenize.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tokenize.py,v
retrieving revision 1.6.10.2
retrieving revision 1.6.10.3
diff -u -d -r1.6.10.2 -r1.6.10.3
--- test_tokenize.py	7 Jan 2005 06:59:13 -0000	1.6.10.2
+++ test_tokenize.py	16 Oct 2005 05:24:01 -0000	1.6.10.3
@@ -1,12 +1,100 @@
-from test.test_support import verbose, findfile
-import tokenize, os, sys
+from test.test_support import verbose, findfile, is_resource_enabled, TestFailed
+import os, glob, random
+from tokenize import (tokenize, generate_tokens, untokenize,
+                      NUMBER, NAME, OP, STRING)
 
 if verbose:
     print 'starting...'
 
 f = file(findfile('tokenize_tests' + os.extsep + 'txt'))
-tokenize.tokenize(f.readline)
+tokenize(f.readline)
 f.close()
 
+
+
+###### Test roundtrip for untokenize ##########################
+
+def test_roundtrip(f):
+    ## print 'Testing:', f
+    f = file(f)
+    try:
+        fulltok = list(generate_tokens(f.readline))
+    finally:
+        f.close()
+
+    t1 = [tok[:2] for tok in fulltok]
+    newtext = untokenize(t1)
+    readline = iter(newtext.splitlines(1)).next
+    t2 = [tok[:2] for tok in generate_tokens(readline)]
+    assert t1 == t2
+
+
+f = findfile('tokenize_tests' + os.extsep + 'txt')
+test_roundtrip(f)
+
+testdir = os.path.dirname(f) or os.curdir
+testfiles = glob.glob(testdir + os.sep + 'test*.py')
+if not is_resource_enabled('compiler'):
+    testfiles = random.sample(testfiles, 10)
+
+for f in testfiles:
+    test_roundtrip(f)
+
+
+###### Test detecton of IndentationError ######################
+
+from cStringIO import StringIO
+
+sampleBadText = """
+def foo():
+    bar
+  baz
+"""
+
+try:
+    for tok in generate_tokens(StringIO(sampleBadText).readline):
+        pass
+except IndentationError:
+    pass
+else:
+    raise TestFailed("Did not detect IndentationError:")
+
+
+###### Test example in the docs ###############################
+
+from decimal import Decimal
+from cStringIO import StringIO
+
+def decistmt(s):
+    """Substitute Decimals for floats in a string of statements.
+
+    >>> from decimal import Decimal
+    >>> s = 'print +21.3e-5*-.1234/81.7'
+    >>> decistmt(s)
+    "print +Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7')"
+
+    >>> exec(s)
+    -3.21716034272e-007
+    >>> exec(decistmt(s))
+    -3.217160342717258261933904529E-7
+
+    """
+    result = []
+    g = generate_tokens(StringIO(s).readline)   # tokenize the string
+    for toknum, tokval, _, _, _  in g:
+        if toknum == NUMBER and '.' in tokval:  # replace NUMBER tokens
+            result.extend([
+                (NAME, 'Decimal'),
+                (OP, '('),
+                (STRING, repr(tokval)),
+                (OP, ')')
+            ])
+        else:
+            result.append((toknum, tokval))
+    return untokenize(result)
+
+import doctest
+doctest.testmod()
+
 if verbose:
     print 'finished'

Index: test_trace.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_trace.py,v
retrieving revision 1.7.10.3
retrieving revision 1.7.10.4
diff -u -d -r1.7.10.3 -r1.7.10.4
--- test_trace.py	13 Oct 2005 16:58:39 -0000	1.7.10.3
+++ test_trace.py	16 Oct 2005 05:24:01 -0000	1.7.10.4
@@ -97,6 +97,7 @@
                      (-3, 'call'),
                      (-2, 'line'),
                      (-2, 'exception'),
+                     (-2, 'return'),
                      (2, 'exception'),
                      (3, 'line'),
                      (4, 'line'),

Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.58.2.2
retrieving revision 1.58.2.3
diff -u -d -r1.58.2.2 -r1.58.2.3
--- test_unicode.py	7 Jan 2005 06:59:13 -0000	1.58.2.2
+++ test_unicode.py	16 Oct 2005 05:24:01 -0000	1.58.2.3
@@ -388,7 +388,10 @@
         self.assertEqual('%i %*.*s' % (10, 5,3,u'abc',), u'10   abc')
         self.assertEqual('%i%s %*.*s' % (10, 3, 5, 3, u'abc',), u'103   abc')
         self.assertEqual('%c' % u'a', u'a')
-
+        class Wrapper:
+            def __str__(self):
+                return u'\u1234'
+        self.assertEqual('%s' % Wrapper(), u'\u1234')
 
     def test_constructor(self):
         # unicode(obj) tests (this maps to PyObject_Unicode() at C level)
@@ -725,6 +728,69 @@
         y = x.encode("raw-unicode-escape").decode("raw-unicode-escape")
         self.assertEqual(x, y)
 
+    def test_conversion(self):
+        # Make sure __unicode__() works properly
+        class Foo0:
+            def __str__(self):
+                return "foo"
+
+        class Foo1:
+            def __unicode__(self):
+                return u"foo"
+
+        class Foo2(object):
+            def __unicode__(self):
+                return u"foo"
+
+        class Foo3(object):
+            def __unicode__(self):
+                return "foo"
+
+        class Foo4(str):
+            def __unicode__(self):
+                return "foo"
+
+        class Foo5(unicode):
+            def __unicode__(self):
+                return "foo"
+
+        class Foo6(str):
+            def __str__(self):
+                return "foos"
+
+            def __unicode__(self):
+                return u"foou"
+
+        class Foo7(unicode):
+            def __str__(self):
+                return "foos"
+            def __unicode__(self):
+                return u"foou"
+
+        class Foo8(unicode):
+            def __new__(cls, content=""):
+                return unicode.__new__(cls, 2*content)
+            def __unicode__(self):
+                return self
+
+        class Foo9(unicode):
+            def __str__(self):
+                return "string"
+            def __unicode__(self):
+                return "not unicode"
+
+        self.assertEqual(unicode(Foo0()), u"foo")
+        self.assertEqual(unicode(Foo1()), u"foo")
+        self.assertEqual(unicode(Foo2()), u"foo")
+        self.assertEqual(unicode(Foo3()), u"foo")
+        self.assertEqual(unicode(Foo4("bar")), u"foo")
+        self.assertEqual(unicode(Foo5("bar")), u"foo")
+        self.assertEqual(unicode(Foo6("bar")), u"foou")
+        self.assertEqual(unicode(Foo7("bar")), u"foou")
+        self.assertEqual(unicode(Foo8("foo")), u"foofoo")
+        self.assertEqual(str(Foo9("foo")), "string")
+        self.assertEqual(unicode(Foo9("foo")), u"not unicode")
+
 def test_main():
     test_support.run_unittest(UnicodeTest)
 

Index: test_unicode_file.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode_file.py,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -u -d -r1.4.2.2 -r1.4.2.3
--- test_unicode_file.py	7 Jan 2005 06:59:13 -0000	1.4.2.2
+++ test_unicode_file.py	16 Oct 2005 05:24:01 -0000	1.4.2.3
@@ -44,8 +44,10 @@
     def _do_single(self, filename):
         self.failUnless(os.path.exists(filename))
         self.failUnless(os.path.isfile(filename))
+        self.failUnless(os.access(filename, os.R_OK))
         self.failUnless(os.path.exists(os.path.abspath(filename)))
         self.failUnless(os.path.isfile(os.path.abspath(filename)))
+        self.failUnless(os.access(os.path.abspath(filename), os.R_OK))
         os.chmod(filename, 0777)
         os.utime(filename, None)
         os.utime(filename, (time.time(), time.time()))

Index: test_unicodedata.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicodedata.py,v
retrieving revision 1.5.26.2
retrieving revision 1.5.26.3
diff -u -d -r1.5.26.2 -r1.5.26.3
--- test_unicodedata.py	7 Jan 2005 06:59:13 -0000	1.5.26.2
+++ test_unicodedata.py	16 Oct 2005 05:24:01 -0000	1.5.26.3
@@ -191,7 +191,7 @@
     def test_decimal_numeric_consistent(self):
         # Test that decimal and numeric are consistent,
         # i.e. if a character has a decimal value,
-        # it's numeric value should be the same.
+        # its numeric value should be the same.
         count = 0
         for i in xrange(0x10000):
             c = unichr(i)
@@ -204,7 +204,7 @@
     def test_digit_numeric_consistent(self):
         # Test that digit and numeric are consistent,
         # i.e. if a character has a digit value,
-        # it's numeric value should be the same.
+        # its numeric value should be the same.
         count = 0
         for i in xrange(0x10000):
             c = unichr(i)

Index: test_urllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urllib.py,v
retrieving revision 1.8.26.2
retrieving revision 1.8.26.3
diff -u -d -r1.8.26.2 -r1.8.26.3
--- test_urllib.py	7 Jan 2005 06:59:13 -0000	1.8.26.2
+++ test_urllib.py	16 Oct 2005 05:24:01 -0000	1.8.26.3
@@ -6,6 +6,7 @@
 from test import test_support
 import os
 import mimetools
+import tempfile
 import StringIO
 
 def hexescape(char):
@@ -125,15 +126,53 @@
     """Test urllib.urlretrieve() on local files"""
 
     def setUp(self):
+        # Create a list of temporary files. Each item in the list is a file
+        # name (absolute path or relative to the current working directory).
+        # All files in this list will be deleted in the tearDown method. Note,
+        # this only helps to makes sure temporary files get deleted, but it
+        # does nothing about trying to close files that may still be open. It
+        # is the responsibility of the developer to properly close files even
+        # when exceptional conditions occur.
+        self.tempFiles = []
+
         # Create a temporary file.
+        self.registerFileForCleanUp(test_support.TESTFN)
         self.text = 'testing urllib.urlretrieve'
-        FILE = file(test_support.TESTFN, 'wb')
-        FILE.write(self.text)
-        FILE.close()
+        try:
+            FILE = file(test_support.TESTFN, 'wb')
+            FILE.write(self.text)
+            FILE.close()
+        finally:
+            try: FILE.close()
+            except: pass
 
     def tearDown(self):
-        # Delete the temporary file.
-        os.remove(test_support.TESTFN)
+        # Delete the temporary files.
+        for each in self.tempFiles:
+            try: os.remove(each)
+            except: pass
+
+    def constructLocalFileUrl(self, filePath):
+        return "file://%s" % urllib.pathname2url(os.path.abspath(filePath))
+
+    def createNewTempFile(self, data=""):
+        """Creates a new temporary file containing the specified data,
+        registers the file for deletion during the test fixture tear down, and
+        returns the absolute path of the file."""
+
+        newFd, newFilePath = tempfile.mkstemp()
+        try:
+            self.registerFileForCleanUp(newFilePath)
+            newFile = os.fdopen(newFd, "wb")
+            newFile.write(data)
+            newFile.close()
+        finally:
+            try: newFile.close()
+            except: pass
+        return newFilePath
+
+    def registerFileForCleanUp(self, fileName):
+        self.tempFiles.append(fileName)
 
     def test_basic(self):
         # Make sure that a local file just gets its own location returned and
@@ -147,15 +186,19 @@
     def test_copy(self):
         # Test that setting the filename argument works.
         second_temp = "%s.2" % test_support.TESTFN
-        result = urllib.urlretrieve("file:%s" % test_support.TESTFN, second_temp)
+        self.registerFileForCleanUp(second_temp)
+        result = urllib.urlretrieve(self.constructLocalFileUrl(
+            test_support.TESTFN), second_temp)
         self.assertEqual(second_temp, result[0])
         self.assert_(os.path.exists(second_temp), "copy of the file was not "
                                                   "made")
         FILE = file(second_temp, 'rb')
         try:
             text = FILE.read()
-        finally:
             FILE.close()
+        finally:
+            try: FILE.close()
+            except: pass
         self.assertEqual(self.text, text)
 
     def test_reporthook(self):
@@ -167,8 +210,49 @@
             self.assertEqual(count, count_holder[0])
             count_holder[0] = count_holder[0] + 1
         second_temp = "%s.2" % test_support.TESTFN
-        urllib.urlretrieve(test_support.TESTFN, second_temp, hooktester)
-        os.remove(second_temp)
+        self.registerFileForCleanUp(second_temp)
+        urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN),
+            second_temp, hooktester)
+
+    def test_reporthook_0_bytes(self):
+        # Test on zero length file. Should call reporthook only 1 time.
+        report = []
+        def hooktester(count, block_size, total_size, _report=report):
+            _report.append((count, block_size, total_size))
+        srcFileName = self.createNewTempFile()
+        urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
+            test_support.TESTFN, hooktester)
+        self.assertEqual(len(report), 1)
+        self.assertEqual(report[0][2], 0)
+
+    def test_reporthook_5_bytes(self):
+        # Test on 5 byte file. Should call reporthook only 2 times (once when
+        # the "network connection" is established and once when the block is
+        # read). Since the block size is 8192 bytes, only one block read is
+        # required to read the entire file.
+        report = []
+        def hooktester(count, block_size, total_size, _report=report):
+            _report.append((count, block_size, total_size))
+        srcFileName = self.createNewTempFile("x" * 5)
+        urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
+            test_support.TESTFN, hooktester)
+        self.assertEqual(len(report), 2)
+        self.assertEqual(report[0][1], 8192)
+        self.assertEqual(report[0][2], 5)
+
+    def test_reporthook_8193_bytes(self):
+        # Test on 8193 byte file. Should call reporthook only 3 times (once
+        # when the "network connection" is established, once for the next 8192
+        # bytes, and once for the last byte).
+        report = []
+        def hooktester(count, block_size, total_size, _report=report):
+            _report.append((count, block_size, total_size))
+        srcFileName = self.createNewTempFile("x" * 8193)
+        urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
+            test_support.TESTFN, hooktester)
+        self.assertEqual(len(report), 3)
+        self.assertEqual(report[0][1], 8192)
+        self.assertEqual(report[0][2], 8193)
 
 class QuotingTests(unittest.TestCase):
     """Tests for urllib.quote() and urllib.quote_plus()
@@ -269,6 +353,12 @@
         self.assertEqual(expect, result,
                          "using quote_plus(): %s != %s" % (expect, result))
 
+    def test_quoting_plus(self):
+        self.assertEqual(urllib.quote_plus('alpha+beta gamma'),
+                         'alpha%2Bbeta+gamma')
+        self.assertEqual(urllib.quote_plus('alpha+beta gamma', '+'),
+                         'alpha+beta+gamma')
+
 class UnquotingTests(unittest.TestCase):
     """Tests for unquote() and unquote_plus()
 

Index: test_urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urllib2.py,v
retrieving revision 1.6.10.2
retrieving revision 1.6.10.3
diff -u -d -r1.6.10.2 -r1.6.10.3
--- test_urllib2.py	7 Jan 2005 06:59:13 -0000	1.6.10.2
+++ test_urllib2.py	16 Oct 2005 05:24:01 -0000	1.6.10.3
@@ -41,6 +41,18 @@
         buf = f.read()
         f.close()
 
+    def test_statudict(self):
+        # test the new-in-2.5 httpresponses dictionary
+        self.assertEquals(urllib2.httpresponses[404], "Not Found")
+
+    def test_parse_http_list(self):
+        tests = [('a,b,c', ['a', 'b', 'c']),
+                 ('path"o,l"og"i"cal, example', ['path"o,l"og"i"cal', 'example']),
+                 ('a, b, "c", "d", "e,f", g, h', ['a', 'b', '"c"', '"d"', '"e,f"', 'g', 'h']),
+                 ('a="b\\"c", d="e\\,f", g="h\\\\i"', ['a="b"c"', 'd="e,f"', 'g="h\\i"'])]
+        for string, list in tests:
+            self.assertEquals(urllib2.parse_http_list(string), list)
+
 
 class MockOpener:
     addheaders = []

Index: test_urlparse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urlparse.py,v
retrieving revision 1.5.2.2
retrieving revision 1.5.2.3
diff -u -d -r1.5.2.2 -r1.5.2.3
--- test_urlparse.py	7 Jan 2005 06:59:13 -0000	1.5.2.2
+++ test_urlparse.py	16 Oct 2005 05:24:01 -0000	1.5.2.3
@@ -8,20 +8,22 @@
 RFC2396_BASE = "http://a/b/c/d;p?q"
 
 class UrlParseTestCase(unittest.TestCase):
-    def test_frags(self):
-        for url, parsed, split in [
-            ('http://www.python.org',
-             ('http', 'www.python.org', '', '', '', ''),
-             ('http', 'www.python.org', '', '', '')),
-            ('http://www.python.org#abc',
-             ('http', 'www.python.org', '', '', '', 'abc'),
-             ('http', 'www.python.org', '', '', 'abc')),
-            ('http://www.python.org/#abc',
-             ('http', 'www.python.org', '/', '', '', 'abc'),
-             ('http', 'www.python.org', '/', '', 'abc')),
-            (RFC1808_BASE,
-             ('http', 'a', '/b/c/d', 'p', 'q', 'f'),
-             ('http', 'a', '/b/c/d;p', 'q', 'f')),
+
+    def checkRoundtrips(self, url, parsed, split):
+        result = urlparse.urlparse(url)
+        self.assertEqual(result, parsed)
+        # put it back together and it should be the same
+        result2 = urlparse.urlunparse(result)
+        self.assertEqual(result2, url)
+
+        # check the roundtrip using urlsplit() as well
+        result = urlparse.urlsplit(url)
+        self.assertEqual(result, split)
+        result2 = urlparse.urlunsplit(result)
+        self.assertEqual(result2, url)
+
+    def test_roundtrips(self):
+        testcases = [
             ('file:///tmp/junk.txt',
              ('file', '', '/tmp/junk.txt', '', '', ''),
              ('file', '', '/tmp/junk.txt', '', '')),
@@ -29,20 +31,46 @@
              ('imap', 'mail.python.org', '/mbox1', '', '', ''),
              ('imap', 'mail.python.org', '/mbox1', '', '')),
             ('mms://wms.sys.hinet.net/cts/Drama/09006251100.asf',
-             ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '', ''),
-             ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '')),
-            ]:
-            result = urlparse.urlparse(url)
-            self.assertEqual(result, parsed)
-            # put it back together and it should be the same
-            result2 = urlparse.urlunparse(result)
-            self.assertEqual(result2, url)
+             ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
+              '', '', ''),
+             ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
+              '', '')),
+            ('svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/',
+             ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
+              '', '', ''),
+             ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
+              '', ''))
+            ]
+        for url, parsed, split in testcases:
+            self.checkRoundtrips(url, parsed, split)
 
-            # check the roundtrip using urlsplit() as well
-            result = urlparse.urlsplit(url)
-            self.assertEqual(result, split)
-            result2 = urlparse.urlunsplit(result)
-            self.assertEqual(result2, url)
+    def test_http_roundtrips(self):
+        # urlparse.urlsplit treats 'http:' as an optimized special case,
+        # so we test both 'http:' and 'https:' in all the following.
+        # Three cheers for white box knowledge!
+        testcases = [
+            ('://www.python.org',
+             ('www.python.org', '', '', '', ''),
+             ('www.python.org', '', '', '')),
+            ('://www.python.org#abc',
+             ('www.python.org', '', '', '', 'abc'),
+             ('www.python.org', '', '', 'abc')),
+            ('://www.python.org?q=abc',
+             ('www.python.org', '', '', 'q=abc', ''),
+             ('www.python.org', '', 'q=abc', '')),
+            ('://www.python.org/#abc',
+             ('www.python.org', '/', '', '', 'abc'),
+             ('www.python.org', '/', '', 'abc')),
+            ('://a/b/c/d;p?q#f',
+             ('a', '/b/c/d', 'p', 'q', 'f'),
+             ('a', '/b/c/d;p', 'q', 'f')),
+            ]
+        for scheme in ('http', 'https'):
+            for url, parsed, split in testcases:
+                url = scheme + url
+                parsed = (scheme,) + parsed
+                split = (scheme,) + split
+                self.checkRoundtrips(url, parsed, split)
 
     def checkJoin(self, base, relurl, expected):
         self.assertEqual(urlparse.urljoin(base, relurl), expected,

Index: test_userdict.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userdict.py,v
retrieving revision 1.5.10.2
retrieving revision 1.5.10.3
diff -u -d -r1.5.10.2 -r1.5.10.3
--- test_userdict.py	7 Jan 2005 06:59:13 -0000	1.5.10.2
+++ test_userdict.py	16 Oct 2005 05:24:01 -0000	1.5.10.3
@@ -191,12 +191,12 @@
         for key, value in self.iteritems():
             d[key] = value
         return d
+    @classmethod
     def fromkeys(cls, keys, value=None):
         d = cls()
         for key in keys:
             d[key] = value
         return d
-    fromkeys = classmethod(fromkeys)
 
 class UserDictMixinTest(mapping_tests.TestMappingProtocol):
     type2test = SeqDict

Index: test_userstring.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -u -d -r1.6.2.2 -r1.6.2.3
--- test_userstring.py	7 Jan 2005 06:59:13 -0000	1.6.2.2
+++ test_userstring.py	16 Oct 2005 05:24:01 -0000	1.6.2.3
@@ -5,7 +5,7 @@
 import unittest
 from test import test_support, string_tests
 
-from UserString import UserString
+from UserString import UserString, MutableString
 
 class UserStringTest(
     string_tests.CommonTest,
@@ -43,8 +43,77 @@
         # we don't fix the arguments, because UserString can't cope with it
         getattr(object, methodname)(*args)
 
+class MutableStringTest(UserStringTest):
+    type2test = MutableString
+
+    # MutableStrings can be hashed => deactivate test
+    def test_hash(self):
+        pass
+
+    def test_setitem(self):
+        s = self.type2test("foo")
+        self.assertRaises(IndexError, s.__setitem__, -4, "bar")
+        self.assertRaises(IndexError, s.__setitem__, 3, "bar")
+        s[-1] = "bar"
+        self.assertEqual(s, "fobar")
+        s[0] = "bar"
+        self.assertEqual(s, "barobar")
+
+    def test_delitem(self):
+        s = self.type2test("foo")
+        self.assertRaises(IndexError, s.__delitem__, -4)
+        self.assertRaises(IndexError, s.__delitem__, 3)
+        del s[-1]
+        self.assertEqual(s, "fo")
+        del s[0]
+        self.assertEqual(s, "o")
+        del s[0]
+        self.assertEqual(s, "")
+
+    def test_setslice(self):
+        s = self.type2test("foo")
+        s[:] = "bar"
+        self.assertEqual(s, "bar")
+        s[1:2] = "foo"
+        self.assertEqual(s, "bfoor")
+        s[1:-1] = UserString("a")
+        self.assertEqual(s, "bar")
+        s[0:10] = 42
+        self.assertEqual(s, "42")
+
+    def test_delslice(self):
+        s = self.type2test("foobar")
+        del s[3:10]
+        self.assertEqual(s, "foo")
+        del s[-1:10]
+        self.assertEqual(s, "fo")
+
+    def test_immutable(self):
+        s = self.type2test("foobar")
+        s2 = s.immutable()
+        self.assertEqual(s, s2)
+        self.assert_(isinstance(s2, UserString))
+
+    def test_iadd(self):
+        s = self.type2test("foo")
+        s += "bar"
+        self.assertEqual(s, "foobar")
+        s += UserString("baz")
+        self.assertEqual(s, "foobarbaz")
+        s += 42
+        self.assertEqual(s, "foobarbaz42")
+
+    def test_imul(self):
+        s = self.type2test("foo")
+        s *= 1
+        self.assertEqual(s, "foo")
+        s *= 2
+        self.assertEqual(s, "foofoo")
+        s *= -1
+        self.assertEqual(s, "")
+
 def test_main():
-    test_support.run_unittest(UserStringTest)
+    test_support.run_unittest(UserStringTest, MutableStringTest)
 
 if __name__ == "__main__":
     test_main()

Index: test_weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v
retrieving revision 1.19.2.2
retrieving revision 1.19.2.3
diff -u -d -r1.19.2.2 -r1.19.2.3
--- test_weakref.py	7 Jan 2005 06:59:13 -0000	1.19.2.2
+++ test_weakref.py	16 Oct 2005 05:24:01 -0000	1.19.2.3
@@ -271,6 +271,12 @@
         del f[0]
         self.assertEqual(f.result, 0)
 
+    def test_proxy_bool(self):
+        # Test clearing of SF bug #1170766
+        class List(list): pass
+        lyst = List()
+        self.assertEqual(bool(weakref.proxy(lyst)), bool(lyst))
+
     def test_getweakrefcount(self):
         o = C()
         ref1 = weakref.ref(o)
@@ -995,6 +1001,91 @@
     def _reference(self):
         return self.__ref.copy()
 
+libreftest = """ Doctest for examples in the library reference: libweakref.tex
+
+>>> import weakref
+>>> class Dict(dict):
+...     pass
+...
+>>> obj = Dict(red=1, green=2, blue=3)   # this object is weak referencable
+>>> r = weakref.ref(obj)
+>>> print r()
+{'blue': 3, 'green': 2, 'red': 1}
+
+>>> import weakref
+>>> class Object:
+...     pass
+...
+>>> o = Object()
+>>> r = weakref.ref(o)
+>>> o2 = r()
+>>> o is o2
+True
+>>> del o, o2
+>>> print r()
+None
+
+>>> import weakref
+>>> class ExtendedRef(weakref.ref):
+...     def __init__(self, ob, callback=None, **annotations):
+...         super(ExtendedRef, self).__init__(ob, callback)
+...         self.__counter = 0
+...         for k, v in annotations.iteritems():
+...             setattr(self, k, v)
+...     def __call__(self):
+...         '''Return a pair containing the referent and the number of
+...         times the reference has been called.
+...         '''
+...         ob = super(ExtendedRef, self).__call__()
+...         if ob is not None:
+...             self.__counter += 1
+...             ob = (ob, self.__counter)
+...         return ob
+...
+>>> class A:   # not in docs from here, just testing the ExtendedRef
+...     pass
+...
+>>> a = A()
+>>> r = ExtendedRef(a, foo=1, bar="baz")
+>>> r.foo
+1
+>>> r.bar
+'baz'
+>>> r()[1]
+1
+>>> r()[1]
+2
+>>> r()[0] is a
+True
+
+
+>>> import weakref
+>>> _id2obj_dict = weakref.WeakValueDictionary()
+>>> def remember(obj):
+...     oid = id(obj)
+...     _id2obj_dict[oid] = obj
+...     return oid
+...
+>>> def id2obj(oid):
+...     return _id2obj_dict[oid]
+...
+>>> a = A()             # from here, just testing
+>>> a_id = remember(a)
+>>> id2obj(a_id) is a
+True
+>>> del a
+>>> try:
+...     id2obj(a_id)
+... except KeyError:
+...     print 'OK'
+... else:
+...     print 'WeakValueDictionary error'
+OK
+
+"""
+
+__test__ = {'libreftest' : libreftest}
+
 def test_main():
     test_support.run_unittest(
         ReferencesTestCase,
@@ -1002,6 +1093,7 @@
         WeakValueDictionaryTestCase,
         WeakKeyDictionaryTestCase,
         )
+    test_support.run_doctest(sys.modules[__name__])
 
 
 if __name__ == "__main__":

Index: test_xmlrpc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xmlrpc.py,v
retrieving revision 1.2.10.2
retrieving revision 1.2.10.3
diff -u -d -r1.2.10.2 -r1.2.10.3
--- test_xmlrpc.py	7 Jan 2005 06:59:13 -0000	1.2.10.2
+++ test_xmlrpc.py	16 Oct 2005 05:24:01 -0000	1.2.10.3
@@ -1,8 +1,16 @@
+import datetime
 import sys
 import unittest
 import xmlrpclib
 from test import test_support
 
+try:
+    unicode
+except NameError:
+    have_unicode = False
+else:
+    have_unicode = True
+
 alist = [{'astring': 'foo at bar.baz.spam',
           'afloat': 7283.43,
           'anint': 2**20,
@@ -12,6 +20,11 @@
           'boolean': xmlrpclib.False,
           'unicode': u'\u4000\u6000\u8000',
           u'ukey\u4000': 'regular value',
+          'datetime1': xmlrpclib.DateTime('20050210T11:41:23'),
+          'datetime2': xmlrpclib.DateTime(
+                        (2005, 02, 10, 11, 41, 23, 0, 1, -1)),
+          'datetime3': xmlrpclib.DateTime(
+                        datetime.datetime(2005, 02, 10, 11, 41, 23)),
           }]
 
 class XMLRPCTestCase(unittest.TestCase):
@@ -20,6 +33,49 @@
         self.assertEquals(alist,
                           xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0])
 
+    def test_dump_bare_datetime(self):
+        # This checks that an unwrapped datetime.date object can be handled
+        # by the marshalling code.  This can't be done via test_dump_load()
+        # since with use_datetime set to 1 the unmarshaller would create
+        # datetime objects for the 'datetime[123]' keys as well
+        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
+        s = xmlrpclib.dumps((dt,))
+        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
+        self.assertEquals(newdt, dt)
+        self.assertEquals(m, None)
+
+        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
+        self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23'))
+
+    def test_dump_bare_date(self):
+        # This checks that an unwrapped datetime.date object can be handled
+        # by the marshalling code.  This can't be done via test_dump_load()
+        # since the unmarshaller produces a datetime object
+        d = datetime.datetime(2005, 02, 10, 11, 41, 23).date()
+        s = xmlrpclib.dumps((d,))
+        (newd,), m = xmlrpclib.loads(s, use_datetime=1)
+        self.assertEquals(newd.date(), d)
+        self.assertEquals(newd.time(), datetime.time(0, 0, 0))
+        self.assertEquals(m, None)
+
+        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
+        self.assertEquals(newdt, xmlrpclib.DateTime('20050210T00:00:00'))
+
+    def test_dump_bare_time(self):
+        # This checks that an unwrapped datetime.time object can be handled
+        # by the marshalling code.  This can't be done via test_dump_load()
+        # since the unmarshaller produces a datetime object
+        t = datetime.datetime(2005, 02, 10, 11, 41, 23).time()
+        s = xmlrpclib.dumps((t,))
+        (newt,), m = xmlrpclib.loads(s, use_datetime=1)
+        today = datetime.datetime.now().date().strftime("%Y%m%d")
+        self.assertEquals(newt.time(), t)
+        self.assertEquals(newt.date(), datetime.datetime.now().date())
+        self.assertEquals(m, None)
+
+        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
+        self.assertEquals(newdt, xmlrpclib.DateTime('%sT11:41:23'%today))
+
     def test_dump_big_long(self):
         self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,))
 
@@ -39,6 +95,48 @@
                           xmlrpclib.loads(strg)[0][0])
         self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,))
 
+    def test_default_encoding_issues(self):
+        # SF bug #1115989: wrong decoding in '_stringify'
+        utf8 = """<?xml version='1.0' encoding='iso-8859-1'?>
+                  <params>
+                    <param><value>
+                      <string>abc \x95</string>
+                      </value></param>
+                    <param><value>
+                      <struct>
+                        <member>
+                          <name>def \x96</name>
+                          <value><string>ghi \x97</string></value>
+                          </member>
+                        </struct>
+                      </value></param>
+                  </params>
+                  """
+
+        # sys.setdefaultencoding() normally doesn't exist after site.py is
+        # loaded.  reload(sys) is the way to get it back.
+        old_encoding = sys.getdefaultencoding()
+        setdefaultencoding_existed = hasattr(sys, "setdefaultencoding")
+        reload(sys) # ugh!
+        sys.setdefaultencoding("iso-8859-1")
+        try:
+            (s, d), m = xmlrpclib.loads(utf8)
+        finally:
+            sys.setdefaultencoding(old_encoding)
+            if not setdefaultencoding_existed:
+                del sys.setdefaultencoding
+
+        items = d.items()
+        if have_unicode:
+            self.assertEquals(s, u"abc \x95")
+            self.assert_(isinstance(s, unicode))
+            self.assertEquals(items, [(u"def \x96", u"ghi \x97")])
+            self.assert_(isinstance(items[0][0], unicode))
+            self.assert_(isinstance(items[0][1], unicode))
+        else:
+            self.assertEquals(s, "abc \xc2\x95")
+            self.assertEquals(items, [("def \xc2\x96", "ghi \xc2\x97")])
+
 def test_main():
     test_support.run_unittest(XMLRPCTestCase)
 

Index: test_zlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zlib.py,v
retrieving revision 1.17.2.2
retrieving revision 1.17.2.3
diff -u -d -r1.17.2.2 -r1.17.2.3
--- test_zlib.py	7 Jan 2005 06:59:13 -0000	1.17.2.2
+++ test_zlib.py	16 Oct 2005 05:24:01 -0000	1.17.2.3
@@ -299,7 +299,7 @@
         self.failUnless(co.flush())  # Returns a zlib header
         dco = zlib.decompressobj()
         self.assertEqual(dco.flush(), "") # Returns nothing
-        
+
 
 def genblock(seed, length, step=1024, generator=random):
     """length-byte stream of random data from a seed (in step-byte blocks)."""



More information about the Python-checkins mailing list