From python-checkins at python.org Thu Apr 1 00:01:03 2010 From: python-checkins at python.org (florent.xicluna) Date: Thu, 1 Apr 2010 00:01:03 +0200 (CEST) Subject: [Python-checkins] r79539 - in python/trunk/Lib/test: test___all__.py test_argparse.py test_coercion.py test_commands.py test_complex.py test_contextlib.py test_cookie.py test_descr.py test_doctest.py test_exceptions.py test_global.py test_hmac.py test_int_literal.py test_io.py test_macostools.py test_pep352.py test_re.py test_sundry.py test_symtable.py test_urllibnet.py test_zipimport_support.py Message-ID: <20100331220103.CB732C547@mail.python.org> Author: florent.xicluna Date: Thu Apr 1 00:01:03 2010 New Revision: 79539 Log: Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests. Modified: python/trunk/Lib/test/test___all__.py python/trunk/Lib/test/test_argparse.py python/trunk/Lib/test/test_coercion.py python/trunk/Lib/test/test_commands.py python/trunk/Lib/test/test_complex.py python/trunk/Lib/test/test_contextlib.py python/trunk/Lib/test/test_cookie.py python/trunk/Lib/test/test_descr.py python/trunk/Lib/test/test_doctest.py python/trunk/Lib/test/test_exceptions.py python/trunk/Lib/test/test_global.py python/trunk/Lib/test/test_hmac.py python/trunk/Lib/test/test_int_literal.py python/trunk/Lib/test/test_io.py python/trunk/Lib/test/test_macostools.py python/trunk/Lib/test/test_pep352.py python/trunk/Lib/test/test_re.py python/trunk/Lib/test/test_sundry.py python/trunk/Lib/test/test_symtable.py python/trunk/Lib/test/test_urllibnet.py python/trunk/Lib/test/test_zipimport_support.py Modified: python/trunk/Lib/test/test___all__.py ============================================================================== --- python/trunk/Lib/test/test___all__.py (original) +++ python/trunk/Lib/test/test___all__.py Thu Apr 1 00:01:03 2010 @@ -4,7 +4,6 @@ from test import test_support as support import os import sys -import warnings class NoAll(RuntimeError): @@ -18,9 +17,8 @@ def check_all(self, modname): names = {} - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", ".* (module|package)", - DeprecationWarning) + with support.check_warnings((".* (module|package)", + DeprecationWarning), quiet=True): try: exec "import %s" % modname in names except: Modified: python/trunk/Lib/test/test_argparse.py ============================================================================== --- python/trunk/Lib/test/test_argparse.py (original) +++ python/trunk/Lib/test/test_argparse.py Thu Apr 1 00:01:03 2010 @@ -7,7 +7,6 @@ import textwrap import tempfile import unittest -import warnings import argparse from StringIO import StringIO @@ -4160,21 +4159,12 @@ self.assertTrue(hasattr(argparse, name)) def test_main(): - with warnings.catch_warnings(): - # silence warnings about version argument - these are expected - warnings.filterwarnings( - action='ignore', - message='The "version" argument to ArgumentParser is deprecated.', - category=DeprecationWarning) - warnings.filterwarnings( - action='ignore', - message='The format_version method is deprecated', - category=DeprecationWarning) - warnings.filterwarnings( - action='ignore', - message='The print_version method is deprecated', - category=DeprecationWarning) - + # silence warnings about version argument - these are expected + with test_support.check_warnings( + ('The "version" argument to ArgumentParser is deprecated.', + DeprecationWarning), + ('The (format|print)_version method is deprecated', + DeprecationWarning)): test_support.run_unittest(__name__) # Remove global references to avoid looking like we have refleaks. RFile.seen = {} Modified: python/trunk/Lib/test/test_coercion.py ============================================================================== --- python/trunk/Lib/test/test_coercion.py (original) +++ python/trunk/Lib/test/test_coercion.py Thu Apr 1 00:01:03 2010 @@ -1,7 +1,6 @@ import copy -import warnings import unittest -from test.test_support import run_unittest, TestFailed +from test.test_support import run_unittest, TestFailed, check_warnings # Fake a number that implements numeric methods through __coerce__ class CoerceNumber: @@ -223,12 +222,6 @@ infix_results[key] = res -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", "classic int division", - DeprecationWarning) - process_infix_results() -# now infix_results has two lists of results for every pairing. - prefix_binops = [ 'divmod' ] prefix_results = [ [(1,0), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1,0)], @@ -339,11 +332,13 @@ raise exc def test_main(): - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", "complex divmod.., // and % " - "are deprecated", DeprecationWarning) - warnings.filterwarnings("ignore", "classic (int|long) division", - DeprecationWarning) + with check_warnings(("complex divmod.., // and % are deprecated", + DeprecationWarning), + ("classic (int|long) division", DeprecationWarning), + quiet=True): + process_infix_results() + # now infix_results has two lists of results for every pairing. + run_unittest(CoercionTest) if __name__ == "__main__": Modified: python/trunk/Lib/test/test_commands.py ============================================================================== --- python/trunk/Lib/test/test_commands.py (original) +++ python/trunk/Lib/test/test_commands.py Thu Apr 1 00:01:03 2010 @@ -4,12 +4,9 @@ ''' import unittest import os, tempfile, re -import warnings -warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated", - DeprecationWarning) - -from test.test_support import run_unittest, reap_children, import_module +from test.test_support import run_unittest, reap_children, import_module, \ + check_warnings # Silence Py3k warning commands = import_module('commands', deprecated=True) @@ -59,7 +56,9 @@ /\. # and end with the name of the file. ''' - self.assertTrue(re.match(pat, commands.getstatus("/."), re.VERBOSE)) + with check_warnings((".*commands.getstatus.. is deprecated", + DeprecationWarning)): + self.assertTrue(re.match(pat, commands.getstatus("/."), re.VERBOSE)) def test_main(): Modified: python/trunk/Lib/test/test_complex.py ============================================================================== --- python/trunk/Lib/test/test_complex.py (original) +++ python/trunk/Lib/test/test_complex.py Thu Apr 1 00:01:03 2010 @@ -1,13 +1,6 @@ -import unittest, os +import unittest from test import test_support -import warnings -warnings.filterwarnings( - "ignore", - category=DeprecationWarning, - message=".*complex divmod.*are deprecated" -) - from random import random from math import atan2, isnan, copysign @@ -464,10 +457,7 @@ finally: if (fo is not None) and (not fo.closed): fo.close() - try: - os.remove(test_support.TESTFN) - except (OSError, IOError): - pass + test_support.unlink(test_support.TESTFN) def test_getnewargs(self): self.assertEqual((1+2j).__getnewargs__(), (1.0, 2.0)) @@ -613,7 +603,9 @@ self.assertEqual('{0:F}'.format(complex(NAN, NAN)), 'NAN+NANj') def test_main(): - test_support.run_unittest(ComplexTest) + with test_support.check_warnings(("complex divmod.., // and % are " + "deprecated", DeprecationWarning)): + test_support.run_unittest(ComplexTest) if __name__ == "__main__": test_main() Modified: python/trunk/Lib/test/test_contextlib.py ============================================================================== --- python/trunk/Lib/test/test_contextlib.py (original) +++ python/trunk/Lib/test/test_contextlib.py Thu Apr 1 00:01:03 2010 @@ -1,14 +1,12 @@ """Unit tests for contextlib.py, and other context managers.""" - -import os import sys import tempfile import unittest import threading from contextlib import * # Tests __all__ from test import test_support -import warnings + class ContextManagerTestCase(unittest.TestCase): @@ -34,16 +32,12 @@ yield 42 finally: state.append(999) - try: + with self.assertRaises(ZeroDivisionError): with woohoo() as x: self.assertEqual(state, [1]) self.assertEqual(x, 42) state.append(x) raise ZeroDivisionError() - except ZeroDivisionError: - pass - else: - self.fail("Expected ZeroDivisionError") self.assertEqual(state, [1, 42, 999]) def test_contextmanager_no_reraise(self): @@ -144,15 +138,12 @@ yield 5 finally: state.append(6) - try: + with self.assertRaises(ZeroDivisionError): with nested(a(), b()) as (x, y): state.append(x) state.append(y) - 1/0 - except ZeroDivisionError: - self.assertEqual(state, [1, 4, 2, 5, 6, 3]) - else: - self.fail("Didn't raise ZeroDivisionError") + 1 // 0 + self.assertEqual(state, [1, 4, 2, 5, 6, 3]) def test_nested_right_exception(self): @contextmanager @@ -166,15 +157,10 @@ raise Exception() except: pass - try: + with self.assertRaises(ZeroDivisionError): with nested(a(), b()) as (x, y): - 1/0 - except ZeroDivisionError: - self.assertEqual((x, y), (1, 2)) - except Exception: - self.fail("Reraised wrong exception") - else: - self.fail("Didn't raise ZeroDivisionError") + 1 // 0 + self.assertEqual((x, y), (1, 2)) def test_nested_b_swallows(self): @contextmanager @@ -189,7 +175,7 @@ pass try: with nested(a(), b()): - 1/0 + 1 // 0 except ZeroDivisionError: self.fail("Didn't swallow ZeroDivisionError") @@ -252,14 +238,11 @@ state.append(1) x = C() self.assertEqual(state, []) - try: + with self.assertRaises(ZeroDivisionError): with closing(x) as y: self.assertEqual(x, y) - 1/0 - except ZeroDivisionError: - self.assertEqual(state, [1]) - else: - self.fail("Didn't raise ZeroDivisionError") + 1 // 0 + self.assertEqual(state, [1]) class FileContextTestCase(unittest.TestCase): @@ -272,20 +255,14 @@ f.write("Booh\n") self.assertTrue(f.closed) f = None - try: + with self.assertRaises(ZeroDivisionError): with open(tfn, "r") as f: self.assertFalse(f.closed) self.assertEqual(f.read(), "Booh\n") - 1/0 - except ZeroDivisionError: - self.assertTrue(f.closed) - else: - self.fail("Didn't raise ZeroDivisionError") + 1 // 0 + self.assertTrue(f.closed) finally: - try: - os.remove(tfn) - except os.error: - pass + test_support.unlink(tfn) class LockContextTestCase(unittest.TestCase): @@ -294,14 +271,11 @@ with lock: self.assertTrue(locked()) self.assertFalse(locked()) - try: + with self.assertRaises(ZeroDivisionError): with lock: self.assertTrue(locked()) - 1/0 - except ZeroDivisionError: - self.assertFalse(locked()) - else: - self.fail("Didn't raise ZeroDivisionError") + 1 // 0 + self.assertFalse(locked()) def testWithLock(self): lock = threading.Lock() @@ -339,8 +313,9 @@ # This is needed to make the test actually run under regrtest.py! def test_main(): - with warnings.catch_warnings(): - warnings.simplefilter('ignore') + with test_support.check_warnings(("With-statements now directly support " + "multiple context managers", + DeprecationWarning)): test_support.run_unittest(__name__) if __name__ == "__main__": Modified: python/trunk/Lib/test/test_cookie.py ============================================================================== --- python/trunk/Lib/test/test_cookie.py (original) +++ python/trunk/Lib/test/test_cookie.py Thu Apr 1 00:01:03 2010 @@ -1,13 +1,9 @@ # Simple test suite for Cookie.py -from test.test_support import run_unittest, run_doctest +from test.test_support import run_unittest, run_doctest, check_warnings import unittest import Cookie -import warnings -warnings.filterwarnings("ignore", - ".* class is insecure.*", - DeprecationWarning) class CookieTests(unittest.TestCase): # Currently this only tests SimpleCookie @@ -76,7 +72,9 @@ def test_main(): run_unittest(CookieTests) - run_doctest(Cookie) + with check_warnings(('.+Cookie class is insecure; do not use it', + DeprecationWarning)): + run_doctest(Cookie) if __name__ == '__main__': test_main() Modified: python/trunk/Lib/test/test_descr.py ============================================================================== --- python/trunk/Lib/test/test_descr.py (original) +++ python/trunk/Lib/test/test_descr.py Thu Apr 1 00:01:03 2010 @@ -2,7 +2,6 @@ import sys import types import unittest -import warnings from copy import deepcopy from test import test_support @@ -59,15 +58,6 @@ expr = '%s a' % expr self.unops[name] = expr - def setUp(self): - self.original_filters = warnings.filters[:] - warnings.filterwarnings("ignore", - r'complex divmod\(\), // and % are deprecated$', - DeprecationWarning, r'(|%s)$' % __name__) - - def tearDown(self): - warnings.filters = self.original_filters - def unop_test(self, a, res, expr="len(a)", meth="__len__"): d = {'a': a} self.assertEqual(eval(expr, d), res) @@ -4622,11 +4612,15 @@ def test_main(): - with test_support.check_py3k_warnings( + deprecations = [(r'complex divmod\(\), // and % are deprecated$', + DeprecationWarning)] + if sys.py3kwarning: + deprecations += [ ("classic (int|long) division", DeprecationWarning), ("coerce.. not supported", DeprecationWarning), ("Overriding __cmp__ ", DeprecationWarning), - (".+__(get|set|del)slice__ has been removed", DeprecationWarning)): + (".+__(get|set|del)slice__ has been removed", DeprecationWarning)] + with test_support.check_warnings(*deprecations): # Run all local test cases, with PTypesLongInitTest first. test_support.run_unittest(PTypesLongInitTest, OperatorsTest, ClassPropertiesAndMethods, DictProxyTests) Modified: python/trunk/Lib/test/test_doctest.py ============================================================================== --- python/trunk/Lib/test/test_doctest.py (original) +++ python/trunk/Lib/test/test_doctest.py Thu Apr 1 00:01:03 2010 @@ -3,9 +3,9 @@ Test script for doctest. """ +import sys from test import test_support import doctest -import warnings # NOTE: There are some additional tests relating to interaction with # zipimport in the test_zipimport_support test module. @@ -2458,12 +2458,13 @@ test_support.run_doctest(doctest, verbosity=True) from test import test_doctest - with test_support.check_py3k_warnings( - ("backquote not supported", SyntaxWarning), - ("execfile.. not supported", DeprecationWarning)): - # Ignore all warnings about the use of class Tester in this module. - warnings.filterwarnings("ignore", "class Tester is deprecated", - DeprecationWarning) + + # Ignore all warnings about the use of class Tester in this module. + deprecations = [("class Tester is deprecated", DeprecationWarning)] + if sys.py3kwarning: + deprecations += [("backquote not supported", SyntaxWarning), + ("execfile.. not supported", DeprecationWarning)] + with test_support.check_warnings(*deprecations): # Check the doctest cases defined here: test_support.run_doctest(test_doctest, verbosity=True) Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Thu Apr 1 00:01:03 2010 @@ -4,9 +4,9 @@ import sys import unittest import pickle, cPickle -import warnings -from test.test_support import TESTFN, unlink, run_unittest, captured_output +from test.test_support import (TESTFN, unlink, run_unittest, captured_output, + check_warnings) from test.test_pep352 import ignore_deprecation_warnings # XXX This is not really enough, each *operation* should be tested! @@ -308,24 +308,19 @@ # Accessing BaseException.message and relying on its value set by # BaseException.__init__ triggers a deprecation warning. exc = BaseException("foo") - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter('default') - self.assertEquals(exc.message, "foo") - self.assertEquals(len(w), 1) - self.assertEquals(w[0].category, DeprecationWarning) - self.assertEquals( - str(w[0].message), - "BaseException.message has been deprecated as of Python 2.6") - + with check_warnings(("BaseException.message has been deprecated " + "as of Python 2.6", DeprecationWarning)) as w: + self.assertEqual(exc.message, "foo") + self.assertEqual(len(w.warnings), 1) def testRegularMessageAttribute(self): # Accessing BaseException.message after explicitly setting a value # for it does not trigger a deprecation warning. exc = BaseException("foo") exc.message = "bar" - with warnings.catch_warnings(record=True) as w: - self.assertEquals(exc.message, "bar") - self.assertEquals(len(w), 0) + with check_warnings(quiet=True) as w: + self.assertEqual(exc.message, "bar") + self.assertEqual(len(w.warnings), 0) # Deleting the message is supported, too. del exc.message with self.assertRaises(AttributeError): Modified: python/trunk/Lib/test/test_global.py ============================================================================== --- python/trunk/Lib/test/test_global.py (original) +++ python/trunk/Lib/test/test_global.py Thu Apr 1 00:01:03 2010 @@ -2,9 +2,8 @@ from test.test_support import run_unittest, check_syntax_error import unittest - import warnings -warnings.filterwarnings("error", module="") + class GlobalTests(unittest.TestCase): @@ -45,7 +44,9 @@ def test_main(): - run_unittest(GlobalTests) + with warnings.catch_warnings(): + warnings.filterwarnings("error", module="") + run_unittest(GlobalTests) if __name__ == "__main__": test_main() Modified: python/trunk/Lib/test/test_hmac.py ============================================================================== --- python/trunk/Lib/test/test_hmac.py (original) +++ python/trunk/Lib/test/test_hmac.py Thu Apr 1 00:01:03 2010 @@ -213,19 +213,13 @@ with warnings.catch_warnings(): warnings.simplefilter('error', RuntimeWarning) - try: + with self.assertRaises(RuntimeWarning): hmac.HMAC('a', 'b', digestmod=MockCrazyHash) - except RuntimeWarning: - pass - else: self.fail('Expected warning about missing block_size') MockCrazyHash.block_size = 1 - try: + with self.assertRaises(RuntimeWarning): hmac.HMAC('a', 'b', digestmod=MockCrazyHash) - except RuntimeWarning: - pass - else: self.fail('Expected warning about small block_size') Modified: python/trunk/Lib/test/test_int_literal.py ============================================================================== --- python/trunk/Lib/test/test_int_literal.py (original) +++ python/trunk/Lib/test/test_int_literal.py Thu Apr 1 00:01:03 2010 @@ -6,9 +6,6 @@ import unittest from test import test_support -import warnings -warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning, - "") class TestHexOctBin(unittest.TestCase): Modified: python/trunk/Lib/test/test_io.py ============================================================================== --- python/trunk/Lib/test/test_io.py (original) +++ python/trunk/Lib/test/test_io.py Thu Apr 1 00:01:03 2010 @@ -29,7 +29,6 @@ import threading import random import unittest -import warnings import weakref import abc from itertools import cycle, count Modified: python/trunk/Lib/test/test_macostools.py ============================================================================== --- python/trunk/Lib/test/test_macostools.py (original) +++ python/trunk/Lib/test/test_macostools.py Thu Apr 1 00:01:03 2010 @@ -23,14 +23,8 @@ rfp.close() def tearDown(self): - try: - os.unlink(test_support.TESTFN) - except: - pass - try: - os.unlink(TESTFN2) - except: - pass + test_support.unlink(test_support.TESTFN) + test_support.unlink(TESTFN2) def compareData(self): fp = open(test_support.TESTFN, 'r') @@ -53,36 +47,25 @@ def test_touched(self): # This really only tests that nothing unforeseen happens. - import warnings - with warnings.catch_warnings(): - warnings.filterwarnings('ignore', 'macostools.touched*', - DeprecationWarning) + with test_support.check_warnings(('macostools.touched*', + DeprecationWarning), quiet=True): macostools.touched(test_support.TESTFN) if sys.maxint < 2**32: def test_copy(self): - try: - os.unlink(TESTFN2) - except: - pass + test_support.unlink(TESTFN2) macostools.copy(test_support.TESTFN, TESTFN2) self.assertEqual(self.compareData(), '') if sys.maxint < 2**32: def test_mkalias(self): - try: - os.unlink(TESTFN2) - except: - pass + test_support.unlink(TESTFN2) macostools.mkalias(test_support.TESTFN, TESTFN2) fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) def test_mkalias_relative(self): - try: - os.unlink(TESTFN2) - except: - pass + test_support.unlink(TESTFN2) # If the directory doesn't exist, then chances are this is a new # install of Python so don't create it since the user might end up # running ``sudo make install`` and creating the directory here won't Modified: python/trunk/Lib/test/test_pep352.py ============================================================================== --- python/trunk/Lib/test/test_pep352.py (original) +++ python/trunk/Lib/test/test_pep352.py Thu Apr 1 00:01:03 2010 @@ -2,7 +2,7 @@ import __builtin__ import exceptions import warnings -from test.test_support import run_unittest +from test.test_support import run_unittest, check_warnings import os import sys from platform import system as platform_system @@ -15,14 +15,13 @@ "catching classes that don't inherit from BaseException is not allowed", "__get(item|slice)__ not supported for exception classes"]) +_deprecations = [(msg, DeprecationWarning) for msg in DEPRECATION_WARNINGS] + # Silence Py3k and other deprecation warnings def ignore_deprecation_warnings(func): """Ignore the known DeprecationWarnings.""" def wrapper(*args, **kw): - with warnings.catch_warnings(): - warnings.resetwarnings() - for text in DEPRECATION_WARNINGS: - warnings.filterwarnings("ignore", text, DeprecationWarning) + with check_warnings(*_deprecations, quiet=True): return func(*args, **kw) return wrapper @@ -139,16 +138,8 @@ def test_message_deprecation(self): # As of Python 2.6, BaseException.message is deprecated. - with warnings.catch_warnings(): - warnings.resetwarnings() - warnings.filterwarnings('error') - - try: - BaseException().message - except DeprecationWarning: - pass - else: - self.fail("BaseException.message not deprecated") + with check_warnings(("", DeprecationWarning)): + BaseException().message class UsageTests(unittest.TestCase): @@ -224,28 +215,19 @@ warnings.resetwarnings() warnings.filterwarnings("error") str_exc = "spam" - try: + with self.assertRaises(DeprecationWarning): try: raise StandardError except str_exc: pass - except DeprecationWarning: - pass - except StandardError: - self.fail("catching a string exception did not raise " - "DeprecationWarning") + # Make sure that even if the string exception is listed in a tuple # that a warning is raised. - try: + with self.assertRaises(DeprecationWarning): try: raise StandardError except (AssertionError, str_exc): pass - except DeprecationWarning: - pass - except StandardError: - self.fail("catching a string exception specified in a tuple did " - "not raise DeprecationWarning") def test_main(): Modified: python/trunk/Lib/test/test_re.py ============================================================================== --- python/trunk/Lib/test/test_re.py (original) +++ python/trunk/Lib/test/test_re.py Thu Apr 1 00:01:03 2010 @@ -1,4 +1,4 @@ -from test.test_support import verbose, run_unittest +from test.test_support import verbose, run_unittest, import_module import re from re import Scanner import sys, traceback @@ -447,11 +447,8 @@ import cPickle self.pickle_test(cPickle) # old pickles expect the _compile() reconstructor in sre module - import warnings - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", "The sre module is deprecated", - DeprecationWarning) - from sre import _compile + import_module("sre", deprecated=True) + from sre import _compile def pickle_test(self, pickle): oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)') Modified: python/trunk/Lib/test/test_sundry.py ============================================================================== --- python/trunk/Lib/test/test_sundry.py (original) +++ python/trunk/Lib/test/test_sundry.py Thu Apr 1 00:01:03 2010 @@ -3,13 +3,11 @@ from test import test_support import sys import unittest -import warnings class TestUntestedModules(unittest.TestCase): def test_at_least_import_untested_modules(self): - with warnings.catch_warnings(): - warnings.simplefilter("ignore") + with test_support.check_warnings(quiet=True): import CGIHTTPServer import audiodev import bdb Modified: python/trunk/Lib/test/test_symtable.py ============================================================================== --- python/trunk/Lib/test/test_symtable.py (original) +++ python/trunk/Lib/test/test_symtable.py Thu Apr 1 00:01:03 2010 @@ -3,7 +3,6 @@ """ import symtable import unittest -import warnings from test import test_support @@ -44,9 +43,8 @@ class SymtableTest(unittest.TestCase): - with warnings.catch_warnings(): - # Ignore warnings about "from blank import *" - warnings.simplefilter("ignore", SyntaxWarning) + with test_support.check_warnings( + ("import \* only allowed at module level", SyntaxWarning)): top = symtable.symtable(TEST_CODE, "?", "exec") # These correspond to scopes in TEST_CODE Mine = find_block(top, "Mine") Modified: python/trunk/Lib/test/test_urllibnet.py ============================================================================== --- python/trunk/Lib/test/test_urllibnet.py (original) +++ python/trunk/Lib/test/test_urllibnet.py Thu Apr 1 00:01:03 2010 @@ -182,10 +182,8 @@ def test_main(): test_support.requires('network') - from warnings import filterwarnings, catch_warnings - with catch_warnings(): - filterwarnings('ignore', '.*urllib\.urlopen.*Python 3.0', - DeprecationWarning) + with test_support.check_py3k_warnings( + ("urllib.urlopen.. has been removed", DeprecationWarning)): test_support.run_unittest(URLTimeoutTest, urlopenNetworkTests, urlretrieveNetworkTests) Modified: python/trunk/Lib/test/test_zipimport_support.py ============================================================================== --- python/trunk/Lib/test/test_zipimport_support.py (original) +++ python/trunk/Lib/test/test_zipimport_support.py Thu Apr 1 00:01:03 2010 @@ -168,12 +168,14 @@ test_zipped_doctest.test_unittest_reportflags, ] # Needed for test_DocTestParser and test_debug - with test.test_support.check_py3k_warnings( - ("backquote not supported", SyntaxWarning), - ("execfile.. not supported", DeprecationWarning)): + deprecations = [ # Ignore all warnings about the use of class Tester in this module. - warnings.filterwarnings("ignore", "class Tester is deprecated", - DeprecationWarning) + ("class Tester is deprecated", DeprecationWarning)] + if sys.py3kwarning: + deprecations += [ + ("backquote not supported", SyntaxWarning), + ("execfile.. not supported", DeprecationWarning)] + with test.test_support.check_warnings(*deprecations): for obj in known_good_tests: _run_object_doctest(obj, test_zipped_doctest) From python-checkins at python.org Thu Apr 1 00:18:09 2010 From: python-checkins at python.org (ezio.melotti) Date: Thu, 1 Apr 2010 00:18:09 +0200 (CEST) Subject: [Python-checkins] r79540 - python/trunk/Makefile.pre.in Message-ID: <20100331221809.5AAB7DFE4@mail.python.org> Author: ezio.melotti Date: Thu Apr 1 00:18:09 2010 New Revision: 79540 Log: Add -Wd and -3 to the flags used to run the tests. Modified: python/trunk/Makefile.pre.in Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Thu Apr 1 00:18:09 2010 @@ -683,13 +683,13 @@ # In the past, we've had problems where bugs in the marshalling or # elsewhere caused bytecode read from .pyc files to behave differently # than bytecode generated directly from a .py source file. Sometimes -# the bytecode read from a .pyc file had the bug, somtimes the directly +# the bytecode read from a .pyc file had the bug, sometimes the directly # generated bytecode. This is sometimes a very shy bug needing a lot of # sample data. TESTOPTS= -l $(EXTRATESTOPTS) TESTPROG= $(srcdir)/Lib/test/regrtest.py -TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt +TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt test: all platform -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) From python-checkins at python.org Thu Apr 1 00:43:31 2010 From: python-checkins at python.org (ezio.melotti) Date: Thu, 1 Apr 2010 00:43:31 +0200 (CEST) Subject: [Python-checkins] r79541 - python/trunk/PCbuild/rt.bat Message-ID: <20100331224331.46E37DF1E@mail.python.org> Author: ezio.melotti Date: Thu Apr 1 00:43:31 2010 New Revision: 79541 Log: Add -Wd and -3 to the flags used to run the tests on Windows. Modified: python/trunk/PCbuild/rt.bat Modified: python/trunk/PCbuild/rt.bat ============================================================================== --- python/trunk/PCbuild/rt.bat (original) +++ python/trunk/PCbuild/rt.bat Thu Apr 1 00:43:31 2010 @@ -40,7 +40,7 @@ PATH %PATH%;..\..\%tcltk%\bin set exe=%prefix%\python%suffix% -set cmd=%exe% %dashO% -E -tt ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 +set cmd=%exe% %dashO% -Wd -3 -E -tt ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 if defined qmode goto Qmode echo Deleting .pyc/.pyo files ... From solipsis at pitrou.net Thu Apr 1 01:20:57 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 1 Apr 2010 01:20:57 +0200 (CEST) Subject: [Python-checkins] Daily py3k reference leaks (r79531): sum=0 Message-ID: <20100331232057.2D2131770B@ns6635.ovh.net> py3k results for svn r79531 (hg cset abf8b1bf895a) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogqsiTcd', '-x', 'test_httpservers'] From nnorwitz at gmail.com Thu Apr 1 03:10:17 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 31 Mar 2010 20:10:17 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20100401011017.GA1624@kbk-i386-bb.psfb.org> More important issues: ---------------------- test_bz2 leaked [0, 0, 84] references, sum=84 Less important issues: ---------------------- test_threadsignals leaked [0, 0, -8] references, sum=-8 From python-checkins at python.org Thu Apr 1 03:28:39 2010 From: python-checkins at python.org (r.david.murray) Date: Thu, 1 Apr 2010 03:28:39 +0200 (CEST) Subject: [Python-checkins] r79542 - python/trunk/Doc/library/test.rst Message-ID: <20100401012839.672B5D691@mail.python.org> Author: r.david.murray Date: Thu Apr 1 03:28:39 2010 New Revision: 79542 Log: A couple small grammar fixes in test.rst, and rewrite the check_warnings docs to be clearer. Modified: python/trunk/Doc/library/test.rst Modified: python/trunk/Doc/library/test.rst ============================================================================== --- python/trunk/Doc/library/test.rst (original) +++ python/trunk/Doc/library/test.rst Thu Apr 1 03:28:39 2010 @@ -235,15 +235,15 @@ .. data:: TESTFN - Set to the name that a temporary file could use. Any temporary file that is - created should be closed and unlinked (removed). + Set to a name that is safe to use as the name of a temporary file. Any + temporary file that is created should be closed and unlinked (removed). The :mod:`test.test_support` module defines the following functions: .. function:: forget(module_name) - Remove the module named *module_name* from ``sys.modules`` and deletes any + Remove the module named *module_name* from ``sys.modules`` and delete any byte-compiled files of the module. @@ -286,49 +286,55 @@ This will run all tests defined in the named module. -.. function:: check_warnings(*filters, quiet=None) +.. function:: check_warnings(*filters, quiet=True) - A convenience wrapper for ``warnings.catch_warnings()`` that makes - it easier to test that a warning was correctly raised with a single - assertion. It is approximately equivalent to calling - ``warnings.catch_warnings(record=True)``. - - It accepts 2-tuples ``("message regexp", WarningCategory)`` as positional - arguments. If there's some ``*filters`` defined, or if the optional keyword - argument ``quiet`` is :const:`False`, it checks if the warnings are - effective. If some filter did not catch any warning, the test fails. If some - warnings are not caught, the test fails, too. To disable these checks, set - argument ``quiet`` to :const:`True`. + A convenience wrapper for :func:`warnings.catch_warnings()` that makes it + easier to test that a warning was correctly raised. It is approximately + equivalent to calling ``warnings.catch_warnings(record=True)`` with + :meth:`warnings.simplefilter` set to ``always`` and with the option to + automatically validate the results that are recorded. + + ``check_warnings`` accepts 2-tuples of the form ``("message regexp", + WarningCategory)`` as positional arguments. If one or more *filters* are + provided, or if the optional keyword argument *quiet* is :const:`False`, + it checks to make sure the warnings are as expected: each specified filter + must match at least one of the warnings raised by the enclosed code or the + test fails, and if any warnings are raised that do not match any of the + specified filters the test fails. To disable the first of these checks, + set *quiet* to :const:`True`. - Without argument, it defaults to:: + If no arguments are specified, it defaults to:: check_warnings(("", Warning), quiet=True) - Additionally, on entry to the context manager, a :class:`WarningRecorder` - instance is returned. The underlying warnings list is available via the - recorder object's :attr:`warnings` attribute, while the attributes of the - last raised warning are also accessible directly on the object. If no - warning has been raised, then the latter attributes will all be - :const:`None`. + In this case all warnings are caught and no errors are raised. - A :meth:`reset` method is also provided on the recorder object. This - method simply clears the warnings list. + On entry to the context manager, a :class:`WarningRecorder` instance is + returned. The underlying warnings list from + :func:`~warnings.catch_warnings` is available via the recorder object's + :attr:`warnings` attribute. As a convenience, the attributes of the object + representing the most recent warning can also be accessed directly through + the recorder object (see example below). If no warning has been raised, + then any of the attributes that would otherwise be expected on an object + representing a warning will return :const:`None`. - The context manager may be used like this:: + The recorder object also has a :meth:`reset` method, which clears the + warnings list. - import warnings - - with check_warnings(quiet=False): - exec('assert(False, "Hey!")') - warnings.warn(UserWarning("Hide me!")) + The context manager is designed to be used like this:: with check_warnings(("assertion is always true", SyntaxWarning), ("", UserWarning)): exec('assert(False, "Hey!")') warnings.warn(UserWarning("Hide me!")) + In this case if either warning was not raised, or some other warning was + raised, :func:`check_warnings` would raise an error. + + When a test needs to look more deeply into the warnings, rather than + just checking whether or not they occurred, code like this can be used:: + with check_warnings(quiet=True) as w: - warnings.simplefilter("always") warnings.warn("foo") assert str(w.args[0]) == "foo" warnings.warn("bar") @@ -338,21 +344,23 @@ w.reset() assert len(w.warnings) == 0 + Here all warnings will be caught, and the test code tests the captured + warnings directly. + .. versionadded:: 2.6 .. versionchanged:: 2.7 - New optional attributes ``*filters`` and ``quiet``. + New optional arguments *filters* and *quiet*. .. function:: check_py3k_warnings(*filters, quiet=False) - Same as :func:`check_warnings` but for Python 3 compatibility warnings. + Similar to :func:`check_warnings`, but for Python 3 compatibility warnings. If ``sys.py3kwarning == 1``, it checks if the warning is effectively raised. - If ``sys.py3kwarning == 0``, it checks that no warning is raised. - - It accepts 2-tuples ``("message regexp", WarningCategory)`` as positional - arguments. When the optional keyword argument ``quiet`` is :const:`True`, it - does not fail if a filter catches nothing. Without argument, it defaults - to:: + If ``sys.py3kwarning == 0``, it checks that no warning is raised. It + accepts 2-tuples of the form ``("message regexp", WarningCategory)`` as + positional arguments. When the optional keyword argument *quiet* is + :const:`True`, it does not fail if a filter catches nothing. Without + arguments, it defaults to:: check_py3k_warnings(("", DeprecationWarning), quiet=False) From nnorwitz at gmail.com Thu Apr 1 03:34:05 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 31 Mar 2010 20:34:05 -0500 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20100401013405.GA9002@kbk-i386-bb.psfb.org> 353 tests OK. 1 test failed: test_pydoc 26 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_epoll test_ioctl test_multiprocessing test_tk test_ttk_guionly test_ttk_textonly == CPython 2.7a4+ (trunk:79532M, Mar 31 2010, 16:01:34) [GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] == Linux-2.6.9-gentoo-r1-i686-AMD_Athlon-tm-_XP_3000+-with-gentoo-1.4.16 == /tmp/test_python_1632 test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_argparse test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-1632 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictcomps test_dictviews test_difflib test_dircache test_dis test_distutils [20616 refs] test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [16621 refs] [16621 refs] [16621 refs] [26875 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770. test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os [16621 refs] [16621 refs] test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [18017 refs] [18017 refs] test_plistlib test_poll test_popen [16626 refs] [16626 refs] [16626 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [21735 refs] [21735 refs] [21735 refs] [21735 refs] [21735 refs] [21734 refs] [21734 refs] test test_pydoc failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_pydoc.py", line 251, in test_issue8225 self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") AssertionError: MODULE DOCS incorrectly includes a link Re-running test 'test_pydoc' in verbose mode test_badimport (test.test_pydoc.PyDocDocTest) ... [21735 refs] [21735 refs] [21735 refs] [21735 refs] [21735 refs] ok test_html_doc (test.test_pydoc.PyDocDocTest) ... ok test_input_strip (test.test_pydoc.PyDocDocTest) ... [21734 refs] ok test_issue8225 (test.test_pydoc.PyDocDocTest) ... FAIL test_not_here (test.test_pydoc.PyDocDocTest) ... [21734 refs] ok test_stripid (test.test_pydoc.PyDocDocTest) ... ok test_text_doc (test.test_pydoc.PyDocDocTest) ... ok test_class (test.test_pydoc.TestDescriptions) ... ok test_classic_class (test.test_pydoc.TestDescriptions) ... ok test_module (test.test_pydoc.TestDescriptions) ... ok ====================================================================== FAIL: test_issue8225 (test.test_pydoc.PyDocDocTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_pydoc.py", line 251, in test_issue8225 self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") AssertionError: MODULE DOCS incorrectly includes a link ---------------------------------------------------------------------- Ran 10 tests in 1.617s FAILED (failures=1) test test_pydoc failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_pydoc.py", line 251, in test_issue8225 self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") AssertionError: MODULE DOCS incorrectly includes a link test_pyexpat test_queue test_quopri [19450 refs] [19450 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [16621 refs] [16621 refs] [16621 refs] [16621 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_strtod test_struct test_structmembers test_structseq test_subprocess [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16836 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] . [16621 refs] [16621 refs] this bit of output is from a test of stdout in a different process ... [16621 refs] [16621 refs] [16836 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16836 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] [16621 refs] . [16621 refs] [16621 refs] this bit of output is from a test of stdout in a different process ... [16621 refs] [16621 refs] [16836 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [16621 refs] [16621 refs] [16621 refs] [16850 refs] [16644 refs] test_sysconfig [16621 refs] [16621 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [16621 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [19921 refs] [21994 refs] [20906 refs] [20906 refs] [20906 refs] [20906 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_weakset test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 353 tests OK. 1 test failed: test_pydoc 26 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_epoll test_ioctl test_multiprocessing test_tk test_ttk_guionly test_ttk_textonly [973928 refs] From python-checkins at python.org Thu Apr 1 06:02:00 2010 From: python-checkins at python.org (brian.curtin) Date: Thu, 1 Apr 2010 06:02:00 +0200 (CEST) Subject: [Python-checkins] r79543 - python/trunk/Lib/pydoc.py Message-ID: <20100401040200.87267C57D@mail.python.org> Author: brian.curtin Date: Thu Apr 1 06:02:00 2010 New Revision: 79543 Log: Fix a test_pydoc failure on Neal Norwitz's buildbot. Modified: python/trunk/Lib/pydoc.py Modified: python/trunk/Lib/pydoc.py ============================================================================== --- python/trunk/Lib/pydoc.py (original) +++ python/trunk/Lib/pydoc.py Thu Apr 1 06:02:00 2010 @@ -357,7 +357,7 @@ 'thread', 'zipimport') or (file.startswith(basedir) and not file.startswith(os.path.join(basedir, 'site-packages')))) and - object.__name__ != 'xml.etree'): + object.__name__ not in ('xml.etree', 'test.pydoc_mod')): if docloc.startswith("http://"): docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__) else: From python-checkins at python.org Thu Apr 1 06:03:45 2010 From: python-checkins at python.org (brian.curtin) Date: Thu, 1 Apr 2010 06:03:45 +0200 (CEST) Subject: [Python-checkins] r79544 - in python/branches/release26-maint: Lib/pydoc.py Message-ID: <20100401040345.98C80C771@mail.python.org> Author: brian.curtin Date: Thu Apr 1 06:03:45 2010 New Revision: 79544 Log: Merged revisions 79543 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79543 | brian.curtin | 2010-03-31 23:02:00 -0500 (Wed, 31 Mar 2010) | 2 lines Fix a test_pydoc failure on Neal Norwitz's buildbot. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/pydoc.py Modified: python/branches/release26-maint/Lib/pydoc.py ============================================================================== --- python/branches/release26-maint/Lib/pydoc.py (original) +++ python/branches/release26-maint/Lib/pydoc.py Thu Apr 1 06:03:45 2010 @@ -357,7 +357,7 @@ 'thread', 'zipimport') or (file.startswith(basedir) and not file.startswith(os.path.join(basedir, 'site-packages')))) and - object.__name__ != 'xml.etree'): + object.__name__ not in ('xml.etree', 'test.pydoc_mod')): if docloc.startswith("http://"): docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__) else: From python-checkins at python.org Thu Apr 1 06:05:25 2010 From: python-checkins at python.org (brian.curtin) Date: Thu, 1 Apr 2010 06:05:25 +0200 (CEST) Subject: [Python-checkins] r79545 - in python/branches/py3k: Lib/pydoc.py Message-ID: <20100401040525.DC536DE67@mail.python.org> Author: brian.curtin Date: Thu Apr 1 06:05:25 2010 New Revision: 79545 Log: Merged revisions 79543 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79543 | brian.curtin | 2010-03-31 23:02:00 -0500 (Wed, 31 Mar 2010) | 2 lines Fix a test_pydoc failure on Neal Norwitz's buildbot. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/pydoc.py Modified: python/branches/py3k/Lib/pydoc.py ============================================================================== --- python/branches/py3k/Lib/pydoc.py (original) +++ python/branches/py3k/Lib/pydoc.py Thu Apr 1 06:05:25 2010 @@ -350,7 +350,7 @@ '_thread', 'zipimport') or (file.startswith(basedir) and not file.startswith(os.path.join(basedir, 'site-packages')))) and - object.__name__ != 'xml.etree'): + object.__name__ not in ('xml.etree', 'test.pydoc_mod')): if docloc.startswith("http://"): docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__) else: From python-checkins at python.org Thu Apr 1 06:06:54 2010 From: python-checkins at python.org (brian.curtin) Date: Thu, 1 Apr 2010 06:06:54 +0200 (CEST) Subject: [Python-checkins] r79546 - in python/branches/release31-maint: Lib/pydoc.py Message-ID: <20100401040654.94285DE67@mail.python.org> Author: brian.curtin Date: Thu Apr 1 06:06:54 2010 New Revision: 79546 Log: Merged revisions 79545 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r79545 | brian.curtin | 2010-03-31 23:05:25 -0500 (Wed, 31 Mar 2010) | 9 lines Merged revisions 79543 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79543 | brian.curtin | 2010-03-31 23:02:00 -0500 (Wed, 31 Mar 2010) | 2 lines Fix a test_pydoc failure on Neal Norwitz's buildbot. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/pydoc.py Modified: python/branches/release31-maint/Lib/pydoc.py ============================================================================== --- python/branches/release31-maint/Lib/pydoc.py (original) +++ python/branches/release31-maint/Lib/pydoc.py Thu Apr 1 06:06:54 2010 @@ -350,7 +350,7 @@ '_thread', 'zipimport') or (file.startswith(basedir) and not file.startswith(os.path.join(basedir, 'site-packages')))) and - object.__name__ != 'xml.etree'): + object.__name__ not in ('xml.etree', 'test.pydoc_mod')): if docloc.startswith("http://"): docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__) else: From python-checkins at python.org Thu Apr 1 09:25:27 2010 From: python-checkins at python.org (raymond.hettinger) Date: Thu, 1 Apr 2010 09:25:27 +0200 (CEST) Subject: [Python-checkins] r79547 - python/branches/release26-maint/Doc/library/functions.rst Message-ID: <20100401072527.324D6C79D@mail.python.org> Author: raymond.hettinger Date: Thu Apr 1 09:25:26 2010 New Revision: 79547 Log: Document the link to the HowTo guide. Modified: python/branches/release26-maint/Doc/library/functions.rst Modified: python/branches/release26-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/functions.rst (original) +++ python/branches/release26-maint/Doc/library/functions.rst Thu Apr 1 09:25:26 2010 @@ -1148,6 +1148,9 @@ function, see the `CmpToKey recipe in the ASPN cookbook `_\. + For sorting examples and a brief sorting tutorial, see `Sorting HowTo + `_\. + .. versionadded:: 2.4 From python-checkins at python.org Thu Apr 1 09:40:51 2010 From: python-checkins at python.org (martin.v.loewis) Date: Thu, 1 Apr 2010 09:40:51 +0200 (CEST) Subject: [Python-checkins] r79548 - in python/trunk: .bzrignore .hgignore Lib/test/test_gdb.py Lib/test/test_gdb_sample.py Makefile.pre.in Misc/ACKS Misc/NEWS Tools/README Tools/gdb Tools/gdb/libpython.py Message-ID: <20100401074051.804EDE3B4@mail.python.org> Author: martin.v.loewis Date: Thu Apr 1 09:40:51 2010 New Revision: 79548 Log: Issue #8032: For gdb7, a python-gdb.py file is added to the build, allowing to use advanced gdb features when debugging Python. Added: python/trunk/Lib/test/test_gdb.py (contents, props changed) python/trunk/Lib/test/test_gdb_sample.py (contents, props changed) python/trunk/Tools/gdb/ python/trunk/Tools/gdb/libpython.py (contents, props changed) Modified: python/trunk/ (props changed) python/trunk/.bzrignore python/trunk/.hgignore python/trunk/Makefile.pre.in python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Tools/README Modified: python/trunk/.bzrignore ============================================================================== --- python/trunk/.bzrignore (original) +++ python/trunk/.bzrignore Thu Apr 1 09:40:51 2010 @@ -14,6 +14,7 @@ pyconfig.h libpython*.a python.exe +python-gdb.py reflog.txt tags TAGS Modified: python/trunk/.hgignore ============================================================================== --- python/trunk/.hgignore (original) +++ python/trunk/.hgignore Thu Apr 1 09:40:51 2010 @@ -30,6 +30,7 @@ Modules/config.c Parser/pgen core +python-gdb.py syntax: glob libpython*.a Added: python/trunk/Lib/test/test_gdb.py ============================================================================== --- (empty file) +++ python/trunk/Lib/test/test_gdb.py Thu Apr 1 09:40:51 2010 @@ -0,0 +1,658 @@ +# Verify that gdb can pretty-print the various PyObject* types +# +# The code for testing gdb was adapted from similar work in Unladen Swallow's +# Lib/test/test_jit_gdb.py + +import os +import re +import subprocess +import sys +import unittest + +from test.test_support import run_unittest + +try: + gdb_version, _ = subprocess.Popen(["gdb", "--version"], + stdout=subprocess.PIPE).communicate() +except OSError: + # This is what "no gdb" looks like. There may, however, be other + # errors that manifest this way too. + raise unittest.SkipTest("Couldn't find gdb on the path") +gdb_version_number = re.search(r"^GNU gdb [^\d]*(\d+)\.", gdb_version) +if int(gdb_version_number.group(1)) < 7: + raise unittest.SkipTest("gdb versions before 7.0 didn't support python embedding" + " Saw:\n" + gdb_version) + +# Verify that "gdb" was built with the embedded python support enabled: +cmd = "--eval-command=python import sys; print sys.version_info" +p = subprocess.Popen(["gdb", "--batch", cmd], + stdout=subprocess.PIPE) +gdbpy_version, _ = p.communicate() +if gdbpy_version == '': + raise unittest.SkipTest("gdb not built with embedded python support") + + +class DebuggerTests(unittest.TestCase): + + """Test that the debugger can debug Python.""" + + def run_gdb(self, *args): + """Runs gdb with the command line given by *args. + + Returns its stdout, stderr + """ + out, err = subprocess.Popen( + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + ).communicate() + return out, err + + def get_stack_trace(self, source=None, script=None, + breakpoint='PyObject_Print', + cmds_after_breakpoint=None, + import_site=False): + ''' + Run 'python -c SOURCE' under gdb with a breakpoint. + + Support injecting commands after the breakpoint is reached + + Returns the stdout from gdb + + cmds_after_breakpoint: if provided, a list of strings: gdb commands + ''' + # We use "set breakpoint pending yes" to avoid blocking with a: + # Function "foo" not defined. + # Make breakpoint pending on future shared library load? (y or [n]) + # error, which typically happens python is dynamically linked (the + # breakpoints of interest are to be found in the shared library) + # When this happens, we still get: + # Function "PyObject_Print" not defined. + # emitted to stderr each time, alas. + + # Initially I had "--eval-command=continue" here, but removed it to + # avoid repeated print breakpoints when traversing hierarchical data + # structures + + # Generate a list of commands in gdb's language: + commands = ['set breakpoint pending yes', + 'break %s' % breakpoint, + 'run'] + if cmds_after_breakpoint: + commands += cmds_after_breakpoint + else: + commands += ['backtrace'] + + # print commands + + # Use "commands" to generate the arguments with which to invoke "gdb": + args = ["gdb", "--batch"] + args += ['--eval-command=%s' % cmd for cmd in commands] + args += ["--args", + sys.executable] + + if not import_site: + # -S suppresses the default 'import site' + args += ["-S"] + + if source: + args += ["-c", source] + elif script: + args += [script] + + # print args + # print ' '.join(args) + + # Use "args" to invoke gdb, capturing stdout, stderr: + out, err = self.run_gdb(*args) + + # Ignore some noise on stderr due to the pending breakpoint: + err = err.replace('Function "%s" not defined.\n' % breakpoint, '') + + # Ensure no unexpected error messages: + self.assertEquals(err, '') + + return out + + def get_gdb_repr(self, source, + cmds_after_breakpoint=None, + import_site=False): + # Given an input python source representation of data, + # run "python -c'print DATA'" under gdb with a breakpoint on + # PyObject_Print and scrape out gdb's representation of the "op" + # parameter, and verify that the gdb displays the same string + # + # For a nested structure, the first time we hit the breakpoint will + # give us the top-level structure + gdb_output = self.get_stack_trace(source, breakpoint='PyObject_Print', + cmds_after_breakpoint=cmds_after_breakpoint, + import_site=import_site) + m = re.match('.*#0 PyObject_Print \(op\=(.*?), fp=.*\).*', + gdb_output, re.DOTALL) + #print m.groups() + return m.group(1), gdb_output + + def assertEndsWith(self, actual, exp_end): + '''Ensure that the given "actual" string ends with "exp_end"''' + self.assert_(actual.endswith(exp_end), + msg='%r did not end with %r' % (actual, exp_end)) + + def assertMultilineMatches(self, actual, pattern): + m = re.match(pattern, actual, re.DOTALL) + self.assert_(m, + msg='%r did not match %r' % (actual, pattern)) + +class PrettyPrintTests(DebuggerTests): + def test_getting_backtrace(self): + gdb_output = self.get_stack_trace('print 42') + self.assertTrue('PyObject_Print' in gdb_output) + + def assertGdbRepr(self, val, cmds_after_breakpoint=None): + # Ensure that gdb's rendering of the value in a debugged process + # matches repr(value) in this process: + gdb_repr, gdb_output = self.get_gdb_repr('print ' + repr(val), + cmds_after_breakpoint) + self.assertEquals(gdb_repr, repr(val), gdb_output) + + def test_int(self): + 'Verify the pretty-printing of various "int" values' + self.assertGdbRepr(42) + self.assertGdbRepr(0) + self.assertGdbRepr(-7) + self.assertGdbRepr(sys.maxint) + self.assertGdbRepr(-sys.maxint) + + def test_long(self): + 'Verify the pretty-printing of various "long" values' + self.assertGdbRepr(0L) + self.assertGdbRepr(1000000000000L) + self.assertGdbRepr(-1L) + self.assertGdbRepr(-1000000000000000L) + + def test_singletons(self): + 'Verify the pretty-printing of True, False and None' + self.assertGdbRepr(True) + self.assertGdbRepr(False) + self.assertGdbRepr(None) + + def test_dicts(self): + 'Verify the pretty-printing of dictionaries' + self.assertGdbRepr({}) + self.assertGdbRepr({'foo': 'bar'}) + self.assertGdbRepr({'foo': 'bar', 'douglas':42}) + + def test_lists(self): + 'Verify the pretty-printing of lists' + self.assertGdbRepr([]) + self.assertGdbRepr(range(5)) + + def test_strings(self): + 'Verify the pretty-printing of strings' + self.assertGdbRepr('') + self.assertGdbRepr('And now for something hopefully the same') + self.assertGdbRepr('string with embedded NUL here \0 and then some more text') + self.assertGdbRepr('this is byte 255:\xff and byte 128:\x80') + + def test_tuples(self): + 'Verify the pretty-printing of tuples' + self.assertGdbRepr(tuple()) + self.assertGdbRepr((1,)) + self.assertGdbRepr(('foo', 'bar', 'baz')) + + def test_unicode(self): + 'Verify the pretty-printing of unicode values' + # Test the empty unicode string: + self.assertGdbRepr(u'') + + self.assertGdbRepr(u'hello world') + + # Test printing a single character: + # U+2620 SKULL AND CROSSBONES + self.assertGdbRepr(u'\u2620') + + # Test printing a Japanese unicode string + # (I believe this reads "mojibake", using 3 characters from the CJK + # Unified Ideographs area, followed by U+3051 HIRAGANA LETTER KE) + self.assertGdbRepr(u'\u6587\u5b57\u5316\u3051') + + # Test a character outside the BMP: + # U+1D121 MUSICAL SYMBOL C CLEF + # This is: + # UTF-8: 0xF0 0x9D 0x84 0xA1 + # UTF-16: 0xD834 0xDD21 + try: + # This will only work on wide-unicode builds: + self.assertGdbRepr(unichr(0x1D121)) + except ValueError, e: + if e.message != 'unichr() arg not in range(0x10000) (narrow Python build)': + raise e + + def test_sets(self): + 'Verify the pretty-printing of sets' + self.assertGdbRepr(set()) + self.assertGdbRepr(set(['a', 'b'])) + self.assertGdbRepr(set([4, 5, 6])) + + # Ensure that we handled sets containing the "dummy" key value, + # which happens on deletion: + gdb_repr, gdb_output = self.get_gdb_repr('''s = set(['a','b']) +s.pop() +print s''') + self.assertEquals(gdb_repr, "set(['b'])") + + def test_frozensets(self): + 'Verify the pretty-printing of frozensets' + self.assertGdbRepr(frozenset()) + self.assertGdbRepr(frozenset(['a', 'b'])) + self.assertGdbRepr(frozenset([4, 5, 6])) + + def test_exceptions(self): + # Test a RuntimeError + gdb_repr, gdb_output = self.get_gdb_repr(''' +try: + raise RuntimeError("I am an error") +except RuntimeError, e: + print e +''') + self.assertEquals(gdb_repr, + "exceptions.RuntimeError('I am an error',)") + + + # Test division by zero: + gdb_repr, gdb_output = self.get_gdb_repr(''' +try: + a = 1 / 0 +except ZeroDivisionError, e: + print e +''') + self.assertEquals(gdb_repr, + "exceptions.ZeroDivisionError('integer division or modulo by zero',)") + + def test_classic_class(self): + 'Verify the pretty-printing of classic class instances' + gdb_repr, gdb_output = self.get_gdb_repr(''' +class Foo: + pass +foo = Foo() +foo.an_int = 42 +print foo''') + m = re.match(r'', gdb_repr) + self.assertTrue(m, + msg='Unexpected classic-class rendering %r' % gdb_repr) + + def test_modern_class(self): + 'Verify the pretty-printing of new-style class instances' + gdb_repr, gdb_output = self.get_gdb_repr(''' +class Foo(object): + pass +foo = Foo() +foo.an_int = 42 +print foo''') + m = re.match(r'', gdb_repr) + self.assertTrue(m, + msg='Unexpected new-style class rendering %r' % gdb_repr) + + def test_subclassing_list(self): + 'Verify the pretty-printing of an instance of a list subclass' + gdb_repr, gdb_output = self.get_gdb_repr(''' +class Foo(list): + pass +foo = Foo() +foo += [1, 2, 3] +foo.an_int = 42 +print foo''') + m = re.match(r'', gdb_repr) + self.assertTrue(m, + msg='Unexpected new-style class rendering %r' % gdb_repr) + + def test_subclassing_tuple(self): + 'Verify the pretty-printing of an instance of a tuple subclass' + # This should exercise the negative tp_dictoffset code in the + # new-style class support + gdb_repr, gdb_output = self.get_gdb_repr(''' +class Foo(tuple): + pass +foo = Foo((1, 2, 3)) +foo.an_int = 42 +print foo''') + m = re.match(r'', gdb_repr) + self.assertTrue(m, + msg='Unexpected new-style class rendering %r' % gdb_repr) + + def assertSane(self, source, corruption, exp_type='unknown'): + '''Run Python under gdb, corrupting variables in the inferior process + immediately before taking a backtrace. + + Verify that the variable's representation is the expected failsafe + representation''' + if corruption: + cmds_after_breakpoint=[corruption, 'backtrace'] + else: + cmds_after_breakpoint=['backtrace'] + + gdb_repr, gdb_output = \ + self.get_gdb_repr(source, + cmds_after_breakpoint=cmds_after_breakpoint) + self.assertTrue(re.match('<%s at remote 0x[0-9a-f]+>' % exp_type, + gdb_repr), + 'Unexpected gdb representation: %r\n%s' % \ + (gdb_repr, gdb_output)) + + def test_NULL_ptr(self): + 'Ensure that a NULL PyObject* is handled gracefully' + gdb_repr, gdb_output = ( + self.get_gdb_repr('print 42', + cmds_after_breakpoint=['set variable op=0', + 'backtrace']) + ) + + self.assertEquals(gdb_repr, '0x0') + + def test_NULL_ob_type(self): + 'Ensure that a PyObject* with NULL ob_type is handled gracefully' + self.assertSane('print 42', + 'set op->ob_type=0') + + def test_corrupt_ob_type(self): + 'Ensure that a PyObject* with a corrupt ob_type is handled gracefully' + self.assertSane('print 42', + 'set op->ob_type=0xDEADBEEF') + + def test_corrupt_tp_flags(self): + 'Ensure that a PyObject* with a type with corrupt tp_flags is handled' + self.assertSane('print 42', + 'set op->ob_type->tp_flags=0x0', + exp_type='int') + + def test_corrupt_tp_name(self): + 'Ensure that a PyObject* with a type with corrupt tp_name is handled' + self.assertSane('print 42', + 'set op->ob_type->tp_name=0xDEADBEEF') + + def test_NULL_instance_dict(self): + 'Ensure that a PyInstanceObject with with a NULL in_dict is handled' + self.assertSane(''' +class Foo: + pass +foo = Foo() +foo.an_int = 42 +print foo''', + 'set ((PyInstanceObject*)op)->in_dict = 0', + exp_type='Foo') + + def test_builtins_help(self): + 'Ensure that the new-style class _Helper in site.py can be handled' + # (this was the issue causing tracebacks in + # http://bugs.python.org/issue8032#msg100537 ) + + gdb_repr, gdb_output = self.get_gdb_repr('print __builtins__.help', import_site=True) + m = re.match(r'<_Helper at remote 0x[0-9a-f]+>', gdb_repr) + self.assertTrue(m, + msg='Unexpected rendering %r' % gdb_repr) + + def test_selfreferential_list(self): + '''Ensure that a reference loop involving a list doesn't lead proxyval + into an infinite loop:''' + gdb_repr, gdb_output = \ + self.get_gdb_repr("a = [3, 4, 5] ; a.append(a) ; print a") + + self.assertEquals(gdb_repr, '[3, 4, 5, [...]]') + + gdb_repr, gdb_output = \ + self.get_gdb_repr("a = [3, 4, 5] ; b = [a] ; a.append(b) ; print a") + + self.assertEquals(gdb_repr, '[3, 4, 5, [[...]]]') + + def test_selfreferential_dict(self): + '''Ensure that a reference loop involving a dict doesn't lead proxyval + into an infinite loop:''' + gdb_repr, gdb_output = \ + self.get_gdb_repr("a = {} ; b = {'bar':a} ; a['foo'] = b ; print a") + + self.assertEquals(gdb_repr, "{'foo': {'bar': {...}}}") + + def test_selfreferential_old_style_instance(self): + gdb_repr, gdb_output = \ + self.get_gdb_repr(''' +class Foo: + pass +foo = Foo() +foo.an_attr = foo +print foo''') + self.assertTrue(re.match('\) at remote 0x[0-9a-f]+>', + gdb_repr), + 'Unexpected gdb representation: %r\n%s' % \ + (gdb_repr, gdb_output)) + + def test_selfreferential_new_style_instance(self): + gdb_repr, gdb_output = \ + self.get_gdb_repr(''' +class Foo(object): + pass +foo = Foo() +foo.an_attr = foo +print foo''') + self.assertTrue(re.match('\) at remote 0x[0-9a-f]+>', + gdb_repr), + 'Unexpected gdb representation: %r\n%s' % \ + (gdb_repr, gdb_output)) + + gdb_repr, gdb_output = \ + self.get_gdb_repr(''' +class Foo(object): + pass +a = Foo() +b = Foo() +a.an_attr = b +b.an_attr = a +print a''') + self.assertTrue(re.match('\) at remote 0x[0-9a-f]+>\) at remote 0x[0-9a-f]+>', + gdb_repr), + 'Unexpected gdb representation: %r\n%s' % \ + (gdb_repr, gdb_output)) + + def test_truncation(self): + 'Verify that very long output is truncated' + gdb_repr, gdb_output = self.get_gdb_repr('print range(1000)') + self.assertEquals(gdb_repr, + "\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, " + "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, " + "27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, " + "40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, " + "53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, " + "66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, " + "79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, " + "92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, " + "104, 105, 106, 107, 108, 109, 110, 111, 112, 113, " + "114, 115, 116, 117, 118, 119, 120, 121, 122, 123, " + "124, 125, 126, 127, 128, 129, 130, 131, 132, 133, " + "134, 135, 136, 137, 138, 139, 140, 141, 142, 143, " + "144, 145, 146, 147, 148, 149, 150, 151, 152, 153, " + "154, 155, 156, 157, 158, 159, 160, 161, 162, 163, " + "164, 165, 166, 167, 168, 169, 170, 171, 172, 173, " + "174, 175, 176, 177, 178, 179, 180, 181, 182, 183, " + "184, 185, 186, 187, 188, 189, 190, 191, 192, 193, " + "194, 195, 196, 197, 198, 199, 200, 201, 202, 203, " + "204, 205, 206, 207, 208, 209, 210, 211, 212, 213, " + "214, 215, 216, 217, 218, 219, 220, 221, 222, 223, " + "224, 225, 226...(truncated)") + self.assertEquals(len(gdb_repr), + len('\n ') + 1024 + len('...(truncated)')) + + def test_builtin_function(self): + gdb_repr, gdb_output = self.get_gdb_repr('print len') + self.assertEquals(gdb_repr, '') + + def test_builtin_method(self): + gdb_repr, gdb_output = self.get_gdb_repr('import sys; print sys.stdout.readlines') + self.assertTrue(re.match('', + gdb_repr), + 'Unexpected gdb representation: %r\n%s' % \ + (gdb_repr, gdb_output)) + + def test_frames(self): + gdb_output = self.get_stack_trace(''' +def foo(a, b, c): + pass + +foo(3, 4, 5) +print foo.__code__''', + breakpoint='PyObject_Print', + cmds_after_breakpoint=['print (PyFrameObject*)(((PyCodeObject*)op)->co_zombieframe)'] + ) + for line in gdb_output.splitlines(): + if line.startswith('$1'): + self.assertTrue(re.match(r'\$1 = Frame 0x[0-9a-f]+, for file , line 3, in foo \(\)', + line), + 'Unexpected gdb representation: %r\n%s' % (line, gdb_output)) + return + self.fail('Did not find expected line beginning with $1') + + + +class PyListTests(DebuggerTests): + def assertListing(self, expected, actual): + self.assertEndsWith(actual, expected) + + def test_basic_command(self): + 'Verify that the "py-list" command works' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-list']) + + self.assertListing(''' + 5 + 6 def bar(a, b, c): + 7 baz(a, b, c) + 8 + 9 def baz(*args): + >10 print(42) + 11 + 12 foo(1, 2, 3) +''', + bt) + + def test_one_abs_arg(self): + 'Verify the "py-list" command with one absolute argument' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-list 9']) + + self.assertListing(''' + 9 def baz(*args): + >10 print(42) + 11 + 12 foo(1, 2, 3) +''', + bt) + + def test_two_abs_args(self): + 'Verify the "py-list" command with two absolute arguments' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-list 1,3']) + + self.assertListing(''' + 1 # Sample script for use by test_gdb.py + 2 + 3 def foo(a, b, c): +''', + bt) + +class StackNavigationTests(DebuggerTests): + def test_pyup_command(self): + 'Verify that the "py-up" command works' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-up']) + self.assertMultilineMatches(bt, + r'''^.* +#[0-9]+ Frame 0x[0-9a-f]+, for file Lib/test/test_gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\) + baz\(a, b, c\) +$''') + + def test_down_at_bottom(self): + 'Verify handling of "py-down" at the bottom of the stack' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-down']) + self.assertEndsWith(bt, + 'Unable to find a newer python frame\n') + + def test_up_at_top(self): + 'Verify handling of "py-up" at the top of the stack' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-up'] * 4) + self.assertEndsWith(bt, + 'Unable to find an older python frame\n') + + def test_up_then_down(self): + 'Verify "py-up" followed by "py-down"' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-up', 'py-down']) + self.assertMultilineMatches(bt, + r'''^.* +#[0-9]+ Frame 0x[0-9a-f]+, for file Lib/test/test_gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\) + baz\(a, b, c\) +#[0-9]+ Frame 0x[0-9a-f]+, for file Lib/test/test_gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\) + print\(42\) +$''') + +class PyBtTests(DebuggerTests): + def test_basic_command(self): + 'Verify that the "py-bt" command works' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-bt']) + self.assertMultilineMatches(bt, + r'''^.* +#[0-9]+ Frame 0x[0-9a-f]+, for file Lib/test/test_gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\) + baz\(a, b, c\) +#[0-9]+ Frame 0x[0-9a-f]+, for file Lib/test/test_gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\) + bar\(a, b, c\) +#[0-9]+ Frame 0x[0-9a-f]+, for file Lib/test/test_gdb_sample.py, line 12, in \(\) +foo\(1, 2, 3\) +''') + +class PyPrintTests(DebuggerTests): + def test_basic_command(self): + 'Verify that the "py-print" command works' + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-print args']) + self.assertMultilineMatches(bt, + r".*\nlocal 'args' = \(1, 2, 3\)\n.*") + + def test_print_after_up(self): + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-up', 'py-print c', 'py-print b', 'py-print a']) + self.assertMultilineMatches(bt, + r".*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*") + + def test_printing_global(self): + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-print __name__']) + self.assertMultilineMatches(bt, + r".*\nglobal '__name__' = '__main__'\n.*") + + def test_printing_builtin(self): + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-print len']) + self.assertMultilineMatches(bt, + r".*\nbuiltin 'len' = \n.*") + +class PyLocalsTests(DebuggerTests): + def test_basic_command(self): + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-locals']) + self.assertMultilineMatches(bt, + r".*\nargs = \(1, 2, 3\)\n.*") + + def test_locals_after_up(self): + bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py', + cmds_after_breakpoint=['py-up', 'py-locals']) + self.assertMultilineMatches(bt, + r".*\na = 1\nb = 2\nc = 3\n.*") + +def test_main(): + run_unittest(PrettyPrintTests, + #PyListTests, + #StackNavigationTests, + #PyBtTests, + #PyPrintTests, + #PyLocalsTests + ) + +if __name__ == "__main__": + test_main() Added: python/trunk/Lib/test/test_gdb_sample.py ============================================================================== --- (empty file) +++ python/trunk/Lib/test/test_gdb_sample.py Thu Apr 1 09:40:51 2010 @@ -0,0 +1,12 @@ +# Sample script for use by test_gdb.py + +def foo(a, b, c): + bar(a, b, c) + +def bar(a, b, c): + baz(a, b, c) + +def baz(*args): + print(42) + +foo(1, 2, 3) Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Thu Apr 1 09:40:51 2010 @@ -360,7 +360,7 @@ # Default target all: build_all -build_all: $(BUILDPYTHON) oldsharedmods sharedmods +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks # Compile a binary with gcc profile guided optimization. profile-opt: @@ -433,6 +433,16 @@ libpython$(VERSION).sl: $(LIBRARY_OBJS) $(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST) +# Copy up the gdb python hooks into a position where they can be automatically +# loaded by gdb during Lib/test/test_gdb.py +# +# Distributors are likely to want to install this somewhere else e.g. relative +# to the stripped DWARF data for the shared library. +gdbhooks: $(BUILDPYTHON)-gdb.py + +$(BUILDPYTHON)-gdb.py: Tools/gdb/libpython.py + $(INSTALL_SCRIPT) $< $(BUILDPYTHON)-gdb.py + # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary # minimal framework (not including the Lib directory and such) in the current # directory. @@ -1238,5 +1248,6 @@ .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean .PHONY: smelly funny patchcheck +.PHONY: gdbhooks # IF YOU PUT ANYTHING HERE IT WILL GO AWAY Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Thu Apr 1 09:40:51 2010 @@ -481,6 +481,7 @@ Nick Maclaren Steve Majewski Grzegorz Makarewicz +David Malcolm Ken Manheimer Vladimir Marangozov David Marek Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Apr 1 09:40:51 2010 @@ -155,6 +155,9 @@ Build ----- +- Issue #8032: For gdb7, a python-gdb.py file is added to the build, + allowing to use advanced gdb features when debugging Python. + - Issue #1628484: The Makefile doesn't ignore the CFLAGS environment variable anymore. It also forwards the LDFLAGS settings to the linker when building a shared library. Modified: python/trunk/Tools/README ============================================================================== --- python/trunk/Tools/README (original) +++ python/trunk/Tools/README Thu Apr 1 09:40:51 2010 @@ -20,6 +20,9 @@ freeze Create a stand-alone executable from a Python program. +gdb Python code to be run inside gdb, to make it easier to + debug Python itself (by David Malcolm). + i18n Tools for internationalization. pygettext.py parses Python source code and generates .pot files, and msgfmt.py generates a binary message catalog Added: python/trunk/Tools/gdb/libpython.py ============================================================================== --- (empty file) +++ python/trunk/Tools/gdb/libpython.py Thu Apr 1 09:40:51 2010 @@ -0,0 +1,1392 @@ +#!/usr/bin/python +''' +From gdb 7 onwards, gdb's build can be configured --with-python, allowing gdb +to be extended with Python code e.g. for library-specific data visualizations, +such as for the C++ STL types. Documentation on this API can be seen at: +http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html + + +This python module deals with the case when the process being debugged (the +"inferior process" in gdb parlance) is itself python, or more specifically, +linked against libpython. In this situation, almost every item of data is a +(PyObject*), and having the debugger merely print their addresses is not very +enlightening. + +This module embeds knowledge about the implementation details of libpython so +that we can emit useful visualizations e.g. a string, a list, a dict, a frame +giving file/line information and the state of local variables + +In particular, given a gdb.Value corresponding to a PyObject* in the inferior +process, we can generate a "proxy value" within the gdb process. For example, +given a PyObject* in the inferior process that is in fact a PyListObject* +holding three PyObject* that turn out to be PyStringObject* instances, we can +generate a proxy value within the gdb process that is a list of strings: + ["foo", "bar", "baz"] + +Doing so can be expensive for complicated graphs of objects, and could take +some time, so we also have a "write_repr" method that writes a representation +of the data to a file-like object. This allows us to stop the traversal by +having the file-like object raise an exception if it gets too much data. + +With both "proxyval" and "write_repr" we keep track of the set of all addresses +visited so far in the traversal, to avoid infinite recursion due to cycles in +the graph of object references. + +We try to defer gdb.lookup_type() invocations for python types until as late as +possible: for a dynamically linked python binary, when the process starts in +the debugger, the libpython.so hasn't been dynamically loaded yet, so none of +the type names are known to the debugger + +The module also extends gdb with some python-specific commands. +''' +from __future__ import with_statement +import gdb + +# Look up the gdb.Type for some standard types: +_type_char_ptr = gdb.lookup_type('char').pointer() # char* +_type_unsigned_char_ptr = gdb.lookup_type('unsigned char').pointer() # unsigned char* +_type_void_ptr = gdb.lookup_type('void').pointer() # void* +_type_size_t = gdb.lookup_type('size_t') + +SIZEOF_VOID_P = _type_void_ptr.sizeof + + +Py_TPFLAGS_HEAPTYPE = (1L << 9) + +Py_TPFLAGS_INT_SUBCLASS = (1L << 23) +Py_TPFLAGS_LONG_SUBCLASS = (1L << 24) +Py_TPFLAGS_LIST_SUBCLASS = (1L << 25) +Py_TPFLAGS_TUPLE_SUBCLASS = (1L << 26) +Py_TPFLAGS_STRING_SUBCLASS = (1L << 27) +Py_TPFLAGS_UNICODE_SUBCLASS = (1L << 28) +Py_TPFLAGS_DICT_SUBCLASS = (1L << 29) +Py_TPFLAGS_BASE_EXC_SUBCLASS = (1L << 30) +Py_TPFLAGS_TYPE_SUBCLASS = (1L << 31) + + +MAX_OUTPUT_LEN=1024 + +class NullPyObjectPtr(RuntimeError): + pass + + +def safety_limit(val): + # Given a integer value from the process being debugged, limit it to some + # safety threshold so that arbitrary breakage within said process doesn't + # break the gdb process too much (e.g. sizes of iterations, sizes of lists) + return min(val, 1000) + + +def safe_range(val): + # As per range, but don't trust the value too much: cap it to a safety + # threshold in case the data was corrupted + return xrange(safety_limit(val)) + + +class StringTruncated(RuntimeError): + pass + +class TruncatedStringIO(object): + '''Similar to cStringIO, but can truncate the output by raising a + StringTruncated exception''' + def __init__(self, maxlen=None): + self._val = '' + self.maxlen = maxlen + + def write(self, data): + if self.maxlen: + if len(data) + len(self._val) > self.maxlen: + # Truncation: + self._val += data[0:self.maxlen - len(self._val)] + raise StringTruncated() + + self._val += data + + def getvalue(self): + return self._val + +class PyObjectPtr(object): + """ + Class wrapping a gdb.Value that's a either a (PyObject*) within the + inferior process, or some subclass pointer e.g. (PyStringObject*) + + There will be a subclass for every refined PyObject type that we care + about. + + Note that at every stage the underlying pointer could be NULL, point + to corrupt data, etc; this is the debugger, after all. + """ + _typename = 'PyObject' + + def __init__(self, gdbval, cast_to=None): + if cast_to: + self._gdbval = gdbval.cast(cast_to) + else: + self._gdbval = gdbval + + def field(self, name): + ''' + Get the gdb.Value for the given field within the PyObject, coping with + some python 2 versus python 3 differences. + + Various libpython types are defined using the "PyObject_HEAD" and + "PyObject_VAR_HEAD" macros. + + In Python 2, this these are defined so that "ob_type" and (for a var + object) "ob_size" are fields of the type in question. + + In Python 3, this is defined as an embedded PyVarObject type thus: + PyVarObject ob_base; + so that the "ob_size" field is located insize the "ob_base" field, and + the "ob_type" is most easily accessed by casting back to a (PyObject*). + ''' + if self.is_null(): + raise NullPyObjectPtr(self) + + if name == 'ob_type': + pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type()) + return pyo_ptr.dereference()[name] + + if name == 'ob_size': + try: + # Python 2: + return self._gdbval.dereference()[name] + except RuntimeError: + # Python 3: + return self._gdbval.dereference()['ob_base'][name] + + # General case: look it up inside the object: + return self._gdbval.dereference()[name] + + def pyop_field(self, name): + ''' + Get a PyObjectPtr for the given PyObject* field within this PyObject, + coping with some python 2 versus python 3 differences. + ''' + return PyObjectPtr.from_pyobject_ptr(self.field(name)) + + def write_field_repr(self, name, out, visited): + ''' + Extract the PyObject* field named "name", and write its representation + to file-like object "out" + ''' + field_obj = self.pyop_field(name) + field_obj.write_repr(out, visited) + + def get_truncated_repr(self, maxlen): + ''' + Get a repr-like string for the data, but truncate it at "maxlen" bytes + (ending the object graph traversal as soon as you do) + ''' + out = TruncatedStringIO(maxlen) + try: + self.write_repr(out, set()) + except StringTruncated: + # Truncation occurred: + return out.getvalue() + '...(truncated)' + + # No truncation occurred: + return out.getvalue() + + def type(self): + return PyTypeObjectPtr(self.field('ob_type')) + + def is_null(self): + return 0 == long(self._gdbval) + + def is_optimized_out(self): + ''' + Is the value of the underlying PyObject* visible to the debugger? + + This can vary with the precise version of the compiler used to build + Python, and the precise version of gdb. + + See e.g. https://bugzilla.redhat.com/show_bug.cgi?id=556975 with + PyEval_EvalFrameEx's "f" + ''' + return self._gdbval.is_optimized_out + + def safe_tp_name(self): + try: + return self.type().field('tp_name').string() + except NullPyObjectPtr: + # NULL tp_name? + return 'unknown' + except RuntimeError: + # Can't even read the object at all? + return 'unknown' + + def proxyval(self, visited): + ''' + Scrape a value from the inferior process, and try to represent it + within the gdb process, whilst (hopefully) avoiding crashes when + the remote data is corrupt. + + Derived classes will override this. + + For example, a PyIntObject* with ob_ival 42 in the inferior process + should result in an int(42) in this process. + + visited: a set of all gdb.Value pyobject pointers already visited + whilst generating this value (to guard against infinite recursion when + visiting object graphs with loops). Analogous to Py_ReprEnter and + Py_ReprLeave + ''' + + class FakeRepr(object): + """ + Class representing a non-descript PyObject* value in the inferior + process for when we don't have a custom scraper, intended to have + a sane repr(). + """ + + def __init__(self, tp_name, address): + self.tp_name = tp_name + self.address = address + + def __repr__(self): + # For the NULL pointer, we have no way of knowing a type, so + # special-case it as per + # http://bugs.python.org/issue8032#msg100882 + if self.address == 0: + return '0x0' + return '<%s at remote 0x%x>' % (self.tp_name, self.address) + + return FakeRepr(self.safe_tp_name(), + long(self._gdbval)) + + def write_repr(self, out, visited): + ''' + Write a string representation of the value scraped from the inferior + process to "out", a file-like object. + ''' + # Default implementation: generate a proxy value and write its repr + # However, this could involve a lot of work for complicated objects, + # so for derived classes we specialize this + return out.write(repr(self.proxyval(visited))) + + @classmethod + def subclass_from_type(cls, t): + ''' + Given a PyTypeObjectPtr instance wrapping a gdb.Value that's a + (PyTypeObject*), determine the corresponding subclass of PyObjectPtr + to use + + Ideally, we would look up the symbols for the global types, but that + isn't working yet: + (gdb) python print gdb.lookup_symbol('PyList_Type')[0].value + Traceback (most recent call last): + File "", line 1, in + NotImplementedError: Symbol type not yet supported in Python scripts. + Error while executing Python code. + + For now, we use tp_flags, after doing some string comparisons on the + tp_name for some special-cases that don't seem to be visible through + flags + ''' + try: + tp_name = t.field('tp_name').string() + tp_flags = int(t.field('tp_flags')) + except RuntimeError: + # Handle any kind of error e.g. NULL ptrs by simply using the base + # class + return cls + + #print 'tp_flags = 0x%08x' % tp_flags + #print 'tp_name = %r' % tp_name + + name_map = {'bool': PyBoolObjectPtr, + 'classobj': PyClassObjectPtr, + 'instance': PyInstanceObjectPtr, + 'NoneType': PyNoneStructPtr, + 'frame': PyFrameObjectPtr, + 'set' : PySetObjectPtr, + 'frozenset' : PySetObjectPtr, + 'builtin_function_or_method' : PyCFunctionObjectPtr, + } + if tp_name in name_map: + return name_map[tp_name] + + if tp_flags & Py_TPFLAGS_HEAPTYPE: + return HeapTypeObjectPtr + + if tp_flags & Py_TPFLAGS_INT_SUBCLASS: + return PyIntObjectPtr + if tp_flags & Py_TPFLAGS_LONG_SUBCLASS: + return PyLongObjectPtr + if tp_flags & Py_TPFLAGS_LIST_SUBCLASS: + return PyListObjectPtr + if tp_flags & Py_TPFLAGS_TUPLE_SUBCLASS: + return PyTupleObjectPtr + if tp_flags & Py_TPFLAGS_STRING_SUBCLASS: + return PyStringObjectPtr + if tp_flags & Py_TPFLAGS_UNICODE_SUBCLASS: + return PyUnicodeObjectPtr + if tp_flags & Py_TPFLAGS_DICT_SUBCLASS: + return PyDictObjectPtr + if tp_flags & Py_TPFLAGS_BASE_EXC_SUBCLASS: + return PyBaseExceptionObjectPtr + #if tp_flags & Py_TPFLAGS_TYPE_SUBCLASS: + # return PyTypeObjectPtr + + # Use the base class: + return cls + + @classmethod + def from_pyobject_ptr(cls, gdbval): + ''' + Try to locate the appropriate derived class dynamically, and cast + the pointer accordingly. + ''' + try: + p = PyObjectPtr(gdbval) + cls = cls.subclass_from_type(p.type()) + return cls(gdbval, cast_to=cls.get_gdb_type()) + except RuntimeError: + # Handle any kind of error e.g. NULL ptrs by simply using the base + # class + pass + return cls(gdbval) + + @classmethod + def get_gdb_type(cls): + return gdb.lookup_type(cls._typename).pointer() + + def as_address(self): + return long(self._gdbval) + + +class ProxyAlreadyVisited(object): + ''' + Placeholder proxy to use when protecting against infinite recursion due to + loops in the object graph. + + Analogous to the values emitted by the users of Py_ReprEnter and Py_ReprLeave + ''' + def __init__(self, rep): + self._rep = rep + + def __repr__(self): + return self._rep + + +def _write_instance_repr(out, visited, name, pyop_attrdict, address): + '''Shared code for use by old-style and new-style classes: + write a representation to file-like object "out"''' + out.write('<') + out.write(name) + + # Write dictionary of instance attributes: + if isinstance(pyop_attrdict, PyDictObjectPtr): + out.write('(') + first = True + for pyop_arg, pyop_val in pyop_attrdict.iteritems(): + if not first: + out.write(', ') + first = False + out.write(pyop_arg.proxyval(visited)) + out.write('=') + pyop_val.write_repr(out, visited) + out.write(')') + out.write(' at remote 0x%x>' % address) + + +class InstanceProxy(object): + + def __init__(self, cl_name, attrdict, address): + self.cl_name = cl_name + self.attrdict = attrdict + self.address = address + + def __repr__(self): + if isinstance(self.attrdict, dict): + kwargs = ', '.join(["%s=%r" % (arg, val) + for arg, val in self.attrdict.iteritems()]) + return '<%s(%s) at remote 0x%x>' % (self.cl_name, + kwargs, self.address) + else: + return '<%s at remote 0x%x>' % (self.cl_name, + self.address) + +def _PyObject_VAR_SIZE(typeobj, nitems): + return ( ( typeobj.field('tp_basicsize') + + nitems * typeobj.field('tp_itemsize') + + (SIZEOF_VOID_P - 1) + ) & ~(SIZEOF_VOID_P - 1) + ).cast(_type_size_t) + +class HeapTypeObjectPtr(PyObjectPtr): + _typename = 'PyObject' + + def get_attr_dict(self): + ''' + Get the PyDictObject ptr representing the attribute dictionary + (or None if there's a problem) + ''' + try: + typeobj = self.type() + dictoffset = int_from_int(typeobj.field('tp_dictoffset')) + if dictoffset != 0: + if dictoffset < 0: + type_PyVarObject_ptr = gdb.lookup_type('PyVarObject').pointer() + tsize = int_from_int(self._gdbval.cast(type_PyVarObject_ptr)['ob_size']) + if tsize < 0: + tsize = -tsize + size = _PyObject_VAR_SIZE(typeobj, tsize) + dictoffset += size + assert dictoffset > 0 + assert dictoffset % SIZEOF_VOID_P == 0 + + dictptr = self._gdbval.cast(_type_char_ptr) + dictoffset + PyObjectPtrPtr = PyObjectPtr.get_gdb_type().pointer() + dictptr = dictptr.cast(PyObjectPtrPtr) + return PyObjectPtr.from_pyobject_ptr(dictptr.dereference()) + except RuntimeError: + # Corrupt data somewhere; fail safe + pass + + # Not found, or some kind of error: + return None + + def proxyval(self, visited): + ''' + Support for new-style classes. + + Currently we just locate the dictionary using a transliteration to + python of _PyObject_GetDictPtr, ignoring descriptors + ''' + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('<...>') + visited.add(self.as_address()) + + pyop_attr_dict = self.get_attr_dict() + if pyop_attr_dict: + attr_dict = pyop_attr_dict.proxyval(visited) + else: + attr_dict = {} + tp_name = self.safe_tp_name() + + # New-style class: + return InstanceProxy(tp_name, attr_dict, long(self._gdbval)) + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('<...>') + return + visited.add(self.as_address()) + + pyop_attrdict = self.get_attr_dict() + _write_instance_repr(out, visited, + self.safe_tp_name(), pyop_attrdict, self.as_address()) + +class ProxyException(Exception): + def __init__(self, tp_name, args): + self.tp_name = tp_name + self.args = args + + def __repr__(self): + return '%s%r' % (self.tp_name, self.args) + +class PyBaseExceptionObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyBaseExceptionObject* i.e. an exception + within the process being debugged. + """ + _typename = 'PyBaseExceptionObject' + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('(...)') + visited.add(self.as_address()) + arg_proxy = self.pyop_field('args').proxyval(visited) + return ProxyException(self.safe_tp_name(), + arg_proxy) + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('(...)') + return + visited.add(self.as_address()) + + out.write(self.safe_tp_name()) + self.write_field_repr('args', out, visited) + +class PyBoolObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyBoolObject* i.e. one of the two + instances (Py_True/Py_False) within the process being debugged. + """ + _typename = 'PyBoolObject' + + def proxyval(self, visited): + if int_from_int(self.field('ob_ival')): + return True + else: + return False + + +class PyClassObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyClassObject* i.e. a + instance within the process being debugged. + """ + _typename = 'PyClassObject' + + +class BuiltInFunctionProxy(object): + def __init__(self, ml_name): + self.ml_name = ml_name + + def __repr__(self): + return "" % self.ml_name + +class BuiltInMethodProxy(object): + def __init__(self, ml_name, pyop_m_self): + self.ml_name = ml_name + self.pyop_m_self = pyop_m_self + + def __repr__(self): + return ('' + % (self.ml_name, + self.pyop_m_self.safe_tp_name(), + self.pyop_m_self.as_address()) + ) + +class PyCFunctionObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyCFunctionObject* + (see Include/methodobject.h and Objects/methodobject.c) + """ + _typename = 'PyCFunctionObject' + + def proxyval(self, visited): + m_ml = self.field('m_ml') # m_ml is a (PyMethodDef*) + ml_name = m_ml['ml_name'].string() + + pyop_m_self = self.pyop_field('m_self') + if pyop_m_self.is_null(): + return BuiltInFunctionProxy(ml_name) + else: + return BuiltInMethodProxy(ml_name, pyop_m_self) + + +class PyCodeObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyCodeObject* i.e. a instance + within the process being debugged. + """ + _typename = 'PyCodeObject' + + def addr2line(self, addrq): + ''' + Get the line number for a given bytecode offset + + Analogous to PyCode_Addr2Line; translated from pseudocode in + Objects/lnotab_notes.txt + ''' + co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) + + # Initialize lineno to co_firstlineno as per PyCode_Addr2Line + # not 0, as lnotab_notes.txt has it: + lineno = int_from_int(self.field('co_firstlineno')) + + addr = 0 + for addr_incr, line_incr in zip(co_lnotab[::2], co_lnotab[1::2]): + addr += ord(addr_incr) + if addr > addrq: + return lineno + lineno += ord(line_incr) + return lineno + + +class PyDictObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyDictObject* i.e. a dict instance + within the process being debugged. + """ + _typename = 'PyDictObject' + + def iteritems(self): + ''' + Yields a sequence of (PyObjectPtr key, PyObjectPtr value) pairs, + analagous to dict.iteritems() + ''' + for i in safe_range(self.field('ma_mask') + 1): + ep = self.field('ma_table') + i + pyop_value = PyObjectPtr.from_pyobject_ptr(ep['me_value']) + if not pyop_value.is_null(): + pyop_key = PyObjectPtr.from_pyobject_ptr(ep['me_key']) + yield (pyop_key, pyop_value) + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('{...}') + visited.add(self.as_address()) + + result = {} + for pyop_key, pyop_value in self.iteritems(): + proxy_key = pyop_key.proxyval(visited) + proxy_value = pyop_value.proxyval(visited) + result[proxy_key] = proxy_value + return result + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('{...}') + return + visited.add(self.as_address()) + + out.write('{') + first = True + for pyop_key, pyop_value in self.iteritems(): + if not first: + out.write(', ') + first = False + pyop_key.write_repr(out, visited) + out.write(': ') + pyop_value.write_repr(out, visited) + out.write('}') + +class PyInstanceObjectPtr(PyObjectPtr): + _typename = 'PyInstanceObject' + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('<...>') + visited.add(self.as_address()) + + # Get name of class: + in_class = self.pyop_field('in_class') + cl_name = in_class.pyop_field('cl_name').proxyval(visited) + + # Get dictionary of instance attributes: + in_dict = self.pyop_field('in_dict').proxyval(visited) + + # Old-style class: + return InstanceProxy(cl_name, in_dict, long(self._gdbval)) + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('<...>') + return + visited.add(self.as_address()) + + # Old-style class: + + # Get name of class: + in_class = self.pyop_field('in_class') + cl_name = in_class.pyop_field('cl_name').proxyval(visited) + + # Get dictionary of instance attributes: + pyop_in_dict = self.pyop_field('in_dict') + + _write_instance_repr(out, visited, + cl_name, pyop_in_dict, self.as_address()) + +class PyIntObjectPtr(PyObjectPtr): + _typename = 'PyIntObject' + + def proxyval(self, visited): + result = int_from_int(self.field('ob_ival')) + return result + +class PyListObjectPtr(PyObjectPtr): + _typename = 'PyListObject' + + def __getitem__(self, i): + # Get the gdb.Value for the (PyObject*) with the given index: + field_ob_item = self.field('ob_item') + return field_ob_item[i] + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('[...]') + visited.add(self.as_address()) + + result = [PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited) + for i in safe_range(int_from_int(self.field('ob_size')))] + return result + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('[...]') + return + visited.add(self.as_address()) + + out.write('[') + for i in safe_range(int_from_int(self.field('ob_size'))): + if i > 0: + out.write(', ') + element = PyObjectPtr.from_pyobject_ptr(self[i]) + element.write_repr(out, visited) + out.write(']') + +class PyLongObjectPtr(PyObjectPtr): + _typename = 'PyLongObject' + + def proxyval(self, visited): + ''' + Python's Include/longobjrep.h has this declaration: + struct _longobject { + PyObject_VAR_HEAD + digit ob_digit[1]; + }; + + with this description: + The absolute value of a number is equal to + SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) + Negative numbers are represented with ob_size < 0; + zero is represented by ob_size == 0. + + where SHIFT can be either: + #define PyLong_SHIFT 30 + #define PyLong_SHIFT 15 + ''' + ob_size = long(self.field('ob_size')) + if ob_size == 0: + return 0L + + ob_digit = self.field('ob_digit') + + if gdb.lookup_type('digit').sizeof == 2: + SHIFT = 15L + else: + SHIFT = 30L + + digits = [long(ob_digit[i]) * 2**(SHIFT*i) + for i in safe_range(abs(ob_size))] + result = sum(digits) + if ob_size < 0: + result = -result + return result + + +class PyNoneStructPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyObject* pointing to the + singleton (we hope) _Py_NoneStruct with ob_type PyNone_Type + """ + _typename = 'PyObject' + + def proxyval(self, visited): + return None + + +class PyFrameObjectPtr(PyObjectPtr): + _typename = 'PyFrameObject' + + def __init__(self, gdbval, cast_to): + PyObjectPtr.__init__(self, gdbval, cast_to) + + if not self.is_optimized_out(): + self.co = PyCodeObjectPtr.from_pyobject_ptr(self.field('f_code')) + self.co_name = self.co.pyop_field('co_name') + self.co_filename = self.co.pyop_field('co_filename') + + self.f_lineno = int_from_int(self.field('f_lineno')) + self.f_lasti = int_from_int(self.field('f_lasti')) + self.co_nlocals = int_from_int(self.co.field('co_nlocals')) + self.co_varnames = PyTupleObjectPtr.from_pyobject_ptr(self.co.field('co_varnames')) + + def iter_locals(self): + ''' + Yield a sequence of (name,value) pairs of PyObjectPtr instances, for + the local variables of this frame + ''' + if self.is_optimized_out(): + return + + f_localsplus = self.field('f_localsplus') + for i in safe_range(self.co_nlocals): + pyop_value = PyObjectPtr.from_pyobject_ptr(f_localsplus[i]) + if not pyop_value.is_null(): + pyop_name = PyObjectPtr.from_pyobject_ptr(self.co_varnames[i]) + yield (pyop_name, pyop_value) + + def iter_globals(self): + ''' + Yield a sequence of (name,value) pairs of PyObjectPtr instances, for + the global variables of this frame + ''' + if self.is_optimized_out(): + return + + pyop_globals = self.pyop_field('f_globals') + return pyop_globals.iteritems() + + def iter_builtins(self): + ''' + Yield a sequence of (name,value) pairs of PyObjectPtr instances, for + the builtin variables + ''' + if self.is_optimized_out(): + return + + pyop_builtins = self.pyop_field('f_builtins') + return pyop_builtins.iteritems() + + def get_var_by_name(self, name): + ''' + Look for the named local variable, returning a (PyObjectPtr, scope) pair + where scope is a string 'local', 'global', 'builtin' + + If not found, return (None, None) + ''' + for pyop_name, pyop_value in self.iter_locals(): + if name == pyop_name.proxyval(set()): + return pyop_value, 'local' + for pyop_name, pyop_value in self.iter_globals(): + if name == pyop_name.proxyval(set()): + return pyop_value, 'global' + for pyop_name, pyop_value in self.iter_builtins(): + if name == pyop_name.proxyval(set()): + return pyop_value, 'builtin' + return None, None + + def filename(self): + '''Get the path of the current Python source file, as a string''' + if self.is_optimized_out(): + return '(frame information optimized out)' + return self.co_filename.proxyval(set()) + + def current_line_num(self): + '''Get current line number as an integer (1-based) + + Translated from PyFrame_GetLineNumber and PyCode_Addr2Line + + See Objects/lnotab_notes.txt + ''' + if self.is_optimized_out(): + return None + f_trace = self.field('f_trace') + if long(f_trace) != 0: + # we have a non-NULL f_trace: + return self.f_lineno + else: + #try: + return self.co.addr2line(self.f_lasti) + #except ValueError: + # return self.f_lineno + + def current_line(self): + '''Get the text of the current source line as a string, with a trailing + newline character''' + if self.is_optimized_out(): + return '(frame information optimized out)' + with open(self.filename(), 'r') as f: + all_lines = f.readlines() + # Convert from 1-based current_line_num to 0-based list offset: + return all_lines[self.current_line_num()-1] + + def write_repr(self, out, visited): + if self.is_optimized_out(): + out.write('(frame information optimized out)') + return + out.write('Frame 0x%x, for file %s, line %i, in %s (' + % (self.as_address(), + self.co_filename, + self.current_line_num(), + self.co_name)) + first = True + for pyop_name, pyop_value in self.iter_locals(): + if not first: + out.write(', ') + first = False + + out.write(pyop_name.proxyval(visited)) + out.write('=') + pyop_value.write_repr(out, visited) + + out.write(')') + +class PySetObjectPtr(PyObjectPtr): + _typename = 'PySetObject' + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('%s(...)' % self.safe_tp_name()) + visited.add(self.as_address()) + + members = [] + table = self.field('table') + for i in safe_range(self.field('mask')+1): + setentry = table[i] + key = setentry['key'] + if key != 0: + key_proxy = PyObjectPtr.from_pyobject_ptr(key).proxyval(visited) + if key_proxy != '': + members.append(key_proxy) + if self.safe_tp_name() == 'frozenset': + return frozenset(members) + else: + return set(members) + + def write_repr(self, out, visited): + out.write(self.safe_tp_name()) + + # Guard against infinite loops: + if self.as_address() in visited: + out.write('(...)') + return + visited.add(self.as_address()) + + out.write('([') + first = True + table = self.field('table') + for i in safe_range(self.field('mask')+1): + setentry = table[i] + key = setentry['key'] + if key != 0: + pyop_key = PyObjectPtr.from_pyobject_ptr(key) + key_proxy = pyop_key.proxyval(visited) # FIXME! + if key_proxy != '': + if not first: + out.write(', ') + first = False + pyop_key.write_repr(out, visited) + out.write('])') + + +class PyStringObjectPtr(PyObjectPtr): + _typename = 'PyStringObject' + + def __str__(self): + field_ob_size = self.field('ob_size') + field_ob_sval = self.field('ob_sval') + char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr) + return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)]) + + def proxyval(self, visited): + return str(self) + +class PyTupleObjectPtr(PyObjectPtr): + _typename = 'PyTupleObject' + + def __getitem__(self, i): + # Get the gdb.Value for the (PyObject*) with the given index: + field_ob_item = self.field('ob_item') + return field_ob_item[i] + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('(...)') + visited.add(self.as_address()) + + result = tuple([PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited) + for i in safe_range(int_from_int(self.field('ob_size')))]) + return result + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('(...)') + return + visited.add(self.as_address()) + + out.write('(') + for i in safe_range(int_from_int(self.field('ob_size'))): + if i > 0: + out.write(', ') + element = PyObjectPtr.from_pyobject_ptr(self[i]) + element.write_repr(out, visited) + if self.field('ob_size') == 1: + out.write(',)') + else: + out.write(')') + +class PyTypeObjectPtr(PyObjectPtr): + _typename = 'PyTypeObject' + + +class PyUnicodeObjectPtr(PyObjectPtr): + _typename = 'PyUnicodeObject' + + def proxyval(self, visited): + # From unicodeobject.h: + # Py_ssize_t length; /* Length of raw Unicode data in buffer */ + # Py_UNICODE *str; /* Raw Unicode buffer */ + field_length = long(self.field('length')) + field_str = self.field('str') + + # Gather a list of ints from the Py_UNICODE array; these are either + # UCS-2 or UCS-4 code points: + Py_UNICODEs = [int(field_str[i]) for i in safe_range(field_length)] + + # Convert the int code points to unicode characters, and generate a + # local unicode instance: + result = u''.join([unichr(ucs) for ucs in Py_UNICODEs]) + return result + + +def int_from_int(gdbval): + return int(str(gdbval)) + + +def stringify(val): + # TODO: repr() puts everything on one line; pformat can be nicer, but + # can lead to v.long results; this function isolates the choice + if True: + return repr(val) + else: + from pprint import pformat + return pformat(val) + + +class PyObjectPtrPrinter: + "Prints a (PyObject*)" + + def __init__ (self, gdbval): + self.gdbval = gdbval + + def to_string (self): + pyop = PyObjectPtr.from_pyobject_ptr(self.gdbval) + if True: + return pyop.get_truncated_repr(MAX_OUTPUT_LEN) + else: + # Generate full proxy value then stringify it. + # Doing so could be expensive + proxyval = pyop.proxyval(set()) + return stringify(proxyval) + +def pretty_printer_lookup(gdbval): + type = gdbval.type.unqualified() + if type.code == gdb.TYPE_CODE_PTR: + type = type.target().unqualified() + t = str(type) + if t in ("PyObject", "PyFrameObject"): + return PyObjectPtrPrinter(gdbval) + +""" +During development, I've been manually invoking the code in this way: +(gdb) python + +import sys +sys.path.append('/home/david/coding/python-gdb') +import libpython +end + +then reloading it after each edit like this: +(gdb) python reload(libpython) + +The following code should ensure that the prettyprinter is registered +if the code is autoloaded by gdb when visiting libpython.so, provided +that this python file is installed to the same path as the library (or its +.debug file) plus a "-gdb.py" suffix, e.g: + /usr/lib/libpython2.6.so.1.0-gdb.py + /usr/lib/debug/usr/lib/libpython2.6.so.1.0.debug-gdb.py +""" +def register (obj): + if obj == None: + obj = gdb + + # Wire up the pretty-printer + obj.pretty_printers.append(pretty_printer_lookup) + +register (gdb.current_objfile ()) + + +class Frame(object): + ''' + Wrapper for gdb.Frame, adding various methods + ''' + def __init__(self, gdbframe): + self._gdbframe = gdbframe + + def older(self): + older = self._gdbframe.older() + if older: + return Frame(older) + else: + return None + + def newer(self): + newer = self._gdbframe.newer() + if newer: + return Frame(newer) + else: + return None + + def select(self): + self._gdbframe.select() + + def get_index(self): + '''Calculate index of frame, starting at 0 for the newest frame within + this thread''' + index = 0 + # Go down until you reach the newest frame: + iter_frame = self + while iter_frame.newer(): + index += 1 + iter_frame = iter_frame.newer() + return index + + def is_evalframeex(self): + if self._gdbframe.function(): + if self._gdbframe.function().name == 'PyEval_EvalFrameEx': + ''' + I believe we also need to filter on the inline + struct frame_id.inline_depth, only regarding frames with + an inline depth of 0 as actually being this function + + So we reject those with type gdb.INLINE_FRAME + ''' + if self._gdbframe.type() == gdb.NORMAL_FRAME: + # We have a PyEval_EvalFrameEx frame: + return True + + return False + + def get_pyop(self): + try: + f = self._gdbframe.read_var('f') + return PyFrameObjectPtr.from_pyobject_ptr(f) + except ValueError: + return None + + @classmethod + def get_selected_frame(cls): + _gdbframe = gdb.selected_frame() + if _gdbframe: + return Frame(_gdbframe) + return None + + @classmethod + def get_selected_python_frame(cls): + '''Try to obtain the Frame for the python code in the selected frame, + or None''' + frame = cls.get_selected_frame() + + while frame: + if frame.is_evalframeex(): + return frame + frame = frame.older() + + # Not found: + return None + + def print_summary(self): + if self.is_evalframeex(): + pyop = self.get_pyop() + if pyop: + sys.stdout.write('#%i %s\n' % (self.get_index(), pyop.get_truncated_repr(MAX_OUTPUT_LEN))) + sys.stdout.write(pyop.current_line()) + else: + sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index()) + else: + sys.stdout.write('#%i\n' % self.get_index()) + +class PyList(gdb.Command): + '''List the current Python source code, if any + + Use + py-list START + to list at a different line number within the python source. + + Use + py-list START, END + to list a specific range of lines within the python source. + ''' + + def __init__(self): + gdb.Command.__init__ (self, + "py-list", + gdb.COMMAND_FILES, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + import re + + start = None + end = None + + m = re.match(r'\s*(\d+)\s*', args) + if m: + start = int(m.group(0)) + end = start + 10 + + m = re.match(r'\s*(\d+)\s*,\s*(\d+)\s*', args) + if m: + start, end = map(int, m.groups()) + + frame = Frame.get_selected_python_frame() + if not frame: + print 'Unable to locate python frame' + return + + pyop = frame.get_pyop() + if not pyop: + print 'Unable to read information on python frame' + return + + filename = pyop.filename() + lineno = pyop.current_line_num() + + if start is None: + start = lineno - 5 + end = lineno + 5 + + if start<1: + start = 1 + + with open(filename, 'r') as f: + all_lines = f.readlines() + # start and end are 1-based, all_lines is 0-based; + # so [start-1:end] as a python slice gives us [start, end] as a + # closed interval + for i, line in enumerate(all_lines[start-1:end]): + linestr = str(i+start) + # Highlight current line: + if i + start == lineno: + linestr = '>' + linestr + sys.stdout.write('%4s %s' % (linestr, line)) + + +# ...and register the command: +PyList() + +def move_in_stack(move_up): + '''Move up or down the stack (for the py-up/py-down command)''' + frame = Frame.get_selected_python_frame() + while frame: + if move_up: + iter_frame = frame.older() + else: + iter_frame = frame.newer() + + if not iter_frame: + break + + if iter_frame.is_evalframeex(): + # Result: + iter_frame.select() + iter_frame.print_summary() + return + + frame = iter_frame + + if move_up: + print 'Unable to find an older python frame' + else: + print 'Unable to find a newer python frame' + +class PyUp(gdb.Command): + 'Select and print the python stack frame that called this one (if any)' + def __init__(self): + gdb.Command.__init__ (self, + "py-up", + gdb.COMMAND_STACK, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + move_in_stack(move_up=True) + +PyUp() + +class PyDown(gdb.Command): + 'Select and print the python stack frame called by this one (if any)' + def __init__(self): + gdb.Command.__init__ (self, + "py-down", + gdb.COMMAND_STACK, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + move_in_stack(move_up=False) + +PyDown() + +class PyBacktrace(gdb.Command): + 'Display the current python frame and all the frames within its call stack (if any)' + def __init__(self): + gdb.Command.__init__ (self, + "py-bt", + gdb.COMMAND_STACK, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + frame = Frame.get_selected_python_frame() + while frame: + if frame.is_evalframeex(): + frame.print_summary() + frame = frame.older() + +PyBacktrace() + +class PyPrint(gdb.Command): + 'Look up the given python variable name, and print it' + def __init__(self): + gdb.Command.__init__ (self, + "py-print", + gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + name = str(args) + + frame = Frame.get_selected_python_frame() + if not frame: + print 'Unable to locate python frame' + return + + pyop_frame = frame.get_pyop() + if not pyop_frame: + print 'Unable to read information on python frame' + return + + pyop_var, scope = pyop_frame.get_var_by_name(name) + + if pyop_var: + print ('%s %r = %s' + % (scope, + name, + pyop_var.get_truncated_repr(MAX_OUTPUT_LEN))) + else: + print '%r not found' % name + +PyPrint() + +class PyLocals(gdb.Command): + 'Look up the given python variable name, and print it' + def __init__(self): + gdb.Command.__init__ (self, + "py-locals", + gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + name = str(args) + + frame = Frame.get_selected_python_frame() + if not frame: + print 'Unable to locate python frame' + return + + pyop_frame = frame.get_pyop() + if not pyop_frame: + print 'Unable to read information on python frame' + return + + for pyop_name, pyop_value in pyop_frame.iter_locals(): + print ('%s = %s' + % (pyop_name.proxyval(set()), + pyop_value.get_truncated_repr(MAX_OUTPUT_LEN))) + +PyLocals() From python-checkins at python.org Thu Apr 1 09:54:16 2010 From: python-checkins at python.org (raymond.hettinger) Date: Thu, 1 Apr 2010 09:54:16 +0200 (CEST) Subject: [Python-checkins] r79549 - python/trunk/Doc/library/functions.rst Message-ID: <20100401075416.51538E5E1@mail.python.org> Author: raymond.hettinger Date: Thu Apr 1 09:54:16 2010 New Revision: 79549 Log: Document link to Sorting HowTo Modified: python/trunk/Doc/library/functions.rst Modified: python/trunk/Doc/library/functions.rst ============================================================================== --- python/trunk/Doc/library/functions.rst (original) +++ python/trunk/Doc/library/functions.rst Thu Apr 1 09:54:16 2010 @@ -1158,6 +1158,9 @@ function, see the `CmpToKey recipe in the ASPN cookbook `_\. + For sorting examples and a brief sorting tutorial, see `Sorting HowTo + `_\. + .. versionadded:: 2.4 From python-checkins at python.org Thu Apr 1 11:39:03 2010 From: python-checkins at python.org (stefan.krah) Date: Thu, 1 Apr 2010 11:39:03 +0200 (CEST) Subject: [Python-checkins] r79550 - in python/branches/py3k-cdecimal: .hgignore Demo/cgi/cgi1.py Demo/cgi/cgi2.py Demo/cgi/cgi3.py Demo/classes/Complex.py Demo/classes/Dates.py Demo/classes/Dbm.py Demo/classes/Range.py Demo/classes/Rev.py Demo/classes/Vec.py Demo/classes/bitvec.py Demo/comparisons/regextest.py Demo/comparisons/sortingtest.py Demo/comparisons/systemtest.py Demo/curses/life.py Demo/curses/ncurses.py Demo/curses/rain.py Demo/curses/repeat.py Demo/curses/tclock.py Demo/distutils/test2to3/maintest.py Demo/md5test/md5driver.py Demo/parser/test_parser.py Demo/pdist/FSProxy.py Demo/pdist/RCSProxy.py Demo/pdist/client.py Demo/pdist/cmdfw.py Demo/pdist/cmptree.py Demo/pdist/cvslib.py Demo/pdist/cvslock.py Demo/pdist/mac.py Demo/pdist/makechangelog.py Demo/pdist/rcsclient.py Demo/pdist/rcslib.py Demo/pdist/rcvs.py Demo/pdist/rrcs.py Demo/pdist/security.py Demo/pdist/server.py Demo/pdist/sumtree.py Demo/pysvr/pysvr.py Demo/scripts/beer.py Demo/scripts/eqfix.py Demo/scripts/fact.py Demo/scripts/find-uname.py Demo/scripts/from.py Demo/scripts/lpwatch.py Demo/scripts/makedir.py Demo/scripts/markov.py Demo/scripts/mboxconvert.py Demo/scripts/morse.py Demo/scripts/newslist.py Demo/scripts/pi.py Demo/scripts/pp.py Demo/scripts/primes.py Demo/scripts/queens.py Demo/scripts/script.py Demo/scripts/unbirthday.py Demo/scripts/update.py Demo/sockets/broadcast.py Demo/sockets/echosvr.py Demo/sockets/finger.py Demo/sockets/ftp.py Demo/sockets/gopher.py Demo/sockets/mcast.py Demo/sockets/radio.py Demo/sockets/rpython.py Demo/sockets/rpythond.py Demo/sockets/telnet.py Demo/sockets/throughput.py Demo/sockets/udpecho.py Demo/tix/samples/Balloon.py Demo/tix/samples/BtnBox.py Demo/tix/samples/CmpImg.py Demo/tix/samples/ComboBox.py Demo/tix/samples/Control.py Demo/tix/samples/DirList.py Demo/tix/samples/DirTree.py Demo/tix/samples/NoteBook.py Demo/tix/samples/OptMenu.py Demo/tix/samples/PanedWin.py Demo/tix/samples/PopMenu.py Demo/tix/samples/SHList1.py Demo/tix/samples/SHList2.py Demo/tix/samples/Tree.py Demo/tkinter/guido/AttrDialog.py Demo/tkinter/guido/ManPage.py Demo/tkinter/guido/MimeViewer.py Demo/tkinter/guido/ShellWindow.py Demo/tkinter/guido/canvasevents.py Demo/tkinter/guido/dialog.py Demo/tkinter/guido/electrons.py Demo/tkinter/guido/hanoi.py Demo/tkinter/guido/hello.py Demo/tkinter/guido/imagedraw.py Demo/tkinter/guido/imageview.py Demo/tkinter/guido/kill.py Demo/tkinter/guido/listtree.py Demo/tkinter/guido/mbox.py Demo/tkinter/guido/newmenubardemo.py Demo/tkinter/guido/rmt.py Demo/tkinter/guido/solitaire.py Demo/tkinter/guido/sortvisu.py Demo/tkinter/guido/svkill.py Demo/tkinter/guido/tkman.py Demo/tkinter/guido/wish.py Demo/turtle/tdemo_I_dontlike_tiltdemo.py Demo/turtle/tdemo_bytedesign.py Demo/turtle/tdemo_clock.py Demo/turtle/tdemo_forest.py Demo/turtle/tdemo_fractalcurves.py Demo/turtle/tdemo_lindenmayer_indian.py Demo/turtle/tdemo_minimal_hanoi.py Demo/turtle/tdemo_nim.py Demo/turtle/tdemo_paint.py Demo/turtle/tdemo_peace.py Demo/turtle/tdemo_penrose.py Demo/turtle/tdemo_planet_and_moon.py Demo/turtle/tdemo_round_dance.py Demo/turtle/tdemo_tree.py Demo/turtle/tdemo_yinyang.py Demo/turtle/turtleDemo.py Demo/turtle/turtledemo_two_canvases.py Demo/zlib/minigzip.py Demo/zlib/zlibdemo.py Doc Doc/Makefile Doc/README.txt Doc/bugs.rst Doc/c-api/code.rst Doc/c-api/conversion.rst Doc/c-api/exceptions.rst Doc/c-api/gcsupport.rst Doc/c-api/typeobj.rst Doc/c-api/unicode.rst Doc/distutils/examples.rst Doc/distutils/sourcedist.rst Doc/distutils/uploading.rst Doc/extending/extending.rst Doc/extending/newtypes.rst Doc/faq/windows.rst Doc/howto/unicode.rst Doc/howto/webservers.rst Doc/includes/dbpickle.py Doc/includes/email-alternative.py Doc/includes/email-dir.py Doc/includes/email-headers.py Doc/includes/email-unpack.py Doc/includes/minidom-example.py Doc/includes/sqlite3/load_extension.py Doc/library/2to3.rst Doc/library/allos.rst Doc/library/argparse.rst Doc/library/asyncore.rst Doc/library/builtins.rst Doc/library/bz2.rst Doc/library/codecs.rst Doc/library/csv.rst Doc/library/ctypes.rst Doc/library/datetime.rst Doc/library/decimal.rst Doc/library/doctest.rst Doc/library/email-examples.rst Doc/library/email.message.rst Doc/library/functions.rst Doc/library/getopt.rst Doc/library/gzip.rst Doc/library/hashlib.rst Doc/library/http.client.rst Doc/library/index.rst Doc/library/inspect.rst Doc/library/itertools.rst Doc/library/logging.rst Doc/library/multiprocessing.rst Doc/library/objects.rst Doc/library/optparse.rst Doc/library/os.rst Doc/library/pdb.rst Doc/library/pydoc.rst Doc/library/queue.rst Doc/library/random.rst Doc/library/re.rst Doc/library/shutil.rst Doc/library/site.rst Doc/library/sqlite3.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/struct.rst Doc/library/subprocess.rst Doc/library/sys.rst Doc/library/sysconfig.rst Doc/library/tarfile.rst Doc/library/test.rst Doc/library/threading.rst Doc/library/tkinter.rst Doc/library/tkinter.tix.rst Doc/library/tkinter.ttk.rst Doc/library/tokenize.rst Doc/library/traceback.rst Doc/library/turtle.rst Doc/library/unicodedata.rst Doc/library/unittest.rst Doc/library/urllib.request.rst Doc/library/weakref.rst Doc/library/xml.dom.minidom.rst Doc/library/xml.etree.elementtree.rst Doc/library/xml.etree.rst Doc/library/zipfile.rst Doc/library/zlib.rst Doc/make.bat Doc/reference/executionmodel.rst Doc/reference/expressions.rst Doc/reference/lexical_analysis.rst Doc/reference/simple_stmts.rst Doc/tools/rstlint.py Doc/tools/sphinxext/download.html Doc/tutorial/datastructures.rst Doc/tutorial/introduction.rst Doc/tutorial/stdlib.rst Doc/using/mac.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.6.rst Doc/whatsnew/2.7.rst Doc/whatsnew/3.1.rst Include/abstract.h Include/code.h Include/dtoa.h Include/longobject.h Include/pyctype.h Include/pystate.h Include/pystrtod.h Include/pythonrun.h Include/pythread.h Lib/_pyio.py Lib/_threading_local.py Lib/argparse.py Lib/base64.py Lib/cProfile.py Lib/compileall.py Lib/csv.py Lib/ctypes/__init__.py Lib/ctypes/test/test_callbacks.py Lib/ctypes/test/test_internals.py Lib/ctypes/test/test_sizes.py Lib/ctypes/util.py Lib/difflib.py Lib/distutils/command/install.py Lib/distutils/tests/test_bdist.py Lib/distutils/tests/test_bdist_dumb.py Lib/distutils/tests/test_bdist_msi.py Lib/distutils/tests/test_bdist_rpm.py Lib/distutils/tests/test_bdist_wininst.py Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_clean.py Lib/distutils/tests/test_cmd.py Lib/distutils/tests/test_cygwinccompiler.py Lib/distutils/tests/test_dep_util.py Lib/distutils/tests/test_emxccompiler.py Lib/distutils/tests/test_extension.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_sysconfig.py Lib/doctest.py Lib/email/generator.py Lib/email/message.py Lib/email/test/data/msg_10.txt Lib/email/test/data/msg_45.txt Lib/email/test/data/msg_46.txt Lib/email/test/test_email.py Lib/email/test/test_email_torture.py Lib/encodings/cp720.py Lib/fractions.py Lib/genericpath.py Lib/hashlib.py Lib/http/client.py Lib/http/cookies.py Lib/http/server.py Lib/idlelib/PyShell.py Lib/importlib/__init__.py Lib/importlib/_bootstrap.py Lib/importlib/abc.py Lib/importlib/machinery.py Lib/importlib/test/__init__.py Lib/importlib/test/__main__.py Lib/importlib/test/abc.py Lib/importlib/test/benchmark.py Lib/importlib/test/builtin/__init__.py Lib/importlib/test/builtin/test_finder.py Lib/importlib/test/builtin/test_loader.py Lib/importlib/test/builtin/util.py Lib/importlib/test/extension/__init__.py Lib/importlib/test/extension/test_case_sensitivity.py Lib/importlib/test/extension/test_finder.py Lib/importlib/test/extension/test_loader.py Lib/importlib/test/extension/test_path_hook.py Lib/importlib/test/extension/util.py Lib/importlib/test/frozen/__init__.py Lib/importlib/test/frozen/test_finder.py Lib/importlib/test/frozen/test_loader.py Lib/importlib/test/import_/__init__.py Lib/importlib/test/import_/test___package__.py Lib/importlib/test/import_/test_api.py Lib/importlib/test/import_/test_caching.py Lib/importlib/test/import_/test_fromlist.py Lib/importlib/test/import_/test_meta_path.py Lib/importlib/test/import_/test_packages.py Lib/importlib/test/import_/test_path.py Lib/importlib/test/import_/test_relative_imports.py Lib/importlib/test/import_/util.py Lib/importlib/test/regrtest.py Lib/importlib/test/source/__init__.py Lib/importlib/test/source/test_abc_loader.py Lib/importlib/test/source/test_case_sensitivity.py Lib/importlib/test/source/test_file_loader.py Lib/importlib/test/source/test_finder.py Lib/importlib/test/source/test_path_hook.py Lib/importlib/test/source/test_source_encoding.py Lib/importlib/test/source/util.py Lib/importlib/test/test_abc.py Lib/importlib/test/test_api.py Lib/importlib/test/test_util.py Lib/importlib/test/util.py Lib/importlib/util.py Lib/inspect.py Lib/keyword.py Lib/lib2to3/fixes/fix_exitfunc.py Lib/lib2to3/pgen2/token.py Lib/lib2to3/pgen2/tokenize.py Lib/lib2to3/tests/pytree_idempotency.py Lib/lib2to3/tests/test_fixers.py Lib/lib2to3/tests/test_main.py Lib/lib2to3/tests/test_parser.py Lib/lib2to3/tests/test_pytree.py Lib/lib2to3/tests/test_refactor.py Lib/logging/__init__.py Lib/logging/config.py Lib/logging/handlers.py Lib/macpath.py Lib/mailbox.py Lib/mimetypes.py Lib/multiprocessing/forking.py Lib/multiprocessing/pool.py Lib/multiprocessing/process.py Lib/ntpath.py Lib/os.py Lib/pdb.py Lib/pipes.py Lib/plat-freebsd4/regen Lib/plat-freebsd5/regen Lib/plat-freebsd6/regen Lib/plat-freebsd7/regen Lib/plat-freebsd8/regen Lib/plat-os2emx/regen Lib/plat-sunos5/IN.py Lib/platform.py Lib/posixpath.py Lib/profile.py Lib/py_compile.py Lib/pydoc.py Lib/quopri.py Lib/shutil.py Lib/site.py Lib/smtpd.py Lib/smtplib.py Lib/sqlite3/test/dbapi.py Lib/sqlite3/test/regression.py Lib/sqlite3/test/transactions.py Lib/sre_parse.py Lib/ssl.py Lib/subprocess.py Lib/symbol.py Lib/sysconfig.py Lib/tabnanny.py Lib/tarfile.py Lib/test/crashers/recursive_call.py Lib/test/curses_tests.py Lib/test/formatfloat_testcases.txt Lib/test/math_testcases.txt Lib/test/pystone.py Lib/test/re_tests.py Lib/test/regrtest.py Lib/test/script_helper.py Lib/test/support.py Lib/test/test.xml Lib/test/test.xml.out Lib/test/test___future__.py Lib/test/test__locale.py Lib/test/test_abstract_numbers.py Lib/test/test_aifc.py Lib/test/test_argparse.py Lib/test/test_array.py Lib/test/test_ascii_formatd.py Lib/test/test_asynchat.py Lib/test/test_bigmem.py Lib/test/test_binascii.py Lib/test/test_binhex.py Lib/test/test_bool.py Lib/test/test_builtin.py Lib/test/test_bytes.py Lib/test/test_bz2.py Lib/test/test_cgi.py Lib/test/test_cmath.py Lib/test/test_cmd.py Lib/test/test_cmd_line.py Lib/test/test_cmd_line_script.py Lib/test/test_code.py Lib/test/test_codecencodings_cn.py Lib/test/test_codecencodings_hk.py Lib/test/test_codecencodings_jp.py Lib/test/test_codecencodings_kr.py Lib/test/test_codecencodings_tw.py Lib/test/test_codecmaps_cn.py Lib/test/test_codecmaps_hk.py Lib/test/test_codecmaps_jp.py Lib/test/test_codecmaps_kr.py Lib/test/test_codecmaps_tw.py Lib/test/test_codecs.py Lib/test/test_coding.py Lib/test/test_collections.py Lib/test/test_compile.py Lib/test/test_compileall.py Lib/test/test_complex.py Lib/test/test_contextlib.py Lib/test/test_cprofile.py Lib/test/test_crypt.py Lib/test/test_csv.py Lib/test/test_curses.py Lib/test/test_dbm.py Lib/test/test_dbm_dumb.py Lib/test/test_decimal.py Lib/test/test_deque.py Lib/test/test_descr.py Lib/test/test_dict.py Lib/test/test_doctest.py Lib/test/test_doctest2.py Lib/test/test_docxmlrpc.py Lib/test/test_dynamic.py Lib/test/test_eof.py Lib/test/test_epoll.py Lib/test/test_errno.py Lib/test/test_exceptions.py Lib/test/test_extcall.py Lib/test/test_fcntl.py Lib/test/test_file.py Lib/test/test_filecmp.py Lib/test/test_fileio.py Lib/test/test_float.py Lib/test/test_flufl.py Lib/test/test_fnmatch.py Lib/test/test_fork1.py Lib/test/test_format.py Lib/test/test_fractions.py Lib/test/test_frozen.py Lib/test/test_ftplib.py Lib/test/test_functools.py Lib/test/test_genericpath.py Lib/test/test_getopt.py Lib/test/test_global.py Lib/test/test_grammar.py Lib/test/test_grp.py Lib/test/test_gzip.py Lib/test/test_hashlib.py Lib/test/test_heapq.py Lib/test/test_htmlparser.py Lib/test/test_http_cookies.py Lib/test/test_httplib.py Lib/test/test_httpservers.py Lib/test/test_imaplib.py Lib/test/test_imp.py Lib/test/test_import.py Lib/test/test_importhooks.py Lib/test/test_importlib.py Lib/test/test_index.py Lib/test/test_inspect.py Lib/test/test_io.py Lib/test/test_keywordonlyarg.py Lib/test/test_linecache.py Lib/test/test_logging.py Lib/test/test_long.py Lib/test/test_macpath.py Lib/test/test_mailbox.py Lib/test/test_marshal.py Lib/test/test_memoryio.py Lib/test/test_metaclass.py Lib/test/test_minidom.py Lib/test/test_multibytecodec.py Lib/test/test_multibytecodec_support.py Lib/test/test_multiprocessing.py Lib/test/test_normalization.py Lib/test/test_ntpath.py Lib/test/test_optparse.py Lib/test/test_os.py Lib/test/test_ossaudiodev.py Lib/test/test_parser.py Lib/test/test_pdb.py Lib/test/test_pep263.py Lib/test/test_pep277.py Lib/test/test_pep292.py Lib/test/test_pipes.py Lib/test/test_pkg.py Lib/test/test_platform.py Lib/test/test_popen.py Lib/test/test_posix.py Lib/test/test_posixpath.py Lib/test/test_print.py Lib/test/test_profile.py Lib/test/test_profilehooks.py Lib/test/test_property.py Lib/test/test_pwd.py Lib/test/test_pydoc.py Lib/test/test_pyexpat.py Lib/test/test_queue.py Lib/test/test_random.py Lib/test/test_re.py Lib/test/test_richcmp.py Lib/test/test_sax.py Lib/test/test_scope.py Lib/test/test_set.py Lib/test/test_shutil.py Lib/test/test_smtpnet.py Lib/test/test_socket.py Lib/test/test_socketserver.py Lib/test/test_sqlite.py Lib/test/test_ssl.py Lib/test/test_strftime.py Lib/test/test_strtod.py Lib/test/test_struct.py Lib/test/test_structmembers.py Lib/test/test_subprocess.py Lib/test/test_sys.py Lib/test/test_sysconfig.py Lib/test/test_tarfile.py Lib/test/test_tcl.py Lib/test/test_tempfile.py Lib/test/test_thread.py Lib/test/test_threaded_import.py Lib/test/test_threading.py Lib/test/test_threading_local.py Lib/test/test_tokenize.py Lib/test/test_ttk_guionly.py Lib/test/test_ttk_textonly.py Lib/test/test_types.py Lib/test/test_unicode.py Lib/test/test_unicodedata.py Lib/test/test_unittest.py Lib/test/test_urllib.py Lib/test/test_urllib2.py Lib/test/test_urllib2_localnet.py Lib/test/test_urllib2net.py Lib/test/test_urllib_response.py Lib/test/test_urllibnet.py Lib/test/test_urlparse.py Lib/test/test_userstring.py Lib/test/test_warnings.py Lib/test/test_weakref.py Lib/test/test_with.py Lib/test/test_wsgiref.py Lib/test/test_xml_etree.py Lib/test/test_xml_etree_c.py Lib/test/test_xmlrpc.py Lib/test/test_xmlrpc_net.py Lib/test/test_zipimport.py Lib/test/test_zipimport_support.py Lib/test/xmltestdata Lib/threading.py Lib/timeit.py Lib/tkinter/messagebox.py Lib/token.py Lib/tokenize.py Lib/trace.py Lib/turtle.py Lib/unittest/__init__.py Lib/unittest/__main__.py Lib/unittest/case.py Lib/unittest/loader.py Lib/unittest/main.py Lib/unittest/result.py Lib/unittest/runner.py Lib/unittest/signals.py Lib/unittest/suite.py Lib/unittest/test Lib/unittest/util.py Lib/urllib/__init__.py Lib/urllib/error.py Lib/urllib/request.py Lib/urllib/response.py Lib/uu.py Lib/webbrowser.py Lib/wsgiref/handlers.py Lib/wsgiref/headers.py Lib/wsgiref/simple_server.py Lib/wsgiref/util.py Lib/xml/etree/ElementInclude.py Lib/xml/etree/ElementPath.py Lib/xml/etree/ElementTree.py Lib/xml/etree/__init__.py Mac/BuildScript/build-installer.py Mac/Makefile.in Mac/Tools/pythonw.c Makefile.pre.in Misc/ACKS Misc/HISTORY Misc/NEWS Misc/Porting Misc/SpecialBuilds.txt Misc/build.sh Misc/developers.txt Misc/maintainers.rst Misc/python-config.in Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/libffi.diff Modules/_ctypes/libffi/ChangeLog Modules/_ctypes/libffi/ChangeLog.libffi Modules/_ctypes/libffi/ChangeLog.libgcj Modules/_ctypes/libffi/ChangeLog.v1 Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi/Makefile.am Modules/_ctypes/libffi/Makefile.in Modules/_ctypes/libffi/README Modules/_ctypes/libffi/aclocal.m4 Modules/_ctypes/libffi/compile Modules/_ctypes/libffi/config.guess Modules/_ctypes/libffi/config.sub Modules/_ctypes/libffi/configure Modules/_ctypes/libffi/configure.ac Modules/_ctypes/libffi/depcomp Modules/_ctypes/libffi/doc Modules/_ctypes/libffi/fficonfig.h.in Modules/_ctypes/libffi/include/Makefile.am Modules/_ctypes/libffi/include/Makefile.in Modules/_ctypes/libffi/include/ffi.h.in Modules/_ctypes/libffi/include/ffi_common.h Modules/_ctypes/libffi/libffi.pc.in Modules/_ctypes/libffi/libtool-version Modules/_ctypes/libffi/ltmain.sh Modules/_ctypes/libffi/m4 Modules/_ctypes/libffi/man Modules/_ctypes/libffi/mdate-sh Modules/_ctypes/libffi/missing Modules/_ctypes/libffi/msvcc.sh Modules/_ctypes/libffi/src/arm/sysv.S Modules/_ctypes/libffi/src/avr32 Modules/_ctypes/libffi/src/closures.c Modules/_ctypes/libffi/src/darwin/ffitarget.h Modules/_ctypes/libffi/src/debug.c Modules/_ctypes/libffi/src/dlmalloc.c Modules/_ctypes/libffi/src/frv/ffi.c Modules/_ctypes/libffi/src/java_raw_api.c Modules/_ctypes/libffi/src/mips/ffi.c Modules/_ctypes/libffi/src/mips/ffitarget.h Modules/_ctypes/libffi/src/mips/n32.S Modules/_ctypes/libffi/src/mips/o32.S Modules/_ctypes/libffi/src/moxie Modules/_ctypes/libffi/src/pa/ffi.c Modules/_ctypes/libffi/src/powerpc/aix.S Modules/_ctypes/libffi/src/powerpc/aix_closure.S Modules/_ctypes/libffi/src/powerpc/ffi.c Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Modules/_ctypes/libffi/src/powerpc/ffitarget.h Modules/_ctypes/libffi/src/powerpc/sysv.S Modules/_ctypes/libffi/src/prep_cif.c Modules/_ctypes/libffi/src/raw_api.c Modules/_ctypes/libffi/src/s390/sysv.S Modules/_ctypes/libffi/src/sh/ffi.c Modules/_ctypes/libffi/src/sh/sysv.S Modules/_ctypes/libffi/src/sh64/ffi.c Modules/_ctypes/libffi/src/sh64/sysv.S Modules/_ctypes/libffi/src/sparc/ffi.c Modules/_ctypes/libffi/src/sparc/v8.S Modules/_ctypes/libffi/src/types.c Modules/_ctypes/libffi/src/x86/darwin.S Modules/_ctypes/libffi/src/x86/ffi.c Modules/_ctypes/libffi/src/x86/ffi64.c Modules/_ctypes/libffi/src/x86/ffitarget.h Modules/_ctypes/libffi/src/x86/sysv.S Modules/_ctypes/libffi/src/x86/unix64.S Modules/_ctypes/libffi/src/x86/win32.S Modules/_ctypes/libffi/src/x86/win64.S Modules/_ctypes/libffi/testsuite Modules/_ctypes/libffi/texinfo.tex Modules/_curses_panel.c Modules/_cursesmodule.c Modules/_elementtree.c Modules/_hashopenssl.c Modules/_io/fileio.c Modules/_lsprof.c Modules/_math.c Modules/_math.h Modules/_posixsubprocess.c Modules/_sqlite/cache.c Modules/_sqlite/cache.h Modules/_sqlite/connection.c Modules/_sqlite/connection.h Modules/_sqlite/cursor.c Modules/_sqlite/cursor.h Modules/_sqlite/module.c Modules/_sqlite/module.h Modules/_sqlite/prepare_protocol.c Modules/_sqlite/prepare_protocol.h Modules/_sqlite/row.c Modules/_sqlite/row.h Modules/_sqlite/sqlitecompat.h Modules/_sqlite/statement.c Modules/_sqlite/statement.h Modules/_sqlite/util.c Modules/_sqlite/util.h Modules/_sre.c Modules/_ssl.c Modules/_testcapimodule.c Modules/_threadmodule.c Modules/getpath.c Modules/hashlib.h Modules/main.c Modules/ossaudiodev.c Modules/posixmodule.c Modules/selectmodule.c Modules/signalmodule.c Modules/timemodule.c Modules/unicodedata.c Modules/unicodedata_db.h Modules/unicodename_db.h Modules/zipimport.c Objects/abstract.c Objects/codeobject.c Objects/complexobject.c Objects/dictobject.c Objects/exceptions.c Objects/floatobject.c Objects/funcobject.c Objects/listobject.c Objects/lnotab_notes.txt Objects/longobject.c Objects/object.c Objects/setobject.c Objects/stringlib/formatter.h Objects/tupleobject.c Objects/typeobject.c Objects/unicodeobject.c Objects/unicodetype_db.h PC/os2emx/python27.def PC/os2vacpp/python.def Parser/myreadline.c Parser/tokenizer.c Python/bltinmodule.c Python/ceval.c Python/compile.c Python/dtoa.c Python/errors.c Python/import.c Python/pyctype.c Python/pystate.c Python/pystrtod.c Python/pythonrun.c Python/structmember.c Python/sysmodule.c Python/thread_cthread.h Python/thread_foobar.h Python/thread_lwp.h Python/thread_nt.h Python/thread_os2.h Python/thread_pth.h Python/thread_pthread.h Python/thread_sgi.h Python/thread_solaris.h Python/thread_wince.h Tools/README Tools/ccbench/ccbench.py Tools/faqwiz/faqw.py Tools/freeze/freeze.py Tools/i18n/makelocalealias.py Tools/i18n/msgfmt.py Tools/i18n/pygettext.py Tools/modulator Tools/msi/merge.py Tools/msi/msi.py Tools/msi/uuids.py Tools/scripts/README Tools/scripts/analyze_dxp.py Tools/scripts/byteyears.py Tools/scripts/checkappend.py Tools/scripts/checkpyc.py Tools/scripts/classfix.py Tools/scripts/cleanfuture.py Tools/scripts/combinerefs.py Tools/scripts/copytime.py Tools/scripts/crlf.py Tools/scripts/cvsfiles.py Tools/scripts/db2pickle.py Tools/scripts/dutree.py Tools/scripts/eptags.py Tools/scripts/find_recursionlimit.py Tools/scripts/finddiv.py Tools/scripts/findlinksto.py Tools/scripts/findnocoding.py Tools/scripts/fixcid.py Tools/scripts/fixdiv.py Tools/scripts/fixheader.py Tools/scripts/fixnotice.py Tools/scripts/fixps.py Tools/scripts/ftpmirror.py Tools/scripts/google.py Tools/scripts/gprof2html.py Tools/scripts/h2py.py Tools/scripts/ifdef.py Tools/scripts/lfcr.py Tools/scripts/linktree.py Tools/scripts/lll.py Tools/scripts/logmerge.py Tools/scripts/mailerdaemon.py Tools/scripts/md5sum.py Tools/scripts/methfix.py Tools/scripts/mkreal.py Tools/scripts/ndiff.py Tools/scripts/nm2def.py Tools/scripts/objgraph.py Tools/scripts/parseentities.py Tools/scripts/pdeps.py Tools/scripts/pickle2db.py Tools/scripts/pindent.py Tools/scripts/ptags.py Tools/scripts/pysource.py Tools/scripts/reindent.py Tools/scripts/rgrep.py Tools/scripts/serve.py Tools/scripts/suff.py Tools/scripts/svneol.py Tools/scripts/texi2html.py Tools/scripts/treesync.py Tools/scripts/untabify.py Tools/scripts/which.py Tools/scripts/xxci.py Tools/ssl/get-remote-certificate.py Tools/unicode/comparecodecs.py Tools/unicode/gencodec.py Tools/unicode/genwincodec.py Tools/unicode/makeunicodedata.py Tools/webchecker/wcgui.py Tools/webchecker/webchecker.py Tools/webchecker/websucker.py Tools/webchecker/wsgui.py configure configure.in setup.py Message-ID: <20100401093903.CABF8E4E9@mail.python.org> Author: stefan.krah Date: Thu Apr 1 11:38:52 2010 New Revision: 79550 Log: Merged revisions 78270,78276,78283,78286,78289-78290,78301,78305-78306,78309,78311,78314,78316,78320,78322,78325,78333,78335,78337,78340,78347,78350,78357,78362,78366,78369,78375,78382,78388-78389,78395,78397,78400,78405,78410,78414,78420,78426-78427,78433,78435,78437,78442,78446,78451,78455-78456,78459,78462,78464,78469-78470,78473,78476,78478,78480-78481,78484,78487,78491,78493,78499-78500,78505-78506,78510,78513,78519,78524,78529-78530,78533,78538,78541,78545,78548,78552,78556,78568,78577,78583,78595,78598,78602,78605,78607-78608,78611,78615-78616,78622,78626,78632,78636,78639,78642,78645,78647,78649,78654-78655,78657,78663-78664,78670,78672,78674,78676,78684,78687,78689,78691-78692,78695-78698,78702,78705,78708,78711,78715,78723-78725,78727,78729,78733,78739,78745,78747,78750,78752,78756,78763,78765-78766,78780,78782,78786,78792-78793,78795-78799,78801,78803-78804,78807-78808,78818,78821,78829,78831,78834,78843,78845,78848-78852,78861-78863,78868-78869,78871-78873,78875-78876,78882,78884,78888,78891,78893-78894,78896,78899,78901-78902,78911,78915,78918,78920,78924,78927,78929-78930,78933,78938,78940-78943,78945-78948,78950,78955-78961,78963,78965,78967,78973,78975,78977-78978,78980,78987,78989,78991-78994,78997,79009,79014,79017,79019-79020,79022,79025,79033,79035-79036,79040-79041,79045,79048,79050,79052,79057,79061-79062,79065-79069,79071,79074-79075,79080,79083,79087-79088,79092-79095,79097,79099,79102-79103,79107-79113,79116,79119,79124,79126,79128,79136,79140-79141,79143-79145,79149-79155,79157-79158,79161,79166,79170-79171,79175,79177,79180,79182-79183,79186,79193,79196,79209,79221,79239,79242-79245,79251-79253,79255-79260,79262,79264,79267,79269,79271,79273,79275-79276,79281,79287,79289,79298,79301,79315,79317,79319,79321,79327,79333,79352,79360,79364,79368,79375,79380,79386,79389,79393,79398,79400-79401,79407,79409,79411,79414,79420,79429,79434,79449,79452,79454,79456,79458,79461-79463,79465-79467,79469,79472-79474,79484,79499,79501,79503,79505-79508,79520,79525,79531,79536,79538,79545 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r78270 | senthil.kumaran | 2010-02-20 23:19:04 +0100 (Sat, 20 Feb 2010) | 4 lines Merged revisions 78268 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r78276 | r.david.murray | 2010-02-21 05:39:40 +0100 (Sun, 21 Feb 2010) | 16 lines Merged revisions 78274 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78274 | r.david.murray | 2010-02-20 23:23:00 -0500 (Sat, 20 Feb 2010) | 9 lines Issue 7970: When email.Parser.Parser parses a MIME message of type message/rfc822 it turns it into an object whose body consists of a list containing a single Message object. HeaderParser, on the other hand, just copies the body as a string. Generator.flatten has a special handler for the message mime type that expected the body to be the one item list. This fails if the message was parsed by HeaderParser. So we now check to see if the body is a string first, and if so just we just emit it. ........ ................ r78283 | mark.dickinson | 2010-02-21 14:42:03 +0100 (Sun, 21 Feb 2010) | 9 lines Merged revisions 78281 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78281 | mark.dickinson | 2010-02-21 13:37:53 +0000 (Sun, 21 Feb 2010) | 1 line Issue #7384: skip test_curses on FreeBSD, in order to allow other buildbot tests to complete. ........ ................ r78286 | mark.dickinson | 2010-02-21 14:46:40 +0100 (Sun, 21 Feb 2010) | 8 lines Blocked revisions 78280 via svnmerge ........ r78280 | mark.dickinson | 2010-02-21 12:57:35 +0000 (Sun, 21 Feb 2010) | 1 line Fix complex type to avoid implicit calls to complex.__coerce__. ........ ................ r78289 | mark.dickinson | 2010-02-21 15:49:52 +0100 (Sun, 21 Feb 2010) | 9 lines Merged revisions 78287 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78287 | mark.dickinson | 2010-02-21 14:42:27 +0000 (Sun, 21 Feb 2010) | 1 line Reduce number of random tests in test_strtod, to avoid hogging buildbot time. ........ ................ r78290 | brett.cannon | 2010-02-21 15:50:48 +0100 (Sun, 21 Feb 2010) | 3 lines The last bug reported for 'time' made me realize I hate dealing with it, so I am taking myself off as its official maintainer. ................ r78301 | senthil.kumaran | 2010-02-22 12:00:50 +0100 (Mon, 22 Feb 2010) | 10 lines Merged revisions 78299 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78299 | senthil.kumaran | 2010-02-22 16:25:08 +0530 (Mon, 22 Feb 2010) | 4 lines Fix Issue7172 - BaseHTTPServer.BaseHTTPRequestHandler.responses[405] - changing server to resource in the 405 response msg. ........ ................ r78305 | andrew.kuchling | 2010-02-22 15:57:30 +0100 (Mon, 22 Feb 2010) | 9 lines Merged revisions 78303 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78303 | andrew.kuchling | 2010-02-22 09:53:17 -0500 (Mon, 22 Feb 2010) | 1 line #7794: describe 2.6 support for executing directories and zip archives ........ ................ r78306 | eric.smith | 2010-02-22 15:58:30 +0100 (Mon, 22 Feb 2010) | 1 line Issue #5988: Delete deprecated functions PyOS_ascii_formatd, PyOS_ascii_strtod, and PyOS_ascii_atof. ................ r78309 | andrew.kuchling | 2010-02-22 16:15:21 +0100 (Mon, 22 Feb 2010) | 10 lines Merged revisions 78308 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78308 | andrew.kuchling | 2010-02-22 10:13:17 -0500 (Mon, 22 Feb 2010) | 2 lines #6414: clarify description of processor endianness. Text by Alexey Shamrin; I changed 'DEC Alpha' to the more relevant 'Intel Itanium'. ........ ................ r78311 | andrew.kuchling | 2010-02-22 16:24:43 +0100 (Mon, 22 Feb 2010) | 1 line #7794: describe 3.1 support for executing directories and zip archives ................ r78314 | mark.dickinson | 2010-02-22 16:41:48 +0100 (Mon, 22 Feb 2010) | 9 lines Merged revisions 78312 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78312 | mark.dickinson | 2010-02-22 15:40:28 +0000 (Mon, 22 Feb 2010) | 1 line Clarify description of three-argument pow for Decimal types: the exponent of the result is always 0. ........ ................ r78316 | ezio.melotti | 2010-02-22 16:59:01 +0100 (Mon, 22 Feb 2010) | 1 line #7310: fix the repr() of os.environ ................ r78320 | ezio.melotti | 2010-02-22 17:34:50 +0100 (Mon, 22 Feb 2010) | 9 lines Merged revisions 78319 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78319 | ezio.melotti | 2010-02-22 18:30:58 +0200 (Mon, 22 Feb 2010) | 1 line #7482: clarify error message in case of division by zero of float and complex numbers. ........ ................ r78322 | andrew.kuchling | 2010-02-22 17:52:52 +0100 (Mon, 22 Feb 2010) | 9 lines Merged revisions 78318 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78318 | andrew.kuchling | 2010-02-22 11:26:47 -0500 (Mon, 22 Feb 2010) | 1 line #7597: curses.use_env() can be called before initscr(). Noted by Kan-Ru Chen ........ ................ r78325 | senthil.kumaran | 2010-02-22 18:17:22 +0100 (Mon, 22 Feb 2010) | 2 lines Fixing Issue7399 - Fixing an example of urllib usage. ................ r78333 | eric.smith | 2010-02-22 19:54:44 +0100 (Mon, 22 Feb 2010) | 9 lines Merged revisions 78329 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78329 | eric.smith | 2010-02-22 13:33:47 -0500 (Mon, 22 Feb 2010) | 1 line Issue #7988: Fix default alignment to be right aligned for complex.__format__. Now it matches other numeric types. ........ ................ r78335 | antoine.pitrou | 2010-02-22 20:41:37 +0100 (Mon, 22 Feb 2010) | 3 lines Poor PLAN9, it isn't supported ................ r78337 | jack.diederich | 2010-02-22 20:55:46 +0100 (Mon, 22 Feb 2010) | 1 line fixes issue #1522237, bad init check in _threading_local ................ r78340 | andrew.kuchling | 2010-02-22 23:16:58 +0100 (Mon, 22 Feb 2010) | 1 line #6666: fix bug in trace.py that applied the list of ignored dirs only to 1st file ................ r78347 | andrew.kuchling | 2010-02-23 00:26:10 +0100 (Tue, 23 Feb 2010) | 1 line #4532: fixes to make 3.x compile on QNX 6.3.2 (reported by Matt Kraai) ................ r78350 | eric.smith | 2010-02-23 01:22:24 +0100 (Tue, 23 Feb 2010) | 9 lines Merged revisions 78349 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78349 | eric.smith | 2010-02-22 19:11:16 -0500 (Mon, 22 Feb 2010) | 1 line Issue #6902: Fix problem with built-in types format incorrectly with 0 padding. ........ ................ r78357 | tarek.ziade | 2010-02-23 06:03:26 +0100 (Tue, 23 Feb 2010) | 9 lines Merged revisions 78354 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78354 | tarek.ziade | 2010-02-22 23:57:05 -0500 (Mon, 22 Feb 2010) | 1 line removed debugging code ........ ................ r78362 | tarek.ziade | 2010-02-23 06:30:31 +0100 (Tue, 23 Feb 2010) | 13 lines Merged revisions 78359-78360 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78359 | tarek.ziade | 2010-02-23 00:16:41 -0500 (Tue, 23 Feb 2010) | 1 line added make_archive (and secondary APIs) to shutil ........ r78360 | tarek.ziade | 2010-02-23 00:20:22 -0500 (Tue, 23 Feb 2010) | 1 line added a note on shutil new APIs ........ ................ r78366 | tarek.ziade | 2010-02-23 06:39:18 +0100 (Tue, 23 Feb 2010) | 9 lines Merged revisions 78364 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78364 | tarek.ziade | 2010-02-23 00:36:41 -0500 (Tue, 23 Feb 2010) | 1 line completed the __all__ list and changed the module doctest ........ ................ r78369 | tarek.ziade | 2010-02-23 07:00:04 +0100 (Tue, 23 Feb 2010) | 9 lines Merged revisions 78367 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78367 | tarek.ziade | 2010-02-23 00:53:05 -0500 (Tue, 23 Feb 2010) | 1 line fixed #5801: removed spurious empty lines in wsgiref ........ ................ r78375 | mark.dickinson | 2010-02-23 14:20:58 +0100 (Tue, 23 Feb 2010) | 13 lines Merged revisions 78372-78373 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78372 | mark.dickinson | 2010-02-23 12:53:52 +0000 (Tue, 23 Feb 2010) | 1 line Make global variable overflowok into a keyword argument; this fixes a failure when running ./python -m test.regrtest -R 3:2: test_format ........ r78373 | mark.dickinson | 2010-02-23 13:06:50 +0000 (Tue, 23 Feb 2010) | 1 line Fix spacing nit. Thanks Eric Smith for the public humiliation. ........ ................ r78382 | thomas.heller | 2010-02-23 21:25:02 +0100 (Tue, 23 Feb 2010) | 11 lines Merged revisions 78380 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78380 | thomas.heller | 2010-02-23 21:11:44 +0100 (Di, 23 Feb 2010) | 4 lines ctypes CThunkObject was not registered correctly with the cycle garbage collector, leading to possible leaks when using callback functions. ........ ................ r78388 | r.david.murray | 2010-02-23 23:57:58 +0100 (Tue, 23 Feb 2010) | 11 lines Merged revisions 78384 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78384 | dirkjan.ochtman | 2010-02-23 16:09:52 -0500 (Tue, 23 Feb 2010) | 4 lines Fix #1537721: add writeheader() method to csv.DictWriter. Reviewed by skip.montanaro and thomas.wouters. ........ ................ r78389 | r.david.murray | 2010-02-24 00:00:34 +0100 (Wed, 24 Feb 2010) | 2 lines Fix version added for csv writeheader. ................ r78395 | victor.stinner | 2010-02-24 00:21:33 +0100 (Wed, 24 Feb 2010) | 10 lines Blocked revisions 78392 via svnmerge ........ r78392 | victor.stinner | 2010-02-24 00:16:07 +0100 (mer., 24 f??vr. 2010) | 4 lines Issue #7649: Fix u'%c' % char for character in range 0x80..0xFF => raise an UnicodeDecodeError. Patch written by Ezio Melotti. ........ ................ r78397 | amaury.forgeotdarc | 2010-02-24 01:10:48 +0100 (Wed, 24 Feb 2010) | 9 lines Merged revisions 78393 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78393 | amaury.forgeotdarc | 2010-02-24 00:19:39 +0100 (mer., 24 f??vr. 2010) | 2 lines #4852: Remove dead code in every thread implementation, unused for many years. ........ ................ r78400 | r.david.murray | 2010-02-24 02:46:21 +0100 (Wed, 24 Feb 2010) | 12 lines Merged revisions 78351 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78351 | r.david.murray | 2010-02-22 19:24:49 -0500 (Mon, 22 Feb 2010) | 5 lines Issue 6292: for the moment at least, the test suite passes if run with -OO. Tests requiring docstrings are skipped. Patch by Brian Curtin, thanks to Matias Torchinsky for helping review and improve the patch. ........ ................ r78405 | r.david.murray | 2010-02-24 03:11:08 +0100 (Wed, 24 Feb 2010) | 10 lines Merged revisions 78403 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78403 | r.david.murray | 2010-02-23 21:08:28 -0500 (Tue, 23 Feb 2010) | 3 lines The primary copy of lib2to3 is not trunk, so the lib2to3 change should not have been included in the -OO patch, back it out. ........ ................ r78410 | benjamin.peterson | 2010-02-24 03:28:05 +0100 (Wed, 24 Feb 2010) | 16 lines Merged revisions 78408 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r78408 | benjamin.peterson | 2010-02-23 20:24:35 -0600 (Tue, 23 Feb 2010) | 9 lines Merged revisions 78407 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r78407 | benjamin.peterson | 2010-02-23 20:21:34 -0600 (Tue, 23 Feb 2010) | 1 line rewrite test to not rely on __doc__ being present ........ ................ ................ r78414 | r.david.murray | 2010-02-24 03:37:33 +0100 (Wed, 24 Feb 2010) | 12 lines Blocked revisions 78412 via svnmerge ........ r78412 | r.david.murray | 2010-02-23 21:31:27 -0500 (Tue, 23 Feb 2010) | 6 lines Issue 7975: in python 2.6 bsddb.dbshelve switched from DictMixin to MutableMapping, and thereby lost functionality because the replacement functionality was implemented incorrectly or incompletely). Since bsddb isn't in py3k, this patch just goes back to using DictMixin in order to correct the regression. ........ ................ r78420 | eric.smith | 2010-02-24 16:42:29 +0100 (Wed, 24 Feb 2010) | 9 lines Merged revisions 78418 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78418 | eric.smith | 2010-02-24 09:15:36 -0500 (Wed, 24 Feb 2010) | 1 line Issue #7309: Unchecked pointer access when converting UnicodeEncodeError, UnicodeDecodeError, and UnicodeTranslateError to strings. ........ ................ r78426 | senthil.kumaran | 2010-02-24 17:53:16 +0100 (Wed, 24 Feb 2010) | 9 lines Merged revisions 78422 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78422 | senthil.kumaran | 2010-02-24 22:15:46 +0530 (Wed, 24 Feb 2010) | 2 lines Fix for Issue3819 - urllib2 sends Basic auth across redirects ........ ................ r78427 | ezio.melotti | 2010-02-24 17:55:43 +0100 (Wed, 24 Feb 2010) | 9 lines Merged revisions 78424 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78424 | ezio.melotti | 2010-02-24 18:49:56 +0200 (Wed, 24 Feb 2010) | 1 line typos ........ ................ r78433 | senthil.kumaran | 2010-02-24 22:03:37 +0100 (Wed, 24 Feb 2010) | 10 lines Merged revisions 78431 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78431 | senthil.kumaran | 2010-02-25 02:25:31 +0530 (Thu, 25 Feb 2010) | 4 lines Fix for Issue7540 ; urllib2 will raise a TypeError when you try to add_data to a existing req object already having data. ........ ................ r78435 | larry.hastings | 2010-02-24 23:49:58 +0100 (Wed, 24 Feb 2010) | 4 lines Issue #5939: Add additional runtime checking to ensure a valid capsule in Modules/_ctypes/callproc.c. Reviewed by Benjamin P. My first commit! ................ r78437 | benjamin.peterson | 2010-02-25 02:22:28 +0100 (Thu, 25 Feb 2010) | 1 line plug reference leak ................ r78442 | eric.smith | 2010-02-25 15:18:57 +0100 (Thu, 25 Feb 2010) | 9 lines Merged revisions 78440 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78440 | eric.smith | 2010-02-25 09:14:35 -0500 (Thu, 25 Feb 2010) | 1 line Issue #5965: Add documentation for parts of format specification language. ........ ................ r78446 | eric.smith | 2010-02-25 15:58:13 +0100 (Thu, 25 Feb 2010) | 9 lines Merged revisions 78444 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78444 | eric.smith | 2010-02-25 09:26:33 -0500 (Thu, 25 Feb 2010) | 1 line Issue #7928: Document str.format element_index better. ........ ................ r78451 | ezio.melotti | 2010-02-25 18:53:21 +0100 (Thu, 25 Feb 2010) | 8 lines Blocked revisions 78449 via svnmerge ........ r78449 | ezio.melotti | 2010-02-25 19:36:04 +0200 (Thu, 25 Feb 2010) | 1 line #7649: "u'%c' % char" now behaves like "u'%s' % char" and raises a UnicodeDecodeError if 'char' is a byte string that can't be decoded using the default encoding. ........ ................ r78455 | martin.v.loewis | 2010-02-25 21:45:06 +0100 (Thu, 25 Feb 2010) | 17 lines Merged revisions 78327,78399,78454 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78327 | andrew.kuchling | 2010-02-22 18:21:54 +0100 (Mo, 22 Feb 2010) | 1 line Note granting of commit privileges to Larry Hastings ........ r78399 | brett.cannon | 2010-02-24 02:38:04 +0100 (Mi, 24 Feb 2010) | 1 line Record that Dino Viehland got commit privs. ........ r78454 | martin.v.loewis | 2010-02-25 21:42:40 +0100 (Do, 25 Feb 2010) | 2 lines Add Florent Xicluna. ........ ................ r78456 | vinay.sajip | 2010-02-26 00:13:06 +0100 (Fri, 26 Feb 2010) | 33 lines Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line Logging: Implemented PEP 391. ........ r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line Removed spurious print statement. ........ r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line make waiting for the server to start robust ........ r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line Issue #7868: logging: added loggerClass attribute to Manager. ........ r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code. ........ r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line logging: Removed some more 1.5.2 support code. ........ r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line logging: gingerly re-enabling skipped tests after improving thread sync code in configurator. ........ ................ r78459 | senthil.kumaran | 2010-02-26 01:53:23 +0100 (Fri, 26 Feb 2010) | 9 lines Merged revisions 78457 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78457 | senthil.kumaran | 2010-02-26 06:17:05 +0530 (Fri, 26 Feb 2010) | 3 lines Fixing issue5475 : urllib2.getproxies not documented ........ ................ r78462 | florent.xicluna | 2010-02-26 12:12:33 +0100 (Fri, 26 Feb 2010) | 9 lines Merged revisions 78461 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78461 | florent.xicluna | 2010-02-26 11:40:58 +0100 (ven, 26 f??v 2010) | 2 lines #691291: codecs.open() should not convert end of lines on reading and writing. ........ ................ r78464 | andrew.kuchling | 2010-02-26 14:35:56 +0100 (Fri, 26 Feb 2010) | 9 lines Merged revisions 78463 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78463 | andrew.kuchling | 2010-02-26 08:22:50 -0500 (Fri, 26 Feb 2010) | 1 line #7407: specify default maxsize value; patch by Floris Bruynooghe ........ ................ r78469 | benjamin.peterson | 2010-02-27 01:13:52 +0100 (Sat, 27 Feb 2010) | 9 lines Merged revisions 78467 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78467 | ezio.melotti | 2010-02-26 18:05:42 -0600 (Fri, 26 Feb 2010) | 1 line Show an error when the value passed to --enable-unicode is not ucs2 or ucs4 (lowercase). ........ ................ r78470 | benjamin.peterson | 2010-02-27 01:14:20 +0100 (Sat, 27 Feb 2010) | 1 line run autoconf ................ r78473 | benjamin.peterson | 2010-02-27 01:17:04 +0100 (Sat, 27 Feb 2010) | 8 lines Blocked revisions 78468 via svnmerge ........ r78468 | benjamin.peterson | 2010-02-26 18:11:42 -0600 (Fri, 26 Feb 2010) | 1 line run autoconf ........ ................ r78476 | benjamin.peterson | 2010-02-27 01:45:21 +0100 (Sat, 27 Feb 2010) | 1 line revert unapplicable change to py3k ................ r78478 | ezio.melotti | 2010-02-27 02:11:44 +0100 (Sat, 27 Feb 2010) | 8 lines Blocked revisions 78465 via svnmerge ........ r78465 | ezio.melotti | 2010-02-27 01:27:06 +0200 (Sat, 27 Feb 2010) | 1 line typo: __next__ -> next ........ ................ r78480 | gregory.p.smith | 2010-02-27 08:22:22 +0100 (Sat, 27 Feb 2010) | 4 lines Add an os.get_exec_path() function to return the list of directories that launching a subprocess will search for the executable. Refactors some code in os._execvpe(). ................ r78481 | gregory.p.smith | 2010-02-27 09:33:11 +0100 (Sat, 27 Feb 2010) | 2 lines Update a comment with more details. ................ r78484 | florent.xicluna | 2010-02-27 12:31:21 +0100 (Sat, 27 Feb 2010) | 9 lines Merged revisions 78482 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78482 | florent.xicluna | 2010-02-27 12:19:18 +0100 (sam, 27 f??v 2010) | 2 lines Add entry for issue #691291. ........ ................ r78487 | ezio.melotti | 2010-02-27 13:43:58 +0100 (Sat, 27 Feb 2010) | 8 lines Blocked revisions 78486 via svnmerge ........ r78486 | ezio.melotti | 2010-02-27 14:42:52 +0200 (Sat, 27 Feb 2010) | 1 line Add a test for normpath to test_macpath. ........ ................ r78491 | ezio.melotti | 2010-02-27 14:54:27 +0100 (Sat, 27 Feb 2010) | 9 lines Merged revisions 78489 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78489 | ezio.melotti | 2010-02-27 15:50:35 +0200 (Sat, 27 Feb 2010) | 1 line Fix missing parenthesis. ........ ................ r78493 | florent.xicluna | 2010-02-27 15:21:57 +0100 (Sat, 27 Feb 2010) | 11 lines For 3.x, the "backslashreplace" error handling is plugged on the "write" method. Recorded merge of revisions 78488 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78488 | florent.xicluna | 2010-02-27 14:31:23 +0100 (sam, 27 f??v 2010) | 2 lines Issue #1729305: Fix doctest to handle encode error with "backslashreplace". It fixes #7667 too. ........ ................ r78499 | florent.xicluna | 2010-02-27 16:16:59 +0100 (Sat, 27 Feb 2010) | 8 lines Blocked revisions 78497 via svnmerge ........ r78497 | florent.xicluna | 2010-02-27 16:10:19 +0100 (sam, 27 f??v 2010) | 2 lines #7793: Fix RuntimeError when running "regrtest -R" for multibyte codecs. ........ ................ r78500 | florent.xicluna | 2010-02-27 17:12:22 +0100 (Sat, 27 Feb 2010) | 2 lines Use UTF-8 encoding to create Python test scripts. ................ r78505 | benjamin.peterson | 2010-02-27 18:40:01 +0100 (Sat, 27 Feb 2010) | 1 line only accept AttributeError as indicating no __prepare__ attribute on a metaclass, allowing lookup errors to propogate ................ r78506 | benjamin.peterson | 2010-02-27 18:41:13 +0100 (Sat, 27 Feb 2010) | 1 line check PyDict_New() for error ................ r78510 | florent.xicluna | 2010-02-27 23:12:37 +0100 (Sat, 27 Feb 2010) | 13 lines Recorded merge of revisions 78508-78509 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78508 | florent.xicluna | 2010-02-27 20:20:50 +0100 (sam, 27 f??v 2010) | 2 lines Clean test_subprocess: use assertRaises, skipIf, skipUnless helpers and a custom helper assertStderrEqual. ........ r78509 | florent.xicluna | 2010-02-27 22:15:27 +0100 (sam, 27 f??v 2010) | 2 lines Fix an oversight in r78508: p.wait() should be compared to 0 ........ ................ r78513 | ezio.melotti | 2010-02-28 04:46:13 +0100 (Sun, 28 Feb 2010) | 9 lines Merged revisions 78511 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78511 | ezio.melotti | 2010-02-28 05:11:07 +0200 (Sun, 28 Feb 2010) | 1 line Pep8ify test names in the examples. ........ ................ r78519 | gregory.p.smith | 2010-02-28 19:57:46 +0100 (Sun, 28 Feb 2010) | 10 lines Merged revisions 78517 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78517 | gregory.p.smith | 2010-02-28 10:36:09 -0800 (Sun, 28 Feb 2010) | 3 lines Issue #7481: When a threading.Thread failed to start it would leave the instance stuck in initial state and present in threading.enumerate(). ........ ................ r78524 | gregory.p.smith | 2010-03-01 01:17:40 +0100 (Mon, 01 Mar 2010) | 10 lines Merged revisions 78523 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78523 | gregory.p.smith | 2010-02-28 16:05:08 -0800 (Sun, 28 Feb 2010) | 3 lines Issue #1068268: The subprocess module now handles EINTR in internal os.waitpid and os.read system calls where appropriate. ........ ................ r78529 | gregory.p.smith | 2010-03-01 03:05:26 +0100 (Mon, 01 Mar 2010) | 9 lines Merged revisions 78528 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78528 | gregory.p.smith | 2010-02-28 18:01:47 -0800 (Sun, 28 Feb 2010) | 2 lines Adds the hashlib.algorithms attribute. See issue7418. ........ ................ r78530 | brett.cannon | 2010-03-01 03:09:17 +0100 (Mon, 01 Mar 2010) | 1 line Strip out trailing whitespace. ................ r78533 | gregory.p.smith | 2010-03-01 03:56:44 +0100 (Mon, 01 Mar 2010) | 9 lines Merged revisions 78532 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78532 | gregory.p.smith | 2010-02-28 18:53:24 -0800 (Sun, 28 Feb 2010) | 2 lines Fix the new test on windows (skip it, its posix only) ........ ................ r78538 | gregory.p.smith | 2010-03-01 04:13:36 +0100 (Mon, 01 Mar 2010) | 9 lines Merged revisions 78536 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78536 | gregory.p.smith | 2010-02-28 19:09:19 -0800 (Sun, 28 Feb 2010) | 2 lines Cleanup the test added in r78517 based on Ezio Melotti's feedback. ........ ................ r78541 | ezio.melotti | 2010-03-01 05:08:34 +0100 (Mon, 01 Mar 2010) | 17 lines Merged revisions 78515-78516,78522 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78515 | georg.brandl | 2010-02-28 20:19:17 +0200 (Sun, 28 Feb 2010) | 1 line #8030: make builtin type docstrings more consistent: use "iterable" instead of "seq(uence)", use "new" to show that set() always returns a new object. ........ r78516 | georg.brandl | 2010-02-28 20:26:37 +0200 (Sun, 28 Feb 2010) | 1 line The set types can also be called without arguments. ........ r78522 | ezio.melotti | 2010-03-01 01:59:00 +0200 (Mon, 01 Mar 2010) | 1 line #8030: more docstring fix for builtin types. ........ ................ r78545 | gregory.p.smith | 2010-03-01 05:59:27 +0100 (Mon, 01 Mar 2010) | 9 lines Merged revisions 78544 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78544 | gregory.p.smith | 2010-02-28 20:56:12 -0800 (Sun, 28 Feb 2010) | 2 lines Adds c_ssize_t to ctypes. issue 6729. ........ ................ r78548 | gregory.p.smith | 2010-03-01 06:54:14 +0100 (Mon, 01 Mar 2010) | 10 lines Merged revisions 78546 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78546 | gregory.p.smith | 2010-02-28 21:43:43 -0800 (Sun, 28 Feb 2010) | 3 lines Fixes issue #7999: os.setreuid() and os.setregid() would refuse to accept a -1 parameter on some platforms such as OS X. ........ ................ r78552 | gregory.p.smith | 2010-03-01 07:18:41 +0100 (Mon, 01 Mar 2010) | 15 lines Merged revisions 78527,78550 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78527 | gregory.p.smith | 2010-02-28 17:22:39 -0800 (Sun, 28 Feb 2010) | 4 lines Issue #7242: On Solaris 9 and earlier calling os.fork() from within a thread could raise an incorrect RuntimeError about not holding the import lock. The import lock is now reinitialized after fork. ........ r78550 | gregory.p.smith | 2010-02-28 22:01:02 -0800 (Sun, 28 Feb 2010) | 2 lines Fix test to be skipped on windows. ........ ................ r78556 | gregory.p.smith | 2010-03-01 18:04:45 +0100 (Mon, 01 Mar 2010) | 9 lines Merged revisions 78531 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78531 | gregory.p.smith | 2010-02-28 18:31:33 -0800 (Sun, 28 Feb 2010) | 2 lines Fix for r78527. It left out updating forkpty. ........ ................ r78568 | barry.warsaw | 2010-03-01 22:53:00 +0100 (Mon, 01 Mar 2010) | 5 lines Manually copy patch for bug 7250 from the release26-maint branch. I suck because I did this in the wrong order and couldn't smack svnmerge into submission. ................ r78577 | steven.bethard | 2010-03-02 10:22:57 +0100 (Tue, 02 Mar 2010) | 11 lines Merged revisions 78576 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78576 | steven.bethard | 2010-03-02 00:38:09 -0800 (Tue, 02 Mar 2010) | 3 lines Initial commit of the argparse library, based on argparse 1.1. Docs still need some updating to make getopt and optparse match the wording promised in the PEP. There are also probably a number of :class:ArgumentParser etc. links that could be added to the argparse documentation. ........ ................ r78583 | florent.xicluna | 2010-03-02 17:06:24 +0100 (Tue, 02 Mar 2010) | 9 lines Recorded merge of revisions 78582 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78582 | florent.xicluna | 2010-03-02 17:00:00 +0100 (mar, 02 mar 2010) | 2 lines Refactor test_dict using assertRaises. ........ ................ r78595 | benjamin.peterson | 2010-03-02 23:34:37 +0100 (Tue, 02 Mar 2010) | 37 lines Merged revisions 78586-78593 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78586 | benjamin.peterson | 2010-03-02 16:03:03 -0600 (Tue, 02 Mar 2010) | 1 line remove coding cookie as mandated by PEP 8 ........ r78587 | benjamin.peterson | 2010-03-02 16:05:59 -0600 (Tue, 02 Mar 2010) | 1 line set svn:eol-style ........ r78588 | benjamin.peterson | 2010-03-02 16:08:40 -0600 (Tue, 02 Mar 2010) | 1 line remove another coding cookie ........ r78589 | georg.brandl | 2010-03-02 16:17:38 -0600 (Tue, 02 Mar 2010) | 1 line Add some x-refs. ........ r78590 | benjamin.peterson | 2010-03-02 16:20:10 -0600 (Tue, 02 Mar 2010) | 1 line enable running of argparse tests and fix two that failed in the new environment ........ r78591 | benjamin.peterson | 2010-03-02 16:23:33 -0600 (Tue, 02 Mar 2010) | 1 line prevent warning filter adjustment from altering other tests ........ r78592 | benjamin.peterson | 2010-03-02 16:24:30 -0600 (Tue, 02 Mar 2010) | 1 line use test_main() in __main__ section ........ r78593 | benjamin.peterson | 2010-03-02 16:26:25 -0600 (Tue, 02 Mar 2010) | 1 line convert deprecated fail* methods to assert* variants ........ ................ r78598 | victor.stinner | 2010-03-02 23:48:17 +0100 (Tue, 02 Mar 2010) | 11 lines Merged revisions 78596 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78596 | victor.stinner | 2010-03-02 23:44:42 +0100 (mar., 02 mars 2010) | 4 lines Issue #2973: Fix gcc warning on the 2nd argument of ASN1_item_d2i() and method->d2i(): OpenSSL API changed in OpenSSL 0.9.6m. Patch written by Daniel Black. ........ ................ r78602 | benjamin.peterson | 2010-03-03 00:09:38 +0100 (Wed, 03 Mar 2010) | 13 lines Merged revisions 78600-78601 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78600 | benjamin.peterson | 2010-03-02 16:58:01 -0600 (Tue, 02 Mar 2010) | 1 line remove code to avoid BaseException.message bug ........ r78601 | benjamin.peterson | 2010-03-02 17:02:02 -0600 (Tue, 02 Mar 2010) | 1 line remove cross-version compatibility code ........ ................ r78605 | benjamin.peterson | 2010-03-03 00:46:42 +0100 (Wed, 03 Mar 2010) | 9 lines Merged revisions 78604 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78604 | benjamin.peterson | 2010-03-02 17:43:47 -0600 (Tue, 02 Mar 2010) | 1 line plug ref leaks ........ ................ r78607 | florent.xicluna | 2010-03-03 01:06:37 +0100 (Wed, 03 Mar 2010) | 17 lines Merged revisions 78585,78594,78606 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78585 | florent.xicluna | 2010-03-02 22:34:45 +0100 (mar, 02 mar 2010) | 2 lines Tentatively enable test_pep277 on all platforms. ........ r78594 | florent.xicluna | 2010-03-02 23:34:11 +0100 (mar, 02 mar 2010) | 2 lines Test test_pep277 is only relevant for Unicode-friendly filesystems. ........ r78606 | florent.xicluna | 2010-03-03 00:56:38 +0100 (mer, 03 mar 2010) | 2 lines Fix wording. ........ ................ r78608 | victor.stinner | 2010-03-03 01:18:49 +0100 (Wed, 03 Mar 2010) | 12 lines Merged revisions 78603 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78603 | victor.stinner | 2010-03-03 00:20:02 +0100 (mer., 03 mars 2010) | 5 lines Issue #7820: The parser tokenizer restores all bytes in the right if the BOM check fails. Fix an assertion in pydebug mode. ........ ................ r78611 | victor.stinner | 2010-03-03 01:50:12 +0100 (Wed, 03 Mar 2010) | 10 lines Merged revisions 78610 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78610 | victor.stinner | 2010-03-03 01:43:44 +0100 (mer., 03 mars 2010) | 3 lines Issue #3299: fix thread.allocate_lock() error handler, replace PyObject_Del() by Py_DECREF() to fix a crash in pydebug mode. ........ ................ r78615 | benjamin.peterson | 2010-03-03 03:07:08 +0100 (Wed, 03 Mar 2010) | 13 lines Merged revisions 78613-78614 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78613 | benjamin.peterson | 2010-03-02 19:55:09 -0600 (Tue, 02 Mar 2010) | 1 line edit for style ........ r78614 | benjamin.peterson | 2010-03-02 20:04:24 -0600 (Tue, 02 Mar 2010) | 1 line fix Sphinx warnings ........ ................ r78616 | benjamin.peterson | 2010-03-03 03:09:18 +0100 (Wed, 03 Mar 2010) | 1 line convert to print function ................ r78622 | florent.xicluna | 2010-03-03 12:54:54 +0100 (Wed, 03 Mar 2010) | 9 lines Merged revisions 78620 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78620 | florent.xicluna | 2010-03-03 12:49:53 +0100 (mer, 03 mar 2010) | 2 lines Revert a nonexistent docstring typo, r42805. ........ ................ r78626 | lars.gustaebel | 2010-03-03 13:08:54 +0100 (Wed, 03 Mar 2010) | 10 lines Merged revisions 78623 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78623 | lars.gustaebel | 2010-03-03 12:55:48 +0100 (Wed, 03 Mar 2010) | 3 lines Issue #7232: Add support for the context manager protocol to the TarFile class. ........ ................ r78632 | ezio.melotti | 2010-03-03 21:10:45 +0100 (Wed, 03 Mar 2010) | 1 line Add the argparse module and Steven as its maintainer. ................ r78636 | victor.stinner | 2010-03-03 22:56:53 +0100 (Wed, 03 Mar 2010) | 12 lines Merged revisions 78635 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78635 | victor.stinner | 2010-03-03 22:53:41 +0100 (mer., 03 mars 2010) | 5 lines Issue #3299: fix curses.panel.new_panel() error handler, replace PyObject_DEL() by Py_DECREF() to avoid a crash in pydebug mode. Use po->wo==NULL to detect than the panel is in the lop list or not. ........ ................ r78639 | victor.stinner | 2010-03-04 00:28:07 +0100 (Thu, 04 Mar 2010) | 10 lines Merged revisions 78638 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78638 | victor.stinner | 2010-03-04 00:20:25 +0100 (jeu., 04 mars 2010) | 3 lines Issue #7544: Preallocate thread memory before creating the thread to avoid a fatal error in low memory condition. ........ ................ r78642 | victor.stinner | 2010-03-04 01:29:24 +0100 (Thu, 04 Mar 2010) | 10 lines Merged revisions 78641 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78641 | victor.stinner | 2010-03-04 01:10:12 +0100 (jeu., 04 mars 2010) | 3 lines Issue #7494: fix a crash in _lsprof (cProfile) after clearing the profiler, reset also the pointer to the current pointer context. ........ ................ r78645 | benjamin.peterson | 2010-03-04 03:11:41 +0100 (Thu, 04 Mar 2010) | 9 lines Merged revisions 78644 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78644 | benjamin.peterson | 2010-03-03 20:07:55 -0600 (Wed, 03 Mar 2010) | 1 line set svn:executable on all regen scripts ........ ................ r78647 | victor.stinner | 2010-03-04 13:14:57 +0100 (Thu, 04 Mar 2010) | 12 lines Merged revisions 78646 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78646 | victor.stinner | 2010-03-04 13:09:33 +0100 (jeu., 04 mars 2010) | 5 lines Issue #1054943: Fix unicodedata.normalize('NFC', text) for the Public Review Issue #29. PR #29 was released in february 2004! ........ ................ r78649 | victor.stinner | 2010-03-04 13:47:32 +0100 (Thu, 04 Mar 2010) | 2 lines oops, fix the test of my previous commit about unicodedata and PR #29 (r78647) ................ r78654 | florent.xicluna | 2010-03-04 17:10:10 +0100 (Thu, 04 Mar 2010) | 9 lines Merged revisions 78653 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78653 | florent.xicluna | 2010-03-04 16:58:54 +0100 (jeu, 04 mar 2010) | 2 lines #7805: wait until all workers are started before collecting their PIDs ........ ................ r78655 | florent.xicluna | 2010-03-04 17:10:55 +0100 (Thu, 04 Mar 2010) | 2 lines Missing part from r78654 ................ r78657 | r.david.murray | 2010-03-04 18:38:18 +0100 (Thu, 04 Mar 2010) | 10 lines Merged revisions 78656 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78656 | r.david.murray | 2010-03-04 12:34:05 -0500 (Thu, 04 Mar 2010) | 3 lines Fix documentation of email.Message.get_filename to match the fix applied in Issue 7082. ........ ................ r78663 | florent.xicluna | 2010-03-04 22:50:56 +0100 (Thu, 04 Mar 2010) | 16 lines Merged revisions 78661-78662 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78661 | florent.xicluna | 2010-03-04 20:40:48 +0100 (jeu, 04 mar 2010) | 2 lines Cleanup. ........ r78662 | florent.xicluna | 2010-03-04 22:31:58 +0100 (jeu, 04 mar 2010) | 2 lines #2777: Enable test_send_signal, test_kill and test_terminate on all platforms. ........ And fix an oversight of changeset 78510. ................ r78664 | victor.stinner | 2010-03-04 22:59:53 +0100 (Thu, 04 Mar 2010) | 3 lines Issue #3299: replace PyObject_DEL() by Py_DECREF() in _sre module to fix a crash in pydebug mode. ................ r78670 | tarek.ziade | 2010-03-05 01:36:02 +0100 (Fri, 05 Mar 2010) | 12 lines Blocked revisions 78666-78667 via svnmerge ........ r78666 | tarek.ziade | 2010-03-05 01:16:02 +0100 (Fri, 05 Mar 2010) | 1 line reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged ........ r78667 | tarek.ziade | 2010-03-05 01:29:38 +0100 (Fri, 05 Mar 2010) | 1 line reverted the usage of compiler_obj in Python's setup.py ........ ................ r78672 | florent.xicluna | 2010-03-05 01:52:00 +0100 (Fri, 05 Mar 2010) | 10 lines Merged revisions 78671 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78671 | florent.xicluna | 2010-03-05 01:47:40 +0100 (ven, 05 mar 2010) | 3 lines Workaround #3137: Retry SIGINT if it is not received the first time. test_send_signal should not hang anymore on various Linux distributions. ........ ................ r78674 | florent.xicluna | 2010-03-05 02:07:40 +0100 (Fri, 05 Mar 2010) | 2 lines Remove some debug line... ................ r78676 | florent.xicluna | 2010-03-05 02:18:04 +0100 (Fri, 05 Mar 2010) | 9 lines Merged revisions 78673 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78673 | florent.xicluna | 2010-03-05 02:05:55 +0100 (ven, 05 mar 2010) | 2 lines Let's use assertIsNone / assertIsNotNone. It's hype. ........ ................ r78684 | benjamin.peterson | 2010-03-05 04:27:12 +0100 (Fri, 05 Mar 2010) | 20 lines Merged revisions 78683 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r78683 | benjamin.peterson | 2010-03-04 21:24:17 -0600 (Thu, 04 Mar 2010) | 13 lines Merged revisions 78679,78681 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r78679 | benjamin.peterson | 2010-03-04 21:10:46 -0600 (Thu, 04 Mar 2010) | 1 line set svn:eol-style ........ r78681 | benjamin.peterson | 2010-03-04 21:19:06 -0600 (Thu, 04 Mar 2010) | 1 line remove svn:executable property ........ ................ ................ r78687 | benjamin.peterson | 2010-03-05 04:33:11 +0100 (Fri, 05 Mar 2010) | 17 lines Merged revisions 78678,78680,78682 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78678 | benjamin.peterson | 2010-03-04 21:07:59 -0600 (Thu, 04 Mar 2010) | 1 line set svn:eol-style ........ r78680 | benjamin.peterson | 2010-03-04 21:15:07 -0600 (Thu, 04 Mar 2010) | 1 line set svn:eol-style on Lib files ........ r78682 | benjamin.peterson | 2010-03-04 21:20:06 -0600 (Thu, 04 Mar 2010) | 1 line remove the svn:executable property from files that don't have shebang lines ........ ................ r78689 | ezio.melotti | 2010-03-05 13:43:17 +0100 (Fri, 05 Mar 2010) | 1 line This fixes a missing .lower() on the encoding name, a wrong byte undecodable by UTF-8, a wrong variable name, hopefully some windows buildbot on 3.x and adds a proper skip. It might break other things though. ................ r78691 | mark.dickinson | 2010-03-05 15:41:33 +0100 (Fri, 05 Mar 2010) | 10 lines Blocked revisions 78690 via svnmerge ........ r78690 | mark.dickinson | 2010-03-05 14:36:20 +0000 (Fri, 05 Mar 2010) | 3 lines Fix incorrect stacklevel for DeprecationWarnings originating from the struct module. Also clean up related tests in test_struct. The stacklevel fix should be backported to 2.6 once that branch is unfrozen. ........ ................ r78692 | mark.dickinson | 2010-03-05 15:44:08 +0100 (Fri, 05 Mar 2010) | 1 line Remove unused imports & clean up sys imports in test_struct. ................ r78695 | mark.dickinson | 2010-03-05 15:50:47 +0100 (Fri, 05 Mar 2010) | 8 lines Blocked revisions 78694 via svnmerge ........ r78694 | mark.dickinson | 2010-03-05 14:50:22 +0000 (Fri, 05 Mar 2010) | 1 line Remove the redundant #define: PY_STRUCT_FLOAT_COERCE ........ ................ r78696 | ezio.melotti | 2010-03-05 16:08:19 +0100 (Fri, 05 Mar 2010) | 1 line r78689 enabled the test on more platforms but the buildbot did not like it. Using the filesystem encoding might work better. Also see #5604. ................ r78697 | ezio.melotti | 2010-03-05 16:17:26 +0100 (Fri, 05 Mar 2010) | 1 line sys.getdefaultencoding() can return None. ................ r78698 | gerhard.haering | 2010-03-05 16:20:03 +0100 (Fri, 05 Mar 2010) | 2 lines Merged new pysqlite version 2.6.0 from trunk. ................ r78702 | florent.xicluna | 2010-03-05 21:26:54 +0100 (Fri, 05 Mar 2010) | 9 lines Merged revisions 78701 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78701 | florent.xicluna | 2010-03-05 20:31:21 +0100 (ven, 05 mar 2010) | 2 lines #2777: Handle fds more carefully to try to fix some x86-Linux failures (namely, neal bot and twisted bot). ........ ................ r78705 | florent.xicluna | 2010-03-06 01:19:38 +0100 (Sat, 06 Mar 2010) | 9 lines Merged revisions 78704 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78704 | florent.xicluna | 2010-03-06 01:16:57 +0100 (sam, 06 mar 2010) | 2 lines #2777: Apply same recipe for test_terminate and test_kill, i.e. close or redirect fds. ........ ................ r78708 | ezio.melotti | 2010-03-06 02:20:49 +0100 (Sat, 06 Mar 2010) | 1 line Cleanup and minor fixes. ................ r78711 | ezio.melotti | 2010-03-06 02:50:25 +0100 (Sat, 06 Mar 2010) | 1 line The test was failing because the curdir was missing from sys.path. This should fix the problem. ................ r78715 | tarek.ziade | 2010-03-06 03:30:14 +0100 (Sat, 06 Mar 2010) | 12 lines Blocked revisions 78706,78710 via svnmerge ........ r78706 | tarek.ziade | 2010-03-06 02:04:14 +0100 (Sat, 06 Mar 2010) | 1 line copied back the build_ext tests from 2.6 ........ r78710 | tarek.ziade | 2010-03-06 02:27:09 +0100 (Sat, 06 Mar 2010) | 1 line files used by win32 tests ........ ................ r78723 | florent.xicluna | 2010-03-06 12:43:55 +0100 (Sat, 06 Mar 2010) | 14 lines Merged revisions 78719-78720 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78719 | florent.xicluna | 2010-03-06 09:07:44 +0100 (sam, 06 mar 2010) | 3 lines Keep the test files in the ./build/ subdirectory, if Python is not installed. Remove two hacks which are no longer needed after #7712, because all __file__ attributes are absolute. ........ r78720 | florent.xicluna | 2010-03-06 10:11:55 +0100 (sam, 06 mar 2010) | 2 lines Print platform information to stdout, to help troubleshooting platform-specific failures. ........ ................ r78724 | florent.xicluna | 2010-03-06 12:52:51 +0100 (Sat, 06 Mar 2010) | 9 lines Merged revisions 78721 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78721 | florent.xicluna | 2010-03-06 10:54:14 +0100 (sam, 06 mar 2010) | 2 lines #2777: Apply same recipe on win32, i.e. do not inherit file handles. ........ ................ r78725 | florent.xicluna | 2010-03-06 15:04:16 +0100 (Sat, 06 Mar 2010) | 2 lines Fix test_pydoc when sys.modules["test"] is first imported using importlib.import_module. ................ r78727 | florent.xicluna | 2010-03-06 15:43:34 +0100 (Sat, 06 Mar 2010) | 2 lines Fix TypeError on usage() when using regrtest switches which are not compatible. ................ r78729 | ezio.melotti | 2010-03-06 16:24:08 +0100 (Sat, 06 Mar 2010) | 1 line #6509: fix re.sub to work properly when the pattern, the string, and the replacement were all bytes. Patch by Antoine Pitrou. ................ r78733 | florent.xicluna | 2010-03-06 18:34:48 +0100 (Sat, 06 Mar 2010) | 9 lines Merged revisions 78732 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78732 | florent.xicluna | 2010-03-06 18:24:36 +0100 (sam, 06 mar 2010) | 2 lines Do not print the header lines when running a single test. ........ ................ r78739 | benjamin.peterson | 2010-03-06 21:34:24 +0100 (Sat, 06 Mar 2010) | 10 lines Merged revisions 78718 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78718 | gregory.p.smith | 2010-03-06 01:35:19 -0600 (Sat, 06 Mar 2010) | 3 lines Call setreuid and setregid in a subprocess to avoid altering the test runner's process state. Should fix issue8045. ........ ................ r78745 | benjamin.peterson | 2010-03-06 23:49:30 +0100 (Sat, 06 Mar 2010) | 12 lines Blocked revisions 78738,78743 via svnmerge ........ r78738 | benjamin.peterson | 2010-03-06 14:34:14 -0600 (Sat, 06 Mar 2010) | 1 line bump version to 2.7a4 ........ r78743 | benjamin.peterson | 2010-03-06 16:44:07 -0600 (Sat, 06 Mar 2010) | 1 line post release update ........ ................ r78747 | benjamin.peterson | 2010-03-07 01:03:46 +0100 (Sun, 07 Mar 2010) | 8 lines Blocked revisions 78746 via svnmerge ........ r78746 | benjamin.peterson | 2010-03-06 18:00:37 -0600 (Sat, 06 Mar 2010) | 1 line more specific exception for wrong kind of raise #8082 ........ ................ r78750 | benjamin.peterson | 2010-03-07 01:35:13 +0100 (Sun, 07 Mar 2010) | 8 lines Blocked revisions 78749 via svnmerge ........ r78749 | benjamin.peterson | 2010-03-06 18:29:44 -0600 (Sat, 06 Mar 2010) | 1 line eliminate py3k warnings in argparse ........ ................ r78752 | senthil.kumaran | 2010-03-07 05:12:02 +0100 (Sun, 07 Mar 2010) | 3 lines Reverting the changes made in r78433. ................ r78756 | ronald.oussoren | 2010-03-07 10:14:06 +0100 (Sun, 07 Mar 2010) | 10 lines Merged revisions 78755 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78755 | ronald.oussoren | 2010-03-07 10:04:06 +0100 (Sun, 07 Mar 2010) | 3 lines Fix for issue #7998: pythonw didn't work when --with-framework-name was specified ........ ................ r78763 | mark.dickinson | 2010-03-07 17:25:25 +0100 (Sun, 07 Mar 2010) | 14 lines Blocked revisions 78762 via svnmerge ........ r78762 | mark.dickinson | 2010-03-07 16:24:45 +0000 (Sun, 07 Mar 2010) | 8 lines Issue #1530559: When packing a non-integer with any integer conversion code using struct.pack, attempt to convert to an integer first using the argument's __int__ method (if present). Also raise a DeprecationWarning for any such usage of __int__. This fixes a regression from 2.6, where some (but not all) integer conversion codes already used __int__. ........ ................ r78765 | mark.dickinson | 2010-03-07 18:10:42 +0100 (Sun, 07 Mar 2010) | 8 lines Blocked revisions 78764 via svnmerge ........ r78764 | mark.dickinson | 2010-03-07 17:10:19 +0000 (Sun, 07 Mar 2010) | 1 line Silence compiler warning. ........ ................ r78766 | benjamin.peterson | 2010-03-07 18:10:51 +0100 (Sun, 07 Mar 2010) | 1 line prevent generator finalization from invalidating sys.exc_info() #7173 ................ r78780 | r.david.murray | 2010-03-08 03:17:03 +0100 (Mon, 08 Mar 2010) | 20 lines bdecode was already gone in email 5. This merge adds the test from the trunk patch, and removes the last trace of bdecode, which was a commented out call in message.py. Merged revisions 78778 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78778 | r.david.murray | 2010-03-07 21:04:06 -0500 (Sun, 07 Mar 2010) | 9 lines Issue #7143: get_payload used to strip any trailing newline from a base64 transfer-encoded payload *after* decoding it; it no longer does. email had a special method in utils, _bdecode, specifically to do this, so it must have served a purpose at some point, yet it is clearly wrong per RFC. Fixed with Barry's approval, but no backport. Email package minor version number is bumped, now version 4.0.1. Patch by Joaquin Cuenca Abela. ........ ................ r78782 | ronald.oussoren | 2010-03-08 08:02:03 +0100 (Mon, 08 Mar 2010) | 2 lines Fix for issue 8067 ................ r78786 | ronald.oussoren | 2010-03-08 08:09:59 +0100 (Mon, 08 Mar 2010) | 10 lines Merged revisions 78784 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78784 | ronald.oussoren | 2010-03-08 08:06:47 +0100 (Mon, 08 Mar 2010) | 3 lines Fix for issue 8066: readline should not be linked against libedit when the deployment target is 10.4, libedit on 10.4 is too broken. ........ ................ r78792 | florent.xicluna | 2010-03-08 13:24:53 +0100 (Mon, 08 Mar 2010) | 13 lines Merged revisions 78734-78735 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78734 | florent.xicluna | 2010-03-06 19:07:18 +0100 (sam, 06 mar 2010) | 2 lines Create test_genericpath.CommonTest and reuse it to test other path modules. ........ r78735 | florent.xicluna | 2010-03-06 19:52:52 +0100 (sam, 06 mar 2010) | 2 lines Minor tweaking of previous r78734, and add a NEWS entry. ........ ................ r78793 | florent.xicluna | 2010-03-08 13:25:35 +0100 (Mon, 08 Mar 2010) | 2 lines Fix macpath to deal with bytes ................ r78795 | florent.xicluna | 2010-03-08 13:42:20 +0100 (Mon, 08 Mar 2010) | 2 lines Merge other tests from test_*path.py into test_genericpath.CommonTest, and do some cleanup. ................ r78796 | florent.xicluna | 2010-03-08 13:47:44 +0100 (Mon, 08 Mar 2010) | 2 lines Fix string-> bytes conversion on backport from 2.x. ................ r78797 | florent.xicluna | 2010-03-08 14:27:26 +0100 (Mon, 08 Mar 2010) | 30 lines Merged revisions 78736,78759,78761,78767,78788-78789 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78736 | florent.xicluna | 2010-03-06 20:43:41 +0100 (sam, 06 mar 2010) | 2 lines Skip test_send_signal, test_kill, test_terminate on win32 platforms, for 2.7a4 release. ........ r78759 | florent.xicluna | 2010-03-07 13:21:36 +0100 (dim, 07 mar 2010) | 2 lines #2777: Enable test_send_signal, test_terminate and test_kill on win32 platforms. ........ r78761 | florent.xicluna | 2010-03-07 16:27:39 +0100 (dim, 07 mar 2010) | 4 lines Do not fail if returncode is 0 on send_signal/kill/terminate, for win32 platforms. Do not hide the KeyboardInterrupt on POSIX platforms. ........ r78767 | florent.xicluna | 2010-03-07 18:12:23 +0100 (dim, 07 mar 2010) | 2 lines #2777: Try hard to make Win7 buildbot happy... ........ r78788 | florent.xicluna | 2010-03-08 11:58:12 +0100 (lun, 08 mar 2010) | 2 lines Fix syntax: "rc != None" -> "rc is not None" ........ r78789 | florent.xicluna | 2010-03-08 11:59:33 +0100 (lun, 08 mar 2010) | 2 lines Replace the stderr logging with assertNotEqual(returncode, 0). ........ ................ r78798 | florent.xicluna | 2010-03-08 14:32:17 +0100 (Mon, 08 Mar 2010) | 18 lines Merged revisions 78777,78787,78790 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78777 | florent.xicluna | 2010-03-08 00:49:03 +0100 (lun, 08 mar 2010) | 4 lines Backport the Popen.poll() protection from subprocess to multiprocessing. See #1731717. It should fix transient failures on test_multiprocessing. ........ r78787 | florent.xicluna | 2010-03-08 08:21:16 +0100 (lun, 08 mar 2010) | 2 lines Don't fail on a debug() statement, if the worker PID is (still) None. ........ r78790 | florent.xicluna | 2010-03-08 12:01:39 +0100 (lun, 08 mar 2010) | 2 lines On finalize, don't try to join not started process. ........ ................ r78799 | florent.xicluna | 2010-03-08 15:44:41 +0100 (Mon, 08 Mar 2010) | 2 lines Fix ntpath abspath to deal with bytes. ................ r78801 | florent.xicluna | 2010-03-08 16:34:35 +0100 (Mon, 08 Mar 2010) | 11 lines Backport the tests only. Merged revisions 78800 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78800 | florent.xicluna | 2010-03-08 16:20:28 +0100 (lun, 08 mar 2010) | 2 lines #7624: Fix isinstance(foo(), collections.Callable) for old-style classes. ........ ................ r78803 | r.david.murray | 2010-03-08 18:16:58 +0100 (Mon, 08 Mar 2010) | 12 lines Blocked revisions 78558 via svnmerge ........ r78558 | r.david.murray | 2010-03-01 14:14:16 -0500 (Mon, 01 Mar 2010) | 6 lines Issue 3892 again. The bsddb3 replication test still fails randomly. Since this module is unmaintained in the library and gone in py3k, this patch skips the remainder of the replication test if a second timeout occurs, as it randomly does. This should improve buildbot stability. ........ ................ r78804 | r.david.murray | 2010-03-08 18:48:38 +0100 (Mon, 08 Mar 2010) | 13 lines Merged revisions 78416,78430 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78416 | dirkjan.ochtman | 2010-02-23 23:12:11 -0500 (Tue, 23 Feb 2010) | 1 line Issue #8004: add a serve target to the Doc Makefile. ........ r78430 | dirkjan.ochtman | 2010-02-24 12:06:31 -0500 (Wed, 24 Feb 2010) | 1 line Add some notes about Tools/scripts/serve.py. ........ ................ r78807 | benjamin.peterson | 2010-03-08 23:17:58 +0100 (Mon, 08 Mar 2010) | 9 lines Merged revisions 78806 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78806 | benjamin.peterson | 2010-03-08 16:15:11 -0600 (Mon, 08 Mar 2010) | 1 line set svn:eol-style on various files ........ ................ r78808 | ronald.oussoren | 2010-03-09 07:40:19 +0100 (Tue, 09 Mar 2010) | 2 lines Bugfix for the fix for issue 8067 ................ r78818 | benjamin.peterson | 2010-03-09 22:46:49 +0100 (Tue, 09 Mar 2010) | 9 lines Merged revisions 78817 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78817 | benjamin.peterson | 2010-03-09 15:43:36 -0600 (Tue, 09 Mar 2010) | 1 line handle an empty OPT variable correctly #8100 ........ ................ r78821 | benjamin.peterson | 2010-03-09 22:49:52 +0100 (Tue, 09 Mar 2010) | 9 lines Merged revisions 78819 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78819 | benjamin.peterson | 2010-03-09 15:46:54 -0600 (Tue, 09 Mar 2010) | 1 line fix ugly configure output (follow up to #6943) ........ ................ r78829 | florent.xicluna | 2010-03-11 01:05:17 +0100 (Thu, 11 Mar 2010) | 9 lines Merged revisions 78828 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78828 | florent.xicluna | 2010-03-11 00:58:42 +0100 (jeu, 11 mar 2010) | 2 lines Issue #7880: Fix sysconfig when the python executable is a symbolic link. ........ ................ r78831 | florent.xicluna | 2010-03-11 02:00:26 +0100 (Thu, 11 Mar 2010) | 10 lines Merged revisions 78830 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78830 | florent.xicluna | 2010-03-11 01:56:59 +0100 (jeu, 11 mar 2010) | 3 lines Fix the test_subprocess failure when sys.executable is meaningless: '' or a directory. It does not fix #7774. ........ ................ r78834 | florent.xicluna | 2010-03-11 02:53:10 +0100 (Thu, 11 Mar 2010) | 9 lines Merged revisions 78833 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78833 | florent.xicluna | 2010-03-11 02:50:48 +0100 (jeu, 11 mar 2010) | 2 lines Revert r78830: realpath() should really be applied to sys.executable. ........ ................ r78843 | benjamin.peterson | 2010-03-11 22:55:56 +0100 (Thu, 11 Mar 2010) | 13 lines Merged revisions 78841-78842 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78841 | benjamin.peterson | 2010-03-11 15:50:45 -0600 (Thu, 11 Mar 2010) | 1 line remove executable property from doc files ........ r78842 | benjamin.peterson | 2010-03-11 15:53:25 -0600 (Thu, 11 Mar 2010) | 1 line use proper shebang lines ........ ................ r78845 | benjamin.peterson | 2010-03-11 23:05:58 +0100 (Thu, 11 Mar 2010) | 9 lines Merged revisions 78844 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78844 | benjamin.peterson | 2010-03-11 16:03:45 -0600 (Thu, 11 Mar 2010) | 1 line revert r78842 cgi.py change ........ ................ r78848 | benjamin.peterson | 2010-03-11 23:36:36 +0100 (Thu, 11 Mar 2010) | 8 lines Blocked revisions 78846 via svnmerge ........ r78846 | benjamin.peterson | 2010-03-11 16:33:25 -0600 (Thu, 11 Mar 2010) | 1 line normalize shebang lines to #!/usr/bin/env python ........ ................ r78849 | benjamin.peterson | 2010-03-11 23:40:40 +0100 (Thu, 11 Mar 2010) | 9 lines Merged revisions 78847 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78847 | benjamin.peterson | 2010-03-11 16:34:12 -0600 (Thu, 11 Mar 2010) | 1 line remove shebang line from non-executable test ........ ................ r78850 | benjamin.peterson | 2010-03-11 23:53:45 +0100 (Thu, 11 Mar 2010) | 1 line convert shebang lines: python -> python3 ................ r78851 | benjamin.peterson | 2010-03-12 00:39:40 +0100 (Fri, 12 Mar 2010) | 1 line fix bootstrapping on machines with only 2.x installed ................ r78852 | benjamin.peterson | 2010-03-12 00:59:55 +0100 (Fri, 12 Mar 2010) | 1 line take into account shebang line change ................ r78861 | georg.brandl | 2010-03-12 11:04:37 +0100 (Fri, 12 Mar 2010) | 1 line Make tool compatible with 2.x and 3.x. ................ r78862 | georg.brandl | 2010-03-12 11:06:40 +0100 (Fri, 12 Mar 2010) | 13 lines Merged revisions 78859-78860 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78859 | georg.brandl | 2010-03-12 10:57:43 +0100 (Fr, 12 M??r 2010) | 1 line Get rid of backticks. ........ r78860 | georg.brandl | 2010-03-12 11:02:03 +0100 (Fr, 12 M??r 2010) | 1 line Fix warnings from "make check". ........ ................ r78863 | georg.brandl | 2010-03-12 11:07:31 +0100 (Fri, 12 Mar 2010) | 15 lines Commit merge properties (missing from r78862). Merged revisions 78859-78860 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78859 | georg.brandl | 2010-03-12 10:57:43 +0100 (Fr, 12 M??r 2010) | 1 line Get rid of backticks. ........ r78860 | georg.brandl | 2010-03-12 11:02:03 +0100 (Fr, 12 M??r 2010) | 1 line Fix warnings from "make check". ........ ................ r78868 | victor.stinner | 2010-03-12 15:20:59 +0100 (Fri, 12 Mar 2010) | 25 lines Merged revisions 78835-78837 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78835 | victor.stinner | 2010-03-11 13:34:39 +0100 (jeu., 11 mars 2010) | 7 lines Issue #7774: Set sys.executable to an empty string if argv[0] has been set to an non existent program name and Python is unable to retrieve the real program name. Fix also sysconfig: if sys.executable is an empty string, use the current working directory. ........ r78836 | victor.stinner | 2010-03-11 14:27:35 +0100 (jeu., 11 mars 2010) | 4 lines Fix test_executable introduce in previous commit (r78835): Windows is able to retrieve the absolute Python path even if argv[0] has been set to a non existent program name. ........ r78837 | victor.stinner | 2010-03-11 14:46:06 +0100 (jeu., 11 mars 2010) | 3 lines Another fix to test_executable() of test_sys: set the current working to avoid the #7774 bug. ........ ................ r78869 | victor.stinner | 2010-03-12 15:27:16 +0100 (Fri, 12 Mar 2010) | 2 lines Oops, I loose the NEWS change in my previous backport (r78868) of r78835. ................ r78871 | victor.stinner | 2010-03-12 15:31:06 +0100 (Fri, 12 Mar 2010) | 8 lines Blocked revisions 78870 via svnmerge ........ r78870 | victor.stinner | 2010-03-12 15:30:26 +0100 (ven., 12 mars 2010) | 1 line NEWS: issue #7774 is related to Library (sys), not Core and Builtins ........ ................ r78872 | victor.stinner | 2010-03-12 15:45:56 +0100 (Fri, 12 Mar 2010) | 12 lines Merged revisions 78826 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78826 | victor.stinner | 2010-03-10 23:30:19 +0100 (mer., 10 mars 2010) | 5 lines Issue #3137: Don't ignore errors at startup, especially a keyboard interrupt (SIGINT). If an error occurs while importing the site module, the error is printed and Python exits. Initialize the GIL before importing the site module. ........ ................ r78873 | victor.stinner | 2010-03-12 15:47:28 +0100 (Fri, 12 Mar 2010) | 10 lines Blocked revisions 78827 via svnmerge ........ r78827 | victor.stinner | 2010-03-10 23:45:04 +0100 (mer., 10 mars 2010) | 4 lines ooops, fix error message in execusercustomize() Copy/paste failure :-) ........ ................ r78875 | victor.stinner | 2010-03-12 18:00:41 +0100 (Fri, 12 Mar 2010) | 5 lines Issue #6697: use %U format instead of _PyUnicode_AsString(), because _PyUnicode_AsString() was not checked for error (NULL). The unicode string is no more truncated to 200 or 400 *bytes*. ................ r78876 | victor.stinner | 2010-03-12 18:17:58 +0100 (Fri, 12 Mar 2010) | 3 lines Issue #6697: catch _PyUnicode_AsString() errors in getattr() and setattr() builtin functions. ................ r78882 | georg.brandl | 2010-03-12 22:29:28 +0100 (Fri, 12 Mar 2010) | 9 lines Merged revisions 78880 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78880 | georg.brandl | 2010-03-12 22:27:23 +0100 (Fr, 12 M??r 2010) | 1 line Deactivate automatic upload of the docs to python.org, they will now be built by a job on that machine. ........ ................ r78884 | ezio.melotti | 2010-03-12 23:45:38 +0100 (Fri, 12 Mar 2010) | 1 line #8057: fix strings -> byte strings ................ r78888 | victor.stinner | 2010-03-13 01:19:17 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78886 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78886 | victor.stinner | 2010-03-13 01:13:22 +0100 (sam., 13 mars 2010) | 2 lines Issue #7818: set().test_c_api() doesn't expect a set('abc'), modify the set. ........ ................ r78891 | ezio.melotti | 2010-03-13 01:26:04 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78887 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78887 | ezio.melotti | 2010-03-13 02:15:36 +0200 (Sat, 13 Mar 2010) | 1 line fix broken links ........ ................ r78893 | ezio.melotti | 2010-03-13 01:39:49 +0100 (Sat, 13 Mar 2010) | 11 lines Fix wrong indentation that was causing a Sphinx warning and a typo. Merged revisions 78112 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78112 | ezio.melotti | 2010-02-09 00:22:41 +0200 (Tue, 09 Feb 2010) | 1 line Fix typo ........ ................ r78894 | victor.stinner | 2010-03-13 01:57:22 +0100 (Sat, 13 Mar 2010) | 4 lines sqlite3: Fix _PyUnicode_AsStringAndSize() error handler. Destroy begin_statement (not statement) on error. ................ r78896 | ezio.melotti | 2010-03-13 02:28:34 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78895 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78895 | ezio.melotti | 2010-03-13 03:21:34 +0200 (Sat, 13 Mar 2010) | 1 line #8011: use exc.tb_lineno instead of traceback.tb_lineno() and pep8ify variable names. ........ ................ r78899 | victor.stinner | 2010-03-13 04:28:34 +0100 (Sat, 13 Mar 2010) | 14 lines Merged revisions 78898 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78898 | victor.stinner | 2010-03-13 04:27:07 +0100 (sam., 13 mars 2010) | 7 lines sqlite3: Fix a segfault on calling a connection with something else than a string. Initialize all attributes to be able to call the statement destructor on error. Avoid also a duplicate connection in some tests: setUp() does already open a connection (":memory:"). ........ ................ r78901 | ezio.melotti | 2010-03-13 05:42:07 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78900 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78900 | ezio.melotti | 2010-03-13 06:39:51 +0200 (Sat, 13 Mar 2010) | 1 line Silence compiler warnings. ........ ................ r78902 | mark.dickinson | 2010-03-13 10:48:39 +0100 (Sat, 13 Mar 2010) | 2 lines Issue #7845: Make 1j.__le__(2j) return NotImplemented rather than raising TypeError. ................ r78911 | georg.brandl | 2010-03-13 11:56:09 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78910 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78910 | georg.brandl | 2010-03-13 11:54:12 +0100 (Sa, 13 M??r 2010) | 1 line Bump externals versions for doc build. ........ ................ r78915 | georg.brandl | 2010-03-13 12:02:07 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78908 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78908 | georg.brandl | 2010-03-13 11:12:39 +0100 (Sa, 13 M??r 2010) | 1 line Add Makefile targets for automatic doc build. Add script that will be used for daily build. ........ ................ r78918 | mark.dickinson | 2010-03-13 12:34:40 +0100 (Sat, 13 Mar 2010) | 4 lines Issue #8014: Fix PyLong_As methods not to produce an internal error on non-integer input: they now raise TypeError instead. This is needed for attributes declared via PyMemberDefs. ................ r78920 | mark.dickinson | 2010-03-13 14:23:05 +0100 (Sat, 13 Mar 2010) | 3 lines Issue #8014: Fix incorrect error checks in structmember.c, and re-enable previously failing test_structmember.py tests. ................ r78924 | georg.brandl | 2010-03-13 14:42:16 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78921 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78921 | georg.brandl | 2010-03-13 14:39:46 +0100 (Sa, 13 M??r 2010) | 1 line Change/fix handling of docs download location: for daily builds, put them right next to the HTML. ........ ................ r78927 | mark.dickinson | 2010-03-13 15:24:41 +0100 (Sat, 13 Mar 2010) | 8 lines Blocked revisions 78926 via svnmerge ........ r78926 | mark.dickinson | 2010-03-13 14:18:34 +0000 (Sat, 13 Mar 2010) | 1 line Fix incorrect error checks in structmember.c (backport of r78920 from py3k). ........ ................ r78929 | florent.xicluna | 2010-03-13 16:26:44 +0100 (Sat, 13 Mar 2010) | 24 lines Only the parts which are relevant for 3.x branch. Merged revisions 78757-78758,78769,78815 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78757 | florent.xicluna | 2010-03-07 13:14:25 +0100 (dim, 07 mar 2010) | 2 lines Fix some py3k warnings in the standard library. ........ r78758 | florent.xicluna | 2010-03-07 13:18:33 +0100 (dim, 07 mar 2010) | 4 lines Issue #7849: Now the utility ``check_warnings`` verifies if the warnings are effectively raised. A new utility ``check_py3k_warnings`` deals with py3k warnings. ........ r78769 | florent.xicluna | 2010-03-07 20:14:12 +0100 (dim, 07 mar 2010) | 2 lines Refresh the documentation for the test.test_support module. ........ r78815 | florent.xicluna | 2010-03-09 20:57:01 +0100 (mar, 09 mar 2010) | 2 lines #7772: Fix test_py3kwarn. Now the test suite could pass with "-3" flag. ........ ................ r78930 | florent.xicluna | 2010-03-13 16:35:12 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78832 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78832 | florent.xicluna | 2010-03-11 02:39:55 +0100 (jeu, 11 mar 2010) | 2 lines It is not optimal to test sys.stderr on a debug build. ........ ................ r78933 | martin.v.loewis | 2010-03-13 18:55:57 +0100 (Sat, 13 Mar 2010) | 9 lines Merged revisions 78932 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78932 | martin.v.loewis | 2010-03-13 18:53:02 +0100 (Sa, 13 M??r 2010) | 2 lines Add 2.6 uuids. ........ ................ r78938 | benjamin.peterson | 2010-03-13 22:20:06 +0100 (Sat, 13 Mar 2010) | 80 lines Blocked revisions 77942,78053,78061,78113-78114,78150,78215,78247,78385,78467,78563,78652,78726,78751,78812,78814 via svnmerge ........ r77942 | ezio.melotti | 2010-02-02 23:37:26 -0600 (Tue, 02 Feb 2010) | 1 line #7092: Silence more py3k warnings. Patch by Florent Xicluna. ........ r78053 | georg.brandl | 2010-02-06 17:54:43 -0600 (Sat, 06 Feb 2010) | 1 line Fix some name errors in Mac modules. ........ r78061 | ronald.oussoren | 2010-02-07 05:38:28 -0600 (Sun, 07 Feb 2010) | 10 lines A number of APIs in macostools cannot work in 64-bit mode because they use Carbon APIs that aren't available there. This patch disables tests for the affected entrypoints in macostools and mentions this in the documentation. In theory it is possible to replace the implementation by code that does work in 64-bit mode, but that would require further updates to the Carbon wrappers because the modern APIs aren't wrapped properly. ........ r78113 | georg.brandl | 2010-02-08 16:37:20 -0600 (Mon, 08 Feb 2010) | 1 line Fix missing string formatting argument. ........ r78114 | georg.brandl | 2010-02-08 16:37:52 -0600 (Mon, 08 Feb 2010) | 1 line Fix undefined local. ........ r78150 | ronald.oussoren | 2010-02-11 07:19:34 -0600 (Thu, 11 Feb 2010) | 3 lines Fix copy&paste error in the definition of ARCH_RUN_32BIT for a 3-way universal build (all other definition where correct). ........ r78215 | martin.v.loewis | 2010-02-18 06:45:45 -0600 (Thu, 18 Feb 2010) | 1 line Move bsddb47 macros before their use, to make VS 2010 happy. ........ r78247 | ezio.melotti | 2010-02-20 02:09:39 -0600 (Sat, 20 Feb 2010) | 1 line #3426: os.path.abspath now returns unicode when its arg is unicode. ........ r78385 | georg.brandl | 2010-02-23 15:33:17 -0600 (Tue, 23 Feb 2010) | 1 line #8000: fix deprecated directive. What a shame to lose that glorious issue number to such a minor bug :) ........ r78467 | ezio.melotti | 2010-02-26 18:05:42 -0600 (Fri, 26 Feb 2010) | 1 line Show an error when the value passed to --enable-unicode is not ucs2 or ucs4 (lowercase). ........ r78563 | florent.xicluna | 2010-03-01 14:45:01 -0600 (Mon, 01 Mar 2010) | 2 lines #7808: Fix reference leaks in _bsddb and related tests. ........ r78652 | florent.xicluna | 2010-03-04 09:57:20 -0600 (Thu, 04 Mar 2010) | 2 lines Fix transient refleak in test_popen2. ........ r78726 | florent.xicluna | 2010-03-06 08:38:09 -0600 (Sat, 06 Mar 2010) | 2 lines Backport "test.regrtest -R 2:3" syntax from py3k branch, and other minor adjustments. ........ r78751 | senthil.kumaran | 2010-03-06 22:09:30 -0600 (Sat, 06 Mar 2010) | 3 lines Reverting the change made in r78431. ........ r78812 | raymond.hettinger | 2010-03-09 03:58:53 -0600 (Tue, 09 Mar 2010) | 6 lines Have links in OrderedDicts be native Python lists instead of a custom class with __slots__. This simplifies the code a bit, reduces memory consumption, improves speed, and eliminates the need for weak reference proxies. ........ r78814 | raymond.hettinger | 2010-03-09 05:29:10 -0600 (Tue, 09 Mar 2010) | 1 line Improve code clarity a bit. ........ ................ r78940 | antoine.pitrou | 2010-03-13 22:27:21 +0100 (Sat, 13 Mar 2010) | 11 lines Merged revisions 78939 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78939 | antoine.pitrou | 2010-03-13 22:21:30 +0100 (Sat, 13 Mar 2010) | 5 lines Issue #7993: Add a test of IO packet processing bandwidth to ccbench. It measures the number of UDP packets processed per second depending on the number of background CPU-bound Python threads. ........ ................ r78941 | benjamin.peterson | 2010-03-13 23:30:34 +0100 (Sat, 13 Mar 2010) | 97 lines Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line Logging: Implemented PEP 391. ........ r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line Removed spurious print statement. ........ r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line Issue #7851: logging: clarification on logging configuration files. ........ r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line Added unit test for cfg:// resolution. ........ r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line Issue #7857: test_logging: listener test now uses find_unused_port(). ........ r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line Issue #7857: test_logging: listener tests disabled for now. ........ r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line test_logging: minor tweaks to timeouts, listening tests marked as skipped. ........ r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line Issue #7857: Tentatively re-enabling one test to see effect on buildbots. ........ r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test. ........ r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line Remove unused imports from test_logging. ........ r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line make waiting for the server to start robust ........ r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code. ........ r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line logging: Removed some more 1.5.2 support code. ........ r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line Removed spurious print statement in test. ........ r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line logging: skipped listening tests because they're not working reliably. ........ r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line Issue #7857: Another attempt to keep the buildbots happy. ........ r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line logging: gingerly re-enabling skipped tests after improving thread sync code in configurator. ........ r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line logging: Documented warnings module integration. ........ r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future. ........ r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line Added schema version test in dictConfig. ........ r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line Added checks for tuples in dictConfig. ........ r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line Issue #8117: logging: Improved algorithm for computing initial rollover time. ........ r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line Issue #8117: Updated NEWS entry and added to logging documentation. ........ ................ r78942 | florent.xicluna | 2010-03-14 00:24:31 +0100 (Sun, 14 Mar 2010) | 30 lines Merged revisions 78838-78839,78917,78919,78934,78937 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78838 | florent.xicluna | 2010-03-11 15:36:19 +0100 (jeu, 11 mar 2010) | 2 lines Issue #6472: The xml.etree package is updated to ElementTree 1.3. The cElementTree module is updated too. ........ r78839 | florent.xicluna | 2010-03-11 16:55:11 +0100 (jeu, 11 mar 2010) | 2 lines Fix repr of tree Element on windows. ........ r78917 | florent.xicluna | 2010-03-13 12:18:49 +0100 (sam, 13 mar 2010) | 2 lines Move the xml test data to their own directory. ........ r78919 | florent.xicluna | 2010-03-13 13:41:48 +0100 (sam, 13 mar 2010) | 2 lines Do not chdir when running test_xml_etree, and enhance the findfile helper. ........ r78934 | florent.xicluna | 2010-03-13 18:56:19 +0100 (sam, 13 mar 2010) | 2 lines Update some parts of the xml.etree documentation. ........ r78937 | florent.xicluna | 2010-03-13 21:30:15 +0100 (sam, 13 mar 2010) | 3 lines Add the keyword argument "method=None" to the .write() method and the tostring/tostringlist functions. Update the function, class and method signatures, according to the new convention. ........ ................ r78943 | benjamin.peterson | 2010-03-14 01:07:01 +0100 (Sun, 14 Mar 2010) | 9 lines Merged revisions 78055 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78055 | vinay.sajip | 2010-02-06 19:37:08 -0600 (Sat, 06 Feb 2010) | 1 line Issue #7868: logging: added loggerClass attribute to Manager. ........ ................ r78945 | florent.xicluna | 2010-03-14 02:28:07 +0100 (Sun, 14 Mar 2010) | 9 lines Merged revisions 78944 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78944 | florent.xicluna | 2010-03-14 02:22:09 +0100 (dim, 14 mar 2010) | 2 lines Minor documentation updates for xml.etree. ........ ................ r78946 | gregory.p.smith | 2010-03-14 07:49:55 +0100 (Sun, 14 Mar 2010) | 14 lines * Replaces the internals of the subprocess module from fork through exec on POSIX systems with a C extension module. This is required in order for the subprocess module to be made thread safe. The pure python implementation is retained so that it can continue to be used if for some reason the _posixsubprocess extension module is not available. The unittest executes tests on both code paths to guarantee compatibility. * Moves PyLong_FromPid and PyLong_AsPid from posixmodule.c into longobject.h. Code reviewed by jeffrey.yasskin at http://codereview.appspot.com/223077/show ................ r78947 | gregory.p.smith | 2010-03-14 07:52:18 +0100 (Sun, 14 Mar 2010) | 2 lines NEWS entry for subprocess module C extension in r78946. ................ r78948 | gregory.p.smith | 2010-03-14 08:13:25 +0100 (Sun, 14 Mar 2010) | 2 lines More notes about r78946, this time describing the restore_signals behavior. ................ r78950 | ezio.melotti | 2010-03-14 10:51:37 +0100 (Sun, 14 Mar 2010) | 1 line #7057: fix several errors. ................ r78955 | georg.brandl | 2010-03-14 11:23:39 +0100 (Sun, 14 Mar 2010) | 97 lines Merged revisions 78018,78035-78040,78042-78043,78046,78048-78052,78054,78059,78075-78080 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78018 | georg.brandl | 2010-02-06 11:08:21 +0100 (Sa, 06 Feb 2010) | 1 line #7864: make deprecation notices a bit clearer. ........ r78035 | georg.brandl | 2010-02-06 23:44:17 +0100 (Sa, 06 Feb 2010) | 1 line Fix duplicate import. ........ r78036 | georg.brandl | 2010-02-06 23:49:47 +0100 (Sa, 06 Feb 2010) | 1 line Remove unused import. ........ r78037 | georg.brandl | 2010-02-06 23:59:15 +0100 (Sa, 06 Feb 2010) | 1 line No need to assign the results of expressions used only for side effects. ........ r78038 | georg.brandl | 2010-02-07 00:02:29 +0100 (So, 07 Feb 2010) | 1 line Add a missing import. ........ r78039 | georg.brandl | 2010-02-07 00:06:24 +0100 (So, 07 Feb 2010) | 1 line Add missing imports. ........ r78040 | georg.brandl | 2010-02-07 00:08:00 +0100 (So, 07 Feb 2010) | 1 line Fix a few UnboundLocalErrors in test_long. ........ r78042 | georg.brandl | 2010-02-07 00:12:12 +0100 (So, 07 Feb 2010) | 1 line Add missing import. ........ r78043 | georg.brandl | 2010-02-07 00:12:19 +0100 (So, 07 Feb 2010) | 1 line Remove duplicate test method. ........ r78046 | georg.brandl | 2010-02-07 00:18:00 +0100 (So, 07 Feb 2010) | 1 line Fix various missing import/unbound name errors. ........ r78048 | georg.brandl | 2010-02-07 00:23:45 +0100 (So, 07 Feb 2010) | 1 line We heard you like test failures so we put unbound locals in your test so that you can fail while you fail. ........ r78049 | georg.brandl | 2010-02-07 00:33:33 +0100 (So, 07 Feb 2010) | 1 line Fix import/access for some identifiers. _TestSharedCTypes does not seem to be executed? ........ r78050 | georg.brandl | 2010-02-07 00:34:10 +0100 (So, 07 Feb 2010) | 1 line Fix more unbound locals in code paths that do not seem to be used. ........ r78051 | georg.brandl | 2010-02-07 00:53:52 +0100 (So, 07 Feb 2010) | 1 line Add missing import when running these tests standalone. ........ r78052 | georg.brandl | 2010-02-07 00:54:04 +0100 (So, 07 Feb 2010) | 1 line Add missing import when running these tests standalone. ........ r78054 | georg.brandl | 2010-02-07 00:58:25 +0100 (So, 07 Feb 2010) | 1 line Add missing import. ........ r78059 | georg.brandl | 2010-02-07 12:34:15 +0100 (So, 07 Feb 2010) | 1 line Use "regexp" consistently. ........ r78075 | georg.brandl | 2010-02-07 13:16:12 +0100 (So, 07 Feb 2010) | 1 line Fix another duplicated test method. ........ r78076 | georg.brandl | 2010-02-07 13:19:43 +0100 (So, 07 Feb 2010) | 1 line Fix wrong usage of "except X, Y:". ........ r78077 | georg.brandl | 2010-02-07 13:25:50 +0100 (So, 07 Feb 2010) | 1 line Fix two redefined test methods. ........ r78078 | georg.brandl | 2010-02-07 13:27:06 +0100 (So, 07 Feb 2010) | 1 line Fix a redefined test method. ........ r78079 | georg.brandl | 2010-02-07 13:34:26 +0100 (So, 07 Feb 2010) | 1 line Add a minimal test for fnmatchcase(). ........ r78080 | georg.brandl | 2010-02-07 13:55:12 +0100 (So, 07 Feb 2010) | 1 line Remove duplicate test method. ........ ................ r78956 | georg.brandl | 2010-03-14 11:24:29 +0100 (Sun, 14 Mar 2010) | 8 lines Blocked revisions 78949 via svnmerge ........ r78949 | georg.brandl | 2010-03-14 10:50:54 +0100 (So, 14 M??r 2010) | 1 line Format and rewrap 2.7 NEWS consistently. ........ ................ r78957 | georg.brandl | 2010-03-14 11:45:50 +0100 (Sun, 14 Mar 2010) | 9 lines Merged revisions 78093 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78093 | georg.brandl | 2010-02-07 18:03:15 +0100 (So, 07 Feb 2010) | 1 line Remove unused imports in test modules. ........ ................ r78958 | georg.brandl | 2010-03-14 11:51:01 +0100 (Sun, 14 Mar 2010) | 37 lines Merged revisions 78101,78115,78117,78182,78188,78245,78386,78496 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78101 | georg.brandl | 2010-02-08 01:04:54 +0100 (Mo, 08 Feb 2010) | 1 line Fix test_fnmatch. ........ r78115 | georg.brandl | 2010-02-08 23:40:51 +0100 (Mo, 08 Feb 2010) | 1 line Fix missing string formatting placeholder. ........ r78117 | georg.brandl | 2010-02-08 23:48:37 +0100 (Mo, 08 Feb 2010) | 1 line Convert test failure from output-producing to self.fail(). ........ r78182 | georg.brandl | 2010-02-14 09:18:23 +0100 (So, 14 Feb 2010) | 1 line #7926: fix stray parens. ........ r78188 | georg.brandl | 2010-02-14 14:38:12 +0100 (So, 14 Feb 2010) | 1 line #7926: fix-up wording. ........ r78245 | georg.brandl | 2010-02-19 20:36:08 +0100 (Fr, 19 Feb 2010) | 1 line #7967: PyXML is no more. ........ r78386 | georg.brandl | 2010-02-23 22:48:57 +0100 (Di, 23 Feb 2010) | 1 line #6544: fix refleak in kqueue, occurring in certain error conditions. ........ r78496 | georg.brandl | 2010-02-27 15:58:08 +0100 (Sa, 27 Feb 2010) | 1 line Link to http://www.python.org/dev/workflow/ from bugs page. ........ ................ r78959 | georg.brandl | 2010-03-14 11:56:14 +0100 (Sun, 14 Mar 2010) | 33 lines Merged revisions 78760,78771-78773,78802,78922,78952 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78760 | georg.brandl | 2010-03-07 16:23:59 +0100 (So, 07 M??r 2010) | 1 line #5341: more built-in vs builtin fixes. ........ r78771 | georg.brandl | 2010-03-07 21:58:31 +0100 (So, 07 M??r 2010) | 1 line #8085: The function is called PyObject_NewVar, not PyObject_VarNew. ........ r78772 | georg.brandl | 2010-03-07 22:12:28 +0100 (So, 07 M??r 2010) | 1 line #8039: document conditional expressions better, giving them their own section. ........ r78773 | georg.brandl | 2010-03-07 22:32:06 +0100 (So, 07 M??r 2010) | 1 line #8044: document Py_{Enter,Leave}RecursiveCall functions. ........ r78802 | georg.brandl | 2010-03-08 17:28:40 +0100 (Mo, 08 M??r 2010) | 1 line Fix typo. ........ r78922 | georg.brandl | 2010-03-13 14:41:58 +0100 (Sa, 13 M??r 2010) | 1 line Update for new download location. ........ r78952 | georg.brandl | 2010-03-14 10:55:08 +0100 (So, 14 M??r 2010) | 1 line #8137: add iso-8859-16 to the standard encodings table. ........ ................ r78960 | ezio.melotti | 2010-03-14 12:51:00 +0100 (Sun, 14 Mar 2010) | 9 lines Merged revisions 78954 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78954 | ezio.melotti | 2010-03-14 12:13:49 +0200 (Sun, 14 Mar 2010) | 1 line Add a link about the Public Review Issue #29 ........ ................ r78961 | florent.xicluna | 2010-03-14 13:31:06 +0100 (Sun, 14 Mar 2010) | 2 lines Fix an oversight in r78946 which causes failure in the subprocess module on Windows. ................ r78963 | benjamin.peterson | 2010-03-14 16:04:17 +0100 (Sun, 14 Mar 2010) | 47 lines Merged revisions 78227,78229,78288,78348,78377,78770,78774-78776,78810 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78227 | michael.foord | 2010-02-18 14:30:09 -0600 (Thu, 18 Feb 2010) | 1 line unittest.TestCase uses safe_repr for producing failure messages. Partial fix for issue 7956 ........ r78229 | michael.foord | 2010-02-18 15:37:07 -0600 (Thu, 18 Feb 2010) | 1 line Fix unittest.TestCase.assertDictContainsSubset so it can't die with unicode issues when constructing failure messages. Issue 7956 ........ r78288 | michael.foord | 2010-02-21 08:48:59 -0600 (Sun, 21 Feb 2010) | 1 line Silence UnicodeWarning in crazy unittest test. ........ r78348 | michael.foord | 2010-02-22 17:28:32 -0600 (Mon, 22 Feb 2010) | 1 line Support for old TestResult object (unittest) with warnings when using unsupported features. ........ r78377 | michael.foord | 2010-02-23 11:00:53 -0600 (Tue, 23 Feb 2010) | 1 line unittest.TestResult can now be used with the TextTestRunner. TextTestRunner compatible with old TestResult objects. ........ r78770 | michael.foord | 2010-03-07 14:22:12 -0600 (Sun, 07 Mar 2010) | 1 line Fix for potentials errors in constructing unittest failure messages. Plus skipped test methods no longer run setUp and tearDown (Issue 8059) ........ r78774 | michael.foord | 2010-03-07 16:04:55 -0600 (Sun, 07 Mar 2010) | 1 line Addition of setUpClass and setUpModule shared fixtures to unittest. ........ r78775 | michael.foord | 2010-03-07 17:10:36 -0600 (Sun, 07 Mar 2010) | 1 line Fix accidental name rebinding in unittest py3k warning filtering. ........ r78776 | michael.foord | 2010-03-07 17:16:20 -0600 (Sun, 07 Mar 2010) | 1 line Remove accidental print statement from last commit. ........ r78810 | raymond.hettinger | 2010-03-09 02:44:18 -0600 (Tue, 09 Mar 2010) | 5 lines Improve the basic example. * Show both the decorator and regular form for assertRaises() * Use assertTrue() instead of assertIn() to teach useful minimal subset of the API ........ ................ r78965 | benjamin.peterson | 2010-03-14 16:18:25 +0100 (Sun, 14 Mar 2010) | 13 lines Merged revisions 78962,78964 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78962 | benjamin.peterson | 2010-03-14 09:24:31 -0500 (Sun, 14 Mar 2010) | 1 line fix freebsd linking #7705 ........ r78964 | benjamin.peterson | 2010-03-14 10:06:14 -0500 (Sun, 14 Mar 2010) | 1 line fix quotes ........ ................ r78967 | gregory.p.smith | 2010-03-14 19:56:11 +0100 (Sun, 14 Mar 2010) | 2 lines Change PARSE_PID to _Py_PARSE_PID (cleanup for r78946). ................ r78973 | gregory.p.smith | 2010-03-15 07:07:42 +0100 (Mon, 15 Mar 2010) | 4 lines * Fix the refcount leak in _PySequence_BytesToCharpArray from r78946. * Also fixes a potential extra DECREF of an arg in the error case within _posixsubprocess.fork_exec() by not reusing the process_args variable. ................ r78975 | matthias.klose | 2010-03-15 13:49:46 +0100 (Mon, 15 Mar 2010) | 2 lines - Issue #6949: Allow the _dbm extension to be built with db 4.8.x. ................ r78977 | florent.xicluna | 2010-03-15 14:14:39 +0100 (Mon, 15 Mar 2010) | 2 lines Fix \xhh specs, #1889. (an oversight of r60193, r60210). ................ r78978 | matthias.klose | 2010-03-15 14:25:28 +0100 (Mon, 15 Mar 2010) | 18 lines Merged revisions 78968-78969 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78968 | matthias.klose | 2010-03-15 01:02:36 +0100 (Mon, 15 Mar 2010) | 226 lines - Issue #8142: Update libffi to the 3.0.9 release. ........ r78969 | matthias.klose | 2010-03-15 01:36:18 +0100 (Mon, 15 Mar 2010) | 7 lines Backport from the libffi trunk: 2010-02-15 Matthias Klose * src/arm/sysv.S (__ARM_ARCH__): Define for processor __ARM_ARCH_7EM__. ........ ................ r78980 | matthias.klose | 2010-03-15 14:46:04 +0100 (Mon, 15 Mar 2010) | 10 lines Merged revisions 78979 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78979 | matthias.klose | 2010-03-15 14:42:23 +0100 (Mo, 15 M??r 2010) | 3 lines - Issue #7356: ctypes.util: Make parsing of ldconfig output independent of the locale. ........ ................ r78987 | matthias.klose | 2010-03-16 01:36:26 +0100 (Tue, 16 Mar 2010) | 13 lines Merged revisions 78983,78985 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78983 | matthias.klose | 2010-03-15 18:44:12 +0100 (Mo, 15 M??r 2010) | 2 lines - Issue #8140: extend compileall to compile single files. Add -i option. ........ r78985 | matthias.klose | 2010-03-15 19:00:01 +0100 (Mo, 15 M??r 2010) | 2 lines - Fix typo in Lib/compileall.py(__all__). ........ ................ r78989 | matthias.klose | 2010-03-16 11:51:28 +0100 (Tue, 16 Mar 2010) | 10 lines Merged revisions 78988 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78988 | matthias.klose | 2010-03-16 11:48:52 +0100 (Tue, 16 Mar 2010) | 3 lines - Issue #4961: Inconsistent/wrong result of askyesno function in tkMessageBox with Tcl/Tk-8.5. ........ ................ r78991 | martin.v.loewis | 2010-03-16 12:03:13 +0100 (Tue, 16 Mar 2010) | 9 lines Merged revisions 78976 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78976 | martin.v.loewis | 2010-03-15 14:00:17 +0100 (Mo, 15 M??r 2010) | 1 line Issue #6716: Quote -x arguments of compileall in MSI installer. ........ ................ r78992 | martin.v.loewis | 2010-03-16 14:19:21 +0100 (Tue, 16 Mar 2010) | 2 lines Issue #6716/2: Backslash-replace error output in compilall. ................ r78993 | martin.v.loewis | 2010-03-16 15:16:09 +0100 (Tue, 16 Mar 2010) | 1 line Add UUID for 3.2 DLL. ................ r78994 | martin.v.loewis | 2010-03-16 17:19:47 +0100 (Tue, 16 Mar 2010) | 1 line Issue #6716/3: Exclude 2to3 tests from compileall. ................ r78997 | martin.v.loewis | 2010-03-16 19:53:33 +0100 (Tue, 16 Mar 2010) | 9 lines Merged revisions 78996 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78996 | martin.v.loewis | 2010-03-16 19:49:28 +0100 (Di, 16 M??r 2010) | 1 line Integrate merge.py into msi.py. ........ ................ r79009 | collin.winter | 2010-03-17 01:41:56 +0100 (Wed, 17 Mar 2010) | 1 line Add some tests for ways users can change or shadow globals and builtins. ................ r79014 | collin.winter | 2010-03-17 03:08:57 +0100 (Wed, 17 Mar 2010) | 9 lines Merged revisions 79013 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79013 | collin.winter | 2010-03-16 19:02:30 -0700 (Tue, 16 Mar 2010) | 1 line Fix a trivial class of (hypothetical, future) false-positive refleaks, discovered by an optimization in Unladen Swallow's past (which will become CPython's future). ........ ................ r79017 | collin.winter | 2010-03-17 03:51:00 +0100 (Wed, 17 Mar 2010) | 1 line Commit missing merge info from r79014. ................ r79019 | collin.winter | 2010-03-17 04:09:21 +0100 (Wed, 17 Mar 2010) | 9 lines Merged revisions 79016 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79016 | collin.winter | 2010-03-16 19:40:12 -0700 (Tue, 16 Mar 2010) | 1 line Style cleanup in test_import. ........ ................ r79020 | collin.winter | 2010-03-17 04:14:31 +0100 (Wed, 17 Mar 2010) | 1 line Add tests for overriding and shadowing __import__; these are a useful tripwire for an incoming JIT optimization. ................ r79022 | benjamin.peterson | 2010-03-17 04:30:15 +0100 (Wed, 17 Mar 2010) | 1 line set svn:eol-style ................ r79025 | ezio.melotti | 2010-03-17 15:28:47 +0100 (Wed, 17 Mar 2010) | 8 lines Blocked revisions 79023 via svnmerge ........ r79023 | ezio.melotti | 2010-03-17 15:52:48 +0200 (Wed, 17 Mar 2010) | 1 line #7092: silence some more py3k warnings. ........ ................ r79033 | florent.xicluna | 2010-03-17 21:29:51 +0100 (Wed, 17 Mar 2010) | 17 lines Merged revisions 79030-79032 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79030 | florent.xicluna | 2010-03-17 20:05:04 +0100 (mer, 17 mar 2010) | 2 lines Cleanup in test_import and test_coding. ........ r79031 | florent.xicluna | 2010-03-17 20:15:56 +0100 (mer, 17 mar 2010) | 2 lines Cleanup some test cases using check_warnings and check_py3k_warnings. ........ r79032 | florent.xicluna | 2010-03-17 21:05:11 +0100 (mer, 17 mar 2010) | 2 lines Fix and check cgi module deprecation warnings. Revert an unwanted rename in test_import. ........ ................ r79035 | benjamin.peterson | 2010-03-17 21:56:58 +0100 (Wed, 17 Mar 2010) | 9 lines Merged revisions 79034 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79034 | benjamin.peterson | 2010-03-17 15:41:42 -0500 (Wed, 17 Mar 2010) | 1 line prevent lambda functions from having docstrings #8164 ........ ................ r79036 | benjamin.peterson | 2010-03-17 21:57:32 +0100 (Wed, 17 Mar 2010) | 1 line bring back commented out test ................ r79040 | antoine.pitrou | 2010-03-17 23:50:28 +0100 (Wed, 17 Mar 2010) | 14 lines NOTE: just porting tests here. Merged revisions 79039 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79039 | antoine.pitrou | 2010-03-17 23:45:39 +0100 (mer., 17 mars 2010) | 5 lines Issue #8104: socket.recv_into() and socket.recvfrom_into() now support writing into objects supporting the new buffer API, for example bytearrays or memoryviews. ........ ................ r79041 | collin.winter | 2010-03-18 00:49:15 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79038 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79038 | collin.winter | 2010-03-17 15:36:26 -0700 (Wed, 17 Mar 2010) | 2 lines Fix a race condition in test_asynchat uncovered by the Unladen Swallow JIT. ........ ................ r79045 | collin.winter | 2010-03-18 01:23:44 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79044 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79044 | collin.winter | 2010-03-17 17:10:34 -0700 (Wed, 17 Mar 2010) | 1 line Make test_pwd more stable in the face of unusual LDAP/NIS/Kerberos deployments (the old test was flaky on Google buildslaves). ........ ................ r79048 | ezio.melotti | 2010-03-18 13:29:13 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79024 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79024 | ezio.melotti | 2010-03-17 16:22:34 +0200 (Wed, 17 Mar 2010) | 1 line Use "x in y" instead of y.find(x) != -1. ........ ................ r79050 | florent.xicluna | 2010-03-18 21:00:57 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79049 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79049 | florent.xicluna | 2010-03-18 20:51:47 +0100 (jeu, 18 mar 2010) | 2 lines #8155: Preserve backward compatibility for test_support.check_warnings(). Add regression tests. ........ ................ r79052 | benjamin.peterson | 2010-03-18 22:23:05 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79051 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79051 | benjamin.peterson | 2010-03-18 16:20:35 -0500 (Thu, 18 Mar 2010) | 1 line don't try to compile anything in lib2to3/tests/data #8169 ........ ................ r79057 | benjamin.peterson | 2010-03-18 22:36:06 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79056 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79056 | benjamin.peterson | 2010-03-18 16:32:38 -0500 (Thu, 18 Mar 2010) | 1 line install tkinter and ttk tests ........ ................ r79061 | benjamin.peterson | 2010-03-18 22:58:43 +0100 (Thu, 18 Mar 2010) | 13 lines Merged revisions 78971-78972 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78971 | benjamin.peterson | 2010-03-14 22:00:35 -0500 (Sun, 14 Mar 2010) | 1 line remove mac 9 code ........ r78972 | benjamin.peterson | 2010-03-14 22:02:37 -0500 (Sun, 14 Mar 2010) | 1 line clean up files correctly ........ ................ r79062 | florent.xicluna | 2010-03-18 23:11:01 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79059 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79059 | florent.xicluna | 2010-03-18 22:50:06 +0100 (jeu, 18 mar 2010) | 2 lines Issue #8024: Update the Unicode database to 5.2 ........ ................ r79065 | florent.xicluna | 2010-03-18 23:19:01 +0100 (Thu, 18 Mar 2010) | 2 lines Missing update from previous changeset r79062. ................ r79066 | benjamin.peterson | 2010-03-18 23:29:52 +0100 (Thu, 18 Mar 2010) | 1 line in tokenize.detect_encoding(), return utf-8-sig when a BOM is found ................ r79067 | benjamin.peterson | 2010-03-18 23:34:15 +0100 (Thu, 18 Mar 2010) | 1 line fix for files with coding cookies and BOMs ................ r79068 | benjamin.peterson | 2010-03-18 23:37:38 +0100 (Thu, 18 Mar 2010) | 1 line kill py_compile's homemade encoding detection in favor of tokenize.detect_encoding() (see #8168) ................ r79069 | benjamin.peterson | 2010-03-18 23:43:41 +0100 (Thu, 18 Mar 2010) | 1 line show a common usage of detect_encoding ................ r79071 | collin.winter | 2010-03-18 23:46:40 +0100 (Thu, 18 Mar 2010) | 11 lines Merged revisions 79060 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79060 | collin.winter | 2010-03-18 14:54:01 -0700 (Thu, 18 Mar 2010) | 4 lines Add support for weak references to code objects. This will be used by an optimization in the incoming Python 3 JIT. Patch by Reid Kleckner! ........ ................ r79074 | benjamin.peterson | 2010-03-18 23:55:53 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79070 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79070 | benjamin.peterson | 2010-03-18 17:44:54 -0500 (Thu, 18 Mar 2010) | 1 line these lines can now be dispensed with ........ ................ r79075 | benjamin.peterson | 2010-03-18 23:58:19 +0100 (Thu, 18 Mar 2010) | 9 lines Merged revisions 79073 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79073 | benjamin.peterson | 2010-03-18 17:55:46 -0500 (Thu, 18 Mar 2010) | 1 line reignore bad_coding ........ ................ r79080 | benjamin.peterson | 2010-03-19 00:14:21 +0100 (Fri, 19 Mar 2010) | 8 lines Blocked revisions 79078 via svnmerge ........ r79078 | benjamin.peterson | 2010-03-18 18:12:43 -0500 (Thu, 18 Mar 2010) | 1 line make compiler's py3k warning a full deprecation warning #6837 ........ ................ r79083 | florent.xicluna | 2010-03-19 01:03:01 +0100 (Fri, 19 Mar 2010) | 2 lines Fix bad unicodedata checksum merge from trunk in r79062 ................ r79087 | benjamin.peterson | 2010-03-19 02:08:38 +0100 (Fri, 19 Mar 2010) | 12 lines Blocked revisions 79078,79086 via svnmerge ........ r79078 | benjamin.peterson | 2010-03-18 18:12:43 -0500 (Thu, 18 Mar 2010) | 1 line make compiler's py3k warning a full deprecation warning #6837 ........ r79086 | benjamin.peterson | 2010-03-18 20:06:33 -0500 (Thu, 18 Mar 2010) | 1 line keep DeprecationWarning from failing test ........ ................ r79088 | florent.xicluna | 2010-03-19 02:17:46 +0100 (Fri, 19 Mar 2010) | 2 lines Revert Unicode UCD 5.2 upgrade in 3.x. It broke repr() for unicode objects, and gave failures in test_bigmem. Revert 79062, 79065 and 79083. ................ r79092 | mark.dickinson | 2010-03-19 13:38:03 +0100 (Fri, 19 Mar 2010) | 1 line Remove out-of-date comment about making ints and longs hash equal. ................ r79093 | florent.xicluna | 2010-03-19 14:37:08 +0100 (Fri, 19 Mar 2010) | 11 lines Fixed a failure in test_bigmem. Merged revision 79059 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79059 | florent.xicluna | 2010-03-18 22:50:06 +0100 (jeu, 18 mar 2010) | 2 lines Issue #8024: Update the Unicode database to 5.2 ........ ................ r79094 | florent.xicluna | 2010-03-19 15:25:03 +0100 (Fri, 19 Mar 2010) | 14 lines Merged revisions 78982,78986 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78982 | florent.xicluna | 2010-03-15 15:00:58 +0100 (lun, 15 mar 2010) | 2 lines Remove py3k deprecation warnings from these Unicode tools. ........ r78986 | florent.xicluna | 2010-03-15 19:08:58 +0100 (lun, 15 mar 2010) | 3 lines Issue #7783 and #7787: open_urlresource invalidates the outdated files from the local cache. Use this feature to fix test_normalization. ........ ................ r79095 | florent.xicluna | 2010-03-19 15:40:31 +0100 (Fri, 19 Mar 2010) | 2 lines Rename test.test_support to test.support for 3.x. ................ r79097 | gregory.p.smith | 2010-03-19 17:53:08 +0100 (Fri, 19 Mar 2010) | 7 lines * Fix a refleak when a preexec_fn was supplied (preexec_fn_args_tuple was not being defref'ed). * Fixes another potential refleak of a reference to the gc module in the unlikely odd case where gc module isenabled or disable calls fail. * Adds a unittest for the above case to verify behavior and lack of leaks. ................ r79099 | matthias.klose | 2010-03-19 18:47:21 +0100 (Fri, 19 Mar 2010) | 15 lines Merged revisions 79098 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79098 | matthias.klose | 2010-03-19 18:46:33 +0100 (Fr, 19 M??r 2010) | 8 lines Generate libffi's Makefiles again to be able to run the libffi testsuite -- Diese und die folgenden Zeilen werden ignoriert -- M _ctypes/libffi/configure M _ctypes/libffi/configure.ac M _ctypes/libffi/aclocal.m4 M _ctypes/libffi.diff ........ ................ r79102 | florent.xicluna | 2010-03-19 20:00:44 +0100 (Fri, 19 Mar 2010) | 9 lines Merged revisions 79100 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79100 | florent.xicluna | 2010-03-19 19:34:55 +0100 (ven, 19 mar 2010) | 2 lines Various tests cleanup: check_warnings/check_py3k_warnings, unittest.assert* and setUp/tearDown. ........ ................ r79103 | matthias.klose | 2010-03-19 20:02:09 +0100 (Fri, 19 Mar 2010) | 10 lines Merged revisions 79101 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79101 | matthias.klose | 2010-03-19 19:59:20 +0100 (Fr, 19 M??r 2010) | 3 lines update libffi to commit 59a259f4d348f593b45f452309f4d020a28051c4 from the trunk (adding msvc port). ........ ................ r79107 | benjamin.peterson | 2010-03-19 21:42:30 +0100 (Fri, 19 Mar 2010) | 9 lines Merged revisions 79106 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79106 | benjamin.peterson | 2010-03-19 15:39:41 -0500 (Fri, 19 Mar 2010) | 1 line set svn:eol-style to native on C files ........ ................ r79108 | benjamin.peterson | 2010-03-19 21:44:28 +0100 (Fri, 19 Mar 2010) | 1 line set svn:eol-style on importlib files ................ r79109 | benjamin.peterson | 2010-03-19 21:58:52 +0100 (Fri, 19 Mar 2010) | 1 line fix demo/doc eol ................ r79110 | benjamin.peterson | 2010-03-19 22:00:11 +0100 (Fri, 19 Mar 2010) | 1 line fix test eol ................ r79111 | benjamin.peterson | 2010-03-19 22:00:32 +0100 (Fri, 19 Mar 2010) | 1 line set urllib svn:eol-style ................ r79112 | benjamin.peterson | 2010-03-19 22:01:04 +0100 (Fri, 19 Mar 2010) | 1 line set svn:eol-style on modules ................ r79113 | benjamin.peterson | 2010-03-19 22:01:27 +0100 (Fri, 19 Mar 2010) | 1 line make maintainers.rst have correct eol ................ r79116 | collin.winter | 2010-03-19 22:17:17 +0100 (Fri, 19 Mar 2010) | 13 lines Merged revisions 79082,79084 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79082 | collin.winter | 2010-03-18 17:00:30 -0700 (Thu, 18 Mar 2010) | 1 line Add a separate python-config make target, useful for testing changes to Misc/python-config.in. ........ r79084 | collin.winter | 2010-03-18 17:08:44 -0700 (Thu, 18 Mar 2010) | 1 line Make python-config support multiple option flags on the same command line, rather than requiring one invocation per flag. ........ ................ r79119 | benjamin.peterson | 2010-03-19 22:42:45 +0100 (Fri, 19 Mar 2010) | 1 line update mac installer script from the trunk #8068 ................ r79124 | sean.reifschneider | 2010-03-20 00:23:05 +0100 (Sat, 20 Mar 2010) | 2 lines Adding an example of reproducing the rfc822.Message() parsing. ................ r79126 | sean.reifschneider | 2010-03-20 01:06:05 +0100 (Sat, 20 Mar 2010) | 2 lines Fixing the file call in the rfc822.Message replacement example. ................ r79128 | florent.xicluna | 2010-03-20 01:21:04 +0100 (Sat, 20 Mar 2010) | 9 lines Merged revisions 79127 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79127 | florent.xicluna | 2010-03-20 01:17:46 +0100 (sam, 20 mar 2010) | 2 lines #8178 Cleanup the threads after test_thread.TestForkInThread. ........ ................ r79136 | michael.foord | 2010-03-20 16:42:52 +0100 (Sat, 20 Mar 2010) | 1 line Block revision 79132 in preparation for a manual merge. ................ r79140 | michael.foord | 2010-03-20 17:58:04 +0100 (Sat, 20 Mar 2010) | 1 line Adding assertItemsEqual with tests. Issue 7832. assertSameElements still needs to be deprecated plus documentation needs to be updated. ................ r79141 | michael.foord | 2010-03-20 18:21:27 +0100 (Sat, 20 Mar 2010) | 1 line Issue 7832. Deprecating assertSameElements in Py3k. ................ r79143 | michael.foord | 2010-03-20 19:09:14 +0100 (Sat, 20 Mar 2010) | 1 line Issue 7832. Document changes to unittest.TestCase.assertSameElements and assertItemsEqual ................ r79144 | florent.xicluna | 2010-03-20 21:30:53 +0100 (Sat, 20 Mar 2010) | 2 lines #8133: Use appropriate Unicode decomposition on MacOS X platform. ................ r79145 | florent.xicluna | 2010-03-20 21:31:34 +0100 (Sat, 20 Mar 2010) | 2 lines Typo ................ r79149 | brett.cannon | 2010-03-20 21:59:33 +0100 (Sat, 20 Mar 2010) | 2 lines Clean up the manipulation of the warnings filter in test_builtin. ................ r79150 | brett.cannon | 2010-03-20 22:45:01 +0100 (Sat, 20 Mar 2010) | 2 lines Clean up warnings filter use in test_bytes. ................ r79151 | brett.cannon | 2010-03-20 22:48:19 +0100 (Sat, 20 Mar 2010) | 3 lines Clean up warnings filter use in test_global by no longer having it be a module-level manipulation of the filter. ................ r79152 | brett.cannon | 2010-03-20 22:51:10 +0100 (Sat, 20 Mar 2010) | 2 lines Fix the warnings filter usage in test_http_cookies. ................ r79153 | brett.cannon | 2010-03-20 22:53:28 +0100 (Sat, 20 Mar 2010) | 2 lines Fix the warnings usage in test_posix. ................ r79154 | brett.cannon | 2010-03-20 22:55:48 +0100 (Sat, 20 Mar 2010) | 2 lines Clean up the warnings filter use in test_set. ................ r79155 | brett.cannon | 2010-03-20 23:19:55 +0100 (Sat, 20 Mar 2010) | 2 lines Clean up warnings filter use in test_tempfile. ................ r79157 | brett.cannon | 2010-03-20 23:22:22 +0100 (Sat, 20 Mar 2010) | 2 lines Clean up the warnings filter use in test_unicode. ................ r79158 | brett.cannon | 2010-03-20 23:22:57 +0100 (Sat, 20 Mar 2010) | 2 lines Have regrtest monitor the warnings filter for changes made by a test suite. ................ r79161 | antoine.pitrou | 2010-03-21 01:22:55 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79160 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79160 | antoine.pitrou | 2010-03-21 01:21:43 +0100 (dim., 21 mars 2010) | 3 lines Fix overzealous .hgignore file ........ ................ r79166 | ezio.melotti | 2010-03-21 08:16:43 +0100 (Sun, 21 Mar 2010) | 1 line Update versionadded/changed. ................ r79170 | georg.brandl | 2010-03-21 10:02:59 +0100 (Sun, 21 Mar 2010) | 1 line Fix some issues found by Jacques Ducasse on the docs list. ................ r79171 | georg.brandl | 2010-03-21 10:04:24 +0100 (Sun, 21 Mar 2010) | 13 lines Merged revisions 79168-79169 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79168 | georg.brandl | 2010-03-21 10:01:27 +0100 (So, 21 M??r 2010) | 1 line Fix some issues found by Jacques Ducasse on the docs list. ........ r79169 | georg.brandl | 2010-03-21 10:02:01 +0100 (So, 21 M??r 2010) | 1 line Remove the "built-in objects" file. It only contained two paragraphs of which only one contained useful information, which belongs in the ref manual however. ........ ................ r79175 | georg.brandl | 2010-03-21 10:10:32 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79172 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79172 | georg.brandl | 2010-03-21 10:08:00 +0100 (So, 21 M??r 2010) | 1 line Add a paragraph about set displays. ........ ................ r79177 | georg.brandl | 2010-03-21 10:25:54 +0100 (Sun, 21 Mar 2010) | 1 line Need to use list(range()) to get a list. ................ r79180 | georg.brandl | 2010-03-21 10:50:49 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79178 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79178 | georg.brandl | 2010-03-21 10:28:16 +0100 (So, 21 M??r 2010) | 1 line Clarify that for shell=True, the shell PID will be the child PID. ........ ................ r79182 | georg.brandl | 2010-03-21 10:51:44 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79179 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79179 | georg.brandl | 2010-03-21 10:37:54 +0100 (So, 21 M??r 2010) | 1 line Mention inefficiency of lists as queues, add link to collections.deque discussion. ........ ................ r79183 | georg.brandl | 2010-03-21 10:52:24 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79181 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79181 | georg.brandl | 2010-03-21 10:51:16 +0100 (So, 21 M??r 2010) | 1 line Update os.kill() emulation example for Windows to use ctypes. ........ ................ r79186 | georg.brandl | 2010-03-21 11:03:36 +0100 (Sun, 21 Mar 2010) | 13 lines Merged revisions 79184-79185 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79184 | georg.brandl | 2010-03-21 10:58:36 +0100 (So, 21 M??r 2010) | 1 line Update text for newest US DST regulation. The sample file already has the calculation right. ........ r79185 | georg.brandl | 2010-03-21 11:02:47 +0100 (So, 21 M??r 2010) | 1 line Include structmember.h correctly. ........ ................ r79193 | georg.brandl | 2010-03-21 12:53:50 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79192 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79192 | georg.brandl | 2010-03-21 12:50:58 +0100 (So, 21 M??r 2010) | 1 line Remove leftover word. ........ ................ r79196 | florent.xicluna | 2010-03-21 13:29:50 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79195 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79195 | florent.xicluna | 2010-03-21 13:27:20 +0100 (dim, 21 mar 2010) | 2 lines Issue #8179: Fix macpath.realpath() on a non-existing path. ........ ................ r79209 | florent.xicluna | 2010-03-21 19:49:50 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 79207 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79207 | florent.xicluna | 2010-03-21 19:00:38 +0100 (dim, 21 mar 2010) | 2 lines #8180: Fix test_pep277 on OS X and add more tests for special Unicode normalization cases. ........ ................ r79221 | antoine.pitrou | 2010-03-21 20:25:26 +0100 (Sun, 21 Mar 2010) | 11 lines Merged revisions 79218 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79218 | antoine.pitrou | 2010-03-21 20:19:41 +0100 (dim., 21 mars 2010) | 5 lines Issue #1628484: The Makefile doesn't ignore the CFLAGS environment variable anymore. It also forwards the LDFLAGS settings to the linker when building a shared library. ........ ................ r79239 | benjamin.peterson | 2010-03-21 22:00:50 +0100 (Sun, 21 Mar 2010) | 39 lines Merged revisions 79205,79219,79228,79230,79232-79233,79235,79237 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79205 | benjamin.peterson | 2010-03-21 12:34:54 -0500 (Sun, 21 Mar 2010) | 1 line rewrite a bit ........ r79219 | benjamin.peterson | 2010-03-21 14:24:08 -0500 (Sun, 21 Mar 2010) | 1 line flatten condition ........ r79228 | benjamin.peterson | 2010-03-21 14:35:39 -0500 (Sun, 21 Mar 2010) | 1 line remove pointless condition ........ r79230 | benjamin.peterson | 2010-03-21 14:39:52 -0500 (Sun, 21 Mar 2010) | 1 line co_varnames is certainly a tuple, so let's not waste time finding out ........ r79232 | benjamin.peterson | 2010-03-21 14:54:56 -0500 (Sun, 21 Mar 2010) | 1 line fix import ........ r79233 | benjamin.peterson | 2010-03-21 14:56:37 -0500 (Sun, 21 Mar 2010) | 1 line don't write duplicate tests ........ r79235 | benjamin.peterson | 2010-03-21 15:21:00 -0500 (Sun, 21 Mar 2010) | 4 lines improve error message from passing inadequate number of keyword arguments #6474 Note this removes the "non-keyword" or "keyword" phrases from these messages. ........ r79237 | benjamin.peterson | 2010-03-21 15:30:30 -0500 (Sun, 21 Mar 2010) | 1 line take into account keyword arguments when passing too many args ........ ................ r79242 | benjamin.peterson | 2010-03-21 22:08:54 +0100 (Sun, 21 Mar 2010) | 1 line cleanup a bit ................ r79243 | benjamin.peterson | 2010-03-21 22:12:03 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 78028 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78028 | benjamin.peterson | 2010-02-06 13:40:18 -0600 (Sat, 06 Feb 2010) | 1 line remove pointless error checking ........ ................ r79244 | benjamin.peterson | 2010-03-21 22:16:24 +0100 (Sun, 21 Mar 2010) | 1 line count keyword only arguments as part of the total ................ r79245 | benjamin.peterson | 2010-03-21 22:22:12 +0100 (Sun, 21 Mar 2010) | 1 line nest if for clarity ................ r79251 | benjamin.peterson | 2010-03-21 23:03:03 +0100 (Sun, 21 Mar 2010) | 99 lines Merged revisions 77952,78030,78102,78104,78107,78206,78216,78296-78297,78328,78331-78332,78336,78339,78343,78378-78379,78415,78559,78717,78791 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77952 | mark.dickinson | 2010-02-03 10:50:14 -0600 (Wed, 03 Feb 2010) | 1 line Fix test_inspect.py data to match recent change to inspect_fodder.py (r77942). ........ r78030 | benjamin.peterson | 2010-02-06 14:14:10 -0600 (Sat, 06 Feb 2010) | 1 line check type_getattro for correctness in a descriptor corner case ........ r78102 | andrew.kuchling | 2010-02-07 19:35:35 -0600 (Sun, 07 Feb 2010) | 1 line Move distutils into its own subsection; add various items ........ r78104 | andrew.kuchling | 2010-02-08 07:22:24 -0600 (Mon, 08 Feb 2010) | 1 line Add two items; move a subsection ........ r78107 | antoine.pitrou | 2010-02-08 14:25:47 -0600 (Mon, 08 Feb 2010) | 3 lines Clarify and correct description for ccbench and iobench. ........ r78206 | r.david.murray | 2010-02-16 11:55:26 -0600 (Tue, 16 Feb 2010) | 3 lines Make the references to Popen in the description of Call and check_call into links. ........ r78216 | andrew.kuchling | 2010-02-18 08:16:48 -0600 (Thu, 18 Feb 2010) | 1 line Add various items ........ r78296 | andrew.kuchling | 2010-02-21 20:08:45 -0600 (Sun, 21 Feb 2010) | 1 line Re-word ........ r78297 | andrew.kuchling | 2010-02-21 20:29:10 -0600 (Sun, 21 Feb 2010) | 1 line #7076: mention SystemRandom class near start of the module docs; reword change description for clarity. Noted by Shawn Ligocki. ........ r78328 | jack.diederich | 2010-02-22 12:17:16 -0600 (Mon, 22 Feb 2010) | 1 line fixes issue #7530, serve_forever() ........ r78331 | andrew.kuchling | 2010-02-22 12:38:23 -0600 (Mon, 22 Feb 2010) | 1 line Fix comment typo ........ r78332 | andrew.kuchling | 2010-02-22 12:42:07 -0600 (Mon, 22 Feb 2010) | 2 lines #7627: MH.remove() would fail if the MH mailbox was locked; it would call _unlock_file() and pass it a closed file object. Noted by Rob Austein. ........ r78336 | jack.diederich | 2010-02-22 13:55:22 -0600 (Mon, 22 Feb 2010) | 1 line fixes issue #1522237, bad init check in _threading_local ........ r78339 | jack.diederich | 2010-02-22 15:27:38 -0600 (Mon, 22 Feb 2010) | 1 line * fix issue#7476 ........ r78343 | andrew.kuchling | 2010-02-22 16:48:41 -0600 (Mon, 22 Feb 2010) | 10 lines #2560: remove an unnecessary 'for' loop from my_fgets() in Parser/myreadline.c. Noted by Joseph Armbruster; patch by Jessica McKellar. The original code was 'for (;;) {...}', where ... ended with a 'return -2' statement and did not contain a 'break' or 'continue' statement. Therefore, the body of the loop is always executed once. Once upon a time there was a 'continue' in the loop, but it was removed in rev36346, committed by mwh on Wed Jul 7 17:44:12 2004. ........ r78378 | jack.diederich | 2010-02-23 11:23:30 -0600 (Tue, 23 Feb 2010) | 1 line fixup markup error ........ r78379 | jack.diederich | 2010-02-23 13:34:06 -0600 (Tue, 23 Feb 2010) | 1 line issue#6442 use in operator instead of has_key ........ r78415 | dirkjan.ochtman | 2010-02-23 22:00:52 -0600 (Tue, 23 Feb 2010) | 1 line Issue #7733: add explicit reference in asyncore docs. ........ r78559 | andrew.kuchling | 2010-03-01 13:45:21 -0600 (Mon, 01 Mar 2010) | 1 line #7637: update discussion of minidom.unlink() and garbage collection ........ r78717 | benjamin.peterson | 2010-03-05 21:13:33 -0600 (Fri, 05 Mar 2010) | 1 line settscdump is definitely an implementation detail ........ r78791 | andrew.kuchling | 2010-03-08 06:00:39 -0600 (Mon, 08 Mar 2010) | 1 line Add various items ........ ................ r79252 | benjamin.peterson | 2010-03-21 23:05:32 +0100 (Sun, 21 Mar 2010) | 1 line sync 2.7.rst with trunk ................ r79253 | benjamin.peterson | 2010-03-21 23:21:53 +0100 (Sun, 21 Mar 2010) | 79 lines Blocked revisions 78272,78580,78707,78709-78710,78712-78713,78811,78974,79096,79105,79123,79125,79165,79187-79189,79191 via svnmerge ........ r78272 | ezio.melotti | 2010-02-20 16:34:21 -0600 (Sat, 20 Feb 2010) | 1 line skip tests with a non-ascii cwd when the file system encoding is ascii ........ r78580 | andrew.kuchling | 2010-03-02 07:55:33 -0600 (Tue, 02 Mar 2010) | 1 line Add an item ........ r78707 | tarek.ziade | 2010-03-05 19:18:27 -0600 (Fri, 05 Mar 2010) | 1 line provide a fallback for xxmodule.c in case the buildir is not present ........ r78709 | tarek.ziade | 2010-03-05 19:23:21 -0600 (Fri, 05 Mar 2010) | 1 line simplified the fallback case ........ r78710 | tarek.ziade | 2010-03-05 19:27:09 -0600 (Fri, 05 Mar 2010) | 1 line files used by win32 tests ........ r78712 | tarek.ziade | 2010-03-05 20:11:14 -0600 (Fri, 05 Mar 2010) | 1 line fixed various failures and environment alterations in distutils.test_build_ext ........ r78713 | tarek.ziade | 2010-03-05 20:17:28 -0600 (Fri, 05 Mar 2010) | 1 line search in the alternative location for VCExpress ........ r78811 | raymond.hettinger | 2010-03-09 03:01:46 -0600 (Tue, 09 Mar 2010) | 4 lines Add nicer docstrings to namedtuples(). Provides better tooltips and looks better in help(). ........ r78974 | matthias.klose | 2010-03-15 07:46:18 -0500 (Mon, 15 Mar 2010) | 2 lines - Issue #6949: Allow the _bsddb extension to be built with db-4.8.x. ........ r79096 | matthias.klose | 2010-03-19 09:45:06 -0500 (Fri, 19 Mar 2010) | 2 lines - Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument. ........ r79105 | thomas.heller | 2010-03-19 14:59:30 -0500 (Fri, 19 Mar 2010) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-79104" from svn+ssh://pythondev at svn.python.org/python/branches/branch_libffi-3_0_10-win ........ r79123 | sean.reifschneider | 2010-03-19 18:19:55 -0500 (Fri, 19 Mar 2010) | 2 lines Adding an example of reproducing the rfc822.Message() parsing. ........ r79125 | sean.reifschneider | 2010-03-19 19:05:42 -0500 (Fri, 19 Mar 2010) | 2 lines Fixing the file call in the rfc822.Message replacement example. ........ r79165 | florent.xicluna | 2010-03-20 20:14:24 -0500 (Sat, 20 Mar 2010) | 2 lines #7092 - Silence more py3k deprecation warnings, using test_support.check_py3k_warnings() helper. ........ r79187 | florent.xicluna | 2010-03-21 05:50:44 -0500 (Sun, 21 Mar 2010) | 2 lines Silence more py3k warnings in unittest.case. ........ r79188 | florent.xicluna | 2010-03-21 05:51:40 -0500 (Sun, 21 Mar 2010) | 2 lines Fix py3k warnings in test_decimal, using unittest.assertItemsEqual. ........ r79189 | florent.xicluna | 2010-03-21 06:03:21 -0500 (Sun, 21 Mar 2010) | 2 lines Silence some py3k SyntaxWarning using check_py3k_warnings() with "exec" statements. ........ r79191 | florent.xicluna | 2010-03-21 06:50:17 -0500 (Sun, 21 Mar 2010) | 3 lines No more deprecation warnings for distutils.sysconfig, following r78666. But when the "dl" module is available, it gives a py3k deprecation warning. ........ ................ r79255 | benjamin.peterson | 2010-03-21 23:36:19 +0100 (Sun, 21 Mar 2010) | 56 lines Merged revisions 78338,78345-78346,78561-78562,78566,78574,78581,78634,78660,78675 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78338 | andrew.kuchling | 2010-02-22 15:04:02 -0600 (Mon, 22 Feb 2010) | 4 lines Remove Tools/modulator, a reference to it in the docs, and a screenshot of it. (I asked the BDFL first, and he approved removing it. The last actual bugfix to Tools/modulator was in 2001; since then all changes have been search-and-replace: string methods, whitespace fixes, etc.) ........ r78345 | andrew.kuchling | 2010-02-22 17:10:52 -0600 (Mon, 22 Feb 2010) | 1 line #7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819). ........ r78346 | andrew.kuchling | 2010-02-22 17:12:00 -0600 (Mon, 22 Feb 2010) | 1 line #7706: add include guards where they're missing; required for Windows CE ........ r78561 | andrew.kuchling | 2010-03-01 13:51:43 -0600 (Mon, 01 Mar 2010) | 1 line #7191: describe more details of wbits parameter ........ r78562 | andrew.kuchling | 2010-03-01 14:11:57 -0600 (Mon, 01 Mar 2010) | 1 line #7637: avoid repeated-concatenation antipattern in example ........ r78566 | barry.warsaw | 2010-03-01 15:46:51 -0600 (Mon, 01 Mar 2010) | 4 lines Manually copy patch for bug 7250 from the release26-maint branch. I suck because I did this in the wrong order and couldn't smack svnmerge into submission. ........ r78574 | benjamin.peterson | 2010-03-01 17:25:13 -0600 (Mon, 01 Mar 2010) | 1 line remove CVS id ........ r78581 | michael.foord | 2010-03-02 08:22:15 -0600 (Tue, 02 Mar 2010) | 1 line Link correction in documentation. ........ r78634 | benjamin.peterson | 2010-03-03 15:28:25 -0600 (Wed, 03 Mar 2010) | 1 line rephrase ........ r78660 | dirkjan.ochtman | 2010-03-04 13:21:53 -0600 (Thu, 04 Mar 2010) | 4 lines Try to fix buildbot breakage from r78384. Thanks bitdancer and briancurtin for the help. ........ r78675 | florent.xicluna | 2010-03-04 19:12:14 -0600 (Thu, 04 Mar 2010) | 2 lines These line should not be there. ........ ................ r79256 | benjamin.peterson | 2010-03-21 23:42:02 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 78779 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78779 | benjamin.peterson | 2010-03-07 20:11:06 -0600 (Sun, 07 Mar 2010) | 1 line remove svn:executable from scripts without a shebang line ........ ................ r79257 | benjamin.peterson | 2010-03-21 23:46:35 +0100 (Sun, 21 Mar 2010) | 8 lines Blocked revisions 78722 via svnmerge ........ r78722 | florent.xicluna | 2010-03-06 05:01:08 -0600 (Sat, 06 Mar 2010) | 2 lines #6906: TCL_LIBRARY and TK_LIBRARY environment variables should be encoded. ........ ................ r79258 | benjamin.peterson | 2010-03-21 23:50:04 +0100 (Sun, 21 Mar 2010) | 9 lines Merged revisions 78417 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78417 | dirkjan.ochtman | 2010-02-23 22:49:00 -0600 (Tue, 23 Feb 2010) | 1 line Issue #7427: improve the representation of httplib.BadStatusLine exceptions. ........ ................ r79259 | benjamin.peterson | 2010-03-22 00:13:07 +0100 (Mon, 22 Mar 2010) | 65 lines Merged revisions 78966,78970,79018,79026-79027,79055,79156,79159,79163-79164,79173,79176,79194,79208,79212 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78966 | florent.xicluna | 2010-03-14 10:20:59 -0500 (Sun, 14 Mar 2010) | 2 lines Do not hardcode Expat version. It's possible to build Python with --with-system-expat option. ........ r78970 | benjamin.peterson | 2010-03-14 21:58:24 -0500 (Sun, 14 Mar 2010) | 1 line this little exception dance is pointless ........ r79018 | collin.winter | 2010-03-16 22:04:01 -0500 (Tue, 16 Mar 2010) | 1 line Delete unused import. ........ r79026 | vinay.sajip | 2010-03-17 10:05:57 -0500 (Wed, 17 Mar 2010) | 1 line Issue #8162: logging: Clarified docstring and documentation for disable function. ........ r79027 | collin.winter | 2010-03-17 12:36:16 -0500 (Wed, 17 Mar 2010) | 1 line Avoid hardcoding refcounts in tests. ........ r79055 | benjamin.peterson | 2010-03-18 16:30:48 -0500 (Thu, 18 Mar 2010) | 1 line remove installation of deleted test/output dir ........ r79156 | florent.xicluna | 2010-03-20 17:21:02 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_struct using check_warnings. ........ r79159 | florent.xicluna | 2010-03-20 17:26:42 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_tarfile, and use check_warnings. ........ r79163 | michael.foord | 2010-03-20 19:53:39 -0500 (Sat, 20 Mar 2010) | 1 line A faulty load_tests in a test module no longer halts test discovery. A placeholder test, that reports the failure, is created instead. ........ r79164 | michael.foord | 2010-03-20 19:55:58 -0500 (Sat, 20 Mar 2010) | 1 line Change order of arguments in a unittest function. ........ r79173 | georg.brandl | 2010-03-21 04:09:38 -0500 (Sun, 21 Mar 2010) | 1 line Document that GzipFile supports iteration. ........ r79176 | georg.brandl | 2010-03-21 04:17:41 -0500 (Sun, 21 Mar 2010) | 1 line Introduce copy by slicing, used in later chapters. ........ r79194 | florent.xicluna | 2010-03-21 06:58:11 -0500 (Sun, 21 Mar 2010) | 2 lines Use assertRaises and add a specific warning filter. ........ r79208 | andrew.kuchling | 2010-03-21 13:47:12 -0500 (Sun, 21 Mar 2010) | 1 line Add items ........ r79212 | georg.brandl | 2010-03-21 14:01:38 -0500 (Sun, 21 Mar 2010) | 1 line Fix plural. ........ ................ r79260 | benjamin.peterson | 2010-03-22 00:17:57 +0100 (Mon, 22 Mar 2010) | 13 lines Merged revisions 79138-79139 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79138 | benjamin.peterson | 2010-03-20 11:16:44 -0500 (Sat, 20 Mar 2010) | 1 line document exitfunc fixer ........ r79139 | benjamin.peterson | 2010-03-20 11:17:37 -0500 (Sat, 20 Mar 2010) | 1 line wrap ........ ................ r79262 | benjamin.peterson | 2010-03-22 00:25:07 +0100 (Mon, 22 Mar 2010) | 9 lines Recorded merge of revisions 79047 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79047 | senthil.kumaran | 2010-03-18 07:14:15 -0500 (Thu, 18 Mar 2010) | 3 lines Fix for Issue8135 - urllib.unquote to support mixed percent escapes ........ ................ r79264 | benjamin.peterson | 2010-03-22 01:15:53 +0100 (Mon, 22 Mar 2010) | 9 lines Merged revisions 79263 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79263 | michael.foord | 2010-03-21 19:06:30 -0500 (Sun, 21 Mar 2010) | 1 line Issue 7815. __unittest in module globals trims frames from reported stacktraces in unittest. ........ ................ r79267 | benjamin.peterson | 2010-03-22 02:13:48 +0100 (Mon, 22 Mar 2010) | 13 lines Merged revisions 79265-79266 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79265 | michael.foord | 2010-03-21 20:01:34 -0500 (Sun, 21 Mar 2010) | 1 line -f/--failfast command line option for unittest. Issue 8074. Documentation still needed. Plus minor change to test_unittest to allow it to be run with python -m test.unittest ........ r79266 | michael.foord | 2010-03-21 20:02:23 -0500 (Sun, 21 Mar 2010) | 1 line Fix failing test committed by accident. ........ ................ r79269 | benjamin.peterson | 2010-03-22 02:46:47 +0100 (Mon, 22 Mar 2010) | 9 lines Merged revisions 79268 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79268 | michael.foord | 2010-03-21 20:41:11 -0500 (Sun, 21 Mar 2010) | 1 line Removing Python 2.3 compatibility code from unittest. ........ ................ r79271 | victor.stinner | 2010-03-22 02:58:35 +0100 (Mon, 22 Mar 2010) | 4 lines Issue #4282: Fix the main function of the profile module for a non-ASCII script, open the file in binary mode and not in text mode with the default (utf8) encoding. ................ r79273 | benjamin.peterson | 2010-03-22 03:02:37 +0100 (Mon, 22 Mar 2010) | 9 lines Merged revisions 79270 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79270 | michael.foord | 2010-03-21 20:56:54 -0500 (Sun, 21 Mar 2010) | 1 line expected failure should not trigger failfast behavior in unittest. ........ ................ r79275 | benjamin.peterson | 2010-03-22 03:53:52 +0100 (Mon, 22 Mar 2010) | 9 lines Merged revisions 79274 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79274 | michael.foord | 2010-03-21 21:49:08 -0500 (Sun, 21 Mar 2010) | 1 line Correct usage message displayed for python -m unittest -h ........ ................ r79276 | victor.stinner | 2010-03-22 13:11:44 +0100 (Mon, 22 Mar 2010) | 7 lines Fix a crash in _elementtree related to lone unicode surrogates. Fix a segfault on: >>> import _elementtree >>> _elementtree.iterparse('/bin/sh', ("\uDC80", "\ud808\udf45")) ................ r79281 | victor.stinner | 2010-03-22 13:50:40 +0100 (Mon, 22 Mar 2010) | 16 lines Merged revisions 79278,79280 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79278 | victor.stinner | 2010-03-22 13:24:37 +0100 (lun., 22 mars 2010) | 2 lines Issue #1583863: An unicode subclass can now override the __str__ method ........ r79280 | victor.stinner | 2010-03-22 13:36:28 +0100 (lun., 22 mars 2010) | 5 lines Fix the NEWS about my last commit: an unicode subclass can now override the __unicode__ method (and not the __str__ method). Simplify also the testcase. ........ ................ r79287 | antoine.pitrou | 2010-03-22 15:49:10 +0100 (Mon, 22 Mar 2010) | 13 lines Merged revisions 79226,79286 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79226 | antoine.pitrou | 2010-03-21 20:33:38 +0100 (dim., 21 mars 2010) | 4 lines Issue #3890: Fix recv() and recv_into() on non-blocking SSL sockets. ........ r79286 | antoine.pitrou | 2010-03-22 15:41:48 +0100 (lun., 22 mars 2010) | 3 lines Fix an occasional test_ftplib failure, following r79226. ........ ................ r79289 | antoine.pitrou | 2010-03-22 16:07:09 +0100 (Mon, 22 Mar 2010) | 3 lines Fix a blunder in r79287. This part is, obviously, poorly tested (if at all). ................ r79298 | r.david.murray | 2010-03-22 18:48:48 +0100 (Mon, 22 Mar 2010) | 11 lines Merged revisions 79294 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79294 | r.david.murray | 2010-03-22 11:55:09 -0400 (Mon, 22 Mar 2010) | 4 lines Issue #7860: platform.uname now reports the correct 'machine' type when Python is running in WOW64 mode on 64 bit Windows. Patch by Brian Curtin. ........ ................ r79301 | antoine.pitrou | 2010-03-22 21:11:09 +0100 (Mon, 22 Mar 2010) | 11 lines Merged revisions 79299 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79299 | antoine.pitrou | 2010-03-22 20:59:46 +0100 (lun., 22 mars 2010) | 5 lines Issue #7512: shutil.copystat() could raise an OSError when the filesystem didn't support chflags() (for example ZFS under FreeBSD). The error is now silenced. ........ ................ r79315 | ezio.melotti | 2010-03-23 00:16:42 +0100 (Tue, 23 Mar 2010) | 9 lines Merged revisions 79314 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79314 | ezio.melotti | 2010-03-23 01:07:32 +0200 (Tue, 23 Mar 2010) | 1 line Update the version number of the Unicode Database in a few more places. ........ ................ r79317 | antoine.pitrou | 2010-03-23 01:25:54 +0100 (Tue, 23 Mar 2010) | 5 lines Issue #8139: ossaudiodev didn't initialize its types properly, therefore some methods (such as oss_mixer_device.fileno()) were not available. Initial patch by Bertrand Janin. ................ r79319 | ezio.melotti | 2010-03-23 01:32:49 +0100 (Tue, 23 Mar 2010) | 9 lines Merged revisions 79316 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79316 | ezio.melotti | 2010-03-23 02:25:19 +0200 (Tue, 23 Mar 2010) | 1 line Remove link to objects.rst (gone in r79179). ........ ................ r79321 | ezio.melotti | 2010-03-23 01:39:22 +0100 (Tue, 23 Mar 2010) | 9 lines Merged revisions 79320 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79320 | ezio.melotti | 2010-03-23 02:38:12 +0200 (Tue, 23 Mar 2010) | 1 line Link specifically to the UCD version 5.2.0. ........ ................ r79327 | benjamin.peterson | 2010-03-23 04:22:05 +0100 (Tue, 23 Mar 2010) | 54 lines Merged revisions 79306,79311,79325 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r79306 | benjamin.peterson | 2010-03-22 17:40:06 -0500 (Mon, 22 Mar 2010) | 21 lines Merged revisions 79077,79137,79304-79305 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r79077 | benjamin.peterson | 2010-03-18 18:05:29 -0500 (Thu, 18 Mar 2010) | 1 line port detect_encoding improvements from py3k ........ r79137 | benjamin.peterson | 2010-03-20 11:12:53 -0500 (Sat, 20 Mar 2010) | 1 line add a fixer for setting sys.exitfunc #2356 ........ r79304 | benjamin.peterson | 2010-03-22 17:20:22 -0500 (Mon, 22 Mar 2010) | 1 line fix test_parser when it's run in a path with spaces #7666 ........ r79305 | benjamin.peterson | 2010-03-22 17:27:07 -0500 (Mon, 22 Mar 2010) | 1 line normalize whitespace ........ ................ r79311 | benjamin.peterson | 2010-03-22 17:54:42 -0500 (Mon, 22 Mar 2010) | 9 lines Merged revisions 79309 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r79309 | benjamin.peterson | 2010-03-22 17:50:47 -0500 (Mon, 22 Mar 2010) | 1 line pass correct symbol in ........ ................ r79325 | benjamin.peterson | 2010-03-22 22:03:55 -0500 (Mon, 22 Mar 2010) | 13 lines Merged revisions 79313,79324 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r79313 | benjamin.peterson | 2010-03-22 17:59:57 -0500 (Mon, 22 Mar 2010) | 1 line another case where a symbol is needed ........ r79324 | benjamin.peterson | 2010-03-22 21:59:47 -0500 (Mon, 22 Mar 2010) | 1 line use unicode literals ........ ................ ................ r79333 | senthil.kumaran | 2010-03-23 12:00:53 +0100 (Tue, 23 Mar 2010) | 9 lines Merged revisions 79329 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79329 | senthil.kumaran | 2010-03-23 14:16:31 +0530 (Tue, 23 Mar 2010) | 2 lines Fixed Issue8209 - OptionParser keyword arg 'epilog' not mentioned in the docs ........ ................ r79352 | benjamin.peterson | 2010-03-23 22:02:34 +0100 (Tue, 23 Mar 2010) | 9 lines Merged revisions 79351 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79351 | benjamin.peterson | 2010-03-23 15:58:37 -0500 (Tue, 23 Mar 2010) | 1 line the == test doesn't work on Solaris #8210 ........ ................ r79360 | ezio.melotti | 2010-03-24 00:29:39 +0100 (Wed, 24 Mar 2010) | 9 lines Merged revisions 79358 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79358 | ezio.melotti | 2010-03-24 01:26:21 +0200 (Wed, 24 Mar 2010) | 1 line #8217: typo. ........ ................ r79364 | ezio.melotti | 2010-03-24 00:56:06 +0100 (Wed, 24 Mar 2010) | 9 lines Merged revisions 79362 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79362 | ezio.melotti | 2010-03-24 01:53:20 +0200 (Wed, 24 Mar 2010) | 1 line Another typo. ........ ................ r79368 | r.david.murray | 2010-03-24 01:29:21 +0100 (Wed, 24 Mar 2010) | 2 lines Fix porting mistake in r79298. ................ r79375 | martin.v.loewis | 2010-03-24 16:07:12 +0100 (Wed, 24 Mar 2010) | 9 lines Merged revisions 79374 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79374 | martin.v.loewis | 2010-03-24 16:05:53 +0100 (Mi, 24 M??r 2010) | 2 lines Add Brian Curtin. ........ ................ r79380 | florent.xicluna | 2010-03-24 18:37:49 +0100 (Wed, 24 Mar 2010) | 2 lines Revert improper merge in test_inspect (r79251). ................ r79386 | benjamin.peterson | 2010-03-24 23:10:42 +0100 (Wed, 24 Mar 2010) | 9 lines Merged revisions 79385 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79385 | benjamin.peterson | 2010-03-24 17:03:09 -0500 (Wed, 24 Mar 2010) | 1 line replace copy right notice with simple attribution ........ ................ r79389 | steven.bethard | 2010-03-25 00:07:31 +0100 (Thu, 25 Mar 2010) | 9 lines Merged revisions 79388 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79388 | steven.bethard | 2010-03-24 16:03:24 -0700 (Wed, 24 Mar 2010) | 1 line Replace license with simple attribution. ........ ................ r79393 | victor.stinner | 2010-03-25 01:30:28 +0100 (Thu, 25 Mar 2010) | 3 lines Issue #8226: sys.setfilesystemencoding() raises a LookupError if the encoding is unknown. ................ r79398 | victor.stinner | 2010-03-25 01:55:12 +0100 (Thu, 25 Mar 2010) | 12 lines Merged revisions 79395 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79395 | victor.stinner | 2010-03-25 01:51:58 +0100 (jeu., 25 mars 2010) | 5 lines Fix _curses.tiget*() functions: deny None to avoid a crash. Fix the following calls: _curses.tigetflag(None), _curses.tigetnum(None), _curses.tigetstr(None). ........ ................ r79400 | larry.hastings | 2010-03-25 01:57:10 +0100 (Thu, 25 Mar 2010) | 9 lines Blocked revisions 79397 via svnmerge ........ r79397 | larry.hastings | 2010-03-24 17:54:54 -0700 (Wed, 24 Mar 2010) | 4 lines Backported PyCapsule from 3.1, and converted most uses of CObject to PyCapsule. ........ ................ r79401 | victor.stinner | 2010-03-25 02:02:29 +0100 (Thu, 25 Mar 2010) | 10 lines Merged revisions 79392 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79392 | victor.stinner | 2010-03-25 01:21:53 +0100 (jeu., 25 mars 2010) | 3 lines Issue #8211: Save/restore CFLAGS around AC_PROG_CC in configure.in, compiler optimizations are disabled when --with-pydebug is used. ........ ................ r79407 | benjamin.peterson | 2010-03-25 02:11:10 +0100 (Thu, 25 Mar 2010) | 12 lines Blocked revisions 79402,79406 via svnmerge ........ r79402 | benjamin.peterson | 2010-03-24 20:03:51 -0500 (Wed, 24 Mar 2010) | 1 line set bsddb eol style ........ r79406 | benjamin.peterson | 2010-03-24 20:05:57 -0500 (Wed, 24 Mar 2010) | 1 line fix eol properties on capsule files ........ ................ r79409 | benjamin.peterson | 2010-03-25 02:21:09 +0100 (Thu, 25 Mar 2010) | 9 lines Merged revisions 79403 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79403 | benjamin.peterson | 2010-03-24 20:04:58 -0500 (Wed, 24 Mar 2010) | 1 line set eol on email example ........ ................ r79411 | larry.hastings | 2010-03-25 02:25:31 +0100 (Thu, 25 Mar 2010) | 8 lines Blocked revisions 79410 via svnmerge ........ r79410 | larry.hastings | 2010-03-24 18:23:27 -0700 (Wed, 24 Mar 2010) | 2 lines Remove extraneous experimental code checked in by accident. ........ ................ r79414 | benjamin.peterson | 2010-03-25 04:46:05 +0100 (Thu, 25 Mar 2010) | 8 lines Blocked revisions 79413 via svnmerge ........ r79413 | benjamin.peterson | 2010-03-24 22:44:24 -0500 (Wed, 24 Mar 2010) | 1 line make an attempt to add capsule to the Windows build ........ ................ r79420 | victor.stinner | 2010-03-25 13:24:38 +0100 (Thu, 25 Mar 2010) | 10 lines Fix my test introduced in test_sys by r79394: Restore the orginal filesystem encoding before testing assertRaises(LookupError, sys.setfilesystemencoding, "xxx"). Unittest formats the exception, but the formatting failed because the file system was invalid (set to iso-8859-1 by the previous test). Anyway, ensure to restore the original filesystem encoding when exiting test_setfilesystemencoding() to avoid error propagation to the other tests. ................ r79429 | benjamin.peterson | 2010-03-26 00:30:20 +0100 (Fri, 26 Mar 2010) | 9 lines Merged revisions 79428 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79428 | benjamin.peterson | 2010-03-25 18:27:16 -0500 (Thu, 25 Mar 2010) | 1 line make naming convention consistent ........ ................ r79434 | brian.curtin | 2010-03-26 01:39:56 +0100 (Fri, 26 Mar 2010) | 9 lines Merged revisions 79430 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79430 | brian.curtin | 2010-03-25 18:48:54 -0500 (Thu, 25 Mar 2010) | 2 lines Fix #6538. Markup RegexObject and MatchObject as classes. Patch by Ryan Arana. ........ ................ r79449 | antoine.pitrou | 2010-03-26 20:32:24 +0100 (Fri, 26 Mar 2010) | 12 lines Merged revisions 79448 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79448 | antoine.pitrou | 2010-03-26 20:27:16 +0100 (ven., 26 mars 2010) | 6 lines Issue #8222: Enable the SSL_MODE_AUTO_RETRY flag on SSL sockets, so that blocking reads and writes are always retried by OpenSSL itself. (this is a followup to issue #3890) ........ ................ r79452 | antoine.pitrou | 2010-03-26 20:36:14 +0100 (Fri, 26 Mar 2010) | 3 lines Add NEWS entry for r79449. ................ r79454 | michael.foord | 2010-03-27 02:41:24 +0100 (Sat, 27 Mar 2010) | 8 lines Blocked revisions 79432 via svnmerge ........ r79432 | michael.foord | 2010-03-25 23:56:33 +0000 (Thu, 25 Mar 2010) | 1 line Turn unittest tests into a package ........ ................ r79456 | mark.dickinson | 2010-03-27 12:11:13 +0100 (Sat, 27 Mar 2010) | 9 lines Merged revisions 79455 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79455 | mark.dickinson | 2010-03-27 11:09:29 +0000 (Sat, 27 Mar 2010) | 2 lines Make Fraction to complex comparisons with <=, <, >= or > raise TypeError. ........ ................ r79458 | mark.dickinson | 2010-03-27 12:16:00 +0100 (Sat, 27 Mar 2010) | 9 lines Merged revisions 79457 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79457 | mark.dickinson | 2010-03-27 11:14:37 +0000 (Sat, 27 Mar 2010) | 1 line Add Misc/NEWS entry for r79455. ........ ................ r79461 | michael.foord | 2010-03-27 13:34:21 +0100 (Sat, 27 Mar 2010) | 1 line Breaking test_unittest.py into a package. Manual merge of revision 79432. ................ r79462 | michael.foord | 2010-03-27 13:41:09 +0100 (Sat, 27 Mar 2010) | 8 lines Blocked revisions 79433 via svnmerge ........ r79433 | michael.foord | 2010-03-26 00:03:38 +0000 (Fri, 26 Mar 2010) | 1 line Remove incorrect docstring in unittest.test ........ ................ r79463 | michael.foord | 2010-03-27 13:49:01 +0100 (Sat, 27 Mar 2010) | 8 lines Blocked revisions 79436 via svnmerge ........ r79436 | michael.foord | 2010-03-26 02:53:56 +0000 (Fri, 26 Mar 2010) | 1 line Move a support TestCase out of the main namespace in unittest.test.test_suite ........ ................ r79465 | michael.foord | 2010-03-27 14:25:41 +0100 (Sat, 27 Mar 2010) | 9 lines Merged revisions 79437 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79437 | michael.foord | 2010-03-26 03:18:31 +0000 (Fri, 26 Mar 2010) | 1 line Addition of -c command line option to unittest, to handle ctrl-c during a test run more elegantly ........ ................ r79466 | michael.foord | 2010-03-27 14:28:27 +0100 (Sat, 27 Mar 2010) | 9 lines Merged revisions 79442 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79442 | michael.foord | 2010-03-26 13:07:38 +0000 (Fri, 26 Mar 2010) | 1 line Makefile.pre.in for the unittest/test directory ........ ................ r79467 | michael.foord | 2010-03-27 14:29:35 +0100 (Sat, 27 Mar 2010) | 8 lines Blocked revisions 79443 via svnmerge ........ r79443 | benjamin.peterson | 2010-03-26 13:53:32 +0000 (Fri, 26 Mar 2010) | 1 line reorder imports ........ ................ r79469 | michael.foord | 2010-03-27 14:45:04 +0100 (Sat, 27 Mar 2010) | 9 lines Merged revisions 79468 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79468 | michael.foord | 2010-03-27 13:42:34 +0000 (Sat, 27 Mar 2010) | 1 line Rename the unittest test_suite function to not clash with a test module name (unittest.test.test_suite is now unambiguous). ........ ................ r79472 | florent.xicluna | 2010-03-27 23:18:04 +0100 (Sat, 27 Mar 2010) | 27 lines Blocked revisions 79288,79295-79296,79334,79378 via svnmerge ........ r79288 | florent.xicluna | 2010-03-22 16:02:46 +0100 (lun, 22 mar 2010) | 2 lines Get rid of buffer() in test_ctypes: backport the 3.x tests. ........ r79295 | florent.xicluna | 2010-03-22 17:07:38 +0100 (lun, 22 mar 2010) | 3 lines Issue #7703: ctypes supports both buffer() and memoryview(). The former is deprecated. Complement of r79288. ........ r79296 | florent.xicluna | 2010-03-22 17:36:51 +0100 (lun, 22 mar 2010) | 3 lines Preserve backward compatibility of the ctypes module. "This file should be kept compatible with Python 2.3, see PEP 291." ........ r79334 | florent.xicluna | 2010-03-23 12:07:54 +0100 (mar, 23 mar 2010) | 2 lines Skip test_format_deprecation if _ctypes is not available. Add a filter to the warning check. ........ r79378 | florent.xicluna | 2010-03-24 18:32:58 +0100 (mer, 24 mar 2010) | 3 lines Skip test_ascii_formatd if _ctypes is not available (BSD, ...). Previous change was incomplete (r79334). ........ ................ r79473 | florent.xicluna | 2010-03-27 23:47:23 +0100 (Sat, 27 Mar 2010) | 17 lines Merged revisions 79344,79346,79350 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79344 | florent.xicluna | 2010-03-23 15:36:45 +0100 (mar, 23 mar 2010) | 2 lines Silence test_subprocess. ........ r79346 | florent.xicluna | 2010-03-23 16:05:30 +0100 (mar, 23 mar 2010) | 2 lines The standard error should be empty when the signal is killed, except on SIGINT. ........ r79350 | florent.xicluna | 2010-03-23 20:19:16 +0100 (mar, 23 mar 2010) | 2 lines The SIGINT signal may happen earlier, during site.py initialization. ........ ................ r79474 | florent.xicluna | 2010-03-28 01:25:02 +0100 (Sun, 28 Mar 2010) | 33 lines Merged revisions 79297,79310,79382,79425-79427,79450 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79297 | florent.xicluna | 2010-03-22 18:18:18 +0100 (lun, 22 mar 2010) | 2 lines #7668: Fix test_httpservers failure when sys.executable contains non-ASCII bytes. ........ r79310 | florent.xicluna | 2010-03-22 23:52:11 +0100 (lun, 22 mar 2010) | 2 lines Issue #8205: Remove the "Modules" directory from sys.path when Python is running from the build directory (POSIX only). ........ r79382 | florent.xicluna | 2010-03-24 20:33:25 +0100 (mer, 24 mar 2010) | 2 lines Skip tests which depend on multiprocessing.sharedctypes, if _ctypes is not available. ........ r79425 | florent.xicluna | 2010-03-25 21:32:07 +0100 (jeu, 25 mar 2010) | 2 lines Syntax cleanup `== None` -> `is None` ........ r79426 | florent.xicluna | 2010-03-25 21:33:49 +0100 (jeu, 25 mar 2010) | 2 lines #8207: Fix test_pep277 on OS X ........ r79427 | florent.xicluna | 2010-03-25 21:39:10 +0100 (jeu, 25 mar 2010) | 2 lines Fix test_unittest and test_warnings when running "python -Werror -m test.regrtest" ........ r79450 | florent.xicluna | 2010-03-26 20:32:44 +0100 (ven, 26 mar 2010) | 2 lines Ensure that the failed or unexpected tests are sorted before printing. ........ ................ r79484 | raymond.hettinger | 2010-03-28 20:27:13 +0200 (Sun, 28 Mar 2010) | 1 line Update itertools recipes. ................ r79499 | benjamin.peterson | 2010-03-30 19:34:47 +0200 (Tue, 30 Mar 2010) | 4 lines build without -fno-strict-aliasing when gcc isn't buggy #3326 Patch from Daniel Stutzbach ................ r79501 | benjamin.peterson | 2010-03-30 20:42:32 +0200 (Tue, 30 Mar 2010) | 11 lines Merged revisions 79500 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79500 | benjamin.peterson | 2010-03-30 12:58:13 -0500 (Tue, 30 Mar 2010) | 4 lines add inspect.getcallargs, which binds function arguments like a normal call #3135 Patch by George Sakkis ........ ................ r79503 | antoine.pitrou | 2010-03-30 20:56:19 +0200 (Tue, 30 Mar 2010) | 9 lines Merged revisions 79502 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79502 | antoine.pitrou | 2010-03-30 20:49:45 +0200 (mar., 30 mars 2010) | 4 lines Issue #8248: Add some tests for the bool type. Patch by Gregory Nofi. ........ ................ r79505 | antoine.pitrou | 2010-03-30 20:59:21 +0200 (Tue, 30 Mar 2010) | 8 lines Blocked revisions 79504 via svnmerge ........ r79504 | antoine.pitrou | 2010-03-30 20:58:22 +0200 (mar., 30 mars 2010) | 3 lines Fix small error in r79502 ........ ................ r79506 | florent.xicluna | 2010-03-30 21:34:18 +0200 (Tue, 30 Mar 2010) | 13 lines Merged revisions 79494,79496 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79494 | florent.xicluna | 2010-03-30 10:24:06 +0200 (mar, 30 mar 2010) | 2 lines #7643: Unicode codepoints VT (0x0B) and FF (0x0C) are linebreaks according to Unicode Standard Annex #14. ........ r79496 | florent.xicluna | 2010-03-30 18:29:03 +0200 (mar, 30 mar 2010) | 2 lines Highlight the change of behavior related to r79494. Now VT and FF are linebreaks. ........ ................ r79507 | florent.xicluna | 2010-03-30 21:37:07 +0200 (Tue, 30 Mar 2010) | 9 lines Merged revisions 79498 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79498 | florent.xicluna | 2010-03-30 18:42:47 +0200 (mar, 30 mar 2010) | 2 lines fix ACKS: alphabetic order and UTF-8 ........ ................ r79508 | florent.xicluna | 2010-03-30 21:43:09 +0200 (Tue, 30 Mar 2010) | 9 lines Merged revisions 79497 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79497 | florent.xicluna | 2010-03-30 18:31:14 +0200 (mar, 30 mar 2010) | 2 lines #8263: Now regrtest.py will report a failure if it receives a KeyboardInterrupt (SIGINT). ........ ................ r79520 | brian.curtin | 2010-03-31 05:19:28 +0200 (Wed, 31 Mar 2010) | 9 lines Merged revisions 79518 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79518 | brian.curtin | 2010-03-30 22:10:21 -0500 (Tue, 30 Mar 2010) | 2 lines Fix #8225. xml.etree was displaying an incorrect link when viewed in help. ........ ................ r79525 | ezio.melotti | 2010-03-31 09:45:32 +0200 (Wed, 31 Mar 2010) | 9 lines Merged revisions 79522 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79522 | ezio.melotti | 2010-03-31 10:26:24 +0300 (Wed, 31 Mar 2010) | 1 line Revert r79179 and merge r75584 to explain how to implement a queue using collection.deque instead of a list. ........ ................ r79531 | brian.curtin | 2010-03-31 19:46:38 +0200 (Wed, 31 Mar 2010) | 4 lines Merged revisions 79529 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r79536 | barry.warsaw | 2010-03-31 23:36:22 +0200 (Wed, 31 Mar 2010) | 6 lines - Issue #8233: When run as a script, py_compile.py optionally takes a single argument `-` which tells it to read files to compile from stdin. Each line is read on demand and the named file is compiled immediately. (Original patch by Piotr O??arowski). ................ r79538 | antoine.pitrou | 2010-03-31 23:40:47 +0200 (Wed, 31 Mar 2010) | 13 lines NOTE: only ported the test for new-style classes. Merged revisions 79535 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79535 | antoine.pitrou | 2010-03-31 23:32:15 +0200 (mer., 31 mars 2010) | 5 lines Issue #8268: Old-style classes (not just instances) now support weak references. ........ ................ r79545 | brian.curtin | 2010-04-01 06:05:25 +0200 (Thu, 01 Apr 2010) | 9 lines Merged revisions 79543 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r79543 | brian.curtin | 2010-03-31 23:02:00 -0500 (Wed, 31 Mar 2010) | 2 lines Fix a test_pydoc failure on Neal Norwitz's buildbot. ........ ................ Added: python/branches/py3k-cdecimal/Doc/includes/email-headers.py - copied unchanged from r79545, /python/branches/py3k/Doc/includes/email-headers.py python/branches/py3k-cdecimal/Doc/includes/sqlite3/load_extension.py - copied unchanged from r79545, /python/branches/py3k/Doc/includes/sqlite3/load_extension.py python/branches/py3k-cdecimal/Doc/library/argparse.rst - copied unchanged from r79545, /python/branches/py3k/Doc/library/argparse.rst python/branches/py3k-cdecimal/Lib/argparse.py - copied unchanged from r79545, /python/branches/py3k/Lib/argparse.py python/branches/py3k-cdecimal/Lib/email/test/data/msg_46.txt - copied unchanged from r79545, /python/branches/py3k/Lib/email/test/data/msg_46.txt python/branches/py3k-cdecimal/Lib/lib2to3/fixes/fix_exitfunc.py - copied unchanged from r79545, /python/branches/py3k/Lib/lib2to3/fixes/fix_exitfunc.py python/branches/py3k-cdecimal/Lib/test/test_argparse.py - copied unchanged from r79545, /python/branches/py3k/Lib/test/test_argparse.py python/branches/py3k-cdecimal/Lib/test/test_dynamic.py - copied unchanged from r79545, /python/branches/py3k/Lib/test/test_dynamic.py python/branches/py3k-cdecimal/Lib/test/xmltestdata/ - copied from r79545, /python/branches/py3k/Lib/test/xmltestdata/ python/branches/py3k-cdecimal/Lib/unittest/signals.py - copied unchanged from r79545, /python/branches/py3k/Lib/unittest/signals.py python/branches/py3k-cdecimal/Lib/unittest/test/ - copied from r79545, /python/branches/py3k/Lib/unittest/test/ python/branches/py3k-cdecimal/Modules/_ctypes/libffi/ChangeLog - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/ChangeLog python/branches/py3k-cdecimal/Modules/_ctypes/libffi/ChangeLog.libffi - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/ChangeLog.libffi python/branches/py3k-cdecimal/Modules/_ctypes/libffi/ChangeLog.libgcj - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/ChangeLog.libgcj python/branches/py3k-cdecimal/Modules/_ctypes/libffi/ChangeLog.v1 - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/ChangeLog.v1 python/branches/py3k-cdecimal/Modules/_ctypes/libffi/compile - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/compile python/branches/py3k-cdecimal/Modules/_ctypes/libffi/depcomp - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/depcomp python/branches/py3k-cdecimal/Modules/_ctypes/libffi/doc/ - copied from r79545, /python/branches/py3k/Modules/_ctypes/libffi/doc/ python/branches/py3k-cdecimal/Modules/_ctypes/libffi/libffi.pc.in - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/libffi.pc.in python/branches/py3k-cdecimal/Modules/_ctypes/libffi/libtool-version - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/libtool-version python/branches/py3k-cdecimal/Modules/_ctypes/libffi/ltmain.sh - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/ltmain.sh python/branches/py3k-cdecimal/Modules/_ctypes/libffi/m4/ - copied from r79545, /python/branches/py3k/Modules/_ctypes/libffi/m4/ python/branches/py3k-cdecimal/Modules/_ctypes/libffi/man/ - copied from r79545, /python/branches/py3k/Modules/_ctypes/libffi/man/ python/branches/py3k-cdecimal/Modules/_ctypes/libffi/mdate-sh - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/mdate-sh python/branches/py3k-cdecimal/Modules/_ctypes/libffi/msvcc.sh - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/msvcc.sh python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/avr32/ - copied from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/avr32/ python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/closures.c - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/closures.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/debug.c - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/debug.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/dlmalloc.c - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/dlmalloc.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/java_raw_api.c - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/java_raw_api.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/moxie/ - copied from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/moxie/ python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/raw_api.c - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/raw_api.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/types.c - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/types.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/win64.S - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/src/x86/win64.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/testsuite/ - copied from r79545, /python/branches/py3k/Modules/_ctypes/libffi/testsuite/ python/branches/py3k-cdecimal/Modules/_ctypes/libffi/texinfo.tex - copied unchanged from r79545, /python/branches/py3k/Modules/_ctypes/libffi/texinfo.tex python/branches/py3k-cdecimal/Modules/_posixsubprocess.c - copied unchanged from r79545, /python/branches/py3k/Modules/_posixsubprocess.c python/branches/py3k-cdecimal/Tools/scripts/serve.py - copied unchanged from r79545, /python/branches/py3k/Tools/scripts/serve.py Removed: python/branches/py3k-cdecimal/Doc/library/objects.rst python/branches/py3k-cdecimal/Doc/library/xml.etree.rst python/branches/py3k-cdecimal/Lib/test/test.xml python/branches/py3k-cdecimal/Lib/test/test.xml.out python/branches/py3k-cdecimal/Lib/test/test_ascii_formatd.py python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/darwin/ffitarget.h python/branches/py3k-cdecimal/Tools/modulator/ python/branches/py3k-cdecimal/Tools/msi/merge.py Modified: python/branches/py3k-cdecimal/ (props changed) python/branches/py3k-cdecimal/.hgignore python/branches/py3k-cdecimal/Demo/cgi/cgi1.py python/branches/py3k-cdecimal/Demo/cgi/cgi2.py python/branches/py3k-cdecimal/Demo/cgi/cgi3.py python/branches/py3k-cdecimal/Demo/classes/Complex.py (props changed) python/branches/py3k-cdecimal/Demo/classes/Dates.py (props changed) python/branches/py3k-cdecimal/Demo/classes/Dbm.py (props changed) python/branches/py3k-cdecimal/Demo/classes/Range.py (props changed) python/branches/py3k-cdecimal/Demo/classes/Rev.py (props changed) python/branches/py3k-cdecimal/Demo/classes/Vec.py (props changed) python/branches/py3k-cdecimal/Demo/classes/bitvec.py (props changed) python/branches/py3k-cdecimal/Demo/comparisons/regextest.py python/branches/py3k-cdecimal/Demo/comparisons/sortingtest.py python/branches/py3k-cdecimal/Demo/comparisons/systemtest.py python/branches/py3k-cdecimal/Demo/curses/life.py python/branches/py3k-cdecimal/Demo/curses/ncurses.py python/branches/py3k-cdecimal/Demo/curses/rain.py python/branches/py3k-cdecimal/Demo/curses/repeat.py python/branches/py3k-cdecimal/Demo/curses/tclock.py python/branches/py3k-cdecimal/Demo/distutils/test2to3/maintest.py python/branches/py3k-cdecimal/Demo/md5test/md5driver.py (props changed) python/branches/py3k-cdecimal/Demo/parser/test_parser.py python/branches/py3k-cdecimal/Demo/pdist/FSProxy.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/RCSProxy.py python/branches/py3k-cdecimal/Demo/pdist/client.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/cmdfw.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/cmptree.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/cvslib.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/cvslock.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/mac.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/makechangelog.py python/branches/py3k-cdecimal/Demo/pdist/rcsclient.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/rcslib.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/rcvs.py python/branches/py3k-cdecimal/Demo/pdist/rrcs.py python/branches/py3k-cdecimal/Demo/pdist/security.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/server.py (props changed) python/branches/py3k-cdecimal/Demo/pdist/sumtree.py (props changed) python/branches/py3k-cdecimal/Demo/pysvr/pysvr.py python/branches/py3k-cdecimal/Demo/scripts/beer.py python/branches/py3k-cdecimal/Demo/scripts/eqfix.py python/branches/py3k-cdecimal/Demo/scripts/fact.py python/branches/py3k-cdecimal/Demo/scripts/find-uname.py python/branches/py3k-cdecimal/Demo/scripts/from.py python/branches/py3k-cdecimal/Demo/scripts/lpwatch.py python/branches/py3k-cdecimal/Demo/scripts/makedir.py python/branches/py3k-cdecimal/Demo/scripts/markov.py python/branches/py3k-cdecimal/Demo/scripts/mboxconvert.py python/branches/py3k-cdecimal/Demo/scripts/morse.py python/branches/py3k-cdecimal/Demo/scripts/newslist.py python/branches/py3k-cdecimal/Demo/scripts/pi.py python/branches/py3k-cdecimal/Demo/scripts/pp.py python/branches/py3k-cdecimal/Demo/scripts/primes.py python/branches/py3k-cdecimal/Demo/scripts/queens.py python/branches/py3k-cdecimal/Demo/scripts/script.py python/branches/py3k-cdecimal/Demo/scripts/unbirthday.py python/branches/py3k-cdecimal/Demo/scripts/update.py python/branches/py3k-cdecimal/Demo/sockets/broadcast.py (props changed) python/branches/py3k-cdecimal/Demo/sockets/echosvr.py python/branches/py3k-cdecimal/Demo/sockets/finger.py python/branches/py3k-cdecimal/Demo/sockets/ftp.py (props changed) python/branches/py3k-cdecimal/Demo/sockets/gopher.py python/branches/py3k-cdecimal/Demo/sockets/mcast.py python/branches/py3k-cdecimal/Demo/sockets/radio.py (props changed) python/branches/py3k-cdecimal/Demo/sockets/rpython.py python/branches/py3k-cdecimal/Demo/sockets/rpythond.py python/branches/py3k-cdecimal/Demo/sockets/telnet.py python/branches/py3k-cdecimal/Demo/sockets/throughput.py python/branches/py3k-cdecimal/Demo/sockets/udpecho.py python/branches/py3k-cdecimal/Demo/tix/samples/Balloon.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/BtnBox.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/CmpImg.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/ComboBox.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/Control.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/DirList.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/DirTree.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/NoteBook.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/OptMenu.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/PanedWin.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/PopMenu.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/SHList1.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/SHList2.py (props changed) python/branches/py3k-cdecimal/Demo/tix/samples/Tree.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/AttrDialog.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/ManPage.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/MimeViewer.py python/branches/py3k-cdecimal/Demo/tkinter/guido/ShellWindow.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/canvasevents.py python/branches/py3k-cdecimal/Demo/tkinter/guido/dialog.py python/branches/py3k-cdecimal/Demo/tkinter/guido/electrons.py python/branches/py3k-cdecimal/Demo/tkinter/guido/hanoi.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/hello.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/imagedraw.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/imageview.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/kill.py python/branches/py3k-cdecimal/Demo/tkinter/guido/listtree.py (props changed) python/branches/py3k-cdecimal/Demo/tkinter/guido/mbox.py python/branches/py3k-cdecimal/Demo/tkinter/guido/newmenubardemo.py python/branches/py3k-cdecimal/Demo/tkinter/guido/rmt.py python/branches/py3k-cdecimal/Demo/tkinter/guido/solitaire.py python/branches/py3k-cdecimal/Demo/tkinter/guido/sortvisu.py python/branches/py3k-cdecimal/Demo/tkinter/guido/svkill.py python/branches/py3k-cdecimal/Demo/tkinter/guido/tkman.py python/branches/py3k-cdecimal/Demo/tkinter/guido/wish.py (props changed) python/branches/py3k-cdecimal/Demo/turtle/tdemo_I_dontlike_tiltdemo.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_bytedesign.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_clock.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_forest.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_fractalcurves.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_lindenmayer_indian.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_minimal_hanoi.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_nim.py (contents, props changed) python/branches/py3k-cdecimal/Demo/turtle/tdemo_paint.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_peace.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_penrose.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_planet_and_moon.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_round_dance.py (contents, props changed) python/branches/py3k-cdecimal/Demo/turtle/tdemo_tree.py python/branches/py3k-cdecimal/Demo/turtle/tdemo_yinyang.py python/branches/py3k-cdecimal/Demo/turtle/turtleDemo.py python/branches/py3k-cdecimal/Demo/turtle/turtledemo_two_canvases.py python/branches/py3k-cdecimal/Demo/zlib/minigzip.py python/branches/py3k-cdecimal/Demo/zlib/zlibdemo.py python/branches/py3k-cdecimal/Doc/ (props changed) python/branches/py3k-cdecimal/Doc/Makefile python/branches/py3k-cdecimal/Doc/README.txt python/branches/py3k-cdecimal/Doc/bugs.rst python/branches/py3k-cdecimal/Doc/c-api/code.rst (props changed) python/branches/py3k-cdecimal/Doc/c-api/conversion.rst python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst python/branches/py3k-cdecimal/Doc/c-api/gcsupport.rst python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst python/branches/py3k-cdecimal/Doc/c-api/unicode.rst python/branches/py3k-cdecimal/Doc/distutils/examples.rst python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst python/branches/py3k-cdecimal/Doc/distutils/uploading.rst python/branches/py3k-cdecimal/Doc/extending/extending.rst python/branches/py3k-cdecimal/Doc/extending/newtypes.rst python/branches/py3k-cdecimal/Doc/faq/windows.rst python/branches/py3k-cdecimal/Doc/howto/unicode.rst python/branches/py3k-cdecimal/Doc/howto/webservers.rst python/branches/py3k-cdecimal/Doc/includes/dbpickle.py (props changed) python/branches/py3k-cdecimal/Doc/includes/email-alternative.py python/branches/py3k-cdecimal/Doc/includes/email-dir.py python/branches/py3k-cdecimal/Doc/includes/email-unpack.py python/branches/py3k-cdecimal/Doc/includes/minidom-example.py python/branches/py3k-cdecimal/Doc/library/2to3.rst python/branches/py3k-cdecimal/Doc/library/allos.rst python/branches/py3k-cdecimal/Doc/library/asyncore.rst python/branches/py3k-cdecimal/Doc/library/builtins.rst python/branches/py3k-cdecimal/Doc/library/bz2.rst python/branches/py3k-cdecimal/Doc/library/codecs.rst python/branches/py3k-cdecimal/Doc/library/csv.rst python/branches/py3k-cdecimal/Doc/library/ctypes.rst python/branches/py3k-cdecimal/Doc/library/datetime.rst python/branches/py3k-cdecimal/Doc/library/decimal.rst python/branches/py3k-cdecimal/Doc/library/doctest.rst python/branches/py3k-cdecimal/Doc/library/email-examples.rst python/branches/py3k-cdecimal/Doc/library/email.message.rst python/branches/py3k-cdecimal/Doc/library/functions.rst python/branches/py3k-cdecimal/Doc/library/getopt.rst python/branches/py3k-cdecimal/Doc/library/gzip.rst python/branches/py3k-cdecimal/Doc/library/hashlib.rst python/branches/py3k-cdecimal/Doc/library/http.client.rst python/branches/py3k-cdecimal/Doc/library/index.rst python/branches/py3k-cdecimal/Doc/library/inspect.rst python/branches/py3k-cdecimal/Doc/library/itertools.rst python/branches/py3k-cdecimal/Doc/library/logging.rst python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst python/branches/py3k-cdecimal/Doc/library/optparse.rst python/branches/py3k-cdecimal/Doc/library/os.rst python/branches/py3k-cdecimal/Doc/library/pdb.rst python/branches/py3k-cdecimal/Doc/library/pydoc.rst python/branches/py3k-cdecimal/Doc/library/queue.rst python/branches/py3k-cdecimal/Doc/library/random.rst python/branches/py3k-cdecimal/Doc/library/re.rst python/branches/py3k-cdecimal/Doc/library/shutil.rst python/branches/py3k-cdecimal/Doc/library/site.rst python/branches/py3k-cdecimal/Doc/library/sqlite3.rst python/branches/py3k-cdecimal/Doc/library/stdtypes.rst python/branches/py3k-cdecimal/Doc/library/string.rst python/branches/py3k-cdecimal/Doc/library/struct.rst python/branches/py3k-cdecimal/Doc/library/subprocess.rst python/branches/py3k-cdecimal/Doc/library/sys.rst python/branches/py3k-cdecimal/Doc/library/sysconfig.rst (contents, props changed) python/branches/py3k-cdecimal/Doc/library/tarfile.rst python/branches/py3k-cdecimal/Doc/library/test.rst python/branches/py3k-cdecimal/Doc/library/threading.rst python/branches/py3k-cdecimal/Doc/library/tkinter.rst python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst python/branches/py3k-cdecimal/Doc/library/tkinter.ttk.rst python/branches/py3k-cdecimal/Doc/library/tokenize.rst python/branches/py3k-cdecimal/Doc/library/traceback.rst python/branches/py3k-cdecimal/Doc/library/turtle.rst python/branches/py3k-cdecimal/Doc/library/unicodedata.rst python/branches/py3k-cdecimal/Doc/library/unittest.rst python/branches/py3k-cdecimal/Doc/library/urllib.request.rst python/branches/py3k-cdecimal/Doc/library/weakref.rst python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst python/branches/py3k-cdecimal/Doc/library/xml.etree.elementtree.rst python/branches/py3k-cdecimal/Doc/library/zipfile.rst python/branches/py3k-cdecimal/Doc/library/zlib.rst python/branches/py3k-cdecimal/Doc/make.bat python/branches/py3k-cdecimal/Doc/reference/executionmodel.rst python/branches/py3k-cdecimal/Doc/reference/expressions.rst python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst python/branches/py3k-cdecimal/Doc/reference/simple_stmts.rst python/branches/py3k-cdecimal/Doc/tools/rstlint.py python/branches/py3k-cdecimal/Doc/tools/sphinxext/download.html python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst python/branches/py3k-cdecimal/Doc/tutorial/introduction.rst python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst python/branches/py3k-cdecimal/Doc/using/mac.rst python/branches/py3k-cdecimal/Doc/whatsnew/2.2.rst python/branches/py3k-cdecimal/Doc/whatsnew/2.6.rst python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst python/branches/py3k-cdecimal/Doc/whatsnew/3.1.rst python/branches/py3k-cdecimal/Include/abstract.h python/branches/py3k-cdecimal/Include/code.h python/branches/py3k-cdecimal/Include/dtoa.h (props changed) python/branches/py3k-cdecimal/Include/longobject.h python/branches/py3k-cdecimal/Include/pyctype.h (props changed) python/branches/py3k-cdecimal/Include/pystate.h python/branches/py3k-cdecimal/Include/pystrtod.h python/branches/py3k-cdecimal/Include/pythonrun.h python/branches/py3k-cdecimal/Include/pythread.h python/branches/py3k-cdecimal/Lib/_pyio.py python/branches/py3k-cdecimal/Lib/_threading_local.py python/branches/py3k-cdecimal/Lib/base64.py python/branches/py3k-cdecimal/Lib/cProfile.py python/branches/py3k-cdecimal/Lib/compileall.py python/branches/py3k-cdecimal/Lib/csv.py python/branches/py3k-cdecimal/Lib/ctypes/__init__.py python/branches/py3k-cdecimal/Lib/ctypes/test/test_callbacks.py python/branches/py3k-cdecimal/Lib/ctypes/test/test_internals.py python/branches/py3k-cdecimal/Lib/ctypes/test/test_sizes.py python/branches/py3k-cdecimal/Lib/ctypes/util.py python/branches/py3k-cdecimal/Lib/difflib.py python/branches/py3k-cdecimal/Lib/distutils/command/install.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_dumb.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_msi.py (contents, props changed) python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_rpm.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_wininst.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_build_py.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_clean.py (props changed) python/branches/py3k-cdecimal/Lib/distutils/tests/test_cmd.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_cygwinccompiler.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_dep_util.py (props changed) python/branches/py3k-cdecimal/Lib/distutils/tests/test_emxccompiler.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_extension.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_install_lib.py python/branches/py3k-cdecimal/Lib/distutils/tests/test_sysconfig.py python/branches/py3k-cdecimal/Lib/doctest.py python/branches/py3k-cdecimal/Lib/email/generator.py python/branches/py3k-cdecimal/Lib/email/message.py python/branches/py3k-cdecimal/Lib/email/test/data/msg_10.txt python/branches/py3k-cdecimal/Lib/email/test/data/msg_45.txt (props changed) python/branches/py3k-cdecimal/Lib/email/test/test_email.py python/branches/py3k-cdecimal/Lib/email/test/test_email_torture.py python/branches/py3k-cdecimal/Lib/encodings/cp720.py (contents, props changed) python/branches/py3k-cdecimal/Lib/fractions.py python/branches/py3k-cdecimal/Lib/genericpath.py python/branches/py3k-cdecimal/Lib/hashlib.py python/branches/py3k-cdecimal/Lib/http/client.py python/branches/py3k-cdecimal/Lib/http/cookies.py python/branches/py3k-cdecimal/Lib/http/server.py python/branches/py3k-cdecimal/Lib/idlelib/PyShell.py python/branches/py3k-cdecimal/Lib/importlib/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/_bootstrap.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/abc.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/machinery.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/__main__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/abc.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/benchmark.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/builtin/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/builtin/test_finder.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/builtin/test_loader.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/builtin/util.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/extension/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/extension/test_case_sensitivity.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/extension/test_finder.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/extension/test_loader.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/extension/test_path_hook.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/extension/util.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/frozen/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/frozen/test_finder.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/frozen/test_loader.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test___package__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test_api.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test_caching.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test_fromlist.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test_meta_path.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test_packages.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test_path.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/test_relative_imports.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/import_/util.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/regrtest.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/test_abc_loader.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/test_case_sensitivity.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/test_file_loader.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/test_finder.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/test_path_hook.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/test_source_encoding.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/source/util.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/test_abc.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/test_api.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/test_util.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/test/util.py (props changed) python/branches/py3k-cdecimal/Lib/importlib/util.py (props changed) python/branches/py3k-cdecimal/Lib/inspect.py python/branches/py3k-cdecimal/Lib/keyword.py python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/token.py python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/tokenize.py python/branches/py3k-cdecimal/Lib/lib2to3/tests/pytree_idempotency.py python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_fixers.py (contents, props changed) python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_main.py (props changed) python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_parser.py python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_pytree.py (props changed) python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py python/branches/py3k-cdecimal/Lib/logging/__init__.py python/branches/py3k-cdecimal/Lib/logging/config.py python/branches/py3k-cdecimal/Lib/logging/handlers.py python/branches/py3k-cdecimal/Lib/macpath.py python/branches/py3k-cdecimal/Lib/mailbox.py python/branches/py3k-cdecimal/Lib/mimetypes.py python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py python/branches/py3k-cdecimal/Lib/multiprocessing/process.py python/branches/py3k-cdecimal/Lib/ntpath.py python/branches/py3k-cdecimal/Lib/os.py python/branches/py3k-cdecimal/Lib/pdb.py python/branches/py3k-cdecimal/Lib/pipes.py python/branches/py3k-cdecimal/Lib/plat-freebsd4/regen (props changed) python/branches/py3k-cdecimal/Lib/plat-freebsd5/regen (props changed) python/branches/py3k-cdecimal/Lib/plat-freebsd6/regen (props changed) python/branches/py3k-cdecimal/Lib/plat-freebsd7/regen (props changed) python/branches/py3k-cdecimal/Lib/plat-freebsd8/regen (props changed) python/branches/py3k-cdecimal/Lib/plat-os2emx/regen (props changed) python/branches/py3k-cdecimal/Lib/plat-sunos5/IN.py (props changed) python/branches/py3k-cdecimal/Lib/platform.py python/branches/py3k-cdecimal/Lib/posixpath.py python/branches/py3k-cdecimal/Lib/profile.py python/branches/py3k-cdecimal/Lib/py_compile.py python/branches/py3k-cdecimal/Lib/pydoc.py python/branches/py3k-cdecimal/Lib/quopri.py python/branches/py3k-cdecimal/Lib/shutil.py python/branches/py3k-cdecimal/Lib/site.py python/branches/py3k-cdecimal/Lib/smtpd.py python/branches/py3k-cdecimal/Lib/smtplib.py python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py python/branches/py3k-cdecimal/Lib/sqlite3/test/regression.py python/branches/py3k-cdecimal/Lib/sqlite3/test/transactions.py python/branches/py3k-cdecimal/Lib/sre_parse.py python/branches/py3k-cdecimal/Lib/ssl.py python/branches/py3k-cdecimal/Lib/subprocess.py python/branches/py3k-cdecimal/Lib/symbol.py python/branches/py3k-cdecimal/Lib/sysconfig.py (contents, props changed) python/branches/py3k-cdecimal/Lib/tabnanny.py python/branches/py3k-cdecimal/Lib/tarfile.py python/branches/py3k-cdecimal/Lib/test/crashers/recursive_call.py python/branches/py3k-cdecimal/Lib/test/curses_tests.py python/branches/py3k-cdecimal/Lib/test/formatfloat_testcases.txt (props changed) python/branches/py3k-cdecimal/Lib/test/math_testcases.txt (props changed) python/branches/py3k-cdecimal/Lib/test/pystone.py python/branches/py3k-cdecimal/Lib/test/re_tests.py python/branches/py3k-cdecimal/Lib/test/regrtest.py python/branches/py3k-cdecimal/Lib/test/script_helper.py python/branches/py3k-cdecimal/Lib/test/support.py python/branches/py3k-cdecimal/Lib/test/test___future__.py python/branches/py3k-cdecimal/Lib/test/test__locale.py python/branches/py3k-cdecimal/Lib/test/test_abstract_numbers.py python/branches/py3k-cdecimal/Lib/test/test_aifc.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_array.py python/branches/py3k-cdecimal/Lib/test/test_asynchat.py python/branches/py3k-cdecimal/Lib/test/test_bigmem.py python/branches/py3k-cdecimal/Lib/test/test_binascii.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_binhex.py python/branches/py3k-cdecimal/Lib/test/test_bool.py python/branches/py3k-cdecimal/Lib/test/test_builtin.py python/branches/py3k-cdecimal/Lib/test/test_bytes.py python/branches/py3k-cdecimal/Lib/test/test_bz2.py python/branches/py3k-cdecimal/Lib/test/test_cgi.py python/branches/py3k-cdecimal/Lib/test/test_cmath.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_cmd.py python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py python/branches/py3k-cdecimal/Lib/test/test_cmd_line_script.py python/branches/py3k-cdecimal/Lib/test/test_code.py python/branches/py3k-cdecimal/Lib/test/test_codecencodings_cn.py python/branches/py3k-cdecimal/Lib/test/test_codecencodings_hk.py python/branches/py3k-cdecimal/Lib/test/test_codecencodings_jp.py python/branches/py3k-cdecimal/Lib/test/test_codecencodings_kr.py python/branches/py3k-cdecimal/Lib/test/test_codecencodings_tw.py python/branches/py3k-cdecimal/Lib/test/test_codecmaps_cn.py python/branches/py3k-cdecimal/Lib/test/test_codecmaps_hk.py python/branches/py3k-cdecimal/Lib/test/test_codecmaps_jp.py python/branches/py3k-cdecimal/Lib/test/test_codecmaps_kr.py python/branches/py3k-cdecimal/Lib/test/test_codecmaps_tw.py python/branches/py3k-cdecimal/Lib/test/test_codecs.py python/branches/py3k-cdecimal/Lib/test/test_coding.py python/branches/py3k-cdecimal/Lib/test/test_collections.py python/branches/py3k-cdecimal/Lib/test/test_compile.py python/branches/py3k-cdecimal/Lib/test/test_compileall.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_complex.py python/branches/py3k-cdecimal/Lib/test/test_contextlib.py python/branches/py3k-cdecimal/Lib/test/test_cprofile.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_crypt.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_csv.py python/branches/py3k-cdecimal/Lib/test/test_curses.py python/branches/py3k-cdecimal/Lib/test/test_dbm.py python/branches/py3k-cdecimal/Lib/test/test_dbm_dumb.py python/branches/py3k-cdecimal/Lib/test/test_decimal.py python/branches/py3k-cdecimal/Lib/test/test_deque.py python/branches/py3k-cdecimal/Lib/test/test_descr.py python/branches/py3k-cdecimal/Lib/test/test_dict.py python/branches/py3k-cdecimal/Lib/test/test_doctest.py python/branches/py3k-cdecimal/Lib/test/test_doctest2.py python/branches/py3k-cdecimal/Lib/test/test_docxmlrpc.py python/branches/py3k-cdecimal/Lib/test/test_eof.py python/branches/py3k-cdecimal/Lib/test/test_epoll.py python/branches/py3k-cdecimal/Lib/test/test_errno.py python/branches/py3k-cdecimal/Lib/test/test_exceptions.py python/branches/py3k-cdecimal/Lib/test/test_extcall.py python/branches/py3k-cdecimal/Lib/test/test_fcntl.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_file.py python/branches/py3k-cdecimal/Lib/test/test_filecmp.py python/branches/py3k-cdecimal/Lib/test/test_fileio.py python/branches/py3k-cdecimal/Lib/test/test_float.py python/branches/py3k-cdecimal/Lib/test/test_flufl.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_fnmatch.py python/branches/py3k-cdecimal/Lib/test/test_fork1.py python/branches/py3k-cdecimal/Lib/test/test_format.py python/branches/py3k-cdecimal/Lib/test/test_fractions.py python/branches/py3k-cdecimal/Lib/test/test_frozen.py python/branches/py3k-cdecimal/Lib/test/test_ftplib.py python/branches/py3k-cdecimal/Lib/test/test_functools.py python/branches/py3k-cdecimal/Lib/test/test_genericpath.py python/branches/py3k-cdecimal/Lib/test/test_getopt.py python/branches/py3k-cdecimal/Lib/test/test_global.py python/branches/py3k-cdecimal/Lib/test/test_grammar.py python/branches/py3k-cdecimal/Lib/test/test_grp.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_gzip.py python/branches/py3k-cdecimal/Lib/test/test_hashlib.py python/branches/py3k-cdecimal/Lib/test/test_heapq.py python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py python/branches/py3k-cdecimal/Lib/test/test_httplib.py python/branches/py3k-cdecimal/Lib/test/test_httpservers.py python/branches/py3k-cdecimal/Lib/test/test_imaplib.py python/branches/py3k-cdecimal/Lib/test/test_imp.py python/branches/py3k-cdecimal/Lib/test/test_import.py python/branches/py3k-cdecimal/Lib/test/test_importhooks.py python/branches/py3k-cdecimal/Lib/test/test_importlib.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_index.py python/branches/py3k-cdecimal/Lib/test/test_inspect.py python/branches/py3k-cdecimal/Lib/test/test_io.py python/branches/py3k-cdecimal/Lib/test/test_keywordonlyarg.py python/branches/py3k-cdecimal/Lib/test/test_linecache.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_logging.py python/branches/py3k-cdecimal/Lib/test/test_long.py python/branches/py3k-cdecimal/Lib/test/test_macpath.py python/branches/py3k-cdecimal/Lib/test/test_mailbox.py python/branches/py3k-cdecimal/Lib/test/test_marshal.py python/branches/py3k-cdecimal/Lib/test/test_memoryio.py python/branches/py3k-cdecimal/Lib/test/test_metaclass.py python/branches/py3k-cdecimal/Lib/test/test_minidom.py python/branches/py3k-cdecimal/Lib/test/test_multibytecodec.py python/branches/py3k-cdecimal/Lib/test/test_multibytecodec_support.py python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py python/branches/py3k-cdecimal/Lib/test/test_normalization.py python/branches/py3k-cdecimal/Lib/test/test_ntpath.py python/branches/py3k-cdecimal/Lib/test/test_optparse.py python/branches/py3k-cdecimal/Lib/test/test_os.py python/branches/py3k-cdecimal/Lib/test/test_ossaudiodev.py python/branches/py3k-cdecimal/Lib/test/test_parser.py python/branches/py3k-cdecimal/Lib/test/test_pdb.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_pep263.py python/branches/py3k-cdecimal/Lib/test/test_pep277.py python/branches/py3k-cdecimal/Lib/test/test_pep292.py python/branches/py3k-cdecimal/Lib/test/test_pipes.py python/branches/py3k-cdecimal/Lib/test/test_pkg.py python/branches/py3k-cdecimal/Lib/test/test_platform.py python/branches/py3k-cdecimal/Lib/test/test_popen.py python/branches/py3k-cdecimal/Lib/test/test_posix.py python/branches/py3k-cdecimal/Lib/test/test_posixpath.py python/branches/py3k-cdecimal/Lib/test/test_print.py python/branches/py3k-cdecimal/Lib/test/test_profile.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_profilehooks.py python/branches/py3k-cdecimal/Lib/test/test_property.py python/branches/py3k-cdecimal/Lib/test/test_pwd.py python/branches/py3k-cdecimal/Lib/test/test_pydoc.py python/branches/py3k-cdecimal/Lib/test/test_pyexpat.py python/branches/py3k-cdecimal/Lib/test/test_queue.py python/branches/py3k-cdecimal/Lib/test/test_random.py python/branches/py3k-cdecimal/Lib/test/test_re.py python/branches/py3k-cdecimal/Lib/test/test_richcmp.py python/branches/py3k-cdecimal/Lib/test/test_sax.py python/branches/py3k-cdecimal/Lib/test/test_scope.py python/branches/py3k-cdecimal/Lib/test/test_set.py python/branches/py3k-cdecimal/Lib/test/test_shutil.py python/branches/py3k-cdecimal/Lib/test/test_smtpnet.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_socket.py python/branches/py3k-cdecimal/Lib/test/test_socketserver.py python/branches/py3k-cdecimal/Lib/test/test_sqlite.py python/branches/py3k-cdecimal/Lib/test/test_ssl.py python/branches/py3k-cdecimal/Lib/test/test_strftime.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_strtod.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_struct.py python/branches/py3k-cdecimal/Lib/test/test_structmembers.py python/branches/py3k-cdecimal/Lib/test/test_subprocess.py python/branches/py3k-cdecimal/Lib/test/test_sys.py python/branches/py3k-cdecimal/Lib/test/test_sysconfig.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_tarfile.py python/branches/py3k-cdecimal/Lib/test/test_tcl.py python/branches/py3k-cdecimal/Lib/test/test_tempfile.py python/branches/py3k-cdecimal/Lib/test/test_thread.py python/branches/py3k-cdecimal/Lib/test/test_threaded_import.py python/branches/py3k-cdecimal/Lib/test/test_threading.py python/branches/py3k-cdecimal/Lib/test/test_threading_local.py python/branches/py3k-cdecimal/Lib/test/test_tokenize.py python/branches/py3k-cdecimal/Lib/test/test_ttk_guionly.py (contents, props changed) python/branches/py3k-cdecimal/Lib/test/test_ttk_textonly.py python/branches/py3k-cdecimal/Lib/test/test_types.py python/branches/py3k-cdecimal/Lib/test/test_unicode.py python/branches/py3k-cdecimal/Lib/test/test_unicodedata.py python/branches/py3k-cdecimal/Lib/test/test_unittest.py python/branches/py3k-cdecimal/Lib/test/test_urllib.py python/branches/py3k-cdecimal/Lib/test/test_urllib2.py python/branches/py3k-cdecimal/Lib/test/test_urllib2_localnet.py python/branches/py3k-cdecimal/Lib/test/test_urllib2net.py python/branches/py3k-cdecimal/Lib/test/test_urllib_response.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_urllibnet.py python/branches/py3k-cdecimal/Lib/test/test_urlparse.py python/branches/py3k-cdecimal/Lib/test/test_userstring.py python/branches/py3k-cdecimal/Lib/test/test_warnings.py python/branches/py3k-cdecimal/Lib/test/test_weakref.py python/branches/py3k-cdecimal/Lib/test/test_with.py python/branches/py3k-cdecimal/Lib/test/test_wsgiref.py (props changed) python/branches/py3k-cdecimal/Lib/test/test_xml_etree.py python/branches/py3k-cdecimal/Lib/test/test_xml_etree_c.py python/branches/py3k-cdecimal/Lib/test/test_xmlrpc.py python/branches/py3k-cdecimal/Lib/test/test_xmlrpc_net.py python/branches/py3k-cdecimal/Lib/test/test_zipimport.py python/branches/py3k-cdecimal/Lib/test/test_zipimport_support.py python/branches/py3k-cdecimal/Lib/threading.py python/branches/py3k-cdecimal/Lib/timeit.py python/branches/py3k-cdecimal/Lib/tkinter/messagebox.py python/branches/py3k-cdecimal/Lib/token.py python/branches/py3k-cdecimal/Lib/tokenize.py python/branches/py3k-cdecimal/Lib/trace.py python/branches/py3k-cdecimal/Lib/turtle.py python/branches/py3k-cdecimal/Lib/unittest/__init__.py python/branches/py3k-cdecimal/Lib/unittest/__main__.py python/branches/py3k-cdecimal/Lib/unittest/case.py python/branches/py3k-cdecimal/Lib/unittest/loader.py python/branches/py3k-cdecimal/Lib/unittest/main.py python/branches/py3k-cdecimal/Lib/unittest/result.py python/branches/py3k-cdecimal/Lib/unittest/runner.py python/branches/py3k-cdecimal/Lib/unittest/suite.py python/branches/py3k-cdecimal/Lib/unittest/util.py python/branches/py3k-cdecimal/Lib/urllib/__init__.py (props changed) python/branches/py3k-cdecimal/Lib/urllib/error.py (props changed) python/branches/py3k-cdecimal/Lib/urllib/request.py python/branches/py3k-cdecimal/Lib/urllib/response.py (props changed) python/branches/py3k-cdecimal/Lib/uu.py python/branches/py3k-cdecimal/Lib/webbrowser.py python/branches/py3k-cdecimal/Lib/wsgiref/handlers.py python/branches/py3k-cdecimal/Lib/wsgiref/headers.py python/branches/py3k-cdecimal/Lib/wsgiref/simple_server.py python/branches/py3k-cdecimal/Lib/wsgiref/util.py python/branches/py3k-cdecimal/Lib/xml/etree/ElementInclude.py python/branches/py3k-cdecimal/Lib/xml/etree/ElementPath.py python/branches/py3k-cdecimal/Lib/xml/etree/ElementTree.py python/branches/py3k-cdecimal/Lib/xml/etree/__init__.py python/branches/py3k-cdecimal/Mac/BuildScript/build-installer.py python/branches/py3k-cdecimal/Mac/Makefile.in python/branches/py3k-cdecimal/Mac/Tools/pythonw.c python/branches/py3k-cdecimal/Makefile.pre.in python/branches/py3k-cdecimal/Misc/ACKS python/branches/py3k-cdecimal/Misc/HISTORY python/branches/py3k-cdecimal/Misc/NEWS python/branches/py3k-cdecimal/Misc/Porting python/branches/py3k-cdecimal/Misc/SpecialBuilds.txt python/branches/py3k-cdecimal/Misc/build.sh python/branches/py3k-cdecimal/Misc/developers.txt python/branches/py3k-cdecimal/Misc/maintainers.rst (contents, props changed) python/branches/py3k-cdecimal/Misc/python-config.in python/branches/py3k-cdecimal/Modules/_ctypes/callbacks.c python/branches/py3k-cdecimal/Modules/_ctypes/callproc.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi.diff python/branches/py3k-cdecimal/Modules/_ctypes/libffi/LICENSE python/branches/py3k-cdecimal/Modules/_ctypes/libffi/Makefile.am python/branches/py3k-cdecimal/Modules/_ctypes/libffi/Makefile.in python/branches/py3k-cdecimal/Modules/_ctypes/libffi/README python/branches/py3k-cdecimal/Modules/_ctypes/libffi/aclocal.m4 python/branches/py3k-cdecimal/Modules/_ctypes/libffi/config.guess python/branches/py3k-cdecimal/Modules/_ctypes/libffi/config.sub python/branches/py3k-cdecimal/Modules/_ctypes/libffi/configure python/branches/py3k-cdecimal/Modules/_ctypes/libffi/configure.ac python/branches/py3k-cdecimal/Modules/_ctypes/libffi/fficonfig.h.in python/branches/py3k-cdecimal/Modules/_ctypes/libffi/include/Makefile.am python/branches/py3k-cdecimal/Modules/_ctypes/libffi/include/Makefile.in python/branches/py3k-cdecimal/Modules/_ctypes/libffi/include/ffi.h.in python/branches/py3k-cdecimal/Modules/_ctypes/libffi/include/ffi_common.h python/branches/py3k-cdecimal/Modules/_ctypes/libffi/missing python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/arm/sysv.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/frv/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/mips/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/mips/ffitarget.h python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/mips/n32.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/mips/o32.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/pa/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/powerpc/aix.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/powerpc/aix_closure.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/powerpc/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/powerpc/ffitarget.h python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/powerpc/sysv.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/prep_cif.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/s390/sysv.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/sh/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/sh/sysv.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/sh64/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/sh64/sysv.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/sparc/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/sparc/v8.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/darwin.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/ffi.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/ffi64.c python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/ffitarget.h python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/sysv.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/unix64.S python/branches/py3k-cdecimal/Modules/_ctypes/libffi/src/x86/win32.S python/branches/py3k-cdecimal/Modules/_curses_panel.c python/branches/py3k-cdecimal/Modules/_cursesmodule.c (contents, props changed) python/branches/py3k-cdecimal/Modules/_elementtree.c python/branches/py3k-cdecimal/Modules/_hashopenssl.c python/branches/py3k-cdecimal/Modules/_io/fileio.c python/branches/py3k-cdecimal/Modules/_lsprof.c python/branches/py3k-cdecimal/Modules/_math.c (props changed) python/branches/py3k-cdecimal/Modules/_math.h (props changed) python/branches/py3k-cdecimal/Modules/_sqlite/cache.c python/branches/py3k-cdecimal/Modules/_sqlite/cache.h python/branches/py3k-cdecimal/Modules/_sqlite/connection.c python/branches/py3k-cdecimal/Modules/_sqlite/connection.h python/branches/py3k-cdecimal/Modules/_sqlite/cursor.c python/branches/py3k-cdecimal/Modules/_sqlite/cursor.h python/branches/py3k-cdecimal/Modules/_sqlite/module.c python/branches/py3k-cdecimal/Modules/_sqlite/module.h python/branches/py3k-cdecimal/Modules/_sqlite/prepare_protocol.c python/branches/py3k-cdecimal/Modules/_sqlite/prepare_protocol.h python/branches/py3k-cdecimal/Modules/_sqlite/row.c python/branches/py3k-cdecimal/Modules/_sqlite/row.h python/branches/py3k-cdecimal/Modules/_sqlite/sqlitecompat.h python/branches/py3k-cdecimal/Modules/_sqlite/statement.c python/branches/py3k-cdecimal/Modules/_sqlite/statement.h python/branches/py3k-cdecimal/Modules/_sqlite/util.c python/branches/py3k-cdecimal/Modules/_sqlite/util.h python/branches/py3k-cdecimal/Modules/_sre.c python/branches/py3k-cdecimal/Modules/_ssl.c python/branches/py3k-cdecimal/Modules/_testcapimodule.c python/branches/py3k-cdecimal/Modules/_threadmodule.c python/branches/py3k-cdecimal/Modules/getpath.c python/branches/py3k-cdecimal/Modules/hashlib.h (props changed) python/branches/py3k-cdecimal/Modules/main.c python/branches/py3k-cdecimal/Modules/ossaudiodev.c python/branches/py3k-cdecimal/Modules/posixmodule.c python/branches/py3k-cdecimal/Modules/selectmodule.c python/branches/py3k-cdecimal/Modules/signalmodule.c python/branches/py3k-cdecimal/Modules/timemodule.c python/branches/py3k-cdecimal/Modules/unicodedata.c python/branches/py3k-cdecimal/Modules/unicodedata_db.h python/branches/py3k-cdecimal/Modules/unicodename_db.h python/branches/py3k-cdecimal/Modules/zipimport.c python/branches/py3k-cdecimal/Objects/abstract.c python/branches/py3k-cdecimal/Objects/codeobject.c python/branches/py3k-cdecimal/Objects/complexobject.c python/branches/py3k-cdecimal/Objects/dictobject.c python/branches/py3k-cdecimal/Objects/exceptions.c python/branches/py3k-cdecimal/Objects/floatobject.c python/branches/py3k-cdecimal/Objects/funcobject.c python/branches/py3k-cdecimal/Objects/listobject.c python/branches/py3k-cdecimal/Objects/lnotab_notes.txt (props changed) python/branches/py3k-cdecimal/Objects/longobject.c python/branches/py3k-cdecimal/Objects/object.c python/branches/py3k-cdecimal/Objects/setobject.c python/branches/py3k-cdecimal/Objects/stringlib/formatter.h python/branches/py3k-cdecimal/Objects/tupleobject.c python/branches/py3k-cdecimal/Objects/typeobject.c python/branches/py3k-cdecimal/Objects/unicodeobject.c python/branches/py3k-cdecimal/Objects/unicodetype_db.h python/branches/py3k-cdecimal/PC/os2emx/python27.def python/branches/py3k-cdecimal/PC/os2vacpp/python.def python/branches/py3k-cdecimal/Parser/myreadline.c python/branches/py3k-cdecimal/Parser/tokenizer.c python/branches/py3k-cdecimal/Python/bltinmodule.c python/branches/py3k-cdecimal/Python/ceval.c python/branches/py3k-cdecimal/Python/compile.c python/branches/py3k-cdecimal/Python/dtoa.c (props changed) python/branches/py3k-cdecimal/Python/errors.c python/branches/py3k-cdecimal/Python/import.c python/branches/py3k-cdecimal/Python/pyctype.c (props changed) python/branches/py3k-cdecimal/Python/pystate.c python/branches/py3k-cdecimal/Python/pystrtod.c python/branches/py3k-cdecimal/Python/pythonrun.c python/branches/py3k-cdecimal/Python/structmember.c python/branches/py3k-cdecimal/Python/sysmodule.c python/branches/py3k-cdecimal/Python/thread_cthread.h python/branches/py3k-cdecimal/Python/thread_foobar.h python/branches/py3k-cdecimal/Python/thread_lwp.h python/branches/py3k-cdecimal/Python/thread_nt.h python/branches/py3k-cdecimal/Python/thread_os2.h python/branches/py3k-cdecimal/Python/thread_pth.h python/branches/py3k-cdecimal/Python/thread_pthread.h python/branches/py3k-cdecimal/Python/thread_sgi.h python/branches/py3k-cdecimal/Python/thread_solaris.h python/branches/py3k-cdecimal/Python/thread_wince.h python/branches/py3k-cdecimal/Tools/README python/branches/py3k-cdecimal/Tools/ccbench/ccbench.py python/branches/py3k-cdecimal/Tools/faqwiz/faqw.py python/branches/py3k-cdecimal/Tools/freeze/freeze.py python/branches/py3k-cdecimal/Tools/i18n/makelocalealias.py python/branches/py3k-cdecimal/Tools/i18n/msgfmt.py python/branches/py3k-cdecimal/Tools/i18n/pygettext.py python/branches/py3k-cdecimal/Tools/msi/msi.py python/branches/py3k-cdecimal/Tools/msi/uuids.py python/branches/py3k-cdecimal/Tools/scripts/README python/branches/py3k-cdecimal/Tools/scripts/analyze_dxp.py (props changed) python/branches/py3k-cdecimal/Tools/scripts/byteyears.py python/branches/py3k-cdecimal/Tools/scripts/checkappend.py python/branches/py3k-cdecimal/Tools/scripts/checkpyc.py python/branches/py3k-cdecimal/Tools/scripts/classfix.py python/branches/py3k-cdecimal/Tools/scripts/cleanfuture.py python/branches/py3k-cdecimal/Tools/scripts/combinerefs.py python/branches/py3k-cdecimal/Tools/scripts/copytime.py python/branches/py3k-cdecimal/Tools/scripts/crlf.py python/branches/py3k-cdecimal/Tools/scripts/cvsfiles.py python/branches/py3k-cdecimal/Tools/scripts/db2pickle.py python/branches/py3k-cdecimal/Tools/scripts/dutree.py python/branches/py3k-cdecimal/Tools/scripts/eptags.py python/branches/py3k-cdecimal/Tools/scripts/find_recursionlimit.py python/branches/py3k-cdecimal/Tools/scripts/finddiv.py python/branches/py3k-cdecimal/Tools/scripts/findlinksto.py python/branches/py3k-cdecimal/Tools/scripts/findnocoding.py python/branches/py3k-cdecimal/Tools/scripts/fixcid.py python/branches/py3k-cdecimal/Tools/scripts/fixdiv.py python/branches/py3k-cdecimal/Tools/scripts/fixheader.py python/branches/py3k-cdecimal/Tools/scripts/fixnotice.py python/branches/py3k-cdecimal/Tools/scripts/fixps.py python/branches/py3k-cdecimal/Tools/scripts/ftpmirror.py python/branches/py3k-cdecimal/Tools/scripts/google.py python/branches/py3k-cdecimal/Tools/scripts/gprof2html.py python/branches/py3k-cdecimal/Tools/scripts/h2py.py python/branches/py3k-cdecimal/Tools/scripts/ifdef.py python/branches/py3k-cdecimal/Tools/scripts/lfcr.py python/branches/py3k-cdecimal/Tools/scripts/linktree.py python/branches/py3k-cdecimal/Tools/scripts/lll.py python/branches/py3k-cdecimal/Tools/scripts/logmerge.py python/branches/py3k-cdecimal/Tools/scripts/mailerdaemon.py (props changed) python/branches/py3k-cdecimal/Tools/scripts/md5sum.py python/branches/py3k-cdecimal/Tools/scripts/methfix.py python/branches/py3k-cdecimal/Tools/scripts/mkreal.py python/branches/py3k-cdecimal/Tools/scripts/ndiff.py python/branches/py3k-cdecimal/Tools/scripts/nm2def.py python/branches/py3k-cdecimal/Tools/scripts/objgraph.py python/branches/py3k-cdecimal/Tools/scripts/parseentities.py python/branches/py3k-cdecimal/Tools/scripts/pdeps.py python/branches/py3k-cdecimal/Tools/scripts/pickle2db.py python/branches/py3k-cdecimal/Tools/scripts/pindent.py python/branches/py3k-cdecimal/Tools/scripts/ptags.py python/branches/py3k-cdecimal/Tools/scripts/pysource.py python/branches/py3k-cdecimal/Tools/scripts/reindent.py python/branches/py3k-cdecimal/Tools/scripts/rgrep.py python/branches/py3k-cdecimal/Tools/scripts/suff.py python/branches/py3k-cdecimal/Tools/scripts/svneol.py python/branches/py3k-cdecimal/Tools/scripts/texi2html.py python/branches/py3k-cdecimal/Tools/scripts/treesync.py python/branches/py3k-cdecimal/Tools/scripts/untabify.py python/branches/py3k-cdecimal/Tools/scripts/which.py python/branches/py3k-cdecimal/Tools/scripts/xxci.py python/branches/py3k-cdecimal/Tools/ssl/get-remote-certificate.py python/branches/py3k-cdecimal/Tools/unicode/comparecodecs.py python/branches/py3k-cdecimal/Tools/unicode/gencodec.py python/branches/py3k-cdecimal/Tools/unicode/genwincodec.py (contents, props changed) python/branches/py3k-cdecimal/Tools/unicode/makeunicodedata.py python/branches/py3k-cdecimal/Tools/webchecker/wcgui.py python/branches/py3k-cdecimal/Tools/webchecker/webchecker.py python/branches/py3k-cdecimal/Tools/webchecker/websucker.py python/branches/py3k-cdecimal/Tools/webchecker/wsgui.py python/branches/py3k-cdecimal/configure python/branches/py3k-cdecimal/configure.in python/branches/py3k-cdecimal/setup.py Modified: python/branches/py3k-cdecimal/.hgignore ============================================================================== --- python/branches/py3k-cdecimal/.hgignore (original) +++ python/branches/py3k-cdecimal/.hgignore Thu Apr 1 11:38:52 2010 @@ -1,8 +1,8 @@ .gdb_history .purify .svn -Makefile -Makefile.pre +Makefile$ +Makefile.pre$ TAGS autom4te.cache build Modified: python/branches/py3k-cdecimal/Demo/cgi/cgi1.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/cgi/cgi1.py (original) +++ python/branches/py3k-cdecimal/Demo/cgi/cgi1.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/local/bin/python +#!/usr/bin/env python3 """CGI test 1 - check server setup.""" Modified: python/branches/py3k-cdecimal/Demo/cgi/cgi2.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/cgi/cgi2.py (original) +++ python/branches/py3k-cdecimal/Demo/cgi/cgi2.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/local/bin/python +#!/usr/bin/env python3 """CGI test 2 - basic use of cgi module.""" Modified: python/branches/py3k-cdecimal/Demo/cgi/cgi3.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/cgi/cgi3.py (original) +++ python/branches/py3k-cdecimal/Demo/cgi/cgi3.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/local/bin/python +#!/usr/bin/env python3 """CGI test 3 (persistent data).""" Modified: python/branches/py3k-cdecimal/Demo/comparisons/regextest.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/comparisons/regextest.py (original) +++ python/branches/py3k-cdecimal/Demo/comparisons/regextest.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # 1) Regular Expressions Test # Modified: python/branches/py3k-cdecimal/Demo/comparisons/sortingtest.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/comparisons/sortingtest.py (original) +++ python/branches/py3k-cdecimal/Demo/comparisons/sortingtest.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # 2) Sorting Test # Modified: python/branches/py3k-cdecimal/Demo/comparisons/systemtest.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/comparisons/systemtest.py (original) +++ python/branches/py3k-cdecimal/Demo/comparisons/systemtest.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # 3) System Test # Modified: python/branches/py3k-cdecimal/Demo/curses/life.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/curses/life.py (original) +++ python/branches/py3k-cdecimal/Demo/curses/life.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # life.py -- A curses-based version of Conway's Game of Life. # Contributed by AMK # Modified: python/branches/py3k-cdecimal/Demo/curses/ncurses.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/curses/ncurses.py (original) +++ python/branches/py3k-cdecimal/Demo/curses/ncurses.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # $Id$ # Modified: python/branches/py3k-cdecimal/Demo/curses/rain.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/curses/rain.py (original) +++ python/branches/py3k-cdecimal/Demo/curses/rain.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # $Id$ # Modified: python/branches/py3k-cdecimal/Demo/curses/repeat.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/curses/repeat.py (original) +++ python/branches/py3k-cdecimal/Demo/curses/repeat.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """repeat [-i SECONDS] Modified: python/branches/py3k-cdecimal/Demo/curses/tclock.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/curses/tclock.py (original) +++ python/branches/py3k-cdecimal/Demo/curses/tclock.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # $Id$ # Modified: python/branches/py3k-cdecimal/Demo/distutils/test2to3/maintest.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/distutils/test2to3/maintest.py (original) +++ python/branches/py3k-cdecimal/Demo/distutils/test2to3/maintest.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # The above line should get replaced with the path to the Python # interpreter; the block below should get 2to3-converted. Modified: python/branches/py3k-cdecimal/Demo/parser/test_parser.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/parser/test_parser.py (original) +++ python/branches/py3k-cdecimal/Demo/parser/test_parser.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # (Force the script to use the latest build.) # # test_parser.py Modified: python/branches/py3k-cdecimal/Demo/pdist/RCSProxy.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/pdist/RCSProxy.py (original) +++ python/branches/py3k-cdecimal/Demo/pdist/RCSProxy.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """RCS Proxy. Modified: python/branches/py3k-cdecimal/Demo/pdist/makechangelog.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/pdist/makechangelog.py (original) +++ python/branches/py3k-cdecimal/Demo/pdist/makechangelog.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Turn a pile of RCS log output into ChangeLog file entries. Modified: python/branches/py3k-cdecimal/Demo/pdist/rcvs.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/pdist/rcvs.py (original) +++ python/branches/py3k-cdecimal/Demo/pdist/rcvs.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Remote CVS -- command line interface""" Modified: python/branches/py3k-cdecimal/Demo/pdist/rrcs.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/pdist/rrcs.py (original) +++ python/branches/py3k-cdecimal/Demo/pdist/rrcs.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 "Remote RCS -- command line interface" Modified: python/branches/py3k-cdecimal/Demo/pysvr/pysvr.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/pysvr/pysvr.py (original) +++ python/branches/py3k-cdecimal/Demo/pysvr/pysvr.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """A multi-threaded telnet-like server that gives a Python prompt. Modified: python/branches/py3k-cdecimal/Demo/scripts/beer.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/beer.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/beer.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # By GvR, demystified after a version by Fredrik Lundh. Modified: python/branches/py3k-cdecimal/Demo/scripts/eqfix.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/eqfix.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/eqfix.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Fix Python source files to use the new equality test operator, i.e., # if x = y: ... Modified: python/branches/py3k-cdecimal/Demo/scripts/fact.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/fact.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/fact.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Factorize numbers. # The algorithm is not efficient, but easy to understand. Modified: python/branches/py3k-cdecimal/Demo/scripts/find-uname.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/find-uname.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/find-uname.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ For each argument on the command line, look for it in the set of all Unicode Modified: python/branches/py3k-cdecimal/Demo/scripts/from.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/from.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/from.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Print From and Subject of messages in $MAIL. # Extension to multiple mailboxes and other bells & whistles are left Modified: python/branches/py3k-cdecimal/Demo/scripts/lpwatch.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/lpwatch.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/lpwatch.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Watch line printer queue(s). # Intended for BSD 4.3 lpq. Modified: python/branches/py3k-cdecimal/Demo/scripts/makedir.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/makedir.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/makedir.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Like mkdir, but also make intermediate directories if necessary. # It is not an error if the given directory already exists (as long Modified: python/branches/py3k-cdecimal/Demo/scripts/markov.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/markov.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/markov.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 class Markov: def __init__(self, histsize, choice): Modified: python/branches/py3k-cdecimal/Demo/scripts/mboxconvert.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/mboxconvert.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/mboxconvert.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Convert MH directories (1 message per file) or MMDF mailboxes (4x^A # delimited) to unix mailbox (From ... delimited) on stdout. Modified: python/branches/py3k-cdecimal/Demo/scripts/morse.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/morse.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/morse.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # DAH should be three DOTs. # Space between DOTs and DAHs should be one DOT. Modified: python/branches/py3k-cdecimal/Demo/scripts/newslist.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/newslist.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/newslist.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 ####################################################################### # Newslist $Revision$ # Modified: python/branches/py3k-cdecimal/Demo/scripts/pi.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/pi.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/pi.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Print digits of pi forever. # Modified: python/branches/py3k-cdecimal/Demo/scripts/pp.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/pp.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/pp.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Emulate some Perl command line options. # Usage: pp [-a] [-c] [-d] [-e scriptline] [-F fieldsep] [-n] [-p] [file] ... Modified: python/branches/py3k-cdecimal/Demo/scripts/primes.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/primes.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/primes.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Print prime numbers in a given range Modified: python/branches/py3k-cdecimal/Demo/scripts/queens.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/queens.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/queens.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """N queens problem. Modified: python/branches/py3k-cdecimal/Demo/scripts/script.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/script.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/script.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # script.py -- Make typescript of terminal session. # Usage: Modified: python/branches/py3k-cdecimal/Demo/scripts/unbirthday.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/unbirthday.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/unbirthday.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Calculate your unbirthday count (see Alice in Wonderland). # This is defined as the number of days from your birth until today Modified: python/branches/py3k-cdecimal/Demo/scripts/update.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/scripts/update.py (original) +++ python/branches/py3k-cdecimal/Demo/scripts/update.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Update a bunch of files according to a script. # The input file contains lines of the form ::, Modified: python/branches/py3k-cdecimal/Demo/sockets/echosvr.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/echosvr.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/echosvr.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Python implementation of an 'echo' tcp server: echo all data it receives. # Modified: python/branches/py3k-cdecimal/Demo/sockets/finger.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/finger.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/finger.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Python interface to the Internet finger daemon. # Modified: python/branches/py3k-cdecimal/Demo/sockets/gopher.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/gopher.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/gopher.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # A simple gopher client. # Modified: python/branches/py3k-cdecimal/Demo/sockets/mcast.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/mcast.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/mcast.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Send/receive UDP multicast packets. # Requires that your OS kernel supports IP multicast. Modified: python/branches/py3k-cdecimal/Demo/sockets/rpython.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/rpython.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/rpython.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Remote python client. # Execute Python commands remotely and send output back. Modified: python/branches/py3k-cdecimal/Demo/sockets/rpythond.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/rpythond.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/rpythond.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Remote python server. # Execute Python commands remotely and send output back. Modified: python/branches/py3k-cdecimal/Demo/sockets/telnet.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/telnet.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/telnet.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Minimal interface to the Internet telnet protocol. # Modified: python/branches/py3k-cdecimal/Demo/sockets/throughput.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/throughput.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/throughput.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Test network throughput. # Modified: python/branches/py3k-cdecimal/Demo/sockets/udpecho.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/sockets/udpecho.py (original) +++ python/branches/py3k-cdecimal/Demo/sockets/udpecho.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Client and server for udp (datagram) echo. # Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/MimeViewer.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/MimeViewer.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/MimeViewer.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # View a single MIME multipart message. # Display each part as a box. Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/canvasevents.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/canvasevents.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/canvasevents.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from tkinter import * from Canvas import Oval, Group, CanvasText Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/dialog.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/dialog.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/dialog.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # A Python function that generates dialog boxes with a text message, # optional bitmap, and any number of buttons. Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/electrons.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/electrons.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/electrons.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Simulate "electrons" migrating across the screen. # An optional bitmap file in can be in the background. Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/kill.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/kill.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/kill.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Tkinter interface to Linux `kill' command. from tkinter import * Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/mbox.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/mbox.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/mbox.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Scan MH folder, display results in window Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/newmenubardemo.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/newmenubardemo.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/newmenubardemo.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Play with the new Tk 8.0 toplevel menu option.""" Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/rmt.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/rmt.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/rmt.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # A Python program implementing rmt, an application for remotely # controlling other Tk applications. Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/solitaire.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/solitaire.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/solitaire.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Solitaire game, much like the one that comes with MS Windows. Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/sortvisu.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/sortvisu.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/sortvisu.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Sorting algorithms visualizer using Tkinter. Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/svkill.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/svkill.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/svkill.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Tkinter interface to SYSV `ps' and `kill' commands. Modified: python/branches/py3k-cdecimal/Demo/tkinter/guido/tkman.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/tkinter/guido/tkman.py (original) +++ python/branches/py3k-cdecimal/Demo/tkinter/guido/tkman.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Tk man page browser -- currently only shows the Tcl/Tk man pages Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_I_dontlike_tiltdemo.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_I_dontlike_tiltdemo.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_I_dontlike_tiltdemo.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo-I_dont_like_tiltdemo.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_bytedesign.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_bytedesign.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_bytedesign.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_bytedesign.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_clock.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_clock.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_clock.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: cp1252 -*- """ turtle-example-suite: Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_forest.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_forest.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_forest.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtlegraphics-example-suite: tdemo_forest.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_fractalcurves.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_fractalcurves.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_fractalcurves.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_fractalCurves.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_lindenmayer_indian.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_lindenmayer_indian.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_lindenmayer_indian.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: xtx_lindenmayer_indian.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_minimal_hanoi.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_minimal_hanoi.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_minimal_hanoi.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_minimal_hanoi.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_nim.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_nim.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_nim.py Thu Apr 1 11:38:52 2010 @@ -1,227 +1,226 @@ -""" turtle-example-suite: - - tdemo_nim.py - -Play nim against the computer. The player -who takes the last stick is the winner. - -Implements the model-view-controller -design pattern. -""" - - -import turtle -import random -import time - -SCREENWIDTH = 640 -SCREENHEIGHT = 480 - -MINSTICKS = 7 -MAXSTICKS = 31 - -HUNIT = SCREENHEIGHT // 12 -WUNIT = SCREENWIDTH // ((MAXSTICKS // 5) * 11 + (MAXSTICKS % 5) * 2) - -SCOLOR = (63, 63, 31) -HCOLOR = (255, 204, 204) -COLOR = (204, 204, 255) - -def randomrow(): - return random.randint(MINSTICKS, MAXSTICKS) - -def computerzug(state): - xored = state[0] ^ state[1] ^ state[2] - if xored == 0: - return randommove(state) - for z in range(3): - s = state[z] ^ xored - if s <= state[z]: - move = (z, s) - return move - -def randommove(state): - m = max(state) - while True: - z = random.randint(0,2) - if state[z] > (m > 1): - break - rand = random.randint(m > 1, state[z]-1) - return z, rand - - -class NimModel(object): - def __init__(self, game): - self.game = game - - def setup(self): - if self.game.state not in [Nim.CREATED, Nim.OVER]: - return - self.sticks = [randomrow(), randomrow(), randomrow()] - self.player = 0 - self.winner = None - self.game.view.setup() - self.game.state = Nim.RUNNING - - def move(self, row, col): - maxspalte = self.sticks[row] - self.sticks[row] = col - self.game.view.notify_move(row, col, maxspalte, self.player) - if self.game_over(): - self.game.state = Nim.OVER - self.winner = self.player - self.game.view.notify_over() - elif self.player == 0: - self.player = 1 - row, col = computerzug(self.sticks) - self.move(row, col) - self.player = 0 - - def game_over(self): - return self.sticks == [0, 0, 0] - - def notify_move(self, row, col): - if self.sticks[row] <= col: - return - self.move(row, col) - - -class Stick(turtle.Turtle): - def __init__(self, row, col, game): - turtle.Turtle.__init__(self, visible=False) - self.row = row - self.col = col - self.game = game - x, y = self.coords(row, col) - self.shape("square") - self.shapesize(HUNIT/10.0, WUNIT/20.0) - self.speed(0) - self.pu() - self.goto(x,y) - self.color("white") - self.showturtle() - - def coords(self, row, col): - packet, remainder = divmod(col, 5) - x = (3 + 11 * packet + 2 * remainder) * WUNIT - y = (2 + 3 * row) * HUNIT - return x - SCREENWIDTH // 2 + WUNIT // 2, SCREENHEIGHT // 2 - y - HUNIT // 2 - - def makemove(self, x, y): - if self.game.state != Nim.RUNNING: - return - self.game.controller.notify_move(self.row, self.col) - - -class NimView(object): - def __init__(self, game): - self.game = game - self.screen = game.screen - self.model = game.model - self.screen.colormode(255) - self.screen.tracer(False) - self.screen.bgcolor((240, 240, 255)) - self.writer = turtle.Turtle(visible=False) - self.writer.pu() - self.writer.speed(0) - self.sticks = {} - for row in range(3): - for col in range(MAXSTICKS): - self.sticks[(row, col)] = Stick(row, col, game) - self.display("... a moment please ...") - self.screen.tracer(True) - - def display(self, msg1, msg2=None): - self.screen.tracer(False) - self.writer.clear() - if msg2 is not None: - self.writer.goto(0, - SCREENHEIGHT // 2 + 48) - self.writer.pencolor("red") - self.writer.write(msg2, align="center", font=("Courier",18,"bold")) - self.writer.goto(0, - SCREENHEIGHT // 2 + 20) - self.writer.pencolor("black") - self.writer.write(msg1, align="center", font=("Courier",14,"bold")) - self.screen.tracer(True) - - - def setup(self): - self.screen.tracer(False) - for row in range(3): - for col in range(self.model.sticks[row]): - self.sticks[(row, col)].color(SCOLOR) - for row in range(3): - for col in range(self.model.sticks[row], MAXSTICKS): - self.sticks[(row, col)].color("white") - self.display("Your turn! Click leftmost stick to remove.") - self.screen.tracer(True) - - def notify_move(self, row, col, maxspalte, player): - if player == 0: - farbe = HCOLOR - for s in range(col, maxspalte): - self.sticks[(row, s)].color(farbe) - else: - self.display(" ... thinking ... ") - time.sleep(0.5) - self.display(" ... thinking ... aaah ...") - farbe = COLOR - for s in range(maxspalte-1, col-1, -1): - time.sleep(0.2) - self.sticks[(row, s)].color(farbe) - self.display("Your turn! Click leftmost stick to remove.") - - def notify_over(self): - if self.game.model.winner == 0: - msg2 = "Congrats. You're the winner!!!" - else: - msg2 = "Sorry, the computer is the winner." - self.display("To play again press space bar. To leave press ESC.", msg2) - - def clear(self): - if self.game.state == Nim.OVER: - self.screen.clear() - -class NimController(object): - - def __init__(self, game): - self.game = game - self.sticks = game.view.sticks - self.BUSY = False - for stick in self.sticks.values(): - stick.onclick(stick.makemove) - self.game.screen.onkey(self.game.model.setup, "space") - self.game.screen.onkey(self.game.view.clear, "Escape") - self.game.view.display("Press space bar to start game") - self.game.screen.listen() - - def notify_move(self, row, col): - if self.BUSY: - return - self.BUSY = True - self.game.model.notify_move(row, col) - self.BUSY = False - -class Nim(object): - CREATED = 0 - RUNNING = 1 - OVER = 2 - def __init__(self, screen): - self.state = Nim.CREATED - self.screen = screen - self.model = NimModel(self) - self.view = NimView(self) - self.controller = NimController(self) - - -mainscreen = turtle.Screen() -mainscreen.mode("standard") -mainscreen.setup(SCREENWIDTH, SCREENHEIGHT) - -def main(): - nim = Nim(mainscreen) - return "EVENTLOOP!" - -if __name__ == "__main__": - main() - turtle.mainloop() - +""" turtle-example-suite: + + tdemo_nim.py + +Play nim against the computer. The player +who takes the last stick is the winner. + +Implements the model-view-controller +design pattern. +""" + + +import turtle +import random +import time + +SCREENWIDTH = 640 +SCREENHEIGHT = 480 + +MINSTICKS = 7 +MAXSTICKS = 31 + +HUNIT = SCREENHEIGHT // 12 +WUNIT = SCREENWIDTH // ((MAXSTICKS // 5) * 11 + (MAXSTICKS % 5) * 2) + +SCOLOR = (63, 63, 31) +HCOLOR = (255, 204, 204) +COLOR = (204, 204, 255) + +def randomrow(): + return random.randint(MINSTICKS, MAXSTICKS) + +def computerzug(state): + xored = state[0] ^ state[1] ^ state[2] + if xored == 0: + return randommove(state) + for z in range(3): + s = state[z] ^ xored + if s <= state[z]: + move = (z, s) + return move + +def randommove(state): + m = max(state) + while True: + z = random.randint(0,2) + if state[z] > (m > 1): + break + rand = random.randint(m > 1, state[z]-1) + return z, rand + + +class NimModel(object): + def __init__(self, game): + self.game = game + + def setup(self): + if self.game.state not in [Nim.CREATED, Nim.OVER]: + return + self.sticks = [randomrow(), randomrow(), randomrow()] + self.player = 0 + self.winner = None + self.game.view.setup() + self.game.state = Nim.RUNNING + + def move(self, row, col): + maxspalte = self.sticks[row] + self.sticks[row] = col + self.game.view.notify_move(row, col, maxspalte, self.player) + if self.game_over(): + self.game.state = Nim.OVER + self.winner = self.player + self.game.view.notify_over() + elif self.player == 0: + self.player = 1 + row, col = computerzug(self.sticks) + self.move(row, col) + self.player = 0 + + def game_over(self): + return self.sticks == [0, 0, 0] + + def notify_move(self, row, col): + if self.sticks[row] <= col: + return + self.move(row, col) + + +class Stick(turtle.Turtle): + def __init__(self, row, col, game): + turtle.Turtle.__init__(self, visible=False) + self.row = row + self.col = col + self.game = game + x, y = self.coords(row, col) + self.shape("square") + self.shapesize(HUNIT/10.0, WUNIT/20.0) + self.speed(0) + self.pu() + self.goto(x,y) + self.color("white") + self.showturtle() + + def coords(self, row, col): + packet, remainder = divmod(col, 5) + x = (3 + 11 * packet + 2 * remainder) * WUNIT + y = (2 + 3 * row) * HUNIT + return x - SCREENWIDTH // 2 + WUNIT // 2, SCREENHEIGHT // 2 - y - HUNIT // 2 + + def makemove(self, x, y): + if self.game.state != Nim.RUNNING: + return + self.game.controller.notify_move(self.row, self.col) + + +class NimView(object): + def __init__(self, game): + self.game = game + self.screen = game.screen + self.model = game.model + self.screen.colormode(255) + self.screen.tracer(False) + self.screen.bgcolor((240, 240, 255)) + self.writer = turtle.Turtle(visible=False) + self.writer.pu() + self.writer.speed(0) + self.sticks = {} + for row in range(3): + for col in range(MAXSTICKS): + self.sticks[(row, col)] = Stick(row, col, game) + self.display("... a moment please ...") + self.screen.tracer(True) + + def display(self, msg1, msg2=None): + self.screen.tracer(False) + self.writer.clear() + if msg2 is not None: + self.writer.goto(0, - SCREENHEIGHT // 2 + 48) + self.writer.pencolor("red") + self.writer.write(msg2, align="center", font=("Courier",18,"bold")) + self.writer.goto(0, - SCREENHEIGHT // 2 + 20) + self.writer.pencolor("black") + self.writer.write(msg1, align="center", font=("Courier",14,"bold")) + self.screen.tracer(True) + + + def setup(self): + self.screen.tracer(False) + for row in range(3): + for col in range(self.model.sticks[row]): + self.sticks[(row, col)].color(SCOLOR) + for row in range(3): + for col in range(self.model.sticks[row], MAXSTICKS): + self.sticks[(row, col)].color("white") + self.display("Your turn! Click leftmost stick to remove.") + self.screen.tracer(True) + + def notify_move(self, row, col, maxspalte, player): + if player == 0: + farbe = HCOLOR + for s in range(col, maxspalte): + self.sticks[(row, s)].color(farbe) + else: + self.display(" ... thinking ... ") + time.sleep(0.5) + self.display(" ... thinking ... aaah ...") + farbe = COLOR + for s in range(maxspalte-1, col-1, -1): + time.sleep(0.2) + self.sticks[(row, s)].color(farbe) + self.display("Your turn! Click leftmost stick to remove.") + + def notify_over(self): + if self.game.model.winner == 0: + msg2 = "Congrats. You're the winner!!!" + else: + msg2 = "Sorry, the computer is the winner." + self.display("To play again press space bar. To leave press ESC.", msg2) + + def clear(self): + if self.game.state == Nim.OVER: + self.screen.clear() + +class NimController(object): + + def __init__(self, game): + self.game = game + self.sticks = game.view.sticks + self.BUSY = False + for stick in self.sticks.values(): + stick.onclick(stick.makemove) + self.game.screen.onkey(self.game.model.setup, "space") + self.game.screen.onkey(self.game.view.clear, "Escape") + self.game.view.display("Press space bar to start game") + self.game.screen.listen() + + def notify_move(self, row, col): + if self.BUSY: + return + self.BUSY = True + self.game.model.notify_move(row, col) + self.BUSY = False + +class Nim(object): + CREATED = 0 + RUNNING = 1 + OVER = 2 + def __init__(self, screen): + self.state = Nim.CREATED + self.screen = screen + self.model = NimModel(self) + self.view = NimView(self) + self.controller = NimController(self) + + +mainscreen = turtle.Screen() +mainscreen.mode("standard") +mainscreen.setup(SCREENWIDTH, SCREENHEIGHT) + +def main(): + nim = Nim(mainscreen) + return "EVENTLOOP!" + +if __name__ == "__main__": + main() + turtle.mainloop() Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_paint.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_paint.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_paint.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_paint.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_peace.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_peace.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_peace.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_peace.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_penrose.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_penrose.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_penrose.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ xturtle-example-suite: xtx_kites_and_darts.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_planet_and_moon.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_planet_and_moon.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_planet_and_moon.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_planets_and_moon.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_round_dance.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_round_dance.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_round_dance.py Thu Apr 1 11:38:52 2010 @@ -1,90 +1,86 @@ -""" turtle-example-suite: - - tdemo_round_dance.py - -(Needs version 1.1 of the turtle module that -comes with Python 3.1) - -Dancing turtles have a compound shape -consisting of a series of triangles of -decreasing size. - -Turtles march along a circle while rotating -pairwise in opposite direction, with one -exception. Does that breaking of symmetry -enhance the attractiveness of the example? - -Press any key to stop the animation. - -Technically: demonstrates use of compound -shapes, transformation of shapes as well as -cloning turtles. The animation is -controlled through update(). -""" - -from turtle import * - -def stop(): - global running - running = False - -def main(): - global running - clearscreen() - bgcolor("gray10") - tracer(False) - shape("triangle") - f = 0.793402 - phi = 9.064678 - s = 5 - c = 1 - # create compound shape - sh = Shape("compound") - for i in range(10): - shapesize(s) - p =get_shapepoly() - s *= f - c *= f - tilt(-phi) - sh.addcomponent(p, (c, 0.25, 1-c), "black") - register_shape("multitri", sh) - # create dancers - shapesize(1) - shape("multitri") - pu() - setpos(0, -200) - dancers = [] - for i in range(180): - fd(7) - tilt(-4) - lt(2) - update() - if i % 12 == 0: - dancers.append(clone()) - home() - # dance - running = True - onkeypress(stop) - listen() - cs = 1 - while running: - ta = -4 - for dancer in dancers: - dancer.fd(7) - dancer.lt(2) - dancer.tilt(ta) - ta = -4 if ta > 0 else 2 - if cs < 180: - right(4) - shapesize(cs) - cs *= 1.005 - update() - return "DONE!" - -if __name__=='__main__': - print(main()) - mainloop() - - - - +""" turtle-example-suite: + + tdemo_round_dance.py + +(Needs version 1.1 of the turtle module that +comes with Python 3.1) + +Dancing turtles have a compound shape +consisting of a series of triangles of +decreasing size. + +Turtles march along a circle while rotating +pairwise in opposite direction, with one +exception. Does that breaking of symmetry +enhance the attractiveness of the example? + +Press any key to stop the animation. + +Technically: demonstrates use of compound +shapes, transformation of shapes as well as +cloning turtles. The animation is +controlled through update(). +""" + +from turtle import * + +def stop(): + global running + running = False + +def main(): + global running + clearscreen() + bgcolor("gray10") + tracer(False) + shape("triangle") + f = 0.793402 + phi = 9.064678 + s = 5 + c = 1 + # create compound shape + sh = Shape("compound") + for i in range(10): + shapesize(s) + p =get_shapepoly() + s *= f + c *= f + tilt(-phi) + sh.addcomponent(p, (c, 0.25, 1-c), "black") + register_shape("multitri", sh) + # create dancers + shapesize(1) + shape("multitri") + pu() + setpos(0, -200) + dancers = [] + for i in range(180): + fd(7) + tilt(-4) + lt(2) + update() + if i % 12 == 0: + dancers.append(clone()) + home() + # dance + running = True + onkeypress(stop) + listen() + cs = 1 + while running: + ta = -4 + for dancer in dancers: + dancer.fd(7) + dancer.lt(2) + dancer.tilt(ta) + ta = -4 if ta > 0 else 2 + if cs < 180: + right(4) + shapesize(cs) + cs *= 1.005 + update() + return "DONE!" + +if __name__=='__main__': + print(main()) + mainloop() Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_tree.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_tree.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_tree.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_tree.py Modified: python/branches/py3k-cdecimal/Demo/turtle/tdemo_yinyang.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/tdemo_yinyang.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/tdemo_yinyang.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ turtle-example-suite: tdemo_yinyang.py Modified: python/branches/py3k-cdecimal/Demo/turtle/turtleDemo.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/turtleDemo.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/turtleDemo.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import sys import os Modified: python/branches/py3k-cdecimal/Demo/turtle/turtledemo_two_canvases.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/turtle/turtledemo_two_canvases.py (original) +++ python/branches/py3k-cdecimal/Demo/turtle/turtledemo_two_canvases.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 ## DEMONSTRATES USE OF 2 CANVASES, SO CANNOT BE RUN IN DEMOVIEWER! """turtle example: Using TurtleScreen and RawTurtle for drawing on two distinct canvases. Modified: python/branches/py3k-cdecimal/Demo/zlib/minigzip.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/zlib/minigzip.py (original) +++ python/branches/py3k-cdecimal/Demo/zlib/minigzip.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Demo program for zlib; it compresses or decompresses files, but *doesn't* # delete the original. This doesn't support all of gzip's options. # Modified: python/branches/py3k-cdecimal/Demo/zlib/zlibdemo.py ============================================================================== --- python/branches/py3k-cdecimal/Demo/zlib/zlibdemo.py (original) +++ python/branches/py3k-cdecimal/Demo/zlib/zlibdemo.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Takes an optional filename, defaulting to this file itself. # Reads the file and compresses the content using level 1 and level 9 Modified: python/branches/py3k-cdecimal/Doc/Makefile ============================================================================== --- python/branches/py3k-cdecimal/Doc/Makefile (original) +++ python/branches/py3k-cdecimal/Doc/Makefile Thu Apr 1 11:38:52 2010 @@ -14,37 +14,45 @@ ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \ $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES) -.PHONY: help checkout update build html htmlhelp clean coverage dist check +.PHONY: help checkout update build html htmlhelp latex text changes linkcheck \ + suspicious coverage doctest pydoc-topics htmlview clean dist check serve \ + autobuild-dev autobuild-stable help: @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " text to make plain text files" - @echo " changes to make an overview over all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" + @echo " clean to remove build files" + @echo " update to update build tools" + @echo " html to make standalone HTML files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " text to make plain text files" + @echo " changes to make an overview over all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " coverage to check documentation coverage for library and C API" + @echo " doctest to run doctests in the documentation" + @echo " pydoc-topics to regenerate the pydoc topics file" + @echo " dist to create a \"dist\" directory with archived docs for download" @echo " suspicious to check for suspicious markup in output text" - @echo " coverage to check documentation coverage for library and C API" - @echo " dist to create a \"dist\" directory with archived docs for download" + @echo " check to run a check for frequent markup errors" + @echo " serve to serve the documentation on the localhost (8000)" # Note: if you update versions here, do the same in make.bat and README.txt checkout: @if [ ! -d tools/sphinx ]; then \ echo "Checking out Sphinx..."; \ - svn checkout $(SVNROOT)/external/Sphinx-0.6.3/sphinx tools/sphinx; \ + svn checkout $(SVNROOT)/external/Sphinx-0.6.5/sphinx tools/sphinx; \ fi @if [ ! -d tools/docutils ]; then \ echo "Checking out Docutils..."; \ - svn checkout $(SVNROOT)/external/docutils-0.5/docutils tools/docutils; \ + svn checkout $(SVNROOT)/external/docutils-0.6/docutils tools/docutils; \ fi @if [ ! -d tools/jinja2 ]; then \ echo "Checking out Jinja..."; \ - svn checkout $(SVNROOT)/external/Jinja-2.1.1/jinja2 tools/jinja2; \ + svn checkout $(SVNROOT)/external/Jinja-2.3.1/jinja2 tools/jinja2; \ fi @if [ ! -d tools/pygments ]; then \ echo "Checking out Pygments..."; \ - svn checkout $(SVNROOT)/external/Pygments-1.1.1/pygments tools/pygments; \ + svn checkout $(SVNROOT)/external/Pygments-1.3.1/pygments tools/pygments; \ fi update: clean checkout @@ -149,3 +157,21 @@ check: $(PYTHON) tools/rstlint.py -i tools + +serve: + ../Tools/scripts/serve.py build/html + +# Targets for daily automated doc build + +# for development releases: always build +autobuild-dev: + make update + make dist SPHINXOPTS='-A daily=1' + +# for stable releases: only build if not in pre-release stage (alpha, beta, rc) +autobuild-stable: + @case $(DISTVERSION) in *[abc]*) \ + echo "Not building; $(DISTVERSION) is not a release version."; \ + exit 1;; \ + esac + @make autobuild-dev Modified: python/branches/py3k-cdecimal/Doc/README.txt ============================================================================== --- python/branches/py3k-cdecimal/Doc/README.txt (original) +++ python/branches/py3k-cdecimal/Doc/README.txt Thu Apr 1 11:38:52 2010 @@ -77,25 +77,27 @@ Without make ------------ -You'll need to checkout the Sphinx package to the `tools/` directory:: +You'll need to install the Sphinx package, either by checking it out via :: - svn co http://svn.python.org/projects/external/Sphinx-0.6.1/sphinx tools/sphinx + svn co http://svn.python.org/projects/external/Sphinx-0.6.5/sphinx tools/sphinx + +or by installing it from PyPI. Then, you need to install Docutils, either by checking it out via :: - svn co http://svn.python.org/projects/external/docutils-0.5/docutils tools/docutils + svn co http://svn.python.org/projects/external/docutils-0.6/docutils tools/docutils or by installing it from http://docutils.sf.net/. You also need Jinja2, either by checking it out via :: - svn co http://svn.python.org/projects/external/Jinja-2.1.1/jinja2 tools/jinja2 + svn co http://svn.python.org/projects/external/Jinja-2.3.1/jinja2 tools/jinja2 or by installing it from PyPI. You can optionally also install Pygments, either as a checkout via :: - svn co http://svn.python.org/projects/external/Pygments-1.1.1/pygments tools/pygments + svn co http://svn.python.org/projects/external/Pygments-1.3.1/pygments tools/pygments or from PyPI at http://pypi.python.org/pypi/Pygments. Modified: python/branches/py3k-cdecimal/Doc/bugs.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/bugs.rst (original) +++ python/branches/py3k-cdecimal/Doc/bugs.rst Thu Apr 1 11:38:52 2010 @@ -23,10 +23,9 @@ http://docs.python.org/dev to see if the bug has been fixed. If the problem you're reporting is not already in the bug tracker, go back to -the Python Bug Tracker. If you don't already have a tracker account, select the -"Register" link in the sidebar and undergo the registration procedure. -Otherwise, if you're not logged in, enter your credentials and select "Login". -It is not possible to submit a bug report anonymously. +the Python Bug Tracker and log in. If you don't already have a tracker account, +select the "Register" link or, if you use OpenID, one of the OpenID provider +logos in the sidebar. It is not possible to submit a bug report anonymously. Being now logged in, you can submit a bug. Select the "Create New" link in the sidebar to open the bug reporting form. @@ -43,7 +42,8 @@ Each bug report will be assigned to a developer who will determine what needs to be done to correct the problem. You will receive an update each time action is -taken on the bug. +taken on the bug. See http://www.python.org/dev/workflow/ for a detailed +description of the issue workflow. .. seealso:: Modified: python/branches/py3k-cdecimal/Doc/c-api/conversion.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/c-api/conversion.rst (original) +++ python/branches/py3k-cdecimal/Doc/c-api/conversion.rst Thu Apr 1 11:38:52 2010 @@ -51,21 +51,6 @@ The following functions provide locale-independent string to number conversions. -.. cfunction:: double PyOS_ascii_strtod(const char *nptr, char **endptr) - - Convert a string to a :ctype:`double`. This function behaves like the Standard C - function :cfunc:`strtod` does in the C locale. It does this without changing the - current locale, since that would not be thread-safe. - - :cfunc:`PyOS_ascii_strtod` should typically be used for reading configuration - files or other non-user input that should be locale independent. - - See the Unix man page :manpage:`strtod(2)` for details. - - .. deprecated:: 3.1 - Use :cfunc:`PyOS_string_to_double` instead. - - .. cfunction:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception) Convert a string ``s`` to a :ctype:`double`, raising a Python @@ -100,20 +85,6 @@ .. versionadded:: 3.1 -.. cfunction:: char* PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d) - - Convert a :ctype:`double` to a string using the ``'.'`` as the decimal - separator. *format* is a :cfunc:`printf`\ -style format string specifying the - number format. Allowed conversion characters are ``'e'``, ``'E'``, ``'f'``, - ``'F'``, ``'g'`` and ``'G'``. - - The return value is a pointer to *buffer* with the converted string or NULL if - the conversion failed. - - .. deprecated:: 3.1 - Use :cfunc:`PyOS_double_to_string` instead. - - .. cfunction:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype) Convert a :ctype:`double` *val* to a string using supplied @@ -148,16 +119,6 @@ .. versionadded:: 3.1 -.. cfunction:: double PyOS_ascii_atof(const char *nptr) - - Convert a string to a :ctype:`double` in a locale-independent way. - - See the Unix man page :manpage:`atof(2)` for details. - - .. deprecated:: 3.1 - Use :cfunc:`PyOS_string_to_double` instead. - - .. cfunction:: char* PyOS_stricmp(char *s1, char *s2) Case insensitive comparison of strings. The function works almost Modified: python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst (original) +++ python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst Thu Apr 1 11:38:52 2010 @@ -214,7 +214,7 @@ .. note:: The `"%lld"` and `"%llu"` format specifiers are only available - when `HAVE_LONG_LONG` is defined. + when :const:`HAVE_LONG_LONG` is defined. .. versionchanged:: 3.2 Support for `"%lld"` and `"%llu"` added. @@ -471,6 +471,36 @@ This steals a reference to *ctx*. +Recursion Control +================= + +These two functions provide a way to perform safe recursive calls at the C +level, both in the core and in extension modules. They are needed if the +recursive code does not necessarily invoke Python code (which tracks its +recursion depth automatically). + +.. cfunction:: int Py_EnterRecursiveCall(char *where) + + Marks a point where a recursive C-level call is about to be performed. + + If :const:`USE_STACKCHECK` is defined, this function checks if the the OS + stack overflowed using :cfunc:`PyOS_CheckStack`. In this is the case, it + sets a :exc:`MemoryError` and returns a nonzero value. + + The function then checks if the recursion limit is reached. If this is the + case, a :exc:`RuntimeError` is set and a nonzero value is returned. + Otherwise, zero is returned. + + *where* should be a string such as ``" in instance check"`` to be + concatenated to the :exc:`RuntimeError` message caused by the recursion depth + limit. + +.. cfunction:: void Py_LeaveRecursiveCall() + + Ends a :cfunc:`Py_EnterRecursiveCall`. Must be called once for each + *successful* invocation of :cfunc:`Py_EnterRecursiveCall`. + + .. _standardexceptions: Standard Exceptions Modified: python/branches/py3k-cdecimal/Doc/c-api/gcsupport.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/c-api/gcsupport.rst (original) +++ python/branches/py3k-cdecimal/Doc/c-api/gcsupport.rst Thu Apr 1 11:38:52 2010 @@ -28,7 +28,7 @@ Constructors for container types must conform to two rules: #. The memory for the object must be allocated using :cfunc:`PyObject_GC_New` - or :cfunc:`PyObject_GC_VarNew`. + or :cfunc:`PyObject_GC_NewVar`. #. Once all the fields which may contain references to other containers are initialized, it must call :cfunc:`PyObject_GC_Track`. Modified: python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst (original) +++ python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst Thu Apr 1 11:38:52 2010 @@ -182,7 +182,7 @@ instance; this is normally :cfunc:`PyObject_Del` if the instance was allocated using :cfunc:`PyObject_New` or :cfunc:`PyObject_VarNew`, or :cfunc:`PyObject_GC_Del` if the instance was allocated using - :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_VarNew`. + :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_NewVar`. This field is inherited by subtypes. Modified: python/branches/py3k-cdecimal/Doc/c-api/unicode.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/c-api/unicode.rst (original) +++ python/branches/py3k-cdecimal/Doc/c-api/unicode.rst Thu Apr 1 11:38:52 2010 @@ -313,7 +313,7 @@ .. note:: The `"%lld"` and `"%llu"` format specifiers are only available - when `HAVE_LONG_LONG` is defined. + when :const:`HAVE_LONG_LONG` is defined. .. versionchanged:: 3.2 Support for `"%lld"` and `"%llu"` added. Modified: python/branches/py3k-cdecimal/Doc/distutils/examples.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/distutils/examples.rst (original) +++ python/branches/py3k-cdecimal/Doc/distutils/examples.rst Thu Apr 1 11:38:52 2010 @@ -257,9 +257,9 @@ (maintainer and maintainer_email) must be supplied -If you use the reStructuredText syntax in the `long_description` field and +If you use the reStructuredText syntax in the ``long_description`` field and `docutils `_ is installed you can check if -the syntax is fine with the ``check`` command, using the `restructuredtext` +the syntax is fine with the ``check`` command, using the ``restructuredtext`` option. For example, if the :file:`setup.py` script is changed like this:: @@ -278,7 +278,7 @@ url='http://example.com', long_description=desc) Where the long description is broken, ``check`` will be able to detect it -by using the `docutils` parser:: +by using the :mod:`docutils` parser:: $ pythontrunk setup.py check --restructuredtext running check @@ -293,20 +293,20 @@ The :func:`distutils.core.setup` function provides a command-line interface that allows you to query the metadata fields of a project through the -`setup.py` script of a given project:: +:file:`setup.py` script of a given project:: $ python setup.py --name distribute -This call reads the `name` metadata by running the +This call reads the ``name`` metadata by running the :func:`distutils.core.setup` function. Although, when a source or binary distribution is created with Distutils, the metadata fields are written in a static file called :file:`PKG-INFO`. When a Distutils-based project is installed in Python, the :file:`PKG-INFO` file is copied alongside the modules and packages of the distribution under :file:`NAME-VERSION-pyX.X.egg-info`, -where `NAME` is the name of the project, `VERSION` its version as defined -in the Metadata, and `pyX.X` the major and minor version of Python like -`2.7` or `3.2`. +where ``NAME`` is the name of the project, ``VERSION`` its version as defined +in the Metadata, and ``pyX.X`` the major and minor version of Python like +``2.7`` or ``3.2``. You can read back this static file, by using the :class:`distutils.dist.DistributionMetadata` class and its Modified: python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst (original) +++ python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst Thu Apr 1 11:38:52 2010 @@ -54,9 +54,9 @@ requires the :program:`compress` program. Notice that this format is now pending for deprecation and will be removed in the future versions of Python. -When using any ``tar`` format (``gztar``, ``bztar``, ``ztar`` or ``tar``), you -can specify under Unix the ``owner`` and ``group`` names that will be set for -each member of the archive. +When using any ``tar`` format (``gztar``, ``bztar``, ``ztar`` or +``tar``) under Unix, you can specify the ``owner`` and ``group`` names +that will be set for each member of the archive. For example, if you want all files of the archive to be owned by root:: Modified: python/branches/py3k-cdecimal/Doc/distutils/uploading.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/distutils/uploading.rst (original) +++ python/branches/py3k-cdecimal/Doc/distutils/uploading.rst Thu Apr 1 11:38:52 2010 @@ -60,13 +60,13 @@ setup(name='Distutils', long_description=open('README.txt')) -In that case, `README.txt` is a regular reStructuredText text file located -in the root of the package besides `setup.py`. +In that case, :file:`README.txt` is a regular reStructuredText text file located +in the root of the package besides :file:`setup.py`. To prevent registering broken reStructuredText content, you can use the -:program:`rst2html` program that is provided by the `docutils` package +:program:`rst2html` program that is provided by the :mod:`docutils` package and check the ``long_description`` from the command line:: $ python setup.py --long-description | rst2html.py > output.html -`docutils` will display a warning if there's something wrong with your syntax. +:mod:`docutils` will display a warning if there's something wrong with your syntax. Modified: python/branches/py3k-cdecimal/Doc/extending/extending.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/extending/extending.rst (original) +++ python/branches/py3k-cdecimal/Doc/extending/extending.rst Thu Apr 1 11:38:52 2010 @@ -381,12 +381,7 @@ A more substantial example module is included in the Python source distribution as :file:`Modules/xxmodule.c`. This file may be used as a template or simply -read as an example. The :program:`modulator.py` script included in the source -distribution or Windows install provides a simple graphical user interface for -declaring the functions and objects which a module should implement, and can -generate a template which can be filled in. The script lives in the -:file:`Tools/modulator/` directory; see the :file:`README` file there for more -information. +read as an example. .. _compilation: Modified: python/branches/py3k-cdecimal/Doc/extending/newtypes.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/extending/newtypes.rst (original) +++ python/branches/py3k-cdecimal/Doc/extending/newtypes.rst Thu Apr 1 11:38:52 2010 @@ -236,7 +236,7 @@ We've added an extra include:: - #include "structmember.h" + #include This include provides declarations that we use to handle attributes, as described a bit later. Modified: python/branches/py3k-cdecimal/Doc/faq/windows.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/faq/windows.rst (original) +++ python/branches/py3k-cdecimal/Doc/faq/windows.rst Thu Apr 1 11:38:52 2010 @@ -445,13 +445,15 @@ How do I emulate os.kill() in Windows? -------------------------------------- -Use win32api:: +To terminate a process, you can use ctypes:: + + import ctypes def kill(pid): """kill function for Win32""" - import win32api - handle = win32api.OpenProcess(1, 0, pid) - return (0 != win32api.TerminateProcess(handle, 0)) + kernel32 = ctypes.windll.kernel32 + handle = kernel32.OpenProcess(1, 0, pid) + return (0 != kernel32.TerminateProcess(handle, 0)) Why does os.path.isdir() fail on NT shared directories? Modified: python/branches/py3k-cdecimal/Doc/howto/unicode.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/howto/unicode.rst (original) +++ python/branches/py3k-cdecimal/Doc/howto/unicode.rst Thu Apr 1 11:38:52 2010 @@ -403,7 +403,7 @@ from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means "Number, other", ``'Mn'`` is "Mark, nonspacing", and ``'So'`` is "Symbol, other". See - for a + for a list of category codes. References Modified: python/branches/py3k-cdecimal/Doc/howto/webservers.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/howto/webservers.rst (original) +++ python/branches/py3k-cdecimal/Doc/howto/webservers.rst Thu Apr 1 11:38:52 2010 @@ -38,7 +38,7 @@ When a user enters a web site, his browser makes a connection to the site's webserver (this is called the *request*). The server looks up the file in the file system and sends it back to the user's browser, which displays it (this is -the *response*). This is roughly how the unterlying protocol, HTTP works. +the *response*). This is roughly how the underlying protocol, HTTP, works. Now, dynamic web sites are not files in the file system, but rather programs which are run by the web server when a request comes in. They can do all sorts @@ -677,7 +677,7 @@ "normal" Python programmers use the very mature Zope components. Another framework that's already been mentioned is `Pylons`_. Pylons is much -like TurboGears with ab even stronger emphasis on flexibility, which is bought +like TurboGears with an even stronger emphasis on flexibility, which is bought at the cost of being more difficult to use. Nearly every component can be exchanged, which makes it necessary to use the documentation of every single component, because there are so many Pylons combinations possible that can Modified: python/branches/py3k-cdecimal/Doc/includes/email-alternative.py ============================================================================== --- python/branches/py3k-cdecimal/Doc/includes/email-alternative.py (original) +++ python/branches/py3k-cdecimal/Doc/includes/email-alternative.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/python +#!/usr/bin/env python3 import smtplib Modified: python/branches/py3k-cdecimal/Doc/includes/email-dir.py ============================================================================== --- python/branches/py3k-cdecimal/Doc/includes/email-dir.py (original) +++ python/branches/py3k-cdecimal/Doc/includes/email-dir.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Send the contents of a directory as a MIME message.""" Modified: python/branches/py3k-cdecimal/Doc/includes/email-unpack.py ============================================================================== --- python/branches/py3k-cdecimal/Doc/includes/email-unpack.py (original) +++ python/branches/py3k-cdecimal/Doc/includes/email-unpack.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unpack a MIME message into a directory of files.""" Modified: python/branches/py3k-cdecimal/Doc/includes/minidom-example.py ============================================================================== --- python/branches/py3k-cdecimal/Doc/includes/minidom-example.py (original) +++ python/branches/py3k-cdecimal/Doc/includes/minidom-example.py Thu Apr 1 11:38:52 2010 @@ -19,11 +19,11 @@ dom = xml.dom.minidom.parseString(document) def getText(nodelist): - rc = "" + rc = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: - rc = rc + node.data - return rc + rc.append(node.data) + return ''.join(rc) def handleSlideshow(slideshow): print("") Modified: python/branches/py3k-cdecimal/Doc/library/2to3.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/2to3.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/2to3.rst Thu Apr 1 11:38:52 2010 @@ -130,8 +130,8 @@ Fixes dictionary iteration methods. :meth:`dict.iteritems` is converted to :meth:`dict.items`, :meth:`dict.iterkeys` to :meth:`dict.keys`, and :meth:`dict.itervalues` to :meth:`dict.values`. Similarly, - :meth:`dict.viewitems`, :meth:`dict.viewkeys` and :meth:`dict.viewvalues` - are converted respectively to :meth:`dict.items`, :meth:`dict.keys` and + :meth:`dict.viewitems`, :meth:`dict.viewkeys` and :meth:`dict.viewvalues` are + converted respectively to :meth:`dict.items`, :meth:`dict.keys` and :meth:`dict.values`. It also wraps existing usages of :meth:`dict.items`, :meth:`dict.keys`, and :meth:`dict.values` in a call to :class:`list`. @@ -148,6 +148,11 @@ Removes usage of :func:`execfile`. The argument to :func:`execfile` is wrapped in calls to :func:`open`, :func:`compile`, and :func:`exec`. +.. 2to3fixer:: exitfunc + + Changes assignment of :attr:`sys.exitfunc` to use of the :mod:`atexit` + module. + .. 2to3fixer:: filter Wraps :func:`filter` usage in a :class:`list` call. Modified: python/branches/py3k-cdecimal/Doc/library/allos.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/allos.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/allos.rst Thu Apr 1 11:38:52 2010 @@ -15,6 +15,7 @@ os.rst io.rst time.rst + argparse.rst optparse.rst getopt.rst logging.rst Modified: python/branches/py3k-cdecimal/Doc/library/asyncore.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/asyncore.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/asyncore.rst Thu Apr 1 11:38:52 2010 @@ -201,7 +201,8 @@ .. method:: bind(address) Bind the socket to *address*. The socket must not already be bound. (The - format of *address* depends on the address family --- see above.) To mark + format of *address* depends on the address family --- refer to the + :mod:`socket` documentation for more information.) To mark the socket as re-usable (setting the :const:`SO_REUSEADDR` option), call the :class:`dispatcher` object's :meth:`set_reuse_addr` method. Modified: python/branches/py3k-cdecimal/Doc/library/builtins.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/builtins.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/builtins.rst Thu Apr 1 11:38:52 2010 @@ -7,7 +7,7 @@ This module provides direct access to all 'built-in' identifiers of Python; for example, ``builtins.open`` is the full name for the built-in function -:func:`open`. See chapter :ref:`builtin`. +:func:`open`. This module is not normally accessed explicitly by most applications, but can be useful in modules that provide objects with the same name as a built-in value, Modified: python/branches/py3k-cdecimal/Doc/library/bz2.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/bz2.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/bz2.rst Thu Apr 1 11:38:52 2010 @@ -18,9 +18,10 @@ Here is a summary of the features offered by the bz2 module: * :class:`BZ2File` class implements a complete file interface, including - :meth:`readline`, :meth:`readlines`, :meth:`writelines`, :meth:`seek`, etc; + :meth:`~BZ2File.readline`, :meth:`~BZ2File.readlines`, + :meth:`~BZ2File.writelines`, :meth:`~BZ2File.seek`, etc; -* :class:`BZ2File` class implements emulated :meth:`seek` support; +* :class:`BZ2File` class implements emulated :meth:`~BZ2File.seek` support; * :class:`BZ2File` class implements universal newline support; @@ -73,15 +74,16 @@ .. method:: read([size]) - Read at most *size* uncompressed bytes, returned as a string. If the + Read at most *size* uncompressed bytes, returned as a byte string. If the *size* argument is negative or omitted, read until EOF is reached. .. method:: readline([size]) - Return the next line from the file, as a string, retaining newline. A - non-negative *size* argument limits the maximum number of bytes to return - (an incomplete line may be returned then). Return an empty string at EOF. + Return the next line from the file, as a byte string, retaining newline. + A non-negative *size* argument limits the maximum number of bytes to + return (an incomplete line may be returned then). Return an empty byte + string at EOF. .. method:: readlines([size]) @@ -111,15 +113,16 @@ .. method:: write(data) - Write string *data* to file. Note that due to buffering, :meth:`close` may - be needed before the file on disk reflects the data written. + Write the byte string *data* to file. Note that due to buffering, + :meth:`close` may be needed before the file on disk reflects the data + written. - .. method:: writelines(sequence_of_strings) + .. method:: writelines(sequence_of_byte_strings) - Write the sequence of strings to the file. Note that newlines are not - added. The sequence can be any iterable object producing strings. This is - equivalent to calling write() for each string. + Write the sequence of byte strings to the file. Note that newlines are not + added. The sequence can be any iterable object producing byte strings. + This is equivalent to calling write() for each byte string. Sequential (de)compression Modified: python/branches/py3k-cdecimal/Doc/library/codecs.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/codecs.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/codecs.rst Thu Apr 1 11:38:52 2010 @@ -77,7 +77,7 @@ * ``'xmlcharrefreplace'``: replace with the appropriate XML character reference (for encoding only) * ``'backslashreplace'``: replace with backslashed escape sequences (for - encoding only + encoding only) * ``'surrogateescape'``: replace with surrogate U+DCxx, see :pep:`383` as well as any other error handling name defined via :func:`register_error`. @@ -1065,11 +1065,13 @@ +-----------------+--------------------------------+--------------------------------+ | iso8859_10 | iso-8859-10, latin6, L6 | Nordic languages | +-----------------+--------------------------------+--------------------------------+ -| iso8859_13 | iso-8859-13 | Baltic languages | +| iso8859_13 | iso-8859-13, latin7, L7 | Baltic languages | +-----------------+--------------------------------+--------------------------------+ | iso8859_14 | iso-8859-14, latin8, L8 | Celtic languages | +-----------------+--------------------------------+--------------------------------+ -| iso8859_15 | iso-8859-15 | Western Europe | +| iso8859_15 | iso-8859-15, latin9, L9 | Western Europe | ++-----------------+--------------------------------+--------------------------------+ +| iso8859_16 | iso-8859-16, latin10, L10 | South-Eastern Europe | +-----------------+--------------------------------+--------------------------------+ | johab | cp1361, ms1361 | Korean | +-----------------+--------------------------------+--------------------------------+ Modified: python/branches/py3k-cdecimal/Doc/library/csv.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/csv.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/csv.rst Thu Apr 1 11:38:52 2010 @@ -392,6 +392,16 @@ A read-only description of the dialect in use by the writer. +DictWriter objects have the following public method: + + +.. method:: DictWriter.writeheader() + + Write a row with the field names (as specified in the constructor). + + .. versionadded:: 3.2 + + .. _csv-examples: Examples Modified: python/branches/py3k-cdecimal/Doc/library/ctypes.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/ctypes.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/ctypes.rst Thu Apr 1 11:38:52 2010 @@ -2207,6 +2207,13 @@ Represents the C :ctype:`size_t` datatype. +.. class:: c_ssize_t + + Represents the C :ctype:`ssize_t` datatype. + + .. versionadded:: 3.2 + + .. class:: c_ubyte Represents the C :ctype:`unsigned char` datatype, it interprets the value as Modified: python/branches/py3k-cdecimal/Doc/library/datetime.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/datetime.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/datetime.rst Thu Apr 1 11:38:52 2010 @@ -1454,8 +1454,8 @@ Note that there are unavoidable subtleties twice per year in a :class:`tzinfo` subclass accounting for both standard and daylight time, at the DST transition points. For concreteness, consider US Eastern (UTC -0500), where EDT begins the -minute after 1:59 (EST) on the first Sunday in April, and ends the minute after -1:59 (EDT) on the last Sunday in October:: +minute after 1:59 (EST) on the second Sunday in March, and ends the minute after +1:59 (EDT) on the first Sunday in November:: UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM Modified: python/branches/py3k-cdecimal/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/decimal.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/decimal.rst Thu Apr 1 11:38:52 2010 @@ -1218,9 +1218,12 @@ - at least one of ``x`` or ``y`` must be nonzero - ``modulo`` must be nonzero and have at most 'precision' digits - The result of ``Context.power(x, y, modulo)`` is identical to the result - that would be obtained by computing ``(x**y) % modulo`` with unbounded - precision, but is computed more efficiently. It is always exact. + The value resulting from ``Context.power(x, y, modulo)`` is + equal to the value that would be obtained by computing ``(x**y) + % modulo`` with unbounded precision, but is computed more + efficiently. The exponent of the result is zero, regardless of + the exponents of ``x``, ``y`` and ``modulo``. The result is + always exact. .. method:: quantize(x, y) Modified: python/branches/py3k-cdecimal/Doc/library/doctest.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/doctest.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/doctest.rst Thu Apr 1 11:38:52 2010 @@ -625,7 +625,7 @@ For example, this test passes:: - >>> print(range(20)) #doctest: +NORMALIZE_WHITESPACE + >>> print(list(range(20))) #doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] @@ -634,28 +634,28 @@ is on a single line. This test also passes, and also requires a directive to do so:: - >>> print(range(20)) # doctest: +ELLIPSIS + >>> print(list(range(20))) # doctest: +ELLIPSIS [0, 1, ..., 18, 19] Multiple directives can be used on a single physical line, separated by commas:: - >>> print(range(20)) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + >>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19] If multiple directive comments are used for a single example, then they are combined:: - >>> print(range(20)) # doctest: +ELLIPSIS - ... # doctest: +NORMALIZE_WHITESPACE + >>> print(list(range(20))) # doctest: +ELLIPSIS + ... # doctest: +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19] As the previous example shows, you can add ``...`` lines to your example containing only directives. This can be useful when an example is too long for a directive to comfortably fit on the same line:: - >>> print(range(5) + range(10,20) + range(30,40) + range(50,60)) + >>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40))) ... # doctest: +ELLIPSIS - [0, ..., 4, 10, ..., 19, 30, ..., 39, 50, ..., 59] + [0, ..., 4, 10, ..., 19, 30, ..., 39] Note that since all options are disabled by default, and directives apply only to the example they appear in, enabling options (via ``+`` in a directive) is Modified: python/branches/py3k-cdecimal/Doc/library/email-examples.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/email-examples.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/email-examples.rst Thu Apr 1 11:38:52 2010 @@ -11,6 +11,12 @@ .. literalinclude:: ../includes/email-simple.py +And parsing RFC822 headers can easily be done by the parse(filename) or +parsestr(message_as_string) methods of the Parser() class: + +.. literalinclude:: ../includes/email-headers.py + + Here's an example of how to send a MIME message containing a bunch of family pictures that may be residing in a directory: Modified: python/branches/py3k-cdecimal/Doc/library/email.message.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/email.message.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/email.message.rst Thu Apr 1 11:38:52 2010 @@ -415,9 +415,10 @@ Return the value of the ``filename`` parameter of the :mailheader:`Content-Disposition` header of the message. If the header does not have a ``filename`` parameter, this method falls back to looking - for the ``name`` parameter. If neither is found, or the header is - missing, then *failobj* is returned. The returned string will always be - unquoted as per :func:`email.utils.unquote`. + for the ``name`` parameter on the :mailheader:`Content-Type` header. If + neither is found, or the header is missing, then *failobj* is returned. + The returned string will always be unquoted as per + :func:`email.utils.unquote`. .. method:: get_boundary(failobj=None) Modified: python/branches/py3k-cdecimal/Doc/library/functions.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/functions.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/functions.rst Thu Apr 1 11:38:52 2010 @@ -328,7 +328,7 @@ This function can also be used to execute arbitrary code objects (such as those created by :func:`compile`). In this case pass a code object instead of a string. If the code object has been compiled with ``'exec'`` as the - *kind* argument, :func:`eval`\'s return value will be ``None``. + *mode* argument, :func:`eval`\'s return value will be ``None``. Hints: dynamic execution of statements is supported by the :func:`exec` function. The :func:`globals` and :func:`locals` functions @@ -1008,7 +1008,8 @@ Has two optional arguments which must be specified as keyword arguments. *key* specifies a function of one argument that is used to extract a comparison - key from each list element: ``key=str.lower``. The default value is ``None``. + key from each list element: ``key=str.lower``. The default value is ``None`` + (compare the elements directly). *reverse* is a boolean value. If set to ``True``, then the list elements are sorted as if each comparison were reversed. Modified: python/branches/py3k-cdecimal/Doc/library/getopt.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/getopt.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/getopt.rst Thu Apr 1 11:38:52 2010 @@ -1,5 +1,5 @@ -:mod:`getopt` --- Parser for command line options -================================================= +:mod:`getopt` --- C-style parser for command line options +========================================================= .. module:: getopt :synopsis: Portable parser for command line options; support both short and Modified: python/branches/py3k-cdecimal/Doc/library/gzip.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/gzip.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/gzip.rst Thu Apr 1 11:38:52 2010 @@ -67,7 +67,7 @@ writing as *fileobj*, and retrieve the resulting memory buffer using the :class:`StringIO` object's :meth:`getvalue` method. - :class:`GzipFile` supports the :keyword:`with` statement. + :class:`GzipFile` supports iteration and the :keyword:`with` statement. .. versionchanged:: 3.1 Support for the :keyword:`with` statement was added. Modified: python/branches/py3k-cdecimal/Doc/library/hashlib.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/hashlib.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/hashlib.rst Thu Apr 1 11:38:52 2010 @@ -82,6 +82,15 @@ >>> h.hexdigest() 'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc' +This module provides the following constant attribute: + +.. data:: hashlib.algorithms + + A tuple providing the names of the hash algorithms guaranteed to be + supported by this module. + + .. versionadded:: 3.2 + The following values are provided as constant attributes of the hash objects returned by the constructors: Modified: python/branches/py3k-cdecimal/Doc/library/http.client.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/http.client.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/http.client.rst Thu Apr 1 11:38:52 2010 @@ -498,7 +498,7 @@ .. attribute:: HTTPResponse.debuglevel - A debugging hook. If `debuglevel` is greater than zero, messages + A debugging hook. If :attr:`debuglevel` is greater than zero, messages will be printed to stdout as the response is read and parsed. Modified: python/branches/py3k-cdecimal/Doc/library/index.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/index.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/index.rst Thu Apr 1 11:38:52 2010 @@ -43,7 +43,6 @@ intro.rst functions.rst constants.rst - objects.rst stdtypes.rst exceptions.rst Modified: python/branches/py3k-cdecimal/Doc/library/inspect.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/inspect.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/inspect.rst Thu Apr 1 11:38:52 2010 @@ -449,6 +449,32 @@ metatype is in use, cls will be the first element of the tuple. +.. function:: getcallargs(func[, *args][, **kwds]) + + Bind the *args* and *kwds* to the argument names of the Python function or + method *func*, as if it was called with them. For bound methods, bind also the + first argument (typically named ``self``) to the associated instance. A dict + is returned, mapping the argument names (including the names of the ``*`` and + ``**`` arguments, if any) to their values from *args* and *kwds*. In case of + invoking *func* incorrectly, i.e. whenever ``func(*args, **kwds)`` would raise + an exception because of incompatible signature, an exception of the same type + and the same or similar message is raised. For example:: + + >>> from inspect import getcallargs + >>> def f(a, b=1, *pos, **named): + ... pass + >>> getcallargs(f, 1, 2, 3) + {'a': 1, 'named': {}, 'b': 2, 'pos': (3,)} + >>> getcallargs(f, a=2, x=4) + {'a': 2, 'named': {'x': 4}, 'b': 1, 'pos': ()} + >>> getcallargs(f) + Traceback (most recent call last): + ... + TypeError: f() takes at least 1 argument (0 given) + + .. versionadded:: 3.2 + + .. _inspect-stack: The interpreter stack Modified: python/branches/py3k-cdecimal/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/itertools.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/itertools.rst Thu Apr 1 11:38:52 2010 @@ -580,16 +580,19 @@ "Return first n items of the iterable as a list" return list(islice(iterable, n)) - def enumerate(iterable, start=0): - return zip(count(start), iterable) - def tabulate(function, start=0): "Return function(0), function(1), ..." return map(function, count(start)) def consume(iterator, n): "Advance the iterator n-steps ahead. If n is none, consume entirely." - collections.deque(islice(iterator, n), maxlen=0) + # Use functions that consume iterators at C speed. + if n is None: + # feed the entire iterator into a zero-length deque + collections.deque(iterator, maxlen=0) + else: + # advance to the emtpy slice starting at position n + next(islice(iterator, n, n), None) def nth(iterable, n, default=None): "Returns the nth item or a default value" @@ -661,10 +664,9 @@ seen = set() seen_add = seen.add if key is None: - for element in iterable: - if element not in seen: - seen_add(element) - yield element + for element in filterfalse(seen.__contains__, iterable): + seen_add(element) + yield element else: for element in iterable: k = key(element) @@ -677,3 +679,33 @@ # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B # unique_justseen('ABBCcAD', str.lower) --> A B C A D return map(next, map(itemgetter(1), groupby(iterable, key))) + + def iter_except(func, exception, first=None): + """ Call a function repeatedly until an exception is raised. + + Converts a call-until-exception interface to an iterator interface. + Like __builtin__.iter(func, sentinel) but uses an exception instead + of a sentinel to end the loop. + + Examples: + iter_except(functools.partial(heappop, h), IndexError) # priority queue iterator + iter_except(d.popitem, KeyError) # non-blocking dict iterator + iter_except(d.popleft, IndexError) # non-blocking deque iterator + iter_except(q.get_nowait, Queue.Empty) # loop over a producer Queue + iter_except(s.pop, KeyError) # non-blocking set iterator + + """ + try: + if first is not None: + yield first() # For database APIs needing an initial cast to db.first() + while 1: + yield func() + except exception: + pass + +Note, many of the above recipes can be optimized by replacing global lookups +with local variables defined as default values. For example, the +*dotproduct* recipe can be written as:: + + def dotproduct(vec1, vec2, sum=sum, map=map, mul=operator.mul): + return sum(map(mul, vec1, vec2)) Modified: python/branches/py3k-cdecimal/Doc/library/logging.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/logging.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/logging.rst Thu Apr 1 11:38:52 2010 @@ -420,6 +420,13 @@ code approach, mainly separation of configuration and code and the ability of noncoders to easily modify the logging properties. +Note that the class names referenced in config files need to be either relative +to the logging module, or absolute values which can be resolved using normal +import mechanisms. Thus, you could use either `handlers.WatchedFileHandler` +(relative to the logging module) or `mypackage.mymodule.MyHandler` (for a +class defined in package `mypackage` and module `mymodule`, where `mypackage` +is available on the Python import path). + .. _library-config: Configuring Logging for a Library @@ -727,7 +734,11 @@ Provides an overriding level *lvl* for all loggers which takes precedence over the logger's own level. When the need arises to temporarily throttle logging - output down across the whole application, this function can be useful. + output down across the whole application, this function can be useful. Its + effect is to disable all logging calls of severity *lvl* and below, so that + if you call it with a value of INFO, then all INFO and DEBUG events would be + discarded, whereas those of severity WARNING and above would be processed + according to the logger's effective level. .. function:: addLevelName(lvl, levelName) @@ -1210,12 +1221,12 @@ :class:`Handler` subclass are passed to its :meth:`handleError` method. The default implementation of :meth:`handleError` in :class:`Handler` checks -to see if a module-level variable, `raiseExceptions`, is set. If set, a -traceback is printed to `sys.stderr`. If not set, the exception is swallowed. +to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a +traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. -**Note:** The default value of `raiseExceptions` is `True`. This is because +**Note:** The default value of :data:`raiseExceptions` is ``True``. This is because during development, you typically want to be notified of any exceptions that -occur. It's advised that you set `raiseExceptions` to `False` for production +occur. It's advised that you set :data:`raiseExceptions` to ``False`` for production usage. .. _context-info: @@ -1849,6 +1860,11 @@ The extensions are date-and-time based, using the strftime format ``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on the rollover interval. + + When computing the next rollover time for the first time (when the handler + is created), the last modification time of an existing log file, or else + the current time, is used to compute when the next rotation will occur. + If the *utc* argument is true, times in UTC will be used; otherwise local time is used. @@ -2401,6 +2417,28 @@ because lock implementations in the :mod:`threading` module are not always re-entrant, and so cannot be invoked from such signal handlers. + +Integration with the warnings module +------------------------------------ + +The :func:`captureWarnings` function can be used to integrate :mod:`logging` +with the :mod:`warnings` module. + +.. function:: captureWarnings(capture) + + This function is used to turn the capture of warnings by logging on and + off. + + If `capture` is `True`, warnings issued by the :mod:`warnings` module + will be redirected to the logging system. Specifically, a warning will be + formatted using :func:`warnings.formatwarning` and the resulting string + logged to a logger named "py.warnings" with a severity of `WARNING`. + + If `capture` is `False`, the redirection of warnings to the logging system + will stop, and warnings will be redirected to their original destinations + (i.e. those in effect before `captureWarnings(True)` was called). + + Configuration ------------- Modified: python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst Thu Apr 1 11:38:52 2010 @@ -1131,7 +1131,7 @@ Create a BaseManager object. - Once created one should call :meth:`start` or :meth:`serve_forever` to ensure + Once created one should call :meth:`start` or ``get_server().serve_forever()`` to ensure that the manager object refers to a started manager process. *address* is the address on which the manager process listens for new @@ -1147,10 +1147,6 @@ Start a subprocess to start the manager. If *initializer* is not ``None`` then the subprocess will call ``initializer(*initargs)`` when it starts. - .. method:: serve_forever() - - Run the server in the current process. - .. method:: get_server() Returns a :class:`Server` object which represents the actual server under Deleted: python/branches/py3k-cdecimal/Doc/library/objects.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/objects.rst Thu Apr 1 11:38:52 2010 +++ (empty file) @@ -1,27 +0,0 @@ - -.. _builtin: - -**************** -Built-in Objects -**************** - -.. index:: - pair: built-in; types - pair: built-in; exceptions - pair: built-in; functions - pair: built-in; constants - single: symbol table - -Names for built-in exceptions and functions and a number of constants are found -in a separate symbol table. This table is searched last when the interpreter -looks up the meaning of a name, so local and global user-defined names can -override built-in names. Built-in types are described together here for easy -reference. - -The tables in this chapter document the priorities of operators by listing them -in order of ascending priority (within a table) and grouping operators that have -the same priority in the same box. Binary operators of the same priority group -from left to right. (Unary operators group from right to left, but there you -have no real choice.) See :ref:`operator-summary` for the complete picture on -operator priorities. - Modified: python/branches/py3k-cdecimal/Doc/library/optparse.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/optparse.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/optparse.rst Thu Apr 1 11:38:52 2010 @@ -1,8 +1,8 @@ -:mod:`optparse` --- More powerful command line option parser -============================================================ +:mod:`optparse` --- Parser for command line options +=================================================== .. module:: optparse - :synopsis: More convenient, flexible, and powerful command-line parsing library. + :synopsis: Command-line option parsing library. .. moduleauthor:: Greg Ward .. sectionauthor:: Greg Ward @@ -762,7 +762,8 @@ The string to use when expanding ``"%prog"`` in ``usage`` and ``version`` instead of ``os.path.basename(sys.argv[0])``. - + ``epilog`` (default: ``None``) + A paragraph of help text to print after the option help. .. _optparse-populating-parser: Modified: python/branches/py3k-cdecimal/Doc/library/os.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/os.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/os.rst Thu Apr 1 11:38:52 2010 @@ -136,6 +136,17 @@ These functions are described in :ref:`os-file-dir`. +.. function:: get_exec_path(env=None) + + Returns the list of directories that will be searched for a named + executable, similar to a shell, when launching a process. + *env*, when specified, should be an environment variable dictionary + to lookup the PATH in. + By default, when *env* is None, :data:`environ` is used. + + .. versionadded:: 3.2 + + .. function:: ctermid() Return the filename corresponding to the controlling terminal of the process. Modified: python/branches/py3k-cdecimal/Doc/library/pdb.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/pdb.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/pdb.rst Thu Apr 1 11:38:52 2010 @@ -22,7 +22,7 @@ The debugger is extensible --- it is actually defined as the class :class:`Pdb`. This is currently undocumented but easily understood by reading the source. The -extension interface uses the modules :mod:`bdb` (undocumented) and :mod:`cmd`. +extension interface uses the modules :mod:`bdb` and :mod:`cmd`. The debugger's prompt is ``(Pdb)``. Typical usage to run a program under control of the debugger is:: Modified: python/branches/py3k-cdecimal/Doc/library/pydoc.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/pydoc.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/pydoc.rst Thu Apr 1 11:38:52 2010 @@ -54,7 +54,7 @@ :option:`-p 1234` will start a HTTP server on port 1234, allowing you to browse the documentation at ``http://localhost:1234/`` in your preferred Web browser. :program:`pydoc` :option:`-g` will start the server and additionally bring up a -small :mod:`Tkinter`\ -based graphical interface to help you search for +small :mod:`tkinter`\ -based graphical interface to help you search for documentation pages. When :program:`pydoc` generates documentation, it uses the current environment Modified: python/branches/py3k-cdecimal/Doc/library/queue.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/queue.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/queue.rst Thu Apr 1 11:38:52 2010 @@ -21,15 +21,14 @@ The :mod:`queue` module defines the following classes and exceptions: -.. class:: Queue(maxsize) +.. class:: Queue(maxsize=0) Constructor for a FIFO queue. *maxsize* is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If *maxsize* is less than or equal to zero, the queue size is infinite. - -.. class:: LifoQueue(maxsize) +.. class:: LifoQueue(maxsize=0) Constructor for a LIFO queue. *maxsize* is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will @@ -37,7 +36,7 @@ *maxsize* is less than or equal to zero, the queue size is infinite. -.. class:: PriorityQueue(maxsize) +.. class:: PriorityQueue(maxsize=0) Constructor for a priority queue. *maxsize* is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will Modified: python/branches/py3k-cdecimal/Doc/library/random.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/random.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/random.rst Thu Apr 1 11:38:52 2010 @@ -35,6 +35,18 @@ Optionally, a new generator can supply a :meth:`getrandbits` method --- this allows :meth:`randrange` to produce selections over an arbitrarily large range. +As an example of subclassing, the :mod:`random` module provides the +:class:`WichmannHill` class that implements an alternative generator in pure +Python. The class provides a backward compatible way to reproduce results from +earlier versions of Python, which used the Wichmann-Hill algorithm as the core +generator. Note that this Wichmann-Hill generator can no longer be recommended: +its period is too short by contemporary standards, and the sequence generated is +known to fail some stringent randomness tests. See the references below for a +recent variant that repairs these flaws. + +The :mod:`random` module also provides the :class:`SystemRandom` class which +uses the system function :func:`os.urandom` to generate random numbers +from sources provided by the operating system. Bookkeeping functions: Modified: python/branches/py3k-cdecimal/Doc/library/re.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/re.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/re.rst Thu Apr 1 11:38:52 2010 @@ -705,98 +705,99 @@ Regular Expression Objects -------------------------- -Compiled regular expression objects support the following methods and -attributes: +.. class:: RegexObject + The :class:`RegexObject` class supports the following methods and attributes: -.. method:: RegexObject.match(string[, pos[, endpos]]) - If zero or more characters at the beginning of *string* match this regular - expression, return a corresponding :class:`MatchObject` instance. Return - ``None`` if the string does not match the pattern; note that this is different - from a zero-length match. + .. method:: RegexObject.match(string[, pos[, endpos]]) - .. note:: + If zero or more characters at the beginning of *string* match this regular + expression, return a corresponding :class:`MatchObject` instance. Return + ``None`` if the string does not match the pattern; note that this is different + from a zero-length match. - If you want to locate a match anywhere in *string*, use - :meth:`~RegexObject.search` instead. + .. note:: - The optional second parameter *pos* gives an index in the string where the - search is to start; it defaults to ``0``. This is not completely equivalent to - slicing the string; the ``'^'`` pattern character matches at the real beginning - of the string and at positions just after a newline, but not necessarily at the - index where the search is to start. + If you want to locate a match anywhere in *string*, use + :meth:`~RegexObject.search` instead. - The optional parameter *endpos* limits how far the string will be searched; it - will be as if the string is *endpos* characters long, so only the characters - from *pos* to ``endpos - 1`` will be searched for a match. If *endpos* is less - than *pos*, no match will be found, otherwise, if *rx* is a compiled regular - expression object, ``rx.match(string, 0, 50)`` is equivalent to - ``rx.match(string[:50], 0)``. + The optional second parameter *pos* gives an index in the string where the + search is to start; it defaults to ``0``. This is not completely equivalent to + slicing the string; the ``'^'`` pattern character matches at the real beginning + of the string and at positions just after a newline, but not necessarily at the + index where the search is to start. - >>> pattern = re.compile("o") - >>> pattern.match("dog") # No match as "o" is not at the start of "dog." - >>> pattern.match("dog", 1) # Match as "o" is the 2nd character of "dog". - <_sre.SRE_Match object at ...> + The optional parameter *endpos* limits how far the string will be searched; it + will be as if the string is *endpos* characters long, so only the characters + from *pos* to ``endpos - 1`` will be searched for a match. If *endpos* is less + than *pos*, no match will be found, otherwise, if *rx* is a compiled regular + expression object, ``rx.match(string, 0, 50)`` is equivalent to + ``rx.match(string[:50], 0)``. + >>> pattern = re.compile("o") + >>> pattern.match("dog") # No match as "o" is not at the start of "dog." + >>> pattern.match("dog", 1) # Match as "o" is the 2nd character of "dog". + <_sre.SRE_Match object at ...> -.. method:: RegexObject.search(string[, pos[, endpos]]) - Scan through *string* looking for a location where this regular expression - produces a match, and return a corresponding :class:`MatchObject` instance. - Return ``None`` if no position in the string matches the pattern; note that this - is different from finding a zero-length match at some point in the string. + .. method:: RegexObject.search(string[, pos[, endpos]]) - The optional *pos* and *endpos* parameters have the same meaning as for the - :meth:`~RegexObject.match` method. + Scan through *string* looking for a location where this regular expression + produces a match, and return a corresponding :class:`MatchObject` instance. + Return ``None`` if no position in the string matches the pattern; note that this + is different from finding a zero-length match at some point in the string. + The optional *pos* and *endpos* parameters have the same meaning as for the + :meth:`~RegexObject.match` method. -.. method:: RegexObject.split(string, maxsplit=0) - Identical to the :func:`split` function, using the compiled pattern. + .. method:: RegexObject.split(string[, maxsplit=0]) + Identical to the :func:`split` function, using the compiled pattern. -.. method:: RegexObject.findall(string[, pos[, endpos]]) - Identical to the :func:`findall` function, using the compiled pattern. + .. method:: RegexObject.findall(string[, pos[, endpos]]) + Identical to the :func:`findall` function, using the compiled pattern. -.. method:: RegexObject.finditer(string[, pos[, endpos]]) - Identical to the :func:`finditer` function, using the compiled pattern. + .. method:: RegexObject.finditer(string[, pos[, endpos]]) + Identical to the :func:`finditer` function, using the compiled pattern. -.. method:: RegexObject.sub(repl, string, count=0) - Identical to the :func:`sub` function, using the compiled pattern. + .. method:: RegexObject.sub(repl, string[, count=0]) + Identical to the :func:`sub` function, using the compiled pattern. -.. method:: RegexObject.subn(repl, string, count=0) - Identical to the :func:`subn` function, using the compiled pattern. + .. method:: RegexObject.subn(repl, string[, count=0]) + Identical to the :func:`subn` function, using the compiled pattern. -.. attribute:: RegexObject.flags - The flags argument used when the RE object was compiled, or ``0`` if no flags - were provided. + .. attribute:: RegexObject.flags + The flags argument used when the RE object was compiled, or ``0`` if no flags + were provided. -.. attribute:: RegexObject.groups - The number of capturing groups in the pattern. + .. attribute:: RegexObject.groups + The number of capturing groups in the pattern. -.. attribute:: RegexObject.groupindex - A dictionary mapping any symbolic group names defined by ``(?P)`` to group - numbers. The dictionary is empty if no symbolic groups were used in the - pattern. + .. attribute:: RegexObject.groupindex + A dictionary mapping any symbolic group names defined by ``(?P)`` to group + numbers. The dictionary is empty if no symbolic groups were used in the + pattern. -.. attribute:: RegexObject.pattern - The pattern string from which the RE object was compiled. + .. attribute:: RegexObject.pattern + + The pattern string from which the RE object was compiled. .. _match-objects: @@ -804,176 +805,178 @@ Match Objects ------------- -Match objects always have a boolean value of :const:`True`, so that you can test -whether e.g. :func:`match` resulted in a match with a simple if statement. They -support the following methods and attributes: - +.. class:: MatchObject -.. method:: MatchObject.expand(template) + Match Objects always have a boolean value of :const:`True`, so that you can test + whether e.g. :func:`match` resulted in a match with a simple if statement. They + support the following methods and attributes: - Return the string obtained by doing backslash substitution on the template - string *template*, as done by the :meth:`~RegexObject.sub` method. Escapes - such as ``\n`` are converted to the appropriate characters, and numeric - backreferences (``\1``, ``\2``) and named backreferences (``\g<1>``, - ``\g``) are replaced by the contents of the corresponding group. + .. method:: MatchObject.expand(template) -.. method:: MatchObject.group([group1, ...]) + Return the string obtained by doing backslash substitution on the template + string *template*, as done by the :meth:`~RegexObject.sub` method. Escapes + such as ``\n`` are converted to the appropriate characters, and numeric + backreferences (``\1``, ``\2``) and named backreferences (``\g<1>``, + ``\g``) are replaced by the contents of the corresponding group. - Returns one or more subgroups of the match. If there is a single argument, the - result is a single string; if there are multiple arguments, the result is a - tuple with one item per argument. Without arguments, *group1* defaults to zero - (the whole match is returned). If a *groupN* argument is zero, the corresponding - return value is the entire matching string; if it is in the inclusive range - [1..99], it is the string matching the corresponding parenthesized group. If a - group number is negative or larger than the number of groups defined in the - pattern, an :exc:`IndexError` exception is raised. If a group is contained in a - part of the pattern that did not match, the corresponding result is ``None``. - If a group is contained in a part of the pattern that matched multiple times, - the last match is returned. - >>> m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist") - >>> m.group(0) # The entire match - 'Isaac Newton' - >>> m.group(1) # The first parenthesized subgroup. - 'Isaac' - >>> m.group(2) # The second parenthesized subgroup. - 'Newton' - >>> m.group(1, 2) # Multiple arguments give us a tuple. - ('Isaac', 'Newton') + .. method:: MatchObject.group([group1, ...]) - If the regular expression uses the ``(?P...)`` syntax, the *groupN* - arguments may also be strings identifying groups by their group name. If a - string argument is not used as a group name in the pattern, an :exc:`IndexError` - exception is raised. + Returns one or more subgroups of the match. If there is a single argument, the + result is a single string; if there are multiple arguments, the result is a + tuple with one item per argument. Without arguments, *group1* defaults to zero + (the whole match is returned). If a *groupN* argument is zero, the corresponding + return value is the entire matching string; if it is in the inclusive range + [1..99], it is the string matching the corresponding parenthesized group. If a + group number is negative or larger than the number of groups defined in the + pattern, an :exc:`IndexError` exception is raised. If a group is contained in a + part of the pattern that did not match, the corresponding result is ``None``. + If a group is contained in a part of the pattern that matched multiple times, + the last match is returned. - A moderately complicated example: + >>> m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist") + >>> m.group(0) # The entire match + 'Isaac Newton' + >>> m.group(1) # The first parenthesized subgroup. + 'Isaac' + >>> m.group(2) # The second parenthesized subgroup. + 'Newton' + >>> m.group(1, 2) # Multiple arguments give us a tuple. + ('Isaac', 'Newton') - >>> m = re.match(r"(?P\w+) (?P\w+)", "Malcolm Reynolds") - >>> m.group('first_name') - 'Malcolm' - >>> m.group('last_name') - 'Reynolds' + If the regular expression uses the ``(?P...)`` syntax, the *groupN* + arguments may also be strings identifying groups by their group name. If a + string argument is not used as a group name in the pattern, an :exc:`IndexError` + exception is raised. - Named groups can also be referred to by their index: + A moderately complicated example: - >>> m.group(1) - 'Malcolm' - >>> m.group(2) - 'Reynolds' + >>> m = re.match(r"(?P\w+) (?P\w+)", "Malcolm Reynolds") + >>> m.group('first_name') + 'Malcolm' + >>> m.group('last_name') + 'Reynolds' - If a group matches multiple times, only the last match is accessible: + Named groups can also be referred to by their index: - >>> m = re.match(r"(..)+", "a1b2c3") # Matches 3 times. - >>> m.group(1) # Returns only the last match. - 'c3' + >>> m.group(1) + 'Malcolm' + >>> m.group(2) + 'Reynolds' + If a group matches multiple times, only the last match is accessible: -.. method:: MatchObject.groups(default=None) + >>> m = re.match(r"(..)+", "a1b2c3") # Matches 3 times. + >>> m.group(1) # Returns only the last match. + 'c3' - Return a tuple containing all the subgroups of the match, from 1 up to however - many groups are in the pattern. The *default* argument is used for groups that - did not participate in the match; it defaults to ``None``. + Return a tuple containing all the subgroups of the match, from 1 up to however + many groups are in the pattern. The *default* argument is used for groups that + did not participate in the match; it defaults to ``None``. (Incompatibility + note: in the original Python 1.5 release, if the tuple was one element long, a + string would be returned instead. In later versions (from 1.5.1 on), a + singleton tuple is returned in such cases.) - For example: + For example: - >>> m = re.match(r"(\d+)\.(\d+)", "24.1632") - >>> m.groups() - ('24', '1632') + >>> m = re.match(r"(\d+)\.(\d+)", "24.1632") + >>> m.groups() + ('24', '1632') - If we make the decimal place and everything after it optional, not all groups - might participate in the match. These groups will default to ``None`` unless - the *default* argument is given: + If we make the decimal place and everything after it optional, not all groups + might participate in the match. These groups will default to ``None`` unless + the *default* argument is given: - >>> m = re.match(r"(\d+)\.?(\d+)?", "24") - >>> m.groups() # Second group defaults to None. - ('24', None) - >>> m.groups('0') # Now, the second group defaults to '0'. - ('24', '0') + >>> m = re.match(r"(\d+)\.?(\d+)?", "24") + >>> m.groups() # Second group defaults to None. + ('24', None) + >>> m.groups('0') # Now, the second group defaults to '0'. + ('24', '0') -.. method:: MatchObject.groupdict(default=None) + .. method:: MatchObject.groupdict([default]) - Return a dictionary containing all the *named* subgroups of the match, keyed by - the subgroup name. The *default* argument is used for groups that did not - participate in the match; it defaults to ``None``. For example: + Return a dictionary containing all the *named* subgroups of the match, keyed by + the subgroup name. The *default* argument is used for groups that did not + participate in the match; it defaults to ``None``. For example: - >>> m = re.match(r"(?P\w+) (?P\w+)", "Malcolm Reynolds") - >>> m.groupdict() - {'first_name': 'Malcolm', 'last_name': 'Reynolds'} + >>> m = re.match(r"(?P\w+) (?P\w+)", "Malcolm Reynolds") + >>> m.groupdict() + {'first_name': 'Malcolm', 'last_name': 'Reynolds'} -.. method:: MatchObject.start(group=0) - MatchObject.end(group=0) + .. method:: MatchObject.start([group]) + MatchObject.end([group]) - Return the indices of the start and end of the substring matched by *group*; - *group* defaults to zero (meaning the whole matched substring). Return ``-1`` if - *group* exists but did not contribute to the match. For a match object *m*, and - a group *g* that did contribute to the match, the substring matched by group *g* - (equivalent to ``m.group(g)``) is :: + Return the indices of the start and end of the substring matched by *group*; + *group* defaults to zero (meaning the whole matched substring). Return ``-1`` if + *group* exists but did not contribute to the match. For a match object *m*, and + a group *g* that did contribute to the match, the substring matched by group *g* + (equivalent to ``m.group(g)``) is :: - m.string[m.start(g):m.end(g)] + m.string[m.start(g):m.end(g)] - Note that ``m.start(group)`` will equal ``m.end(group)`` if *group* matched a - null string. For example, after ``m = re.search('b(c?)', 'cba')``, - ``m.start(0)`` is 1, ``m.end(0)`` is 2, ``m.start(1)`` and ``m.end(1)`` are both - 2, and ``m.start(2)`` raises an :exc:`IndexError` exception. + Note that ``m.start(group)`` will equal ``m.end(group)`` if *group* matched a + null string. For example, after ``m = re.search('b(c?)', 'cba')``, + ``m.start(0)`` is 1, ``m.end(0)`` is 2, ``m.start(1)`` and ``m.end(1)`` are both + 2, and ``m.start(2)`` raises an :exc:`IndexError` exception. - An example that will remove *remove_this* from email addresses: + An example that will remove *remove_this* from email addresses: - >>> email = "tony at tiremove_thisger.net" - >>> m = re.search("remove_this", email) - >>> email[:m.start()] + email[m.end():] - 'tony at tiger.net' + >>> email = "tony at tiremove_thisger.net" + >>> m = re.search("remove_this", email) + >>> email[:m.start()] + email[m.end():] + 'tony at tiger.net' -.. method:: MatchObject.span(group=0) + .. method:: MatchObject.span([group]) - For :class:`MatchObject` *m*, return the 2-tuple ``(m.start(group), - m.end(group))``. Note that if *group* did not contribute to the match, this is - ``(-1, -1)``. *group* defaults to zero, the entire match. + For :class:`MatchObject` *m*, return the 2-tuple ``(m.start(group), + m.end(group))``. Note that if *group* did not contribute to the match, this is + ``(-1, -1)``. *group* defaults to zero, the entire match. -.. attribute:: MatchObject.pos + .. attribute:: MatchObject.pos - The value of *pos* which was passed to the :meth:`~RegexObject.search` or - :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the - index into the string at which the RE engine started looking for a match. + The value of *pos* which was passed to the :meth:`~RegexObject.search` or + :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the + index into the string at which the RE engine started looking for a match. -.. attribute:: MatchObject.endpos + .. attribute:: MatchObject.endpos - The value of *endpos* which was passed to the :meth:`~RegexObject.search` or - :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the - index into the string beyond which the RE engine will not go. + The value of *endpos* which was passed to the :meth:`~RegexObject.search` or + :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the + index into the string beyond which the RE engine will not go. -.. attribute:: MatchObject.lastindex + .. attribute:: MatchObject.lastindex - The integer index of the last matched capturing group, or ``None`` if no group - was matched at all. For example, the expressions ``(a)b``, ``((a)(b))``, and - ``((ab))`` will have ``lastindex == 1`` if applied to the string ``'ab'``, while - the expression ``(a)(b)`` will have ``lastindex == 2``, if applied to the same - string. + The integer index of the last matched capturing group, or ``None`` if no group + was matched at all. For example, the expressions ``(a)b``, ``((a)(b))``, and + ``((ab))`` will have ``lastindex == 1`` if applied to the string ``'ab'``, while + the expression ``(a)(b)`` will have ``lastindex == 2``, if applied to the same + string. -.. attribute:: MatchObject.lastgroup + .. attribute:: MatchObject.lastgroup - The name of the last matched capturing group, or ``None`` if the group didn't - have a name, or if no group was matched at all. + The name of the last matched capturing group, or ``None`` if the group didn't + have a name, or if no group was matched at all. -.. attribute:: MatchObject.re + .. attribute:: MatchObject.re - The regular expression object whose :meth:`~RegexObject.match` or - :meth:`~RegexObject.search` method produced this :class:`MatchObject` - instance. + The regular expression object whose :meth:`~RegexObject.match` or + :meth:`~RegexObject.search` method produced this :class:`MatchObject` + instance. -.. attribute:: MatchObject.string + .. attribute:: MatchObject.string - The string passed to :meth:`~RegexObject.match` or - :meth:`~RegexObject.search`. + The string passed to :meth:`~RegexObject.match` or + :meth:`~RegexObject.search`. Examples Modified: python/branches/py3k-cdecimal/Doc/library/shutil.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/shutil.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/shutil.rst Thu Apr 1 11:38:52 2010 @@ -26,6 +26,8 @@ not be correct. On Windows, file owners, ACLs and alternate data streams are not copied. +Directory and files operations +------------------------------ .. function:: copyfileobj(fsrc, fdst[, length]) @@ -150,8 +152,8 @@ .. _shutil-example: -Example -------- +copytree example +:::::::::::::::: This example is the implementation of the :func:`copytree` function, described above, with the docstring omitted. It demonstrates many of the other functions @@ -189,3 +191,117 @@ if errors: raise Error(errors) +Another example that uses the :func:`ignore_patterns` helper:: + + from shutil import copytree, ignore_patterns + + copytree(source, destination, ignore=ignore_patterns('*.pyc', 'tmp*')) + +This will copy everything except ``.pyc`` files and files or directories whose +name starts with ``tmp``. + +Another example that uses the *ignore* argument to add a logging call:: + + from shutil import copytree + import logging + + def _logpath(path, names): + logging.info('Working in %s' % path) + return [] # nothing will be ignored + + copytree(source, destination, ignore=_logpath) + + +Archives operations +------------------- + +.. function:: make_archive(base_name, format, [root_dir, [base_dir, [verbose, [dry_run, [owner, [group, [logger]]]]]]]) + + Create an archive file (eg. zip or tar) and returns its name. + + *base_name* is the name of the file to create, including the path, minus + any format-specific extension. *format* is the archive format: one of + "zip", "tar", "ztar", or "gztar". + + *root_dir* is a directory that will be the root directory of the + archive; ie. we typically chdir into *root_dir* before creating the + archive. + + *base_dir* is the directory where we start archiving from; + ie. *base_dir* will be the common prefix of all files and + directories in the archive. + + *root_dir* and *base_dir* both default to the current directory. + + *owner* and *group* are used when creating a tar archive. By default, + uses the current owner and group. + + .. versionadded:: 3.2 + + +.. function:: get_archive_formats() + + Returns a list of supported formats for archiving. + Each element of the returned sequence is a tuple ``(name, description)`` + + By default :mod:`shutil` provides these formats: + + - *gztar*: gzip'ed tar-file + - *bztar*: bzip2'ed tar-file + - *ztar*: compressed tar file + - *tar*: uncompressed tar file + - *zip*: ZIP file + + You can register new formats or provide your own archiver for any existing + formats, by using :func:`register_archive_format`. + + .. versionadded:: 3.2 + + +.. function:: register_archive_format(name, function, [extra_args, [description]]) + + Registers an archiver for the format *name*. *function* is a callable that + will be used to invoke the archiver. + + If given, *extra_args* is a sequence of ``(name, value)`` that will be + used as extra keywords arguments when the archiver callable is used. + + *description* is used by :func:`get_archive_formats` which returns the + list of archivers. Defaults to an empty list. + + .. versionadded:: 3.2 + + +.. function:: unregister_archive_format(name) + + Remove the archive format *name* from the list of supported formats. + + .. versionadded:: 3.2 + + +Archiving example +::::::::::::::::: + +In this example, we create a gzip'ed tar-file archive containing all files +found in the :file:`.ssh` directory of the user:: + + >>> from shutil import make_archive + >>> import os + >>> archive_name = os.path.expanduser(os.path.join('~', 'myarchive')) + >>> root_dir = os.path.expanduser(os.path.join('~', '.ssh')) + >>> make_archive(archive_name, 'gztar', root_dir) + '/Users/tarek/myarchive.tar.gz' + +The resulting archive contains:: + + $ tar -tzvf /Users/tarek/myarchive.tar.gz + drwx------ tarek/staff 0 2010-02-01 16:23:40 ./ + -rw-r--r-- tarek/staff 609 2008-06-09 13:26:54 ./authorized_keys + -rwxr-xr-x tarek/staff 65 2008-06-09 13:26:54 ./config + -rwx------ tarek/staff 668 2008-06-09 13:26:54 ./id_dsa + -rwxr-xr-x tarek/staff 609 2008-06-09 13:26:54 ./id_dsa.pub + -rw------- tarek/staff 1675 2008-06-09 13:26:54 ./id_rsa + -rw-r--r-- tarek/staff 397 2008-06-09 13:26:54 ./id_rsa.pub + -rw-r--r-- tarek/staff 37192 2010-02-06 18:23:10 ./known_hosts + + Modified: python/branches/py3k-cdecimal/Doc/library/site.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/site.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/site.rst Thu Apr 1 11:38:52 2010 @@ -124,9 +124,9 @@ .. function:: getuserbase() - Returns the `user base` directory path. + Returns the "user base" directory path. - The `user base` directory can be used to store data. If the global + The "user base" directory can be used to store data. If the global variable ``USER_BASE`` is not initialized yet, this function will also set it. Modified: python/branches/py3k-cdecimal/Doc/library/sqlite3.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/sqlite3.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/sqlite3.rst Thu Apr 1 11:38:52 2010 @@ -90,7 +90,7 @@ .. seealso:: - http://www.pysqlite.org + http://code.google.com/p/pysqlite/ The pysqlite web page -- sqlite3 is developed externally under the name "pysqlite". @@ -365,6 +365,25 @@ method with :const:`None` for *handler*. +.. method:: Connection.enable_load_extension(enabled) + + .. versionadded:: 3.2 + + This routine allows/disallows the SQLite engine to load SQLite extensions + from shared libraries. SQLite extensions can define new functions, + aggregates or whole new virtual table implementations. One well-known + extension is the fulltext-search extension distributed with SQLite. + + .. literalinclude:: ../includes/sqlite3/load_extension.py + +.. method:: Connection.load_extension(path) + + .. versionadded:: 3.2 + + This routine loads a SQLite extension from a shared library. You have to + enable extension loading with ``enable_load_extension`` before you can use + this routine. + .. attribute:: Connection.row_factory You can change this attribute to a callable that accepts the cursor and the @@ -434,7 +453,7 @@ Cursor Objects -------------- -.. class:: Cursor +A :class:`Cursor` instance has the following attributes and methods: A SQLite database cursor has the following attributes and methods: Modified: python/branches/py3k-cdecimal/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/stdtypes.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/stdtypes.rst Thu Apr 1 11:38:52 2010 @@ -168,8 +168,9 @@ Furthermore, some types (for example, function objects) support only a degenerate notion of comparison where any two objects of that type are unequal. The ``<``, ``<=``, ``>`` and ``>=`` operators will raise a :exc:`TypeError` exception when -any operand is a complex number, the objects are of different types that cannot -be compared, or other cases where there is no defined ordering. +comparing a complex number with another built-in numeric type, when the objects +are of different types that cannot be compared, or in other cases where there is +no defined ordering. .. index:: single: __eq__() (instance method) @@ -919,12 +920,12 @@ .. method:: str.format(*args, **kwargs) - Perform a string formatting operation. The *format_string* argument can - contain literal text or replacement fields delimited by braces ``{}``. Each - replacement field contains either the numeric index of a positional argument, - or the name of a keyword argument. Returns a copy of *format_string* where - each replacement field is replaced with the string value of the corresponding - argument. + Perform a string formatting operation. The string on which this method is + called can contain literal text or replacement fields delimited by braces + ``{}``. Each replacement field contains either the numeric index of a + positional argument, or the name of a keyword argument. Returns a copy of + the string where each replacement field is replaced with the string value of + the corresponding argument. >>> "The sum of 1 + 2 is {0}".format(1+2) 'The sum of 1 + 2 is 3' @@ -1703,6 +1704,10 @@ altered after it is created; it can therefore be used as a dictionary key or as an element of another set. +Non-empty sets (not frozensets) can be created by placing a comma-separated list +of elements within braces, for example: ``{'jack', 'sjoerd'}``, in addition to the +:class:`set` constructor. + The constructors for both classes work the same: .. class:: set([iterable]) Modified: python/branches/py3k-cdecimal/Doc/library/string.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/string.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/string.rst Thu Apr 1 11:38:52 2010 @@ -199,7 +199,8 @@ field_name: arg_name ("." `attribute_name` | "[" `element_index` "]")* arg_name: (`identifier` | `integer`)? attribute_name: `identifier` - element_index: `integer` + element_index: `integer` | `index_string` + index_string: + conversion: "r" | "s" | "a" format_spec: @@ -296,8 +297,9 @@ Most built-in types implement the following options for format specifications, although some of the formatting options are only supported by the numeric types. -A general convention is that an empty format string (``""``) produces the same -result as if you had called :func:`str` on the value. +A general convention is that an empty format string (``""``) produces +the same result as if you had called :func:`str` on the value. A +non-empty format string typically modifies the result. The general form of a *standard format specifier* is: @@ -308,7 +310,7 @@ sign: "+" | "-" | " " width: `integer` precision: `integer` - type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "x" | "X" | "%" + type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%" The *fill* character can be any character other than '}' (which signifies the end of the field). The presence of a fill character is signaled by the *next* @@ -380,6 +382,17 @@ Finally, the *type* determines how the data should be presented. +The available string presentation types are: + + +---------+----------------------------------------------------------+ + | Type | Meaning | + +=========+==========================================================+ + | ``'s'`` | String format. This is the default type for strings and | + | | may be omitted. | + +---------+----------------------------------------------------------+ + | None | The same as ``'s'``. | + +---------+----------------------------------------------------------+ + The available integer presentation types are: +---------+----------------------------------------------------------+ @@ -407,6 +420,11 @@ | None | The same as ``'d'``. | +---------+----------------------------------------------------------+ +In addition to the above presentation types, integers can be formatted +with the floating point presentation types listed below (except +``'n'`` and None). When doing so, :func:`float` is used to convert the +integer to a floating point number before formatting. + The available presentation types for floating point and decimal values are: +---------+----------------------------------------------------------+ Modified: python/branches/py3k-cdecimal/Doc/library/struct.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/struct.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/struct.rst Thu Apr 1 11:38:52 2010 @@ -184,9 +184,11 @@ If the first character is not one of these, ``'@'`` is assumed. -Native byte order is big-endian or little-endian, depending on the host system. -For example, Motorola and Sun processors are big-endian; Intel and DEC -processors are little-endian. +Native byte order is big-endian or little-endian, depending on the host +system. For example, Intel x86 and AMD64 (x86-64) are little-endian; +Motorola 68000 and PowerPC G5 are big-endian; ARM and Intel Itanium feature +switchable endianness (bi-endian). Use ``sys.byteorder`` to check the +endianness of your system. Native size and alignment are determined using the C compiler's ``sizeof`` expression. This is always combined with native byte order. Modified: python/branches/py3k-cdecimal/Doc/library/subprocess.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/subprocess.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/subprocess.rst Thu Apr 1 11:38:52 2010 @@ -28,7 +28,7 @@ This module defines one class called :class:`Popen`: -.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0) +.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False) Arguments are: @@ -41,7 +41,8 @@ name for the executing program in utilities such as :program:`ps`. On Unix, with *shell=False* (default): In this case, the Popen class uses - :meth:`os.execvp` to execute the child program. *args* should normally be a + :meth:`os.execvp` like behavior to execute the child program. + *args* should normally be a sequence. If a string is specified for *args*, it will be used as the name or path of the program to execute; this will only work if the program is being given no arguments. @@ -108,7 +109,23 @@ applications should be captured into the same file handle as for stdout. If *preexec_fn* is set to a callable object, this object will be called in the - child process just before the child is executed. (Unix only) + child process just before the child is executed. + (Unix only) + + .. warning:: + + The *preexec_fn* parameter is not safe to use in the presence of threads + in your application. The child process could deadlock before exec is + called. + If you must use it, keep it trivial! Minimize the number of libraries + you call into. + + .. note:: + + If you need to modify the environment for the child use the *env* + parameter rather than doing it in a *preexec_fn*. + The *start_new_session* parameter can take the place of a previously + common use of *preexec_fn* to call os.setsid() in the child. If *close_fds* is true, all file descriptors except :const:`0`, :const:`1` and :const:`2` will be closed before the child process is executed. (Unix only). @@ -124,9 +141,23 @@ searching the executable, so you can't specify the program's path relative to *cwd*. + If *restore_signals* is True (the default) all signals that Python has set to + SIG_IGN are restored to SIG_DFL in the child process before the exec. + Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. + (Unix only) + + .. versionchanged:: 3.2 + *restore_signals* was added. + + If *start_new_session* is True the setsid() system call will be made in the + child process prior to the execution of the subprocess. (Unix only) + + .. versionchanged:: 3.2 + *start_new_session* was added. + If *env* is not ``None``, it must be a mapping that defines the environment - variables for the new process; these are used instead of inheriting the current - process' environment, which is the default behavior. + variables for the new process; these are used instead of the default + behavior of inheriting the current process' environment. .. note:: @@ -179,7 +210,7 @@ Run command with arguments. Wait for command to complete, then return the :attr:`returncode` attribute. - The arguments are the same as for the Popen constructor. Example:: + The arguments are the same as for the :class:`Popen` constructor. Example:: >>> retcode = subprocess.call(["ls", "-l"]) @@ -198,7 +229,7 @@ :exc:`CalledProcessError` object will have the return code in the :attr:`returncode` attribute. - The arguments are the same as for the Popen constructor. Example:: + The arguments are the same as for the :class:`Popen` constructor. Example:: >>> subprocess.check_call(["ls", "-l"]) 0 @@ -392,6 +423,9 @@ The process ID of the child process. + Note that if you set the *shell* argument to ``True``, this is the process ID + of the spawned shell. + .. attribute:: Popen.returncode @@ -534,7 +568,7 @@ pipe = os.popen(cmd, 'w') ... rc = pipe.close() - if rc != None and rc % 256: + if rc is not None and rc % 256: print("There were some errors") ==> process = Popen(cmd, 'w', stdin=PIPE) Modified: python/branches/py3k-cdecimal/Doc/library/sys.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/sys.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/sys.rst Thu Apr 1 11:38:52 2010 @@ -127,13 +127,12 @@ .. index:: object: traceback - If no exception is being handled anywhere on the stack, a tuple containing three - ``None`` values is returned. Otherwise, the values returned are ``(type, value, - traceback)``. Their meaning is: *type* gets the exception type of the exception - being handled (a class object); *value* gets the exception parameter (its - :dfn:`associated value` or the second argument to :keyword:`raise`, which is - always a class instance if the exception type is a class object); *traceback* - gets a traceback object (see the Reference Manual) which encapsulates the call + If no exception is being handled anywhere on the stack, a tuple containing + three ``None`` values is returned. Otherwise, the values returned are + ``(type, value, traceback)``. Their meaning is: *type* gets the type of the + exception being handled (a subclass of :exc:`BaseException`); *value* gets + the exception instance (an instance of the exception type); *traceback* gets + a traceback object (see the Reference Manual) which encapsulates the call stack at the point where the exception originally occurred. .. warning:: @@ -339,7 +338,7 @@ specific. If given, *default* will be returned if the object does not provide means to - retrieve the size. Otherwise a `TypeError` will be raised. + retrieve the size. Otherwise a :exc:`TypeError` will be raised. :func:`getsizeof` calls the object's ``__sizeof__`` method and adds an additional garbage collector overhead if the object is managed by the garbage @@ -508,9 +507,7 @@ more information.) The meaning of the variables is the same as that of the return values from - :func:`exc_info` above. (Since there is only one interactive thread, - thread-safety is not a concern for these variables, unlike for ``exc_type`` - etc.) + :func:`exc_info` above. .. data:: maxsize @@ -819,6 +816,10 @@ available only if Python was compiled with :option:`--with-tsc`. To understand the output of this dump, read :file:`Python/ceval.c` in the Python sources. + .. impl-detail:: + This function is intimately bound to CPython implementation details and + thus not likely to be implemented elsewhere. + .. data:: stdin stdout Modified: python/branches/py3k-cdecimal/Doc/library/sysconfig.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/sysconfig.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/sysconfig.rst Thu Apr 1 11:38:52 2010 @@ -5,7 +5,7 @@ :synopsis: Python's configuration information .. moduleauthor:: Tarek Ziade .. sectionauthor:: Tarek Ziade -.. versionadded:: 2.7 +.. versionadded:: 3.2 .. index:: single: configuration information Modified: python/branches/py3k-cdecimal/Doc/library/tarfile.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/tarfile.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/tarfile.rst Thu Apr 1 11:38:52 2010 @@ -209,6 +209,14 @@ archive several times. Each archive member is represented by a :class:`TarInfo` object, see :ref:`tarinfo-objects` for details. +A :class:`TarFile` object can be used as a context manager in a :keyword:`with` +statement. It will automatically be closed when the block is completed. Please +note that in the event of an exception an archive opened for writing will not +be finalized, only the internally used file object will be closed. See the +:ref:`tar-examples` section for a use case. + +.. versionadded:: 3.2 + Added support for the context manager protocol. .. class:: TarFile(name=None, mode='r', fileobj=None, format=DEFAULT_FORMAT, tarinfo=TarInfo, dereference=False, ignore_zeros=False, encoding=ENCODING, errors=None, pax_headers=None, debug=0, errorlevel=0) @@ -593,6 +601,13 @@ tar.add(name) tar.close() +The same example using the :keyword:`with` statement:: + + import tarfile + with tarfile.open("sample.tar", "w") as tar: + for name in ["foo", "bar", "quux"]: + tar.add(name) + How to read a gzip compressed tar archive and display some member information:: import tarfile Modified: python/branches/py3k-cdecimal/Doc/library/test.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/test.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/test.rst Thu Apr 1 11:38:52 2010 @@ -89,17 +89,17 @@ guidelines to be followed: * The testing suite should exercise all classes, functions, and constants. This - includes not just the external API that is to be presented to the outside world - but also "private" code. + includes not just the external API that is to be presented to the outside + world but also "private" code. * Whitebox testing (examining the code being tested when the tests are being written) is preferred. Blackbox testing (testing only the published user - interface) is not complete enough to make sure all boundary and edge cases are - tested. + interface) is not complete enough to make sure all boundary and edge cases + are tested. * Make sure all possible values are tested including invalid ones. This makes - sure that not only all valid values are acceptable but also that improper values - are handled correctly. + sure that not only all valid values are acceptable but also that improper + values are handled correctly. * Exhaust as many code paths as possible. Test where branching occurs and thus tailor input to make sure as many different paths through the code are taken. @@ -119,8 +119,8 @@ behavior from side-effects of importing a module. * Try to maximize code reuse. On occasion, tests will vary by something as small - as what type of input is used. Minimize code duplication by subclassing a basic - test class with a class that specifies the input:: + as what type of input is used. Minimize code duplication by subclassing a + basic test class with a class that specifies the input:: class TestFuncAcceptsSequences(unittest.TestCase): @@ -130,13 +130,13 @@ self.func(self.arg) class AcceptLists(TestFuncAcceptsSequences): - arg = [1,2,3] + arg = [1, 2, 3] class AcceptStrings(TestFuncAcceptsSequences): arg = 'abc' class AcceptTuples(TestFuncAcceptsSequences): - arg = (1,2,3) + arg = (1, 2, 3) .. seealso:: @@ -154,10 +154,10 @@ suite. Running the script by itself automatically starts running all regression tests in the :mod:`test` package. It does this by finding all modules in the package whose name starts with ``test_``, importing them, and executing the -function :func:`test_main` if present. The names of tests to execute may also be -passed to the script. Specifying a single regression test (:program:`python -regrtest.py` :option:`test_spam.py`) will minimize output and only print whether -the test passed or failed and thus minimize output. +function :func:`test_main` if present. The names of tests to execute may also +be passed to the script. Specifying a single regression test (:program:`python +regrtest.py` :option:`test_spam.py`) will minimize output and only print +whether the test passed or failed and thus minimize output. Running :mod:`test.regrtest` directly allows what resources are available for tests to use to be set. You do this by using the :option:`-u` command-line @@ -172,10 +172,10 @@ regrtest.py` :option:`-h`. Some other ways to execute the regression tests depend on what platform the -tests are being executed on. On Unix, you can run :program:`make` :option:`test` -at the top-level directory where Python was built. On Windows, executing -:program:`rt.bat` from your :file:`PCBuild` directory will run all regression -tests. +tests are being executed on. On Unix, you can run :program:`make` +:option:`test` at the top-level directory where Python was built. On Windows, +executing :program:`rt.bat` from your :file:`PCBuild` directory will run all +regression tests. :mod:`test.support` --- Utility functions for tests @@ -198,17 +198,11 @@ methods. -.. exception:: TestSkipped - - Subclass of :exc:`TestFailed`. Raised when a test is skipped. This occurs when a - needed resource (such as a network connection) is not available at the time of - testing. - - .. exception:: ResourceDenied - Subclass of :exc:`TestSkipped`. Raised when a resource (such as a network - connection) is not available. Raised by the :func:`requires` function. + Subclass of :exc:`unittest.SkipTest`. Raised when a resource (such as a + network connection) is not available. Raised by the :func:`requires` + function. The :mod:`test.support` module defines the following constants: @@ -227,7 +221,7 @@ .. data:: TESTFN - Set to the path that a temporary file may be created at. Any temporary that is + Set to the name that a temporary file could use. Any temporary file that is created should be closed and unlinked (removed). The :mod:`test.support` module defines the following functions: @@ -235,36 +229,37 @@ .. function:: forget(module_name) - Removes the module named *module_name* from ``sys.modules`` and deletes any + Remove the module named *module_name* from ``sys.modules`` and deletes any byte-compiled files of the module. .. function:: is_resource_enabled(resource) - Returns :const:`True` if *resource* is enabled and available. The list of + Return :const:`True` if *resource* is enabled and available. The list of available resources is only set when :mod:`test.regrtest` is executing the tests. .. function:: requires(resource, msg=None) - Raises :exc:`ResourceDenied` if *resource* is not available. *msg* is the - argument to :exc:`ResourceDenied` if it is raised. Always returns true if called - by a function whose ``__name__`` is ``'__main__'``. Used when tests are executed - by :mod:`test.regrtest`. + Raise :exc:`ResourceDenied` if *resource* is not available. *msg* is the + argument to :exc:`ResourceDenied` if it is raised. Always returns + :const:`True` if called by a function whose ``__name__`` is ``'__main__'``. + Used when tests are executed by :mod:`test.regrtest`. .. function:: findfile(filename) - Return the path to the file named *filename*. If no match is found *filename* is - returned. This does not equal a failure since it could be the path to the file. + Return the path to the file named *filename*. If no match is found + *filename* is returned. This does not equal a failure since it could be the + path to the file. .. function:: run_unittest(*classes) Execute :class:`unittest.TestCase` subclasses passed to the function. The - function scans the classes for methods starting with the prefix ``test_`` and - executes the tests individually. + function scans the classes for methods starting with the prefix ``test_`` + and executes the tests individually. It is also legal to pass strings as parameters; these should be keys in ``sys.modules``. Each associated module will be scanned by @@ -277,36 +272,61 @@ This will run all tests defined in the named module. -.. function:: check_warnings() +.. function:: check_warnings(*filters, quiet=None) A convenience wrapper for ``warnings.catch_warnings()`` that makes it easier to test that a warning was correctly raised with a single assertion. It is approximately equivalent to calling ``warnings.catch_warnings(record=True)``. - The main difference is that on entry to the context manager, a - :class:`WarningRecorder` instance is returned instead of a simple list. - The underlying warnings list is available via the recorder object's - :attr:`warnings` attribute, while the attributes of the last raised - warning are also accessible directly on the object. If no warning has - been raised, then the latter attributes will all be :const:`None`. + It accepts 2-tuples ``("message regexp", WarningCategory)`` as positional + arguments. If there's some ``*filters`` defined, or if the optional keyword + argument ``quiet`` is :const:`False`, it checks if the warnings are + effective. If some filter did not catch any warning, the test fails. If some + warnings are not caught, the test fails, too. To disable these checks, set + argument ``quiet`` to :const:`True`. + + Without argument, it defaults to:: + + check_warnings(("", Warning), quiet=True) + + Additionally, on entry to the context manager, a :class:`WarningRecorder` + instance is returned. The underlying warnings list is available via the + recorder object's :attr:`warnings` attribute, while the attributes of the + last raised warning are also accessible directly on the object. If no + warning has been raised, then the latter attributes will all be + :const:`None`. A :meth:`reset` method is also provided on the recorder object. This - method simply clears the warning list. + method simply clears the warnings list. + + The context manager may be used like this:: - The context manager is used like this:: + import warnings - with check_warnings() as w: + with check_warnings(quiet=False): + exec('assert(False, "Hey!")') + warnings.warn(UserWarning("Hide me!")) + + with check_warnings(("assertion is always true", SyntaxWarning), + ("", UserWarning)): + exec('assert(False, "Hey!")') + warnings.warn(UserWarning("Hide me!")) + + with check_warnings(quiet=True) as w: warnings.simplefilter("always") warnings.warn("foo") - assert str(w.message) == "foo" + assert str(w.args[0]) == "foo" warnings.warn("bar") - assert str(w.message) == "bar" - assert str(w.warnings[0].message) == "foo" - assert str(w.warnings[1].message) == "bar" + assert str(w.args[0]) == "bar" + assert str(w.warnings[0].args[0]) == "foo" + assert str(w.warnings[1].args[0]) == "bar" w.reset() assert len(w.warnings) == 0 + .. versionchanged:: 3.2 + New optional attributes ``*filters`` and ``quiet``. + .. function:: captured_stdout() @@ -382,18 +402,19 @@ .. class:: EnvironmentVarGuard() - Class used to temporarily set or unset environment variables. Instances can be - used as a context manager and have a complete dictionary interface for - querying/modifying the underlying ``os.environ``. After exit from the context - manager all changes to environment variables done through this instance will - be rolled back. + Class used to temporarily set or unset environment variables. Instances can + be used as a context manager and have a complete dictionary interface for + querying/modifying the underlying ``os.environ``. After exit from the + context manager all changes to environment variables done through this + instance will be rolled back. .. versionchanged:: 3.1 Added dictionary interface. .. method:: EnvironmentVarGuard.set(envvar, value) - Temporarily set the environment variable ``envvar`` to the value of ``value``. + Temporarily set the environment variable ``envvar`` to the value of + ``value``. .. method:: EnvironmentVarGuard.unset(envvar) @@ -405,4 +426,3 @@ Class used to record warnings for unit tests. See documentation of :func:`check_warnings` above for more details. - Modified: python/branches/py3k-cdecimal/Doc/library/threading.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/threading.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/threading.rst Thu Apr 1 11:38:52 2010 @@ -647,9 +647,6 @@ Return true if and only if the internal flag is true. - .. versionchanged:: 2.6 - The ``is_set()`` syntax is new. - .. method:: set() Set the internal flag to true. All threads waiting for it to become true Modified: python/branches/py3k-cdecimal/Doc/library/tkinter.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/tkinter.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/tkinter.rst Thu Apr 1 11:38:52 2010 @@ -30,8 +30,8 @@ Tkinter Modules --------------- -Most of the time, the :mod:`tkinter` is all you really need, but a number -of additional modules are available as well. The Tk interface is located in a +Most of the time, :mod:`tkinter` is all you really need, but a number of +additional modules are available as well. The Tk interface is located in a binary module named :mod:`_tkinter`. This module contains the low-level interface to Tk, and should never be used directly by application programmers. It is usually a shared library (or DLL), but might in some cases be statically @@ -112,13 +112,13 @@ Credits: -* Tkinter was written by Steen Lumholt and Guido van Rossum. - * Tk was written by John Ousterhout while at Berkeley. +* Tkinter was written by Steen Lumholt and Guido van Rossum. + * This Life Preserver was written by Matt Conway at the University of Virginia. -* The html rendering, and some liberal editing, was produced from a FrameMaker +* The HTML rendering, and some liberal editing, was produced from a FrameMaker version by Ken Manheimer. * Fredrik Lundh elaborated and revised the class interface descriptions, to get @@ -143,10 +143,10 @@ can't fulfill that role, so the best we can do is point you to the best documentation that exists. Here are some hints: -* The authors strongly suggest getting a copy of the Tk man pages. Specifically, - the man pages in the ``mann`` directory are most useful. The ``man3`` man pages - describe the C interface to the Tk library and thus are not especially helpful - for script writers. +* The authors strongly suggest getting a copy of the Tk man pages. + Specifically, the man pages in the ``manN`` directory are most useful. + The ``man3`` man pages describe the C interface to the Tk library and thus + are not especially helpful for script writers. * Addison-Wesley publishes a book called Tcl and the Tk Toolkit by John Ousterhout (ISBN 0-201-63337-X) which is a good introduction to Tcl and Tk for @@ -159,6 +159,9 @@ .. seealso:: + `Tcl/Tk 8.6 man pages `_ + The Tcl/Tk manual on www.tcl.tk. + `ActiveState Tcl Home Page `_ The Tk/Tcl development is largely taking place at ActiveState. @@ -183,8 +186,8 @@ def createWidgets(self): self.QUIT = Button(self) self.QUIT["text"] = "QUIT" - self.QUIT["fg"] = "red" - self.QUIT["command"] = self.quit + self.QUIT["fg"] = "red" + self.QUIT["command"] = self.quit self.QUIT.pack({"side": "left"}) @@ -257,7 +260,7 @@ For example:: button .fred -fg red -text "hi there" - ^ ^ \_____________________/ + ^ ^ \______________________/ | | | class new options command widget (-opt val -opt val ...) @@ -301,15 +304,15 @@ dictionary style, for established instances. See section :ref:`tkinter-setting-options` on setting options. :: - button .fred -fg red =====> fred = Button(panel, fg = "red") + button .fred -fg red =====> fred = Button(panel, fg="red") .fred configure -fg red =====> fred["fg"] = red - OR ==> fred.config(fg = "red") + OR ==> fred.config(fg="red") In Tk, to perform an action on a widget, use the widget name as a command, and follow it with an action name, possibly with arguments (options). In Tkinter, you call methods on the class instance to invoke actions on the widget. The -actions (methods) that a given widget can perform are listed in the Tkinter.py -module. :: +actions (methods) that a given widget can perform are listed in +:file:`tkinter/__init__.py`. :: .fred invoke =====> fred.invoke() @@ -320,7 +323,7 @@ methods. See the :mod:`tkinter.tix` module documentation for additional information on the Form geometry manager. :: - pack .fred -side left =====> fred.pack(side = "left") + pack .fred -side left =====> fred.pack(side="left") How Tk and Tkinter are Related @@ -332,14 +335,15 @@ A Python application makes a :mod:`tkinter` call. tkinter (Python Package) - This call (say, for example, creating a button widget), is implemented in the - *tkinter* package, which is written in Python. This Python function will parse - the commands and the arguments and convert them into a form that makes them look - as if they had come from a Tk script instead of a Python script. + This call (say, for example, creating a button widget), is implemented in + the :mod:`tkinter` package, which is written in Python. This Python + function will parse the commands and the arguments and convert them into a + form that makes them look as if they had come from a Tk script instead of + a Python script. -tkinter (C) +_tkinter (C) These commands and their arguments will be passed to a C function in the - *tkinter* - note the lowercase - extension module. + :mod:`_tkinter` - note the underscore - extension module. Tk Widgets (C and Tcl) This C function is able to make calls into other C modules, including the C @@ -370,7 +374,7 @@ At object creation time, using keyword arguments :: - fred = Button(self, fg = "red", bg = "blue") + fred = Button(self, fg="red", bg="blue") After object creation, treating the option name like a dictionary index :: @@ -381,7 +385,7 @@ Use the config() method to update multiple attrs subsequent to object creation :: - fred.config(fg = "red", bg = "blue") + fred.config(fg="red", bg="blue") For a complete explanation of a given option and its behavior, see the Tk man pages for the widget in question. @@ -464,8 +468,8 @@ the main application window is resized. Here are some examples:: fred.pack() # defaults to side = "top" - fred.pack(side = "left") - fred.pack(expand = 1) + fred.pack(side="left") + fred.pack(expand=1) Packer Options @@ -506,7 +510,7 @@ possible to hand over an arbitrary Python variable to a widget through a ``variable`` or ``textvariable`` option. The only kinds of variables for which this works are variables that are subclassed from a class called Variable, -defined in the :mod:`tkinter`. +defined in :mod:`tkinter`. There are many useful subclasses of Variable already defined: :class:`StringVar`, :class:`IntVar`, :class:`DoubleVar`, and @@ -606,7 +610,7 @@ This is any Python function that takes no arguments. For example:: def print_it(): - print("hi there") + print("hi there") fred["command"] = print_it color @@ -702,24 +706,32 @@ :meth:`turnRed` callback. This field contains the widget that caught the X event. The following table lists the other event fields you can access, and how they are denoted in Tk, which can be useful when referring to the Tk man pages. -:: - Tk Tkinter Event Field Tk Tkinter Event Field - -- ------------------- -- ------------------- - %f focus %A char - %h height %E send_event - %k keycode %K keysym - %s state %N keysym_num - %t time %T type - %w width %W widget - %x x %X x_root - %y y %Y y_root ++----+---------------------+----+---------------------+ +| Tk | Tkinter Event Field | Tk | Tkinter Event Field | ++====+=====================+====+=====================+ +| %f | focus | %A | char | ++----+---------------------+----+---------------------+ +| %h | height | %E | send_event | ++----+---------------------+----+---------------------+ +| %k | keycode | %K | keysym | ++----+---------------------+----+---------------------+ +| %s | state | %N | keysym_num | ++----+---------------------+----+---------------------+ +| %t | time | %T | type | ++----+---------------------+----+---------------------+ +| %w | width | %W | widget | ++----+---------------------+----+---------------------+ +| %x | x | %X | x_root | ++----+---------------------+----+---------------------+ +| %y | y | %Y | y_root | ++----+---------------------+----+---------------------+ The index Parameter ^^^^^^^^^^^^^^^^^^^ -A number of widgets require"index" parameters to be passed. These are used to +A number of widgets require "index" parameters to be passed. These are used to point at a specific place in a Text widget, or to particular characters in an Entry widget, or to particular menu items in a Menu widget. @@ -755,7 +767,7 @@ * an integer which refers to the numeric position of the entry in the widget, counted from the top, starting with 0; - * the string ``'active'``, which refers to the menu position that is currently + * the string ``"active"``, which refers to the menu position that is currently under the cursor; * the string ``"last"`` which refers to the last menu item; Modified: python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst Thu Apr 1 11:38:52 2010 @@ -84,7 +84,7 @@ ----------- `Tix `_ -introduces over 40 widget classes to the :mod:`Tkinter` repertoire. There is a +introduces over 40 widget classes to the :mod:`tkinter` repertoire. There is a demo of all the :mod:`tkinter.tix` widgets in the :file:`Demo/tix` directory of the standard distribution. Modified: python/branches/py3k-cdecimal/Doc/library/tkinter.ttk.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/tkinter.ttk.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/tkinter.ttk.rst Thu Apr 1 11:38:52 2010 @@ -116,12 +116,13 @@ | | for the parent widget. | +-----------+--------------------------------------------------------------+ | takefocus | Determines whether the window accepts the focus during | - | | keyboard traversal. 0, 1 or an empty is return. If 0 is | - | | returned, it means that the window should be skipped entirely| - | | during keyboard traversal. If 1, it means that the window | - | | should receive the input focus as long as it is viewable. And| - | | an empty string means that the traversal scripts make the | - | | decision about whether or not to focus on the window. | + | | keyboard traversal. 0, 1 or an empty string is returned. | + | | If 0 is returned, it means that the window should be skipped | + | | entirely during keyboard traversal. If 1, it means that the | + | | window should receive the input focus as long as it is | + | | viewable. And an empty string means that the traversal | + | | scripts make the decision about whether or not to focus | + | | on the window. | +-----------+--------------------------------------------------------------+ | style | May be used to specify a custom widget style. | +-----------+--------------------------------------------------------------+ Modified: python/branches/py3k-cdecimal/Doc/library/tokenize.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/tokenize.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/tokenize.rst Thu Apr 1 11:38:52 2010 @@ -95,9 +95,20 @@ It detects the encoding from the presence of a UTF-8 BOM or an encoding cookie as specified in :pep:`263`. If both a BOM and a cookie are present, - but disagree, a SyntaxError will be raised. + but disagree, a SyntaxError will be raised. Note that if the BOM is found, + ``'utf-8-sig'`` will be returned as an encoding. - If no encoding is specified, then the default of ``'utf-8'`` will be returned. + If no encoding is specified, then the default of ``'utf-8'`` will be + returned. + + :func:`detect_encoding` is useful for robustly reading Python source files. + A common pattern for this follows:: + + def read_python_source(file_name): + with open(file_name, "rb") as fp: + encoding = tokenize.detect_encoding(fp.readline)[0] + with open(file_name, "r", encoding=encoding) as fp: + return fp.read() Example of a script re-writer that transforms float literals into Decimal Modified: python/branches/py3k-cdecimal/Doc/library/traceback.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/traceback.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/traceback.rst Thu Apr 1 11:38:52 2010 @@ -172,12 +172,12 @@ try: lumberjack() - except: - exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() + except IndexError: + exc_type, exc_value, exc_traceback = sys.exc_info() print("*** print_tb:") - traceback.print_tb(exceptionTraceback, limit=1, file=sys.stdout) + traceback.print_tb(exc_traceback, limit=1, file=sys.stdout) print("*** print_exception:") - traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback, + traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stdout) print("*** print_exc:") traceback.print_exc() @@ -186,13 +186,13 @@ print(formatted_lines[0]) print(formatted_lines[-1]) print("*** format_exception:") - print(repr(traceback.format_exception(exceptionType, exceptionValue, - exceptionTraceback))) + print(repr(traceback.format_exception(exc_type, exc_value, + exc_traceback))) print("*** extract_tb:") - print(repr(traceback.extract_tb(exceptionTraceback))) + print(repr(traceback.extract_tb(exc_traceback))) print("*** format_tb:") - print(repr(traceback.format_tb(exceptionTraceback))) - print("*** tb_lineno:", traceback.tb_lineno(exceptionTraceback)) + print(repr(traceback.format_tb(exc_traceback))) + print("*** tb_lineno:", exc_traceback.tb_lineno) The output for the example would look similar to this: Modified: python/branches/py3k-cdecimal/Doc/library/turtle.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/turtle.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/turtle.rst Thu Apr 1 11:38:52 2010 @@ -35,13 +35,13 @@ the module from within IDLE run with the ``-n`` switch. The turtle module provides turtle graphics primitives, in both object-oriented -and procedure-oriented ways. Because it uses :mod:`Tkinter` for the underlying +and procedure-oriented ways. Because it uses :mod:`tkinter` for the underlying graphics, it needs a version of Python installed with Tk support. The object-oriented interface uses essentially two+two classes: 1. The :class:`TurtleScreen` class defines graphics windows as a playground for - the drawing turtles. Its constructor needs a :class:`Tkinter.Canvas` or a + the drawing turtles. Its constructor needs a :class:`tkinter.Canvas` or a :class:`ScrolledCanvas` as argument. It should be used when :mod:`turtle` is used as part of some application. @@ -1998,7 +1998,7 @@ .. class:: RawTurtle(canvas) RawPen(canvas) - :param canvas: a :class:`Tkinter.Canvas`, a :class:`ScrolledCanvas` or a + :param canvas: a :class:`tkinter.Canvas`, a :class:`ScrolledCanvas` or a :class:`TurtleScreen` Create a turtle. The turtle has all methods described above as "methods of @@ -2013,7 +2013,7 @@ .. class:: TurtleScreen(cv) - :param cv: a :class:`Tkinter.Canvas` + :param cv: a :class:`tkinter.Canvas` Provides screen oriented methods like :func:`setbg` etc. that are described above. Modified: python/branches/py3k-cdecimal/Doc/library/unicodedata.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/unicodedata.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/unicodedata.rst Thu Apr 1 11:38:52 2010 @@ -15,12 +15,12 @@ This module provides access to the Unicode Character Database which defines character properties for all Unicode characters. The data in this database is -based on the :file:`UnicodeData.txt` file version 5.1.0 which is publicly +based on the :file:`UnicodeData.txt` file version 5.2.0 which is publicly available from ftp://ftp.unicode.org/. The module uses the same names and symbols as defined by the UnicodeData File -Format 5.1.0 (see http://www.unicode.org/Public/5.1.0/ucd/UCD.html). It defines -the following functions: +Format 5.2.0 (see http://www.unicode.org/reports/tr44/tr44-4.html). +It defines the following functions: .. function:: lookup(name) Modified: python/branches/py3k-cdecimal/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/unittest.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/unittest.rst Thu Apr 1 11:38:52 2010 @@ -177,14 +177,18 @@ self.seq.sort() self.assertEqual(self.seq, list(range(10))) + # should raise an exception for an immutable sequence + self.assertRaises(TypeError, random.shuffle, (1,2,3)) + def test_choice(self): element = random.choice(self.seq) - self.assertIn(element, self.seq) + self.assertTrue(element in self.seq) def test_sample(self): - self.assertRaises(ValueError, random.sample, self.seq, 20) + with self.assertRaises(ValueError): + random.sample(self.seq, 20) for element in random.sample(self.seq, 5): - self.assertIn(element, self.seq) + self.assertTrue(element in self.seq) if __name__ == '__main__': unittest.main() @@ -226,9 +230,9 @@ Running the revised script from the interpreter or another script produces the following output:: - testchoice (__main__.TestSequenceFunctions) ... ok - testsample (__main__.TestSequenceFunctions) ... ok - testshuffle (__main__.TestSequenceFunctions) ... ok + test_choice (__main__.TestSequenceFunctions) ... ok + test_sample (__main__.TestSequenceFunctions) ... ok + test_shuffle (__main__.TestSequenceFunctions) ... ok ---------------------------------------------------------------------- Ran 3 tests in 0.110s @@ -345,32 +349,32 @@ self.widget.dispose() self.widget = None - def testDefaultSize(self): + def test_default_size(self): self.assertEqual(self.widget.size(), (50,50), 'incorrect default size') - def testResize(self): + def test_resize(self): self.widget.resize(100,150) self.assertEqual(self.widget.size(), (100,150), 'wrong size after resize') Here we have not provided a :meth:`~TestCase.runTest` method, but have instead provided two different test methods. Class instances will now each run one of -the :meth:`test\*` methods, with ``self.widget`` created and destroyed +the :meth:`test_\*` methods, with ``self.widget`` created and destroyed separately for each instance. When creating an instance we must specify the test method it is to run. We do this by passing the method name in the constructor:: - defaultSizeTestCase = WidgetTestCase('testDefaultSize') - resizeTestCase = WidgetTestCase('testResize') + defaultSizeTestCase = WidgetTestCase('test_default_size') + resizeTestCase = WidgetTestCase('test_resize') Test case instances are grouped together according to the features they test. :mod:`unittest` provides a mechanism for this: the :dfn:`test suite`, represented by :mod:`unittest`'s :class:`TestSuite` class:: widgetTestSuite = unittest.TestSuite() - widgetTestSuite.addTest(WidgetTestCase('testDefaultSize')) - widgetTestSuite.addTest(WidgetTestCase('testResize')) + widgetTestSuite.addTest(WidgetTestCase('test_default_size')) + widgetTestSuite.addTest(WidgetTestCase('test_resize')) For the ease of running tests, as we will see later, it is a good idea to provide in each test module a callable object that returns a pre-built test @@ -378,14 +382,14 @@ def suite(): suite = unittest.TestSuite() - suite.addTest(WidgetTestCase('testDefaultSize')) - suite.addTest(WidgetTestCase('testResize')) + suite.addTest(WidgetTestCase('test_default_size')) + suite.addTest(WidgetTestCase('test_resize')) return suite or even:: def suite(): - tests = ['testDefaultSize', 'testResize'] + tests = ['test_default_size', 'test_resize'] return unittest.TestSuite(map(WidgetTestCase, tests)) @@ -396,8 +400,8 @@ suite = unittest.TestLoader().loadTestsFromTestCase(WidgetTestCase) -will create a test suite that will run ``WidgetTestCase.testDefaultSize()`` and -``WidgetTestCase.testResize``. :class:`TestLoader` uses the ``'test'`` method +will create a test suite that will run ``WidgetTestCase.test_default_size()`` and +``WidgetTestCase.test_resize``. :class:`TestLoader` uses the ``'test'`` method name prefix to identify test methods automatically. Note that the order in which the various test cases will be run is @@ -605,8 +609,8 @@ def suite(): suite = unittest.TestSuite() - suite.addTest(WidgetTestCase('testDefaultSize')) - suite.addTest(WidgetTestCase('testResize')) + suite.addTest(WidgetTestCase('test_default_size')) + suite.addTest(WidgetTestCase('test_resize')) return suite Here, we create two instances of :class:`WidgetTestCase`, each of which runs a @@ -676,7 +680,7 @@ will be *msg* if given, otherwise it will be :const:`None`. .. deprecated:: 3.1 - :meth:`failUnless`. + :meth:`failUnless`; use one of the ``assert`` variants. :meth:`assert_`; use :meth:`assertTrue`. @@ -704,7 +708,7 @@ function for comparing strings. .. deprecated:: 3.1 - :meth:`failUnlessEqual`. + :meth:`failUnlessEqual`; use :meth:`assertEqual`. .. method:: assertNotEqual(first, second, msg=None) @@ -718,7 +722,7 @@ *first* and *second*. .. deprecated:: 3.1 - :meth:`failIfEqual`. + :meth:`failIfEqual`; use :meth:`assertNotEqual`. .. method:: assertAlmostEqual(first, second, *, places=7, msg=None) @@ -737,7 +741,7 @@ Objects that compare equal are automatically almost equal. .. deprecated:: 3.1 - :meth:`failUnlessAlmostEqual`. + :meth:`failUnlessAlmostEqual`; use :meth:`assertAlmostEqual`. .. method:: assertNotAlmostEqual(first, second, *, places=7, msg=None) @@ -756,7 +760,7 @@ Objects that compare equal automatically fail. .. deprecated:: 3.1 - :meth:`failIfAlmostEqual`. + :meth:`failIfAlmostEqual`; use :meth:`assertNotAlmostEqual`. .. method:: assertGreater(first, second, msg=None) @@ -781,7 +785,7 @@ will be included in the error message. This method is used by default when comparing strings with :meth:`assertEqual`. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. .. versionadded:: 3.1 @@ -802,7 +806,7 @@ Tests that *first* is or is not in *second* with an explanatory error message as appropriate. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. .. versionadded:: 3.1 @@ -815,12 +819,31 @@ Duplicate elements are ignored when comparing *actual* and *expected*. It is the equivalent of ``assertEqual(set(expected), set(actual))`` - but it works with sequences of unhashable objects as well. + but it works with sequences of unhashable objects as well. Because + duplicates are ignored, this method has been deprecated in favour of + :meth:`assertItemsEqual`. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. .. versionadded:: 3.1 + .. deprecated:: 3.2 + + .. method:: assertItemsEqual(actual, expected, msg=None) + + Test that sequence *expected* contains the same elements as *actual*, + regardless of their order. When they don't, an error message listing the + differences between the sequences will be generated. + + Duplicate elements are *not* ignored when comparing *actual* and + *expected*. It verifies if each element has the same count in both + sequences. It is the equivalent of ``assertEqual(sorted(expected), + sorted(actual))`` but it works with sequences of unhashable objects as + well. + + If specified, *msg* will be used as the error message on failure. + + .. versionadded:: 3.2 .. method:: assertSetEqual(set1, set2, msg=None) @@ -831,7 +854,7 @@ Fails if either of *set1* or *set2* does not have a :meth:`set.difference` method. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. .. versionadded:: 3.1 @@ -843,7 +866,7 @@ method will be used by default to compare dictionaries in calls to :meth:`assertEqual`. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. .. versionadded:: 3.1 @@ -854,7 +877,7 @@ superset of those in *expected*. If not, an error message listing the missing keys and mismatched values is generated. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. .. versionadded:: 3.1 @@ -868,7 +891,7 @@ These methods are used by default when comparing lists or tuples with :meth:`assertEqual`. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. .. versionadded:: 3.1 @@ -880,7 +903,7 @@ be raised. If the sequences are different an error message is constructed that shows the difference between the two. - If specified *msg* will be used as the error message on failure. + If specified, *msg* will be used as the error message on failure. This method is used to implement :meth:`assertListEqual` and :meth:`assertTupleEqual`. @@ -923,7 +946,7 @@ Added the :attr:`exception` attribute. .. deprecated:: 3.1 - :meth:`failUnlessRaises`. + :meth:`failUnlessRaises`; use :meth:`assertRaises`. .. method:: assertRaisesRegexp(exception, regexp[, callable, ...]) @@ -1000,7 +1023,7 @@ for the error message. .. deprecated:: 3.1 - :meth:`failIf`. + :meth:`failIf`; use :meth:`assertFalse`. .. method:: fail(msg=None) @@ -1221,7 +1244,7 @@ :class:`TestLoader` objects have the following methods: - +a .. method:: loadTestsFromTestCase(testCaseClass) Return a suite of all tests cases contained in the :class:`TestCase`\ -derived Modified: python/branches/py3k-cdecimal/Doc/library/urllib.request.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/urllib.request.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/urllib.request.rst Thu Apr 1 11:38:52 2010 @@ -164,6 +164,14 @@ path. This does not accept a complete URL. This function uses :func:`unquote` to decode *path*. +.. function:: getproxies() + + This helper function returns a dictionary of scheme to proxy server URL + mappings. It scans the environment for variables named ``_proxy`` + for all operating systems first, and when it cannot find it, looks for proxy + information from Mac OSX System Configuration for Mac OS X and Windows + Systems Registry for Windows. + The following classes are provided: Modified: python/branches/py3k-cdecimal/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/weakref.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/weakref.rst Thu Apr 1 11:38:52 2010 @@ -59,10 +59,10 @@ Not all objects can be weakly referenced; those objects which can include class instances, functions written in Python (but not in C), instance methods, sets, frozensets, file objects, :term:`generator`\s, type objects, sockets, arrays, -deques, and regular expression pattern objects. +deques, regular expression pattern objects, and code objects. .. versionchanged:: 3.2 - Added support for thread.lock and threading.Lock. + Added support for thread.lock, threading.Lock, and code objects. Several built-in types such as :class:`list` and :class:`dict` do not directly support weak references but can add support through subclassing:: Modified: python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst Thu Apr 1 11:38:52 2010 @@ -82,22 +82,12 @@ dom3 = parseString("Some data") assert dom3.documentElement.tagName == "myxml" -When you are finished with a DOM, you should clean it up. This is necessary -because some versions of Python do not support garbage collection of objects -that refer to each other in a cycle. Until this restriction is removed from all -versions of Python, it is safest to write your code as if cycles would not be -cleaned up. - -The way to clean up a DOM is to call its :meth:`unlink` method:: - - dom1.unlink() - dom2.unlink() - dom3.unlink() - -:meth:`unlink` is a :mod:`xml.dom.minidom`\ -specific extension to the DOM API. -After calling :meth:`unlink` on a node, the node and its descendants are -essentially useless. - +When you are finished with a DOM tree, you may optionally call the +:meth:`unlink` method to encourage early cleanup of the now-unneeded +objects. :meth:`unlink` is a :mod:`xml.dom.minidom`\ -specific +extension to the DOM API that renders the node and its descendants are +essentially useless. Otherwise, Python's garbage collector will +eventually take care of the objects in the tree. .. seealso:: Modified: python/branches/py3k-cdecimal/Doc/library/xml.etree.elementtree.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/xml.etree.elementtree.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/xml.etree.elementtree.rst Thu Apr 1 11:38:52 2010 @@ -6,9 +6,9 @@ .. moduleauthor:: Fredrik Lundh -The Element type is a flexible container object, designed to store hierarchical -data structures in memory. The type can be described as a cross between a list -and a dictionary. +The :class:`Element` type is a flexible container object, designed to store +hierarchical data structures in memory. The type can be described as a cross +between a list and a dictionary. Each element has a number of properties associated with it: @@ -23,7 +23,8 @@ * a number of child elements, stored in a Python sequence -To create an element instance, use the Element or SubElement factory functions. +To create an element instance, use the :class:`Element` constructor or the +:func:`SubElement` factory function. The :class:`ElementTree` class can be used to wrap an element structure, and convert it from and to XML. @@ -31,8 +32,14 @@ A C implementation of this API is available as :mod:`xml.etree.cElementTree`. See http://effbot.org/zone/element-index.htm for tutorials and links to other -docs. Fredrik Lundh's page is also the location of the development version of the -xml.etree.ElementTree. +docs. Fredrik Lundh's page is also the location of the development version of +the xml.etree.ElementTree. + +.. versionchanged:: 3.2 + The ElementTree API is updated to 1.3. For more information, see + `Introducing ElementTree 1.3 + `_. + .. _elementtree-functions: @@ -43,16 +50,16 @@ .. function:: Comment(text=None) Comment element factory. This factory function creates a special element - that will be serialized as an XML comment. The comment string can be either - an ASCII-only :class:`bytes` object or a :class:`str` object. *text* is a - string containing the comment string. Returns an element instance + that will be serialized as an XML comment by the standard serializer. The + comment string can be either a bytestring or a Unicode string. *text* is a + string containing the comment string. Returns an element instance representing a comment. .. function:: dump(elem) - Writes an element tree or element structure to sys.stdout. This function should - be used for debugging only. + Writes an element tree or element structure to sys.stdout. This function + should be used for debugging only. The exact output format is implementation dependent. In this version, it's written as an ordinary XML file. @@ -60,38 +67,36 @@ *elem* is an element tree or an individual element. -.. function:: Element(tag, attrib={}, **extra) +.. function:: fromstring(text) - Element factory. This function returns an object implementing the standard - Element interface. The exact class or type of that object is implementation - dependent, but it will always be compatible with the _ElementInterface class in - this module. - - The element name, attribute names, and attribute values can be either an - ASCII-only :class:`bytes` object or a :class:`str` object. *tag* is the - element name. *attrib* is an optional dictionary, containing element - attributes. *extra* contains additional attributes, given as keyword - arguments. Returns an element instance. + Parses an XML section from a string constant. Same as :func:`XML`. *text* + is a string containing XML data. Returns an :class:`Element` instance. -.. function:: fromstring(text) +.. function:: fromstringlist(sequence, parser=None) - Parses an XML section from a string constant. Same as XML. *text* is a string - containing XML data. Returns an Element instance. + Parses an XML document from a sequence of string fragments. *sequence* is a + list or other sequence containing XML data fragments. *parser* is an + optional parser instance. If not given, the standard :class:`XMLParser` + parser is used. Returns an :class:`Element` instance. + + .. versionadded:: 3.2 .. function:: iselement(element) - Checks if an object appears to be a valid element object. *element* is an - element instance. Returns a true value if this is an element object. + Checks if an object appears to be a valid element object. *element* is an + element instance. Returns a true value if this is an element object. -.. function:: iterparse(source, events=None) +.. function:: iterparse(source, events=None, parser=None) Parses an XML section into an element tree incrementally, and reports what's - going on to the user. *source* is a filename or file object containing XML data. - *events* is a list of events to report back. If omitted, only "end" events are - reported. Returns an :term:`iterator` providing ``(event, elem)`` pairs. + going on to the user. *source* is a filename or file object containing XML + data. *events* is a list of events to report back. If omitted, only "end" + events are reported. *parser* is an optional parser instance. If not + given, the standard :class:`XMLParser` parser is used. Returns an + :term:`iterator` providing ``(event, elem)`` pairs. .. note:: @@ -106,196 +111,269 @@ .. function:: parse(source, parser=None) - Parses an XML section into an element tree. *source* is a filename or file - object containing XML data. *parser* is an optional parser instance. If not - given, the standard XMLTreeBuilder parser is used. Returns an ElementTree - instance. + Parses an XML section into an element tree. *source* is a filename or file + object containing XML data. *parser* is an optional parser instance. If + not given, the standard :class:`XMLParser` parser is used. Returns an + :class:`ElementTree` instance. .. function:: ProcessingInstruction(target, text=None) - PI element factory. This factory function creates a special element that will - be serialized as an XML processing instruction. *target* is a string containing - the PI target. *text* is a string containing the PI contents, if given. Returns - an element instance, representing a processing instruction. + PI element factory. This factory function creates a special element that + will be serialized as an XML processing instruction. *target* is a string + containing the PI target. *text* is a string containing the PI contents, if + given. Returns an element instance, representing a processing instruction. + + +.. function:: register_namespace(prefix, uri) + + Registers a namespace prefix. The registry is global, and any existing + mapping for either the given prefix or the namespace URI will be removed. + *prefix* is a namespace prefix. *uri* is a namespace uri. Tags and + attributes in this namespace will be serialized with the given prefix, if at + all possible. + + .. versionadded:: 3.2 .. function:: SubElement(parent, tag, attrib={}, **extra) - Subelement factory. This function creates an element instance, and appends it - to an existing element. + Subelement factory. This function creates an element instance, and appends + it to an existing element. + + The element name, attribute names, and attribute values can be either + bytestrings or Unicode strings. *parent* is the parent element. *tag* is + the subelement name. *attrib* is an optional dictionary, containing element + attributes. *extra* contains additional attributes, given as keyword + arguments. Returns an element instance. + + +.. function:: tostring(element, encoding=None, method="xml") + + Generates a string representation of an XML element, including all + subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is + the output encoding (default is None). *method* is either ``"xml"``, + ``"html"`` or ``"text"`` (default is ``"xml"``). Returns an (optionally) + encoded string containing the XML data. - The element name, attribute names, and attribute values can be an ASCII-only - :class:`bytes` object or a :class:`str` object. *parent* is the parent - element. *tag* is the subelement name. *attrib* is an optional dictionary, - containing element attributes. *extra* contains additional attributes, given - as keyword arguments. Returns an element instance. +.. function:: tostringlist(element, encoding=None, method="xml") -.. function:: tostring(element, encoding=None) + Generates a string representation of an XML element, including all + subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is + the output encoding (default is None). *method* is either ``"xml"``, + ``"html"`` or ``"text"`` (default is ``"xml"``). Returns a list of + (optionally) encoded strings containing the XML data. It does not guarantee + any specific sequence, except that ``"".join(tostringlist(element)) == + tostring(element)``. - Generates a string representation of an XML element, including all subelements. - *element* is an Element instance. *encoding* is the output encoding (default is - US-ASCII). Returns an encoded string containing the XML data. + .. versionadded:: 3.2 -.. function:: XML(text) +.. function:: XML(text, parser=None) Parses an XML section from a string constant. This function can be used to - embed "XML literals" in Python code. *text* is a string containing XML data. - Returns an Element instance. + embed "XML literals" in Python code. *text* is a string containing XML + data. *parser* is an optional parser instance. If not given, the standard + :class:`XMLParser` parser is used. Returns an :class:`Element` instance. -.. function:: XMLID(text) +.. function:: XMLID(text, parser=None) Parses an XML section from a string constant, and also returns a dictionary - which maps from element id:s to elements. *text* is a string containing XML - data. Returns a tuple containing an Element instance and a dictionary. + which maps from element id:s to elements. *text* is a string containing XML + data. *parser* is an optional parser instance. If not given, the standard + :class:`XMLParser` parser is used. Returns a tuple containing an + :class:`Element` instance and a dictionary. -.. _elementtree-element-interface: +.. _elementtree-element-objects: -The Element Interface ---------------------- +Element Objects +--------------- -Element objects returned by Element or SubElement have the following methods -and attributes. +.. class:: Element(tag, attrib={}, **extra) -.. attribute:: Element.tag + Element class. This class defines the Element interface, and provides a + reference implementation of this interface. - A string identifying what kind of data this element represents (the element - type, in other words). + The element name, attribute names, and attribute values can be either + bytestrings or Unicode strings. *tag* is the element name. *attrib* is + an optional dictionary, containing element attributes. *extra* contains + additional attributes, given as keyword arguments. -.. attribute:: Element.text + .. attribute:: tag - The *text* attribute can be used to hold additional data associated with the - element. As the name implies this attribute is usually a string but may be any - application-specific object. If the element is created from an XML file the - attribute will contain any text found between the element tags. + A string identifying what kind of data this element represents (the + element type, in other words). -.. attribute:: Element.tail + .. attribute:: text - The *tail* attribute can be used to hold additional data associated with the - element. This attribute is usually a string but may be any application-specific - object. If the element is created from an XML file the attribute will contain - any text found after the element's end tag and before the next tag. + The *text* attribute can be used to hold additional data associated with + the element. As the name implies this attribute is usually a string but + may be any application-specific object. If the element is created from + an XML file the attribute will contain any text found between the element + tags. -.. attribute:: Element.attrib + .. attribute:: tail - A dictionary containing the element's attributes. Note that while the *attrib* - value is always a real mutable Python dictionary, an ElementTree implementation - may choose to use another internal representation, and create the dictionary - only if someone asks for it. To take advantage of such implementations, use the - dictionary methods below whenever possible. + The *tail* attribute can be used to hold additional data associated with + the element. This attribute is usually a string but may be any + application-specific object. If the element is created from an XML file + the attribute will contain any text found after the element's end tag and + before the next tag. -The following dictionary-like methods work on the element attributes. + .. attribute:: attrib -.. method:: Element.clear() + A dictionary containing the element's attributes. Note that while the + *attrib* value is always a real mutable Python dictionary, an ElementTree + implementation may choose to use another internal representation, and + create the dictionary only if someone asks for it. To take advantage of + such implementations, use the dictionary methods below whenever possible. - Resets an element. This function removes all subelements, clears all - attributes, and sets the text and tail attributes to None. + The following dictionary-like methods work on the element attributes. -.. method:: Element.get(key, default=None) + .. method:: clear() - Gets the element attribute named *key*. + Resets an element. This function removes all subelements, clears all + attributes, and sets the text and tail attributes to None. - Returns the attribute value, or *default* if the attribute was not found. + .. method:: get(key, default=None) -.. method:: Element.items() + Gets the element attribute named *key*. - Returns the element attributes as a sequence of (name, value) pairs. The - attributes are returned in an arbitrary order. + Returns the attribute value, or *default* if the attribute was not found. -.. method:: Element.keys() + .. method:: items() - Returns the elements attribute names as a list. The names are returned in an - arbitrary order. + Returns the element attributes as a sequence of (name, value) pairs. The + attributes are returned in an arbitrary order. -.. method:: Element.set(key, value) + .. method:: keys() - Set the attribute *key* on the element to *value*. + Returns the elements attribute names as a list. The names are returned + in an arbitrary order. -The following methods work on the element's children (subelements). + .. method:: set(key, value) -.. method:: Element.append(subelement) + Set the attribute *key* on the element to *value*. - Adds the element *subelement* to the end of this elements internal list of - subelements. + The following methods work on the element's children (subelements). -.. method:: Element.find(match) + .. method:: append(subelement) - Finds the first subelement matching *match*. *match* may be a tag name or path. - Returns an element instance or ``None``. + Adds the element *subelement* to the end of this elements internal list + of subelements. -.. method:: Element.findall(match) + .. method:: extend(subelements) - Finds all subelements matching *match*. *match* may be a tag name or path. - Returns an iterable yielding all matching elements in document order. + Appends *subelements* from a sequence object with zero or more elements. + Raises :exc:`AssertionError` if a subelement is not a valid object. + .. versionadded:: 3.2 -.. method:: Element.findtext(condition, default=None) - Finds text for the first subelement matching *condition*. *condition* may be a - tag name or path. Returns the text content of the first matching element, or - *default* if no element was found. Note that if the matching element has no - text content an empty string is returned. + .. method:: find(match) + Finds the first subelement matching *match*. *match* may be a tag name + or path. Returns an element instance or ``None``. + + + .. method:: findall(match) + + Finds all matching subelements, by tag name or path. Returns a list + containing all matching elements in document order. + + + .. method:: findtext(match, default=None) + + Finds text for the first subelement matching *match*. *match* may be + a tag name or path. Returns the text content of the first matching + element, or *default* if no element was found. Note that if the matching + element has no text content an empty string is returned. + + + .. method:: getchildren() + + .. deprecated:: 2.7 + Use ``list(elem)`` or iteration. + + + .. method:: getiterator(tag=None) -.. method:: Element.getchildren() + .. deprecated:: 2.7 + Use method :meth:`Element.iter` instead. - Returns all subelements. The elements are returned in document order. + .. method:: insert(index, element) -.. method:: Element.getiterator(tag=None) + Inserts a subelement at the given position in this element. - Creates a tree iterator with the current element as the root. The iterator - iterates over this element and all elements below it, in document (depth first) - order. If *tag* is not ``None`` or ``'*'``, only elements whose tag equals - *tag* are returned from the iterator. + .. method:: iter(tag=None) -.. method:: Element.insert(index, element) + Creates a tree :term:`iterator` with the current element as the root. + The iterator iterates over this element and all elements below it, in + document (depth first) order. If *tag* is not ``None`` or ``'*'``, only + elements whose tag equals *tag* are returned from the iterator. If the + tree structure is modified during iteration, the result is undefined. - Inserts a subelement at the given position in this element. + .. method:: iterfind(match) -.. method:: Element.makeelement(tag, attrib) + Finds all matching subelements, by tag name or path. Returns an iterable + yielding all matching elements in document order. - Creates a new element object of the same type as this element. Do not call this - method, use the SubElement factory function instead. + .. versionadded:: 3.2 -.. method:: Element.remove(subelement) + .. method:: itertext() - Removes *subelement* from the element. Unlike the findXYZ methods this method - compares elements based on the instance identity, not on tag value or contents. + Creates a text iterator. The iterator loops over this element and all + subelements, in document order, and returns all inner text. -Element objects also support the following sequence type methods for working -with subelements: :meth:`__delitem__`, :meth:`__getitem__`, :meth:`__setitem__`, -:meth:`__len__`. + .. versionadded:: 3.2 -Caution: Because Element objects do not define a :meth:`__bool__` method, -elements with no subelements will test as ``False``. :: - element = root.find('foo') + .. method:: makeelement(tag, attrib) - if not element: # careful! - print("element not found, or element has no subelements") + Creates a new element object of the same type as this element. Do not + call this method, use the :func:`SubElement` factory function instead. - if element is None: - print("element not found") + + .. method:: remove(subelement) + + Removes *subelement* from the element. Unlike the find\* methods this + method compares elements based on the instance identity, not on tag value + or contents. + + :class:`Element` objects also support the following sequence type methods + for working with subelements: :meth:`__delitem__`, :meth:`__getitem__`, + :meth:`__setitem__`, :meth:`__len__`. + + Caution: Elements with no subelements will test as ``False``. This behavior + will change in future versions. Use specific ``len(elem)`` or ``elem is + None`` test instead. :: + + element = root.find('foo') + + if not element: # careful! + print("element not found, or element has no subelements") + + if element is None: + print("element not found") .. _elementtree-elementtree-objects: @@ -306,70 +384,88 @@ .. class:: ElementTree(element=None, file=None) - ElementTree wrapper class. This class represents an entire element hierarchy, - and adds some extra support for serialization to and from standard XML. + ElementTree wrapper class. This class represents an entire element + hierarchy, and adds some extra support for serialization to and from + standard XML. - *element* is the root element. The tree is initialized with the contents of the - XML *file* if given. + *element* is the root element. The tree is initialized with the contents + of the XML *file* if given. .. method:: _setroot(element) Replaces the root element for this tree. This discards the current contents of the tree, and replaces it with the given element. Use with - care. *element* is an element instance. + care. *element* is an element instance. - .. method:: find(path) + .. method:: find(match) - Finds the first toplevel element with given tag. Same as - getroot().find(path). *path* is the element to look for. Returns the - first matching element, or ``None`` if no element was found. + Finds the first toplevel element matching *match*. *match* may be a tag + name or path. Same as getroot().find(match). Returns the first matching + element, or ``None`` if no element was found. - .. method:: findall(path) + .. method:: findall(match) - Finds all toplevel elements with the given tag. Same as - getroot().findall(path). *path* is the element to look for. Returns a - list or :term:`iterator` containing all matching elements, in document - order. + Finds all matching subelements, by tag name or path. Same as + getroot().findall(match). *match* may be a tag name or path. Returns a + list containing all matching elements, in document order. - .. method:: findtext(path, default=None) + .. method:: findtext(match, default=None) Finds the element text for the first toplevel element with given tag. - Same as getroot().findtext(path). *path* is the toplevel element to look - for. *default* is the value to return if the element was not - found. Returns the text content of the first matching element, or the - default value no element was found. Note that if the element has is - found, but has no text content, this method returns an empty string. + Same as getroot().findtext(match). *match* may be a tag name or path. + *default* is the value to return if the element was not found. Returns + the text content of the first matching element, or the default value no + element was found. Note that if the element is found, but has no text + content, this method returns an empty string. .. method:: getiterator(tag=None) + .. deprecated:: 2.7 + Use method :meth:`ElementTree.iter` instead. + + + .. method:: getroot() + Returns the root element for this tree. + + + .. method:: iter(tag=None) + Creates and returns a tree iterator for the root element. The iterator - loops over all elements in this tree, in section order. *tag* is the tag + loops over all elements in this tree, in section order. *tag* is the tag to look for (default is to return all elements) - .. method:: getroot() + .. method:: iterfind(match) - Returns the root element for this tree. + Finds all matching subelements, by tag name or path. Same as + getroot().iterfind(match). Returns an iterable yielding all matching + elements in document order. + + .. versionadded:: 3.2 .. method:: parse(source, parser=None) - Loads an external XML section into this element tree. *source* is a file - name or file object. *parser* is an optional parser instance. If not - given, the standard XMLTreeBuilder parser is used. Returns the section + Loads an external XML section into this element tree. *source* is a file + name or file object. *parser* is an optional parser instance. If not + given, the standard XMLParser parser is used. Returns the section root element. - .. method:: write(file, encoding=None) + .. method:: write(file, encoding=None, xml_declaration=None, method="xml") - Writes the element tree to a file, as XML. *file* is a file name, or a - file object opened for writing. *encoding* [1]_ is the output encoding - (default is US-ASCII). + Writes the element tree to a file, as XML. *file* is a file name, or a + file object opened for writing. *encoding* [1]_ is the output encoding + (default is None). *xml_declaration* controls if an XML declaration + should be added to the file. Use False for never, True for always, None + for only if not US-ASCII or UTF-8 (default is None). *method* is either + ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). Returns an + (optionally) encoded string. This is the XML file that is going to be manipulated:: @@ -388,13 +484,13 @@ >>> from xml.etree.ElementTree import ElementTree >>> tree = ElementTree() >>> tree.parse("index.xhtml") - + >>> p = tree.find("body/p") # Finds first occurrence of tag p in body >>> p - - >>> links = p.getiterator("a") # Returns list of all links + + >>> links = list(p.iter("a")) # Returns list of all links >>> links - [, ] + [, ] >>> for i in links: # Iterates through all found links ... i.attrib["target"] = "blank" >>> tree.write("output.xhtml") @@ -407,12 +503,12 @@ .. class:: QName(text_or_uri, tag=None) - QName wrapper. This can be used to wrap a QName attribute value, in order to - get proper namespace handling on output. *text_or_uri* is a string containing - the QName value, in the form {uri}local, or, if the tag argument is given, the - URI part of a QName. If *tag* is given, the first argument is interpreted as an - URI, and this argument is interpreted as a local name. :class:`QName` instances - are opaque. + QName wrapper. This can be used to wrap a QName attribute value, in order + to get proper namespace handling on output. *text_or_uri* is a string + containing the QName value, in the form {uri}local, or, if the tag argument + is given, the URI part of a QName. If *tag* is given, the first argument is + interpreted as an URI, and this argument is interpreted as a local name. + :class:`QName` instances are opaque. .. _elementtree-treebuilder-objects: @@ -423,74 +519,89 @@ .. class:: TreeBuilder(element_factory=None) - Generic element structure builder. This builder converts a sequence of start, - data, and end method calls to a well-formed element structure. You can use this - class to build an element structure using a custom XML parser, or a parser for - some other XML-like format. The *element_factory* is called to create new - Element instances when given. + Generic element structure builder. This builder converts a sequence of + start, data, and end method calls to a well-formed element structure. You + can use this class to build an element structure using a custom XML parser, + or a parser for some other XML-like format. The *element_factory* is called + to create new :class:`Element` instances when given. .. method:: close() - Flushes the parser buffers, and returns the toplevel document - element. Returns an Element instance. + Flushes the builder buffers, and returns the toplevel document + element. Returns an :class:`Element` instance. .. method:: data(data) - Adds text to the current element. *data* is a string. This should be - either an ASCII-only :class:`bytes` object or a :class:`str` object. + Adds text to the current element. *data* is a string. This should be + either a bytestring, or a Unicode string. .. method:: end(tag) - Closes the current element. *tag* is the element name. Returns the closed - element. + Closes the current element. *tag* is the element name. Returns the + closed element. .. method:: start(tag, attrs) - Opens a new element. *tag* is the element name. *attrs* is a dictionary - containing element attributes. Returns the opened element. + Opens a new element. *tag* is the element name. *attrs* is a dictionary + containing element attributes. Returns the opened element. + + In addition, a custom :class:`TreeBuilder` object can provide the + following method: -.. _elementtree-xmltreebuilder-objects: + .. method:: doctype(name, pubid, system) + + Handles a doctype declaration. *name* is the doctype name. *pubid* is + the public identifier. *system* is the system identifier. This method + does not exist on the default :class:`TreeBuilder` class. + + .. versionadded:: 3.2 -XMLTreeBuilder Objects ----------------------- +.. _elementtree-xmlparser-objects: -.. class:: XMLTreeBuilder(html=0, target=None) +XMLParser Objects +----------------- - Element structure builder for XML source data, based on the expat parser. *html* - are predefined HTML entities. This flag is not supported by the current - implementation. *target* is the target object. If omitted, the builder uses an - instance of the standard TreeBuilder class. + +.. class:: XMLParser(html=0, target=None, encoding=None) + + :class:`Element` structure builder for XML source data, based on the expat + parser. *html* are predefined HTML entities. This flag is not supported by + the current implementation. *target* is the target object. If omitted, the + builder uses an instance of the standard TreeBuilder class. *encoding* [1]_ + is optional. If given, the value overrides the encoding specified in the + XML file. .. method:: close() - Finishes feeding data to the parser. Returns an element structure. + Finishes feeding data to the parser. Returns an element structure. .. method:: doctype(name, pubid, system) - Handles a doctype declaration. *name* is the doctype name. *pubid* is the - public identifier. *system* is the system identifier. + .. deprecated:: 2.7 + Define the :meth:`TreeBuilder.doctype` method on a custom TreeBuilder + target. .. method:: feed(data) - Feeds data to the parser. *data* is encoded data. + Feeds data to the parser. *data* is encoded data. -:meth:`XMLTreeBuilder.feed` calls *target*\'s :meth:`start` method +:meth:`XMLParser.feed` calls *target*\'s :meth:`start` method for each opening tag, its :meth:`end` method for each closing tag, -and data is processed by method :meth:`data`. :meth:`XMLTreeBuilder.close` +and data is processed by method :meth:`data`. :meth:`XMLParser.close` calls *target*\'s method :meth:`close`. -:class:`XMLTreeBuilder` can be used not only for building a tree structure. +:class:`XMLParser` can be used not only for building a tree structure. This is an example of counting the maximum depth of an XML file:: - >>> from xml.etree.ElementTree import XMLTreeBuilder + >>> from xml.etree.ElementTree import XMLParser >>> class MaxDepth: # The target object of the parser ... maxDepth = 0 ... depth = 0 @@ -506,7 +617,7 @@ ... return self.maxDepth ... >>> target = MaxDepth() - >>> parser = XMLTreeBuilder(target=target) + >>> parser = XMLParser(target=target) >>> exampleXml = """ ... ... @@ -526,7 +637,6 @@ .. rubric:: Footnotes .. [#] The encoding string included in XML output should conform to the - appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + appropriate standards. For example, "UTF-8" is valid, but "UTF8" is + not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl and http://www.iana.org/assignments/character-sets. - Deleted: python/branches/py3k-cdecimal/Doc/library/xml.etree.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/xml.etree.rst Thu Apr 1 11:38:52 2010 +++ (empty file) @@ -1,23 +0,0 @@ -:mod:`xml.etree` --- The ElementTree API for XML -================================================ - -.. module:: xml.etree - :synopsis: Package containing common ElementTree modules. -.. moduleauthor:: Fredrik Lundh - - -The ElementTree package is a simple, efficient, and quite popular library for -XML manipulation in Python. The :mod:`xml.etree` package contains the most -common components from the ElementTree API library. In the current release, -this package contains the :mod:`ElementTree`, :mod:`ElementPath`, and -:mod:`ElementInclude` modules from the full ElementTree distribution. - -.. XXX To be continued! - - -.. seealso:: - - `ElementTree Overview `_ - The home page for :mod:`ElementTree`. This includes links to additional - documentation, alternative implementations, and other add-ons. - Modified: python/branches/py3k-cdecimal/Doc/library/zipfile.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/zipfile.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/zipfile.rst Thu Apr 1 11:38:52 2010 @@ -288,7 +288,7 @@ member of the given :class:`ZipInfo` instance. By default, the :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`. - .. versionchanged:: 2.7 + .. versionchanged:: 3.2 The *compression_type* argument. The following data attributes are also available: Modified: python/branches/py3k-cdecimal/Doc/library/zlib.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/library/zlib.rst (original) +++ python/branches/py3k-cdecimal/Doc/library/zlib.rst Thu Apr 1 11:38:52 2010 @@ -96,14 +96,18 @@ Decompresses the data in *string*, returning a string containing the uncompressed data. The *wbits* parameter controls the size of the window - buffer. If *bufsize* is given, it is used as the initial size of the output + buffer, and is discussed further below. + If *bufsize* is given, it is used as the initial size of the output buffer. Raises the :exc:`error` exception if any error occurs. The absolute value of *wbits* is the base two logarithm of the size of the history buffer (the "window size") used when compressing data. Its absolute value should be between 8 and 15 for the most recent versions of the zlib library, larger values resulting in better compression at the expense of greater - memory usage. The default value is 15. When *wbits* is negative, the standard + memory usage. When decompressing a stream, *wbits* must not be smaller + than the size originally used to compress the stream; using a too-small + value will result in an exception. The default value is therefore the + highest value, 15. When *wbits* is negative, the standard :program:`gzip` header is suppressed; this is an undocumented feature of the zlib library, used for compatibility with :program:`unzip`'s compression file format. Modified: python/branches/py3k-cdecimal/Doc/make.bat ============================================================================== --- python/branches/py3k-cdecimal/Doc/make.bat (original) +++ python/branches/py3k-cdecimal/Doc/make.bat Thu Apr 1 11:38:52 2010 @@ -34,10 +34,10 @@ goto end :checkout -svn co %SVNROOT%/external/Sphinx-0.6.3/sphinx tools/sphinx -svn co %SVNROOT%/external/docutils-0.5/docutils tools/docutils -svn co %SVNROOT%/external/Jinja-2.1.1/jinja2 tools/jinja2 -svn co %SVNROOT%/external/Pygments-1.1.1/pygments tools/pygments +svn co %SVNROOT%/external/Sphinx-0.6.5/sphinx tools/sphinx +svn co %SVNROOT%/external/docutils-0.6/docutils tools/docutils +svn co %SVNROOT%/external/Jinja-2.3.1/jinja2 tools/jinja2 +svn co %SVNROOT%/external/Pygments-1.3.1/pygments tools/pygments goto end :update Modified: python/branches/py3k-cdecimal/Doc/reference/executionmodel.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/reference/executionmodel.rst (original) +++ python/branches/py3k-cdecimal/Doc/reference/executionmodel.rst Thu Apr 1 11:38:52 2010 @@ -120,7 +120,7 @@ .. index:: pair: restricted; execution -The built-in namespace associated with the execution of a code block is actually +The builtins namespace associated with the execution of a code block is actually found by looking up the name ``__builtins__`` in its global namespace; this should be a dictionary or a module (in the latter case the module's dictionary is used). By default, when in the :mod:`__main__` module, ``__builtins__`` is @@ -132,7 +132,7 @@ .. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation - detail. Users wanting to override values in the built-in namespace should + detail. Users wanting to override values in the builtins namespace should :keyword:`import` the :mod:`builtins` module and modify its attributes appropriately. Modified: python/branches/py3k-cdecimal/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/reference/expressions.rst (original) +++ python/branches/py3k-cdecimal/Doc/reference/expressions.rst Thu Apr 1 11:38:52 2010 @@ -1113,12 +1113,7 @@ pair: Conditional; expression pair: Boolean; operation -Boolean operations have the lowest priority of all Python operations: - .. productionlist:: - expression: `conditional_expression` | `lambda_form` - expression_nocond: `or_test` | `lambda_form_nocond` - conditional_expression: `or_test` ["if" `or_test` "else" `expression`] or_test: `and_test` | `or_test` "or" `and_test` and_test: `not_test` | `and_test` "and" `not_test` not_test: `comparison` | "not" `not_test` @@ -1135,10 +1130,6 @@ The operator :keyword:`not` yields ``True`` if its argument is false, ``False`` otherwise. -The expression ``x if C else y`` first evaluates *C* (*not* *x*); if *C* is -true, *x* is evaluated and its value is returned; otherwise, *y* is evaluated -and its value is returned. - .. index:: operator: and The expression ``x and y`` first evaluates *x*; if *x* is false, its value is @@ -1158,6 +1149,28 @@ 'foo'`` yields ``False``, not ``''``.) +Conditional Expressions +======================= + +.. index:: + pair: conditional; expression + pair: ternary; operator + +.. productionlist:: + conditional_expression: `or_test` ["if" `or_test` "else" `expression`] + expression: `conditional_expression` | `lambda_form` + expression_nocond: `or_test` | `lambda_form_nocond` + +Conditional expressions (sometimes called a "ternary operator") have the lowest +priority of all Python operations. + +The expression ``x if C else y`` first evaluates the condition, *C* (*not* *x*); +if *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is +evaluated and its value is returned. + +See :pep:`308` for more details about conditional expressions. + + .. _lambdas: .. _lambda: @@ -1252,6 +1265,8 @@ +===============================================+=====================================+ | :keyword:`lambda` | Lambda expression | +-----------------------------------------------+-------------------------------------+ +| :keyword:`if` -- :keyword:`else` | Conditional expression | ++-----------------------------------------------+-------------------------------------+ | :keyword:`or` | Boolean OR | +-----------------------------------------------+-------------------------------------+ | :keyword:`and` | Boolean AND | Modified: python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst (original) +++ python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst Thu Apr 1 11:38:52 2010 @@ -503,7 +503,7 @@ As in Standard C, up to three octal digits are accepted. (2) - Unlike in Standard C, at most two hex digits are accepted. + Unlike in Standard C, exactly two hex digits are required. (3) In a bytes literal, hexadecimal and octal escapes denote the byte with the Modified: python/branches/py3k-cdecimal/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/reference/simple_stmts.rst (original) +++ python/branches/py3k-cdecimal/Doc/reference/simple_stmts.rst Thu Apr 1 11:38:52 2010 @@ -146,16 +146,12 @@ * Otherwise: the name is bound to the object in the global namespace or the outer namespace determined by :keyword:`nonlocal`, respectively. + .. index:: single: destructor + The name is rebound if it was already bound. This may cause the reference count for the object previously bound to the name to reach zero, causing the object to be deallocated and its destructor (if it has one) to be called. - .. index:: single: destructor - - The name is rebound if it was already bound. This may cause the reference count - for the object previously bound to the name to reach zero, causing the object to - be deallocated and its destructor (if it has one) to be called. - * If the target is a target list enclosed in parentheses or in square brackets: The object must be an iterable with the same number of items as there are targets in the target list, and its items are assigned, from left to right, Modified: python/branches/py3k-cdecimal/Doc/tools/rstlint.py ============================================================================== --- python/branches/py3k-cdecimal/Doc/tools/rstlint.py (original) +++ python/branches/py3k-cdecimal/Doc/tools/rstlint.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Check for stylistic and formal issues in .rst and .py @@ -169,7 +169,6 @@ return 2 count = defaultdict(int) - out = sys.stdout for root, dirs, files in os.walk(path): # ignore subdirs controlled by svn @@ -212,8 +211,7 @@ csev = checker.severity if csev >= severity: for lno, msg in checker(fn, lines): - print('[%d] %s:%d: %s' % (csev, fn, lno, msg), - file=out) + print('[%d] %s:%d: %s' % (csev, fn, lno, msg)) count[csev] += 1 if verbose: print() Modified: python/branches/py3k-cdecimal/Doc/tools/sphinxext/download.html ============================================================================== --- python/branches/py3k-cdecimal/Doc/tools/sphinxext/download.html (original) +++ python/branches/py3k-cdecimal/Doc/tools/sphinxext/download.html Thu Apr 1 11:38:52 2010 @@ -1,15 +1,14 @@ {% extends "layout.html" %} {% set title = 'Download' %} -{% set dlbase = 'http://docs.python.org/ftp/python/doc/' + release %} -{% block body %} +{% if daily is defined %} + {% set dlbase = pathto('archives', 1) %} +{% else %} + {% set dlbase = 'http://docs.python.org/ftp/python/doc/' + release %} +{% endif %} +{% block body %}

Download Python {{ release }} Documentation

-{% if 'a' in release or 'b' in release or 'c' in release %} -

We don't package the documentation for development releases for download. - Downloads will be available for the final release.

- -{% else %} {% if last_updated %}

Last updated on: {{ last_updated }}.

{% endif %}

To download an archive containing all the documents for this version of @@ -55,6 +54,4 @@

If you have comments or suggestions for the Python documentation, please send email to docs at python.org.

-{% endif %} - {% endblock %} Modified: python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst (original) +++ python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst Thu Apr 1 11:38:52 2010 @@ -137,21 +137,25 @@ .. sectionauthor:: Ka-Ping Yee +It is also possible to use a list as a queue, where the first element added is +the first element retrieved ("first-in, first-out"); however, lists are not +efficient for this purpose. While appends and pops from the end of list are +fast, doing inserts or pops from the beginning of a list is slow (because all +of the other elements have to be shifted by one). -You can also use a list conveniently as a queue, where the first element added -is the first element retrieved ("first-in, first-out"). To add an item to the -back of the queue, use :meth:`append`. To retrieve an item from the front of -the queue, use :meth:`pop` with ``0`` as the index. For example:: +To implement a queue, use :class:`collections.deque` which was designed to +have fast appends and pops from both ends. For example:: - >>> queue = ["Eric", "John", "Michael"] + >>> from collections import deque + >>> queue = deque(["Eric", "John", "Michael"]) >>> queue.append("Terry") # Terry arrives >>> queue.append("Graham") # Graham arrives - >>> queue.pop(0) + >>> queue.popleft() # The first to arrive now leaves 'Eric' - >>> queue.pop(0) + >>> queue.popleft() # The second to arrive now leaves 'John' - >>> queue - ['Michael', 'Terry', 'Graham'] + >>> queue # Remaining queue in order of arrival + deque(['Michael', 'Terry', 'Graham']) .. _tut-listcomps: Modified: python/branches/py3k-cdecimal/Doc/tutorial/introduction.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/tutorial/introduction.rst (original) +++ python/branches/py3k-cdecimal/Doc/tutorial/introduction.rst Thu Apr 1 11:38:52 2010 @@ -482,6 +482,12 @@ >>> 3*a[:3] + ['Boo!'] ['spam', 'eggs', 100, 'spam', 'eggs', 100, 'spam', 'eggs', 100, 'Boo!'] +All slice operations return a new list containing the requested elements. This +means that the following slice returns a shallow copy of the list *a*:: + + >>> a[:] + ['spam', 'eggs', 100, 1234] + Unlike strings, which are *immutable*, it is possible to change individual elements of a list:: Modified: python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst (original) +++ python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst Thu Apr 1 11:38:52 2010 @@ -72,7 +72,7 @@ The :mod:`getopt` module processes *sys.argv* using the conventions of the Unix :func:`getopt` function. More powerful and flexible command line processing is -provided by the :mod:`optparse` module. +provided by the :mod:`argparse` module. .. _tut-stderr: @@ -152,6 +152,7 @@ >>> from urllib.request import urlopen >>> for line in urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'): + ... line = line.decode('utf-8') # Decoding the binary data to text. ... if 'EST' in line or 'EDT' in line: # look for Eastern Time ... print(line) Modified: python/branches/py3k-cdecimal/Doc/using/mac.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/using/mac.rst (original) +++ python/branches/py3k-cdecimal/Doc/using/mac.rst Thu Apr 1 11:38:52 2010 @@ -143,7 +143,7 @@ the foundation of most modern Mac development. Information on PyObjC is available from http://pyobjc.sourceforge.net. -The standard Python GUI toolkit is :mod:`Tkinter`, based on the cross-platform +The standard Python GUI toolkit is :mod:`tkinter`, based on the cross-platform Tk toolkit (http://www.tcl.tk). An Aqua-native version of Tk is bundled with OS X by Apple, and the latest version can be downloaded and installed from http://www.activestate.com; it can also be built from source. Modified: python/branches/py3k-cdecimal/Doc/whatsnew/2.2.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/whatsnew/2.2.rst (original) +++ python/branches/py3k-cdecimal/Doc/whatsnew/2.2.rst Thu Apr 1 11:38:52 2010 @@ -30,7 +30,7 @@ to the PEP for a particular new feature. -.. seealso (now defunct) +.. see also, now defunct http://www.unixreview.com/documents/s=1356/urm0109h/0109h.htm "What's So Special About Python 2.2?" is also about the new 2.2 features, and Modified: python/branches/py3k-cdecimal/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k-cdecimal/Doc/whatsnew/2.6.rst Thu Apr 1 11:38:52 2010 @@ -111,9 +111,9 @@ :func:`reduce` function. Python 3.0 adds several new built-in functions and changes the -semantics of some existing built-ins. Functions that are new in 3.0 +semantics of some existing builtins. Functions that are new in 3.0 such as :func:`bin` have simply been added to Python 2.6, but existing -built-ins haven't been changed; instead, the :mod:`future_builtins` +builtins haven't been changed; instead, the :mod:`future_builtins` module has versions with the new 3.0 semantics. Code written to be compatible with 3.0 can do ``from future_builtins import hex, map`` as necessary. @@ -350,9 +350,10 @@ * The code in *BLOCK* is executed. -* If *BLOCK* raises an exception, the :meth:`__exit__(type, value, traceback)` - is called with the exception details, the same values returned by - :func:`sys.exc_info`. The method's return value controls whether the exception +* If *BLOCK* raises an exception, the context manager's :meth:`__exit__` method + is called with three arguments, the exception details (``type, value, traceback``, + the same values returned by :func:`sys.exc_info`, which can also be ``None`` + if no exception occurred). The method's return value controls whether an exception is re-raised: any false value re-raises the exception, and ``True`` will result in suppressing it. You'll only rarely want to suppress the exception, because if you do the author of the code containing the ':keyword:`with`' statement will @@ -463,7 +464,7 @@ with db_transaction(db) as cursor: ... -The :mod:`contextlib` module also has a :func:`nested(mgr1, mgr2, ...)` function +The :mod:`contextlib` module also has a ``nested(mgr1, mgr2, ...)`` function that combines a number of context managers so you don't need to write nested ':keyword:`with`' statements. In this example, the single ':keyword:`with`' statement both starts a database transaction and acquires a thread lock:: @@ -472,8 +473,9 @@ with nested (db_transaction(db), lock) as (cursor, locked): ... -Finally, the :func:`closing(object)` function returns *object* so that it can be -bound to a variable, and calls ``object.close`` at the end of the block. :: +Finally, the :func:`closing` function returns its argument so that it can be +bound to a variable, and calls the argument's ``.close()`` method at the end +of the block. :: import urllib, sys from contextlib import closing @@ -835,7 +837,7 @@ else: return str(self) -There's also a :func:`format` built-in that will format a single +There's also a :func:`format` builtin that will format a single value. It calls the type's :meth:`__format__` method with the provided specifier:: @@ -1166,7 +1168,7 @@ feature for Python. The ABC support consists of an :mod:`abc` module containing a metaclass called :class:`ABCMeta`, special handling of this metaclass by the :func:`isinstance` and :func:`issubclass` -built-ins, and a collection of basic ABCs that the Python developers +builtins, and a collection of basic ABCs that the Python developers think will be widely useful. Future versions of Python will probably add more ABCs. @@ -1320,9 +1322,9 @@ >>> 0b101111 47 -The :func:`oct` built-in still returns numbers +The :func:`oct` builtin still returns numbers prefixed with a leading zero, and a new :func:`bin` -built-in returns the binary representation for a number:: +builtin returns the binary representation for a number:: >>> oct(42) '052' @@ -1331,7 +1333,7 @@ >>> bin(173) '0b10101101' -The :func:`int` and :func:`long` built-ins will now accept the "0o" +The :func:`int` and :func:`long` builtins will now accept the "0o" and "0b" prefixes when base-8 or base-2 are requested, or when the *base* argument is zero (signalling that the base used should be determined from the string):: @@ -1417,7 +1419,7 @@ combined using bitwise operations such as ``&`` and ``|``, and can be used as array indexes and slice boundaries. -In Python 3.0, the PEP slightly redefines the existing built-ins +In Python 3.0, the PEP slightly redefines the existing builtins :func:`round`, :func:`math.floor`, :func:`math.ceil`, and adds a new one, :func:`math.trunc`, that's been backported to Python 2.6. :func:`math.trunc` rounds toward zero, returning the closest @@ -1483,6 +1485,13 @@ Some smaller changes made to the core Python language are: +* Directories and zip archives containing a :file:`__main__.py` file + can now be executed directly by passing their name to the + interpreter. The directory or zip archive is automatically inserted + as the first entry in sys.path. (Suggestion and initial patch by + Andy Chu, subsequently revised by Phillip J. Eby and Nick Coghlan; + :issue:`1739468`.) + * The :func:`hasattr` function was catching and ignoring all errors, under the assumption that they meant a :meth:`__getattr__` method was failing somehow and the return value of :func:`hasattr` would @@ -1518,7 +1527,7 @@ Previously this would have been a syntax error. (Contributed by Amaury Forgeot d'Arc; :issue:`3473`.) -* A new built-in, ``next(iterator, [default])`` returns the next item +* A new builtin, ``next(iterator, [default])`` returns the next item from the specified iterator. If the *default* argument is supplied, it will be returned if *iterator* has been exhausted; otherwise, the :exc:`StopIteration` exception will be raised. (Backported @@ -1947,9 +1956,9 @@ (Contributed by Phil Schwartz; :issue:`1221598`.) * The :func:`reduce` built-in function is also available in the - :mod:`functools` module. In Python 3.0, the built-in has been + :mod:`functools` module. In Python 3.0, the builtin has been dropped and :func:`reduce` is only available from :mod:`functools`; - currently there are no plans to drop the built-in in the 2.x series. + currently there are no plans to drop the builtin in the 2.x series. (Patched by Christian Heimes; :issue:`1739906`.) * When possible, the :mod:`getpass` module will now use @@ -2751,7 +2760,7 @@ * ``filter(predicate, iterable)``, ``map(func, iterable1, ...)``: the 3.0 versions - return iterators, unlike the 2.x built-ins which return lists. + return iterators, unlike the 2.x builtins which return lists. * ``hex(value)``, ``oct(value)``: instead of calling the :meth:`__hex__` or :meth:`__oct__` methods, these versions will Modified: python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst (original) +++ python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst Thu Apr 1 11:38:52 2010 @@ -222,11 +222,70 @@ :pep:`378` - Format Specifier for Thousands Separator PEP written by Raymond Hettinger; implemented by Eric Smith. +PEP 389: The argparse Module for Parsing Command Lines +====================================================== + +XXX write this section. + +.. seealso:: + + :pep:`389` - argparse - New Command Line Parsing Module + PEP written and implemented by Steven Bethard. + +PEP 391: Dictionary-Based Configuration For Logging +==================================================== + +XXX write this section. + +.. seealso:: + + :pep:`391` - Dictionary-Based Configuration For Logging + PEP written and implemented by Vinay Sajip. + +PEP 3106: Dictionary Views +==================================================== + +XXX write this section. + +.. seealso:: + + :pep:`3106` - Revamping dict.keys(), .values() and .items() + PEP written by Guido van Rossum. + Backported to 2.7 by Alexandre Vassalotti; :issue:`1967`. + + Other Language Changes ====================== Some smaller changes made to the core Python language are: +* The syntax for set literals has been backported from Python 3.x. + Curly brackets are used to surround the contents of the resulting + mutable set; set literals are + distinguished from dictionaries by not containing colons and values. + ``{}`` continues to represent an empty dictionary; use + ``set()`` for an empty set. + + >>> {1,2,3,4,5} + set([1, 2, 3, 4, 5]) + >>> set() + set([]) + >>> {} + {} + + Backported by Alexandre Vassalotti; :issue:`2335`. + +* Dictionary and set comprehensions are another feature backported from + 3.x, generalizing list/generator comprehensions to use + the literal syntax for sets and dictionaries. + + >>> {x:x*x for x in range(6)} + {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25} + >>> {'a'*x for x in range(6)} + set(['', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa']) + + Backported by Alexandre Vassalotti; :issue:`2333`. + * The :keyword:`with` statement can now use multiple context managers in one statement. Context managers are processed from left to right and each one is treated as beginning a new :keyword:`with` statement. @@ -363,7 +422,10 @@ * The :class:`file` object will now set the :attr:`filename` attribute on the :exc:`IOError` exception when trying to open a directory - on POSIX platforms. (Noted by Jan Kaliszewski; :issue:`4764`.) + on POSIX platforms (noted by Jan Kaliszewski; :issue:`4764`), and + now explicitly checks for and forbids writing to read-only file objects + instead of trusting the C library to catch and report the error + (fixed by Stefan Krah; :issue:`5677`). * The Python tokenizer now translates line endings itself, so the :func:`compile` built-in function can now accept code using any @@ -375,6 +437,10 @@ Python3-warning mode, Python 2.7 will now warn about this odd usage. (Noted by James Lingard; :issue:`7362`.) +* When a module object is garbage-collected, the module's dictionary is + now only cleared if no one else is holding a reference to the + dictionary (:issue:`7140`). + .. ====================================================================== @@ -498,6 +564,10 @@ (Contributed by Maru Newby after a suggestion by Senthil Kumaran; :issue:`5142`.) +* The :mod:`binascii` module now supports the buffer API, so it can be + used with :class:`memoryview` instances and other similar buffer objects. + (Backported from 3.x by Florent Xicluna; :issue:`7703`.) + * The :mod:`bz2` module's :class:`BZ2File` now supports the context management protocol, so you can write ``with bz2.BZ2File(...) as f: ...``. (Contributed by Hagen Fuerstenau; :issue:`3860`.) @@ -539,7 +609,7 @@ Contributed by Raymond Hettinger; :issue:`1696199`. - The new `OrderedDict` class is described in the earlier section + The new `~collections.OrderedDict` class is described in the earlier section :ref:`pep-0372`. The :class:`namedtuple` class now has an optional *rename* parameter. @@ -566,7 +636,10 @@ * The :mod:`ctypes` module now always converts ``None`` to a C NULL pointer for arguments declared as pointers. (Changed by Thomas - Heller; :issue:`4606`.) + Heller; :issue:`4606`.) The underlying `libffi library + `__ has been updated to version + 3.0.9, containing various fixes for different platforms. (Updated + by Matthias Klose; :issue:`8142`.) * New method: the :mod:`datetime` module's :class:`timedelta` class gained a :meth:`total_seconds` method that returns the number of seconds @@ -592,46 +665,6 @@ left-alignment. This has been changed to right-alignment, which seems more sensible for numeric types. (Changed by Mark Dickinson; :issue:`6857`.) -* Distutils is being more actively developed, thanks to Tarek Ziad?? - who has taken over maintenance of the package, so there are a number - of fixes and improvments. - - A new :file:`setup.py` subcommand, ``check``, will check that the - arguments being passed to the :func:`setup` function are complete - and correct (:issue:`5732`). - - Byte-compilation by the ``install_lib`` subcommand is now only done - if the ``sys.dont_write_bytecode`` setting allows it (:issue:`7071`). - - :func:`distutils.sdist.add_defaults` now uses - *package_dir* and *data_files* to create the MANIFEST file. - :mod:`distutils.sysconfig` now reads the :envvar:`AR` and - :envvar:`ARFLAGS` environment variables. - - .. ARFLAGS done in #5941 - - It is no longer mandatory to store clear-text passwords in the - :file:`.pypirc` file when registering and uploading packages to PyPI. As long - as the username is present in that file, the :mod:`distutils` package will - prompt for the password if not present. (Added by Tarek Ziad??, - based on an initial contribution by Nathan Van Gheem; :issue:`4394`.) - - A Distutils setup can now specify that a C extension is optional by - setting the *optional* option setting to true. If this optional is - supplied, failure to build the extension will not abort the build - process, but instead simply not install the failing extension. - (Contributed by Georg Brandl; :issue:`5583`.) - - The :class:`distutils.dist.DistributionMetadata` class' - :meth:`read_pkg_file` method will read the contents of a package's - :file:`PKG-INFO` metadata file. For an example of its use, see - :ref:`reading-metadata`. - (Contributed by Tarek Ziad??; :issue:`7457`.) - - :file:`setup.py` files will now accept a :option:`--no-user-cfg` switch - to skip reading the :file:`~/.pydistutils.cfg` file. (Suggested by - by Michael Hoffman, and implemented by Paul Winkler; :issue:`1180`.) - * The :class:`Fraction` class now accepts two rational numbers as arguments to its constructor. (Implemented by Mark Dickinson; :issue:`5812`.) @@ -649,9 +682,12 @@ otherwise. (Contributed by Antoine Pitrou; :issue:`4688`.) * The :mod:`gzip` module's :class:`GzipFile` now supports the context - management protocol, so you can write ``with gzip.GzipFile(...) as f: ...``. - (Contributed by Hagen Fuerstenau; :issue:`3860`.) - It's now possible to override the modification time + management protocol, so you can write ``with gzip.GzipFile(...) as f: ...`` + (contributed by Hagen Fuerstenau; :issue:`3860`), and it now implements + the :class:`io.BufferedIOBase` ABC, so you can wrap it with + :class:`io.BufferedReader` for faster processing + (contributed by Nir Aides; :issue:`7471`). + It's also now possible to override the modification time recorded in a gzipped file by providing an optional timestamp to the constructor. (Contributed by Jacques Frechet; :issue:`4272`.) @@ -663,6 +699,11 @@ supports buffering, resulting in much faster reading of HTTP responses. (Contributed by Kristjan Valur Jonsson; :issue:`4879`.) + The :class:`HTTPConnection` and :class:`HTTPSConnection` classes + now support a *source_address* parameter, a ``(host, port)`` 2-tuple + giving the source address that will be used for the connection. + (Contributed by Eldon Ziegler; :issue:`3972`.) + * The :mod:`imaplib` module now supports IPv6 addresses. (Contributed by Derek Morr; :issue:`1655`.) @@ -756,6 +797,10 @@ contributed by Travis H.; :issue:`6508`. Support for initgroups added by Jean-Paul Calderone; :issue:`7333`.) + The :func:`os.fork` function now re-initializes the import lock in + the child process; this fixes problems on Solaris when :func:`fork` + is called from a thread. (Fixed by Zsolt Cserna; :issue:`7242`.) + The :func:`normpath` function now preserves Unicode; if its input path is a Unicode string, the return value is also a Unicode string. (Fixed by Matt Giuca; :issue:`5827`.) @@ -774,6 +819,10 @@ named pipes like a regular file by opening them for reading, and this would block indefinitely. (Fixed by Antoine Pitrou; :issue:`3002`.) + New function: :func:`make_archive` takes a filename, archive type + (zip or tar-format), and a directory path, and creates an archive + containing the directory's contents. (Added by Tarek Ziad??.) + * New functions: in the :mod:`site` module, three new functions return various site- and user-specific paths. :func:`getsitepackages` returns a list containing all @@ -785,9 +834,24 @@ to store data. (Contributed by Tarek Ziad??; :issue:`6693`.) + The :mod:`site` module now reports exceptions occurring + when the :mod:`sitecustomize` module is imported, and will no longer + catch and swallow the :exc:`KeyboardError` exception. (Fixed by + Victor Stinner; :issue:`3137`.) + * The :mod:`socket` module's :class:`SSL` objects now support the - buffer API, which fixed a test suite failure. (Fixed by Antoine Pitrou; - :issue:`7133`.) + buffer API, which fixed a test suite failure. (Fixed by Antoine + Pitrou; :issue:`7133`.) + + The :func:`create_connection` function + gained a *source_address* parameter, a ``(host, port)`` 2-tuple + giving the source address that will be used for the connection. + (Contributed by Eldon Ziegler; :issue:`3972`.) + + The :meth:`recv_into` and `recvfrom_into` methods will now write + into objects that support the buffer API, most usefully + the :class:`bytearray` and :class:`memoryview` objects. (Implemented by + Antoine Pitrou; :issue:`8104`.) * The :mod:`SocketServer` module's :class:`TCPServer` class now has a :attr:`disable_nagle_algorithm` class attribute. @@ -796,6 +860,13 @@ prevent buffering many small sends into a single TCP packet. (Contributed by Kristjan Valur Jonsson; :issue:`6192`.) +* Updated module: the :mod:`sqlite` module has been updated to + version 2.6.0 of the `pysqlite package `__. Version 2.6.0 includes a number of bugfixes, and adds + the ability to load SQLite extensions from shared libraries. + Call the ``enable_load_extension(True)`` method to enable extensions, + and then call :meth:`load_extension` to load a particular shared library. + (Updated by Gerhard H??ring.) + * The :mod:`struct` module will no longer silently ignore overflow errors when a value is too large for a particular integer format code (one of ``bBhHiIlLqQ``); it now always raises a @@ -830,8 +901,8 @@ Light; :issue:`4285`.) :func:`sys.getwindowsversion` also returns a named tuple, - with attributes named :attr:`major`, :attr:`minor`, :attr:`build`, - :attr:`platform`:, :attr:`service_pack`, :attr:`service_pack_major`, + with attributes named :attr:`major`, :attr:`minor`, :attr:`build`, + :attr:`platform`, :attr:`service_pack`, :attr:`service_pack_major`, :attr:`service_pack_minor`, :attr:`suite_mask`, and :attr:`product_type`. (Contributed by Brian Curtin; :issue:`7766`.) @@ -852,6 +923,8 @@ resulting archive. This is more powerful than the existing *exclude* argument, which has therefore been deprecated. (Added by Lars Gust??bel; :issue:`6856`.) + The :class:`TarFile` class also now supports the context manager protocol. + (Added by Lars Gust??bel; :issue:`7232`.) * The :mod:`threading` module's :meth:`Event.wait` method now returns the internal flag on exit. This means the method will usually @@ -860,9 +933,24 @@ a timeout was provided and the operation timed out. (Contributed by Tim Lesher; :issue:`1674032`.) +* The Unicode database has been updated to the version 5.2.0. + (Updated by Florent Xicluna; :issue:`8024`.) + +* The Unicode database provided by the :mod:`unicodedata` is used + internally to determine which characters are numeric, whitespace, + or represent line breaks. The database also now includes information + from the :file:`Unihan.txt` data file. (Patch by Anders Chrigstr??m + and Amaury Forgeot d'Arc; :issue:`1571184`.) + * The :class:`UserDict` class is now a new-style class. (Changed by Benjamin Peterson.) +* The ElementTree library, :mod:`xml.etree`, no longer escapes + ampersands and angle brackets when outputting an XML processing + instruction (which looks like ``) + or comment (which looks like ``). + (Patch by Neil Muller; :issue:`2746`.) + * The :mod:`zipfile` module's :class:`ZipFile` now supports the context management protocol, so you can write ``with zipfile.ZipFile(...) as f: ...``. (Contributed by Brian Curtin; :issue:`5511`.) @@ -877,15 +965,81 @@ accepts a file object, in addition to the path names accepted in earlier versions. (Contributed by Gabriel Genellina; :issue:`4756`.) + The :meth:`writestr` method now has an optional *compress_type* parameter + that lets you override the default compression method specified in the + :class:`ZipFile` constructor. (Contributed by Ronald Oussoren; + :issue:`6003`.) + +* XXX the :mod:`shutil` module has now a :func:`make_archive` function + (see the module doc, contributed by Tarek) + + +New module: sysconfig +--------------------------------- + +XXX A new :mod:`sysconfig` module has been extracted from +:mod:`distutils` and put in the standard library. + +The :mod:`sysconfig` module provides access to Python's configuration +information like the list of installation paths and the configuration +variables relevant for the current platform. (contributed by Tarek) + +Updated module: ElementTree 1.3 +--------------------------------- + +XXX write this. + .. ====================================================================== .. whole new modules get described in subsections here -* XXX A new :mod:`sysconfig` module has been extracted from :mod:`distutils` - and put in the standard library. - The :mod:`sysconfig` module provides access to Python's configuration - information like the list of installation paths and the configuration - variables relevant for the current platform. +Distutils Enhancements +--------------------------------- + +Distutils is being more actively developed, thanks to Tarek Ziad?? +who has taken over maintenance of the package, so there are a number +of fixes and improvements. + +A new :file:`setup.py` subcommand, ``check``, will check that the +arguments being passed to the :func:`setup` function are complete +and correct (:issue:`5732`). + +Byte-compilation by the ``install_lib`` subcommand is now only done +if the ``sys.dont_write_bytecode`` setting allows it (:issue:`7071`). + +:func:`distutils.sdist.add_defaults` now uses +*package_dir* and *data_files* to create the MANIFEST file. +:mod:`distutils.sysconfig` now reads the :envvar:`AR` and +:envvar:`ARFLAGS` environment variables. + +.. ARFLAGS done in #5941 + +It is no longer mandatory to store clear-text passwords in the +:file:`.pypirc` file when registering and uploading packages to PyPI. As long +as the username is present in that file, the :mod:`distutils` package will +prompt for the password if not present. (Added by Tarek Ziad??, +based on an initial contribution by Nathan Van Gheem; :issue:`4394`.) + +A Distutils setup can now specify that a C extension is optional by +setting the *optional* option setting to true. If this optional is +supplied, failure to build the extension will not abort the build +process, but instead simply not install the failing extension. +(Contributed by Georg Brandl; :issue:`5583`.) + +The :class:`distutils.dist.DistributionMetadata` class' +:meth:`read_pkg_file` method will read the contents of a package's +:file:`PKG-INFO` metadata file. For an example of its use, see +:ref:`reading-metadata`. +(Contributed by Tarek Ziad??; :issue:`7457`.) + +:file:`setup.py` files will now accept a :option:`--no-user-cfg` switch +to skip reading the :file:`~/.pydistutils.cfg` file. (Suggested by +by Michael Hoffman, and implemented by Paul Winkler; :issue:`1180`.) + +When creating a tar-format archive, the ``sdist`` subcommand now +allows specifying the user id and group that will own the files in the +archives using the :option:`--owner` and :option:`--group` switches +(:issue:`6516`). Unit Testing Enhancements @@ -945,7 +1099,8 @@ * :meth:`assertMultiLineEqual` compares two strings, and if they're not equal, displays a helpful comparison that highlights the - differences in the two strings. + differences in the two strings. This comparison is now used by + default when Unicode strings are compared with :meth:`assertEqual`.) * :meth:`assertRegexpMatches` checks whether its first argument is a string matching a regular expression provided as its second argument. @@ -957,25 +1112,29 @@ * :meth:`assertIn` and :meth:`assertNotIn` tests whether *first* is or is not in *second*. -* :meth:`assertSameElements` tests whether two provided sequences +* :meth:`assertItemsEqual` tests whether two provided sequences contain the same elements. * :meth:`assertSetEqual` compares whether two sets are equal, and only reports the differences between the sets in case of error. * Similarly, :meth:`assertListEqual` and :meth:`assertTupleEqual` - compare the specified types and explain the differences. + compare the specified types and explain any differences without necessarily + printing their full values; these methods are now used by default + when comparing lists and tuples using :meth:`assertEqual`. More generally, :meth:`assertSequenceEqual` compares two sequences and can optionally check whether both sequences are of a particular type. * :meth:`assertDictEqual` compares two dictionaries and reports the - differences. :meth:`assertDictContainsSubset` checks whether + differences; it's now used by default when you compare two dictionaries + using :meth:`assertEqual`. :meth:`assertDictContainsSubset` checks whether all of the key/value pairs in *first* are found in *second*. -* :meth:`assertAlmostEqual` and :meth:`assertNotAlmostEqual` short-circuit - (automatically pass or fail without checking decimal places) if the objects - are equal. +* :meth:`assertAlmostEqual` and :meth:`assertNotAlmostEqual` test + whether *first* and *second* are approximately equal by computing + their difference, rounding the result to an optionally-specified number + of *places* (the default is 7), and comparing to zero. * :meth:`loadTestsFromName` properly honors the ``suiteClass`` attribute of the :class:`TestLoader`. (Fixed by Mark Roddy; :issue:`6866`.) @@ -1229,6 +1388,14 @@ Other Changes and Fixes ======================= +* Two benchmark scripts, :file:`iobench` and :file:`ccbench`, were + added to the :file:`Tools` directory. :file:`iobench` measures the + speed of built-in file I/O objects (as returned by :func:`open`) + while performing various operations, and :file:`ccbench` is a + concurrency benchmark that tries to measure computing throughput, + thread switching latency, and IO processing bandwidth when + performing several tasks using a varying number of threads. + * When importing a module from a :file:`.pyc` or :file:`.pyo` file with an existing :file:`.py` counterpart, the :attr:`co_filename` attributes of the resulting code objects are overwritten when the @@ -1280,6 +1447,14 @@ nothing when a negative length is requested, as other file-like objects do. (:issue:`7348`). +In the standard library: + +* The ElementTree library, :mod:`xml.etree`, no longer escapes + ampersands and angle brackets when outputting an XML processing + instruction (which looks like ``) + or comment (which looks like ``). + (Patch by Neil Muller; :issue:`2746`.) + For C extensions: * C extensions that use integer format codes with the ``PyArg_Parse*`` Modified: python/branches/py3k-cdecimal/Doc/whatsnew/3.1.rst ============================================================================== --- python/branches/py3k-cdecimal/Doc/whatsnew/3.1.rst (original) +++ python/branches/py3k-cdecimal/Doc/whatsnew/3.1.rst Thu Apr 1 11:38:52 2010 @@ -119,6 +119,12 @@ Some smaller changes made to the core Python language are: +* Directories and zip archives containing a :file:`__main__.py` + file can now be executed directly by passing their name to the + interpreter. The directory/zipfile is automatically inserted as the + first entry in sys.path. (Suggestion and initial patch by Andy Chu; + revised patch by Phillip J. Eby and Nick Coghlan; :issue:`1739468`.) + * The :func:`int` type gained a ``bit_length`` method that returns the number of bits necessary to represent its argument in binary:: Modified: python/branches/py3k-cdecimal/Include/abstract.h ============================================================================== --- python/branches/py3k-cdecimal/Include/abstract.h (original) +++ python/branches/py3k-cdecimal/Include/abstract.h Thu Apr 1 11:38:52 2010 @@ -1232,6 +1232,9 @@ PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); +PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self); + +PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]); #ifdef __cplusplus } Modified: python/branches/py3k-cdecimal/Include/code.h ============================================================================== --- python/branches/py3k-cdecimal/Include/code.h (original) +++ python/branches/py3k-cdecimal/Include/code.h Thu Apr 1 11:38:52 2010 @@ -27,6 +27,7 @@ PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See Objects/lnotab_notes.txt for details. */ void *co_zombieframe; /* for optimization only (see frameobject.c) */ + PyObject *co_weakreflist; /* to support weakrefs to code objects */ } PyCodeObject; /* Masks for co_flags above */ Modified: python/branches/py3k-cdecimal/Include/longobject.h ============================================================================== --- python/branches/py3k-cdecimal/Include/longobject.h (original) +++ python/branches/py3k-cdecimal/Include/longobject.h Thu Apr 1 11:38:52 2010 @@ -41,6 +41,23 @@ #define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd) #endif +/* Issue #1983: pid_t can be longer than a C long on some systems */ +#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT +#define _Py_PARSE_PID "i" +#define PyLong_FromPid PyLong_FromLong +#define PyLong_AsPid PyLong_AsLong +#elif SIZEOF_PID_T == SIZEOF_LONG +#define _Py_PARSE_PID "l" +#define PyLong_FromPid PyLong_FromLong +#define PyLong_AsPid PyLong_AsLong +#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG +#define _Py_PARSE_PID "L" +#define PyLong_FromPid PyLong_FromLongLong +#define PyLong_AsPid PyLong_AsLongLong +#else +#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)" +#endif /* SIZEOF_PID_T */ + /* For use by intobject.c only */ PyAPI_DATA(unsigned char) _PyLong_DigitValue[256]; Modified: python/branches/py3k-cdecimal/Include/pystate.h ============================================================================== --- python/branches/py3k-cdecimal/Include/pystate.h (original) +++ python/branches/py3k-cdecimal/Include/pystate.h Thu Apr 1 11:38:52 2010 @@ -115,6 +115,8 @@ PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*); PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *); +PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *); PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); #ifdef WITH_THREAD Modified: python/branches/py3k-cdecimal/Include/pystrtod.h ============================================================================== --- python/branches/py3k-cdecimal/Include/pystrtod.h (original) +++ python/branches/py3k-cdecimal/Include/pystrtod.h Thu Apr 1 11:38:52 2010 @@ -6,9 +6,6 @@ #endif -PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr); -PyAPI_FUNC(double) PyOS_ascii_atof(const char *str); -PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d); PyAPI_FUNC(double) PyOS_string_to_double(const char *str, char **endptr, PyObject *overflow_exception); Modified: python/branches/py3k-cdecimal/Include/pythonrun.h ============================================================================== --- python/branches/py3k-cdecimal/Include/pythonrun.h (original) +++ python/branches/py3k-cdecimal/Include/pythonrun.h Thu Apr 1 11:38:52 2010 @@ -81,6 +81,9 @@ PyAPI_FUNC(void) Py_Exit(int); +/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */ +PyAPI_FUNC(void) _Py_RestoreSignals(void); + PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); /* Bootstrap */ Modified: python/branches/py3k-cdecimal/Include/pythread.h ============================================================================== --- python/branches/py3k-cdecimal/Include/pythread.h (original) +++ python/branches/py3k-cdecimal/Include/pythread.h Thu Apr 1 11:38:52 2010 @@ -2,9 +2,6 @@ #ifndef Py_PYTHREAD_H #define Py_PYTHREAD_H -#define NO_EXIT_PROG /* don't define PyThread_exit_prog() */ - /* (the result is no use of signals on SGI) */ - typedef void *PyThread_type_lock; typedef void *PyThread_type_sema; @@ -15,7 +12,6 @@ PyAPI_FUNC(void) PyThread_init_thread(void); PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); PyAPI_FUNC(void) PyThread_exit_thread(void); -PyAPI_FUNC(void) PyThread__PyThread_exit_thread(void); PyAPI_FUNC(long) PyThread_get_thread_ident(void); PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); @@ -28,11 +24,6 @@ PyAPI_FUNC(size_t) PyThread_get_stacksize(void); PyAPI_FUNC(int) PyThread_set_stacksize(size_t); -#ifndef NO_EXIT_PROG -PyAPI_FUNC(void) PyThread_exit_prog(int); -PyAPI_FUNC(void) PyThread__PyThread_exit_prog(int); -#endif - /* Thread Local Storage (TLS) API */ PyAPI_FUNC(int) PyThread_create_key(void); PyAPI_FUNC(void) PyThread_delete_key(int); Modified: python/branches/py3k-cdecimal/Lib/_pyio.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/_pyio.py (original) +++ python/branches/py3k-cdecimal/Lib/_pyio.py Thu Apr 1 11:38:52 2010 @@ -828,7 +828,7 @@ if self.closed: raise ValueError("seek on closed file") try: - pos = pos.__index__() + pos.__index__ except AttributeError as err: raise TypeError("an integer is required") from err if whence == 0: @@ -853,8 +853,13 @@ raise ValueError("truncate on closed file") if pos is None: pos = self._pos - elif pos < 0: - raise ValueError("negative truncate position %r" % (pos,)) + else: + try: + pos.__index__ + except AttributeError as err: + raise TypeError("an integer is required") from err + if pos < 0: + raise ValueError("negative truncate position %r" % (pos,)) del self._buffer[pos:] return pos @@ -1803,6 +1808,10 @@ if n is None: n = -1 decoder = self._decoder or self._get_decoder() + try: + n.__index__ + except AttributeError as err: + raise TypeError("an integer is required") from err if n < 0: # Read everything. result = (self._get_decoded_chars() + Modified: python/branches/py3k-cdecimal/Lib/_threading_local.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/_threading_local.py (original) +++ python/branches/py3k-cdecimal/Lib/_threading_local.py Thu Apr 1 11:38:52 2010 @@ -154,7 +154,7 @@ object.__setattr__(self, '_local__args', (args, kw)) object.__setattr__(self, '_local__lock', RLock()) - if args or kw and (cls.__init__ is object.__init__): + if (args or kw) and (cls.__init__ is object.__init__): raise TypeError("Initialization arguments are not supported") # We need to create the thread dict in anticipation of Modified: python/branches/py3k-cdecimal/Lib/base64.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/base64.py (original) +++ python/branches/py3k-cdecimal/Lib/base64.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """RFC 3548: Base16, Base32, Base64 Data Encodings""" Modified: python/branches/py3k-cdecimal/Lib/cProfile.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/cProfile.py (original) +++ python/branches/py3k-cdecimal/Lib/cProfile.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Python interface for the 'lsprof' profiler. Compatible with the 'profile' module. Modified: python/branches/py3k-cdecimal/Lib/compileall.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/compileall.py (original) +++ python/branches/py3k-cdecimal/Lib/compileall.py Thu Apr 1 11:38:52 2010 @@ -17,7 +17,7 @@ import struct import imp -__all__ = ["compile_dir","compile_path"] +__all__ = ["compile_dir","compile_file","compile_path"] def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None, quiet=0): @@ -48,47 +48,9 @@ dfile = os.path.join(ddir, name) else: dfile = None - if rx is not None: - mo = rx.search(fullname) - if mo: - continue - if os.path.isfile(fullname): - head, tail = name[:-3], name[-3:] - if tail == '.py': - if not force: - try: - mtime = int(os.stat(fullname).st_mtime) - expect = struct.pack('<4sl', imp.get_magic(), mtime) - cfile = fullname + (__debug__ and 'c' or 'o') - with open(cfile, 'rb') as chandle: - actual = chandle.read(8) - if expect == actual: - continue - except IOError: - pass - if not quiet: - print('Compiling', fullname, '...') - try: - ok = py_compile.compile(fullname, None, dfile, True) - except KeyboardInterrupt: - raise KeyboardInterrupt - except py_compile.PyCompileError as err: - if quiet: - print('*** Error compiling', fullname, '...') - else: - print('*** ', end='') - print(err.msg) - success = 0 - except (SyntaxError, UnicodeError, IOError) as e: - if quiet: - print('*** Error compiling', fullname, '...') - else: - print('*** ', end='') - print(e.__class__.__name__ + ':', e) - success = 0 - else: - if ok == 0: - success = 0 + if not os.path.isdir(fullname): + if not compile_file(fullname, ddir, force, rx, quiet): + success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ @@ -98,6 +60,65 @@ success = 0 return success +def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0): + """Byte-compile file. + file: the file to byte-compile + ddir: if given, purported directory name (this is the + directory name that will show up in error messages) + force: if 1, force compilation, even if timestamps are up-to-date + quiet: if 1, be quiet during compilation + + """ + success = 1 + name = os.path.basename(fullname) + if ddir is not None: + dfile = os.path.join(ddir, name) + else: + dfile = None + if rx is not None: + mo = rx.search(fullname) + if mo: + return success + if os.path.isfile(fullname): + head, tail = name[:-3], name[-3:] + if tail == '.py': + if not force: + try: + mtime = int(os.stat(fullname).st_mtime) + expect = struct.pack('<4sl', imp.get_magic(), mtime) + cfile = fullname + (__debug__ and 'c' or 'o') + with open(cfile, 'rb') as chandle: + actual = chandle.read(8) + if expect == actual: + return success + except IOError: + pass + if not quiet: + print('Compiling', fullname, '...') + try: + ok = py_compile.compile(fullname, None, dfile, True) + except py_compile.PyCompileError as err: + if quiet: + print('*** Error compiling', fullname, '...') + else: + print('*** ', end='') + # escape non-printable characters in msg + msg = err.msg.encode(sys.stdout.encoding, errors='backslashreplace') + msg = msg.decode(sys.stdout.encoding) + print(msg) + success = 0 + except (SyntaxError, UnicodeError, IOError) as e: + if quiet: + print('*** Error compiling', fullname, '...') + else: + print('*** ', end='') + print(e.__class__.__name__ + ':', e) + success = 0 + else: + if ok == 0: + success = 0 + return success + def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0): """Byte-compile all module on sys.path. @@ -118,15 +139,34 @@ force, quiet=quiet) return success +def expand_args(args, flist): + """read names in flist and append to args""" + expanded = args[:] + if flist: + try: + if flist == '-': + fd = sys.stdin + else: + fd = open(flist) + while 1: + line = fd.readline() + if not line: + break + expanded.append(line[:-1]) + except IOError: + print("Error reading file list %s" % flist) + raise + return expanded + def main(): """Script main program.""" import getopt try: - opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:') + opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:i:') except getopt.error as msg: print(msg) print("usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \ - "[-x regexp] [directory ...]") + "[-x regexp] [-i list] [directory|file ...]") print("-l: don't recurse down") print("-f: force rebuild even if timestamps are up-to-date") print("-q: quiet operation") @@ -134,12 +174,14 @@ print(" if no directory arguments, -l sys.path is assumed") print("-x regexp: skip files matching the regular expression regexp") print(" the regexp is searched for in the full path of the file") + print("-i list: expand list with its content (file and directory names)") sys.exit(2) maxlevels = 10 ddir = None force = 0 quiet = 0 rx = None + flist = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a @@ -148,17 +190,28 @@ if o == '-x': import re rx = re.compile(a) + if o == '-i': flist = a if ddir: - if len(args) != 1: + if len(args) != 1 and not os.path.isdir(args[0]): print("-d destdir require exactly one directory argument") sys.exit(2) success = 1 try: - if args: - for dir in args: - if not compile_dir(dir, maxlevels, ddir, - force, rx, quiet): - success = 0 + if args or flist: + try: + if flist: + args = expand_args(args, flist) + except IOError: + success = 0 + if success: + for arg in args: + if os.path.isdir(arg): + if not compile_dir(arg, maxlevels, ddir, + force, rx, quiet): + success = 0 + else: + if not compile_file(arg, ddir, force, rx, quiet): + success = 0 else: success = compile_path() except KeyboardInterrupt: Modified: python/branches/py3k-cdecimal/Lib/csv.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/csv.py (original) +++ python/branches/py3k-cdecimal/Lib/csv.py Thu Apr 1 11:38:52 2010 @@ -127,6 +127,10 @@ self.extrasaction = extrasaction self.writer = writer(f, dialect, *args, **kwds) + def writeheader(self): + header = dict(zip(self.fieldnames, self.fieldnames)) + self.writerow(header) + def _dict_to_list(self, rowdict): if self.extrasaction == "raise": wrong_fields = [k for k in rowdict if k not in self.fieldnames] Modified: python/branches/py3k-cdecimal/Lib/ctypes/__init__.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/ctypes/__init__.py (original) +++ python/branches/py3k-cdecimal/Lib/ctypes/__init__.py Thu Apr 1 11:38:52 2010 @@ -459,10 +459,13 @@ if sizeof(c_uint) == sizeof(c_void_p): c_size_t = c_uint + c_ssize_t = c_int elif sizeof(c_ulong) == sizeof(c_void_p): c_size_t = c_ulong + c_ssize_t = c_long elif sizeof(c_ulonglong) == sizeof(c_void_p): c_size_t = c_ulonglong + c_ssize_t = c_longlong # functions Modified: python/branches/py3k-cdecimal/Lib/ctypes/test/test_callbacks.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/ctypes/test/test_callbacks.py (original) +++ python/branches/py3k-cdecimal/Lib/ctypes/test/test_callbacks.py Thu Apr 1 11:38:52 2010 @@ -118,6 +118,22 @@ prototype = self.functype.__func__(object) self.assertRaises(TypeError, prototype, lambda: None) + def test_issue_7959(self): + proto = self.functype.__func__(None) + + class X(object): + def func(self): pass + def __init__(self): + self.v = proto(self.func) + + import gc + for i in range(32): + X() + gc.collect() + live = [x for x in gc.get_objects() + if isinstance(x, X)] + self.assertEqual(len(live), 0) + try: WINFUNCTYPE except NameError: Modified: python/branches/py3k-cdecimal/Lib/ctypes/test/test_internals.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/ctypes/test/test_internals.py (original) +++ python/branches/py3k-cdecimal/Lib/ctypes/test/test_internals.py Thu Apr 1 11:38:52 2010 @@ -23,16 +23,16 @@ def test_ints(self): i = 42000123 - rc = grc(i) + refcnt = grc(i) ci = c_int(i) - self.assertEqual(rc, grc(i)) + self.assertEqual(refcnt, grc(i)) self.assertEqual(ci._objects, None) def test_c_char_p(self): s = b"Hello, World" - rc = grc(s) + refcnt = grc(s) cs = c_char_p(s) - self.assertEqual(rc + 1, grc(s)) + self.assertEqual(refcnt + 1, grc(s)) self.assertSame(cs._objects, s) def test_simple_struct(self): Modified: python/branches/py3k-cdecimal/Lib/ctypes/test/test_sizes.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/ctypes/test/test_sizes.py (original) +++ python/branches/py3k-cdecimal/Lib/ctypes/test/test_sizes.py Thu Apr 1 11:38:52 2010 @@ -1,8 +1,11 @@ # Test specifically-sized containers. -import unittest from ctypes import * +import sys +import unittest + + class SizesTestCase(unittest.TestCase): def test_8(self): self.assertEqual(1, sizeof(c_int8)) @@ -23,5 +26,9 @@ def test_size_t(self): self.assertEqual(sizeof(c_void_p), sizeof(c_size_t)) + def test_ssize_t(self): + self.assertEqual(sizeof(c_void_p), sizeof(c_ssize_t)) + + if __name__ == "__main__": unittest.main() Modified: python/branches/py3k-cdecimal/Lib/ctypes/util.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/ctypes/util.py (original) +++ python/branches/py3k-cdecimal/Lib/ctypes/util.py Thu Apr 1 11:38:52 2010 @@ -205,7 +205,7 @@ # XXX assuming GLIBC's ldconfig (with option -p) expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \ % (abi_type, re.escape(name)) - with contextlib.closing(os.popen('/sbin/ldconfig -p 2>/dev/null')) as f: + with contextlib.closing(os.popen('LANG=C /sbin/ldconfig -p 2>/dev/null')) as f: data = f.read() res = re.search(expr, data) if not res: Modified: python/branches/py3k-cdecimal/Lib/difflib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/difflib.py (original) +++ python/branches/py3k-cdecimal/Lib/difflib.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """ Module difflib -- helpers for computing deltas between objects. Modified: python/branches/py3k-cdecimal/Lib/distutils/command/install.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/command/install.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/command/install.py Thu Apr 1 11:38:52 2010 @@ -499,10 +499,7 @@ if val is not None: if os.name == 'posix' or os.name == 'nt': val = os.path.expanduser(val) - try: - val = _subst_vars(val, self.config_vars) - except: - import pdb; pdb.set_trace() + val = _subst_vars(val, self.config_vars) setattr(self, attr, val) def expand_basedirs(self): Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist.py Thu Apr 1 11:38:52 2010 @@ -5,6 +5,8 @@ import tempfile import shutil +from test.support import run_unittest + from distutils.core import Distribution from distutils.command.bdist import bdist from distutils.tests import support @@ -40,4 +42,4 @@ return unittest.makeSuite(BuildTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_dumb.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_dumb.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_dumb.py Thu Apr 1 11:38:52 2010 @@ -11,6 +11,8 @@ except ImportError: zlib = None +from test.support import run_unittest + from distutils.core import Distribution from distutils.command.bdist_dumb import bdist_dumb from distutils.tests import support @@ -100,4 +102,4 @@ return unittest.makeSuite(BuildDumbTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_msi.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_msi.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_msi.py Thu Apr 1 11:38:52 2010 @@ -2,6 +2,8 @@ import unittest import sys +from test.support import run_unittest + from distutils.tests import support @unittest.skipUnless(sys.platform=="win32", "These tests are only for win32") @@ -20,4 +22,4 @@ return unittest.makeSuite(BDistMSITestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_rpm.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_rpm.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_rpm.py Thu Apr 1 11:38:52 2010 @@ -6,6 +6,8 @@ import tempfile import shutil +from test.support import run_unittest + from distutils.core import Distribution from distutils.command.bdist_rpm import bdist_rpm from distutils.tests import support @@ -122,4 +124,4 @@ return unittest.makeSuite(BuildRpmTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_wininst.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_wininst.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_bdist_wininst.py Thu Apr 1 11:38:52 2010 @@ -1,6 +1,8 @@ """Tests for distutils.command.bdist_wininst.""" import unittest +from test.support import run_unittest + from distutils.command.bdist_wininst import bdist_wininst from distutils.tests import support @@ -27,4 +29,4 @@ return unittest.makeSuite(BuildWinInstTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_build_py.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_build_py.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_build_py.py Thu Apr 1 11:38:52 2010 @@ -16,7 +16,7 @@ support.LoggingSilencer, unittest.TestCase): - def test_package_data(self): + def _setup_package_data(self): sources = self.mkdtemp() f = open(os.path.join(sources, "__init__.py"), "w") f.write("# Pretend this is a package.") @@ -52,10 +52,19 @@ self.assertEqual(len(cmd.get_outputs()), 3) pkgdest = os.path.join(destination, "pkg") files = os.listdir(pkgdest) + return files + + def test_package_data(self): + files = self._setup_package_data() self.assertTrue("__init__.py" in files) - self.assertTrue("__init__.pyc" in files) self.assertTrue("README.txt" in files) + @unittest.skipIf(sys.flags.optimize >= 2, + "pyc files are not written with -O2 and above") + def test_package_data_pyc(self): + files = self._setup_package_data() + self.assertTrue("__init__.pyc" in files) + def test_empty_package_dir (self): # See SF 1668596/1720897. cwd = os.getcwd() Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_cmd.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_cmd.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_cmd.py Thu Apr 1 11:38:52 2010 @@ -1,7 +1,7 @@ """Tests for distutils.cmd.""" import unittest import os -from test.support import captured_stdout +from test.support import captured_stdout, run_unittest from distutils.cmd import Command from distutils.dist import Distribution @@ -124,4 +124,4 @@ return unittest.makeSuite(CommandTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_cygwinccompiler.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_cygwinccompiler.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_cygwinccompiler.py Thu Apr 1 11:38:52 2010 @@ -6,7 +6,7 @@ import warnings import sysconfig -from test.support import check_warnings +from test.support import check_warnings, run_unittest from test.support import captured_stdout from distutils import cygwinccompiler @@ -109,4 +109,4 @@ return unittest.makeSuite(CygwinCCompilerTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_emxccompiler.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_emxccompiler.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_emxccompiler.py Thu Apr 1 11:38:52 2010 @@ -4,7 +4,7 @@ import os import warnings -from test.support import check_warnings +from test.support import check_warnings, run_unittest from test.support import captured_stdout from distutils.emxccompiler import get_versions @@ -30,4 +30,4 @@ return unittest.makeSuite(EmxCCompilerTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_extension.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_extension.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_extension.py Thu Apr 1 11:38:52 2010 @@ -1,6 +1,7 @@ """Tests for distutils.extension.""" -import unittest import os +import sys +import unittest import warnings from test.support import check_warnings @@ -32,16 +33,22 @@ self.assertEquals(names, wanted) - def test_extension_init(self): - # the first argument, which is the name, must be a string + @unittest.skipIf(sys.flags.optimize >= 2, + "Assertions are omitted with -O2 and above") + def test_extension_init_assertions(self): + # The first argument, which is the name, must be a string. self.assertRaises(AssertionError, Extension, 1, []) - ext = Extension('name', []) - self.assertEquals(ext.name, 'name') # the second argument, which is the list of files, must # be a list of strings self.assertRaises(AssertionError, Extension, 'name', 'file') self.assertRaises(AssertionError, Extension, 'name', ['file', 1]) + + def test_extension_init(self): + ext = Extension('name', []) + self.assertEquals(ext.name, 'name') + + ext = Extension('name', ['file1', 'file2']) self.assertEquals(ext.sources, ['file1', 'file2']) Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_install_lib.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_install_lib.py Thu Apr 1 11:38:52 2010 @@ -1,6 +1,6 @@ """Tests for distutils.command.install_data.""" -import sys import os +import sys import unittest from distutils.command.install_lib import install_lib @@ -31,9 +31,7 @@ cmd.finalize_options() self.assertEquals(cmd.optimize, 2) - @unittest.skipUnless(not sys.dont_write_bytecode, - 'byte-compile not supported') - def test_byte_compile(self): + def _setup_byte_compile(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) cmd.compile = cmd.optimize = 1 @@ -41,8 +39,15 @@ f = os.path.join(pkg_dir, 'foo.py') self.write_file(f, '# python file') cmd.byte_compile([f]) - self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc'))) - self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo'))) + return pkg_dir + + @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile not enabled') + def test_byte_compile(self): + pkg_dir = self._setup_byte_compile() + if sys.flags.optimize < 1: + self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc'))) + else: + self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo'))) def test_get_outputs(self): pkg_dir, dist = self.create_dist() Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/distutils/tests/test_sysconfig.py (original) +++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_sysconfig.py Thu Apr 1 11:38:52 2010 @@ -2,6 +2,7 @@ import os import test import unittest +import shutil from distutils import sysconfig from distutils.tests import support Modified: python/branches/py3k-cdecimal/Lib/doctest.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/doctest.py (original) +++ python/branches/py3k-cdecimal/Lib/doctest.py Thu Apr 1 11:38:52 2010 @@ -218,8 +218,8 @@ def _indent(s, indent=4): """ - Add the given number of space characters to the beginning every - non-blank line in `s`, and return the result. + Add the given number of space characters to the beginning of + every non-blank line in `s`, and return the result. """ # This regexp matches the start of non-blank lines: return re.sub('(?m)^(?!$)', indent*' ', s) @@ -1354,7 +1354,14 @@ save_stdout = sys.stdout if out is None: - out = save_stdout.write + encoding = save_stdout.encoding + if encoding is None or encoding.lower() == 'utf-8': + out = save_stdout.write + else: + # Use backslashreplace error handling on write + def out(s): + s = str(s.encode(encoding, 'backslashreplace'), encoding) + save_stdout.write(s) sys.stdout = self._fakeout # Patch pdb.set_trace to restore sys.stdout during interactive @@ -2192,6 +2199,19 @@ def shortDescription(self): return "Doctest: " + self._dt_test.name +class SkipDocTestCase(DocTestCase): + def __init__(self): + DocTestCase.__init__(self, None) + + def setUp(self): + self.skipTest("DocTestSuite will not work with -O2 and above") + + def test_skip(self): + pass + + def shortDescription(self): + return "Skipping tests from %s" % module.__name__ + def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ @@ -2234,13 +2254,20 @@ module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) - if not tests: + + if not tests and sys.flags.optimize >=2: + # Skip doctests when running with -O2 + suite = unittest.TestSuite() + suite.addTest(SkipDocTestCase()) + return suite + elif not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() + for test in tests: if len(test.examples) == 0: continue Modified: python/branches/py3k-cdecimal/Lib/email/generator.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/email/generator.py (original) +++ python/branches/py3k-cdecimal/Lib/email/generator.py Thu Apr 1 11:38:52 2010 @@ -254,8 +254,16 @@ # of length 1. The zeroth element of the list should be the Message # object for the subpart. Extract that object, stringify it, and # write it out. - g.flatten(msg.get_payload(0), unixfrom=False) - self._fp.write(s.getvalue()) + # Except, it turns out, when it's a string instead, which happens when + # and only when HeaderParser is used on a message of mime type + # message/rfc822. Such messages are generated by, for example, + # Groupwise when forwarding unadorned messages. (Issue 7970.) So + # in that case we just emit the string body. + payload = msg.get_payload() + if isinstance(payload, list): + g.flatten(msg.get_payload(0), unixfrom=False) + payload = s.getvalue() + self._fp.write(payload) Modified: python/branches/py3k-cdecimal/Lib/email/message.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/email/message.py (original) +++ python/branches/py3k-cdecimal/Lib/email/message.py Thu Apr 1 11:38:52 2010 @@ -204,7 +204,6 @@ if isinstance(payload, str): payload = payload.encode('raw-unicode-escape') return base64.b64decode(payload) - #return utils._bdecode(payload) except binascii.Error: # Incorrect padding pass Modified: python/branches/py3k-cdecimal/Lib/email/test/data/msg_10.txt ============================================================================== --- python/branches/py3k-cdecimal/Lib/email/test/data/msg_10.txt (original) +++ python/branches/py3k-cdecimal/Lib/email/test/data/msg_10.txt Thu Apr 1 11:38:52 2010 @@ -26,6 +26,13 @@ --BOUNDARY Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: Base64 + +VGhpcyBpcyBhIEJhc2U2NCBlbmNvZGVkIG1lc3NhZ2UuCg== + + +--BOUNDARY +Content-Type: text/plain; charset="iso-8859-1" This has no Content-Transfer-Encoding: header. Modified: python/branches/py3k-cdecimal/Lib/email/test/test_email.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/email/test/test_email.py (original) +++ python/branches/py3k-cdecimal/Lib/email/test/test_email.py Thu Apr 1 11:38:52 2010 @@ -178,6 +178,18 @@ self.assertRaises(errors.HeaderParseError, msg.set_boundary, 'BOUNDARY') + def test_message_rfc822_only(self): + # Issue 7970: message/rfc822 not in multipart parsed by + # HeaderParser caused an exception when flattened. + fp = openfile(findfile('msg_46.txt')) + msgdata = fp.read() + parser = HeaderParser() + msg = parser.parsestr(msgdata) + out = StringIO() + gen = Generator(out, True, 0) + gen.flatten(msg, False) + self.assertEqual(out.getvalue(), msgdata) + def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') @@ -192,8 +204,12 @@ # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=True), b'This is a Base64 encoded message.') - # Subpart 4 has no Content-Transfer-Encoding: header. + # Subpart 4 is base64 with a trailing newline, which + # used to be stripped (issue 7143). eq(msg.get_payload(3).get_payload(decode=True), + b'This is a Base64 encoded message.\n') + # Subpart 5 has no Content-Transfer-Encoding: header. + eq(msg.get_payload(4).get_payload(decode=True), b'This has no Content-Transfer-Encoding: header.\n') def test_get_decoded_uu_payload(self): Modified: python/branches/py3k-cdecimal/Lib/email/test/test_email_torture.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/email/test/test_email_torture.py (original) +++ python/branches/py3k-cdecimal/Lib/email/test/test_email_torture.py Thu Apr 1 11:38:52 2010 @@ -13,7 +13,7 @@ from types import ListType from email.test.test_email import TestEmailBase -from test.support import TestSkipped +from test.support import TestSkipped, run_unittest import email from email import __file__ as testfile @@ -128,7 +128,7 @@ def test_main(): for testclass in _testclasses(): - support.run_unittest(testclass) + run_unittest(testclass) Modified: python/branches/py3k-cdecimal/Lib/encodings/cp720.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/encodings/cp720.py (original) +++ python/branches/py3k-cdecimal/Lib/encodings/cp720.py Thu Apr 1 11:38:52 2010 @@ -1,311 +1,309 @@ -"""Python Character Mapping Codec cp720 generated on Windows: -Vista 6.0.6002 SP2 Multiprocessor Free with the command: - python Tools/unicode/genwincodec.py 720 -"""#" - - -import codecs - -### Codec APIs - -class Codec(codecs.Codec): - - def encode(self,input,errors='strict'): - return codecs.charmap_encode(input,errors,encoding_table) - - def decode(self,input,errors='strict'): - return codecs.charmap_decode(input,errors,decoding_table) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - return codecs.charmap_encode(input,self.errors,encoding_table)[0] - -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return codecs.charmap_decode(input,self.errors,decoding_table)[0] - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='cp720', - encode=Codec().encode, - decode=Codec().decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamreader=StreamReader, - streamwriter=StreamWriter, - ) - - -### Decoding Table - -decoding_table = ( - '\x00' # 0x00 -> CONTROL CHARACTER - '\x01' # 0x01 -> CONTROL CHARACTER - '\x02' # 0x02 -> CONTROL CHARACTER - '\x03' # 0x03 -> CONTROL CHARACTER - '\x04' # 0x04 -> CONTROL CHARACTER - '\x05' # 0x05 -> CONTROL CHARACTER - '\x06' # 0x06 -> CONTROL CHARACTER - '\x07' # 0x07 -> CONTROL CHARACTER - '\x08' # 0x08 -> CONTROL CHARACTER - '\t' # 0x09 -> CONTROL CHARACTER - '\n' # 0x0A -> CONTROL CHARACTER - '\x0b' # 0x0B -> CONTROL CHARACTER - '\x0c' # 0x0C -> CONTROL CHARACTER - '\r' # 0x0D -> CONTROL CHARACTER - '\x0e' # 0x0E -> CONTROL CHARACTER - '\x0f' # 0x0F -> CONTROL CHARACTER - '\x10' # 0x10 -> CONTROL CHARACTER - '\x11' # 0x11 -> CONTROL CHARACTER - '\x12' # 0x12 -> CONTROL CHARACTER - '\x13' # 0x13 -> CONTROL CHARACTER - '\x14' # 0x14 -> CONTROL CHARACTER - '\x15' # 0x15 -> CONTROL CHARACTER - '\x16' # 0x16 -> CONTROL CHARACTER - '\x17' # 0x17 -> CONTROL CHARACTER - '\x18' # 0x18 -> CONTROL CHARACTER - '\x19' # 0x19 -> CONTROL CHARACTER - '\x1a' # 0x1A -> CONTROL CHARACTER - '\x1b' # 0x1B -> CONTROL CHARACTER - '\x1c' # 0x1C -> CONTROL CHARACTER - '\x1d' # 0x1D -> CONTROL CHARACTER - '\x1e' # 0x1E -> CONTROL CHARACTER - '\x1f' # 0x1F -> CONTROL CHARACTER - ' ' # 0x20 -> SPACE - '!' # 0x21 -> EXCLAMATION MARK - '"' # 0x22 -> QUOTATION MARK - '#' # 0x23 -> NUMBER SIGN - '$' # 0x24 -> DOLLAR SIGN - '%' # 0x25 -> PERCENT SIGN - '&' # 0x26 -> AMPERSAND - "'" # 0x27 -> APOSTROPHE - '(' # 0x28 -> LEFT PARENTHESIS - ')' # 0x29 -> RIGHT PARENTHESIS - '*' # 0x2A -> ASTERISK - '+' # 0x2B -> PLUS SIGN - ',' # 0x2C -> COMMA - '-' # 0x2D -> HYPHEN-MINUS - '.' # 0x2E -> FULL STOP - '/' # 0x2F -> SOLIDUS - '0' # 0x30 -> DIGIT ZERO - '1' # 0x31 -> DIGIT ONE - '2' # 0x32 -> DIGIT TWO - '3' # 0x33 -> DIGIT THREE - '4' # 0x34 -> DIGIT FOUR - '5' # 0x35 -> DIGIT FIVE - '6' # 0x36 -> DIGIT SIX - '7' # 0x37 -> DIGIT SEVEN - '8' # 0x38 -> DIGIT EIGHT - '9' # 0x39 -> DIGIT NINE - ':' # 0x3A -> COLON - ';' # 0x3B -> SEMICOLON - '<' # 0x3C -> LESS-THAN SIGN - '=' # 0x3D -> EQUALS SIGN - '>' # 0x3E -> GREATER-THAN SIGN - '?' # 0x3F -> QUESTION MARK - '@' # 0x40 -> COMMERCIAL AT - 'A' # 0x41 -> LATIN CAPITAL LETTER A - 'B' # 0x42 -> LATIN CAPITAL LETTER B - 'C' # 0x43 -> LATIN CAPITAL LETTER C - 'D' # 0x44 -> LATIN CAPITAL LETTER D - 'E' # 0x45 -> LATIN CAPITAL LETTER E - 'F' # 0x46 -> LATIN CAPITAL LETTER F - 'G' # 0x47 -> LATIN CAPITAL LETTER G - 'H' # 0x48 -> LATIN CAPITAL LETTER H - 'I' # 0x49 -> LATIN CAPITAL LETTER I - 'J' # 0x4A -> LATIN CAPITAL LETTER J - 'K' # 0x4B -> LATIN CAPITAL LETTER K - 'L' # 0x4C -> LATIN CAPITAL LETTER L - 'M' # 0x4D -> LATIN CAPITAL LETTER M - 'N' # 0x4E -> LATIN CAPITAL LETTER N - 'O' # 0x4F -> LATIN CAPITAL LETTER O - 'P' # 0x50 -> LATIN CAPITAL LETTER P - 'Q' # 0x51 -> LATIN CAPITAL LETTER Q - 'R' # 0x52 -> LATIN CAPITAL LETTER R - 'S' # 0x53 -> LATIN CAPITAL LETTER S - 'T' # 0x54 -> LATIN CAPITAL LETTER T - 'U' # 0x55 -> LATIN CAPITAL LETTER U - 'V' # 0x56 -> LATIN CAPITAL LETTER V - 'W' # 0x57 -> LATIN CAPITAL LETTER W - 'X' # 0x58 -> LATIN CAPITAL LETTER X - 'Y' # 0x59 -> LATIN CAPITAL LETTER Y - 'Z' # 0x5A -> LATIN CAPITAL LETTER Z - '[' # 0x5B -> LEFT SQUARE BRACKET - '\\' # 0x5C -> REVERSE SOLIDUS - ']' # 0x5D -> RIGHT SQUARE BRACKET - '^' # 0x5E -> CIRCUMFLEX ACCENT - '_' # 0x5F -> LOW LINE - '`' # 0x60 -> GRAVE ACCENT - 'a' # 0x61 -> LATIN SMALL LETTER A - 'b' # 0x62 -> LATIN SMALL LETTER B - 'c' # 0x63 -> LATIN SMALL LETTER C - 'd' # 0x64 -> LATIN SMALL LETTER D - 'e' # 0x65 -> LATIN SMALL LETTER E - 'f' # 0x66 -> LATIN SMALL LETTER F - 'g' # 0x67 -> LATIN SMALL LETTER G - 'h' # 0x68 -> LATIN SMALL LETTER H - 'i' # 0x69 -> LATIN SMALL LETTER I - 'j' # 0x6A -> LATIN SMALL LETTER J - 'k' # 0x6B -> LATIN SMALL LETTER K - 'l' # 0x6C -> LATIN SMALL LETTER L - 'm' # 0x6D -> LATIN SMALL LETTER M - 'n' # 0x6E -> LATIN SMALL LETTER N - 'o' # 0x6F -> LATIN SMALL LETTER O - 'p' # 0x70 -> LATIN SMALL LETTER P - 'q' # 0x71 -> LATIN SMALL LETTER Q - 'r' # 0x72 -> LATIN SMALL LETTER R - 's' # 0x73 -> LATIN SMALL LETTER S - 't' # 0x74 -> LATIN SMALL LETTER T - 'u' # 0x75 -> LATIN SMALL LETTER U - 'v' # 0x76 -> LATIN SMALL LETTER V - 'w' # 0x77 -> LATIN SMALL LETTER W - 'x' # 0x78 -> LATIN SMALL LETTER X - 'y' # 0x79 -> LATIN SMALL LETTER Y - 'z' # 0x7A -> LATIN SMALL LETTER Z - '{' # 0x7B -> LEFT CURLY BRACKET - '|' # 0x7C -> VERTICAL LINE - '}' # 0x7D -> RIGHT CURLY BRACKET - '~' # 0x7E -> TILDE - '\x7f' # 0x7F -> CONTROL CHARACTER - '\x80' - '\x81' - '\xe9' # 0x82 -> LATIN SMALL LETTER E WITH ACUTE - '\xe2' # 0x83 -> LATIN SMALL LETTER A WITH CIRCUMFLEX - '\x84' - '\xe0' # 0x85 -> LATIN SMALL LETTER A WITH GRAVE - '\x86' - '\xe7' # 0x87 -> LATIN SMALL LETTER C WITH CEDILLA - '\xea' # 0x88 -> LATIN SMALL LETTER E WITH CIRCUMFLEX - '\xeb' # 0x89 -> LATIN SMALL LETTER E WITH DIAERESIS - '\xe8' # 0x8A -> LATIN SMALL LETTER E WITH GRAVE - '\xef' # 0x8B -> LATIN SMALL LETTER I WITH DIAERESIS - '\xee' # 0x8C -> LATIN SMALL LETTER I WITH CIRCUMFLEX - '\x8d' - '\x8e' - '\x8f' - '\x90' - '\u0651' # 0x91 -> ARABIC SHADDA - '\u0652' # 0x92 -> ARABIC SUKUN - '\xf4' # 0x93 -> LATIN SMALL LETTER O WITH CIRCUMFLEX - '\xa4' # 0x94 -> CURRENCY SIGN - '\u0640' # 0x95 -> ARABIC TATWEEL - '\xfb' # 0x96 -> LATIN SMALL LETTER U WITH CIRCUMFLEX - '\xf9' # 0x97 -> LATIN SMALL LETTER U WITH GRAVE - '\u0621' # 0x98 -> ARABIC LETTER HAMZA - '\u0622' # 0x99 -> ARABIC LETTER ALEF WITH MADDA ABOVE - '\u0623' # 0x9A -> ARABIC LETTER ALEF WITH HAMZA ABOVE - '\u0624' # 0x9B -> ARABIC LETTER WAW WITH HAMZA ABOVE - '\xa3' # 0x9C -> POUND SIGN - '\u0625' # 0x9D -> ARABIC LETTER ALEF WITH HAMZA BELOW - '\u0626' # 0x9E -> ARABIC LETTER YEH WITH HAMZA ABOVE - '\u0627' # 0x9F -> ARABIC LETTER ALEF - '\u0628' # 0xA0 -> ARABIC LETTER BEH - '\u0629' # 0xA1 -> ARABIC LETTER TEH MARBUTA - '\u062a' # 0xA2 -> ARABIC LETTER TEH - '\u062b' # 0xA3 -> ARABIC LETTER THEH - '\u062c' # 0xA4 -> ARABIC LETTER JEEM - '\u062d' # 0xA5 -> ARABIC LETTER HAH - '\u062e' # 0xA6 -> ARABIC LETTER KHAH - '\u062f' # 0xA7 -> ARABIC LETTER DAL - '\u0630' # 0xA8 -> ARABIC LETTER THAL - '\u0631' # 0xA9 -> ARABIC LETTER REH - '\u0632' # 0xAA -> ARABIC LETTER ZAIN - '\u0633' # 0xAB -> ARABIC LETTER SEEN - '\u0634' # 0xAC -> ARABIC LETTER SHEEN - '\u0635' # 0xAD -> ARABIC LETTER SAD - '\xab' # 0xAE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - '\xbb' # 0xAF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - '\u2591' # 0xB0 -> LIGHT SHADE - '\u2592' # 0xB1 -> MEDIUM SHADE - '\u2593' # 0xB2 -> DARK SHADE - '\u2502' # 0xB3 -> BOX DRAWINGS LIGHT VERTICAL - '\u2524' # 0xB4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT - '\u2561' # 0xB5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE - '\u2562' # 0xB6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE - '\u2556' # 0xB7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE - '\u2555' # 0xB8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE - '\u2563' # 0xB9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT - '\u2551' # 0xBA -> BOX DRAWINGS DOUBLE VERTICAL - '\u2557' # 0xBB -> BOX DRAWINGS DOUBLE DOWN AND LEFT - '\u255d' # 0xBC -> BOX DRAWINGS DOUBLE UP AND LEFT - '\u255c' # 0xBD -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE - '\u255b' # 0xBE -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE - '\u2510' # 0xBF -> BOX DRAWINGS LIGHT DOWN AND LEFT - '\u2514' # 0xC0 -> BOX DRAWINGS LIGHT UP AND RIGHT - '\u2534' # 0xC1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL - '\u252c' # 0xC2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL - '\u251c' # 0xC3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT - '\u2500' # 0xC4 -> BOX DRAWINGS LIGHT HORIZONTAL - '\u253c' # 0xC5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL - '\u255e' # 0xC6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE - '\u255f' # 0xC7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE - '\u255a' # 0xC8 -> BOX DRAWINGS DOUBLE UP AND RIGHT - '\u2554' # 0xC9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT - '\u2569' # 0xCA -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL - '\u2566' # 0xCB -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL - '\u2560' # 0xCC -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT - '\u2550' # 0xCD -> BOX DRAWINGS DOUBLE HORIZONTAL - '\u256c' # 0xCE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL - '\u2567' # 0xCF -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE - '\u2568' # 0xD0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE - '\u2564' # 0xD1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE - '\u2565' # 0xD2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE - '\u2559' # 0xD3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE - '\u2558' # 0xD4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE - '\u2552' # 0xD5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE - '\u2553' # 0xD6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE - '\u256b' # 0xD7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE - '\u256a' # 0xD8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE - '\u2518' # 0xD9 -> BOX DRAWINGS LIGHT UP AND LEFT - '\u250c' # 0xDA -> BOX DRAWINGS LIGHT DOWN AND RIGHT - '\u2588' # 0xDB -> FULL BLOCK - '\u2584' # 0xDC -> LOWER HALF BLOCK - '\u258c' # 0xDD -> LEFT HALF BLOCK - '\u2590' # 0xDE -> RIGHT HALF BLOCK - '\u2580' # 0xDF -> UPPER HALF BLOCK - '\u0636' # 0xE0 -> ARABIC LETTER DAD - '\u0637' # 0xE1 -> ARABIC LETTER TAH - '\u0638' # 0xE2 -> ARABIC LETTER ZAH - '\u0639' # 0xE3 -> ARABIC LETTER AIN - '\u063a' # 0xE4 -> ARABIC LETTER GHAIN - '\u0641' # 0xE5 -> ARABIC LETTER FEH - '\xb5' # 0xE6 -> MICRO SIGN - '\u0642' # 0xE7 -> ARABIC LETTER QAF - '\u0643' # 0xE8 -> ARABIC LETTER KAF - '\u0644' # 0xE9 -> ARABIC LETTER LAM - '\u0645' # 0xEA -> ARABIC LETTER MEEM - '\u0646' # 0xEB -> ARABIC LETTER NOON - '\u0647' # 0xEC -> ARABIC LETTER HEH - '\u0648' # 0xED -> ARABIC LETTER WAW - '\u0649' # 0xEE -> ARABIC LETTER ALEF MAKSURA - '\u064a' # 0xEF -> ARABIC LETTER YEH - '\u2261' # 0xF0 -> IDENTICAL TO - '\u064b' # 0xF1 -> ARABIC FATHATAN - '\u064c' # 0xF2 -> ARABIC DAMMATAN - '\u064d' # 0xF3 -> ARABIC KASRATAN - '\u064e' # 0xF4 -> ARABIC FATHA - '\u064f' # 0xF5 -> ARABIC DAMMA - '\u0650' # 0xF6 -> ARABIC KASRA - '\u2248' # 0xF7 -> ALMOST EQUAL TO - '\xb0' # 0xF8 -> DEGREE SIGN - '\u2219' # 0xF9 -> BULLET OPERATOR - '\xb7' # 0xFA -> MIDDLE DOT - '\u221a' # 0xFB -> SQUARE ROOT - '\u207f' # 0xFC -> SUPERSCRIPT LATIN SMALL LETTER N - '\xb2' # 0xFD -> SUPERSCRIPT TWO - '\u25a0' # 0xFE -> BLACK SQUARE - '\xa0' # 0xFF -> NO-BREAK SPACE -) - -### Encoding table -encoding_table=codecs.charmap_build(decoding_table) - - +"""Python Character Mapping Codec cp720 generated on Windows: +Vista 6.0.6002 SP2 Multiprocessor Free with the command: + python Tools/unicode/genwincodec.py 720 +"""#" + + +import codecs + +### Codec APIs + +class Codec(codecs.Codec): + + def encode(self,input,errors='strict'): + return codecs.charmap_encode(input,errors,encoding_table) + + def decode(self,input,errors='strict'): + return codecs.charmap_decode(input,errors,decoding_table) + +class IncrementalEncoder(codecs.IncrementalEncoder): + def encode(self, input, final=False): + return codecs.charmap_encode(input,self.errors,encoding_table)[0] + +class IncrementalDecoder(codecs.IncrementalDecoder): + def decode(self, input, final=False): + return codecs.charmap_decode(input,self.errors,decoding_table)[0] + +class StreamWriter(Codec,codecs.StreamWriter): + pass + +class StreamReader(Codec,codecs.StreamReader): + pass + +### encodings module API + +def getregentry(): + return codecs.CodecInfo( + name='cp720', + encode=Codec().encode, + decode=Codec().decode, + incrementalencoder=IncrementalEncoder, + incrementaldecoder=IncrementalDecoder, + streamreader=StreamReader, + streamwriter=StreamWriter, + ) + + +### Decoding Table + +decoding_table = ( + '\x00' # 0x00 -> CONTROL CHARACTER + '\x01' # 0x01 -> CONTROL CHARACTER + '\x02' # 0x02 -> CONTROL CHARACTER + '\x03' # 0x03 -> CONTROL CHARACTER + '\x04' # 0x04 -> CONTROL CHARACTER + '\x05' # 0x05 -> CONTROL CHARACTER + '\x06' # 0x06 -> CONTROL CHARACTER + '\x07' # 0x07 -> CONTROL CHARACTER + '\x08' # 0x08 -> CONTROL CHARACTER + '\t' # 0x09 -> CONTROL CHARACTER + '\n' # 0x0A -> CONTROL CHARACTER + '\x0b' # 0x0B -> CONTROL CHARACTER + '\x0c' # 0x0C -> CONTROL CHARACTER + '\r' # 0x0D -> CONTROL CHARACTER + '\x0e' # 0x0E -> CONTROL CHARACTER + '\x0f' # 0x0F -> CONTROL CHARACTER + '\x10' # 0x10 -> CONTROL CHARACTER + '\x11' # 0x11 -> CONTROL CHARACTER + '\x12' # 0x12 -> CONTROL CHARACTER + '\x13' # 0x13 -> CONTROL CHARACTER + '\x14' # 0x14 -> CONTROL CHARACTER + '\x15' # 0x15 -> CONTROL CHARACTER + '\x16' # 0x16 -> CONTROL CHARACTER + '\x17' # 0x17 -> CONTROL CHARACTER + '\x18' # 0x18 -> CONTROL CHARACTER + '\x19' # 0x19 -> CONTROL CHARACTER + '\x1a' # 0x1A -> CONTROL CHARACTER + '\x1b' # 0x1B -> CONTROL CHARACTER + '\x1c' # 0x1C -> CONTROL CHARACTER + '\x1d' # 0x1D -> CONTROL CHARACTER + '\x1e' # 0x1E -> CONTROL CHARACTER + '\x1f' # 0x1F -> CONTROL CHARACTER + ' ' # 0x20 -> SPACE + '!' # 0x21 -> EXCLAMATION MARK + '"' # 0x22 -> QUOTATION MARK + '#' # 0x23 -> NUMBER SIGN + '$' # 0x24 -> DOLLAR SIGN + '%' # 0x25 -> PERCENT SIGN + '&' # 0x26 -> AMPERSAND + "'" # 0x27 -> APOSTROPHE + '(' # 0x28 -> LEFT PARENTHESIS + ')' # 0x29 -> RIGHT PARENTHESIS + '*' # 0x2A -> ASTERISK + '+' # 0x2B -> PLUS SIGN + ',' # 0x2C -> COMMA + '-' # 0x2D -> HYPHEN-MINUS + '.' # 0x2E -> FULL STOP + '/' # 0x2F -> SOLIDUS + '0' # 0x30 -> DIGIT ZERO + '1' # 0x31 -> DIGIT ONE + '2' # 0x32 -> DIGIT TWO + '3' # 0x33 -> DIGIT THREE + '4' # 0x34 -> DIGIT FOUR + '5' # 0x35 -> DIGIT FIVE + '6' # 0x36 -> DIGIT SIX + '7' # 0x37 -> DIGIT SEVEN + '8' # 0x38 -> DIGIT EIGHT + '9' # 0x39 -> DIGIT NINE + ':' # 0x3A -> COLON + ';' # 0x3B -> SEMICOLON + '<' # 0x3C -> LESS-THAN SIGN + '=' # 0x3D -> EQUALS SIGN + '>' # 0x3E -> GREATER-THAN SIGN + '?' # 0x3F -> QUESTION MARK + '@' # 0x40 -> COMMERCIAL AT + 'A' # 0x41 -> LATIN CAPITAL LETTER A + 'B' # 0x42 -> LATIN CAPITAL LETTER B + 'C' # 0x43 -> LATIN CAPITAL LETTER C + 'D' # 0x44 -> LATIN CAPITAL LETTER D + 'E' # 0x45 -> LATIN CAPITAL LETTER E + 'F' # 0x46 -> LATIN CAPITAL LETTER F + 'G' # 0x47 -> LATIN CAPITAL LETTER G + 'H' # 0x48 -> LATIN CAPITAL LETTER H + 'I' # 0x49 -> LATIN CAPITAL LETTER I + 'J' # 0x4A -> LATIN CAPITAL LETTER J + 'K' # 0x4B -> LATIN CAPITAL LETTER K + 'L' # 0x4C -> LATIN CAPITAL LETTER L + 'M' # 0x4D -> LATIN CAPITAL LETTER M + 'N' # 0x4E -> LATIN CAPITAL LETTER N + 'O' # 0x4F -> LATIN CAPITAL LETTER O + 'P' # 0x50 -> LATIN CAPITAL LETTER P + 'Q' # 0x51 -> LATIN CAPITAL LETTER Q + 'R' # 0x52 -> LATIN CAPITAL LETTER R + 'S' # 0x53 -> LATIN CAPITAL LETTER S + 'T' # 0x54 -> LATIN CAPITAL LETTER T + 'U' # 0x55 -> LATIN CAPITAL LETTER U + 'V' # 0x56 -> LATIN CAPITAL LETTER V + 'W' # 0x57 -> LATIN CAPITAL LETTER W + 'X' # 0x58 -> LATIN CAPITAL LETTER X + 'Y' # 0x59 -> LATIN CAPITAL LETTER Y + 'Z' # 0x5A -> LATIN CAPITAL LETTER Z + '[' # 0x5B -> LEFT SQUARE BRACKET + '\\' # 0x5C -> REVERSE SOLIDUS + ']' # 0x5D -> RIGHT SQUARE BRACKET + '^' # 0x5E -> CIRCUMFLEX ACCENT + '_' # 0x5F -> LOW LINE + '`' # 0x60 -> GRAVE ACCENT + 'a' # 0x61 -> LATIN SMALL LETTER A + 'b' # 0x62 -> LATIN SMALL LETTER B + 'c' # 0x63 -> LATIN SMALL LETTER C + 'd' # 0x64 -> LATIN SMALL LETTER D + 'e' # 0x65 -> LATIN SMALL LETTER E + 'f' # 0x66 -> LATIN SMALL LETTER F + 'g' # 0x67 -> LATIN SMALL LETTER G + 'h' # 0x68 -> LATIN SMALL LETTER H + 'i' # 0x69 -> LATIN SMALL LETTER I + 'j' # 0x6A -> LATIN SMALL LETTER J + 'k' # 0x6B -> LATIN SMALL LETTER K + 'l' # 0x6C -> LATIN SMALL LETTER L + 'm' # 0x6D -> LATIN SMALL LETTER M + 'n' # 0x6E -> LATIN SMALL LETTER N + 'o' # 0x6F -> LATIN SMALL LETTER O + 'p' # 0x70 -> LATIN SMALL LETTER P + 'q' # 0x71 -> LATIN SMALL LETTER Q + 'r' # 0x72 -> LATIN SMALL LETTER R + 's' # 0x73 -> LATIN SMALL LETTER S + 't' # 0x74 -> LATIN SMALL LETTER T + 'u' # 0x75 -> LATIN SMALL LETTER U + 'v' # 0x76 -> LATIN SMALL LETTER V + 'w' # 0x77 -> LATIN SMALL LETTER W + 'x' # 0x78 -> LATIN SMALL LETTER X + 'y' # 0x79 -> LATIN SMALL LETTER Y + 'z' # 0x7A -> LATIN SMALL LETTER Z + '{' # 0x7B -> LEFT CURLY BRACKET + '|' # 0x7C -> VERTICAL LINE + '}' # 0x7D -> RIGHT CURLY BRACKET + '~' # 0x7E -> TILDE + '\x7f' # 0x7F -> CONTROL CHARACTER + '\x80' + '\x81' + '\xe9' # 0x82 -> LATIN SMALL LETTER E WITH ACUTE + '\xe2' # 0x83 -> LATIN SMALL LETTER A WITH CIRCUMFLEX + '\x84' + '\xe0' # 0x85 -> LATIN SMALL LETTER A WITH GRAVE + '\x86' + '\xe7' # 0x87 -> LATIN SMALL LETTER C WITH CEDILLA + '\xea' # 0x88 -> LATIN SMALL LETTER E WITH CIRCUMFLEX + '\xeb' # 0x89 -> LATIN SMALL LETTER E WITH DIAERESIS + '\xe8' # 0x8A -> LATIN SMALL LETTER E WITH GRAVE + '\xef' # 0x8B -> LATIN SMALL LETTER I WITH DIAERESIS + '\xee' # 0x8C -> LATIN SMALL LETTER I WITH CIRCUMFLEX + '\x8d' + '\x8e' + '\x8f' + '\x90' + '\u0651' # 0x91 -> ARABIC SHADDA + '\u0652' # 0x92 -> ARABIC SUKUN + '\xf4' # 0x93 -> LATIN SMALL LETTER O WITH CIRCUMFLEX + '\xa4' # 0x94 -> CURRENCY SIGN + '\u0640' # 0x95 -> ARABIC TATWEEL + '\xfb' # 0x96 -> LATIN SMALL LETTER U WITH CIRCUMFLEX + '\xf9' # 0x97 -> LATIN SMALL LETTER U WITH GRAVE + '\u0621' # 0x98 -> ARABIC LETTER HAMZA + '\u0622' # 0x99 -> ARABIC LETTER ALEF WITH MADDA ABOVE + '\u0623' # 0x9A -> ARABIC LETTER ALEF WITH HAMZA ABOVE + '\u0624' # 0x9B -> ARABIC LETTER WAW WITH HAMZA ABOVE + '\xa3' # 0x9C -> POUND SIGN + '\u0625' # 0x9D -> ARABIC LETTER ALEF WITH HAMZA BELOW + '\u0626' # 0x9E -> ARABIC LETTER YEH WITH HAMZA ABOVE + '\u0627' # 0x9F -> ARABIC LETTER ALEF + '\u0628' # 0xA0 -> ARABIC LETTER BEH + '\u0629' # 0xA1 -> ARABIC LETTER TEH MARBUTA + '\u062a' # 0xA2 -> ARABIC LETTER TEH + '\u062b' # 0xA3 -> ARABIC LETTER THEH + '\u062c' # 0xA4 -> ARABIC LETTER JEEM + '\u062d' # 0xA5 -> ARABIC LETTER HAH + '\u062e' # 0xA6 -> ARABIC LETTER KHAH + '\u062f' # 0xA7 -> ARABIC LETTER DAL + '\u0630' # 0xA8 -> ARABIC LETTER THAL + '\u0631' # 0xA9 -> ARABIC LETTER REH + '\u0632' # 0xAA -> ARABIC LETTER ZAIN + '\u0633' # 0xAB -> ARABIC LETTER SEEN + '\u0634' # 0xAC -> ARABIC LETTER SHEEN + '\u0635' # 0xAD -> ARABIC LETTER SAD + '\xab' # 0xAE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + '\xbb' # 0xAF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + '\u2591' # 0xB0 -> LIGHT SHADE + '\u2592' # 0xB1 -> MEDIUM SHADE + '\u2593' # 0xB2 -> DARK SHADE + '\u2502' # 0xB3 -> BOX DRAWINGS LIGHT VERTICAL + '\u2524' # 0xB4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT + '\u2561' # 0xB5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE + '\u2562' # 0xB6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE + '\u2556' # 0xB7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE + '\u2555' # 0xB8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE + '\u2563' # 0xB9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT + '\u2551' # 0xBA -> BOX DRAWINGS DOUBLE VERTICAL + '\u2557' # 0xBB -> BOX DRAWINGS DOUBLE DOWN AND LEFT + '\u255d' # 0xBC -> BOX DRAWINGS DOUBLE UP AND LEFT + '\u255c' # 0xBD -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE + '\u255b' # 0xBE -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE + '\u2510' # 0xBF -> BOX DRAWINGS LIGHT DOWN AND LEFT + '\u2514' # 0xC0 -> BOX DRAWINGS LIGHT UP AND RIGHT + '\u2534' # 0xC1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL + '\u252c' # 0xC2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL + '\u251c' # 0xC3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT + '\u2500' # 0xC4 -> BOX DRAWINGS LIGHT HORIZONTAL + '\u253c' # 0xC5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL + '\u255e' # 0xC6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE + '\u255f' # 0xC7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE + '\u255a' # 0xC8 -> BOX DRAWINGS DOUBLE UP AND RIGHT + '\u2554' # 0xC9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT + '\u2569' # 0xCA -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL + '\u2566' # 0xCB -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL + '\u2560' # 0xCC -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT + '\u2550' # 0xCD -> BOX DRAWINGS DOUBLE HORIZONTAL + '\u256c' # 0xCE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL + '\u2567' # 0xCF -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE + '\u2568' # 0xD0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE + '\u2564' # 0xD1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE + '\u2565' # 0xD2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE + '\u2559' # 0xD3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE + '\u2558' # 0xD4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE + '\u2552' # 0xD5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE + '\u2553' # 0xD6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE + '\u256b' # 0xD7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE + '\u256a' # 0xD8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE + '\u2518' # 0xD9 -> BOX DRAWINGS LIGHT UP AND LEFT + '\u250c' # 0xDA -> BOX DRAWINGS LIGHT DOWN AND RIGHT + '\u2588' # 0xDB -> FULL BLOCK + '\u2584' # 0xDC -> LOWER HALF BLOCK + '\u258c' # 0xDD -> LEFT HALF BLOCK + '\u2590' # 0xDE -> RIGHT HALF BLOCK + '\u2580' # 0xDF -> UPPER HALF BLOCK + '\u0636' # 0xE0 -> ARABIC LETTER DAD + '\u0637' # 0xE1 -> ARABIC LETTER TAH + '\u0638' # 0xE2 -> ARABIC LETTER ZAH + '\u0639' # 0xE3 -> ARABIC LETTER AIN + '\u063a' # 0xE4 -> ARABIC LETTER GHAIN + '\u0641' # 0xE5 -> ARABIC LETTER FEH + '\xb5' # 0xE6 -> MICRO SIGN + '\u0642' # 0xE7 -> ARABIC LETTER QAF + '\u0643' # 0xE8 -> ARABIC LETTER KAF + '\u0644' # 0xE9 -> ARABIC LETTER LAM + '\u0645' # 0xEA -> ARABIC LETTER MEEM + '\u0646' # 0xEB -> ARABIC LETTER NOON + '\u0647' # 0xEC -> ARABIC LETTER HEH + '\u0648' # 0xED -> ARABIC LETTER WAW + '\u0649' # 0xEE -> ARABIC LETTER ALEF MAKSURA + '\u064a' # 0xEF -> ARABIC LETTER YEH + '\u2261' # 0xF0 -> IDENTICAL TO + '\u064b' # 0xF1 -> ARABIC FATHATAN + '\u064c' # 0xF2 -> ARABIC DAMMATAN + '\u064d' # 0xF3 -> ARABIC KASRATAN + '\u064e' # 0xF4 -> ARABIC FATHA + '\u064f' # 0xF5 -> ARABIC DAMMA + '\u0650' # 0xF6 -> ARABIC KASRA + '\u2248' # 0xF7 -> ALMOST EQUAL TO + '\xb0' # 0xF8 -> DEGREE SIGN + '\u2219' # 0xF9 -> BULLET OPERATOR + '\xb7' # 0xFA -> MIDDLE DOT + '\u221a' # 0xFB -> SQUARE ROOT + '\u207f' # 0xFC -> SUPERSCRIPT LATIN SMALL LETTER N + '\xb2' # 0xFD -> SUPERSCRIPT TWO + '\u25a0' # 0xFE -> BLACK SQUARE + '\xa0' # 0xFF -> NO-BREAK SPACE +) + +### Encoding table +encoding_table=codecs.charmap_build(decoding_table) Modified: python/branches/py3k-cdecimal/Lib/fractions.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/fractions.py (original) +++ python/branches/py3k-cdecimal/Lib/fractions.py Thu Apr 1 11:38:52 2010 @@ -526,8 +526,6 @@ if isinstance(other, numbers.Rational): return op(self._numerator * other.denominator, self._denominator * other.numerator) - if isinstance(other, numbers.Complex) and other.imag == 0: - other = other.real if isinstance(other, float): if math.isnan(other) or math.isinf(other): return op(0.0, other) Modified: python/branches/py3k-cdecimal/Lib/genericpath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/genericpath.py (original) +++ python/branches/py3k-cdecimal/Lib/genericpath.py Thu Apr 1 11:38:52 2010 @@ -15,7 +15,7 @@ def exists(path): """Test whether a path exists. Returns False for broken symbolic links""" try: - st = os.stat(path) + os.stat(path) except os.error: return False return True Modified: python/branches/py3k-cdecimal/Lib/hashlib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/hashlib.py (original) +++ python/branches/py3k-cdecimal/Lib/hashlib.py Thu Apr 1 11:38:52 2010 @@ -57,7 +57,9 @@ # always available algorithm is added. __always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512') -__all__ = __always_supported + ('new',) +algorithms = __always_supported + +__all__ = __always_supported + ('new', 'algorithms') def __get_builtin_constructor(name): Modified: python/branches/py3k-cdecimal/Lib/http/client.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/http/client.py (original) +++ python/branches/py3k-cdecimal/Lib/http/client.py Thu Apr 1 11:38:52 2010 @@ -1121,6 +1121,8 @@ class BadStatusLine(HTTPException): def __init__(self, line): + if not line: + line = repr(line) self.args = line, self.line = line Modified: python/branches/py3k-cdecimal/Lib/http/cookies.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/http/cookies.py (original) +++ python/branches/py3k-cdecimal/Lib/http/cookies.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # #### Modified: python/branches/py3k-cdecimal/Lib/http/server.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/http/server.py (original) +++ python/branches/py3k-cdecimal/Lib/http/server.py Thu Apr 1 11:38:52 2010 @@ -563,7 +563,7 @@ 'Request forbidden -- authorization will not help'), 404: ('Not Found', 'Nothing matches the given URI'), 405: ('Method Not Allowed', - 'Specified method is invalid for this server.'), + 'Specified method is invalid for this resource.'), 406: ('Not Acceptable', 'URI not available in preferred format.'), 407: ('Proxy Authentication Required', 'You must authenticate with ' 'this proxy before proceeding.'), Modified: python/branches/py3k-cdecimal/Lib/idlelib/PyShell.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/idlelib/PyShell.py (original) +++ python/branches/py3k-cdecimal/Lib/idlelib/PyShell.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import os import os.path @@ -347,7 +347,7 @@ rpcpid = None def spawn_subprocess(self): - if self.subprocess_arglist == None: + if self.subprocess_arglist is None: self.subprocess_arglist = self.build_subprocess_arglist() args = self.subprocess_arglist self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args) Modified: python/branches/py3k-cdecimal/Lib/inspect.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/inspect.py (original) +++ python/branches/py3k-cdecimal/Lib/inspect.py Thu Apr 1 11:38:52 2010 @@ -17,7 +17,7 @@ getmodule() - determine the module that an object came from getclasstree() - arrange classes so as to represent their hierarchy - getargspec(), getargvalues() - get info about function arguments + getargspec(), getargvalues(), getcallargs() - get info about function arguments getfullargspec() - same, with support for Python-3000 features formatargspec(), formatargvalues() - format an argument spec getouterframes(), getinnerframes() - get info about frames @@ -33,6 +33,7 @@ import sys import os import types +import itertools import string import re import dis @@ -926,6 +927,71 @@ specs.append(formatvarkw(varkw) + formatvalue(locals[varkw])) return '(' + ', '.join(specs) + ')' +def getcallargs(func, *positional, **named): + """Get the mapping of arguments to values. + + A dict is returned, with keys the function argument names (including the + names of the * and ** arguments, if any), and values the respective bound + values from 'positional' and 'named'.""" + spec = getfullargspec(func) + args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = spec + f_name = func.__name__ + arg2value = {} + + if ismethod(func) and func.__self__ is not None: + # implicit 'self' (or 'cls' for classmethods) argument + positional = (func.__self__,) + positional + num_pos = len(positional) + num_total = num_pos + len(named) + num_args = len(args) + num_defaults = len(defaults) if defaults else 0 + for arg, value in zip(args, positional): + arg2value[arg] = value + if varargs: + if num_pos > num_args: + arg2value[varargs] = positional[-(num_pos-num_args):] + else: + arg2value[varargs] = () + elif 0 < num_args < num_pos: + raise TypeError('%s() takes %s %d %s (%d given)' % ( + f_name, 'at most' if defaults else 'exactly', num_args, + 'arguments' if num_args > 1 else 'argument', num_total)) + elif num_args == 0 and num_total: + raise TypeError('%s() takes no arguments (%d given)' % + (f_name, num_total)) + + for arg in itertools.chain(args, kwonlyargs): + if arg in named: + if arg in arg2value: + raise TypeError("%s() got multiple values for keyword " + "argument '%s'" % (f_name, arg)) + else: + arg2value[arg] = named.pop(arg) + for kwonlyarg in kwonlyargs: + if kwonlyarg not in arg2value: + try: + arg2value[kwonlyarg] = kwonlydefaults[kwonlyarg] + except KeyError: + raise TypeError("%s() needs keyword-only argument %s" % + (f_name, kwonlyarg)) + if defaults: # fill in any missing values with the defaults + for arg, value in zip(args[-num_defaults:], defaults): + if arg not in arg2value: + arg2value[arg] = value + if varkw: + arg2value[varkw] = named + elif named: + unexpected = next(iter(named)) + raise TypeError("%s() got an unexpected keyword argument '%s'" % + (f_name, unexpected)) + unassigned = num_args - len([arg for arg in args if arg in arg2value]) + if unassigned: + num_required = num_args - num_defaults + raise TypeError('%s() takes %s %d %s (%d given)' % ( + f_name, 'at least' if defaults else 'exactly', num_required, + 'arguments' if num_required > 1 else 'argument', num_total)) + return arg2value + # -------------------------------------------------- stack frame extraction Traceback = namedtuple('Traceback', 'filename lineno function code_context index') Modified: python/branches/py3k-cdecimal/Lib/keyword.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/keyword.py (original) +++ python/branches/py3k-cdecimal/Lib/keyword.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Keywords (from "graminit.c") Modified: python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/token.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/token.py (original) +++ python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/token.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Token constants (from "token.h").""" Modified: python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/tokenize.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/tokenize.py (original) +++ python/branches/py3k-cdecimal/Lib/lib2to3/pgen2/tokenize.py Thu Apr 1 11:38:52 2010 @@ -253,14 +253,16 @@ in. It detects the encoding from the presence of a utf-8 bom or an encoding - cookie as specified in pep-0263. If both a bom and a cookie are present, - but disagree, a SyntaxError will be raised. If the encoding cookie is an - invalid charset, raise a SyntaxError. + cookie as specified in pep-0263. If both a bom and a cookie are present, but + disagree, a SyntaxError will be raised. If the encoding cookie is an invalid + charset, raise a SyntaxError. Note that if a utf-8 bom is found, + 'utf-8-sig' is returned. If no encoding is specified, then the default of 'utf-8' will be returned. """ bom_found = False encoding = None + default = 'utf-8' def read_or_stop(): try: return readline() @@ -287,17 +289,16 @@ if codec.name != 'utf-8': # This behaviour mimics the Python interpreter raise SyntaxError('encoding problem: utf-8') - else: - # Allow it to be properly encoded and decoded. - encoding = 'utf-8-sig' + encoding += '-sig' return encoding first = read_or_stop() if first.startswith(BOM_UTF8): bom_found = True first = first[3:] + default = 'utf-8-sig' if not first: - return 'utf-8', [] + return default, [] encoding = find_cookie(first) if encoding: @@ -305,13 +306,13 @@ second = read_or_stop() if not second: - return 'utf-8', [first] + return default, [first] encoding = find_cookie(second) if encoding: return encoding, [first, second] - return 'utf-8', [first, second] + return default, [first, second] def untokenize(iterable): """Transform tokens back into Python source code. Modified: python/branches/py3k-cdecimal/Lib/lib2to3/tests/pytree_idempotency.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/lib2to3/tests/pytree_idempotency.py (original) +++ python/branches/py3k-cdecimal/Lib/lib2to3/tests/pytree_idempotency.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. Modified: python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_fixers.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_fixers.py (original) +++ python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_fixers.py Thu Apr 1 11:38:52 2010 @@ -4285,3 +4285,91 @@ def test_bare_sequenceIncludes(self): s = "sequenceIncludes(x, y)" self.warns_unchanged(s, "You should use operator.contains here.") + + +class Test_exitfunc(FixerTestCase): + + fixer = "exitfunc" + + def test_simple(self): + b = """ + import sys + sys.exitfunc = my_atexit + """ + a = """ + import sys + import atexit + atexit.register(my_atexit) + """ + self.check(b, a) + + def test_names_import(self): + b = """ + import sys, crumbs + sys.exitfunc = my_func + """ + a = """ + import sys, crumbs, atexit + atexit.register(my_func) + """ + self.check(b, a) + + def test_complex_expression(self): + b = """ + import sys + sys.exitfunc = do(d)/a()+complex(f=23, g=23)*expression + """ + a = """ + import sys + import atexit + atexit.register(do(d)/a()+complex(f=23, g=23)*expression) + """ + self.check(b, a) + + def test_comments(self): + b = """ + import sys # Foo + sys.exitfunc = f # Blah + """ + a = """ + import sys + import atexit # Foo + atexit.register(f) # Blah + """ + self.check(b, a) + + b = """ + import apples, sys, crumbs, larry # Pleasant comments + sys.exitfunc = func + """ + a = """ + import apples, sys, crumbs, larry, atexit # Pleasant comments + atexit.register(func) + """ + self.check(b, a) + + def test_in_a_function(self): + b = """ + import sys + def f(): + sys.exitfunc = func + """ + a = """ + import sys + import atexit + def f(): + atexit.register(func) + """ + self.check(b, a) + + def test_no_sys_import(self): + b = """sys.exitfunc = f""" + a = """atexit.register(f)""" + msg = ("Can't find sys import; Please add an atexit import at the " + "top of your file.") + self.warns(b, a, msg) + + + def test_unchanged(self): + s = """f(sys.exitfunc)""" + self.unchanged(s) Modified: python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_parser.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_parser.py (original) +++ python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_parser.py Thu Apr 1 11:38:52 2010 @@ -206,6 +206,7 @@ finally: f.close() try: - return os.system("diff -u %r @" % fn) + fn = fn.replace('"', '\\"') + return os.system('diff -u "%s" @' % fn) finally: os.remove("@") Modified: python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py (original) +++ python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py Thu Apr 1 11:38:52 2010 @@ -242,21 +242,19 @@ def test_refactor_docstring(self): rt = self.rt() - def example(): - """ - >>> example() - 42 - """ - out = rt.refactor_docstring(example.__doc__, "") - self.assertEqual(out, example.__doc__) + doc = """ +>>> example() +42 +""" + out = rt.refactor_docstring(doc, "") + self.assertEqual(out, doc) - def parrot(): - """ - >>> def parrot(): - ... return 43 - """ - out = rt.refactor_docstring(parrot.__doc__, "") - self.assertNotEqual(out, parrot.__doc__) + doc = """ +>>> def parrot(): +... return 43 +""" + out = rt.refactor_docstring(doc, "") + self.assertNotEqual(out, doc) def test_explicit(self): from myfixes.fix_explicit import FixExplicit Modified: python/branches/py3k-cdecimal/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/logging/__init__.py (original) +++ python/branches/py3k-cdecimal/Lib/logging/__init__.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -46,8 +46,8 @@ __author__ = "Vinay Sajip " __status__ = "production" -__version__ = "0.5.1.1" -__date__ = "25 November 2009" +__version__ = "0.5.1.2" +__date__ = "07 February 2010" #--------------------------------------------------------------------------- # Miscellaneous module data @@ -432,6 +432,12 @@ s = s[:-1] return s + def usesTime(self): + """ + Check if the format uses the creation time of the record. + """ + return self._fmt.find("%(asctime)") >= 0 + def format(self, record): """ Format the specified record as text. @@ -440,13 +446,13 @@ string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed - using LogRecord.getMessage(). If the formatting string contains - "%(asctime)", formatTime() is called to format the event time. - If there is exception information, it is formatted using - formatException() and appended to the message. + using LogRecord.getMessage(). If the formatting string uses the + time (as determined by a call to usesTime(), formatTime() is + called to format the event time. If there is exception information, + it is formatted using formatException() and appended to the message. """ record.message = record.getMessage() - if self._fmt.find("%(asctime)") >= 0: + if self.usesTime(): record.asctime = self.formatTime(record, self.datefmt) s = self._fmt % record.__dict__ if record.exc_info: @@ -767,7 +773,10 @@ if raiseExceptions: ei = sys.exc_info() try: - traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) + traceback.print_exception(ei[0], ei[1], ei[2], + None, sys.stderr) + sys.stderr.write('Logged from file %s, line %s\n' % ( + record.filename, record.lineno)) except IOError: pass # see issue 5971 finally: @@ -960,6 +969,7 @@ self.disable = 0 self.emittedNoHandlerWarning = 0 self.loggerDict = {} + self.loggerClass = None def getLogger(self, name): """ @@ -979,13 +989,13 @@ rv = self.loggerDict[name] if isinstance(rv, PlaceHolder): ph = rv - rv = _loggerClass(name) + rv = (self.loggerClass or _loggerClass)(name) rv.manager = self self.loggerDict[name] = rv self._fixupChildren(ph, rv) self._fixupParents(rv) else: - rv = _loggerClass(name) + rv = (self.loggerClass or _loggerClass)(name) rv.manager = self self.loggerDict[name] = rv self._fixupParents(rv) @@ -993,6 +1003,16 @@ _releaseLock() return rv + def setLoggerClass(self, klass): + """ + Set the class to be used when instantiating a logger with this Manager. + """ + if klass != Logger: + if not issubclass(klass, Logger): + raise TypeError("logger not derived from logging.Logger: " + + klass.__name__) + self.loggerClass = klass + def _fixupParents(self, alogger): """ Ensure that there are either loggers or placeholders all the way @@ -1535,7 +1555,7 @@ def disable(level): """ - Disable all logging calls less severe than 'level'. + Disable all logging calls of severity 'level' and below. """ root.manager.disable = level Modified: python/branches/py3k-cdecimal/Lib/logging/config.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/logging/config.py (original) +++ python/branches/py3k-cdecimal/Lib/logging/config.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -19,12 +19,13 @@ is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. -Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, socket, struct, os, traceback +import sys, logging, logging.handlers, socket, struct, os, traceback, re +import types, io try: import _thread as thread @@ -57,10 +58,6 @@ the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). - In versions of ConfigParser which have the readfp method [typically - shipped in 2.x versions of Python], you can pass in a file-like object - rather than a filename, in which case the file-like object will be read - using readfp. """ import configparser @@ -264,6 +261,511 @@ logger.disabled = 1 +IDENTIFIER = re.compile('^[a-z_][a-z0-9_]*$', re.I) + + +def valid_ident(s): + m = IDENTIFIER.match(s) + if not m: + raise ValueError('Not a valid Python identifier: %r' % s) + return True + + +# The ConvertingXXX classes are wrappers around standard Python containers, +# and they serve to convert any suitable values in the container. The +# conversion converts base dicts, lists and tuples to their wrapped +# equivalents, whereas strings which match a conversion format are converted +# appropriately. +# +# Each wrapper should have a configurator attribute holding the actual +# configurator to use for conversion. + +class ConvertingDict(dict): + """A converting dictionary wrapper.""" + + def __getitem__(self, key): + value = dict.__getitem__(self, key) + result = self.configurator.convert(value) + #If the converted value is different, save for next time + if value is not result: + self[key] = result + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + + def get(self, key, default=None): + value = dict.get(self, key, default) + result = self.configurator.convert(value) + #If the converted value is different, save for next time + if value is not result: + self[key] = result + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + + def pop(self, key, default=None): + value = dict.pop(self, key, default) + result = self.configurator.convert(value) + if value is not result: + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + +class ConvertingList(list): + """A converting list wrapper.""" + def __getitem__(self, key): + value = list.__getitem__(self, key) + result = self.configurator.convert(value) + #If the converted value is different, save for next time + if value is not result: + self[key] = result + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + + def pop(self, idx=-1): + value = list.pop(self, idx) + result = self.configurator.convert(value) + if value is not result: + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + return result + +class ConvertingTuple(tuple): + """A converting tuple wrapper.""" + def __getitem__(self, key): + value = tuple.__getitem__(self, key) + result = self.configurator.convert(value) + if value is not result: + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + +class BaseConfigurator(object): + """ + The configurator base class which defines some useful defaults. + """ + + CONVERT_PATTERN = re.compile(r'^(?P[a-z]+)://(?P.*)$') + + WORD_PATTERN = re.compile(r'^\s*(\w+)\s*') + DOT_PATTERN = re.compile(r'^\.\s*(\w+)\s*') + INDEX_PATTERN = re.compile(r'^\[\s*(\w+)\s*\]\s*') + DIGIT_PATTERN = re.compile(r'^\d+$') + + value_converters = { + 'ext' : 'ext_convert', + 'cfg' : 'cfg_convert', + } + + # We might want to use a different one, e.g. importlib + importer = __import__ + + def __init__(self, config): + self.config = ConvertingDict(config) + self.config.configurator = self + + def resolve(self, s): + """ + Resolve strings to objects using standard import and attribute + syntax. + """ + name = s.split('.') + used = name.pop(0) + found = self.importer(used) + for frag in name: + used += '.' + frag + try: + found = getattr(found, frag) + except AttributeError: + self.importer(used) + found = getattr(found, frag) + return found + + def ext_convert(self, value): + """Default converter for the ext:// protocol.""" + return self.resolve(value) + + def cfg_convert(self, value): + """Default converter for the cfg:// protocol.""" + rest = value + m = self.WORD_PATTERN.match(rest) + if m is None: + raise ValueError("Unable to convert %r" % value) + else: + rest = rest[m.end():] + d = self.config[m.groups()[0]] + #print d, rest + while rest: + m = self.DOT_PATTERN.match(rest) + if m: + d = d[m.groups()[0]] + else: + m = self.INDEX_PATTERN.match(rest) + if m: + idx = m.groups()[0] + if not self.DIGIT_PATTERN.match(idx): + d = d[idx] + else: + try: + n = int(idx) # try as number first (most likely) + d = d[n] + except TypeError: + d = d[idx] + if m: + rest = rest[m.end():] + else: + raise ValueError('Unable to convert ' + '%r at %r' % (value, rest)) + #rest should be empty + return d + + def convert(self, value): + """ + Convert values to an appropriate type. dicts, lists and tuples are + replaced by their converting alternatives. Strings are checked to + see if they have a conversion format and are converted if they do. + """ + if not isinstance(value, ConvertingDict) and isinstance(value, dict): + value = ConvertingDict(value) + value.configurator = self + elif not isinstance(value, ConvertingList) and isinstance(value, list): + value = ConvertingList(value) + value.configurator = self + elif not isinstance(value, ConvertingTuple) and\ + isinstance(value, tuple): + value = ConvertingTuple(value) + value.configurator = self + elif isinstance(value, str): # str for py3k + m = self.CONVERT_PATTERN.match(value) + if m: + d = m.groupdict() + prefix = d['prefix'] + converter = self.value_converters.get(prefix, None) + if converter: + suffix = d['suffix'] + converter = getattr(self, converter) + value = converter(suffix) + return value + + def configure_custom(self, config): + """Configure an object with a user-supplied factory.""" + c = config.pop('()') + if not hasattr(c, '__call__'): + c = self.resolve(c) + props = config.pop('.', None) + # Check for valid identifiers + kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) + result = c(**kwargs) + if props: + for name, value in props.items(): + setattr(result, name, value) + return result + + def as_tuple(self, value): + """Utility function which converts lists to tuples.""" + if isinstance(value, list): + value = tuple(value) + return value + +class DictConfigurator(BaseConfigurator): + """ + Configure logging using a dictionary-like object to describe the + configuration. + """ + + def configure(self): + """Do the configuration.""" + + config = self.config + if 'version' not in config: + raise ValueError("dictionary doesn't specify a version") + if config['version'] != 1: + raise ValueError("Unsupported version: %s" % config['version']) + incremental = config.pop('incremental', False) + EMPTY_DICT = {} + logging._acquireLock() + try: + if incremental: + handlers = config.get('handlers', EMPTY_DICT) + for name in handlers: + if name not in logging._handlers: + raise ValueError('No handler found with ' + 'name %r' % name) + else: + try: + handler = logging._handlers[name] + handler_config = handlers[name] + level = handler_config.get('level', None) + if level: + handler.setLevel(logging._checkLevel(level)) + except Exception as e: + raise ValueError('Unable to configure handler ' + '%r: %s' % (name, e)) + loggers = config.get('loggers', EMPTY_DICT) + for name in loggers: + try: + self.configure_logger(name, loggers[name], True) + except Exception as e: + raise ValueError('Unable to configure logger ' + '%r: %s' % (name, e)) + root = config.get('root', None) + if root: + try: + self.configure_root(root, True) + except Exception as e: + raise ValueError('Unable to configure root ' + 'logger: %s' % e) + else: + disable_existing = config.pop('disable_existing_loggers', True) + + logging._handlers.clear() + del logging._handlerList[:] + + # Do formatters first - they don't refer to anything else + formatters = config.get('formatters', EMPTY_DICT) + for name in formatters: + try: + formatters[name] = self.configure_formatter( + formatters[name]) + except Exception as e: + raise ValueError('Unable to configure ' + 'formatter %r: %s' % (name, e)) + # Next, do filters - they don't refer to anything else, either + filters = config.get('filters', EMPTY_DICT) + for name in filters: + try: + filters[name] = self.configure_filter(filters[name]) + except Exception as e: + raise ValueError('Unable to configure ' + 'filter %r: %s' % (name, e)) + + # Next, do handlers - they refer to formatters and filters + # As handlers can refer to other handlers, sort the keys + # to allow a deterministic order of configuration + handlers = config.get('handlers', EMPTY_DICT) + for name in sorted(handlers): + try: + handler = self.configure_handler(handlers[name]) + handler.name = name + handlers[name] = handler + except Exception as e: + raise ValueError('Unable to configure handler ' + '%r: %s' % (name, e)) + # Next, do loggers - they refer to handlers and filters + + #we don't want to lose the existing loggers, + #since other threads may have pointers to them. + #existing is set to contain all existing loggers, + #and as we go through the new configuration we + #remove any which are configured. At the end, + #what's left in existing is the set of loggers + #which were in the previous configuration but + #which are not in the new configuration. + root = logging.root + existing = list(root.manager.loggerDict.keys()) + #The list needs to be sorted so that we can + #avoid disabling child loggers of explicitly + #named loggers. With a sorted list it is easier + #to find the child loggers. + existing.sort() + #We'll keep the list of existing loggers + #which are children of named loggers here... + child_loggers = [] + #now set up the new ones... + loggers = config.get('loggers', EMPTY_DICT) + for name in loggers: + if name in existing: + i = existing.index(name) + prefixed = name + "." + pflen = len(prefixed) + num_existing = len(existing) + i = i + 1 # look at the entry after name + while (i < num_existing) and\ + (existing[i][:pflen] == prefixed): + child_loggers.append(existing[i]) + i = i + 1 + existing.remove(name) + try: + self.configure_logger(name, loggers[name]) + except Exception as e: + raise ValueError('Unable to configure logger ' + '%r: %s' % (name, e)) + + #Disable any old loggers. There's no point deleting + #them as other threads may continue to hold references + #and by disabling them, you stop them doing any logging. + #However, don't disable children of named loggers, as that's + #probably not what was intended by the user. + for log in existing: + logger = root.manager.loggerDict[log] + if log in child_loggers: + logger.level = logging.NOTSET + logger.handlers = [] + logger.propagate = True + elif disable_existing: + logger.disabled = True + + # And finally, do the root logger + root = config.get('root', None) + if root: + try: + self.configure_root(root) + except Exception as e: + raise ValueError('Unable to configure root ' + 'logger: %s' % e) + finally: + logging._releaseLock() + + def configure_formatter(self, config): + """Configure a formatter from a dictionary.""" + if '()' in config: + factory = config['()'] # for use in exception handler + try: + result = self.configure_custom(config) + except TypeError as te: + if "'format'" not in str(te): + raise + #Name of parameter changed from fmt to format. + #Retry with old name. + #This is so that code can be used with older Python versions + #(e.g. by Django) + config['fmt'] = config.pop('format') + config['()'] = factory + result = self.configure_custom(config) + else: + fmt = config.get('format', None) + dfmt = config.get('datefmt', None) + result = logging.Formatter(fmt, dfmt) + return result + + def configure_filter(self, config): + """Configure a filter from a dictionary.""" + if '()' in config: + result = self.configure_custom(config) + else: + name = config.get('name', '') + result = logging.Filter(name) + return result + + def add_filters(self, filterer, filters): + """Add filters to a filterer from a list of names.""" + for f in filters: + try: + filterer.addFilter(self.config['filters'][f]) + except Exception as e: + raise ValueError('Unable to add filter %r: %s' % (f, e)) + + def configure_handler(self, config): + """Configure a handler from a dictionary.""" + formatter = config.pop('formatter', None) + if formatter: + try: + formatter = self.config['formatters'][formatter] + except Exception as e: + raise ValueError('Unable to set formatter ' + '%r: %s' % (formatter, e)) + level = config.pop('level', None) + filters = config.pop('filters', None) + if '()' in config: + c = config.pop('()') + if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType: + c = self.resolve(c) + factory = c + else: + klass = self.resolve(config.pop('class')) + #Special case for handler which refers to another handler + if issubclass(klass, logging.handlers.MemoryHandler) and\ + 'target' in config: + try: + config['target'] = self.config['handlers'][config['target']] + except Exception as e: + raise ValueError('Unable to set target handler ' + '%r: %s' % (config['target'], e)) + elif issubclass(klass, logging.handlers.SMTPHandler) and\ + 'mailhost' in config: + config['mailhost'] = self.as_tuple(config['mailhost']) + elif issubclass(klass, logging.handlers.SysLogHandler) and\ + 'address' in config: + config['address'] = self.as_tuple(config['address']) + factory = klass + kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) + try: + result = factory(**kwargs) + except TypeError as te: + if "'stream'" not in str(te): + raise + #The argument name changed from strm to stream + #Retry with old name. + #This is so that code can be used with older Python versions + #(e.g. by Django) + kwargs['strm'] = kwargs.pop('stream') + result = factory(**kwargs) + if formatter: + result.setFormatter(formatter) + if level is not None: + result.setLevel(logging._checkLevel(level)) + if filters: + self.add_filters(result, filters) + return result + + def add_handlers(self, logger, handlers): + """Add handlers to a logger from a list of names.""" + for h in handlers: + try: + logger.addHandler(self.config['handlers'][h]) + except Exception as e: + raise ValueError('Unable to add handler %r: %s' % (h, e)) + + def common_logger_config(self, logger, config, incremental=False): + """ + Perform configuration which is common to root and non-root loggers. + """ + level = config.get('level', None) + if level is not None: + logger.setLevel(logging._checkLevel(level)) + if not incremental: + #Remove any existing handlers + for h in logger.handlers[:]: + logger.removeHandler(h) + handlers = config.get('handlers', None) + if handlers: + self.add_handlers(logger, handlers) + filters = config.get('filters', None) + if filters: + self.add_filters(logger, filters) + + def configure_logger(self, name, config, incremental=False): + """Configure a non-root logger from a dictionary.""" + logger = logging.getLogger(name) + self.common_logger_config(logger, config, incremental) + propagate = config.get('propagate', None) + if propagate is not None: + logger.propagate = propagate + + def configure_root(self, config, incremental=False): + """Configure a root logger from a dictionary.""" + root = logging.getLogger() + self.common_logger_config(root, config, incremental) + +dictConfigClass = DictConfigurator + +def dictConfig(config): + """Configure logging using a dictionary.""" + dictConfigClass(config).configure() + + def listen(port=DEFAULT_LOGGING_CONFIG_PORT): """ Start up a socket server on the specified port, and listen for new @@ -301,24 +803,26 @@ chunk = self.connection.recv(slen) while len(chunk) < slen: chunk = chunk + conn.recv(slen - len(chunk)) - #Apply new configuration. We'd like to be able to - #create a StringIO and pass that in, but unfortunately - #1.5.2 ConfigParser does not support reading file - #objects, only actual files. So we create a temporary - #file and remove it later. - file = tempfile.mktemp(".ini") - f = open(file, "w") - f.write(chunk) - f.close() + chunk = chunk.decode("utf-8") try: - fileConfig(file) - except (KeyboardInterrupt, SystemExit): - raise + import json + d =json.loads(chunk) + assert isinstance(d, dict) + dictConfig(d) except: - traceback.print_exc() - os.remove(file) + #Apply new configuration. + + file = io.StringIO(chunk) + try: + fileConfig(file) + except (KeyboardInterrupt, SystemExit): + raise + except: + traceback.print_exc() + if self.server.ready: + self.server.ready.set() except socket.error as e: - if not isinstancetype(e.args, tuple): + if not isinstance(e.args, tuple): raise else: errcode = e.args[0] @@ -333,12 +837,13 @@ allow_reuse_address = 1 def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT, - handler=None): + handler=None, ready=None): ThreadingTCPServer.__init__(self, (host, port), handler) logging._acquireLock() self.abort = 0 logging._releaseLock() self.timeout = 1 + self.ready = ready def serve_until_stopped(self): import select @@ -353,17 +858,26 @@ abort = self.abort logging._releaseLock() - def serve(rcvr, hdlr, port): - server = rcvr(port=port, handler=hdlr) - global _listener - logging._acquireLock() - _listener = server - logging._releaseLock() - server.serve_until_stopped() + class Server(threading.Thread): + + def __init__(self, rcvr, hdlr, port): + super(Server, self).__init__() + self.rcvr = rcvr + self.hdlr = hdlr + self.port = port + self.ready = threading.Event() + + def run(self): + server = self.rcvr(port=self.port, handler=self.hdlr, + ready=self.ready) + self.ready.set() + global _listener + logging._acquireLock() + _listener = server + logging._releaseLock() + server.serve_until_stopped() - return threading.Thread(target=serve, - args=(ConfigSocketReceiver, - ConfigStreamHandler, port)) + return Server(ConfigSocketReceiver, ConfigStreamHandler, port) def stopListening(): """ Modified: python/branches/py3k-cdecimal/Lib/logging/handlers.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/logging/handlers.py (original) +++ python/branches/py3k-cdecimal/Lib/logging/handlers.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -19,13 +19,13 @@ based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. -Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. To use, simply 'import logging.handlers' and log away! """ import logging, socket, os, pickle, struct, time, re -from stat import ST_DEV, ST_INO +from stat import ST_DEV, ST_INO, ST_MTIME try: import codecs @@ -203,7 +203,11 @@ self.extMatch = re.compile(self.extMatch, re.ASCII) self.interval = self.interval * interval # multiply by units requested - self.rolloverAt = self.computeRollover(int(time.time())) + if os.path.exists(filename): + t = os.stat(filename)[ST_MTIME] + else: + t = int(time.time()) + self.rolloverAt = self.computeRollover(t) def computeRollover(self, currentTime): """ @@ -844,24 +848,6 @@ """ return self.subject - weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] - - monthname = [None, - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] - - def date_time(self): - """ - Return the current date and time formatted for a MIME header. - Needed for Python 1.5.2 (no email package available) - """ - year, month, day, hh, mm, ss, wd, y, z = time.gmtime(time.time()) - s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( - self.weekdayname[wd], - day, self.monthname[month], year, - hh, mm, ss) - return s - def emit(self, record): """ Emit a record. @@ -870,10 +856,7 @@ """ try: import smtplib - try: - from email.utils import formatdate - except ImportError: - formatdate = self.date_time + from email.utils import formatdate port = self.mailport if not port: port = smtplib.SMTP_PORT Modified: python/branches/py3k-cdecimal/Lib/macpath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/macpath.py (original) +++ python/branches/py3k-cdecimal/Lib/macpath.py Thu Apr 1 11:38:52 2010 @@ -172,7 +172,11 @@ def abspath(path): """Return an absolute path.""" if not isabs(path): - path = join(os.getcwd(), path) + if isinstance(path, bytes): + cwd = os.getcwdb() + else: + cwd = os.getcwd() + path = join(cwd, path) return normpath(path) # realpath is a no-op on systems without islink support @@ -189,7 +193,10 @@ path = components[0] + colon for c in components[1:]: path = join(path, c) - path = Carbon.File.FSResolveAliasFile(path, 1)[0].as_pathname() + try: + path = Carbon.File.FSResolveAliasFile(path, 1)[0].as_pathname() + except Carbon.File.Error: + pass return path supports_unicode_filenames = False Modified: python/branches/py3k-cdecimal/Lib/mailbox.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/mailbox.py (original) +++ python/branches/py3k-cdecimal/Lib/mailbox.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.""" @@ -882,17 +882,9 @@ raise KeyError('No message with key: %s' % key) else: raise - try: - if self._locked: - _lock_file(f) - try: - f.close() - os.remove(os.path.join(self._path, str(key))) - finally: - if self._locked: - _unlock_file(f) - finally: + else: f.close() + os.remove(path) def __setitem__(self, key, message): """Replace the keyed message; raise KeyError if it doesn't exist.""" Modified: python/branches/py3k-cdecimal/Lib/mimetypes.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/mimetypes.py (original) +++ python/branches/py3k-cdecimal/Lib/mimetypes.py Thu Apr 1 11:38:52 2010 @@ -538,7 +538,6 @@ if __name__ == '__main__': - import sys import getopt USAGE = """\ Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py (original) +++ python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py Thu Apr 1 11:38:52 2010 @@ -104,7 +104,12 @@ def poll(self, flag=os.WNOHANG): if self.returncode is None: - pid, sts = os.waitpid(self.pid, flag) + try: + pid, sts = os.waitpid(self.pid, flag) + except os.error: + # Child process not yet created. See #1731717 + # e.errno == errno.ECHILD == 10 + return None if pid == self.pid: if os.WIFSIGNALED(sts): self.returncode = -os.WTERMSIG(sts) Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py (original) +++ python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py Thu Apr 1 11:38:52 2010 @@ -448,12 +448,10 @@ if pool and hasattr(pool[0], 'terminate'): debug('joining pool workers') for p in pool: - p.join() - for w in pool: - if w.exitcode is None: + if p.is_alive(): # worker has not yet exited - debug('cleaning up worker %d' % w.pid) - w.join() + debug('cleaning up worker %d' % p.pid) + p.join() # # Class whose instances are returned by `Pool.apply_async()` Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/process.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/multiprocessing/process.py (original) +++ python/branches/py3k-cdecimal/Lib/multiprocessing/process.py Thu Apr 1 11:38:52 2010 @@ -179,7 +179,7 @@ @property def ident(self): ''' - Return indentifier (PID) of process or `None` if it has yet to start + Return identifier (PID) of process or `None` if it has yet to start ''' if self is _current_process: return os.getpid() Modified: python/branches/py3k-cdecimal/Lib/ntpath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/ntpath.py (original) +++ python/branches/py3k-cdecimal/Lib/ntpath.py Thu Apr 1 11:38:52 2010 @@ -561,6 +561,8 @@ path = _getfullpathname(path) except WindowsError: pass # Bad path - return unchanged. + elif isinstance(path, bytes): + path = os.getcwdb() else: path = os.getcwd() return normpath(path) Modified: python/branches/py3k-cdecimal/Lib/os.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/os.py (original) +++ python/branches/py3k-cdecimal/Lib/os.py Thu Apr 1 11:38:52 2010 @@ -342,28 +342,23 @@ def _execvpe(file, args, env=None): if env is not None: - func = execve + exec_func = execve argrest = (args, env) else: - func = execv + exec_func = execv argrest = (args,) env = environ head, tail = path.split(file) if head: - func(file, *argrest) + exec_func(file, *argrest) return - if 'PATH' in env: - envpath = env['PATH'] - else: - envpath = defpath - PATH = envpath.split(pathsep) last_exc = saved_exc = None saved_tb = None - for dir in PATH: + for dir in get_exec_path(env): fullname = path.join(dir, file) try: - func(fullname, *argrest) + exec_func(fullname, *argrest) except error as e: last_exc = e tb = sys.exc_info()[2] @@ -376,6 +371,18 @@ raise last_exc.with_traceback(tb) +def get_exec_path(env=None): + """Returns the sequence of directories that will be searched for the + named executable (similar to a shell) when launching a process. + + *env* must be an environment variable dict or None. If *env* is None, + os.environ will be used. + """ + if env is None: + env = environ + return env.get('PATH', defpath).split(pathsep) + + # Change environ to automatically call putenv(), unsetenv if they exist. from _abcoll import MutableMapping # Can't use collections (bootstrap) @@ -387,22 +394,32 @@ self.data = data = {} for key, value in environ.items(): data[keymap(key)] = str(value) + def __getitem__(self, key): return self.data[self.keymap(key)] + def __setitem__(self, key, value): value = str(value) self.putenv(key, value) self.data[self.keymap(key)] = value + def __delitem__(self, key): self.unsetenv(key) del self.data[self.keymap(key)] + def __iter__(self): for key in self.data: yield key + def __len__(self): return len(self.data) + + def __repr__(self): + return 'environ({!r})'.format(self.data) + def copy(self): return dict(self) + def setdefault(self, key, value): if key not in self: self[key] = value Modified: python/branches/py3k-cdecimal/Lib/pdb.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/pdb.py (original) +++ python/branches/py3k-cdecimal/Lib/pdb.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """A Python debugger.""" Modified: python/branches/py3k-cdecimal/Lib/pipes.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/pipes.py (original) +++ python/branches/py3k-cdecimal/Lib/pipes.py Thu Apr 1 11:38:52 2010 @@ -253,10 +253,13 @@ _funnychars = '"`$\\' # Unsafe inside "double quotes" def quote(file): + ''' return a shell-escaped version of the file string ''' for c in file: if c not in _safechars: break else: + if not file: + return "''" return file if '\'' not in file: return '\'' + file + '\'' Modified: python/branches/py3k-cdecimal/Lib/platform.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/platform.py (original) +++ python/branches/py3k-cdecimal/Lib/platform.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ This module tries to retrieve as much platform-identifying data as possible. It makes this information available via function APIs. @@ -1103,7 +1103,11 @@ # http://support.microsoft.com/kb/888731 and # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM if not machine: - machine = os.environ.get('PROCESSOR_ARCHITECTURE', '') + # WOW64 processes mask the native architecture + if "PROCESSOR_ARCHITEW6432" in os.environ: + machine = os.environ.get("PROCESSOR_ARCHITEW6432", '') + else: + machine = os.environ.get('PROCESSOR_ARCHITECTURE', '') if not processor: processor = os.environ.get('PROCESSOR_IDENTIFIER', machine) Modified: python/branches/py3k-cdecimal/Lib/posixpath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/posixpath.py (original) +++ python/branches/py3k-cdecimal/Lib/posixpath.py Thu Apr 1 11:38:52 2010 @@ -158,7 +158,7 @@ def lexists(path): """Test whether a path exists. Returns True for broken symbolic links""" try: - st = os.lstat(path) + os.lstat(path) except os.error: return False return True Modified: python/branches/py3k-cdecimal/Lib/profile.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/profile.py (original) +++ python/branches/py3k-cdecimal/Lib/profile.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # # Class for profiling python code. rev 1.0 6/2/94 # @@ -602,11 +602,8 @@ if (len(args) > 0): sys.argv[:] = args sys.path.insert(0, os.path.dirname(sys.argv[0])) - fp = open(sys.argv[0]) - try: + with open(sys.argv[0], 'rb') as fp: script = fp.read() - finally: - fp.close() run('exec(%r)' % script, options.outfile, options.sort) else: parser.print_usage() Modified: python/branches/py3k-cdecimal/Lib/py_compile.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/py_compile.py (original) +++ python/branches/py3k-cdecimal/Lib/py_compile.py Thu Apr 1 11:38:52 2010 @@ -7,8 +7,8 @@ import imp import marshal import os -import re import sys +import tokenize import traceback MAGIC = imp.get_magic() @@ -62,15 +62,6 @@ return self.msg -# Define an internal helper according to the platform -if os.name == "mac": - import MacOS - def set_creator_type(file): - MacOS.SetCreatorAndType(file, 'Pyth', 'PYC ') -else: - def set_creator_type(file): - pass - def wr_long(f, x): """Internal; write a 32-bit int to a file in little-endian order.""" f.write(bytes([x & 0xff, @@ -78,21 +69,6 @@ (x >> 16) & 0xff, (x >> 24) & 0xff])) -def read_encoding(file, default): - """Read the first two lines of the file looking for coding: xyzzy.""" - f = open(file, "rb") - try: - for i in range(2): - line = f.readline() - if not line: - break - m = re.match(br".*\bcoding:\s*(\S+)\b", line) - if m: - return m.group(1).decode("ascii") - return default - finally: - f.close() - def compile(file, cfile=None, dfile=None, doraise=False): """Byte-compile one Python source file to Python bytecode. @@ -128,16 +104,14 @@ directories). """ - encoding = read_encoding(file, "utf-8") - f = open(file, 'U', encoding=encoding) - try: - timestamp = int(os.fstat(f.fileno()).st_mtime) - except AttributeError: - timestamp = int(os.stat(file).st_mtime) - codestring = f.read() - f.close() - if codestring and codestring[-1] != '\n': - codestring = codestring + '\n' + with open(file, "rb") as f: + encoding = tokenize.detect_encoding(f.readline)[0] + with open(file, encoding=encoding) as f: + try: + timestamp = int(os.fstat(f.fileno()).st_mtime) + except AttributeError: + timestamp = int(os.stat(file).st_mtime) + codestring = f.read() try: codeobject = builtins.compile(codestring, dfile or file,'exec') except Exception as err: @@ -149,15 +123,13 @@ return if cfile is None: cfile = file + (__debug__ and 'c' or 'o') - fc = open(cfile, 'wb') - fc.write(b'\0\0\0\0') - wr_long(fc, timestamp) - marshal.dump(codeobject, fc) - fc.flush() - fc.seek(0, 0) - fc.write(MAGIC) - fc.close() - set_creator_type(cfile) + with open(cfile, 'wb') as fc: + fc.write(b'\0\0\0\0') + wr_long(fc, timestamp) + marshal.dump(codeobject, fc) + fc.flush() + fc.seek(0, 0) + fc.write(MAGIC) def main(args=None): """Compile several source files. @@ -166,19 +138,35 @@ not specified) are compiled and the resulting bytecode is cached in the normal manner. This function does not search a directory structure to locate source files; it only compiles files named - explicitly. + explicitly. If '-' is the only parameter in args, the list of + files is taken from standard input. """ if args is None: args = sys.argv[1:] rv = 0 - for filename in args: - try: - compile(filename, doraise=True) - except PyCompileError as err: - # return value to indicate at least one failure - rv = 1 - sys.stderr.write(err.msg) + if args == ['-']: + while True: + filename = sys.stdin.readline() + if not filename: + break + filename = filename.rstrip('\n') + try: + compile(filename, doraise=True) + except PyCompileError as error: + rv = 1 + sys.stderr.write("%s\n" % error.msg) + except IOError as error: + rv = 1 + sys.stderr.write("%s\n" % error) + else: + for filename in args: + try: + compile(filename, doraise=True) + except PyCompileError as err: + # return value to indicate at least one failure + rv = 1 + sys.stderr.write(error.msg) return rv if __name__ == "__main__": Modified: python/branches/py3k-cdecimal/Lib/pydoc.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/pydoc.py (original) +++ python/branches/py3k-cdecimal/Lib/pydoc.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: latin-1 -*- """Generate Python documentation in HTML or text for interactive use. @@ -349,7 +349,8 @@ 'marshal', 'posix', 'signal', 'sys', '_thread', 'zipimport') or (file.startswith(basedir) and - not file.startswith(os.path.join(basedir, 'site-packages'))))): + not file.startswith(os.path.join(basedir, 'site-packages')))) and + object.__name__ not in ('xml.etree', 'test.pydoc_mod')): if docloc.startswith("http://"): docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__) else: Modified: python/branches/py3k-cdecimal/Lib/quopri.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/quopri.py (original) +++ python/branches/py3k-cdecimal/Lib/quopri.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Conversions to/from quoted-printable transport encoding as per RFC 1521.""" Modified: python/branches/py3k-cdecimal/Lib/shutil.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/shutil.py (original) +++ python/branches/py3k-cdecimal/Lib/shutil.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -"""Utility functions for copying files and directory trees. +"""Utility functions for copying and archiving files and directory trees. XXX The functions here don't copy the resource fork or other metadata on Mac. @@ -9,9 +9,24 @@ import stat from os.path import abspath import fnmatch +from warnings import warn +import collections +import errno -__all__ = ["copyfileobj","copyfile","copymode","copystat","copy","copy2", - "copytree","move","rmtree","Error", "SpecialFileError"] +try: + from pwd import getpwnam +except ImportError: + getpwnam = None + +try: + from grp import getgrnam +except ImportError: + getgrnam = None + +__all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2", + "copytree", "move", "rmtree", "Error", "SpecialFileError", + "ExecError", "make_archive", "get_archive_formats", + "register_archive_format", "unregister_archive_format"] class Error(EnvironmentError): pass @@ -20,6 +35,9 @@ """Raised when trying to do a kind of operation (e.g. copying) which is not supported on a special file (e.g. a named pipe)""" +class ExecError(EnvironmentError): + """Raised when a command could not be executed""" + try: WindowsError except NameError: @@ -88,8 +106,11 @@ if hasattr(os, 'chmod'): os.chmod(dst, mode) if hasattr(os, 'chflags') and hasattr(st, 'st_flags'): - os.chflags(dst, st.st_flags) - + try: + os.chflags(dst, st.st_flags) + except OSError as why: + if not hasattr(errno, 'EOPNOTSUPP') or why.errno != errno.EOPNOTSUPP: + raise def copy(src, dst): """Copy data and mode bits ("cp src dst"). @@ -286,3 +307,265 @@ if not dst.endswith(os.path.sep): dst += os.path.sep return dst.startswith(src) + +def _get_gid(name): + """Returns a gid, given a group name.""" + if getgrnam is None or name is None: + return None + try: + result = getgrnam(name) + except KeyError: + result = None + if result is not None: + return result[2] + return None + +def _get_uid(name): + """Returns an uid, given a user name.""" + if getpwnam is None or name is None: + return None + try: + result = getpwnam(name) + except KeyError: + result = None + if result is not None: + return result[2] + return None + +def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, + owner=None, group=None, logger=None): + """Create a (possibly compressed) tar file from all the files under + 'base_dir'. + + 'compress' must be "gzip" (the default), "compress", "bzip2", or None. + (compress will be deprecated in Python 3.2) + + 'owner' and 'group' can be used to define an owner and a group for the + archive that is being built. If not provided, the current owner and group + will be used. + + The output tar file will be named 'base_dir' + ".tar", possibly plus + the appropriate compression extension (".gz", ".bz2" or ".Z"). + + Returns the output filename. + """ + tar_compression = {'gzip': 'gz', 'bzip2': 'bz2', None: '', 'compress': ''} + compress_ext = {'gzip': '.gz', 'bzip2': '.bz2', 'compress': '.Z'} + + # flags for compression program, each element of list will be an argument + if compress is not None and compress not in compress_ext.keys(): + raise ValueError("bad value for 'compress': must be None, 'gzip', " + "'bzip2' or 'compress'") + + archive_name = base_name + '.tar' + if compress != 'compress': + archive_name += compress_ext.get(compress, '') + + archive_dir = os.path.dirname(archive_name) + if not os.path.exists(archive_dir): + logger.info("creating %s" % archive_dir) + if not dry_run: + os.makedirs(archive_dir) + + + # creating the tarball + import tarfile # late import so Python build itself doesn't break + + if logger is not None: + logger.info('Creating tar archive') + + uid = _get_uid(owner) + gid = _get_gid(group) + + def _set_uid_gid(tarinfo): + if gid is not None: + tarinfo.gid = gid + tarinfo.gname = group + if uid is not None: + tarinfo.uid = uid + tarinfo.uname = owner + return tarinfo + + if not dry_run: + tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress]) + try: + tar.add(base_dir, filter=_set_uid_gid) + finally: + tar.close() + + # compression using `compress` + # XXX this block will be removed in Python 3.2 + if compress == 'compress': + warn("'compress' will be deprecated.", PendingDeprecationWarning) + # the option varies depending on the platform + compressed_name = archive_name + compress_ext[compress] + if sys.platform == 'win32': + cmd = [compress, archive_name, compressed_name] + else: + cmd = [compress, '-f', archive_name] + from distutils.spawn import spawn + spawn(cmd, dry_run=dry_run) + return compressed_name + + return archive_name + +def _call_external_zip(directory, verbose=False): + # XXX see if we want to keep an external call here + if verbose: + zipoptions = "-r" + else: + zipoptions = "-rq" + from distutils.errors import DistutilsExecError + from distutils.spawn import spawn + try: + spawn(["zip", zipoptions, zip_filename, base_dir], dry_run=dry_run) + except DistutilsExecError: + # XXX really should distinguish between "couldn't find + # external 'zip' command" and "zip failed". + raise ExecError("unable to create zip file '%s': " + "could neither import the 'zipfile' module nor " + "find a standalone zip utility") % zip_filename + +def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None): + """Create a zip file from all the files under 'base_dir'. + + The output zip file will be named 'base_dir' + ".zip". Uses either the + "zipfile" Python module (if available) or the InfoZIP "zip" utility + (if installed and found on the default search path). If neither tool is + available, raises ExecError. Returns the name of the output zip + file. + """ + zip_filename = base_name + ".zip" + archive_dir = os.path.dirname(base_name) + + if not os.path.exists(archive_dir): + if logger is not None: + logger.info("creating %s", archive_dir) + if not dry_run: + os.makedirs(archive_dir) + + # If zipfile module is not available, try spawning an external 'zip' + # command. + try: + import zipfile + except ImportError: + zipfile = None + + if zipfile is None: + _call_external_zip(base_dir, verbose) + else: + if logger is not None: + logger.info("creating '%s' and adding '%s' to it", + zip_filename, base_dir) + + if not dry_run: + zip = zipfile.ZipFile(zip_filename, "w", + compression=zipfile.ZIP_DEFLATED) + + for dirpath, dirnames, filenames in os.walk(base_dir): + for name in filenames: + path = os.path.normpath(os.path.join(dirpath, name)) + if os.path.isfile(path): + zip.write(path, path) + if logger is not None: + logger.info("adding '%s'", path) + zip.close() + + return zip_filename + +_ARCHIVE_FORMATS = { + 'gztar': (_make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"), + 'bztar': (_make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"), + 'ztar': (_make_tarball, [('compress', 'compress')], + "compressed tar file"), + 'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"), + 'zip': (_make_zipfile, [],"ZIP file") + } + +def get_archive_formats(): + """Returns a list of supported formats for archiving and unarchiving. + + Each element of the returned sequence is a tuple (name, description) + """ + formats = [(name, registry[2]) for name, registry in + _ARCHIVE_FORMATS.items()] + formats.sort() + return formats + +def register_archive_format(name, function, extra_args=None, description=''): + """Registers an archive format. + + name is the name of the format. function is the callable that will be + used to create archives. If provided, extra_args is a sequence of + (name, value) tuples that will be passed as arguments to the callable. + description can be provided to describe the format, and will be returned + by the get_archive_formats() function. + """ + if extra_args is None: + extra_args = [] + if not isinstance(function, collections.Callable): + raise TypeError('The %s object is not callable' % function) + if not isinstance(extra_args, (tuple, list)): + raise TypeError('extra_args needs to be a sequence') + for element in extra_args: + if not isinstance(element, (tuple, list)) or len(element) !=2 : + raise TypeError('extra_args elements are : (arg_name, value)') + + _ARCHIVE_FORMATS[name] = (function, extra_args, description) + +def unregister_archive_format(name): + del _ARCHIVE_FORMATS[name] + +def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, + dry_run=0, owner=None, group=None, logger=None): + """Create an archive file (eg. zip or tar). + + 'base_name' is the name of the file to create, minus any format-specific + extension; 'format' is the archive format: one of "zip", "tar", "ztar", + or "gztar". + + 'root_dir' is a directory that will be the root directory of the + archive; ie. we typically chdir into 'root_dir' before creating the + archive. 'base_dir' is the directory where we start archiving from; + ie. 'base_dir' will be the common prefix of all files and + directories in the archive. 'root_dir' and 'base_dir' both default + to the current directory. Returns the name of the archive file. + + 'owner' and 'group' are used when creating a tar archive. By default, + uses the current owner and group. + """ + save_cwd = os.getcwd() + if root_dir is not None: + if logger is not None: + logger.debug("changing into '%s'", root_dir) + base_name = os.path.abspath(base_name) + if not dry_run: + os.chdir(root_dir) + + if base_dir is None: + base_dir = os.curdir + + kwargs = {'dry_run': dry_run, 'logger': logger} + + try: + format_info = _ARCHIVE_FORMATS[format] + except KeyError: + raise ValueError("unknown archive format '%s'" % format) + + func = format_info[0] + for arg, val in format_info[1]: + kwargs[arg] = val + + if format != 'zip': + kwargs['owner'] = owner + kwargs['group'] = group + + try: + filename = func(base_name, base_dir, **kwargs) + finally: + if root_dir is not None: + if logger is not None: + logger.debug("changing back to '%s'", save_cwd) + os.chdir(save_cwd) + + return filename Modified: python/branches/py3k-cdecimal/Lib/site.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/site.py (original) +++ python/branches/py3k-cdecimal/Lib/site.py Thu Apr 1 11:38:52 2010 @@ -112,7 +112,7 @@ s = "build/lib.%s-%.3s" % (get_platform(), sys.version) if hasattr(sys, 'gettotalrefcount'): s += '-pydebug' - s = os.path.join(os.path.dirname(sys.path[-1]), s) + s = os.path.join(os.path.dirname(sys.path.pop()), s) sys.path.append(s) @@ -489,11 +489,12 @@ pass except Exception as err: if os.environ.get("PYTHONVERBOSE"): - raise - sys.stderr.write( - "Error in sitecustomize; set PYTHONVERBOSE for traceback:\n" - "%s: %s\n" % - (err.__class__.__name__, err)) + sys.excepthook(*sys.exc_info()) + else: + sys.stderr.write( + "Error in sitecustomize; set PYTHONVERBOSE for traceback:\n" + "%s: %s\n" % + (err.__class__.__name__, err)) def execusercustomize(): @@ -502,6 +503,14 @@ import usercustomize except ImportError: pass + except Exception as err: + if os.environ.get("PYTHONVERBOSE"): + sys.excepthook(*sys.exc_info()) + else: + sys.stderr.write( + "Error in usercustomize; set PYTHONVERBOSE for traceback:\n" + "%s: %s\n" % + (err.__class__.__name__, err)) def main(): Modified: python/branches/py3k-cdecimal/Lib/smtpd.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/smtpd.py (original) +++ python/branches/py3k-cdecimal/Lib/smtpd.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """An RFC 2821 smtp proxy. Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]] Modified: python/branches/py3k-cdecimal/Lib/smtplib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/smtplib.py (original) +++ python/branches/py3k-cdecimal/Lib/smtplib.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 '''SMTP/ESMTP client class. Modified: python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py (original) +++ python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py Thu Apr 1 11:38:52 2010 @@ -1,7 +1,7 @@ #-*- coding: ISO-8859-1 -*- # pysqlite2/test/dbapi.py: tests for DB-API compliance # -# Copyright (C) 2004-2007 Gerhard H?ring +# Copyright (C) 2004-2010 Gerhard H?ring # # This file is part of pysqlite. # @@ -653,13 +653,13 @@ res = cur.fetchone()[0] self.assertEqual(res, 5) - def CheckScriptErrorIncomplete(self): + def CheckScriptSyntaxError(self): con = sqlite.connect(":memory:") cur = con.cursor() raised = False try: - cur.executescript("create table test(sadfsadfdsa") - except sqlite.ProgrammingError: + cur.executescript("create table test(x); asdf; create table test2(x)") + except sqlite.OperationalError: raised = True self.assertEqual(raised, True, "should have raised an exception") @@ -692,7 +692,7 @@ result = con.execute("select foo from test").fetchone()[0] self.assertEqual(result, 5, "Basic test of Connection.executescript") -class ClosedTests(unittest.TestCase): +class ClosedConTests(unittest.TestCase): def setUp(self): pass @@ -744,6 +744,102 @@ except: self.fail("Should have raised a ProgrammingError") + def CheckClosedCreateFunction(self): + con = sqlite.connect(":memory:") + con.close() + def f(x): return 17 + try: + con.create_function("foo", 1, f) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedCreateAggregate(self): + con = sqlite.connect(":memory:") + con.close() + class Agg: + def __init__(self): + pass + def step(self, x): + pass + def finalize(self): + return 17 + try: + con.create_aggregate("foo", 1, Agg) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedSetAuthorizer(self): + con = sqlite.connect(":memory:") + con.close() + def authorizer(*args): + return sqlite.DENY + try: + con.set_authorizer(authorizer) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedSetProgressCallback(self): + con = sqlite.connect(":memory:") + con.close() + def progress(): pass + try: + con.set_progress_handler(progress, 100) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedCall(self): + con = sqlite.connect(":memory:") + con.close() + try: + con() + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + +class ClosedCurTests(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def CheckClosed(self): + con = sqlite.connect(":memory:") + cur = con.cursor() + cur.close() + + for method_name in ("execute", "executemany", "executescript", "fetchall", "fetchmany", "fetchone"): + if method_name in ("execute", "executescript"): + params = ("select 4 union select 5",) + elif method_name == "executemany": + params = ("insert into foo(bar) values (?)", [(3,), (4,)]) + else: + params = [] + + try: + method = getattr(cur, method_name) + + method(*params) + self.fail("Should have raised a ProgrammingError: method " + method_name) + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError: " + method_name) + def suite(): module_suite = unittest.makeSuite(ModuleTests, "Check") connection_suite = unittest.makeSuite(ConnectionTests, "Check") @@ -751,8 +847,9 @@ thread_suite = unittest.makeSuite(ThreadTests, "Check") constructor_suite = unittest.makeSuite(ConstructorTests, "Check") ext_suite = unittest.makeSuite(ExtensionTests, "Check") - closed_suite = unittest.makeSuite(ClosedTests, "Check") - return unittest.TestSuite((module_suite, connection_suite, cursor_suite, thread_suite, constructor_suite, ext_suite, closed_suite)) + closed_con_suite = unittest.makeSuite(ClosedConTests, "Check") + closed_cur_suite = unittest.makeSuite(ClosedCurTests, "Check") + return unittest.TestSuite((module_suite, connection_suite, cursor_suite, thread_suite, constructor_suite, ext_suite, closed_con_suite, closed_cur_suite)) def test(): runner = unittest.TextTestRunner() Modified: python/branches/py3k-cdecimal/Lib/sqlite3/test/regression.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/sqlite3/test/regression.py (original) +++ python/branches/py3k-cdecimal/Lib/sqlite3/test/regression.py Thu Apr 1 11:38:52 2010 @@ -1,7 +1,7 @@ #-*- coding: ISO-8859-1 -*- # pysqlite2/test/regression.py: pysqlite regression tests # -# Copyright (C) 2006 Gerhard H?ring +# Copyright (C) 2006-2010 Gerhard H?ring # # This file is part of pysqlite. # @@ -70,16 +70,6 @@ cur.execute('select 1 as "foo baz"') self.assertEqual(cur.description[0][0], "foo baz") - def CheckStatementAvailable(self): - # pysqlite up to 2.3.2 crashed on this, because the active statement handle was not checked - # before trying to fetch data from it. close() destroys the active statement ... - con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES) - cur = con.cursor() - cur.execute("select 4 union select 5") - cur.close() - cur.fetchone() - cur.fetchone() - def CheckStatementFinalizationOnCloseDb(self): # pysqlite versions <= 2.3.3 only finalized statements in the statement # cache when closing the database. statements that were still @@ -169,6 +159,25 @@ con = sqlite.connect(":memory:") setattr(con, "isolation_level", "\xe9") + def CheckCursorConstructorCallCheck(self): + """ + Verifies that cursor methods check wether base class __init__ was called. + """ + class Cursor(sqlite.Cursor): + def __init__(self, con): + pass + + con = sqlite.connect(":memory:") + cur = Cursor(con) + try: + cur.execute("select 4+5").fetchall() + self.fail("should have raised ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("should have raised ProgrammingError") + + def CheckStrSubclass(self): """ The Python 3.0 port of the module didn't cope with values of subclasses of str. @@ -176,6 +185,95 @@ class MyStr(str): pass self.con.execute("select ?", (MyStr("abc"),)) + def CheckConnectionConstructorCallCheck(self): + """ + Verifies that connection methods check wether base class __init__ was called. + """ + class Connection(sqlite.Connection): + def __init__(self, name): + pass + + con = Connection(":memory:") + try: + cur = con.cursor() + self.fail("should have raised ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("should have raised ProgrammingError") + + def CheckCursorRegistration(self): + """ + Verifies that subclassed cursor classes are correctly registered with + the connection object, too. (fetch-across-rollback problem) + """ + class Connection(sqlite.Connection): + def cursor(self): + return Cursor(self) + + class Cursor(sqlite.Cursor): + def __init__(self, con): + sqlite.Cursor.__init__(self, con) + + con = Connection(":memory:") + cur = con.cursor() + cur.execute("create table foo(x)") + cur.executemany("insert into foo(x) values (?)", [(3,), (4,), (5,)]) + cur.execute("select x from foo") + con.rollback() + try: + cur.fetchall() + self.fail("should have raised InterfaceError") + except sqlite.InterfaceError: + pass + except: + self.fail("should have raised InterfaceError") + + def CheckAutoCommit(self): + """ + Verifies that creating a connection in autocommit mode works. + 2.5.3 introduced a regression so that these could no longer + be created. + """ + con = sqlite.connect(":memory:", isolation_level=None) + + def CheckPragmaAutocommit(self): + """ + Verifies that running a PRAGMA statement that does an autocommit does + work. This did not work in 2.5.3/2.5.4. + """ + cur = self.con.cursor() + cur.execute("create table foo(bar)") + cur.execute("insert into foo(bar) values (5)") + + cur.execute("pragma page_size") + row = cur.fetchone() + + def CheckSetDict(self): + """ + See http://bugs.python.org/issue7478 + + It was possible to successfully register callbacks that could not be + hashed. Return codes of PyDict_SetItem were not checked properly. + """ + class NotHashable: + def __call__(self, *args, **kw): + pass + def __hash__(self): + raise TypeError() + var = NotHashable() + self.assertRaises(TypeError, self.con.create_function, var) + self.assertRaises(TypeError, self.con.create_aggregate, var) + self.assertRaises(TypeError, self.con.set_authorizer, var) + self.assertRaises(TypeError, self.con.set_progress_handler, var) + + def CheckConnectionCall(self): + """ + Call a connection with a non-string SQL request: check error handling + of the statement constructor. + """ + self.assertRaises(sqlite.Warning, self.con, 1) + def suite(): regression_suite = unittest.makeSuite(RegressionTests, "Check") return unittest.TestSuite((regression_suite,)) Modified: python/branches/py3k-cdecimal/Lib/sqlite3/test/transactions.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/sqlite3/test/transactions.py (original) +++ python/branches/py3k-cdecimal/Lib/sqlite3/test/transactions.py Thu Apr 1 11:38:52 2010 @@ -147,6 +147,26 @@ # NO self.con2.rollback() HERE!!! self.con1.commit() + def CheckRollbackCursorConsistency(self): + """ + Checks if cursors on the connection are set into a "reset" state + when a rollback is done on the connection. + """ + con = sqlite.connect(":memory:") + cur = con.cursor() + cur.execute("create table test(x)") + cur.execute("insert into test(x) values (5)") + cur.execute("select 1 union select 2 union select 3") + + con.rollback() + try: + cur.fetchall() + self.fail("InterfaceError should have been raised") + except sqlite.InterfaceError as e: + pass + except: + self.fail("InterfaceError should have been raised") + class SpecialCommandTests(unittest.TestCase): def setUp(self): self.con = sqlite.connect(":memory:") Modified: python/branches/py3k-cdecimal/Lib/sre_parse.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/sre_parse.py (original) +++ python/branches/py3k-cdecimal/Lib/sre_parse.py Thu Apr 1 11:38:52 2010 @@ -786,12 +786,18 @@ groups = [] groupsappend = groups.append literals = [None] * len(p) + if isinstance(source, str): + encode = lambda x: x + else: + # The tokenizer implicitly decodes bytes objects as latin-1, we must + # therefore re-encode the final representation. + encode = lambda x: x.encode('latin1') for c, s in p: if c is MARK: groupsappend((i, s)) # literal[i] is already None else: - literals[i] = s + literals[i] = encode(s) i = i + 1 return groups, literals Modified: python/branches/py3k-cdecimal/Lib/ssl.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/ssl.py (original) +++ python/branches/py3k-cdecimal/Lib/ssl.py Thu Apr 1 11:38:52 2010 @@ -240,16 +240,9 @@ if self._sslobj: if flags != 0: raise ValueError( - "non-zero flags not allowed in calls to recv_into() on %s" % - self.__class__) - while True: - try: - return self.read(buflen) - except SSLError as x: - if x.args[0] == SSL_ERROR_WANT_READ: - continue - else: - raise x + "non-zero flags not allowed in calls to recv() on %s" % + self.__class__) + return self.read(buflen) else: return socket.recv(self, buflen, flags) @@ -264,15 +257,7 @@ raise ValueError( "non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) - while True: - try: - v = self.read(nbytes, buffer) - return v - except SSLError as x: - if x.args[0] == SSL_ERROR_WANT_READ: - continue - else: - raise x + return self.read(nbytes, buffer) else: return socket.recv_into(self, buffer, nbytes, flags) Modified: python/branches/py3k-cdecimal/Lib/subprocess.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/subprocess.py (original) +++ python/branches/py3k-cdecimal/Lib/subprocess.py Thu Apr 1 11:38:52 2010 @@ -29,7 +29,8 @@ stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, - startupinfo=None, creationflags=0): + startupinfo=None, creationflags=0, + restore_signals=True, start_new_session=False): Arguments are: @@ -72,8 +73,11 @@ stderr data from the applications should be captured into the same file handle as for stdout. -If preexec_fn is set to a callable object, this object will be called -in the child process just before the child is executed. +On UNIX, if preexec_fn is set to a callable object, this object will be +called in the child process just before the child is executed. The use +of preexec_fn is not thread safe, using it in the presence of threads +could lead to a deadlock in the child process before the new executable +is executed. If close_fds is true, all file descriptors except 0, 1 and 2 will be closed before the child process is executed. @@ -84,6 +88,14 @@ If cwd is not None, the current directory will be changed to cwd before the child is executed. +On UNIX, if restore_signals is True all signals that Python sets to +SIG_IGN are restored to SIG_DFL in the child process before the exec. +Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. This +parameter does nothing on Windows. + +On UNIX, if start_new_session is True, the setsid() system call will be made +in the child process prior to executing the command. + If env is not None, it defines the environment variables for the new process. @@ -110,7 +122,7 @@ The arguments are the same as for the Popen constructor. Example: - >>> retcode = call(["ls", "-l"]) + >>> retcode = subprocess.call(["ls", "-l"]) check_call(*popenargs, **kwargs): Run command with arguments. Wait for command to complete. If the @@ -120,7 +132,7 @@ The arguments are the same as for the Popen constructor. Example: - >>> check_call(["ls", "-l"]) + >>> subprocess.check_call(["ls", "-l"]) 0 getstatusoutput(cmd): @@ -326,6 +338,7 @@ import traceback import gc import signal +import builtins # Exception classes used by this module. class CalledProcessError(Exception): @@ -375,6 +388,15 @@ import fcntl import pickle + try: + import _posixsubprocess + except ImportError: + _posixsubprocess = None + import warnings + warnings.warn("The _posixsubprocess module is not being used. " + "Child process reliability may suffer if your " + "program uses threads.", RuntimeWarning) + # When select or poll has indicated that the file is writable, # we can write up to _PIPE_BUF bytes without risk of blocking. # POSIX defines PIPE_BUF as >= 512. @@ -406,6 +428,16 @@ STDOUT = -2 +def _eintr_retry_call(func, *args): + while True: + try: + return func(*args) + except OSError as e: + if e.errno == errno.EINTR: + continue + raise + + def call(*popenargs, **kwargs): """Run command with arguments. Wait for command to complete, then return the returncode attribute. @@ -586,7 +618,8 @@ stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, - startupinfo=None, creationflags=0): + startupinfo=None, creationflags=0, + restore_signals=True, start_new_session=False): """Create new Popen instance.""" _cleanup() @@ -632,7 +665,7 @@ # On POSIX, the child objects are file descriptors. On # Windows, these are Windows file handles. The parent objects # are file descriptors on both platforms. The parent objects - # are None when not using PIPEs. The child objects are None + # are -1 when not using PIPEs. The child objects are -1 # when not redirecting. (p2cread, p2cwrite, @@ -644,27 +677,28 @@ startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, - errread, errwrite) + errread, errwrite, + restore_signals, start_new_session) if mswindows: - if p2cwrite is not None: + if p2cwrite != -1: p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0) - if c2pread is not None: + if c2pread != -1: c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0) - if errread is not None: + if errread != -1: errread = msvcrt.open_osfhandle(errread.Detach(), 0) if bufsize == 0: bufsize = 1 # Nearly unbuffered (XXX for now) - if p2cwrite is not None: + if p2cwrite != -1: self.stdin = io.open(p2cwrite, 'wb', bufsize) if self.universal_newlines: self.stdin = io.TextIOWrapper(self.stdin) - if c2pread is not None: + if c2pread != -1: self.stdout = io.open(c2pread, 'rb', bufsize) if universal_newlines: self.stdout = io.TextIOWrapper(self.stdout) - if errread is not None: + if errread != -1: self.stderr = io.open(errread, 'rb', bufsize) if universal_newlines: self.stderr = io.TextIOWrapper(self.stderr) @@ -729,11 +763,11 @@ p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin is None and stdout is None and stderr is None: - return (None, None, None, None, None, None) + return (-1, -1, -1, -1, -1, -1) - p2cread, p2cwrite = None, None - c2pread, c2pwrite = None, None - errread, errwrite = None, None + p2cread, p2cwrite = -1, -1 + c2pread, c2pwrite = -1, -1 + errread, errwrite = -1, -1 if stdin is None: p2cread = GetStdHandle(STD_INPUT_HANDLE) @@ -809,7 +843,8 @@ startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, - errread, errwrite): + errread, errwrite, + unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)""" if not isinstance(args, str): @@ -874,11 +909,11 @@ # output pipe are maintained in this process or else the # pipe will not close when the child process exits and the # ReadFile will hang. - if p2cread is not None: + if p2cread != -1: p2cread.Close() - if c2pwrite is not None: + if c2pwrite != -1: c2pwrite.Close() - if errwrite is not None: + if errwrite != -1: errwrite.Close() @@ -895,7 +930,7 @@ """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: - obj = WaitForSingleObject(self._handle, INFINITE) + WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) return self.returncode @@ -963,9 +998,9 @@ """Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ - p2cread, p2cwrite = None, None - c2pread, c2pwrite = None, None - errread, errwrite = None, None + p2cread, p2cwrite = -1, -1 + c2pread, c2pwrite = -1, -1 + errread, errwrite = -1, -1 if stdin is None: pass @@ -1024,7 +1059,8 @@ startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, - errread, errwrite): + errread, errwrite, + restore_signals, start_new_session): """Execute program (POSIX version)""" if isinstance(args, str): @@ -1038,113 +1074,190 @@ if executable is None: executable = args[0] - # For transferring possible exec failure from child to parent - # The first char specifies the exception type: 0 means - # OSError, 1 means some other error. + # For transferring possible exec failure from child to parent. + # Data format: "exception name:hex errno:description" + # Pickle is not used; it is complex and involves memory allocation. errpipe_read, errpipe_write = os.pipe() try: try: self._set_cloexec_flag(errpipe_write) - gc_was_enabled = gc.isenabled() - # Disable gc to avoid bug where gc -> file_dealloc -> - # write to stderr -> hang. http://bugs.python.org/issue1336 - gc.disable() - try: - self.pid = os.fork() - except: - if gc_was_enabled: - gc.enable() - raise - self._child_created = True - if self.pid == 0: - # Child + if _posixsubprocess: + fs_encoding = sys.getfilesystemencoding() + def fs_encode(s): + """Encode s for use in the env, fs or cmdline.""" + return s.encode(fs_encoding, 'surrogateescape') + + # We must avoid complex work that could involve + # malloc or free in the child process to avoid + # potential deadlocks, thus we do all this here. + # and pass it to fork_exec() + + if env: + env_list = [fs_encode(k) + b'=' + fs_encode(v) + for k, v in env.items()] + else: + env_list = None # Use execv instead of execve. + if os.path.dirname(executable): + executable_list = (fs_encode(executable),) + else: + # This matches the behavior of os._execvpe(). + path_list = os.get_exec_path(env) + executable_list = (os.path.join(dir, executable) + for dir in path_list) + executable_list = tuple(fs_encode(exe) + for exe in executable_list) + self.pid = _posixsubprocess.fork_exec( + args, executable_list, + close_fds, cwd, env_list, + p2cread, p2cwrite, c2pread, c2pwrite, + errread, errwrite, + errpipe_read, errpipe_write, + restore_signals, start_new_session, preexec_fn) + else: + # Pure Python implementation: It is not thread safe. + # This implementation may deadlock in the child if your + # parent process has any other threads running. + + gc_was_enabled = gc.isenabled() + # Disable gc to avoid bug where gc -> file_dealloc -> + # write to stderr -> hang. See issue1336 + gc.disable() try: - # Close parent's pipe ends - if p2cwrite is not None: - os.close(p2cwrite) - if c2pread is not None: - os.close(c2pread) - if errread is not None: - os.close(errread) - os.close(errpipe_read) - - # Dup fds for child - if p2cread is not None: - os.dup2(p2cread, 0) - if c2pwrite is not None: - os.dup2(c2pwrite, 1) - if errwrite is not None: - os.dup2(errwrite, 2) - - # Close pipe fds. Make sure we don't close the - # same fd more than once, or standard fds. - if p2cread is not None and p2cread not in (0,): - os.close(p2cread) - if c2pwrite is not None and \ - c2pwrite not in (p2cread, 1): - os.close(c2pwrite) - if (errwrite is not None and - errwrite not in (p2cread, c2pwrite, 2)): - os.close(errwrite) - - # Close all other fds, if asked for - if close_fds: - self._close_fds(but=errpipe_write) - - if cwd is not None: - os.chdir(cwd) - - if preexec_fn: - preexec_fn() - - if env is None: - os.execvp(executable, args) - else: - os.execvpe(executable, args, env) - + self.pid = os.fork() except: - exc_type, exc_value, tb = sys.exc_info() - # Save the traceback and attach it to the exception - # object - exc_lines = traceback.format_exception(exc_type, - exc_value, - tb) - exc_value.child_traceback = ''.join(exc_lines) - os.write(errpipe_write, pickle.dumps(exc_value)) - - # This exitcode won't be reported to applications, so - # it really doesn't matter what we return. - os._exit(255) - - # Parent - if gc_was_enabled: - gc.enable() + if gc_was_enabled: + gc.enable() + raise + self._child_created = True + if self.pid == 0: + # Child + try: + # Close parent's pipe ends + if p2cwrite != -1: + os.close(p2cwrite) + if c2pread != -1: + os.close(c2pread) + if errread != -1: + os.close(errread) + os.close(errpipe_read) + + # Dup fds for child + if p2cread != -1: + os.dup2(p2cread, 0) + if c2pwrite != -1: + os.dup2(c2pwrite, 1) + if errwrite != -1: + os.dup2(errwrite, 2) + + # Close pipe fds. Make sure we don't close the + # same fd more than once, or standard fds. + if p2cread != -1 and p2cread not in (0,): + os.close(p2cread) + if (c2pwrite != -1 and + c2pwrite not in (p2cread, 1)): + os.close(c2pwrite) + if (errwrite != -1 and + errwrite not in (p2cread, c2pwrite, 2)): + os.close(errwrite) + + # Close all other fds, if asked for + if close_fds: + self._close_fds(but=errpipe_write) + + if cwd is not None: + os.chdir(cwd) + + # This is a copy of Python/pythonrun.c + # _Py_RestoreSignals(). If that were exposed + # as a sys._py_restoresignals func it would be + # better.. but this pure python implementation + # isn't likely to be used much anymore. + if restore_signals: + signals = ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ') + for sig in signals: + if hasattr(signal, sig): + signal.signal(getattr(signal, sig), + signal.SIG_DFL) + + if start_new_session and hasattr(os, 'setsid'): + os.setsid() + + if preexec_fn: + preexec_fn() + + if env is None: + os.execvp(executable, args) + else: + os.execvpe(executable, args, env) + + except: + try: + exc_type, exc_value = sys.exc_info()[:2] + if isinstance(exc_value, OSError): + errno = exc_value.errno + else: + errno = 0 + message = '%s:%x:%s' % (exc_type.__name__, + errno, exc_value) + os.write(errpipe_write, message.encode()) + except: + # We MUST not allow anything odd happening + # above to prevent us from exiting below. + pass + + # This exitcode won't be reported to applications + # so it really doesn't matter what we return. + os._exit(255) + + # Parent + if gc_was_enabled: + gc.enable() finally: # be sure the FD is closed no matter what os.close(errpipe_write) - if p2cread is not None and p2cwrite is not None: + if p2cread != -1 and p2cwrite != -1: os.close(p2cread) - if c2pwrite is not None and c2pread is not None: + if c2pwrite != -1 and c2pread != -1: os.close(c2pwrite) - if errwrite is not None and errread is not None: + if errwrite != -1 and errread != -1: os.close(errwrite) # Wait for exec to fail or succeed; possibly raising an - # exception (limited to 1 MB) - data = os.read(errpipe_read, 1048576) + # exception (limited in size) + data = bytearray() + while True: + part = _eintr_retry_call(os.read, errpipe_read, 50000) + data += part + if not part or len(data) > 50000: + break finally: # be sure the FD is closed no matter what os.close(errpipe_read) if data: - os.waitpid(self.pid, 0) - child_exception = pickle.loads(data) + _eintr_retry_call(os.waitpid, self.pid, 0) + try: + exception_name, hex_errno, err_msg = data.split(b':', 2) + except ValueError: + print('Bad exception data:', repr(data)) + exception_name = b'RuntimeError' + hex_errno = b'0' + err_msg = b'Unknown' + child_exception_type = getattr( + builtins, exception_name.decode('ascii'), + RuntimeError) for fd in (p2cwrite, c2pread, errread): - if fd is not None: + if fd != -1: os.close(fd) - raise child_exception + err_msg = err_msg.decode() + if issubclass(child_exception_type, OSError) and hex_errno: + errno = int(hex_errno, 16) + if errno != 0: + err_msg = os.strerror(errno) + raise child_exception_type(errno, err_msg) + raise child_exception_type(err_msg) def _handle_exitstatus(self, sts): @@ -1175,7 +1288,7 @@ """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: - pid, sts = os.waitpid(self.pid, 0) + pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0) self._handle_exitstatus(sts) return self.returncode Modified: python/branches/py3k-cdecimal/Lib/symbol.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/symbol.py (original) +++ python/branches/py3k-cdecimal/Lib/symbol.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Non-terminal symbols of Python grammar (from "graminit.h").""" Modified: python/branches/py3k-cdecimal/Lib/sysconfig.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/sysconfig.py (original) +++ python/branches/py3k-cdecimal/Lib/sysconfig.py Thu Apr 1 11:38:52 2010 @@ -3,7 +3,7 @@ """ import sys import os -from os.path import pardir, abspath +from os.path import pardir, realpath _INSTALL_SCHEMES = { 'posix_prefix': { @@ -84,16 +84,21 @@ _EXEC_PREFIX = os.path.normpath(sys.exec_prefix) _CONFIG_VARS = None _USER_BASE = None -_PROJECT_BASE = abspath(os.path.dirname(sys.executable)) +if sys.executable: + _PROJECT_BASE = os.path.dirname(realpath(sys.executable)) +else: + # sys.executable can be empty if argv[0] has been changed and Python is + # unable to retrieve the real program name + _PROJECT_BASE = realpath(os.getcwd()) if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower(): - _PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir)) + _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir)) # PC/VS7.1 if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower(): - _PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir, pardir)) + _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir, pardir)) # PC/AMD64 if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower(): - _PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir, pardir)) + _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir, pardir)) def is_python_build(): for fn in ("Setup.dist", "Setup.local"): @@ -296,7 +301,7 @@ vars['SO'] = '.pyd' vars['EXE'] = '.exe' vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT - vars['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable)) + vars['BINDIR'] = os.path.dirname(realpath(sys.executable)) # # public APIs Modified: python/branches/py3k-cdecimal/Lib/tabnanny.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/tabnanny.py (original) +++ python/branches/py3k-cdecimal/Lib/tabnanny.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """The Tab Nanny despises ambiguous indentation. She knows no mercy. Modified: python/branches/py3k-cdecimal/Lib/tarfile.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/tarfile.py (original) +++ python/branches/py3k-cdecimal/Lib/tarfile.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #------------------------------------------------------------------- # tarfile.py #------------------------------------------------------------------- @@ -2391,6 +2391,20 @@ """ if level <= self.debug: print(msg, file=sys.stderr) + + def __enter__(self): + self._check() + return self + + def __exit__(self, type, value, traceback): + if type is None: + self.close() + else: + # An exception occurred. We must not call close() because + # it would try to write end-of-archive blocks and padding. + if not self._extfileobj: + self.fileobj.close() + self.closed = True # class TarFile class TarIter: Modified: python/branches/py3k-cdecimal/Lib/test/crashers/recursive_call.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/crashers/recursive_call.py (original) +++ python/branches/py3k-cdecimal/Lib/test/crashers/recursive_call.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # No bug report AFAIK, mail on python-dev on 2006-01-10 Modified: python/branches/py3k-cdecimal/Lib/test/curses_tests.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/curses_tests.py (original) +++ python/branches/py3k-cdecimal/Lib/test/curses_tests.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # $Id: ncurses.py 36559 2004-07-18 05:56:09Z tim_one $ # Modified: python/branches/py3k-cdecimal/Lib/test/pystone.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/pystone.py (original) +++ python/branches/py3k-cdecimal/Lib/test/pystone.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """ "PYSTONE" Benchmark Program Modified: python/branches/py3k-cdecimal/Lib/test/re_tests.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/re_tests.py (original) +++ python/branches/py3k-cdecimal/Lib/test/re_tests.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- mode: python -*- # Re test suite and benchmark suite v1.5 Modified: python/branches/py3k-cdecimal/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/regrtest.py (original) +++ python/branches/py3k-cdecimal/Lib/test/regrtest.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Regression test. @@ -146,7 +146,6 @@ """ import getopt -import itertools import json import os import random @@ -159,6 +158,9 @@ import unittest from inspect import isabstract import tempfile +import platform +import sysconfig + # Some times __path__ and __file__ are not absolute (e.g. while running from # Lib/) and, if we change the CWD to run the tests in a temporary dir, some @@ -383,18 +385,19 @@ if single and fromfile: usage("-s and -f don't go together!") if use_mp and trace: - usage(2, "-T and -j don't go together!") + usage("-T and -j don't go together!") if use_mp and findleaks: - usage(2, "-l and -j don't go together!") + usage("-l and -j don't go together!") + if use_mp and max(sys.flags): + # TODO: inherit the environment and the flags + print("Warning: flags and environment variables are ignored with -j option") good = [] bad = [] skipped = [] resource_denieds = [] environment_changed = [] - - if verbose: - print('The CWD is now', os.getcwd()) + interrupted = False if findleaks: try: @@ -429,10 +432,8 @@ fp.close() # Strip .py extensions. - if args: - args = list(map(removepy, args)) - if tests: - tests = list(map(removepy, tests)) + removepy(args) + removepy(tests) stdtests = STDTESTS[:] nottests = NOTTESTS.copy() @@ -442,12 +443,20 @@ stdtests.remove(arg) nottests.add(arg) args = [] + + # For a partial run, we do not need to clutter the output. + if verbose or not (quiet or tests or args): + # Print basic platform information + print("==", platform.python_implementation(), *sys.version.split()) + print("== ", platform.platform(aliased=True)) + print("== ", os.getcwd()) + alltests = findtests(testdir, stdtests, nottests) - tests = tests or args or alltests + selected = tests or args or alltests if single: - tests = tests[:1] + selected = selected[:1] try: - next_single_test = alltests[alltests.index(tests[0])+1] + next_single_test = alltests[alltests.index(selected[0])+1] except IndexError: next_single_test = None # Remove all the tests that precede start if it's set. @@ -459,7 +468,7 @@ if randomize: random.seed(random_seed) print("Using random seed", random_seed) - random.shuffle(tests) + random.shuffle(selected) if trace: import trace, tempfile tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix, @@ -488,7 +497,7 @@ resource_denieds.append(test) if forever: - def test_forever(tests=list(tests)): + def test_forever(tests=list(selected)): while True: for test in tests: yield test @@ -496,15 +505,13 @@ return tests = test_forever() else: - tests = iter(tests) + tests = iter(selected) if use_mp: from threading import Thread - from queue import Queue, Empty - from subprocess import Popen, PIPE, STDOUT - from collections import deque + from queue import Queue + from subprocess import Popen, PIPE debug_output_pat = re.compile(r"\[\d+ refs\]$") - pending = deque() output = Queue() def tests_and_args(): for test in tests: @@ -563,6 +570,7 @@ raise KeyboardInterrupt # What else? accumulate_result(test, result) except KeyboardInterrupt: + interrupted = True pending.close() for worker in workers: worker.join() @@ -585,8 +593,7 @@ print("Re-running test {} in verbose mode".format(test)) runtest(test, True, quiet, testdir, huntrleaks, debug) except KeyboardInterrupt: - # print a newline separate from the ^C - print() + interrupted = True break except: raise @@ -604,14 +611,15 @@ if module not in save_modules and module.startswith("test."): support.unload(module) - # The lists won't be sorted if running with -r - good.sort() - bad.sort() - skipped.sort() - environment_changed.sort() - + if interrupted: + # print a newline after ^C + print() + print("Test suite interrupted by signal SIGINT.") + omitted = set(selected) - set(good) - set(bad) - set(skipped) + print(count(len(omitted), "test"), "omitted:") + printlist(omitted) if good and not quiet: - if not bad and not skipped and len(good) > 1: + if not bad and not skipped and not interrupted and len(good) > 1: print("All", end=' ') print(count(len(good), "test"), "OK.") if print_slow: @@ -676,7 +684,7 @@ if runleaks: os.system("leaks %d" % os.getpid()) - sys.exit(len(bad) > 0) + sys.exit(len(bad) > 0 or interrupted) STDTESTS = [ @@ -698,16 +706,15 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS): """Return a list of all applicable test modules.""" - if not testdir: testdir = findtestdir() + testdir = findtestdir(testdir) names = os.listdir(testdir) tests = [] + others = set(stdtests) | nottests for name in names: - if name[:5] == "test_" and name[-3:] == ".py": - modname = name[:-3] - if modname not in stdtests and modname not in nottests: - tests.append(modname) - tests.sort() - return stdtests + tests + modname, ext = os.path.splitext(name) + if modname[:5] == "test_" and ext == ".py" and modname not in others: + tests.append(modname) + return stdtests + sorted(tests) def runtest(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False, use_resources=None): @@ -779,7 +786,8 @@ # the corresponding method names. resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr', - 'os.environ', 'sys.path', 'sys.path_hooks', '__import__') + 'os.environ', 'sys.path', 'sys.path_hooks', '__import__', + 'warnings.filters') def get_sys_argv(self): return id(sys.argv), sys.argv, sys.argv[:] @@ -831,6 +839,12 @@ def restore___import__(self, import_): __builtins__.__import__ = import_ + def get_warnings_filters(self): + return id(warnings.filters), warnings.filters, warnings.filters[:] + def restore_warnings_filters(self, saved_filters): + warnings.filters = saved_filters[1] + warnings.filters[:] = saved_filters[2] + def resource_info(self): for name in self.resources: method_suffix = name.replace('.', '_') @@ -865,8 +879,7 @@ def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) - if not testdir: - testdir = findtestdir() + testdir = findtestdir(testdir) test_time = 0.0 refleak = False # True if the test leaked references. @@ -1004,13 +1017,14 @@ sys.stderr.flush() dash_R_cleanup(fs, ps, pic, zdc, abcs) for i in range(repcount): - rc = sys.gettotalrefcount() + rc_before = sys.gettotalrefcount() run_the_test() sys.stderr.write('.') sys.stderr.flush() dash_R_cleanup(fs, ps, pic, zdc, abcs) + rc_after = sys.gettotalrefcount() if i >= nwarmup: - deltas.append(sys.gettotalrefcount() - rc - 2) + deltas.append(rc_after - rc_before) print(file=sys.stderr) if any(deltas): msg = '%s leaked %s references, sum=%s' % (test, deltas, sum(deltas)) @@ -1087,18 +1101,16 @@ for i in range(256): s[i:i+1] -def findtestdir(): - if __name__ == '__main__': - file = sys.argv[0] - else: - file = __file__ - testdir = os.path.dirname(file) or os.curdir - return testdir - -def removepy(name): - if name.endswith(".py"): - name = name[:-3] - return name +def findtestdir(path=None): + return path or os.path.dirname(__file__) or os.curdir + +def removepy(names): + if not names: + return + for idx, name in enumerate(names): + basename, ext = os.path.splitext(name) + if ext == '.py': + names[idx] = basename def count(n, word): if n == 1: @@ -1116,7 +1128,8 @@ from textwrap import fill blanks = ' ' * indent - print(fill(' '.join(map(str, x)), width, + # Print the sorted list: 'x' may be a '--random' list or a set() + print(fill(' '.join(str(elt) for elt in sorted(x)), width, initial_indent=blanks, subsequent_indent=blanks)) # Map sys.platform to a string containing the basenames of tests @@ -1432,31 +1445,25 @@ return self.expected if __name__ == '__main__': - # Remove regrtest.py's own directory from the module search path. This - # prevents relative imports from working, and relative imports will screw - # up the testing framework. E.g. if both test.support and - # support are imported, they will not contain the same globals, and - # much of the testing framework relies on the globals in the - # test.support module. - mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) - i = len(sys.path) - while i >= 0: - i -= 1 - if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: - del sys.path[i] - - # findtestdir() gets the dirname out of sys.argv[0], so we have to make it - # absolute before changing the CWD. - if sys.argv[0]: - sys.argv[0] = os.path.abspath(sys.argv[0]) + # Simplification for findtestdir(). + assert __file__ == os.path.abspath(sys.argv[0]) + # When tests are run from the Python build directory, it is best practice + # to keep the test files in a subfolder. It eases the cleanup of leftover + # files using command "make distclean". + if sysconfig.is_python_build(): + parent_dir = os.path.join(sysconfig.get_config_var('srcdir'), 'build') + if not os.path.exists(parent_dir): + os.mkdir(parent_dir) + else: + parent_dir = os.path.abspath(tempfile.gettempdir()) # Define a writable temp dir that will be used as cwd while running # the tests. The name of the dir includes the pid to allow parallel # testing (see the -j option). TESTCWD = 'test_python_{}'.format(os.getpid()) - TESTCWD = os.path.abspath(os.path.join(tempfile.gettempdir(), TESTCWD)) + TESTCWD = os.path.join(parent_dir, TESTCWD) # Run the tests in a context manager that temporary changes the CWD to a # temporary and writable directory. If it's not possible to create or Modified: python/branches/py3k-cdecimal/Lib/test/script_helper.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/script_helper.py (original) +++ python/branches/py3k-cdecimal/Lib/test/script_helper.py Thu Apr 1 11:38:52 2010 @@ -56,7 +56,8 @@ def make_script(script_dir, script_basename, source): script_filename = script_basename+os.extsep+'py' script_name = os.path.join(script_dir, script_filename) - script_file = open(script_name, 'w') + # The script should be encoded to UTF-8, the default string encoding + script_file = open(script_name, 'w', encoding='utf-8') script_file.write(source) script_file.close() return script_name Modified: python/branches/py3k-cdecimal/Lib/test/support.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/support.py (original) +++ python/branches/py3k-cdecimal/Lib/test/support.py Thu Apr 1 11:38:52 2010 @@ -16,6 +16,7 @@ import unittest import importlib import collections +import re __all__ = ["Error", "TestFailed", "ResourceDenied", "import_module", "verbose", "use_resources", "max_memuse", "record_original_stdout", @@ -29,7 +30,9 @@ "run_with_locale", "set_memlimit", "bigmemtest", "bigaddrspacetest", "BasicTestRunner", "run_unittest", "run_doctest", "threading_setup", "threading_cleanup", - "reap_children", "cpython_only", "check_impl_detail", "get_attribute"] + "reap_children", "cpython_only", "check_impl_detail", "get_attribute", + "swap_item", "swap_attr"] + class Error(Exception): """Base class for regression test exceptions.""" @@ -401,12 +404,14 @@ rmtree(name) -def findfile(file, here=__file__): +def findfile(file, here=__file__, subdir=None): """Try to find a file on sys.path and the working directory. If it is not found the argument passed to the function is returned (this does not necessarily signal failure; could still be the legitimate path).""" if os.path.isabs(file): return file + if subdir is not None: + file = os.path.join(subdir, file) path = sys.path path = [os.path.dirname(here)] + path for dn in path: @@ -440,12 +445,29 @@ def open_urlresource(url, *args, **kw): import urllib.request, urllib.parse - requires('urlfetch') + check = kw.pop('check', None) + filename = urllib.parse.urlparse(url)[2].split('/')[-1] # '/': it's URL! fn = os.path.join(os.path.dirname(__file__), "data", filename) + + def check_valid_file(fn): + f = open(fn, *args, **kw) + if check is None: + return f + elif check(f): + f.seek(0) + return f + f.close() + if os.path.exists(fn): - return open(fn, *args, **kw) + f = check_valid_file(fn) + if f is not None: + return f + unlink(fn) + + # Verify the requirement before downloading the file + requires('urlfetch') print('\tfetching %s ...' % url, file=get_original_stdout()) f = urllib.request.urlopen(url, timeout=15) @@ -457,29 +479,97 @@ s = f.read() finally: f.close() - return open(fn, *args, **kw) + + f = check_valid_file(fn) + if f is not None: + return f + raise TestFailed('invalid resource "%s"' % fn) + class WarningsRecorder(object): """Convenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. """ def __init__(self, warnings_list): - self.warnings = warnings_list + self._warnings = warnings_list + self._last = 0 def __getattr__(self, attr): - if self.warnings: - return getattr(self.warnings[-1], attr) + if len(self._warnings) > self._last: + return getattr(self._warnings[-1], attr) elif attr in warnings.WarningMessage._WARNING_DETAILS: return None raise AttributeError("%r has no attribute %r" % (self, attr)) + @property + def warnings(self): + return self._warnings[self._last:] + def reset(self): - del self.warnings[:] + self._last = len(self._warnings) - at contextlib.contextmanager -def check_warnings(): + +def _filterwarnings(filters, quiet=False): + """Catch the warnings, then check if all the expected + warnings have been raised and re-raise unexpected warnings. + If 'quiet' is True, only re-raise the unexpected warnings. + """ + # Clear the warning registry of the calling module + # in order to re-raise the warnings. + frame = sys._getframe(2) + registry = frame.f_globals.get('__warningregistry__') + if registry: + registry.clear() with warnings.catch_warnings(record=True) as w: + # Set filter "always" to record all warnings. Because + # test_warnings swap the module, we need to look up in + # the sys.modules dictionary. + sys.modules['warnings'].simplefilter("always") yield WarningsRecorder(w) + # Filter the recorded warnings + reraise = [warning.message for warning in w] + missing = [] + for msg, cat in filters: + seen = False + for exc in reraise[:]: + message = str(exc) + # Filter out the matching messages + if (re.match(msg, message, re.I) and + issubclass(exc.__class__, cat)): + seen = True + reraise.remove(exc) + if not seen and not quiet: + # This filter caught nothing + missing.append((msg, cat.__name__)) + if reraise: + raise AssertionError("unhandled warning %r" % reraise[0]) + if missing: + raise AssertionError("filter (%r, %s) did not catch any warning" % + missing[0]) + + + at contextlib.contextmanager +def check_warnings(*filters, **kwargs): + """Context manager to silence warnings. + + Accept 2-tuples as positional arguments: + ("message regexp", WarningCategory) + + Optional argument: + - if 'quiet' is True, it does not fail if a filter catches nothing + (default True without argument, + default False if some filters are defined) + + Without argument, it defaults to: + check_warnings(("", Warning), quiet=True) + """ + quiet = kwargs.get('quiet') + if not filters: + filters = (("", Warning),) + # Preserve backward compatibility + if quiet is None: + quiet = True + return _filterwarnings(filters, quiet) class CleanImport(object): @@ -714,7 +804,6 @@ MAX_Py_ssize_t = sys.maxsize def set_memlimit(limit): - import re global max_memuse global real_max_memuse sizes = { @@ -1014,3 +1103,57 @@ break except: break + + at contextlib.contextmanager +def swap_attr(obj, attr, new_val): + """Temporary swap out an attribute with a new object. + + Usage: + with swap_attr(obj, "attr", 5): + ... + + This will set obj.attr to 5 for the duration of the with: block, + restoring the old value at the end of the block. If `attr` doesn't + exist on `obj`, it will be created and then deleted at the end of the + block. + """ + if hasattr(obj, attr): + real_val = getattr(obj, attr) + setattr(obj, attr, new_val) + try: + yield + finally: + setattr(obj, attr, real_val) + else: + setattr(obj, attr, new_val) + try: + yield + finally: + delattr(obj, attr) + + at contextlib.contextmanager +def swap_item(obj, item, new_val): + """Temporary swap out an item with a new object. + + Usage: + with swap_item(obj, "item", 5): + ... + + This will set obj["item"] to 5 for the duration of the with: block, + restoring the old value at the end of the block. If `item` doesn't + exist on `obj`, it will be created and then deleted at the end of the + block. + """ + if item in obj: + real_val = obj[item] + obj[item] = new_val + try: + yield + finally: + obj[item] = real_val + else: + obj[item] = new_val + try: + yield + finally: + del obj[item] Deleted: python/branches/py3k-cdecimal/Lib/test/test.xml ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test.xml Thu Apr 1 11:38:52 2010 +++ (empty file) @@ -1,115 +0,0 @@ - - -Introduction to XSL -

Introduction to XSL

- - - -
-

Overview -

-
    - -
  • 1.Intro
  • - -
  • 2.History
  • - -
  • 3.XSL Basics
  • - -
  • Lunch
  • - -
  • 4.An XML Data Model
  • - -
  • 5.XSL Patterns
  • - -
  • 6.XSL Templates
  • - -
  • 7.XSL Formatting Model -
  • - -
- - - - - - -
-

Intro

-
    - -
  • Who am I?
  • - -
  • Who are you?
  • - -
  • Why are we here? -
  • - -
- - - - - - -
-

History: XML and SGML

-
    - -
  • XML is a subset of SGML.
  • - -
  • SGML allows the separation of abstract content from formatting.
  • - -
  • Also one of XML's primary virtues (in the doc publishing domain). -
  • - -
- - - - - - -
-

History: What are stylesheets?

-
    - -
  • Stylesheets specify the formatting of SGML/XML documents.
  • - -
  • Stylesheets put the "style" back into documents.
  • - -
  • New York Times content+NYT Stylesheet = NYT paper -
  • - -
- - - - - - -
-

History: FOSI

-
    - -
  • FOSI: "Formatted Output Specification Instance" -
      -
    • MIL-STD-28001 -
    • - -
    • FOSI's are SGML documents -
    • - -
    • A stylesheet for another document -
    • -
  • - -
  • Obsolete but implemented... -
  • - -
- - - - - Deleted: python/branches/py3k-cdecimal/Lib/test/test.xml.out ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test.xml.out Thu Apr 1 11:38:52 2010 +++ (empty file) @@ -1,115 +0,0 @@ - - -Introduction to XSL -

Introduction to XSL

- - - -
-

Overview -

-
    - -
  • 1.Intro
  • - -
  • 2.History
  • - -
  • 3.XSL Basics
  • - -
  • Lunch
  • - -
  • 4.An XML Data Model
  • - -
  • 5.XSL Patterns
  • - -
  • 6.XSL Templates
  • - -
  • 7.XSL Formatting Model -
  • - -
- - - - - - -
-

Intro

-
    - -
  • Who am I?
  • - -
  • Who are you?
  • - -
  • Why are we here? -
  • - -
- - - - - - -
-

History: XML and SGML

-
    - -
  • XML is a subset of SGML.
  • - -
  • SGML allows the separation of abstract content from formatting.
  • - -
  • Also one of XML's primary virtues (in the doc publishing domain). -
  • - -
- - - - - - -
-

History: What are stylesheets?

-
    - -
  • Stylesheets specify the formatting of SGML/XML documents.
  • - -
  • Stylesheets put the "style" back into documents.
  • - -
  • New York Times content+NYT Stylesheet = NYT paper -
  • - -
- - - - - - -
-

History: FOSI

-
    - -
  • FOSI: "Formatted Output Specification Instance" -
      -
    • MIL-STD-28001 -
    • - -
    • FOSI's are SGML documents -
    • - -
    • A stylesheet for another document -
    • -
  • - -
  • Obsolete but implemented... -
  • - -
- - - - - \ No newline at end of file Modified: python/branches/py3k-cdecimal/Lib/test/test___future__.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test___future__.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test___future__.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import unittest from test import support import __future__ Modified: python/branches/py3k-cdecimal/Lib/test/test__locale.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test__locale.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test__locale.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -from test.support import verbose, run_unittest +from test.support import run_unittest from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, localeconv, Error) try: from _locale import (RADIXCHAR, THOUSEP, nl_langinfo) Modified: python/branches/py3k-cdecimal/Lib/test/test_abstract_numbers.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_abstract_numbers.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_abstract_numbers.py Thu Apr 1 11:38:52 2010 @@ -4,7 +4,6 @@ import operator import unittest from numbers import Complex, Real, Rational, Integral -from numbers import Number from test import support class TestNumbers(unittest.TestCase): Modified: python/branches/py3k-cdecimal/Lib/test/test_array.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_array.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_array.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Test the arraymodule. Roger E. Masse """ Deleted: python/branches/py3k-cdecimal/Lib/test/test_ascii_formatd.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_ascii_formatd.py Thu Apr 1 11:38:52 2010 +++ (empty file) @@ -1,61 +0,0 @@ -# PyOS_ascii_formatd is deprecated and not called from anywhere in -# Python itself. So this module is the only place it gets tested. -# Test that it works, and test that it's deprecated. - -import unittest -from test.support import check_warnings, run_unittest, cpython_only - -class FormatDeprecationTests(unittest.TestCase): - - @cpython_only - def testFormatDeprecation(self): - # delay importing ctypes until we know we're in CPython - from ctypes import (pythonapi, create_string_buffer, sizeof, byref, - c_double) - PyOS_ascii_formatd = pythonapi.PyOS_ascii_formatd - buf = create_string_buffer(100) - - with check_warnings() as w: - PyOS_ascii_formatd(byref(buf), sizeof(buf), b'%+.10f', - c_double(10.0)) - self.assertEqual(buf.value, b'+10.0000000000') - - self.assertEqual(w.category, DeprecationWarning) - -class FormatTests(unittest.TestCase): - # ensure that, for the restricted set of format codes, - # %-formatting returns the same values os PyOS_ascii_formatd - @cpython_only - def testFormat(self): - # delay importing ctypes until we know we're in CPython - from ctypes import (pythonapi, create_string_buffer, sizeof, byref, - c_double) - PyOS_ascii_formatd = pythonapi.PyOS_ascii_formatd - buf = create_string_buffer(100) - - tests = [ - ('%f', 100.0), - ('%g', 100.0), - ('%#g', 100.0), - ('%#.2g', 100.0), - ('%#.2g', 123.4567), - ('%#.2g', 1.234567e200), - ('%e', 1.234567e200), - ('%e', 1.234), - ('%+e', 1.234), - ('%-e', 1.234), - ] - - with check_warnings(): - for format, val in tests: - PyOS_ascii_formatd(byref(buf), sizeof(buf), - bytes(format, 'ascii'), - c_double(val)) - self.assertEqual(buf.value, bytes(format % val, 'ascii')) - - -def test_main(): - run_unittest(FormatDeprecationTests, FormatTests) - -if __name__ == '__main__': - test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_asynchat.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_asynchat.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_asynchat.py Thu Apr 1 11:38:52 2010 @@ -22,6 +22,9 @@ self.event = event self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(self.sock) + # This will be set if the client wants us to wait before echoing data + # back. + self.start_resend_event = None def run(self): self.sock.listen(1) @@ -38,6 +41,9 @@ # remove the SERVER_QUIT message self.buffer = self.buffer.replace(SERVER_QUIT, b'') + if self.start_resend_event: + self.start_resend_event.wait() + # re-send entire set of collected data try: # this may fail on some tests, such as test_close_when_done, since @@ -203,11 +209,18 @@ def test_close_when_done(self): s, event = start_echo_server() + s.start_resend_event = threading.Event() c = echo_client(b'\n', s.port) c.push(b"hello world\nI'm not dead yet!\n") c.push(SERVER_QUIT) c.close_when_done() asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) + + # Only allow the server to start echoing data back to the client after + # the client has closed its connection. This prevents a race condition + # where the server echoes all of its data before we can check that it + # got any down below. + s.start_resend_event.set() s.join() self.assertEqual(c.contents, []) Modified: python/branches/py3k-cdecimal/Lib/test/test_bigmem.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_bigmem.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_bigmem.py Thu Apr 1 11:38:52 2010 @@ -618,7 +618,7 @@ @precisionbigmemtest(size=_4G // 5, memuse=character_size * (6 + 1)) def test_unicode_repr_overflow(self, size): try: - s = "\uAAAA"*size + s = "\uDCBA"*size r = repr(s) except MemoryError: pass # acceptable on 32-bit @@ -679,22 +679,24 @@ @bigmemtest(minsize=2**32 / 5, memuse=character_size * 7) def test_unicode_repr(self, size): - s = "\uAAAA" * size + # Use an assigned, but not printable code point. + # It is in the range of the low surrogates \uDC00-\uDFFF. + s = "\uDCBA" * size for f in (repr, ascii): r = f(s) self.assertTrue(len(r) > size) - self.assertTrue(r.endswith(r"\uaaaa'"), r[-10:]) + self.assertTrue(r.endswith(r"\udcba'"), r[-10:]) del r # The character takes 4 bytes even in UCS-2 builds because it will # be decomposed into surrogates. @bigmemtest(minsize=2**32 / 5, memuse=4 + character_size * 9) def test_unicode_repr_wide(self, size): - s = "\U0001AAAA" * size + s = "\U0001DCBA" * size for f in (repr, ascii): r = f(s) self.assertTrue(len(r) > size) - self.assertTrue(r.endswith(r"\U0001aaaa'"), r[-12:]) + self.assertTrue(r.endswith(r"\U0001dcba'"), r[-12:]) del r Modified: python/branches/py3k-cdecimal/Lib/test/test_binhex.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_binhex.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_binhex.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Test script for the binhex C module Uses the mechanism of the python binhex module Modified: python/branches/py3k-cdecimal/Lib/test/test_bool.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_bool.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_bool.py Thu Apr 1 11:38:52 2010 @@ -45,6 +45,12 @@ self.assertEqual(int(True), 1) self.assertIsNot(int(True), True) + def test_float(self): + self.assertEqual(float(False), 0.0) + self.assertIsNot(float(False), False) + self.assertEqual(float(True), 1.0) + self.assertIsNot(float(True), True) + def test_math(self): self.assertEqual(+False, 0) self.assertIsNot(+False, False) @@ -235,6 +241,12 @@ finally: os.remove(support.TESTFN) + def test_types(self): + # types are always true. + for t in [bool, complex, dict, float, int, list, object, + set, str, tuple, type]: + self.assertIs(bool(t), True) + def test_operator(self): import operator self.assertIs(operator.truth(0), False) Modified: python/branches/py3k-cdecimal/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_builtin.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_builtin.py Thu Apr 1 11:38:52 2010 @@ -1,16 +1,12 @@ # Python test set -- built-in functions import platform -import test.support, unittest -from test.support import fcmp, TESTFN, unlink, run_unittest, \ - run_with_locale +import unittest +from test.support import fcmp, TESTFN, unlink, run_unittest, check_warnings from operator import neg -import sys, warnings, random, collections, io, fractions -warnings.filterwarnings("ignore", "hex../oct.. of negative int", - FutureWarning, __name__) -warnings.filterwarnings("ignore", "integer argument expected", - DeprecationWarning, "unittest") +import sys, warnings, random, collections, io + import builtins class Squares: @@ -427,9 +423,10 @@ g = {} l = {} - import warnings - warnings.filterwarnings("ignore", "global statement", module="") - exec('global a; a = 1; b = 2', g, l) + with check_warnings(): + warnings.filterwarnings("ignore", "global statement", + module="") + exec('global a; a = 1; b = 2', g, l) if '__builtins__' in g: del g['__builtins__'] if '__builtins__' in l: @@ -479,6 +476,8 @@ self.assertRaises(TypeError, getattr, sys, 1, "foo") self.assertRaises(TypeError, getattr) self.assertRaises(AttributeError, getattr, sys, chr(sys.maxunicode)) + # unicode surrogates are not encodable to the default encoding (utf8) + self.assertRaises(AttributeError, getattr, 1, "\uDAD1\uD51E") def test_hasattr(self): import sys Modified: python/branches/py3k-cdecimal/Lib/test/test_bytes.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_bytes.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_bytes.py Thu Apr 1 11:38:52 2010 @@ -27,12 +27,6 @@ class BaseBytesTest(unittest.TestCase): - def setUp(self): - self.warning_filters = warnings.filters[:] - - def tearDown(self): - warnings.filters = self.warning_filters - def test_basics(self): b = self.type2test() self.assertEqual(type(b), self.type2test) @@ -127,15 +121,19 @@ self.assertFalse(b3 <= b2) def test_compare_to_str(self): - warnings.simplefilter('ignore', BytesWarning) - # Byte comparisons with unicode should always fail! - # Test this for all expected byte orders and Unicode character sizes - self.assertEqual(self.type2test(b"\0a\0b\0c") == "abc", False) - self.assertEqual(self.type2test(b"\0\0\0a\0\0\0b\0\0\0c") == "abc", False) - self.assertEqual(self.type2test(b"a\0b\0c\0") == "abc", False) - self.assertEqual(self.type2test(b"a\0\0\0b\0\0\0c\0\0\0") == "abc", False) - self.assertEqual(self.type2test() == str(), False) - self.assertEqual(self.type2test() != str(), True) + with test.support.check_warnings(): + warnings.simplefilter('ignore', BytesWarning) + # Byte comparisons with unicode should always fail! + # Test this for all expected byte orders and Unicode character + # sizes. + self.assertEqual(self.type2test(b"\0a\0b\0c") == "abc", False) + self.assertEqual(self.type2test(b"\0\0\0a\0\0\0b\0\0\0c") == "abc", + False) + self.assertEqual(self.type2test(b"a\0b\0c\0") == "abc", False) + self.assertEqual(self.type2test(b"a\0\0\0b\0\0\0c\0\0\0") == "abc", + False) + self.assertEqual(self.type2test() == str(), False) + self.assertEqual(self.type2test() != str(), True) def test_reversed(self): input = list(map(ord, "Hello")) @@ -829,22 +827,17 @@ # Test various combinations of bytes and bytearray # - def setUp(self): - self.warning_filters = warnings.filters[:] - - def tearDown(self): - warnings.filters = self.warning_filters - def test_repr_str(self): - warnings.simplefilter('ignore', BytesWarning) - for f in str, repr: - self.assertEqual(f(bytearray()), "bytearray(b'')") - self.assertEqual(f(bytearray([0])), "bytearray(b'\\x00')") - self.assertEqual(f(bytearray([0, 1, 254, 255])), - "bytearray(b'\\x00\\x01\\xfe\\xff')") - self.assertEqual(f(b"abc"), "b'abc'") - self.assertEqual(f(b"'"), '''b"'"''') # ''' - self.assertEqual(f(b"'\""), r"""b'\'"'""") # ' + with test.support.check_warnings(): + warnings.simplefilter('ignore', BytesWarning) + for f in str, repr: + self.assertEqual(f(bytearray()), "bytearray(b'')") + self.assertEqual(f(bytearray([0])), "bytearray(b'\\x00')") + self.assertEqual(f(bytearray([0, 1, 254, 255])), + "bytearray(b'\\x00\\x01\\xfe\\xff')") + self.assertEqual(f(b"abc"), "b'abc'") + self.assertEqual(f(b"'"), '''b"'"''') # ''' + self.assertEqual(f(b"'\""), r"""b'\'"'""") # ' def test_compare_bytes_to_bytearray(self): self.assertEqual(b"abc" == bytes(b"abc"), True) @@ -876,9 +869,9 @@ self.assertEqual(bytes(b"abc") <= b"ab", False) def test_doc(self): - self.assertTrue(bytearray.__doc__ != None) + self.assertIsNotNone(bytearray.__doc__) self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__) - self.assertTrue(bytes.__doc__ != None) + self.assertIsNotNone(bytes.__doc__) self.assertTrue(bytes.__doc__.startswith("bytes("), bytes.__doc__) def test_from_bytearray(self): @@ -888,13 +881,14 @@ self.assertEqual(b, bytearray(sample)) def test_to_str(self): - warnings.simplefilter('ignore', BytesWarning) - self.assertEqual(str(b''), "b''") - self.assertEqual(str(b'x'), "b'x'") - self.assertEqual(str(b'\x80'), "b'\\x80'") - self.assertEqual(str(bytearray(b'')), "bytearray(b'')") - self.assertEqual(str(bytearray(b'x')), "bytearray(b'x')") - self.assertEqual(str(bytearray(b'\x80')), "bytearray(b'\\x80')") + with test.support.check_warnings(): + warnings.simplefilter('ignore', BytesWarning) + self.assertEqual(str(b''), "b''") + self.assertEqual(str(b'x'), "b'x'") + self.assertEqual(str(b'\x80'), "b'\\x80'") + self.assertEqual(str(bytearray(b'')), "bytearray(b'')") + self.assertEqual(str(bytearray(b'x')), "bytearray(b'x')") + self.assertEqual(str(bytearray(b'\x80')), "bytearray(b'\\x80')") def test_literal(self): tests = [ @@ -940,11 +934,16 @@ def test_compare(self): if sys.flags.bytes_warning: - warnings.simplefilter('error', BytesWarning) - self.assertRaises(BytesWarning, operator.eq, b'', '') - self.assertRaises(BytesWarning, operator.ne, b'', '') - self.assertRaises(BytesWarning, operator.eq, bytearray(b''), '') - self.assertRaises(BytesWarning, operator.ne, bytearray(b''), '') + with test.support.check_warnings(): + warnings.simplefilter('error', BytesWarning) + with self.assertRaises(BytesWarning): + b'' == '' + with self.assertRaises(BytesWarning): + b'' != '' + with self.assertRaises(BytesWarning): + bytearray(b'') == '' + with self.assertRaises(BytesWarning): + bytearray(b'') != '' else: # self.skipTest("BytesWarning is needed for this test: use -bb option") pass Modified: python/branches/py3k-cdecimal/Lib/test/test_bz2.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_bz2.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_bz2.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 from test import support from test.support import TESTFN Modified: python/branches/py3k-cdecimal/Lib/test/test_cgi.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_cgi.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_cgi.py Thu Apr 1 11:38:52 2010 @@ -1,11 +1,10 @@ -from test.support import run_unittest +from test.support import run_unittest, check_warnings import cgi import os import sys import tempfile import unittest from io import StringIO -from warnings import catch_warnings, filterwarnings class HackedSysModule: # The regression test will have real values in sys.argv, which @@ -15,10 +14,6 @@ cgi.sys = HackedSysModule() -try: - from io import StringIO -except ImportError: - from io import StringIO class ComparableException: def __init__(self, err): @@ -117,7 +112,7 @@ result = {} for k, v in dict(form).items(): - result[k] = type(v) is list and form.getlist(k) or v.value + result[k] = isinstance(v, list) and form.getlist(k) or v.value return result @@ -133,10 +128,10 @@ env = {'QUERY_STRING': orig} fs = cgi.FieldStorage(environ=env) - if type(expect) == type({}): + if isinstance(expect, dict): # test dict interface self.assertEqual(len(expect), len(fs)) - self.assertEqual(norm(expect.keys()), norm(fs.keys())) + self.assertItemsEqual(expect.keys(), fs.keys()) ##self.assertEqual(norm(expect.values()), norm(fs.values())) ##self.assertEqual(norm(expect.items()), norm(fs.items())) self.assertEqual(fs.getvalue("nonexistent field", "default"), "default") @@ -308,20 +303,16 @@ self.assertEqual(result, v) def test_deprecated_parse_qs(self): - # this func is moved to urlparse, this is just a sanity check - with catch_warnings(): - filterwarnings('ignore', - 'cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead', - DeprecationWarning) + # this func is moved to urllib.parse, this is just a sanity check + with check_warnings(('cgi.parse_qs is deprecated, use urllib.parse.' + 'parse_qs instead', DeprecationWarning)): self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']}, cgi.parse_qs('a=A1&b=B2&B=B3')) def test_deprecated_parse_qsl(self): - # this func is moved to urlparse, this is just a sanity check - with catch_warnings(): - filterwarnings('ignore', - 'cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead', - DeprecationWarning) + # this func is moved to urllib.parse, this is just a sanity check + with check_warnings(('cgi.parse_qsl is deprecated, use urllib.parse.' + 'parse_qsl instead', DeprecationWarning)): self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')], cgi.parse_qsl('a=A1&b=B2&B=B3')) Modified: python/branches/py3k-cdecimal/Lib/test/test_cmath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_cmath.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_cmath.py Thu Apr 1 11:38:52 2010 @@ -1,7 +1,6 @@ from test.support import run_unittest from test.test_math import parse_testfile, test_file import unittest -import os, sys import cmath, math from cmath import phase, polar, rect, pi Modified: python/branches/py3k-cdecimal/Lib/test/test_cmd.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_cmd.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_cmd.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Test script for the 'cmd' module Original by Michael Schneider Modified: python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py Thu Apr 1 11:38:52 2010 @@ -2,7 +2,6 @@ # All tests are executed with environment variables ignored # See test_cmd_line_script.py for testing of script execution -import os import test.support, unittest import os import sys Modified: python/branches/py3k-cdecimal/Lib/test/test_cmd_line_script.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_cmd_line_script.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_cmd_line_script.py Thu Apr 1 11:38:52 2010 @@ -3,9 +3,8 @@ import unittest import os import os.path -import sys import test.support -from test.script_helper import (spawn_python, kill_python, run_python, +from test.script_helper import (run_python, temp_dir, make_script, compile_script, make_pkg, make_zip_script, make_zip_pkg) Modified: python/branches/py3k-cdecimal/Lib/test/test_code.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_code.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_code.py Thu Apr 1 11:38:52 2010 @@ -103,8 +103,10 @@ """ import unittest +import weakref import _testcapi + def consts(t): """Yield a doctest-safe sequence of object reprs.""" for elt in t: @@ -131,12 +133,37 @@ self.assertEquals(co.co_firstlineno, 15) +class CodeWeakRefTest(unittest.TestCase): + + def test_basic(self): + # Create a code object in a clean environment so that we know we have + # the only reference to it left. + namespace = {} + exec("def f(): pass", globals(), namespace) + f = namespace["f"] + del namespace + + self.called = False + def callback(code): + self.called = True + + # f is now the last reference to the function, and through it, the code + # object. While we hold it, check that we can create a weakref and + # deref it. Then delete it, and check that the callback gets called and + # the reference dies. + coderef = weakref.ref(f.__code__, callback) + self.assertTrue(bool(coderef())) + del f + self.assertFalse(bool(coderef())) + self.assertTrue(self.called) + + def test_main(verbose=None): from test.support import run_doctest, run_unittest from test import test_code run_doctest(test_code, verbose) - run_unittest(CodeTest) + run_unittest(CodeTest, CodeWeakRefTest) -if __name__ == '__main__': +if __name__ == "__main__": test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_codecencodings_cn.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecencodings_cn.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecencodings_cn.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecencodings_cn.py # Codec encoding tests for PRC encodings. Modified: python/branches/py3k-cdecimal/Lib/test/test_codecencodings_hk.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecencodings_hk.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecencodings_hk.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecencodings_hk.py # Codec encoding tests for HongKong encodings. Modified: python/branches/py3k-cdecimal/Lib/test/test_codecencodings_jp.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecencodings_jp.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecencodings_jp.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecencodings_jp.py # Codec encoding tests for Japanese encodings. Modified: python/branches/py3k-cdecimal/Lib/test/test_codecencodings_kr.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecencodings_kr.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecencodings_kr.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecencodings_kr.py # Codec encoding tests for ROK encodings. Modified: python/branches/py3k-cdecimal/Lib/test/test_codecencodings_tw.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecencodings_tw.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecencodings_tw.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecencodings_tw.py # Codec encoding tests for ROC encodings. Modified: python/branches/py3k-cdecimal/Lib/test/test_codecmaps_cn.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecmaps_cn.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecmaps_cn.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecmaps_cn.py # Codec mapping tests for PRC encodings Modified: python/branches/py3k-cdecimal/Lib/test/test_codecmaps_hk.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecmaps_hk.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecmaps_hk.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecmaps_hk.py # Codec mapping tests for HongKong encodings Modified: python/branches/py3k-cdecimal/Lib/test/test_codecmaps_jp.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecmaps_jp.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecmaps_jp.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecmaps_jp.py # Codec mapping tests for Japanese encodings Modified: python/branches/py3k-cdecimal/Lib/test/test_codecmaps_kr.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecmaps_kr.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecmaps_kr.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecmaps_kr.py # Codec mapping tests for ROK encodings Modified: python/branches/py3k-cdecimal/Lib/test/test_codecmaps_tw.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecmaps_tw.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecmaps_tw.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_codecmaps_tw.py # Codec mapping tests for ROC encodings Modified: python/branches/py3k-cdecimal/Lib/test/test_codecs.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_codecs.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_codecs.py Thu Apr 1 11:38:52 2010 @@ -483,6 +483,21 @@ self.check_state_handling_decode(self.encoding, "spamspam", self.spambe) + def test_bug691291(self): + # Files are always opened in binary mode, even if no binary mode was + # specified. This means that no automatic conversion of '\n' is done + # on reading and writing. + s1 = 'Hello\r\nworld\r\n' + + s = s1.encode(self.encoding) + try: + with open(support.TESTFN, 'wb') as fp: + fp.write(s) + with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader: + self.assertEqual(reader.read(), s1) + finally: + support.unlink(support.TESTFN) + class UTF16LETest(ReadTest): encoding = "utf-16-le" Modified: python/branches/py3k-cdecimal/Lib/test/test_coding.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_coding.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_coding.py Thu Apr 1 11:38:52 2010 @@ -1,6 +1,6 @@ import test.support, unittest -from test.support import TESTFN, unlink +from test.support import TESTFN, unlink, unload import os, sys class CodingTest(unittest.TestCase): @@ -17,9 +17,8 @@ path = os.path.dirname(__file__) filename = os.path.join(path, module_name + '.py') - fp = open(filename, "rb") - bytes = fp.read() - fp.close() + with open(filename, "rb") as fp: + bytes = fp.read() self.assertRaises(SyntaxError, compile, bytes, filename, 'exec') def test_exec_valid_coding(self): @@ -30,9 +29,8 @@ def test_file_parse(self): # issue1134: all encodings outside latin-1 and utf-8 fail on # multiline strings and long lines (>512 columns) - if TESTFN in sys.modules: - del sys.modules[TESTFN] - sys.path.insert(0, ".") + unload(TESTFN) + sys.path.insert(0, os.curdir) filename = TESTFN + ".py" f = open(filename, "w") try: @@ -45,21 +43,20 @@ __import__(TESTFN) finally: f.close() - unlink(TESTFN+".py") - unlink(TESTFN+".pyc") - sys.path.pop(0) + unlink(filename) + unlink(filename + "c") + unload(TESTFN) + del sys.path[0] def test_error_from_string(self): # See http://bugs.python.org/issue6289 input = "# coding: ascii\n\N{SNOWMAN}".encode('utf-8') - try: + with self.assertRaises(SyntaxError) as c: compile(input, "", "exec") - except SyntaxError as e: - expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \ - "ordinal not in range(128)" - self.assertTrue(str(e).startswith(expected)) - else: - self.fail("didn't raise") + expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \ + "ordinal not in range(128)" + self.assertTrue(c.exception.args[0].startswith(expected)) + def test_main(): test.support.run_unittest(CodingTest) Modified: python/branches/py3k-cdecimal/Lib/test/test_collections.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_collections.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_collections.py Thu Apr 1 11:38:52 2010 @@ -7,9 +7,9 @@ from test import mapping_tests import pickle, copy from random import randrange, shuffle -import operator import keyword import re +import sys from collections import Hashable, Iterable, Iterator from collections import Sized, Container, Callable from collections import Set, MutableSet @@ -24,7 +24,6 @@ def test_factory(self): Point = namedtuple('Point', 'x y') self.assertEqual(Point.__name__, 'Point') - self.assertEqual(Point.__doc__, 'Point(x, y)') self.assertEqual(Point.__slots__, ()) self.assertEqual(Point.__module__, __name__) self.assertEqual(Point.__getitem__, tuple.__getitem__) @@ -51,6 +50,12 @@ self.assertRaises(TypeError, Point._make, [11]) # catch too few args self.assertRaises(TypeError, Point._make, [11, 22, 33]) # catch too many args + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") + def test_factory_doc_attr(self): + Point = namedtuple('Point', 'x y') + self.assertEqual(Point.__doc__, 'Point(x, y)') + def test_name_fixer(self): for spec, renamed in [ [('efg', 'g%hi'), ('efg', '_1')], # field with non-alpha char @@ -229,6 +234,17 @@ C = type('C', (abc,), stubs) self.assertRaises(TypeError, C, name) + def validate_isinstance(self, abc, name): + stub = lambda s, *args: 0 + + C = type('C', (object,), {'__hash__': None}) + setattr(C, name, stub) + self.assertIsInstance(C(), abc) + self.assertTrue(issubclass(C, abc)) + + C = type('C', (object,), {'__hash__': None}) + self.assertNotIsInstance(C(), abc) + self.assertFalse(issubclass(C, abc)) class TestOneTrickPonyABCs(ABCTestCase): @@ -256,6 +272,7 @@ self.assertEqual(hash(H()), 0) self.assertFalse(issubclass(int, H)) self.validate_abstract_methods(Hashable, '__hash__') + self.validate_isinstance(Hashable, '__hash__') def test_Iterable(self): # Check some non-iterables @@ -280,6 +297,7 @@ self.assertEqual(list(I()), []) self.assertFalse(issubclass(str, I)) self.validate_abstract_methods(Iterable, '__iter__') + self.validate_isinstance(Iterable, '__iter__') def test_Iterator(self): non_samples = [None, 42, 3.14, 1j, b"", "", (), [], {}, set()] @@ -298,6 +316,7 @@ self.assertIsInstance(x, Iterator) self.assertTrue(issubclass(type(x), Iterator), repr(type(x))) self.validate_abstract_methods(Iterator, '__next__') + self.validate_isinstance(Iterator, '__next__') def test_Sized(self): non_samples = [None, 42, 3.14, 1j, @@ -315,6 +334,7 @@ self.assertIsInstance(x, Sized) self.assertTrue(issubclass(type(x), Sized), repr(type(x))) self.validate_abstract_methods(Sized, '__len__') + self.validate_isinstance(Sized, '__len__') def test_Container(self): non_samples = [None, 42, 3.14, 1j, @@ -332,6 +352,7 @@ self.assertIsInstance(x, Container) self.assertTrue(issubclass(type(x), Container), repr(type(x))) self.validate_abstract_methods(Container, '__contains__') + self.validate_isinstance(Container, '__contains__') def test_Callable(self): non_samples = [None, 42, 3.14, 1j, @@ -351,6 +372,7 @@ self.assertIsInstance(x, Callable) self.assertTrue(issubclass(type(x), Callable), repr(type(x))) self.validate_abstract_methods(Callable, '__call__') + self.validate_isinstance(Callable, '__call__') def test_direct_subclassing(self): for B in Hashable, Iterable, Iterator, Sized, Container, Callable: Modified: python/branches/py3k-cdecimal/Lib/test/test_compile.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_compile.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_compile.py Thu Apr 1 11:38:52 2010 @@ -292,6 +292,10 @@ f1, f2 = f() self.assertNotEqual(id(f1.__code__), id(f2.__code__)) + def test_lambda_doc(self): + l = lambda: "foo" + self.assertIsNone(l.__doc__) + ## def test_unicode_encoding(self): ## code = "# -*- coding: utf-8 -*-\npass\n" ## self.assertRaises(SyntaxError, compile, code, "tmp", "exec") Modified: python/branches/py3k-cdecimal/Lib/test/test_compileall.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_compileall.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_compileall.py Thu Apr 1 11:38:52 2010 @@ -1,14 +1,14 @@ +import sys import compileall import imp import os import py_compile import shutil import struct -import sys import tempfile -import time from test import support import unittest +import io class CompileallTests(unittest.TestCase): @@ -19,6 +19,9 @@ self.bc_path = self.source_path + ('c' if __debug__ else 'o') with open(self.source_path, 'w') as file: file.write('x = 123\n') + self.source_path2 = os.path.join(self.directory, '_test2.py') + self.bc_path2 = self.source_path2 + ('c' if __debug__ else 'o') + shutil.copyfile(self.source_path, self.source_path2) def tearDown(self): shutil.rmtree(self.directory) @@ -54,9 +57,47 @@ # Test a change in mtime leads to a new .pyc. self.recreation_check(b'\0\0\0\0') + def test_compile_files(self): + # Test compiling a single file, and complete directory + for fn in (self.bc_path, self.bc_path2): + try: + os.unlink(fn) + except: + pass + compileall.compile_file(self.source_path, force=False, quiet=True) + self.assertTrue(os.path.isfile(self.bc_path) \ + and not os.path.isfile(self.bc_path2)) + os.unlink(self.bc_path) + compileall.compile_dir(self.directory, force=False, quiet=True) + self.assertTrue(os.path.isfile(self.bc_path) \ + and os.path.isfile(self.bc_path2)) + os.unlink(self.bc_path) + os.unlink(self.bc_path2) + +class EncodingTest(unittest.TestCase): + 'Issue 6716: compileall should escape source code when printing errors to stdout.' + + def setUp(self): + self.directory = tempfile.mkdtemp() + self.source_path = os.path.join(self.directory, '_test.py') + with open(self.source_path, 'w', encoding='utf-8') as file: + file.write('# -*- coding: utf-8 -*-\n') + file.write('print u"\u20ac"\n') + + def tearDown(self): + shutil.rmtree(self.directory) + + def test_error(self): + try: + orig_stdout = sys.stdout + sys.stdout = io.TextIOWrapper(io.BytesIO(),encoding='ascii') + compileall.compile_dir(self.directory) + finally: + sys.stdout = orig_stdout def test_main(): - support.run_unittest(CompileallTests) + support.run_unittest(CompileallTests, + EncodingTest) if __name__ == "__main__": Modified: python/branches/py3k-cdecimal/Lib/test/test_complex.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_complex.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_complex.py Thu Apr 1 11:38:52 2010 @@ -3,6 +3,7 @@ from random import random from math import atan2, isnan, copysign +import operator INF = float("inf") NAN = float("nan") @@ -110,15 +111,23 @@ def test_richcompare(self): self.assertRaises(OverflowError, complex.__eq__, 1+1j, 1<<10000) - self.assertEqual(complex.__lt__(1+1j, None), NotImplemented) + self.assertIs(complex.__lt__(1+1j, None), NotImplemented) self.assertIs(complex.__eq__(1+1j, 1+1j), True) self.assertIs(complex.__eq__(1+1j, 2+2j), False) self.assertIs(complex.__ne__(1+1j, 1+1j), False) self.assertIs(complex.__ne__(1+1j, 2+2j), True) - self.assertRaises(TypeError, complex.__lt__, 1+1j, 2+2j) - self.assertRaises(TypeError, complex.__le__, 1+1j, 2+2j) - self.assertRaises(TypeError, complex.__gt__, 1+1j, 2+2j) - self.assertRaises(TypeError, complex.__ge__, 1+1j, 2+2j) + self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented) + self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented) + self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented) + self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented) + self.assertRaises(TypeError, operator.lt, 1+1j, 2+2j) + self.assertRaises(TypeError, operator.le, 1+1j, 2+2j) + self.assertRaises(TypeError, operator.gt, 1+1j, 2+2j) + self.assertRaises(TypeError, operator.ge, 1+1j, 2+2j) + self.assertIs(operator.eq(1+1j, 1+1j), True) + self.assertIs(operator.eq(1+1j, 2+2j), False) + self.assertIs(operator.ne(1+1j, 1+1j), False) + self.assertIs(operator.ne(1+1j, 2+2j), True) def test_mod(self): # % is no longer supported on complex numbers @@ -490,6 +499,8 @@ self.assertEqual(format(1.5+3j, '^20'), ' (1.5+3j) ') self.assertEqual(format(1.123-3.123j, '^20.2'), ' (1.1-3.1j) ') + self.assertEqual(format(1.5+3j, '20.2f'), ' 1.50+3.00j') + self.assertEqual(format(1.5+3j, '>20.2f'), ' 1.50+3.00j') self.assertEqual(format(1.5+3j, '<20.2f'), '1.50+3.00j ') self.assertEqual(format(1.5e20+3j, '<20.2f'), '150000000000000000000.00+3.00j') self.assertEqual(format(1.5e20+3j, '>40.2f'), ' 150000000000000000000.00+3.00j') Modified: python/branches/py3k-cdecimal/Lib/test/test_contextlib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_contextlib.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_contextlib.py Thu Apr 1 11:38:52 2010 @@ -1,9 +1,8 @@ """Unit tests for contextlib.py, and other context managers.""" -import sys import os -import decimal +import sys import tempfile import unittest import threading @@ -85,7 +84,7 @@ raise ZeroDivisionError(999) self.assertEqual(state, [1, 42, 999]) - def test_contextmanager_attribs(self): + def _create_contextmanager_attribs(self): def attribs(**kw): def decorate(func): for k,v in kw.items(): @@ -96,8 +95,17 @@ @attribs(foo='bar') def baz(spam): """Whee!""" + return baz + + def test_contextmanager_attribs(self): + baz = self._create_contextmanager_attribs() self.assertEqual(baz.__name__,'baz') self.assertEqual(baz.foo, 'bar') + + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") + def test_contextmanager_doc_attrib(self): + baz = self._create_contextmanager_attribs() self.assertEqual(baz.__doc__, "Whee!") class ClosingTestCase(unittest.TestCase): Modified: python/branches/py3k-cdecimal/Lib/test/test_csv.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_csv.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_csv.py Thu Apr 1 11:38:52 2010 @@ -488,10 +488,10 @@ def test_null(self): self.writerAssertEqual([], '') - def test_single(self): + def test_single_writer(self): self.writerAssertEqual([['abc']], 'abc\r\n') - def test_simple(self): + def test_simple_writer(self): self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n') def test_quotes(self): @@ -535,8 +535,12 @@ def test_write_simple_dict(self): with TemporaryFile("w+", newline='') as fileobj: writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"]) + writer.writeheader() + fileobj.seek(0) + self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n") writer.writerow({"f1": 10, "f3": "abc"}) fileobj.seek(0) + fileobj.readline() # header self.assertEqual(fileobj.read(), "10,,abc\r\n") def test_write_no_fields(self): Modified: python/branches/py3k-cdecimal/Lib/test/test_curses.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_curses.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_curses.py Thu Apr 1 11:38:52 2010 @@ -23,6 +23,12 @@ curses = import_module('curses') curses.panel = import_module('curses.panel') +# skip all these tests on FreeBSD: test_curses currently hangs the +# FreeBSD buildbots, preventing other tests from running. See issue +# #7384. +if 'freebsd' in sys.platform: + raise unittest.SkipTest('The curses module is broken on FreeBSD. See http://bugs.python.org/issue7384.') + # XXX: if newterm was supported we could use it instead of initscr and not exit term = os.environ.get('TERM') if not term or term == 'unknown': Modified: python/branches/py3k-cdecimal/Lib/test/test_dbm.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_dbm.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_dbm.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Test script for the dbm.open function based on testdumbdbm.py""" import os Modified: python/branches/py3k-cdecimal/Lib/test/test_dbm_dumb.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_dbm_dumb.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_dbm_dumb.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Test script for the dumbdbm module Original by Roger E. Masse """ Modified: python/branches/py3k-cdecimal/Lib/test/test_decimal.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_decimal.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_decimal.py Thu Apr 1 11:38:52 2010 @@ -24,7 +24,6 @@ with the corresponding argument. """ -import glob import math import os, sys import pickle, copy @@ -473,6 +472,12 @@ self.assertRaises(ValueError, Decimal, (1, (4, 10, 4, 9, 1), 2) ) self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 'a', 1), 2) ) + def test_explicit_from_bool(self): + self.assertIs(bool(Decimal(0)), False) + self.assertIs(bool(Decimal(1)), True) + self.assertEqual(Decimal(False), Decimal(0)) + self.assertEqual(Decimal(True), Decimal(1)) + def test_explicit_from_Decimal(self): #positive Modified: python/branches/py3k-cdecimal/Lib/test/test_deque.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_deque.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_deque.py Thu Apr 1 11:38:52 2010 @@ -7,7 +7,6 @@ import pickle from io import StringIO import random -import os BIG = 100000 Modified: python/branches/py3k-cdecimal/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_descr.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_descr.py Thu Apr 1 11:38:52 2010 @@ -624,7 +624,6 @@ def test_module_subclasses(self): # Testing Python subclass of module... log = [] - import types, sys MT = type(sys) class MM(MT): def __init__(self, name): @@ -1006,7 +1005,6 @@ # Test cyclical leaks [SF bug 519621] class F(object): __slots__ = ['a', 'b'] - log = [] s = F() s.a = [Counted(), s] self.assertEqual(Counted.counter, 1) @@ -1015,7 +1013,7 @@ self.assertEqual(Counted.counter, 0) # Test lookup leaks [SF bug 572567] - import sys,gc + import gc if hasattr(gc, 'get_objects'): class G(object): def __eq__(self, other): @@ -1817,6 +1815,9 @@ else: self.fail("expected ZeroDivisionError from bad property") + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") + def test_properties_doc_attrib(self): class E(object): def getter(self): "getter method" @@ -1829,6 +1830,7 @@ prop2 = property(fset=setter) self.assertEqual(prop2.__doc__, None) + def test_testcapi_no_segfault(self): # this segfaulted in 2.5b2 try: import _testcapi @@ -2034,7 +2036,6 @@ ## self.assertIn('__self__', dir(a.Amethod)) # Try a module subclass. - import sys class M(type(sys)): pass minstance = M("m") @@ -3202,7 +3203,6 @@ self.fail("d.foo should be undefined now") # Test a nasty bug in recurse_down_subclasses() - import gc class A(object): pass class B(A): @@ -3992,7 +3992,6 @@ def test_file_fault(self): # Testing sys.stdout is changed in getattr... - import sys test_stdout = sys.stdout class StdoutGuard: def __getattr__(self, attr): @@ -4083,8 +4082,6 @@ def test_not_implemented(self): # Testing NotImplemented... # all binary methods should be able to return a NotImplemented - import sys - import types import operator def specialmethod(self, other): @@ -4167,6 +4164,15 @@ x.a = 42 self.assertEqual(x.a, 42) + # Also check type_getattro for correctness. + class Meta(type): + pass + class X(object): + __metaclass__ = Meta + X.a = 42 + Meta.a = Descr("a") + self.assertEqual(X.a, 42) + def test_getattr_hooks(self): # issue 4230 Modified: python/branches/py3k-cdecimal/Lib/test/test_dict.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_dict.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_dict.py Thu Apr 1 11:38:52 2010 @@ -1,7 +1,7 @@ import unittest from test import support -import sys, collections, random, string +import collections, random, string import gc, weakref @@ -10,24 +10,24 @@ def test_constructor(self): # calling built-in types without argument must return empty self.assertEqual(dict(), {}) - self.assertTrue(dict() is not {}) + self.assertIsNot(dict(), {}) def test_literal_constructor(self): - # check literal constructor for different sized dicts (to exercise the BUILD_MAP oparg + # check literal constructor for different sized dicts + # (to exercise the BUILD_MAP oparg). for n in (0, 1, 6, 256, 400): - items = [(''.join([random.choice(string.ascii_letters) - for j in range(8)]), - i) + items = [(''.join(random.sample(string.ascii_letters, 8)), i) for i in range(n)] random.shuffle(items) - dictliteral = '{' + ', '.join('%r: %d' % item for item in items) + '}' + formatted_items = ('{!r}: {:d}'.format(k, v) for k, v in items) + dictliteral = '{' + ', '.join(formatted_items) + '}' self.assertEqual(eval(dictliteral), dict(items)) def test_bool(self): - self.assertTrue(not {}) + self.assertIs(not {}, True) self.assertTrue({1: 2}) - self.assertTrue(bool({}) is False) - self.assertTrue(bool({1: 2}) is True) + self.assertIs(bool({}), False) + self.assertIs(bool({1: 2}), True) def test_keys(self): d = {} @@ -59,7 +59,7 @@ def test_contains(self): d = {} self.assertNotIn('a', d) - self.assertTrue(not ('a' in d)) + self.assertFalse('a' in d) self.assertTrue('a' not in d) d = {'a': 1, 'b': 2} self.assertIn('a', d) @@ -198,7 +198,7 @@ def test_fromkeys(self): self.assertEqual(dict.fromkeys('abc'), {'a':None, 'b':None, 'c':None}) d = {} - self.assertTrue(not(d.fromkeys('abc') is d)) + self.assertIsNot(d.fromkeys('abc'), d) self.assertEqual(d.fromkeys('abc'), {'a':None, 'b':None, 'c':None}) self.assertEqual(d.fromkeys((4,5),0), {4:0, 5:0}) self.assertEqual(d.fromkeys([]), {}) @@ -209,8 +209,8 @@ class dictlike(dict): pass self.assertEqual(dictlike.fromkeys('a'), {'a':None}) self.assertEqual(dictlike().fromkeys('a'), {'a':None}) - self.assertTrue(type(dictlike.fromkeys('a')) is dictlike) - self.assertTrue(type(dictlike().fromkeys('a')) is dictlike) + self.assertIsInstance(dictlike.fromkeys('a'), dictlike) + self.assertIsInstance(dictlike().fromkeys('a'), dictlike) class mydict(dict): def __new__(cls): return collections.UserDict() @@ -253,10 +253,10 @@ def test_get(self): d = {} - self.assertTrue(d.get('c') is None) + self.assertIs(d.get('c'), None) self.assertEqual(d.get('c', 3), 3) - d = {'a' : 1, 'b' : 2} - self.assertTrue(d.get('c') is None) + d = {'a': 1, 'b': 2} + self.assertIs(d.get('c'), None) self.assertEqual(d.get('c', 3), 3) self.assertEqual(d.get('a'), 1) self.assertEqual(d.get('a', 3), 1) @@ -266,9 +266,9 @@ def test_setdefault(self): # dict.setdefault() d = {} - self.assertTrue(d.setdefault('key0') is None) + self.assertIs(d.setdefault('key0'), None) d.setdefault('key0', []) - self.assertTrue(d.setdefault('key0') is None) + self.assertIs(d.setdefault('key0'), None) d.setdefault('key', []).append(3) self.assertEqual(d['key'][0], 3) d.setdefault('key', []).append(4) @@ -310,9 +310,9 @@ self.assertEqual(va, int(ka)) kb, vb = tb = b.popitem() self.assertEqual(vb, int(kb)) - self.assertTrue(not(copymode < 0 and ta != tb)) - self.assertTrue(not a) - self.assertTrue(not b) + self.assertFalse(copymode < 0 and ta != tb) + self.assertFalse(a) + self.assertFalse(b) d = {} self.assertRaises(KeyError, d.popitem) @@ -351,15 +351,12 @@ self.assertRaises(Exc, d.pop, x) def test_mutatingiteration(self): + # changing dict size during iteration d = {} d[1] = 1 - try: + with self.assertRaises(RuntimeError): for i in d: d[i+1] = 1 - except RuntimeError: - pass - else: - self.fail("changing dict size during iteration doesn't raise Error") def test_repr(self): d = {} @@ -393,12 +390,9 @@ d1 = {BadCmp(): 1} d2 = {1: 1} - try: + + with self.assertRaises(Exc): d1 == d2 - except Exc: - pass - else: - self.fail("< didn't raise Exc") def test_keys_contained(self): self.helper_keys_contained(lambda x: x.keys()) @@ -452,62 +446,70 @@ class C: def __eq__(self, other): raise RuntimeError + d1 = {1: C()} d2 = {1: C()} - self.assertRaises(RuntimeError, lambda: d1.items() == d2.items()) - self.assertRaises(RuntimeError, lambda: d1.items() != d2.items()) - self.assertRaises(RuntimeError, lambda: d1.items() <= d2.items()) - self.assertRaises(RuntimeError, lambda: d1.items() >= d2.items()) + with self.assertRaises(RuntimeError): + d1.items() == d2.items() + with self.assertRaises(RuntimeError): + d1.items() != d2.items() + with self.assertRaises(RuntimeError): + d1.items() <= d2.items() + with self.assertRaises(RuntimeError): + d1.items() >= d2.items() + d3 = {1: C(), 2: C()} - self.assertRaises(RuntimeError, lambda: d2.items() < d3.items()) - self.assertRaises(RuntimeError, lambda: d3.items() > d2.items()) + with self.assertRaises(RuntimeError): + d2.items() < d3.items() + with self.assertRaises(RuntimeError): + d3.items() > d2.items() def test_dictview_set_operations_on_keys(self): k1 = {1:1, 2:2}.keys() k2 = {1:1, 2:2, 3:3}.keys() k3 = {4:4}.keys() - self.assertEquals(k1 - k2, set()) - self.assertEquals(k1 - k3, {1,2}) - self.assertEquals(k2 - k1, {3}) - self.assertEquals(k3 - k1, {4}) - self.assertEquals(k1 & k2, {1,2}) - self.assertEquals(k1 & k3, set()) - self.assertEquals(k1 | k2, {1,2,3}) - self.assertEquals(k1 ^ k2, {3}) - self.assertEquals(k1 ^ k3, {1,2,4}) + self.assertEqual(k1 - k2, set()) + self.assertEqual(k1 - k3, {1,2}) + self.assertEqual(k2 - k1, {3}) + self.assertEqual(k3 - k1, {4}) + self.assertEqual(k1 & k2, {1,2}) + self.assertEqual(k1 & k3, set()) + self.assertEqual(k1 | k2, {1,2,3}) + self.assertEqual(k1 ^ k2, {3}) + self.assertEqual(k1 ^ k3, {1,2,4}) def test_dictview_set_operations_on_items(self): k1 = {1:1, 2:2}.items() k2 = {1:1, 2:2, 3:3}.items() k3 = {4:4}.items() - self.assertEquals(k1 - k2, set()) - self.assertEquals(k1 - k3, {(1,1), (2,2)}) - self.assertEquals(k2 - k1, {(3,3)}) - self.assertEquals(k3 - k1, {(4,4)}) - self.assertEquals(k1 & k2, {(1,1), (2,2)}) - self.assertEquals(k1 & k3, set()) - self.assertEquals(k1 | k2, {(1,1), (2,2), (3,3)}) - self.assertEquals(k1 ^ k2, {(3,3)}) - self.assertEquals(k1 ^ k3, {(1,1), (2,2), (4,4)}) + self.assertEqual(k1 - k2, set()) + self.assertEqual(k1 - k3, {(1,1), (2,2)}) + self.assertEqual(k2 - k1, {(3,3)}) + self.assertEqual(k3 - k1, {(4,4)}) + self.assertEqual(k1 & k2, {(1,1), (2,2)}) + self.assertEqual(k1 & k3, set()) + self.assertEqual(k1 | k2, {(1,1), (2,2), (3,3)}) + self.assertEqual(k1 ^ k2, {(3,3)}) + self.assertEqual(k1 ^ k3, {(1,1), (2,2), (4,4)}) def test_dictview_mixed_set_operations(self): # Just a few for .keys() self.assertTrue({1:1}.keys() == {1}) self.assertTrue({1} == {1:1}.keys()) - self.assertEquals({1:1}.keys() | {2}, {1, 2}) - self.assertEquals({2} | {1:1}.keys(), {1, 2}) + self.assertEqual({1:1}.keys() | {2}, {1, 2}) + self.assertEqual({2} | {1:1}.keys(), {1, 2}) # And a few for .items() self.assertTrue({1:1}.items() == {(1,1)}) self.assertTrue({(1,1)} == {1:1}.items()) - self.assertEquals({1:1}.items() | {2}, {(1,1), 2}) - self.assertEquals({2} | {1:1}.items(), {(1,1), 2}) + self.assertEqual({1:1}.items() | {2}, {(1,1), 2}) + self.assertEqual({2} | {1:1}.items(), {(1,1), 2}) def test_missing(self): # Make sure dict doesn't have a __missing__ method - self.assertEqual(hasattr(dict, "__missing__"), False) - self.assertEqual(hasattr({}, "__missing__"), False) + self.assertFalse(hasattr(dict, "__missing__")) + self.assertFalse(hasattr({}, "__missing__")) # Test several cases: # (D) subclass defines __missing__ method returning a value # (E) subclass defines __missing__ method raising RuntimeError @@ -522,46 +524,37 @@ self.assertNotIn(2, d) self.assertNotIn(2, d.keys()) self.assertEqual(d[2], 42) + class E(dict): def __missing__(self, key): raise RuntimeError(key) e = E() - try: + with self.assertRaises(RuntimeError) as c: e[42] - except RuntimeError as err: - self.assertEqual(err.args, (42,)) - else: - self.fail("e[42] didn't raise RuntimeError") + self.assertEqual(c.exception.args, (42,)) + class F(dict): def __init__(self): # An instance variable __missing__ should have no effect self.__missing__ = lambda key: None f = F() - try: + with self.assertRaises(KeyError) as c: f[42] - except KeyError as err: - self.assertEqual(err.args, (42,)) - else: - self.fail("f[42] didn't raise KeyError") + self.assertEqual(c.exception.args, (42,)) + class G(dict): pass g = G() - try: + with self.assertRaises(KeyError) as c: g[42] - except KeyError as err: - self.assertEqual(err.args, (42,)) - else: - self.fail("g[42] didn't raise KeyError") + self.assertEqual(c.exception.args, (42,)) def test_tuple_keyerror(self): # SF #1576657 d = {} - try: + with self.assertRaises(KeyError) as c: d[(1,)] - except KeyError as e: - self.assertEqual(e.args, ((1,),)) - else: - self.fail("missing KeyError") + self.assertEqual(c.exception.args, ((1,),)) def test_bad_key(self): # Dictionary lookups should fail if __eq__() raises an exception. @@ -588,12 +581,8 @@ 'd.setdefault(x2, 42)', 'd.pop(x2)', 'd.update({x2: 2})']: - try: + with self.assertRaises(CustomException): exec(stmt, locals()) - except CustomException: - pass - else: - self.fail("Statement %r didn't raise exception" % stmt) def test_resize1(self): # Dict resizing bug, found by Jack Jansen in 2.2 CVS development. @@ -636,11 +625,9 @@ def test_empty_presized_dict_in_freelist(self): # Bug #3537: if an empty but presized dict with a size larger # than 7 was in the freelist, it triggered an assertion failure - try: - d = {'a': 1/0, 'b': None, 'c': None, 'd': None, 'e': None, + with self.assertRaises(ZeroDivisionError): + d = {'a': 1 // 0, 'b': None, 'c': None, 'd': None, 'e': None, 'f': None, 'g': None, 'h': None} - except ZeroDivisionError: - pass d = {} def test_container_iterator(self): @@ -657,7 +644,7 @@ obj.x = iter(obj.v) del obj, container gc.collect() - self.assertTrue(ref() is None, "Cycle was not collected") + self.assertIs(ref(), None, "Cycle was not collected") def _not_tracked(self, t): # Nested containers can take several collections to untrack Modified: python/branches/py3k-cdecimal/Lib/test/test_doctest.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_doctest.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_doctest.py Thu Apr 1 11:38:52 2010 @@ -2149,6 +2149,13 @@ called with the name of a file, which is taken to be relative to the calling module. The return value is (#failures, #tests). +We don't want `-v` in sys.argv for these tests. + + >>> save_argv = sys.argv + >>> if '-v' in sys.argv: + ... sys.argv = [arg for arg in save_argv if arg != '-v'] + + >>> doctest.testfile('test_doctest.txt') # doctest: +ELLIPSIS ********************************************************************** File "...", line 6, in test_doctest.txt @@ -2288,6 +2295,28 @@ >>> doctest.testfile('test_doctest4.txt', encoding='utf-8') TestResults(failed=0, attempted=2) >>> doctest.master = None # Reset master. + +Test the verbose output: + + >>> doctest.testfile('test_doctest4.txt', encoding='utf-8', verbose=True) + Trying: + 'f????' + Expecting: + 'f\xf6\xf6' + ok + Trying: + 'b??r' + Expecting: + 'b\u0105r' + ok + 1 items passed all tests: + 2 tests in test_doctest4.txt + 2 tests in 1 items. + 2 passed and 0 failed. + Test passed. + TestResults(failed=0, attempted=2) + >>> doctest.master = None # Reset master. + >>> sys.argv = save_argv """ def test_testmod(): r""" @@ -2297,7 +2326,7 @@ out of the binary module. >>> import unicodedata - >>> doctest.testmod(unicodedata) + >>> doctest.testmod(unicodedata, verbose=False) TestResults(failed=0, attempted=0) """ Modified: python/branches/py3k-cdecimal/Lib/test/test_doctest2.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_doctest2.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_doctest2.py Thu Apr 1 11:38:52 2010 @@ -12,7 +12,11 @@ """ +import sys +import unittest from test import support +if sys.flags.optimize >= 2: + raise unittest.SkipTest("Cannot test docstrings with -O2") class C(object): """Class C. Modified: python/branches/py3k-cdecimal/Lib/test/test_docxmlrpc.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_docxmlrpc.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_docxmlrpc.py Thu Apr 1 11:38:52 2010 @@ -1,12 +1,28 @@ from xmlrpc.server import DocXMLRPCServer import http.client +import sys from test import support import threading import time +import socket import unittest PORT = None +def make_request_and_skipIf(condition, reason): + # If we skip the test, we have to make a request because the + # the server created in setUp blocks expecting one to come in. + if not condition: + return lambda func: func + def decorator(func): + def make_request_and_skip(self): + self.client.request("GET", "/") + self.client.getresponse() + raise unittest.SkipTest(reason) + return make_request_and_skip + return decorator + + def server(evt, numrequests): serv = DocXMLRPCServer(("localhost", 0), logRequests=False) @@ -110,10 +126,12 @@ b'<lambda>(x, y)'), response.read()) + @make_request_and_skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") def test_autolinking(self): - """Test that the server correctly automatically wraps references to PEPS - and RFCs with links, and that it linkifies text starting with http or - ftp protocol prefixes. + """Test that the server correctly automatically wraps references to + PEPS and RFCs with links, and that it linkifies text starting with + http or ftp protocol prefixes. The documentation for the "add" method contains the test material. """ @@ -132,11 +150,13 @@ b'auto-linked, too:
\n' b'http://google.com.'), response) + @make_request_and_skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") def test_system_methods(self): """Test the precense of three consecutive system.* methods. - This also tests their use of parameter type recognition and the systems - related to that process. + This also tests their use of parameter type recognition and the + systems related to that process. """ self.client.request("GET", "/") response = self.client.getresponse().read() Modified: python/branches/py3k-cdecimal/Lib/test/test_eof.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_eof.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_eof.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """test script for a few new invalid token catches""" import unittest Modified: python/branches/py3k-cdecimal/Lib/test/test_epoll.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_epoll.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_epoll.py Thu Apr 1 11:38:52 2010 @@ -21,12 +21,10 @@ """ Tests for epoll wrapper. """ -import os import socket import errno import time import select -import tempfile import unittest from test import support Modified: python/branches/py3k-cdecimal/Lib/test/test_errno.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_errno.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_errno.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Test the errno module Roger E. Masse """ Modified: python/branches/py3k-cdecimal/Lib/test/test_exceptions.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_exceptions.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_exceptions.py Thu Apr 1 11:38:52 2010 @@ -6,7 +6,8 @@ import pickle import weakref -from test.support import TESTFN, unlink, run_unittest, captured_output +from test.support import (TESTFN, unlink, run_unittest, captured_output, + gc_collect) # XXX This is not really enough, each *operation* should be tested! @@ -554,6 +555,20 @@ del g self.assertEquals(sys.exc_info()[0], TypeError) + def test_generator_finalizing_and_exc_info(self): + # See #7173 + def simple_gen(): + yield 1 + def run_gen(): + gen = simple_gen() + try: + raise RuntimeError + except RuntimeError: + return next(gen) + run_gen() + gc_collect() + self.assertEqual(sys.exc_info(), (None, None, None)) + def test_3114(self): # Bug #3114: in its destructor, MyObject retrieves a pointer to # obsolete and/or deallocated objects. @@ -568,6 +583,42 @@ pass self.assertEquals(e, (None, None, None)) + def testUnicodeChangeAttributes(self): + # See issue 7309. This was a crasher. + + u = UnicodeEncodeError('baz', 'xxxxx', 1, 5, 'foo') + self.assertEqual(str(u), "'baz' codec can't encode characters in position 1-4: foo") + u.end = 2 + self.assertEqual(str(u), "'baz' codec can't encode character '\\x78' in position 1: foo") + u.end = 5 + u.reason = 0x345345345345345345 + self.assertEqual(str(u), "'baz' codec can't encode characters in position 1-4: 965230951443685724997") + u.encoding = 4000 + self.assertEqual(str(u), "'4000' codec can't encode characters in position 1-4: 965230951443685724997") + u.start = 1000 + self.assertEqual(str(u), "'4000' codec can't encode characters in position 1000-4: 965230951443685724997") + + u = UnicodeDecodeError('baz', b'xxxxx', 1, 5, 'foo') + self.assertEqual(str(u), "'baz' codec can't decode bytes in position 1-4: foo") + u.end = 2 + self.assertEqual(str(u), "'baz' codec can't decode byte 0x78 in position 1: foo") + u.end = 5 + u.reason = 0x345345345345345345 + self.assertEqual(str(u), "'baz' codec can't decode bytes in position 1-4: 965230951443685724997") + u.encoding = 4000 + self.assertEqual(str(u), "'4000' codec can't decode bytes in position 1-4: 965230951443685724997") + u.start = 1000 + self.assertEqual(str(u), "'4000' codec can't decode bytes in position 1000-4: 965230951443685724997") + + u = UnicodeTranslateError('xxxx', 1, 5, 'foo') + self.assertEqual(str(u), "can't translate characters in position 1-4: foo") + u.end = 2 + self.assertEqual(str(u), "can't translate character '\\x78' in position 1: foo") + u.end = 5 + u.reason = 0x345345345345345345 + self.assertEqual(str(u), "can't translate characters in position 1-4: 965230951443685724997") + u.start = 1000 + self.assertEqual(str(u), "can't translate characters in position 1000-4: 965230951443685724997") def test_badisinstance(self): # Bug #2542: if issubclass(e, MyException) raises an exception, Modified: python/branches/py3k-cdecimal/Lib/test/test_extcall.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_extcall.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_extcall.py Thu Apr 1 11:38:52 2010 @@ -1,3 +1,4 @@ + """Doctest for method/function calls. We're going the use these types for extra testing @@ -65,17 +66,17 @@ >>> g() Traceback (most recent call last): ... - TypeError: g() takes at least 1 positional argument (0 given) + TypeError: g() takes at least 1 argument (0 given) >>> g(*()) Traceback (most recent call last): ... - TypeError: g() takes at least 1 positional argument (0 given) + TypeError: g() takes at least 1 argument (0 given) >>> g(*(), **{}) Traceback (most recent call last): ... - TypeError: g() takes at least 1 positional argument (0 given) + TypeError: g() takes at least 1 argument (0 given) >>> g(1) 1 () {} @@ -261,13 +262,37 @@ ... print(a,b) >>> f(**x) 1 2 + +A obscure message: + + >>> def f(a, b): + ... pass + >>> f(b=1) + Traceback (most recent call last): + ... + TypeError: f() takes exactly 2 arguments (1 given) + +The number of arguments passed in includes keywords: + + >>> def f(a): + ... pass + >>> f(6, a=4, *(1, 2, 3)) + Traceback (most recent call last): + ... + TypeError: f() takes exactly 1 argument (5 given) + >>> def f(a, *, kw): + ... pass + >>> f(6, 4, kw=4) + Traceback (most recent call last): + ... + TypeError: f() takes exactly 2 arguments (3 given) """ +import sys from test import support def test_main(): - from test import test_extcall # self import - support.run_doctest(test_extcall, True) + support.run_doctest(sys.modules[__name__], True) if __name__ == '__main__': test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_file.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_file.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_file.py Thu Apr 1 11:38:52 2010 @@ -7,7 +7,7 @@ import io import _pyio as pyio -from test.support import TESTFN, findfile, run_unittest +from test.support import TESTFN, run_unittest from collections import UserList class AutoFileTests(unittest.TestCase): @@ -166,7 +166,7 @@ except ValueError as msg: if msg.args[0] != 0: s = str(msg) - if s.find(TESTFN) != -1 or s.find(bad_mode) == -1: + if TESTFN in s or bad_mode not in s: self.fail("bad error message for invalid mode: %s" % s) # if msg.args[0] == 0, we're probably on Windows where there may be # no obvious way to discover why open() failed. Modified: python/branches/py3k-cdecimal/Lib/test/test_filecmp.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_filecmp.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_filecmp.py Thu Apr 1 11:38:52 2010 @@ -1,5 +1,5 @@ -import os, filecmp, shutil, tempfile, shutil +import os, filecmp, shutil, tempfile import unittest from test import support Modified: python/branches/py3k-cdecimal/Lib/test/test_fileio.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_fileio.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_fileio.py Thu Apr 1 11:38:52 2010 @@ -8,9 +8,7 @@ from weakref import proxy from functools import wraps -from test.support import (TESTFN, findfile, check_warnings, run_unittest, - make_bad_fd) -from collections import UserList +from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd from _io import FileIO as _FileIO @@ -320,7 +318,7 @@ except ValueError as msg: if msg.args[0] != 0: s = str(msg) - if s.find(TESTFN) != -1 or s.find(bad_mode) == -1: + if TESTFN in s or bad_mode not in s: self.fail("bad error message for invalid mode: %s" % s) # if msg.args[0] == 0, we're probably on Windows where there may be # no obvious way to discover why open() failed. @@ -390,7 +388,7 @@ self.assertRaises(TypeError, _FileIO, "1", 0, 0) def testWarnings(self): - with check_warnings() as w: + with check_warnings(quiet=True) as w: self.assertEqual(w.warnings, []) self.assertRaises(TypeError, _FileIO, []) self.assertEqual(w.warnings, []) Modified: python/branches/py3k-cdecimal/Lib/test/test_float.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_float.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_float.py Thu Apr 1 11:38:52 2010 @@ -546,7 +546,6 @@ if float.__getformat__("double").startswith("IEEE"): def test_negative_zero(self): - import math def pos_pos(): return 0.0, math.atan2(0.0, -1) def pos_neg(): Modified: python/branches/py3k-cdecimal/Lib/test/test_fnmatch.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_fnmatch.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_fnmatch.py Thu Apr 1 11:38:52 2010 @@ -7,13 +7,13 @@ class FnmatchTestCase(unittest.TestCase): - def check_match(self, filename, pattern, should_match=1): + def check_match(self, filename, pattern, should_match=1, fn=fnmatch): if should_match: - self.assertTrue(fnmatch(filename, pattern), + self.assertTrue(fn(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: - self.assertTrue(not fnmatch(filename, pattern), + self.assertTrue(not fn(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) @@ -50,6 +50,11 @@ self.assertRaises(TypeError, fnmatchcase, 'test', b'*') self.assertRaises(TypeError, fnmatchcase, b'test', '*') + def test_fnmatchcase(self): + check = self.check_match + check('AbC', 'abc', 0, fnmatchcase) + check('abc', 'AbC', 0, fnmatchcase) + def test_bytes(self): self.check_match(b'test', b'te*') self.check_match(b'test\xff', b'te*\xff') Modified: python/branches/py3k-cdecimal/Lib/test/test_fork1.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_fork1.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_fork1.py Thu Apr 1 11:38:52 2010 @@ -1,7 +1,6 @@ """This test checks for correct fork() behavior. """ -import errno import imp import os import signal Modified: python/branches/py3k-cdecimal/Lib/test/test_format.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_format.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_format.py Thu Apr 1 11:38:52 2010 @@ -10,9 +10,7 @@ # they crash python) # test on unicode strings as well -overflowok = 1 - -def testformat(formatstr, args, output=None, limit=None): +def testformat(formatstr, args, output=None, limit=None, overflowok=False): if verbose: if output: print("%r %% %r =? %r ..." %\ @@ -50,13 +48,19 @@ class FormatTest(unittest.TestCase): def test_format(self): - global overflowok - testformat("%.1d", (1,), "1") - testformat("%.*d", (sys.maxsize,1)) # expect overflow - testformat("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') - testformat("%#.117x", (1,), '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') - testformat("%#.118x", (1,), '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') + testformat("%.*d", (sys.maxsize,1), overflowok=True) # expect overflow + testformat("%.100d", (1,), '00000000000000000000000000000000000000' + '000000000000000000000000000000000000000000000000000000' + '00000001', overflowok=True) + testformat("%#.117x", (1,), '0x00000000000000000000000000000000000' + '000000000000000000000000000000000000000000000000000000' + '0000000000000000000000000001', + overflowok=True) + testformat("%#.118x", (1,), '0x00000000000000000000000000000000000' + '000000000000000000000000000000000000000000000000000000' + '00000000000000000000000000001', + overflowok=True) testformat("%f", (1.0,), "1.000000") # these are trying to test the limits of the internal magic-number-length @@ -76,7 +80,6 @@ testformat("%#.*f", (110, -1.e+100/3.)) testformat("%#.*F", (110, -1.e+100/3.)) # Formatting of integers. Overflow is not ok - overflowok = 0 testformat("%x", 10, "a") testformat("%x", 100000000000, "174876e800") testformat("%o", 10, "12") Modified: python/branches/py3k-cdecimal/Lib/test/test_fractions.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_fractions.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_fractions.py Thu Apr 1 11:38:52 2010 @@ -479,8 +479,21 @@ def testBigComplexComparisons(self): self.assertFalse(F(10**23) == complex(10**23)) - self.assertTrue(F(10**23) > complex(10**23)) - self.assertFalse(F(10**23) <= complex(10**23)) + self.assertRaises(TypeError, operator.gt, F(10**23), complex(10**23)) + self.assertRaises(TypeError, operator.le, F(10**23), complex(10**23)) + + x = F(3, 8) + z = complex(0.375, 0.0) + w = complex(0.375, 0.2) + self.assertTrue(x == z) + self.assertFalse(x != z) + self.assertFalse(x == w) + self.assertTrue(x != w) + for op in operator.lt, operator.le, operator.gt, operator.ge: + self.assertRaises(TypeError, op, x, z) + self.assertRaises(TypeError, op, z, x) + self.assertRaises(TypeError, op, x, w) + self.assertRaises(TypeError, op, w, x) def testMixedEqual(self): self.assertTrue(0.5 == F(1, 2)) Modified: python/branches/py3k-cdecimal/Lib/test/test_frozen.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_frozen.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_frozen.py Thu Apr 1 11:38:52 2010 @@ -2,7 +2,7 @@ from test.support import captured_stdout, run_unittest import unittest -import sys, os +import sys class FrozenTests(unittest.TestCase): def test_frozen(self): Modified: python/branches/py3k-cdecimal/Lib/test/test_ftplib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_ftplib.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_ftplib.py Thu Apr 1 11:38:52 2010 @@ -296,7 +296,9 @@ try: return super(SSLConnection, self).send(data) except ssl.SSLError as err: - if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN): + if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN, + ssl.SSL_ERROR_WANT_READ, + ssl.SSL_ERROR_WANT_WRITE): return 0 raise @@ -304,6 +306,9 @@ try: return super(SSLConnection, self).recv(buffer_size) except ssl.SSLError as err: + if err.args[0] in (ssl.SSL_ERROR_WANT_READ, + ssl.SSL_ERROR_WANT_WRITE): + return '' if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN): self.handle_close() return b'' Modified: python/branches/py3k-cdecimal/Lib/test/test_functools.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_functools.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_functools.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,5 @@ import functools +import sys import unittest from test import support from weakref import proxy @@ -44,9 +45,17 @@ # 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)) + self.assertRaises(AttributeError, setattr, p, 'func', map) + self.assertRaises(AttributeError, setattr, p, 'args', (1, 2)) + self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2)) + + p = self.thetype(hex) + try: + del p.__dict__ + except TypeError: + pass + else: + self.fail('partial object allowed __dict__ to be deleted') def test_argument_checking(self): self.assertRaises(TypeError, self.thetype) # need at least a func arg @@ -122,15 +131,6 @@ 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) @@ -180,7 +180,7 @@ for key in wrapped_attr: self.assertTrue(wrapped_attr[key] is wrapper_attr[key]) - def test_default_update(self): + def _default_update(self): def f(): """This is a test""" pass @@ -188,11 +188,20 @@ def wrapper(): pass functools.update_wrapper(wrapper, f) + return wrapper, f + + def test_default_update(self): + wrapper, f = self._default_update() self.check_wrapper(wrapper, f) self.assertEqual(wrapper.__name__, 'f') - self.assertEqual(wrapper.__doc__, 'This is a test') self.assertEqual(wrapper.attr, 'This is also a test') + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") + def test_default_update_doc(self): + wrapper, f = self._default_update() + self.assertEqual(wrapper.__doc__, 'This is a test') + def test_no_update(self): def f(): """This is a test""" @@ -233,7 +242,7 @@ class TestWraps(TestUpdateWrapper): - def test_default_update(self): + def _default_update(self): def f(): """This is a test""" pass @@ -242,10 +251,19 @@ def wrapper(): pass self.check_wrapper(wrapper, f) + return wrapper + + def test_default_update(self): + wrapper = self._default_update() self.assertEqual(wrapper.__name__, 'f') - self.assertEqual(wrapper.__doc__, 'This is a test') self.assertEqual(wrapper.attr, 'This is also a test') + @unittest.skipIf(not sys.flags.optimize <= 1, + "Docstrings are omitted with -O2 and above") + def test_default_update_doc(self): + wrapper = self._default_update() + self.assertEqual(wrapper.__doc__, 'This is a test') + def test_no_update(self): def f(): """This is a test""" @@ -350,7 +368,6 @@ def test_main(verbose=None): - import sys test_classes = ( TestPartial, TestPartialSubclass, Modified: python/branches/py3k-cdecimal/Lib/test/test_genericpath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_genericpath.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_genericpath.py Thu Apr 1 11:38:52 2010 @@ -1,38 +1,111 @@ +""" +Tests common to genericpath, macpath, ntpath and posixpath +""" + import unittest from test import support import os import genericpath -class AllCommonTest(unittest.TestCase): + +def safe_rmdir(dirname): + try: + os.rmdir(dirname) + except OSError: + pass + + +class GenericTest(unittest.TestCase): + # The path module to be tested + pathmodule = genericpath + common_attributes = ['commonprefix', 'getsize', 'getatime', 'getctime', + 'getmtime', 'exists', 'isdir', 'isfile'] + attributes = [] + + def test_no_argument(self): + for attr in self.common_attributes + self.attributes: + with self.assertRaises(TypeError): + getattr(self.pathmodule, attr)() + raise self.fail("{}.{}() did not raise a TypeError" + .format(self.pathmodule.__name__, attr)) def test_commonprefix(self): + commonprefix = self.pathmodule.commonprefix self.assertEqual( - genericpath.commonprefix([]), + commonprefix([]), "" ) self.assertEqual( - genericpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"]), + commonprefix(["/home/swenson/spam", "/home/swen/spam"]), "/home/swen" ) self.assertEqual( - genericpath.commonprefix(["/home/swen/spam", "/home/swen/eggs"]), + commonprefix(["/home/swen/spam", "/home/swen/eggs"]), "/home/swen/" ) self.assertEqual( - genericpath.commonprefix(["/home/swen/spam", "/home/swen/spam"]), + commonprefix(["/home/swen/spam", "/home/swen/spam"]), "/home/swen/spam" ) + self.assertEqual( + commonprefix(["home:swenson:spam", "home:swen:spam"]), + "home:swen" + ) + self.assertEqual( + commonprefix([":home:swen:spam", ":home:swen:eggs"]), + ":home:swen:" + ) + self.assertEqual( + commonprefix([":home:swen:spam", ":home:swen:spam"]), + ":home:swen:spam" + ) + + self.assertEqual( + commonprefix([b"/home/swenson/spam", b"/home/swen/spam"]), + b"/home/swen" + ) + self.assertEqual( + commonprefix([b"/home/swen/spam", b"/home/swen/eggs"]), + b"/home/swen/" + ) + self.assertEqual( + commonprefix([b"/home/swen/spam", b"/home/swen/spam"]), + b"/home/swen/spam" + ) + self.assertEqual( + commonprefix([b"home:swenson:spam", b"home:swen:spam"]), + b"home:swen" + ) + self.assertEqual( + commonprefix([b":home:swen:spam", b":home:swen:eggs"]), + b":home:swen:" + ) + self.assertEqual( + commonprefix([b":home:swen:spam", b":home:swen:spam"]), + b":home:swen:spam" + ) + + testlist = ['', 'abc', 'Xbcd', 'Xb', 'XY', 'abcd', + 'aXc', 'abd', 'ab', 'aX', 'abcX'] + for s1 in testlist: + for s2 in testlist: + p = commonprefix([s1, s2]) + self.assertTrue(s1.startswith(p)) + self.assertTrue(s2.startswith(p)) + if s1 != s2: + n = len(p) + self.assertNotEqual(s1[n:n+1], s2[n:n+1]) def test_getsize(self): f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertEqual(genericpath.getsize(support.TESTFN), 3) + self.assertEqual(self.pathmodule.getsize(support.TESTFN), 3) finally: if not f.closed: f.close() - os.remove(support.TESTFN) + support.unlink(support.TESTFN) def test_time(self): f = open(support.TESTFN, "wb") @@ -48,134 +121,177 @@ self.assertEqual(d, b"foobar") self.assertLessEqual( - genericpath.getctime(support.TESTFN), - genericpath.getmtime(support.TESTFN) + self.pathmodule.getctime(support.TESTFN), + self.pathmodule.getmtime(support.TESTFN) ) finally: if not f.closed: f.close() - os.remove(support.TESTFN) + support.unlink(support.TESTFN) def test_exists(self): - self.assertIs(genericpath.exists(support.TESTFN), False) + self.assertIs(self.pathmodule.exists(support.TESTFN), False) f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.exists(support.TESTFN), True) + self.assertIs(self.pathmodule.exists(support.TESTFN), True) + if not self.pathmodule == genericpath: + self.assertIs(self.pathmodule.lexists(support.TESTFN), + True) finally: if not f.close(): f.close() - try: - os.remove(support.TESTFN) - except os.error: - pass - - self.assertRaises(TypeError, genericpath.exists) + support.unlink(support.TESTFN) def test_isdir(self): - self.assertIs(genericpath.isdir(support.TESTFN), False) + self.assertIs(self.pathmodule.isdir(support.TESTFN), False) f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.isdir(support.TESTFN), False) + self.assertIs(self.pathmodule.isdir(support.TESTFN), False) os.remove(support.TESTFN) os.mkdir(support.TESTFN) - self.assertIs(genericpath.isdir(support.TESTFN), True) + self.assertIs(self.pathmodule.isdir(support.TESTFN), True) os.rmdir(support.TESTFN) finally: if not f.close(): f.close() - try: - os.remove(support.TESTFN) - except os.error: - pass - try: - os.rmdir(support.TESTFN) - except os.error: - pass - - self.assertRaises(TypeError, genericpath.isdir) + support.unlink(support.TESTFN) + safe_rmdir(support.TESTFN) def test_isfile(self): - self.assertIs(genericpath.isfile(support.TESTFN), False) + self.assertIs(self.pathmodule.isfile(support.TESTFN), False) f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.isfile(support.TESTFN), True) + self.assertIs(self.pathmodule.isfile(support.TESTFN), True) os.remove(support.TESTFN) os.mkdir(support.TESTFN) - self.assertIs(genericpath.isfile(support.TESTFN), False) + self.assertIs(self.pathmodule.isfile(support.TESTFN), False) os.rmdir(support.TESTFN) finally: if not f.close(): f.close() - try: - os.remove(support.TESTFN) - except os.error: - pass - try: - os.rmdir(support.TESTFN) - except os.error: - pass - - self.assertRaises(TypeError, genericpath.isdir) - - def test_samefile(self): - f = open(support.TESTFN + "1", "wb") - try: - f.write(b"foo") - f.close() - self.assertIs( - genericpath.samefile( - support.TESTFN + "1", - support.TESTFN + "1" - ), - True - ) - # If we don't have links, assume that os.stat doesn't return resonable - # inode information and thus, that samefile() doesn't work - if hasattr(os, "symlink"): - os.symlink( - support.TESTFN + "1", - support.TESTFN + "2" - ) - self.assertIs( - genericpath.samefile( - support.TESTFN + "1", - support.TESTFN + "2" - ), - True - ) - os.remove(support.TESTFN + "2") - f = open(support.TESTFN + "2", "wb") - f.write(b"bar") - f.close() - self.assertIs( - genericpath.samefile( - support.TESTFN + "1", - support.TESTFN + "2" - ), - False - ) - finally: - if not f.close(): - f.close() - try: - os.remove(support.TESTFN + "1") - except os.error: - pass - try: - os.remove(support.TESTFN + "2") - except os.error: - pass + support.unlink(support.TESTFN) + safe_rmdir(support.TESTFN) + + +class CommonTest(GenericTest): + # The path module to be tested + pathmodule = None + common_attributes = GenericTest.common_attributes + [ + # Properties + 'curdir', 'pardir', 'extsep', 'sep', + 'pathsep', 'defpath', 'altsep', 'devnull', + # Methods + 'normcase', 'splitdrive', 'expandvars', 'normpath', 'abspath', + 'join', 'split', 'splitext', 'isabs', 'basename', 'dirname', + 'lexists', 'islink', 'ismount', 'expanduser', 'normpath', 'realpath', + ] + + def test_normcase(self): + # Check that normcase() is idempotent + p = "FoO/./BaR" + p = self.pathmodule.normcase(p) + self.assertEqual(p, self.pathmodule.normcase(p)) + + p = b"FoO/./BaR" + p = self.pathmodule.normcase(p) + self.assertEqual(p, self.pathmodule.normcase(p)) + + def test_splitdrive(self): + # splitdrive for non-NT paths + splitdrive = self.pathmodule.splitdrive + self.assertEqual(splitdrive("/foo/bar"), ("", "/foo/bar")) + self.assertEqual(splitdrive("foo:bar"), ("", "foo:bar")) + self.assertEqual(splitdrive(":foo:bar"), ("", ":foo:bar")) + + self.assertEqual(splitdrive(b"/foo/bar"), (b"", b"/foo/bar")) + self.assertEqual(splitdrive(b"foo:bar"), (b"", b"foo:bar")) + self.assertEqual(splitdrive(b":foo:bar"), (b"", b":foo:bar")) + + def test_expandvars(self): + if self.pathmodule.__name__ == 'macpath': + self.skipTest('macpath.expandvars is a stub') + expandvars = self.pathmodule.expandvars + with support.EnvironmentVarGuard() as env: + env.clear() + env["foo"] = "bar" + env["{foo"] = "baz1" + env["{foo}"] = "baz2" + self.assertEqual(expandvars("foo"), "foo") + self.assertEqual(expandvars("$foo bar"), "bar bar") + self.assertEqual(expandvars("${foo}bar"), "barbar") + self.assertEqual(expandvars("$[foo]bar"), "$[foo]bar") + self.assertEqual(expandvars("$bar bar"), "$bar bar") + self.assertEqual(expandvars("$?bar"), "$?bar") + self.assertEqual(expandvars("${foo}bar"), "barbar") + self.assertEqual(expandvars("$foo}bar"), "bar}bar") + self.assertEqual(expandvars("${foo"), "${foo") + self.assertEqual(expandvars("${{foo}}"), "baz1}") + self.assertEqual(expandvars("$foo$foo"), "barbar") + self.assertEqual(expandvars("$bar$bar"), "$bar$bar") + + self.assertEqual(expandvars(b"foo"), b"foo") + self.assertEqual(expandvars(b"$foo bar"), b"bar bar") + self.assertEqual(expandvars(b"${foo}bar"), b"barbar") + self.assertEqual(expandvars(b"$[foo]bar"), b"$[foo]bar") + self.assertEqual(expandvars(b"$bar bar"), b"$bar bar") + self.assertEqual(expandvars(b"$?bar"), b"$?bar") + self.assertEqual(expandvars(b"${foo}bar"), b"barbar") + self.assertEqual(expandvars(b"$foo}bar"), b"bar}bar") + self.assertEqual(expandvars(b"${foo"), b"${foo") + self.assertEqual(expandvars(b"${{foo}}"), b"baz1}") + self.assertEqual(expandvars(b"$foo$foo"), b"barbar") + self.assertEqual(expandvars(b"$bar$bar"), b"$bar$bar") + + def test_abspath(self): + self.assertIn("foo", self.pathmodule.abspath("foo")) + self.assertIn(b"foo", self.pathmodule.abspath(b"foo")) + + # Abspath returns bytes when the arg is bytes + for path in (b'', b'foo', b'f\xf2\xf2', b'/foo', b'C:\\'): + self.assertIsInstance(self.pathmodule.abspath(path), bytes) + + def test_realpath(self): + self.assertIn("foo", self.pathmodule.realpath("foo")) + self.assertIn(b"foo", self.pathmodule.realpath(b"foo")) + + def test_normpath_issue5827(self): + # Make sure normpath preserves unicode + for path in ('', '.', '/', '\\', '///foo/.//bar//'): + self.assertIsInstance(self.pathmodule.normpath(path), str) + + def test_abspath_issue3426(self): + # Check that abspath returns unicode when the arg is unicode + # with both ASCII and non-ASCII cwds. + abspath = self.pathmodule.abspath + for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'): + self.assertIsInstance(abspath(path), str) + + unicwd = '\xe7w\xf0' + try: + fsencoding = support.TESTFN_ENCODING or "ascii" + unicwd.encode(fsencoding) + except (AttributeError, UnicodeEncodeError): + # FS encoding is probably ASCII + pass + else: + with support.temp_cwd(unicwd): + for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'): + self.assertIsInstance(abspath(path), str) + + # Test non-ASCII, non-UTF8 bytes in the path. + with support.temp_cwd(b'\xe7w\xf0'): + self.test_abspath() - self.assertRaises(TypeError, genericpath.samefile) def test_main(): - support.run_unittest(AllCommonTest) + support.run_unittest(GenericTest) + if __name__=="__main__": test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_getopt.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_getopt.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_getopt.py Thu Apr 1 11:38:52 2010 @@ -5,7 +5,6 @@ import unittest import getopt -import os sentinel = object() Modified: python/branches/py3k-cdecimal/Lib/test/test_global.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_global.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_global.py Thu Apr 1 11:38:52 2010 @@ -1,13 +1,22 @@ """Verify that warnings are issued for global statements following use.""" -from test.support import run_unittest, check_syntax_error +from test.support import run_unittest, check_syntax_error, check_warnings import unittest import warnings -warnings.filterwarnings("error", module="") + class GlobalTests(unittest.TestCase): + def setUp(self): + self._warnings_manager = check_warnings() + self._warnings_manager.__enter__() + warnings.filterwarnings("error", module="") + + def tearDown(self): + self._warnings_manager.__exit__(None, None, None) + + def test1(self): prog_text_1 = """\ def wrong1(): Modified: python/branches/py3k-cdecimal/Lib/test/test_grammar.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_grammar.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_grammar.py Thu Apr 1 11:38:52 2010 @@ -1,42 +1,36 @@ # Python test set -- part 1, grammar. # This just tests whether the parser accepts them all. -# NOTE: When you run this test as a script from the command line, you -# get warnings about certain hex/oct constants. Since those are -# issued by the parser, you can't suppress them by adding a -# filterwarnings() call to this module. Therefore, to shut up the -# regression test, the filterwarnings() call has been added to -# regrtest.py. - from test.support import run_unittest, check_syntax_error import unittest import sys # testing import * from sys import * + class TokenTests(unittest.TestCase): def testBackslash(self): # Backslash means line continuation: x = 1 \ + 1 - self.assertEquals(x, 2, 'backslash for line continuation') + self.assertEqual(x, 2, 'backslash for line continuation') # Backslash does not means continuation in comments :\ x = 0 - self.assertEquals(x, 0, 'backslash ending comment') + self.assertEqual(x, 0, 'backslash ending comment') def testPlainIntegers(self): - self.assertEquals(type(000), type(0)) - self.assertEquals(0xff, 255) - self.assertEquals(0o377, 255) - self.assertEquals(2147483647, 0o17777777777) - self.assertEquals(0b1001, 9) + self.assertEqual(type(000), type(0)) + self.assertEqual(0xff, 255) + self.assertEqual(0o377, 255) + self.assertEqual(2147483647, 0o17777777777) + self.assertEqual(0b1001, 9) # "0x" is not a valid literal self.assertRaises(SyntaxError, eval, "0x") from sys import maxsize if maxsize == 2147483647: - self.assertEquals(-2147483647-1, -0o20000000000) + self.assertEqual(-2147483647-1, -0o20000000000) # XXX -2147483648 self.assertTrue(0o37777777777 > 0) self.assertTrue(0xffffffff > 0) @@ -48,7 +42,7 @@ except OverflowError: self.fail("OverflowError on huge integer literal %r" % s) elif maxsize == 9223372036854775807: - self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000) + self.assertEqual(-9223372036854775807-1, -0o1000000000000000000000) self.assertTrue(0o1777777777777777777777 > 0) self.assertTrue(0xffffffffffffffff > 0) self.assertTrue(0b11111111111111111111111111111111111111111111111111111111111111 > 0) @@ -103,28 +97,28 @@ the 'lazy' dog. """ y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' - self.assertEquals(x, y) + self.assertEqual(x, y) y = ''' The "quick" brown fox jumps over the 'lazy' dog. ''' - self.assertEquals(x, y) + self.assertEqual(x, y) y = "\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the 'lazy' dog.\n\ " - self.assertEquals(x, y) + self.assertEqual(x, y) y = '\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the \'lazy\' dog.\n\ ' - self.assertEquals(x, y) + self.assertEqual(x, y) def testEllipsis(self): x = ... @@ -165,8 +159,8 @@ f1(*(), **{}) def f2(one_argument): pass def f3(two, arguments): pass - self.assertEquals(f2.__code__.co_varnames, ('one_argument',)) - self.assertEquals(f3.__code__.co_varnames, ('two', 'arguments')) + self.assertEqual(f2.__code__.co_varnames, ('one_argument',)) + self.assertEqual(f3.__code__.co_varnames, ('two', 'arguments')) def a1(one_arg,): pass def a2(two, args,): pass def v0(*rest): pass @@ -287,37 +281,37 @@ # keyword arguments after *arglist def f(*args, **kwargs): return args, kwargs - self.assertEquals(f(1, x=2, *[3, 4], y=5), ((1, 3, 4), + self.assertEqual(f(1, x=2, *[3, 4], y=5), ((1, 3, 4), {'x':2, 'y':5})) self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)") self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)") # argument annotation tests def f(x) -> list: pass - self.assertEquals(f.__annotations__, {'return': list}) + self.assertEqual(f.__annotations__, {'return': list}) def f(x:int): pass - self.assertEquals(f.__annotations__, {'x': int}) + self.assertEqual(f.__annotations__, {'x': int}) def f(*x:str): pass - self.assertEquals(f.__annotations__, {'x': str}) + self.assertEqual(f.__annotations__, {'x': str}) def f(**x:float): pass - self.assertEquals(f.__annotations__, {'x': float}) + self.assertEqual(f.__annotations__, {'x': float}) def f(x, y:1+2): pass - self.assertEquals(f.__annotations__, {'y': 3}) + self.assertEqual(f.__annotations__, {'y': 3}) def f(a, b:1, c:2, d): pass - self.assertEquals(f.__annotations__, {'b': 1, 'c': 2}) + self.assertEqual(f.__annotations__, {'b': 1, 'c': 2}) def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass - self.assertEquals(f.__annotations__, + self.assertEqual(f.__annotations__, {'b': 1, 'c': 2, 'e': 3, 'g': 6}) def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10, **k:11) -> 12: pass - self.assertEquals(f.__annotations__, + self.assertEqual(f.__annotations__, {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9, 'k': 11, 'return': 12}) # Check for SF Bug #1697248 - mixing decorators and a return annotation def null(x): return x @null def f(x) -> list: pass - self.assertEquals(f.__annotations__, {'return': list}) + self.assertEqual(f.__annotations__, {'return': list}) # test MAKE_CLOSURE with a variety of oparg's closure = 1 @@ -333,20 +327,20 @@ def testLambdef(self): ### lambdef: 'lambda' [varargslist] ':' test l1 = lambda : 0 - self.assertEquals(l1(), 0) + self.assertEqual(l1(), 0) l2 = lambda : a[d] # XXX just testing the expression l3 = lambda : [2 < x for x in [-1, 3, 0]] - self.assertEquals(l3(), [0, 1, 0]) + self.assertEqual(l3(), [0, 1, 0]) l4 = lambda x = lambda y = lambda z=1 : z : y() : x() - self.assertEquals(l4(), 1) + self.assertEqual(l4(), 1) l5 = lambda x, y, z=2: x + y + z - self.assertEquals(l5(1, 2), 5) - self.assertEquals(l5(1, 2, 3), 6) + self.assertEqual(l5(1, 2), 5) + self.assertEqual(l5(1, 2, 3), 6) check_syntax_error(self, "lambda x: x = 2") check_syntax_error(self, "lambda (None,): None") l6 = lambda x, y, *, k=20: x+y+k - self.assertEquals(l6(1,2), 1+2+20) - self.assertEquals(l6(1,2,k=10), 1+2+10) + self.assertEqual(l6(1,2), 1+2+20) + self.assertEqual(l6(1,2,k=10), 1+2+10) ### stmt: simple_stmt | compound_stmt @@ -502,7 +496,7 @@ try: assert 0, "msg" except AssertionError as e: - self.assertEquals(e.args[0], "msg") + self.assertEqual(e.args[0], "msg") else: if __debug__: self.fail("AssertionError not raised by assert 0") @@ -536,7 +530,7 @@ x = 1 else: x = 2 - self.assertEquals(x, 2) + self.assertEqual(x, 2) def testFor(self): # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] @@ -688,7 +682,7 @@ d[1,2,3] = 4 L = list(d) L.sort(key=lambda x: x if isinstance(x, tuple) else ()) - self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') + self.assertEqual(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') def testAtoms(self): ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING Modified: python/branches/py3k-cdecimal/Lib/test/test_gzip.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_gzip.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_gzip.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Test script for the gzip module. """ Modified: python/branches/py3k-cdecimal/Lib/test/test_hashlib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_hashlib.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_hashlib.py Thu Apr 1 11:38:52 2010 @@ -8,7 +8,6 @@ import array import hashlib -from io import StringIO import itertools import sys try: @@ -102,6 +101,11 @@ c = cons(a) c.hexdigest() + def test_algorithms_attribute(self): + self.assertEqual(hashlib.algorithms, + tuple(_algo for _algo in self.supported_hash_names + if _algo.islower())) + def test_unknown_hash(self): try: hashlib.new('spam spam spam spam spam') Modified: python/branches/py3k-cdecimal/Lib/test/test_heapq.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_heapq.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_heapq.py Thu Apr 1 11:38:52 2010 @@ -370,8 +370,6 @@ def test_main(verbose=None): - from types import BuiltinFunctionType - test_classes = [TestHeapPython, TestHeapC, TestErrorHandling] support.run_unittest(*test_classes) Modified: python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py Thu Apr 1 11:38:52 2010 @@ -1,15 +1,22 @@ # Simple test suite for http/cookies.py -from test.support import run_unittest, run_doctest +from test.support import run_unittest, run_doctest, check_warnings import unittest from http import cookies import warnings -warnings.filterwarnings("ignore", - ".* class is insecure.*", - DeprecationWarning) class CookieTests(unittest.TestCase): + + def setUp(self): + self._warnings_manager = check_warnings() + self._warnings_manager.__enter__() + warnings.filterwarnings("ignore", ".* class is insecure.*", + DeprecationWarning) + + def tearDown(self): + self._warnings_manager.__exit__(None, None, None) + def test_basic(self): cases = [ { 'data': 'chips=ahoy; vienna=finger', Modified: python/branches/py3k-cdecimal/Lib/test/test_httplib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_httplib.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_httplib.py Thu Apr 1 11:38:52 2010 @@ -106,6 +106,10 @@ resp = client.HTTPResponse(sock) self.assertRaises(client.BadStatusLine, resp.begin) + def test_bad_status_repr(self): + exc = client.BadStatusLine('') + self.assertEquals(repr(exc), '''BadStatusLine("\'\'",)''') + def test_partial_reads(self): # if we have a lenght, the system knows when to close itself # same behaviour than when we read the whole thing with read() Modified: python/branches/py3k-cdecimal/Lib/test/test_httpservers.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_httpservers.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_httpservers.py Thu Apr 1 11:38:52 2010 @@ -104,42 +104,42 @@ def test_command(self): self.con.request('GET', '/') res = self.con.getresponse() - self.assertEquals(res.status, 501) + self.assertEqual(res.status, 501) def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 501) + self.assertEqual(res.status, 501) def test_version_bogus(self): self.con._http_vsn_str = 'FUBAR' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 400) + self.assertEqual(res.status, 400) def test_version_digits(self): self.con._http_vsn_str = 'HTTP/9.9.9' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 400) + self.assertEqual(res.status, 400) def test_version_none_get(self): self.con._http_vsn_str = '' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 501) + self.assertEqual(res.status, 501) def test_version_none(self): self.con._http_vsn_str = '' self.con.putrequest('PUT', '/') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 400) + self.assertEqual(res.status, 400) def test_version_invalid(self): self.con._http_vsn = 99 @@ -147,21 +147,21 @@ self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 505) + self.assertEqual(res.status, 505) def test_send_blank(self): self.con._http_vsn_str = '' self.con.putrequest('', '') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 400) + self.assertEqual(res.status, 400) def test_header_close(self): self.con.putrequest('GET', '/') self.con.putheader('Connection', 'close') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 501) + self.assertEqual(res.status, 501) def test_head_keep_alive(self): self.con._http_vsn_str = 'HTTP/1.1' @@ -169,28 +169,28 @@ self.con.putheader('Connection', 'keep-alive') self.con.endheaders() res = self.con.getresponse() - self.assertEquals(res.status, 501) + self.assertEqual(res.status, 501) def test_handler(self): self.con.request('TEST', '/') res = self.con.getresponse() - self.assertEquals(res.status, 204) + self.assertEqual(res.status, 204) def test_return_header_keep_alive(self): self.con.request('KEEP', '/') res = self.con.getresponse() - self.assertEquals(res.getheader('Connection'), 'keep-alive') + self.assertEqual(res.getheader('Connection'), 'keep-alive') self.con.request('TEST', '/') def test_internal_key_error(self): self.con.request('KEYERROR', '/') res = self.con.getresponse() - self.assertEquals(res.status, 999) + self.assertEqual(res.status, 999) def test_return_custom_status(self): self.con.request('CUSTOM', '/') res = self.con.getresponse() - self.assertEquals(res.status, 999) + self.assertEqual(res.status, 999) class SimpleHTTPServerTestCase(BaseTestCase): @@ -222,8 +222,8 @@ def check_status_and_reason(self, response, status, data=None): body = response.read() self.assertTrue(response) - self.assertEquals(response.status, status) - self.assertTrue(response.reason != None) + self.assertEqual(response.status, status) + self.assertIsNotNone(response.reason) if data: self.assertEqual(data, body) @@ -284,8 +284,8 @@ print() form = cgi.FieldStorage() -print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),\ - form.getfirst("bacon"))) +print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"), + form.getfirst("bacon"))) """ class CGIHTTPServerTestCase(BaseTestCase): @@ -298,14 +298,22 @@ self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') os.mkdir(self.cgi_dir) + # The shebang line should be pure ASCII: use symlink if possible. + # See issue #7668. + if hasattr(os, 'symlink'): + self.pythonexe = os.path.join(self.parent_dir, 'python') + os.symlink(sys.executable, self.pythonexe) + else: + self.pythonexe = sys.executable + self.file1_path = os.path.join(self.cgi_dir, 'file1.py') with open(self.file1_path, 'w') as file1: - file1.write(cgi_file1 % sys.executable) + file1.write(cgi_file1 % self.pythonexe) os.chmod(self.file1_path, 0o777) self.file2_path = os.path.join(self.cgi_dir, 'file2.py') with open(self.file2_path, 'w') as file2: - file2.write(cgi_file2 % sys.executable) + file2.write(cgi_file2 % self.pythonexe) os.chmod(self.file2_path, 0o777) self.cwd = os.getcwd() @@ -314,6 +322,8 @@ def tearDown(self): try: os.chdir(self.cwd) + if self.pythonexe != sys.executable: + os.remove(self.pythonexe) os.remove(self.file1_path) os.remove(self.file2_path) os.rmdir(self.cgi_dir) @@ -356,14 +366,14 @@ server._url_collapse_path_split, path) else: actual = server._url_collapse_path_split(path) - self.assertEquals(expected, actual, - msg='path = %r\nGot: %r\nWanted: %r' % ( - path, actual, expected)) + self.assertEqual(expected, actual, + msg='path = %r\nGot: %r\nWanted: %r' % + (path, actual, expected)) def test_headers_and_content(self): res = self.request('/cgi-bin/file1.py') - self.assertEquals((b'Hello World\n', 'text/html', 200), \ - (res.read(), res.getheader('Content-type'), res.status)) + self.assertEqual((b'Hello World\n', 'text/html', 200), + (res.read(), res.getheader('Content-type'), res.status)) def test_post(self): params = urllib.parse.urlencode( @@ -371,24 +381,24 @@ headers = {'Content-type' : 'application/x-www-form-urlencoded'} res = self.request('/cgi-bin/file2.py', 'POST', params, headers) - self.assertEquals(res.read(), b'1, python, 123456\n') + self.assertEqual(res.read(), b'1, python, 123456\n') def test_invaliduri(self): res = self.request('/cgi-bin/invalid') res.read() - self.assertEquals(res.status, 404) + self.assertEqual(res.status, 404) def test_authorization(self): headers = {b'Authorization' : b'Basic ' + base64.b64encode(b'username:pass')} res = self.request('/cgi-bin/file1.py', 'GET', headers=headers) - self.assertEquals((b'Hello World\n', 'text/html', 200), \ - (res.read(), res.getheader('Content-type'), res.status)) + self.assertEqual((b'Hello World\n', 'text/html', 200), + (res.read(), res.getheader('Content-type'), res.status)) def test_no_leading_slash(self): # http://bugs.python.org/issue2254 res = self.request('cgi-bin/file1.py') - self.assertEquals((b'Hello World\n', 'text/html', 200), + self.assertEqual((b'Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) Modified: python/branches/py3k-cdecimal/Lib/test/test_imaplib.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_imaplib.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_imaplib.py Thu Apr 1 11:38:52 2010 @@ -7,10 +7,7 @@ from contextlib import contextmanager import imaplib import os.path -import select -import socket import socketserver -import sys import time from test.support import reap_threads, verbose Modified: python/branches/py3k-cdecimal/Lib/test/test_imp.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_imp.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_imp.py Thu Apr 1 11:38:52 2010 @@ -1,5 +1,4 @@ import imp -import locale import os import os.path import sys @@ -52,7 +51,7 @@ self.assertNotEqual(fp, None) self.assertEqual(fp.encoding, "iso-8859-1") self.assertEqual(fp.tell(), 0) - self.assertEqual(fp.readline(), '#!/usr/bin/env python\n') + self.assertEqual(fp.readline(), '#!/usr/bin/env python3\n') fp.close() fp, filename, info = imp.find_module("tokenize") @@ -85,13 +84,15 @@ # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. - locale_encoding = locale.getpreferredencoding() + # the return encoding could be uppercase or None + fs_encoding = sys.getfilesystemencoding() + fs_encoding = fs_encoding.lower() if fs_encoding else 'ascii' # covers utf-8 and Windows ANSI code pages # one non-space symbol from every page # (http://en.wikipedia.org/wiki/Code_page) known_locales = { - 'utf-8' : b'\xe4', + 'utf-8' : b'\xc3\xa4', 'cp1250' : b'\x8C', 'cp1251' : b'\xc0', 'cp1252' : b'\xc0', @@ -103,47 +104,56 @@ 'cp1258' : b'\xc0', } - special_char = known_locales.get(locale_encoding) - if special_char: - encoded_char = special_char.decode(locale_encoding) - temp_mod_name = 'test_imp_helper_' + encoded_char - test_package_name = 'test_imp_helper_package_' + encoded_char - init_file_name = os.path.join(test_package_name, '__init__.py') - try: - with open(temp_mod_name + '.py', 'w') as file: - file.write('a = 1\n') - file, filename, info = imp.find_module(temp_mod_name) - self.assertNotEquals(None, file) - self.assertTrue(filename[:-3].endswith(temp_mod_name)) - self.assertEquals('.py', info[0]) - self.assertEquals('U', info[1]) - self.assertEquals(imp.PY_SOURCE, info[2]) - - mod = imp.load_module(temp_mod_name, file, filename, info) - self.assertEquals(1, mod.a) - file.close() - - mod = imp.load_source(temp_mod_name, temp_mod_name + '.py') - self.assertEquals(1, mod.a) - - mod = imp.load_compiled(temp_mod_name, temp_mod_name + '.pyc') - self.assertEquals(1, mod.a) - - if not os.path.exists(test_package_name): - os.mkdir(test_package_name) - with open(init_file_name, 'w') as file: - file.write('b = 2\n') - package = imp.load_package(test_package_name, test_package_name) - self.assertEquals(2, package.b) - finally: - support.unlink(temp_mod_name + '.py') - support.unlink(temp_mod_name + '.pyc') - support.unlink(temp_mod_name + '.pyo') - - support.unlink(init_file_name + '.py') - support.unlink(init_file_name + '.pyc') - support.unlink(init_file_name + '.pyo') - support.rmtree(test_package_name) + if sys.platform == 'darwin': + self.assertEqual(fs_encoding, 'utf-8') + # Mac OS X uses the Normal Form D decomposition + # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html + special_char = b'a\xcc\x88' + else: + special_char = known_locales.get(fs_encoding) + + if not special_char: + self.skipTest("can't run this test with %s as filesystem encoding" + % fs_encoding) + decoded_char = special_char.decode(fs_encoding) + temp_mod_name = 'test_imp_helper_' + decoded_char + test_package_name = 'test_imp_helper_package_' + decoded_char + init_file_name = os.path.join(test_package_name, '__init__.py') + try: + # if the curdir is not in sys.path the test fails when run with + # ./python ./Lib/test/regrtest.py test_imp + sys.path.insert(0, os.curdir) + with open(temp_mod_name + '.py', 'w') as file: + file.write('a = 1\n') + file, filename, info = imp.find_module(temp_mod_name) + self.assertIsNotNone(file) + self.assertTrue(filename[:-3].endswith(temp_mod_name)) + self.assertEqual(info[0], '.py') + self.assertEqual(info[1], 'U') + self.assertEqual(info[2], imp.PY_SOURCE) + + mod = imp.load_module(temp_mod_name, file, filename, info) + self.assertEqual(mod.a, 1) + file.close() + + mod = imp.load_source(temp_mod_name, temp_mod_name + '.py') + self.assertEqual(mod.a, 1) + + mod = imp.load_compiled(temp_mod_name, temp_mod_name + '.pyc') + self.assertEqual(mod.a, 1) + + if not os.path.exists(test_package_name): + os.mkdir(test_package_name) + with open(init_file_name, 'w') as file: + file.write('b = 2\n') + package = imp.load_package(test_package_name, test_package_name) + self.assertEqual(package.b, 2) + finally: + del sys.path[0] + for ext in ('.py', '.pyc', '.pyo'): + support.unlink(temp_mod_name + ext) + support.unlink(init_file_name + ext) + support.rmtree(test_package_name) class ReloadTests(unittest.TestCase): @@ -152,7 +162,7 @@ reload().""" def test_source(self): - # XXX (ncoghlan): It would be nice to use test_support.CleanImport + # XXX (ncoghlan): It would be nice to use test.support.CleanImport # here, but that breaks because the os module registers some # handlers in copy_reg on import. Since CleanImport doesn't # revert that registration, the module is left in a broken Modified: python/branches/py3k-cdecimal/Lib/test/test_import.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_import.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_import.py Thu Apr 1 11:38:52 2010 @@ -1,15 +1,15 @@ -import unittest +import builtins +import imp +import marshal import os -import stat +import py_compile import random import shutil +import stat import sys -import py_compile -import warnings -import imp -import marshal -from test.support import (unlink, TESTFN, unload, run_unittest, - TestFailed, EnvironmentVarGuard) +import unittest +from test.support import (unlink, TESTFN, unload, run_unittest, is_jython, + check_warnings, EnvironmentVarGuard, swap_attr, swap_item) def remove_files(name): @@ -18,15 +18,18 @@ name + ".pyo", name + ".pyw", name + "$py.class"): - if os.path.exists(f): - os.remove(f) + unlink(f) + +class ImportTests(unittest.TestCase): -class ImportTest(unittest.TestCase): + def tearDown(self): + unload(TESTFN) + setUp = tearDown - def testCaseSensitivity(self): - # Brief digression to test that import is case-sensitive: if we got this - # far, we know for sure that "random" exists. + def test_case_sensitivity(self): + # Brief digression to test that import is case-sensitive: if we got + # this far, we know for sure that "random" exists. try: import RAnDoM except ImportError: @@ -34,22 +37,24 @@ else: self.fail("import of RAnDoM should have failed (case mismatch)") - def testDoubleConst(self): - # Another brief digression to test the accuracy of manifest float constants. + def test_double_const(self): + # Another brief digression to test the accuracy of manifest float + # constants. from test import double_const # don't blink -- that *was* the test - def testImport(self): + def test_import(self): def test_with_extension(ext): - # ext normally ".py"; perhaps ".pyw" + # The extension is normally ".py", perhaps ".pyw". source = TESTFN + ext pyo = TESTFN + ".pyo" - if sys.platform.startswith('java'): + if is_jython: pyc = TESTFN + "$py.class" else: pyc = TESTFN + ".pyc" with open(source, "w") as f: - print("# This tests Python's ability to import a", ext, "file.", file=f) + print("# This tests Python's ability to import a", ext, "file.", + file=f) a = random.randrange(1000) b = random.randrange(1000) print("a =", a, file=f) @@ -63,21 +68,21 @@ except ImportError as err: self.fail("import from %s failed: %s" % (ext, err)) - self.assertEquals(mod.a, a, + self.assertEqual(mod.a, a, "module loaded (%s) but contents invalid" % mod) - self.assertEquals(mod.b, b, + self.assertEqual(mod.b, b, "module loaded (%s) but contents invalid" % mod) finally: unlink(source) unlink(pyc) unlink(pyo) - del sys.modules[TESTFN] + unload(TESTFN) sys.path.insert(0, os.curdir) try: test_with_extension(".py") if sys.platform.startswith("win"): - for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw": + for ext in [".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw"]: test_with_extension(ext) finally: del sys.path[0] @@ -97,21 +102,22 @@ fn = fname + 'c' if not os.path.exists(fn): fn = fname + 'o' - if not os.path.exists(fn): raise TestFailed("__import__ did " - "not result in creation of either a .pyc or .pyo file") + if not os.path.exists(fn): + self.fail("__import__ did not result in creation of " + "either a .pyc or .pyo file") s = os.stat(fn) - self.assertEquals(stat.S_IMODE(s.st_mode), - stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) + self.assertEqual(stat.S_IMODE(s.st_mode), + stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) finally: os.umask(oldmask) remove_files(TESTFN) - if TESTFN in sys.modules: del sys.modules[TESTFN] + unload(TESTFN) del sys.path[0] - def testImpModule(self): + def test_imp_module(self): # Verify that the imp module can correctly load and find .py files import imp, os - # XXX (ncoghlan): It would be nice to use test_support.CleanImport + # XXX (ncoghlan): It would be nice to use support.CleanImport # here, but that breaks because the os module registers some # handlers in copy_reg on import. Since CleanImport doesn't # revert that registration, the module is left in a broken @@ -128,41 +134,36 @@ self.assertIsNot(orig_getenv, new_os.getenv) def test_module_with_large_stack(self, module='longlist'): - # create module w/list of 65000 elements to test bug #561858 + # Regression test for http://bugs.python.org/issue561858. filename = module + '.py' - # create a file with a list of 65000 elements - f = open(filename, 'w+') - f.write('d = [\n') - for i in range(65000): - f.write('"",\n') - f.write(']') - f.close() - - # compile & remove .py file, we only need .pyc (or .pyo) - f = open(filename, 'r') - py_compile.compile(filename) - f.close() - os.unlink(filename) + # Create a file with a list of 65000 elements. + with open(filename, 'w+') as f: + f.write('d = [\n') + for i in range(65000): + f.write('"",\n') + f.write(']') + + # Compile & remove .py file, we only need .pyc (or .pyo). + with open(filename, 'r') as f: + py_compile.compile(filename) + unlink(filename) - # need to be able to load from current dir + # Need to be able to load from current dir. sys.path.append('') - # this used to crash + # This used to crash. exec('import ' + module) - # cleanup + # Cleanup. del sys.path[-1] - for ext in '.pyc', '.pyo': - fname = module + ext - if os.path.exists(fname): - os.unlink(fname) + unlink(filename + 'c') + unlink(filename + 'o') def test_failing_import_sticks(self): source = TESTFN + ".py" - f = open(source, "w") - print("a = 1/0", file=f) - f.close() + with open(source, "w") as f: + print("a = 1/0", file=f) # New in 2.4, we shouldn't be able to import that no matter how often # we try. @@ -170,16 +171,12 @@ if TESTFN in sys.modules: del sys.modules[TESTFN] try: - for i in 1, 2, 3: - try: - mod = __import__(TESTFN) - except ZeroDivisionError: - if TESTFN in sys.modules: - self.fail("damaged module in sys.modules on %i. try" % i) - else: - self.fail("was able to import a damaged module on %i. try" % i) + for i in [1, 2, 3]: + self.assertRaises(ZeroDivisionError, __import__, TESTFN) + self.assertNotIn(TESTFN, sys.modules, + "damaged module in sys.modules on %i try" % i) finally: - sys.path.pop(0) + del sys.path[0] remove_files(TESTFN) def test_import_name_binding(self): @@ -202,7 +199,7 @@ def test_failing_reload(self): # A failing reload should leave the module object in sys.modules. - source = TESTFN + ".py" + source = TESTFN + os.extsep + "py" with open(source, "w") as f: f.write("a = 1\nb=2\n") @@ -210,8 +207,8 @@ try: mod = __import__(TESTFN) self.assertIn(TESTFN, sys.modules) - self.assertEquals(mod.a, 1, "module has wrong attribute values") - self.assertEquals(mod.b, 2, "module has wrong attribute values") + self.assertEqual(mod.a, 1, "module has wrong attribute values") + self.assertEqual(mod.b, 2, "module has wrong attribute values") # On WinXP, just replacing the .py file wasn't enough to # convince reload() to reparse it. Maybe the timestamp didn't @@ -226,18 +223,17 @@ self.assertRaises(ZeroDivisionError, imp.reload, mod) # But we still expect the module to be in sys.modules. mod = sys.modules.get(TESTFN) - self.assertFalse(mod is None, "expected module to still be in sys.modules") + self.assertIsNot(mod, None, "expected module to be in sys.modules") # We should have replaced a w/ 10, but the old b value should # stick. - self.assertEquals(mod.a, 10, "module has wrong attribute values") - self.assertEquals(mod.b, 2, "module has wrong attribute values") + self.assertEqual(mod.a, 10, "module has wrong attribute values") + self.assertEqual(mod.b, 2, "module has wrong attribute values") finally: - sys.path.pop(0) + del sys.path[0] remove_files(TESTFN) - if TESTFN in sys.modules: - del sys.modules[TESTFN] + unload(TESTFN) def test_file_to_source(self): # check if __file__ points to the source file where available @@ -255,23 +251,37 @@ ext = mod.__file__[-4:] self.assertIn(ext, ('.pyc', '.pyo')) finally: - sys.path.pop(0) + del sys.path[0] remove_files(TESTFN) if TESTFN in sys.modules: del sys.modules[TESTFN] + def test_import_name_binding(self): + # import x.y.z binds x in the current namespace. + import test as x + import test.support + self.assertIs(x, test, x.__name__) + self.assertTrue(hasattr(test.support, "__file__")) + + # import x.y.z as w binds z as w. + import test.support as y + self.assertIs(y, test.support, y.__name__) + + def test_import_initless_directory_warning(self): + with check_warnings(('', ImportWarning)): + # Just a random non-package directory we always expect to be + # somewhere in sys.path... + self.assertRaises(ImportError, __import__, "site-packages") - def test_importbyfilename(self): + def test_import_by_filename(self): path = os.path.abspath(TESTFN) - try: + with self.assertRaises(ImportError) as c: __import__(path) - except ImportError as err: - pass - else: - self.fail("import by path didn't raise an exception") + self.assertEqual("Import by filename is not supported.", + c.exception.args[0]) -class TestPycRewriting(unittest.TestCase): +class PycRewritingTests(unittest.TestCase): # Test that the `co_filename` attribute on code objects always points # to the right file, even when various things happen (e.g. both the .py # and the .pyc file are renamed). @@ -303,10 +313,9 @@ if self.orig_module is not None: sys.modules[self.module_name] = self.orig_module else: - del sys.modules[self.module_name] - for file_name in self.file_name, self.compiled_name: - if os.path.exists(file_name): - os.remove(file_name) + unload(self.module_name) + unlink(self.file_name) + unlink(self.compiled_name) if os.path.exists(self.dir_name): shutil.rmtree(self.dir_name) @@ -363,6 +372,7 @@ mod = self.import_module() self.assertEqual(mod.constant.co_filename, foreign_code.co_filename) + class PathsTests(unittest.TestCase): SAMPLES = ('test', 'test\u00e4\u00f6\u00fc\u00df', 'test\u00e9\u00e8', 'test\u00b0\u00b3\u00b2') @@ -376,22 +386,20 @@ shutil.rmtree(self.path) sys.path[:] = self.syspath - # http://bugs.python.org/issue1293 + # Regression test for http://bugs.python.org/issue1293. def test_trailing_slash(self): - f = open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') - f.write("testdata = 'test_trailing_slash'") - f.close() + with open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') as f: + f.write("testdata = 'test_trailing_slash'") sys.path.append(self.path+'/') mod = __import__("test_trailing_slash") self.assertEqual(mod.testdata, 'test_trailing_slash') unload("test_trailing_slash") - # http://bugs.python.org/issue3677 + # Regression test for http://bugs.python.org/issue3677. def _test_UNC_path(self): - f = open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') - f.write("testdata = 'test_trailing_slash'") - f.close() - #create the UNC path, like \\myhost\c$\foo\bar + with open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') as f: + f.write("testdata = 'test_trailing_slash'") + # Create the UNC path, like \\myhost\c$\foo\bar. path = os.path.abspath(self.path) import socket hn = socket.gethostname() @@ -407,44 +415,72 @@ test_UNC_path = _test_UNC_path -class RelativeImport(unittest.TestCase): +class RelativeImportTests(unittest.TestCase): + def tearDown(self): - try: - del sys.modules["test.relimport"] - except: - pass + unload("test.relimport") + setUp = tearDown def test_relimport_star(self): # This will import * from .test_import. from . import relimport - self.assertTrue(hasattr(relimport, "RelativeImport")) + self.assertTrue(hasattr(relimport, "RelativeImportTests")) def test_issue3221(self): # Note for mergers: the 'absolute' tests from the 2.x branch # are missing in Py3k because implicit relative imports are # a thing of the past + # + # Regression test for http://bugs.python.org/issue3221. def check_relative(): exec("from . import relimport", ns) + # Check relative import OK with __package__ and __name__ correct ns = dict(__package__='test', __name__='test.notarealmodule') check_relative() + # Check relative import OK with only __name__ wrong ns = dict(__package__='test', __name__='notarealpkg.notarealmodule') check_relative() + # Check relative import fails with only __package__ wrong ns = dict(__package__='foo', __name__='test.notarealmodule') self.assertRaises(SystemError, check_relative) + # Check relative import fails with __package__ and __name__ wrong ns = dict(__package__='foo', __name__='notarealpkg.notarealmodule') self.assertRaises(SystemError, check_relative) + # Check relative import fails with package set to a non-string ns = dict(__package__=object()) self.assertRaises(ValueError, check_relative) + +class OverridingImportBuiltinTests(unittest.TestCase): + def test_override_builtin(self): + # Test that overriding builtins.__import__ can bypass sys.modules. + import os + + def foo(): + import os + return os + self.assertEqual(foo(), os) # Quick sanity check. + + with swap_attr(builtins, "__import__", lambda *x: 5): + self.assertEqual(foo(), 5) + + # Test what happens when we shadow __import__ in globals(); this + # currently does not impact the import process, but if this changes, + # other code will need to change, so keep this test as a tripwire. + with swap_item(globals(), "__import__", lambda *x: 5): + self.assertEqual(foo(), os) + + def test_main(verbose=None): - run_unittest(ImportTest, TestPycRewriting, PathsTests, RelativeImport) + run_unittest(ImportTests, PycRewritingTests, PathsTests, RelativeImportTests, + OverridingImportBuiltinTests) if __name__ == '__main__': - # test needs to be a package, so we can do relative import + # Test needs to be a package, so we can do relative imports. from test.test_import import test_main test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_importhooks.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_importhooks.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_importhooks.py Thu Apr 1 11:38:52 2010 @@ -221,15 +221,9 @@ def testBlocker(self): mname = "exceptions" # an arbitrary harmless builtin module - if mname in sys.modules: - del sys.modules[mname] + support.unload(mname) sys.meta_path.append(ImportBlocker(mname)) - try: - __import__(mname) - except ImportError: - pass - else: - self.fail("'%s' was not supposed to be importable" % mname) + self.assertRaises(ImportError, __import__, mname) def testImpWrapper(self): i = ImpWrapper() Modified: python/branches/py3k-cdecimal/Lib/test/test_index.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_index.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_index.py Thu Apr 1 11:38:52 2010 @@ -39,6 +39,8 @@ self.assertEqual(-7 .__index__(), -7) self.assertEqual(self.o.__index__(), 4) self.assertEqual(self.n.__index__(), 5) + self.assertEqual(True.__index__(), 1) + self.assertEqual(False.__index__(), 0) def test_subclasses(self): r = list(range(10)) @@ -154,7 +156,7 @@ lst = [5, 6, 7, 8, 9, 11] l2 = lst.__imul__(self.n) - self.assertTrue(l2 is lst) + self.assertIs(l2, lst) self.assertEqual(lst, [5, 6, 7, 8, 9, 11] * 3) Modified: python/branches/py3k-cdecimal/Lib/test/test_inspect.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_inspect.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_inspect.py Thu Apr 1 11:38:52 2010 @@ -1,3 +1,4 @@ +import re import sys import types import unittest @@ -6,7 +7,7 @@ import collections from os.path import normcase -from test.support import TESTFN, run_unittest +from test.support import run_unittest from test import inspect_fodder as mod from test import inspect_fodder2 as mod2 @@ -236,6 +237,8 @@ self.assertEqual(functions, [('eggs', mod.eggs), ('spam', mod.spam)]) + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") def test_getdoc(self): self.assertEqual(inspect.getdoc(mod), 'A module docstring.') self.assertEqual(inspect.getdoc(mod.StupidGit), @@ -517,10 +520,183 @@ self.assertIn(('m1', 'method', D), attrs, 'missing plain method') self.assertIn(('datablob', 'data', A), attrs, 'missing data') +class TestGetcallargsFunctions(unittest.TestCase): + + def assertEqualCallArgs(self, func, call_params_string, locs=None): + locs = dict(locs or {}, func=func) + r1 = eval('func(%s)' % call_params_string, None, locs) + r2 = eval('inspect.getcallargs(func, %s)' % call_params_string, None, + locs) + self.assertEqual(r1, r2) + + def assertEqualException(self, func, call_param_string, locs=None): + locs = dict(locs or {}, func=func) + try: + eval('func(%s)' % call_param_string, None, locs) + except Exception as e: + ex1 = e + else: + self.fail('Exception not raised') + try: + eval('inspect.getcallargs(func, %s)' % call_param_string, None, + locs) + except Exception as e: + ex2 = e + else: + self.fail('Exception not raised') + self.assertIs(type(ex1), type(ex2)) + self.assertEqual(str(ex1), str(ex2)) + del ex1, ex2 + + def makeCallable(self, signature): + """Create a function that returns its locals()""" + code = "lambda %s: locals()" + return eval(code % signature) + + def test_plain(self): + f = self.makeCallable('a, b=1') + self.assertEqualCallArgs(f, '2') + self.assertEqualCallArgs(f, '2, 3') + self.assertEqualCallArgs(f, 'a=2') + self.assertEqualCallArgs(f, 'b=3, a=2') + self.assertEqualCallArgs(f, '2, b=3') + # expand *iterable / **mapping + self.assertEqualCallArgs(f, '*(2,)') + self.assertEqualCallArgs(f, '*[2]') + self.assertEqualCallArgs(f, '*(2, 3)') + self.assertEqualCallArgs(f, '*[2, 3]') + self.assertEqualCallArgs(f, '**{"a":2}') + self.assertEqualCallArgs(f, 'b=3, **{"a":2}') + self.assertEqualCallArgs(f, '2, **{"b":3}') + self.assertEqualCallArgs(f, '**{"b":3, "a":2}') + # expand UserList / UserDict + self.assertEqualCallArgs(f, '*collections.UserList([2])') + self.assertEqualCallArgs(f, '*collections.UserList([2, 3])') + self.assertEqualCallArgs(f, '**collections.UserDict(a=2)') + self.assertEqualCallArgs(f, '2, **collections.UserDict(b=3)') + self.assertEqualCallArgs(f, 'b=2, **collections.UserDict(a=3)') + + def test_varargs(self): + f = self.makeCallable('a, b=1, *c') + self.assertEqualCallArgs(f, '2') + self.assertEqualCallArgs(f, '2, 3') + self.assertEqualCallArgs(f, '2, 3, 4') + self.assertEqualCallArgs(f, '*(2,3,4)') + self.assertEqualCallArgs(f, '2, *[3,4]') + self.assertEqualCallArgs(f, '2, 3, *collections.UserList([4])') + + def test_varkw(self): + f = self.makeCallable('a, b=1, **c') + self.assertEqualCallArgs(f, 'a=2') + self.assertEqualCallArgs(f, '2, b=3, c=4') + self.assertEqualCallArgs(f, 'b=3, a=2, c=4') + self.assertEqualCallArgs(f, 'c=4, **{"a":2, "b":3}') + self.assertEqualCallArgs(f, '2, c=4, **{"b":3}') + self.assertEqualCallArgs(f, 'b=2, **{"a":3, "c":4}') + self.assertEqualCallArgs(f, '**collections.UserDict(a=2, b=3, c=4)') + self.assertEqualCallArgs(f, '2, c=4, **collections.UserDict(b=3)') + self.assertEqualCallArgs(f, 'b=2, **collections.UserDict(a=3, c=4)') + + def test_keyword_only(self): + f = self.makeCallable('a=3, *, c, d=2') + self.assertEqualCallArgs(f, 'c=3') + self.assertEqualCallArgs(f, 'c=3, a=3') + self.assertEqualCallArgs(f, 'a=2, c=4') + self.assertEqualCallArgs(f, '4, c=4') + self.assertEqualException(f, '') + self.assertEqualException(f, '3') + self.assertEqualException(f, 'a=3') + self.assertEqualException(f, 'd=4') + + def test_multiple_features(self): + f = self.makeCallable('a, b=2, *f, **g') + self.assertEqualCallArgs(f, '2, 3, 7') + self.assertEqualCallArgs(f, '2, 3, x=8') + self.assertEqualCallArgs(f, '2, 3, x=8, *[(4,[5,6]), 7]') + self.assertEqualCallArgs(f, '2, x=8, *[3, (4,[5,6]), 7], y=9') + self.assertEqualCallArgs(f, 'x=8, *[2, 3, (4,[5,6])], y=9') + self.assertEqualCallArgs(f, 'x=8, *collections.UserList(' + '[2, 3, (4,[5,6])]), **{"y":9, "z":10}') + self.assertEqualCallArgs(f, '2, x=8, *collections.UserList([3, ' + '(4,[5,6])]), **collections.UserDict(' + 'y=9, z=10)') + + def test_errors(self): + f0 = self.makeCallable('') + f1 = self.makeCallable('a, b') + f2 = self.makeCallable('a, b=1') + # f0 takes no arguments + self.assertEqualException(f0, '1') + self.assertEqualException(f0, 'x=1') + self.assertEqualException(f0, '1,x=1') + # f1 takes exactly 2 arguments + self.assertEqualException(f1, '') + self.assertEqualException(f1, '1') + self.assertEqualException(f1, 'a=2') + self.assertEqualException(f1, 'b=3') + # f2 takes at least 1 argument + self.assertEqualException(f2, '') + self.assertEqualException(f2, 'b=3') + for f in f1, f2: + # f1/f2 takes exactly/at most 2 arguments + self.assertEqualException(f, '2, 3, 4') + self.assertEqualException(f, '1, 2, 3, a=1') + self.assertEqualException(f, '2, 3, 4, c=5') + self.assertEqualException(f, '2, 3, 4, a=1, c=5') + # f got an unexpected keyword argument + self.assertEqualException(f, 'c=2') + self.assertEqualException(f, '2, c=3') + self.assertEqualException(f, '2, 3, c=4') + self.assertEqualException(f, '2, c=4, b=3') + self.assertEqualException(f, '**{u"\u03c0\u03b9": 4}') + # f got multiple values for keyword argument + self.assertEqualException(f, '1, a=2') + self.assertEqualException(f, '1, **{"a":2}') + self.assertEqualException(f, '1, 2, b=3') + # XXX: Python inconsistency + # - for functions and bound methods: unexpected keyword 'c' + # - for unbound methods: multiple values for keyword 'a' + #self.assertEqualException(f, '1, c=3, a=2') + +class TestGetcallargsMethods(TestGetcallargsFunctions): + + def setUp(self): + class Foo(object): + pass + self.cls = Foo + self.inst = Foo() + + def makeCallable(self, signature): + assert 'self' not in signature + mk = super(TestGetcallargsMethods, self).makeCallable + self.cls.method = mk('self, ' + signature) + return self.inst.method + +class TestGetcallargsUnboundMethods(TestGetcallargsMethods): + + def makeCallable(self, signature): + super(TestGetcallargsUnboundMethods, self).makeCallable(signature) + return self.cls.method + + def assertEqualCallArgs(self, func, call_params_string, locs=None): + return super(TestGetcallargsUnboundMethods, self).assertEqualCallArgs( + *self._getAssertEqualParams(func, call_params_string, locs)) + + def assertEqualException(self, func, call_params_string, locs=None): + return super(TestGetcallargsUnboundMethods, self).assertEqualException( + *self._getAssertEqualParams(func, call_params_string, locs)) + + def _getAssertEqualParams(self, func, call_params_string, locs=None): + assert 'inst' not in call_params_string + locs = dict(locs or {}, inst=self.inst) + return (func, 'inst,' + call_params_string, locs) + def test_main(): - run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners, - TestBuggyCases, - TestInterpreterStack, TestClassesAndFunctions, TestPredicates) + run_unittest( + TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases, + TestInterpreterStack, TestClassesAndFunctions, TestPredicates, + TestGetcallargsFunctions, TestGetcallargsMethods, + TestGetcallargsUnboundMethods) if __name__ == "__main__": test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_io.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_io.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_io.py Thu Apr 1 11:38:52 2010 @@ -28,9 +28,8 @@ import unittest import warnings import weakref -import gc import abc -from itertools import chain, cycle, count +from itertools import cycle, count from collections import deque from test import support @@ -1047,14 +1046,9 @@ self.assertRaises(IOError, bufio.write, b"abcdef") def test_max_buffer_size_deprecation(self): - with support.check_warnings() as w: - warnings.simplefilter("always", DeprecationWarning) + with support.check_warnings(("max_buffer_size is deprecated", + DeprecationWarning)): self.tp(self.MockRawIO(), 8, 12) - self.assertEqual(len(w.warnings), 1) - warning = w.warnings[0] - self.assertTrue(warning.category is DeprecationWarning) - self.assertEqual(str(warning.message), - "max_buffer_size is deprecated") class CBufferedWriterTest(BufferedWriterTest): @@ -1110,14 +1104,9 @@ self.assertRaises(self.UnsupportedOperation, pair.detach) def test_constructor_max_buffer_size_deprecation(self): - with support.check_warnings() as w: - warnings.simplefilter("always", DeprecationWarning) + with support.check_warnings(("max_buffer_size is deprecated", + DeprecationWarning)): self.tp(self.MockRawIO(), self.MockRawIO(), 8, 12) - self.assertEqual(len(w.warnings), 1) - warning = w.warnings[0] - self.assertTrue(warning.category is DeprecationWarning) - self.assertEqual(str(warning.message), - "max_buffer_size is deprecated") def test_constructor_with_not_readable(self): class NotReadable(MockRawIO): Modified: python/branches/py3k-cdecimal/Lib/test/test_keywordonlyarg.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_keywordonlyarg.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_keywordonlyarg.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit tests for the keyword only argument specified in PEP 3102.""" Modified: python/branches/py3k-cdecimal/Lib/test/test_logging.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_logging.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_logging.py Thu Apr 1 11:38:52 2010 @@ -26,24 +26,22 @@ import logging.config import codecs -import copy import pickle import io import gc +import json import os import re import select import socket from socketserver import ThreadingTCPServer, StreamRequestHandler -import string import struct import sys import tempfile -from test.support import captured_stdout, run_with_locale, run_unittest +from test.support import captured_stdout, run_with_locale, run_unittest,\ + find_unused_port import textwrap import threading -import time -import types import unittest import warnings import weakref @@ -85,6 +83,10 @@ level.""" self.stream.close() self.root_logger.removeHandler(self.root_hdlr) + while self.root_logger.handlers: + h = self.root_logger.handlers[0] + self.root_logger.removeHandler(h) + h.close() self.root_logger.setLevel(self.original_logging_level) logging._acquireLock() try: @@ -355,7 +357,7 @@ def setUp(self): BaseTest.setUp(self) - for k, v in list(my_logging_levels.items()): + for k, v in my_logging_levels.items(): logging.addLevelName(k, v) def log_at_all_levels(self, logger): @@ -632,14 +634,8 @@ """ def apply_config(self, conf): - try: - fn = tempfile.mktemp(".ini") - f = open(fn, "w") - f.write(textwrap.dedent(conf)) - f.close() - logging.config.fileConfig(fn) - finally: - os.remove(fn) + file = io.StringIO(textwrap.dedent(conf)) + logging.config.fileConfig(file) def test_config0_ok(self): # A simple config file which overrides the default settings. @@ -831,7 +827,7 @@ # Trigger cycle breaking. gc.collect() dead = [] - for (id_, repr_), ref in list(self._survivors.items()): + for (id_, repr_), ref in self._survivors.items(): if ref() is None: dead.append(repr_) if dead: @@ -870,7 +866,7 @@ # the non-ascii data we write to the log. data = "foo\x80" try: - handler = logging.FileHandler(fn, encoding="utf8") + handler = logging.FileHandler(fn, encoding="utf-8") log.addHandler(handler) try: # write non-ascii data to the log. @@ -879,7 +875,7 @@ log.removeHandler(handler) handler.close() # check we wrote exactly those bytes, ignoring trailing \n etc - f = open(fn, encoding="utf8") + f = open(fn, encoding="utf-8") try: self.assertEqual(f.read().rstrip(), data) finally: @@ -938,15 +934,812 @@ finally: logging.captureWarnings(False) + +def formatFunc(format, datefmt=None): + return logging.Formatter(format, datefmt) + +def handlerFunc(): + return logging.StreamHandler() + +class CustomHandler(logging.StreamHandler): + pass + +class ConfigDictTest(BaseTest): + + """Reading logging config from a dictionary.""" + + expected_log_pat = r"^([\w]+) \+\+ ([\w]+)$" + + # config0 is a standard configuration. + config0 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'root' : { + 'level' : 'WARNING', + 'handlers' : ['hand1'], + }, + } + + # config1 adds a little to the standard configuration. + config1 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + # config2 has a subtle configuration error that should be reported + config2 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdbout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + #As config1 but with a misspelt level on a handler + config2a = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NTOSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + + #As config1 but with a misspelt level on a logger + config2b = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WRANING', + }, + } + + # config3 has a less subtle configuration error + config3 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'misspelled_name', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + # config4 specifies a custom formatter class to be loaded + config4 = { + 'version': 1, + 'formatters': { + 'form1' : { + '()' : __name__ + '.ExceptionFormatter', + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'root' : { + 'level' : 'NOTSET', + 'handlers' : ['hand1'], + }, + } + + # As config4 but using an actual callable rather than a string + config4a = { + 'version': 1, + 'formatters': { + 'form1' : { + '()' : ExceptionFormatter, + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + 'form2' : { + '()' : __name__ + '.formatFunc', + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + 'form3' : { + '()' : formatFunc, + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + 'hand2' : { + '()' : handlerFunc, + }, + }, + 'root' : { + 'level' : 'NOTSET', + 'handlers' : ['hand1'], + }, + } + + # config5 specifies a custom handler class to be loaded + config5 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : __name__ + '.CustomHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + # config6 specifies a custom handler class to be loaded + # but has bad arguments + config6 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : __name__ + '.CustomHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + '9' : 'invalid parameter name', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + #config 7 does not define compiler.parser but defines compiler.lexer + #so compiler.parser should be disabled after applying it + config7 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.lexer' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + config8 = { + 'version': 1, + 'disable_existing_loggers' : False, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + 'compiler.lexer' : { + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + config9 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'WARNING', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'WARNING', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'NOTSET', + }, + } + + config9a = { + 'version': 1, + 'incremental' : True, + 'handlers' : { + 'hand1' : { + 'level' : 'WARNING', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'INFO', + }, + }, + } + + config9b = { + 'version': 1, + 'incremental' : True, + 'handlers' : { + 'hand1' : { + 'level' : 'INFO', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'INFO', + }, + }, + } + + #As config1 but with a filter added + config10 = { + 'version': 1, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'filters' : { + 'filt1' : { + 'name' : 'compiler.parser', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + 'filters' : ['filt1'], + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'filters' : ['filt1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + 'handlers' : ['hand1'], + }, + } + + #As config1 but using cfg:// references + config11 = { + 'version': 1, + 'true_formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handler_configs': { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'formatters' : 'cfg://true_formatters', + 'handlers' : { + 'hand1' : 'cfg://handler_configs[hand1]', + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + #As config11 but missing the version key + config12 = { + 'true_formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handler_configs': { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'formatters' : 'cfg://true_formatters', + 'handlers' : { + 'hand1' : 'cfg://handler_configs[hand1]', + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + #As config11 but using an unsupported version + config13 = { + 'version': 2, + 'true_formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handler_configs': { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'formatters' : 'cfg://true_formatters', + 'handlers' : { + 'hand1' : 'cfg://handler_configs[hand1]', + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + def apply_config(self, conf): + logging.config.dictConfig(conf) + + def test_config0_ok(self): + # A simple config which overrides the default settings. + with captured_stdout() as output: + self.apply_config(self.config0) + logger = logging.getLogger() + # Won't output anything + logger.info(self.next_message()) + # Outputs a message + logger.error(self.next_message()) + self.assert_log_lines([ + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + def test_config1_ok(self, config=config1): + # A config defining a sub-parser as well. + with captured_stdout() as output: + self.apply_config(config) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + def test_config2_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(Exception, self.apply_config, self.config2) + + def test_config2a_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(Exception, self.apply_config, self.config2a) + + def test_config2b_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(Exception, self.apply_config, self.config2b) + + def test_config3_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(Exception, self.apply_config, self.config3) + + def test_config4_ok(self): + # A config specifying a custom formatter class. + with captured_stdout() as output: + self.apply_config(self.config4) + #logger = logging.getLogger() + try: + raise RuntimeError() + except RuntimeError: + logging.exception("just testing") + sys.stdout.seek(0) + self.assertEquals(output.getvalue(), + "ERROR:root:just testing\nGot a [RuntimeError]\n") + # Original logger output is empty + self.assert_log_lines([]) + + def test_config4a_ok(self): + # A config specifying a custom formatter class. + with captured_stdout() as output: + self.apply_config(self.config4a) + #logger = logging.getLogger() + try: + raise RuntimeError() + except RuntimeError: + logging.exception("just testing") + sys.stdout.seek(0) + self.assertEquals(output.getvalue(), + "ERROR:root:just testing\nGot a [RuntimeError]\n") + # Original logger output is empty + self.assert_log_lines([]) + + def test_config5_ok(self): + self.test_config1_ok(config=self.config5) + + def test_config6_failure(self): + self.assertRaises(Exception, self.apply_config, self.config6) + + def test_config7_ok(self): + with captured_stdout() as output: + self.apply_config(self.config1) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + with captured_stdout() as output: + self.apply_config(self.config7) + logger = logging.getLogger("compiler.parser") + self.assertTrue(logger.disabled) + logger = logging.getLogger("compiler.lexer") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '3'), + ('ERROR', '4'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + #Same as test_config_7_ok but don't disable old loggers. + def test_config_8_ok(self): + with captured_stdout() as output: + self.apply_config(self.config1) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + with captured_stdout() as output: + self.apply_config(self.config8) + logger = logging.getLogger("compiler.parser") + self.assertFalse(logger.disabled) + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + logger = logging.getLogger("compiler.lexer") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '3'), + ('ERROR', '4'), + ('INFO', '5'), + ('ERROR', '6'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + def test_config_9_ok(self): + with captured_stdout() as output: + self.apply_config(self.config9) + logger = logging.getLogger("compiler.parser") + #Nothing will be output since both handler and logger are set to WARNING + logger.info(self.next_message()) + self.assert_log_lines([], stream=output) + self.apply_config(self.config9a) + #Nothing will be output since both handler is still set to WARNING + logger.info(self.next_message()) + self.assert_log_lines([], stream=output) + self.apply_config(self.config9b) + #Message should now be output + logger.info(self.next_message()) + self.assert_log_lines([ + ('INFO', '3'), + ], stream=output) + + def test_config_10_ok(self): + with captured_stdout() as output: + self.apply_config(self.config10) + logger = logging.getLogger("compiler.parser") + logger.warning(self.next_message()) + logger = logging.getLogger('compiler') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger('compiler.lexer') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger("compiler.parser.codegen") + #Output, as not filtered + logger.error(self.next_message()) + self.assert_log_lines([ + ('WARNING', '1'), + ('ERROR', '4'), + ], stream=output) + + def test_config11_ok(self): + self.test_config1_ok(self.config11) + + def test_config12_failure(self): + self.assertRaises(Exception, self.apply_config, self.config12) + + def test_config13_failure(self): + self.assertRaises(Exception, self.apply_config, self.config13) + + def setup_via_listener(self, text): + text = text.encode("utf-8") + port = find_unused_port() + t = logging.config.listen(port) + t.start() + t.ready.wait() + t.ready.clear() + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(2.0) + sock.connect(('localhost', port)) + + slen = struct.pack('>L', len(text)) + s = slen + text + sentsofar = 0 + left = len(s) + while left > 0: + sent = sock.send(s[sentsofar:]) + sentsofar += sent + left -= sent + sock.close() + finally: + t.ready.wait(2.0) + logging.config.stopListening() + t.join(2.0) + + def test_listen_config_10_ok(self): + with captured_stdout() as output: + self.setup_via_listener(json.dumps(self.config10)) + logger = logging.getLogger("compiler.parser") + logger.warning(self.next_message()) + logger = logging.getLogger('compiler') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger('compiler.lexer') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger("compiler.parser.codegen") + #Output, as not filtered + logger.error(self.next_message()) + self.assert_log_lines([ + ('WARNING', '1'), + ('ERROR', '4'), + ], stream=output) + + def test_listen_config_1_ok(self): + with captured_stdout() as output: + self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + +class ManagerTest(BaseTest): + def test_manager_loggerclass(self): + logged = [] + + class MyLogger(logging.Logger): + def _log(self, level, msg, args, exc_info=None, extra=None): + logged.append(msg) + + man = logging.Manager(None) + self.assertRaises(TypeError, man.setLoggerClass, int) + man.setLoggerClass(MyLogger) + logger = man.getLogger('test') + logger.warning('should appear in logged') + logging.warning('should not appear in logged') + + self.assertEqual(logged, ['should appear in logged']) + + # Set the locale to the platform-dependent default. I have no idea # why the test does this, but in any case we save the current locale # first and restore it at the end. @run_with_locale('LC_ALL', '') def test_main(): run_unittest(BuiltinLevelsTest, BasicFilterTest, - CustomLevelsAndFiltersTest, MemoryHandlerTest, - ConfigFileTest, SocketHandlerTest, MemoryTest, - EncodingTest, WarningsTest) + CustomLevelsAndFiltersTest, MemoryHandlerTest, + ConfigFileTest, SocketHandlerTest, MemoryTest, + EncodingTest, WarningsTest, ConfigDictTest, ManagerTest) if __name__ == "__main__": test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_long.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_long.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_long.py Thu Apr 1 11:38:52 2010 @@ -402,8 +402,6 @@ self.assertEqual(int(float(x)), y) def test_float_overflow(self): - import math - for x in -2.0, -1.0, 0.0, 1.0, 2.0: self.assertEqual(float(int(x)), x) @@ -435,8 +433,6 @@ "float(shuge) should not equal int(shuge)") def test_logs(self): - import math - LOG10E = math.log10(math.e) for exp in list(range(10)) + [100, 1000, 10000]: @@ -456,7 +452,6 @@ def test_mixed_compares(self): eq = self.assertEqual - import math # 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. @@ -502,7 +497,7 @@ 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" % value) def _cmp__(self, other): if not isinstance(other, Rat): Modified: python/branches/py3k-cdecimal/Lib/test/test_macpath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_macpath.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_macpath.py Thu Apr 1 11:38:52 2010 @@ -1,5 +1,5 @@ import macpath -from test import support +from test import support, test_genericpath import unittest @@ -26,23 +26,6 @@ self.assertFalse(isabs(b":foo:bar")) self.assertFalse(isabs(b":foo:bar:")) - - def test_commonprefix(self): - commonprefix = macpath.commonprefix - self.assertEqual(commonprefix(["home:swenson:spam", "home:swen:spam"]), - "home:swen") - self.assertEqual(commonprefix([":home:swen:spam", ":home:swen:eggs"]), - ":home:swen:") - self.assertEqual(commonprefix([":home:swen:spam", ":home:swen:spam"]), - ":home:swen:spam") - - self.assertTrue(commonprefix([b"home:swenson:spam", b"home:swen:spam"]) - == b"home:swen") - self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:eggs"]) - == b":home:swen:") - self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:spam"]) - == b":home:swen:spam") - def test_split(self): split = macpath.split self.assertEqual(split("foo:bar"), @@ -54,36 +37,28 @@ self.assertEqual(split(":conky:mountpoint:"), (':conky:mountpoint', '')) - self.assertEquals(split(b"foo:bar"), + self.assertEqual(split(b"foo:bar"), (b'foo:', b'bar')) - self.assertEquals(split(b"conky:mountpoint:foo:bar"), + self.assertEqual(split(b"conky:mountpoint:foo:bar"), (b'conky:mountpoint:foo', b'bar')) - self.assertEquals(split(b":"), (b'', b'')) - self.assertEquals(split(b":conky:mountpoint:"), + self.assertEqual(split(b":"), (b'', b'')) + self.assertEqual(split(b":conky:mountpoint:"), (b':conky:mountpoint', b'')) def test_join(self): join = macpath.join - self.assertEquals(join('a', 'b'), ':a:b') - self.assertEquals(join('', 'a:b'), 'a:b') - self.assertEquals(join('a:b', 'c'), 'a:b:c') - self.assertEquals(join('a:b', ':c'), 'a:b:c') - self.assertEquals(join('a', ':b', ':c'), ':a:b:c') - - self.assertEquals(join(b'a', b'b'), b':a:b') - self.assertEquals(join(b'', b'a:b'), b'a:b') - self.assertEquals(join(b'a:b', b'c'), b'a:b:c') - self.assertEquals(join(b'a:b', b':c'), b'a:b:c') - self.assertEquals(join(b'a', b':b', b':c'), b':a:b:c') - - def test_splitdrive(self): - splitdrive = macpath.splitdrive - self.assertEqual(splitdrive("foo:bar"), ('', 'foo:bar')) - self.assertEqual(splitdrive(":foo:bar"), ('', ':foo:bar')) - - self.assertEquals(splitdrive(b"foo:bar"), (b'', b'foo:bar')) - self.assertEquals(splitdrive(b":foo:bar"), (b'', b':foo:bar')) + self.assertEqual(join('a', 'b'), ':a:b') + self.assertEqual(join('', 'a:b'), 'a:b') + self.assertEqual(join('a:b', 'c'), 'a:b:c') + self.assertEqual(join('a:b', ':c'), 'a:b:c') + self.assertEqual(join('a', ':b', ':c'), ':a:b:c') + + self.assertEqual(join(b'a', b'b'), b':a:b') + self.assertEqual(join(b'', b'a:b'), b'a:b') + self.assertEqual(join(b'a:b', b'c'), b'a:b:c') + self.assertEqual(join(b'a:b', b':c'), b'a:b:c') + self.assertEqual(join(b'a', b':b', b':c'), b':a:b:c') def test_splitext(self): splitext = macpath.splitext @@ -95,27 +70,27 @@ self.assertEqual(splitext(""), ('', '')) self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext')) - self.assertEquals(splitext(b":foo.ext"), (b':foo', b'.ext')) - self.assertEquals(splitext(b"foo:foo.ext"), (b'foo:foo', b'.ext')) - self.assertEquals(splitext(b".ext"), (b'.ext', b'')) - self.assertEquals(splitext(b"foo.ext:foo"), (b'foo.ext:foo', b'')) - self.assertEquals(splitext(b":foo.ext:"), (b':foo.ext:', b'')) - self.assertEquals(splitext(b""), (b'', b'')) - self.assertEquals(splitext(b"foo.bar.ext"), (b'foo.bar', b'.ext')) + self.assertEqual(splitext(b":foo.ext"), (b':foo', b'.ext')) + self.assertEqual(splitext(b"foo:foo.ext"), (b'foo:foo', b'.ext')) + self.assertEqual(splitext(b".ext"), (b'.ext', b'')) + self.assertEqual(splitext(b"foo.ext:foo"), (b'foo.ext:foo', b'')) + self.assertEqual(splitext(b":foo.ext:"), (b':foo.ext:', b'')) + self.assertEqual(splitext(b""), (b'', b'')) + self.assertEqual(splitext(b"foo.bar.ext"), (b'foo.bar', b'.ext')) def test_ismount(self): ismount = macpath.ismount - self.assertEquals(ismount("a:"), True) - self.assertEquals(ismount("a:b"), False) - self.assertEquals(ismount("a:b:"), True) - self.assertEquals(ismount(""), False) - self.assertEquals(ismount(":"), False) - - self.assertEquals(ismount(b"a:"), True) - self.assertEquals(ismount(b"a:b"), False) - self.assertEquals(ismount(b"a:b:"), True) - self.assertEquals(ismount(b""), False) - self.assertEquals(ismount(b":"), False) + self.assertEqual(ismount("a:"), True) + self.assertEqual(ismount("a:b"), False) + self.assertEqual(ismount("a:b:"), True) + self.assertEqual(ismount(""), False) + self.assertEqual(ismount(":"), False) + + self.assertEqual(ismount(b"a:"), True) + self.assertEqual(ismount(b"a:b"), False) + self.assertEqual(ismount(b"a:b:"), True) + self.assertEqual(ismount(b""), False) + self.assertEqual(ismount(b":"), False) def test_normpath(self): normpath = macpath.normpath @@ -139,8 +114,13 @@ self.assertEqual(normpath(b"a:"), b"a:") self.assertEqual(normpath(b"a:b:"), b"a:b") + +class MacCommonTest(test_genericpath.CommonTest): + pathmodule = macpath + + def test_main(): - support.run_unittest(MacPathTestCase) + support.run_unittest(MacPathTestCase, MacCommonTest) if __name__ == "__main__": Modified: python/branches/py3k-cdecimal/Lib/test/test_mailbox.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_mailbox.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_mailbox.py Thu Apr 1 11:38:52 2010 @@ -968,6 +968,13 @@ key0 = self._box.add(msg0) refmsg0 = self._box.get_message(key0) + def test_issue7627(self): + msg0 = mailbox.MHMessage(self._template % 0) + key0 = self._box.add(msg0) + self._box.lock() + self._box.remove(key0) + self._box.unlock() + def test_pack(self): # Pack the contents of the mailbox msg0 = mailbox.MHMessage(self._template % 0) Modified: python/branches/py3k-cdecimal/Lib/test/test_marshal.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_marshal.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_marshal.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from test import support import marshal Modified: python/branches/py3k-cdecimal/Lib/test/test_memoryio.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_memoryio.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_memoryio.py Thu Apr 1 11:38:52 2010 @@ -8,7 +8,6 @@ import io import _pyio as pyio -import sys import pickle class MemorySeekTestMixin: Modified: python/branches/py3k-cdecimal/Lib/test/test_metaclass.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_metaclass.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_metaclass.py Thu Apr 1 11:38:52 2010 @@ -230,6 +230,20 @@ 42 >>> +Test failures in looking up the __prepare__ method work. + >>> class ObscureException(Exception): + ... pass + >>> class FailDescr: + ... def __get__(self, instance, owner): + ... raise ObscureException + >>> class Meta(type): + ... __prepare__ = FailDescr() + >>> class X(metaclass=Meta): + ... pass + Traceback (most recent call last): + [...] + test.test_metaclass.ObscureException + """ __test__ = {'doctests' : doctests} Modified: python/branches/py3k-cdecimal/Lib/test/test_minidom.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_minidom.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_minidom.py Thu Apr 1 11:38:52 2010 @@ -1,9 +1,7 @@ # test for xml.dom.minidom -import os -import sys import pickle -from test.support import verbose, run_unittest +from test.support import verbose, run_unittest, findfile import unittest import xml.dom @@ -14,12 +12,8 @@ from xml.dom.minidom import getDOMImplementation -if __name__ == "__main__": - base = sys.argv[0] -else: - base = __file__ -tstfile = os.path.join(os.path.dirname(base), "test.xml") -del base +tstfile = findfile("test.xml", subdir="xmltestdata") + # The tests of DocumentType importing use these helpers to construct # the documents to work with, since not all DOM builders actually @@ -438,7 +432,7 @@ string1 = repr(el) string2 = str(el) self.confirm(string1 == string2) - self.confirm(string1.find("slash:abc") != -1) + self.confirm("slash:abc" in string1) dom.unlink() def testAttributeRepr(self): @@ -955,7 +949,7 @@ node = doc.documentElement node.childNodes[1].nodeValue = "" node.normalize() - self.confirm(node.childNodes[-1].nextSibling == None, + self.confirm(node.childNodes[-1].nextSibling is None, "Final child's .nextSibling should be None") def testSiblings(self): @@ -1455,12 +1449,13 @@ self.confirm(len(n1.entities) == len(n2.entities) and len(n1.notations) == len(n2.notations)) for i in range(len(n1.notations)): + # XXX this loop body doesn't seem to be executed? no1 = n1.notations.item(i) no2 = n1.notations.item(i) self.confirm(no1.name == no2.name and no1.publicId == no2.publicId and no1.systemId == no2.systemId) - statck.append((no1, no2)) + stack.append((no1, no2)) for i in range(len(n1.entities)): e1 = n1.entities.item(i) e2 = n2.entities.item(i) Modified: python/branches/py3k-cdecimal/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_multibytecodec.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_multibytecodec.py Thu Apr 1 11:38:52 2010 @@ -1,11 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_multibytecodec.py # Unit test for multibytecodec itself # from test import support -from test import test_multibytecodec_support from test.support import TESTFN import unittest, io, codecs, sys, os import _multibytecodec Modified: python/branches/py3k-cdecimal/Lib/test/test_multibytecodec_support.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_multibytecodec_support.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_multibytecodec_support.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # test_multibytecodec_support.py # Common Unittest Routines for CJK codecs Modified: python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py Thu Apr 1 11:38:52 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Unit tests for the multiprocessing package @@ -64,6 +64,16 @@ WIN32 = (sys.platform == "win32") # +# Some tests require ctypes +# + +try: + from ctypes import Structure, Value, copy, c_int, c_double +except ImportError: + Structure = object + c_int = c_double = None + +# # Creates a wrapper for a function which records the time it takes to finish # @@ -506,7 +516,7 @@ queue = self.JoinableQueue() if sys.version_info < (2, 5) and not hasattr(queue, 'task_done'): - return + self.skipTest("requires 'queue.task_done()' method") workers = [self.Process(target=self._test_task_done, args=(queue,)) for i in range(4)] @@ -783,6 +793,8 @@ class _TestValue(BaseTestCase): + ALLOWED_TYPES = ('processes',) + codes_values = [ ('i', 4343, 24234), ('d', 3.625, -4.25), @@ -795,10 +807,8 @@ sv.value = cv[2] + @unittest.skipIf(c_int is None, "requires _ctypes") def test_value(self, raw=False): - if self.TYPE != 'processes': - return - if raw: values = [self.RawValue(code, value) for code, value, _ in self.codes_values] @@ -816,13 +826,12 @@ for sv, cv in zip(values, self.codes_values): self.assertEqual(sv.value, cv[2]) + @unittest.skipIf(c_int is None, "requires _ctypes") def test_rawvalue(self): self.test_value(raw=True) + @unittest.skipIf(c_int is None, "requires _ctypes") def test_getobj_getlock(self): - if self.TYPE != 'processes': - return - val1 = self.Value('i', 5) lock1 = val1.get_lock() obj1 = val1.get_obj() @@ -850,14 +859,14 @@ class _TestArray(BaseTestCase): + ALLOWED_TYPES = ('processes',) + def f(self, seq): for i in range(1, len(seq)): seq[i] += seq[i-1] + @unittest.skipIf(c_int is None, "requires _ctypes") def test_array(self, raw=False): - if self.TYPE != 'processes': - return - seq = [680, 626, 934, 821, 150, 233, 548, 982, 714, 831] if raw: arr = self.RawArray('i', seq) @@ -880,13 +889,12 @@ self.assertEqual(list(arr[:]), seq) + @unittest.skipIf(c_int is None, "requires _ctypes") def test_rawarray(self): self.test_array(raw=True) + @unittest.skipIf(c_int is None, "requires _ctypes") def test_getobj_getlock_obj(self): - if self.TYPE != 'processes': - return - arr1 = self.Array('i', list(range(10))) lock1 = arr1.get_lock() obj1 = arr1.get_obj() @@ -1071,8 +1079,16 @@ self.assertEqual(res.get(), sqr(j)) # Refill the pool p._repopulate_pool() - # Finally, check that the worker pids have changed + # Wait until all workers are alive + countdown = 5 + while countdown and not all(w.is_alive() for w in p._pool): + countdown -= 1 + time.sleep(DELTA) finalworkerpids = [w.pid for w in p._pool] + # All pids should be assigned. See issue #7805. + self.assertNotIn(None, origworkerpids) + self.assertNotIn(None, finalworkerpids) + # Finally, check that the worker pids have changed self.assertNotEqual(sorted(origworkerpids), sorted(finalworkerpids)) p.close() p.join() @@ -1562,12 +1578,6 @@ # # -try: - from ctypes import Structure, Value, copy, c_int, c_double -except ImportError: - Structure = object - c_int = c_double = None - class _Foo(Structure): _fields_ = [ ('x', c_int), @@ -1587,15 +1597,13 @@ for i in range(len(arr)): arr[i] *= 2 + @unittest.skipIf(c_int is None, "requires _ctypes") def test_sharedctypes(self, lock=False): - if c_int is None: - return - x = Value('i', 7, lock=lock) - y = Value(ctypes.c_double, 1.0/3.0, lock=lock) + y = Value(c_double, 1.0/3.0, lock=lock) foo = Value(_Foo, 3, 2, lock=lock) - arr = Array('d', list(range(10)), lock=lock) - string = Array('c', 20, lock=lock) + arr = self.Array('d', list(range(10)), lock=lock) + string = self.Array('c', 20, lock=lock) string.value = 'hello' p = self.Process(target=self._double, args=(x, y, foo, arr, string)) @@ -1613,10 +1621,8 @@ def test_synchronize(self): self.test_sharedctypes(lock=True) + @unittest.skipIf(c_int is None, "requires _ctypes") def test_copy(self): - if c_int is None: - return - foo = _Foo(2, 5.0) bar = copy(foo) foo.x = 0 @@ -1688,13 +1694,17 @@ ALLOWED_TYPES = ('processes',) def test_import(self): - modules = ( + modules = [ 'multiprocessing', 'multiprocessing.connection', 'multiprocessing.heap', 'multiprocessing.managers', 'multiprocessing.pool', 'multiprocessing.process', - 'multiprocessing.reduction', 'multiprocessing.sharedctypes', + 'multiprocessing.reduction', 'multiprocessing.synchronize', 'multiprocessing.util' - ) + ] + + if c_int is not None: + # This module requires _ctypes + modules.append('multiprocessing.sharedctypes') for name in modules: __import__(name) @@ -1774,12 +1784,12 @@ class TestInvalidHandle(unittest.TestCase): + @unittest.skipIf(WIN32, "skipped on Windows") def test_invalid_handles(self): - if WIN32: - return conn = _multiprocessing.Connection(44977608) self.assertRaises(IOError, conn.poll) self.assertRaises(IOError, _multiprocessing.Connection, -1) + # # Functions used to create test cases from the base ones in this module # @@ -1796,7 +1806,7 @@ def create_test_cases(Mixin, type): result = {} glob = globals() - Type = type[0].upper() + type[1:] + Type = type.capitalize() for name in list(glob.keys()): if name.startswith('_Test'): Modified: python/branches/py3k-cdecimal/Lib/test/test_normalization.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_normalization.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_normalization.py Thu Apr 1 11:38:52 2010 @@ -9,14 +9,9 @@ TESTDATAFILE = "NormalizationTest.txt" TESTDATAURL = "http://www.unicode.org/Public/" + unidata_version + "/ucd/" + TESTDATAFILE -# Verify we have the correct version of the test data file. -TESTDATAPATH = os.path.join(os.path.dirname(__file__), "data", TESTDATAFILE) -if os.path.exists(TESTDATAPATH): - f = open(TESTDATAPATH, encoding='utf-8') - l = f.readline() - f.close() - if not unidata_version in l: - os.unlink(testdatafile) +def check_version(testfile): + hdr = testfile.readline() + return unidata_version in hdr class RangeError(Exception): pass @@ -42,13 +37,15 @@ class NormalizationTest(unittest.TestCase): def test_main(self): + part = None part1_data = {} # Hit the exception early try: - open_urlresource(TESTDATAURL, encoding="utf-8") + testdata = open_urlresource(TESTDATAURL, encoding="utf-8", + check=check_version) except (IOError, HTTPException): self.skipTest("Could not retrieve " + TESTDATAURL) - for line in open_urlresource(TESTDATAURL, encoding="utf-8"): + for line in testdata: if '#' in line: line = line.split('#')[0] line = line.strip() Modified: python/branches/py3k-cdecimal/Lib/test/test_ntpath.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_ntpath.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_ntpath.py Thu Apr 1 11:38:52 2010 @@ -1,7 +1,7 @@ import ntpath import os -from test.support import verbose, TestFailed -import test.support as support +from test.support import TestFailed +from test import support, test_genericpath import unittest @@ -174,7 +174,6 @@ tester("ntpath.normpath('C:////a/b')", r'C:\a\b') tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b') - def test_expandvars(self): with support.EnvironmentVarGuard() as env: env.clear() @@ -236,8 +235,13 @@ tester('ntpath.relpath("/a/b", "/a/b")', '.') +class NtCommonTest(test_genericpath.CommonTest): + pathmodule = ntpath + attributes = ['relpath', 'splitunc'] + + def test_main(): - support.run_unittest(TestNtpath) + support.run_unittest(TestNtpath, NtCommonTest) if __name__ == "__main__": Modified: python/branches/py3k-cdecimal/Lib/test/test_optparse.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_optparse.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_optparse.py Thu Apr 1 11:38:52 2010 @@ -1,5 +1,3 @@ -#!/usr/bin/python - # # Test suite for Optik. Supplied by Johannes Gijsbers # (taradino at softhome.net) -- translated from the original Optik @@ -18,9 +16,9 @@ from test import support -from optparse import make_option, Option, IndentedHelpFormatter, \ - TitledHelpFormatter, OptionParser, OptionContainer, OptionGroup, \ - SUPPRESS_HELP, SUPPRESS_USAGE, OptionError, OptionConflictError, \ +from optparse import make_option, Option, \ + TitledHelpFormatter, OptionParser, OptionGroup, \ + SUPPRESS_USAGE, OptionError, OptionConflictError, \ BadOptionError, OptionValueError, Values from optparse import _match_abbrev from optparse import _parse_num @@ -443,7 +441,7 @@ return int(value) else: return int(value[:-1]) * _time_units[value[-1]] - except ValueError as IndexError: + except (ValueError, IndexError): raise OptionValueError( 'option %s: invalid duration: %r' % (opt, value)) @@ -1226,7 +1224,6 @@ def variable_args(self, option, opt, value, parser): self.assertTrue(value is None) - done = 0 value = [] rargs = parser.rargs while rargs: Modified: python/branches/py3k-cdecimal/Lib/test/test_os.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_os.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_os.py Thu Apr 1 11:38:52 2010 @@ -154,7 +154,6 @@ self.assertTrue(s == "foobar") def test_tmpnam(self): - import sys if not hasattr(os, "tmpnam"): return warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, @@ -215,8 +214,6 @@ self.assertEquals(result[stat.ST_SIZE], 3) self.assertEquals(result.st_size, 3) - import sys - # Make sure all the attributes are there members = dir(result) for name in dir(stat): @@ -400,6 +397,35 @@ for key, value in self._reference().items(): self.assertEqual(os.environ.get(key), value) + # Issue 7310 + def test___repr__(self): + """Check that the repr() of os.environ looks like environ({...}).""" + env = os.environ + self.assertTrue(isinstance(env.data, dict)) + self.assertEqual(repr(env), 'environ({!r})'.format(env.data)) + + def test_get_exec_path(self): + defpath_list = os.defpath.split(os.pathsep) + test_path = ['/monty', '/python', '', '/flying/circus'] + test_env = {'PATH': os.pathsep.join(test_path)} + + saved_environ = os.environ + try: + os.environ = dict(test_env) + # Test that defaulting to os.environ works. + self.assertSequenceEqual(test_path, os.get_exec_path()) + self.assertSequenceEqual(test_path, os.get_exec_path(env=None)) + finally: + os.environ = saved_environ + + # No PATH environment variable + self.assertSequenceEqual(defpath_list, os.get_exec_path({})) + # Empty PATH environment variable + self.assertSequenceEqual(('',), os.get_exec_path({'PATH':''})) + # Supplied PATH environment variable + self.assertSequenceEqual(test_path, os.get_exec_path(test_env)) + + class WalkTests(unittest.TestCase): """Tests for os.walk().""" @@ -710,6 +736,14 @@ self.assertRaises(OverflowError, os.setreuid, 1<<32, 0) self.assertRaises(OverflowError, os.setreuid, 0, 1<<32) + def test_setreuid_neg1(self): + # Needs to accept -1. We run this in a subprocess to avoid + # altering the test runner's process state (issue8045). + import subprocess + subprocess.check_call([ + sys.executable, '-c', + 'import os,sys;os.setreuid(-1,-1);sys.exit(0)']) + if hasattr(os, 'setregid'): def test_setregid(self): if os.getuid() != 0: @@ -717,6 +751,14 @@ self.assertRaises(OverflowError, os.setregid, 1<<32, 0) self.assertRaises(OverflowError, os.setregid, 0, 1<<32) + def test_setregid_neg1(self): + # Needs to accept -1. We run this in a subprocess to avoid + # altering the test runner's process state (issue8045). + import subprocess + subprocess.check_call([ + sys.executable, '-c', + 'import os,sys;os.setregid(-1,-1);sys.exit(0)']) + @unittest.skipIf(sys.platform == 'darwin', "tests don't apply to OS X") class Pep383Tests(unittest.TestCase): filenames = [b'foo\xf6bar', 'foo\xf6bar'.encode("utf-8")] Modified: python/branches/py3k-cdecimal/Lib/test/test_ossaudiodev.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_ossaudiodev.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_ossaudiodev.py Thu Apr 1 11:38:52 2010 @@ -159,6 +159,15 @@ dsp.close() self.assertTrue(dsp.closed) + def test_mixer_methods(self): + # Issue #8139: ossaudiodev didn't initialize its types properly, + # therefore some methods were unavailable. + mixer = ossaudiodev.openmixer() + try: + self.assertGreaterEqual(mixer.fileno(), 0) + finally: + mixer.close() + def test_main(): try: Modified: python/branches/py3k-cdecimal/Lib/test/test_parser.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_parser.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_parser.py Thu Apr 1 11:38:52 2010 @@ -1,5 +1,4 @@ import parser -import os import unittest import sys import operator Modified: python/branches/py3k-cdecimal/Lib/test/test_pdb.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_pdb.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_pdb.py Thu Apr 1 11:38:52 2010 @@ -2,10 +2,7 @@ # specified test modules (RFE #5142). import imp -import os import sys -import doctest -import tempfile from test import support # This little helper class is essential for testing pdb under doctest. Modified: python/branches/py3k-cdecimal/Lib/test/test_pep263.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_pep263.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_pep263.py Thu Apr 1 11:38:52 2010 @@ -44,6 +44,17 @@ self.assertEqual(len(d['a']), len(d['b'])) self.assertEqual(ascii(d['a']), ascii(d['b'])) + def test_issue7820(self): + # Ensure that check_bom() restores all bytes in the right order if + # check_bom() fails in pydebug mode: a buffer starts with the first + # byte of a valid BOM, but next bytes are different + + # one byte in common with the UTF-16-LE BOM + self.assertRaises(SyntaxError, eval, b'\xff\x20') + + # two bytes in common with the UTF-8 BOM + self.assertRaises(SyntaxError, eval, b'\xef\xbb\x20') + def test_main(): support.run_unittest(PEP263Test) Modified: python/branches/py3k-cdecimal/Lib/test/test_pep277.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_pep277.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_pep277.py Thu Apr 1 11:38:52 2010 @@ -1,9 +1,8 @@ # Test the Unicode versions of normal file functions # open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir import sys, os, unittest +from unicodedata import normalize from test import support -if not os.path.supports_unicode_filenames: - raise unittest.SkipTest("test works only on NT+") filenames = [ 'abc', @@ -15,8 +14,32 @@ '\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', '\u66e8\u66e9\u66eb', '\u66e8\u05e9\u3093\u0434\u0393\xdf', + # Specific code points: fn, NFC(fn) and NFKC(fn) all differents + '\u1fee\u1ffd', + # Specific code points: NFC(fn), NFD(fn), NFKC(fn) and NFKD(fn) all differents + '\u0385\u03d3\u03d4', + '\u00a8\u0301\u03d2\u0301\u03d2\u0308', # == NFD('\u0385\u03d3\u03d4') + '\u0020\u0308\u0301\u038e\u03ab', # == NFKC('\u0385\u03d3\u03d4') + '\u1e9b\u1fc1\u1fcd\u1fce\u1fcf\u1fdd\u1fde\u1fdf\u1fed', ] +# Mac OS X decomposes Unicode names, using Normal Form D. +# http://developer.apple.com/mac/library/qa/qa2001/qa1173.html +# "However, most volume formats do not follow the exact specification for +# these normal forms. For example, HFS Plus uses a variant of Normal Form D +# in which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through +# U+2FAFF are not decomposed." +if sys.platform != 'darwin': + filenames.extend([ + # Specific code points: fn, NFC(fn) and NFKC(fn) all differents + '\u1fee\u1ffd\ufad1', + '\u2000\u2000\u2000A', + '\u2001\u2001\u2001A', + '\u2003\u2003\u2003A', # == NFC('\u2001\u2001\u2001A') + '\u0020\u0020\u0020A', # '\u0020' == ' ' == NFKC('\u2000') == + # NFKC('\u2001') == NFKC('\u2003') +]) + # Destroy directory dirname and all files under it, to one level. def deltree(dirname): # Don't hide legitimate errors: if one of these suckers exists, it's @@ -27,35 +50,51 @@ os.unlink(os.path.join(dirname, fname)) os.rmdir(dirname) + class UnicodeFileTests(unittest.TestCase): - files = [os.path.join(support.TESTFN, f) for f in filenames] + files = set(filenames) + normal_form = None def setUp(self): try: os.mkdir(support.TESTFN) except OSError: pass + files = set() for name in self.files: - f = open(name, 'wb') + name = os.path.join(support.TESTFN, self.norm(name)) + try: + f = open(name, 'wb') + except UnicodeEncodeError: + if not os.path.supports_unicode_filenames: + self.skipTest("only NT+ and systems with Unicode-friendly" + "filesystem encoding") f.write((name+'\n').encode("utf-8")) f.close() os.stat(name) + files.add(name) + self.files = files def tearDown(self): deltree(support.TESTFN) + def norm(self, s): + if self.normal_form: + return normalize(self.normal_form, s) + return s + def _apply_failure(self, fn, filename, expected_exception, check_fn_in_exception = True): - try: + with self.assertRaises(expected_exception) as c: fn(filename) - raise support.TestFailed("Expected to fail calling '%s(%r)'" - % (fn.__name__, filename)) - except expected_exception as details: - if check_fn_in_exception and details.filename != filename: - raise support.TestFailed("Function '%s(%r) failed with " - "bad filename in the exception: %r" - % (fn.__name__, filename, - details.filename)) + exc_filename = c.exception.filename + # the "filename" exception attribute may be encoded + if isinstance(exc_filename, bytes): + filename = filename.encode(sys.getfilesystemencoding()) + if check_fn_in_exception: + self.assertEqual(exc_filename, filename, "Function '%s(%r) failed " + "with bad filename in the exception: %r" % + (fn.__name__, filename, exc_filename)) def test_failures(self): # Pass non-existing Unicode filenames all over the place. @@ -76,39 +115,88 @@ f.close() os.stat(name) + def test_normalize(self): + files = set(self.files) + others = set() + for nf in set(['NFC', 'NFD', 'NFKC', 'NFKD']): + others |= set(normalize(nf, file) for file in files) + others -= files + if sys.platform == 'darwin': + files = set(normalize('NFD', file) for file in files) + for name in others: + if sys.platform == 'darwin' and normalize('NFD', name) in files: + # Mac OS X decomposes Unicode names. See comment above. + os.stat(name) + continue + self._apply_failure(open, name, IOError) + self._apply_failure(os.stat, name, OSError) + self._apply_failure(os.chdir, name, OSError) + self._apply_failure(os.rmdir, name, OSError) + self._apply_failure(os.remove, name, OSError) + # listdir may append a wildcard to the filename, so dont check + self._apply_failure(os.listdir, name, OSError, False) + def test_listdir(self): - f1 = os.listdir(support.TESTFN) - f2 = os.listdir(str(support.TESTFN.encode("utf-8"), - sys.getfilesystemencoding())) - sf2 = set("\\".join((str(support.TESTFN), f)) - for f in f2) - self.assertEqual(len(f1), len(self.files)) - self.assertEqual(sf2, set(self.files)) + sf0 = set(self.files) + f1 = os.listdir(support.TESTFN.encode(sys.getfilesystemencoding())) + f2 = os.listdir(support.TESTFN) + if sys.platform == 'darwin': + # Mac OS X decomposes Unicode names. See comment above. + sf0 = set(normalize('NFD', f) for f in self.files) + f2 = [normalize('NFD', f) for f in f2] + sf2 = set(os.path.join(support.TESTFN, f) for f in f2) + self.assertEqual(sf0, sf2) + self.assertEqual(len(f1), len(f2)) def test_rename(self): for name in self.files: - os.rename(name,"tmp") - os.rename("tmp",name) + os.rename(name, "tmp") + os.rename("tmp", name) def test_directory(self): - dirname = os.path.join(support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb') + dirname = os.path.join(support.TESTFN, 'Gr\xfc\xdf-\u66e8\u66e9\u66eb') filename = '\xdf-\u66e8\u66e9\u66eb' oldwd = os.getcwd() os.mkdir(dirname) os.chdir(dirname) - f = open(filename, 'wb') - f.write((filename + '\n').encode("utf-8")) - f.close() - os.access(filename,os.R_OK) - os.remove(filename) - os.chdir(oldwd) - os.rmdir(dirname) + try: + with open(filename, 'wb') as f: + f.write((filename + '\n').encode("utf-8")) + os.access(filename,os.R_OK) + os.remove(filename) + finally: + os.chdir(oldwd) + os.rmdir(dirname) + + +class UnicodeNFCFileTests(UnicodeFileTests): + normal_form = 'NFC' + + +class UnicodeNFDFileTests(UnicodeFileTests): + normal_form = 'NFD' + + +class UnicodeNFKCFileTests(UnicodeFileTests): + normal_form = 'NFKC' + + +class UnicodeNFKDFileTests(UnicodeFileTests): + normal_form = 'NFKD' + def test_main(): try: - support.run_unittest(UnicodeFileTests) + support.run_unittest( + UnicodeFileTests, + UnicodeNFCFileTests, + UnicodeNFDFileTests, + UnicodeNFKCFileTests, + UnicodeNFKDFileTests, + ) finally: deltree(support.TESTFN) + if __name__ == "__main__": test_main() Modified: python/branches/py3k-cdecimal/Lib/test/test_pep292.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_pep292.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_pep292.py Thu Apr 1 11:38:52 2010 @@ -86,13 +86,6 @@ s = Template('$who likes $100') raises(ValueError, s.substitute, dict(who='tim')) - def test_delimiter_override(self): - class PieDelims(Template): - delimiter = '@' - s = PieDelims('@who likes to eat a bag of @{what} worth $100') - self.assertEqual(s.substitute(dict(who='tim', what='ham')), - 'tim likes to eat a bag of ham worth $100') - def test_idpattern_override(self): class PathPattern(Template): idpattern = r'[_a-z][._a-z0-9]*' @@ -183,6 +176,12 @@ raises(ValueError, s.substitute, dict(gift='bud', who='you')) eq(s.safe_substitute(), 'this &gift is for &{who} &') + class PieDelims(Template): + delimiter = '@' + s = PieDelims('@who likes to eat a bag of @{what} worth $100') + self.assertEqual(s.substitute(dict(who='tim', what='ham')), + 'tim likes to eat a bag of ham worth $100') + def test_main(): from test import support Modified: python/branches/py3k-cdecimal/Lib/test/test_pipes.py ============================================================================== --- python/branches/py3k-cdecimal/Lib/test/test_pipes.py (original) +++ python/branches/py3k-cdecimal/Lib/test/test_pipes.py Thu Apr 1 11:38:52 2010 @@ -82,6 +82,8 @@ self.assertEqual(pipes.quote("test%s'name'" % u), '"test\\%s\'name\'"' % u) + self.assertEqual(pipes.quote(''), "''") + def testRepr(self): t = pipes.Template() self.assertEqual(repr(t), "