From python-3000-checkins at python.org Fri Feb 1 03:16:46 2008 From: python-3000-checkins at python.org (bill.janssen) Date: Fri, 1 Feb 2008 03:16:46 +0100 (CET) Subject: [Python-3000-checkins] r60485 - python/branches/py3k/Lib/imaplib.py Message-ID: <20080201021646.7CA1E1E4012@bag.python.org> Author: bill.janssen Date: Fri Feb 1 03:16:46 2008 New Revision: 60485 Modified: python/branches/py3k/Lib/imaplib.py Log: fix bug 1482: IMAP4 SSL isn't working Modified: python/branches/py3k/Lib/imaplib.py ============================================================================== --- python/branches/py3k/Lib/imaplib.py (original) +++ python/branches/py3k/Lib/imaplib.py Fri Feb 1 03:16:46 2008 @@ -1145,55 +1145,10 @@ """ self.host = host self.port = port - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.connect((host, port)) - self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile) - - - def read(self, size): - """Read 'size' bytes from remote.""" - # sslobj.read() sometimes returns < size bytes - chunks = [] - read = 0 - while read < size: - data = self.sslobj.read(size-read) - read += len(data) - chunks.append(data) - - return ''.join(chunks) - - - def readline(self): - """Read line from remote.""" - line = [] - while 1: - char = self.sslobj.read(1) - line.append(char) - if char == "\n": return ''.join(line) - - - def send(self, data): - """Send data to remote.""" - bytes = len(data) - while bytes > 0: - sent = self.sslobj.write(data) - if sent == bytes: - break # avoid copy - data = data[sent:] - bytes = bytes - sent - - - def shutdown(self): - """Close I/O established in "open".""" - self.sock.close() - - - def socket(self): - """Return socket instance used to connect to IMAP4 server. - - socket = .socket() - """ - return self.sock + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((host, port)) + self.sock = ssl.wrap_socket(sock, self.keyfile, self.certfile) + self.file = self.sock.makefile('rb') def ssl(self): @@ -1201,7 +1156,7 @@ ssl = ssl.wrap_socket(.socket) """ - return self.sslobj + return self.sock __all__.append("IMAP4_SSL") From python-3000-checkins at python.org Fri Feb 1 09:12:05 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Fri, 1 Feb 2008 09:12:05 +0100 (CET) Subject: [Python-3000-checkins] r60489 - in python/branches/py3k: Doc/library/functions.rst Doc/library/math.rst Include/pyport.h Lib/rational.py Lib/test/test_abstract_numbers.py Lib/test/test_builtin.py Lib/test/test_complex.py Lib/test/test_decimal.py Lib/test/test_math.py Lib/test/test_rational.py Modules/mathmodule.c Modules/posixmodule.c Python/bltinmodule.c Python/compile.c Python/marshal.c configure configure.in pyconfig.h.in Message-ID: <20080201081205.40EFB1E4012@bag.python.org> Author: christian.heimes Date: Fri Feb 1 09:12:03 2008 New Revision: 60489 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/math.rst python/branches/py3k/Include/pyport.h python/branches/py3k/Lib/rational.py python/branches/py3k/Lib/test/test_abstract_numbers.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_complex.py python/branches/py3k/Lib/test/test_decimal.py python/branches/py3k/Lib/test/test_math.py python/branches/py3k/Lib/test/test_rational.py python/branches/py3k/Modules/mathmodule.c python/branches/py3k/Modules/posixmodule.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/compile.c python/branches/py3k/Python/marshal.c python/branches/py3k/configure python/branches/py3k/configure.in python/branches/py3k/pyconfig.h.in Log: Merged revisions 60475-60479,60481-60488 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60482 | raymond.hettinger | 2008-01-31 23:07:16 +0100 (Thu, 31 Jan 2008) | 1 line Minor wordsmithing on docstring ........ r60483 | mark.dickinson | 2008-01-31 23:17:37 +0100 (Thu, 31 Jan 2008) | 5 lines Issue #1678380. Fix a bug that identifies 0j and -0j when they appear in the same code unit. The fix is essentially the same as the fix for a previous bug identifying 0. and -0. ........ r60484 | christian.heimes | 2008-02-01 00:08:23 +0100 (Fri, 01 Feb 2008) | 1 line Fixed bug #1983: Return from fork() is pid_t, not int ........ r60486 | jeffrey.yasskin | 2008-02-01 07:22:46 +0100 (Fri, 01 Feb 2008) | 4 lines Move __builtins__.trunc() to math.trunc() per http://mail.python.org/pipermail/python-dev/2008-January/076626.html and issue 1965. ........ r60487 | jeffrey.yasskin | 2008-02-01 08:05:46 +0100 (Fri, 01 Feb 2008) | 3 lines Roll back r60248. It's useful to encourage users not to change Rational instances. ........ r60488 | neal.norwitz | 2008-02-01 08:22:59 +0100 (Fri, 01 Feb 2008) | 1 line Fix refleak ........ Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Fri Feb 1 09:12:03 2008 @@ -1059,12 +1059,6 @@ operators such as ``super(C, self)[name]``. -.. function:: trunc(x) - - Return the :class:`Real` value *x* truncated to an :class:`Integral` (usually - a long integer). Delegates to ``x.__trunc__()``. - - .. function:: tuple([iterable]) Return a tuple whose items are the same and in the same order as *iterable*'s Modified: python/branches/py3k/Doc/library/math.rst ============================================================================== --- python/branches/py3k/Doc/library/math.rst (original) +++ python/branches/py3k/Doc/library/math.rst Fri Feb 1 09:12:03 2008 @@ -96,6 +96,14 @@ Return the fractional and integer parts of *x*. Both results carry the sign of *x*, and both are floats. + +.. function:: trunc(x) + + Return the :class:`Real` value *x* truncated to an :class:`Integral` (usually + a long integer). Delegates to ``x.__trunc__()``. + + .. versionadded:: 2.6 + Note that :func:`frexp` and :func:`modf` have a different call/return pattern than their C equivalents: they take a single argument and return a pair of values, rather than returning their second return value through an 'output Modified: python/branches/py3k/Include/pyport.h ============================================================================== --- python/branches/py3k/Include/pyport.h (original) +++ python/branches/py3k/Include/pyport.h Fri Feb 1 09:12:03 2008 @@ -111,6 +111,10 @@ /* Smallest negative value of type Py_ssize_t. */ #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) +#if SIZEOF_PID_T > SIZEOF_LONG +# error "Python doesn't support sizeof(pid_t) > sizeof(long)" +#endif + /* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf * format to convert an argument with the width of a size_t or Py_ssize_t. * C99 introduced "z" for this purpose, but not all platforms support that; @@ -550,7 +554,7 @@ functions, even though they are included in libutil. */ #include extern int openpty(int *, int *, char *, struct termios *, struct winsize *); -extern int forkpty(int *, char *, struct termios *, struct winsize *); +extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); #endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */ #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ Modified: python/branches/py3k/Lib/rational.py ============================================================================== --- python/branches/py3k/Lib/rational.py (original) +++ python/branches/py3k/Lib/rational.py Fri Feb 1 09:12:03 2008 @@ -42,7 +42,7 @@ """ - __slots__ = ('numerator', 'denominator') + __slots__ = ('_numerator', '_denominator') # We're immutable, so use __new__ not __init__ def __new__(cls, numerator=0, denominator=1): @@ -92,8 +92,8 @@ raise ZeroDivisionError('Rational(%s, 0)' % numerator) g = gcd(numerator, denominator) - self.numerator = int(numerator // g) - self.denominator = int(denominator // g) + self._numerator = int(numerator // g) + self._denominator = int(denominator // g) return self @classmethod @@ -167,6 +167,14 @@ result = new return result + @property + def numerator(a): + return a._numerator + + @property + def denominator(a): + return a._denominator + def __repr__(self): """repr(self)""" return ('Rational(%r,%r)' % (self.numerator, self.denominator)) @@ -192,20 +200,20 @@ Rational, that means that we define __add__ and __radd__ as: def __add__(self, other): + # Both types have numerators/denominator attributes, + # so do the operation directly if isinstance(other, (int, Rational)): - # Do the real operation. return Rational(self.numerator * other.denominator + other.numerator * self.denominator, self.denominator * other.denominator) - # float and complex don't follow this protocol, and - # Rational knows about them, so special case them. + # float and complex don't have those operations, but we + # know about those types, so special case them. elif isinstance(other, float): return float(self) + other elif isinstance(other, complex): return complex(self) + other - else: - # Let the other type take over. - return NotImplemented + # Let the other type take over. + return NotImplemented def __radd__(self, other): # radd handles more types than add because there's @@ -218,8 +226,7 @@ return float(other) + float(self) elif isinstance(other, Complex): return complex(other) + complex(self) - else: - return NotImplemented + return NotImplemented There are 5 different cases for a mixed-type addition on Modified: python/branches/py3k/Lib/test/test_abstract_numbers.py ============================================================================== --- python/branches/py3k/Lib/test/test_abstract_numbers.py (original) +++ python/branches/py3k/Lib/test/test_abstract_numbers.py Fri Feb 1 09:12:03 2008 @@ -1,11 +1,12 @@ """Unit tests for numbers.py.""" +import math +import operator import unittest -from test import test_support -from numbers import Number -from numbers import Exact, Inexact from numbers import Complex, Real, Rational, Integral -import operator +from numbers import Exact, Inexact +from numbers import Number +from test import test_support class TestNumbers(unittest.TestCase): def test_int(self): @@ -37,7 +38,8 @@ self.failUnless(issubclass(complex, Inexact)) c1, c2 = complex(3, 2), complex(4,1) - self.assertRaises(TypeError, trunc, c1) + # XXX: This is not ideal, but see the comment in math_trunc(). + self.assertRaises(TypeError, math.trunc, c1) self.assertRaises(TypeError, operator.mod, c1, c2) self.assertRaises(TypeError, divmod, c1, c2) self.assertRaises(TypeError, operator.floordiv, c1, c2) Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Fri Feb 1 09:12:03 2008 @@ -1643,37 +1643,6 @@ raise ValueError self.assertRaises(ValueError, sum, BadSeq()) - def test_trunc(self): - - self.assertEqual(trunc(1), 1) - self.assertEqual(trunc(-1), -1) - self.assertEqual(type(trunc(1)), int) - self.assertEqual(type(trunc(1.5)), int) - self.assertEqual(trunc(1.5), 1) - self.assertEqual(trunc(-1.5), -1) - self.assertEqual(trunc(1.999999), 1) - self.assertEqual(trunc(-1.999999), -1) - self.assertEqual(trunc(-0.999999), -0) - self.assertEqual(trunc(-100.999), -100) - - class TestTrunc: - def __trunc__(self): - return 23 - - class TestNoTrunc: - pass - - self.assertEqual(trunc(TestTrunc()), 23) - - self.assertRaises(TypeError, trunc) - self.assertRaises(TypeError, trunc, 1, 2) - self.assertRaises(TypeError, trunc, TestNoTrunc()) - - t = TestNoTrunc() - t.__trunc__ = lambda *args: args - self.assertRaises(TypeError, trunc, t) - self.assertRaises(TypeError, trunc, t, 0) - def test_tuple(self): self.assertEqual(tuple(()), ()) t0_3 = (0, 1, 2, 3) Modified: python/branches/py3k/Lib/test/test_complex.py ============================================================================== --- python/branches/py3k/Lib/test/test_complex.py (original) +++ python/branches/py3k/Lib/test/test_complex.py Fri Feb 1 09:12:03 2008 @@ -338,6 +338,13 @@ except (OSError, IOError): pass + if float.__getformat__("double").startswith("IEEE"): + def test_plus_minus_0j(self): + # test that -0j and 0j literals are not identified + z1, z2 = 0j, -0j + self.assertEquals(atan2(z1.imag, -1.), atan2(0., -1.)) + self.assertEquals(atan2(z2.imag, -1.), atan2(-0., -1.)) + def test_main(): test_support.run_unittest(ComplexTest) Modified: python/branches/py3k/Lib/test/test_decimal.py ============================================================================== --- python/branches/py3k/Lib/test/test_decimal.py (original) +++ python/branches/py3k/Lib/test/test_decimal.py Fri Feb 1 09:12:03 2008 @@ -25,10 +25,11 @@ """ from __future__ import with_statement -import unittest import glob +import math import os, sys import pickle, copy +import unittest from decimal import * from test.test_support import (TestSkipped, run_unittest, run_doctest, is_resource_enabled) @@ -1213,7 +1214,7 @@ # should work the same as to_integral in the ROUND_DOWN mode d = Decimal(s) r = d.to_integral(ROUND_DOWN) - self.assertEqual(Decimal(trunc(d)), r) + self.assertEqual(Decimal(math.trunc(d)), r) class ContextAPItests(unittest.TestCase): Modified: python/branches/py3k/Lib/test/test_math.py ============================================================================== --- python/branches/py3k/Lib/test/test_math.py (original) +++ python/branches/py3k/Lib/test/test_math.py Fri Feb 1 09:12:03 2008 @@ -233,6 +233,38 @@ self.ftest('tanh(0)', math.tanh(0), 0) self.ftest('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0) + def test_trunc(self): + self.assertEqual(math.trunc(1), 1) + self.assertEqual(math.trunc(-1), -1) + self.assertEqual(type(math.trunc(1)), int) + self.assertEqual(type(math.trunc(1.5)), int) + self.assertEqual(math.trunc(1.5), 1) + self.assertEqual(math.trunc(-1.5), -1) + self.assertEqual(math.trunc(1.999999), 1) + self.assertEqual(math.trunc(-1.999999), -1) + self.assertEqual(math.trunc(-0.999999), -0) + self.assertEqual(math.trunc(-100.999), -100) + + class TestTrunc(object): + def __trunc__(self): + return 23 + + class TestNoTrunc(object): + pass + + self.assertEqual(math.trunc(TestTrunc()), 23) + + self.assertRaises(TypeError, math.trunc) + self.assertRaises(TypeError, math.trunc, 1, 2) + self.assertRaises(TypeError, math.trunc, TestNoTrunc()) + + # XXX Doesn't work because the method is looked up on + # the type only. + #t = TestNoTrunc() + #t.__trunc__ = lambda *args: args + #self.assertEquals((), math.trunc(t)) + #self.assertRaises(TypeError, math.trunc, t, 0) + def testCopysign(self): self.assertEqual(math.copysign(1, 42), 1.0) self.assertEqual(math.copysign(0., 42), 0.0) Modified: python/branches/py3k/Lib/test/test_rational.py ============================================================================== --- python/branches/py3k/Lib/test/test_rational.py (original) +++ python/branches/py3k/Lib/test/test_rational.py Fri Feb 1 09:12:03 2008 @@ -117,6 +117,17 @@ r.__init__(2, 15) self.assertEquals((7, 3), _components(r)) + self.assertRaises(AttributeError, setattr, r, 'numerator', 12) + self.assertRaises(AttributeError, setattr, r, 'denominator', 6) + self.assertEquals((7, 3), _components(r)) + + # But if you _really_ need to: + r._numerator = 4 + r._denominator = 2 + self.assertEquals((4, 2), _components(r)) + # Which breaks some important operations: + self.assertNotEquals(R(4, 2), r) + def testFromFloat(self): self.assertRaisesMessage( TypeError, "Rational.from_float() only takes floats, not 3 (int)", @@ -193,7 +204,7 @@ self.assertEqual(R.from_float(0.0).approximate(10000), R(0)) def testConversions(self): - self.assertTypedEquals(-1, trunc(R(-11, 10))) + self.assertTypedEquals(-1, math.trunc(R(-11, 10))) self.assertTypedEquals(-2, math.floor(R(-11, 10))) self.assertTypedEquals(-1, math.ceil(R(-11, 10))) self.assertTypedEquals(-1, math.ceil(R(-10, 10))) @@ -337,11 +348,11 @@ # Because 10**23 can't be represented exactly as a float: self.assertFalse(R(10**23) == float(10**23)) # The first test demonstrates why these are important. - self.assertFalse(1e23 < float(R(trunc(1e23) + 1))) - self.assertTrue(1e23 < R(trunc(1e23) + 1)) - self.assertFalse(1e23 <= R(trunc(1e23) - 1)) - self.assertTrue(1e23 > R(trunc(1e23) - 1)) - self.assertFalse(1e23 >= R(trunc(1e23) + 1)) + self.assertFalse(1e23 < float(R(math.trunc(1e23) + 1))) + self.assertTrue(1e23 < R(math.trunc(1e23) + 1)) + self.assertFalse(1e23 <= R(math.trunc(1e23) - 1)) + self.assertTrue(1e23 > R(math.trunc(1e23) - 1)) + self.assertFalse(1e23 >= R(math.trunc(1e23) + 1)) def testBigComplexComparisons(self): self.assertFalse(R(10**23) == complex(10**23)) Modified: python/branches/py3k/Modules/mathmodule.c ============================================================================== --- python/branches/py3k/Modules/mathmodule.c (original) +++ python/branches/py3k/Modules/mathmodule.c Fri Feb 1 09:12:03 2008 @@ -206,6 +206,39 @@ "tanh(x)\n\nReturn the hyperbolic tangent of x.") static PyObject * +math_trunc(PyObject *self, PyObject *number) +{ + static PyObject *trunc_str = NULL; + PyObject *trunc; + + if (Py_TYPE(number)->tp_dict == NULL) { + if (PyType_Ready(Py_TYPE(number)) < 0) + return NULL; + } + + if (trunc_str == NULL) { + trunc_str = PyUnicode_InternFromString("__trunc__"); + if (trunc_str == NULL) + return NULL; + } + + trunc = _PyType_Lookup(Py_TYPE(number), trunc_str); + if (trunc == NULL) { + PyErr_Format(PyExc_TypeError, + "type %.100s doesn't define __trunc__ method", + Py_TYPE(number)->tp_name); + return NULL; + } + return PyObject_CallFunctionObjArgs(trunc, number, NULL); +} + +PyDoc_STRVAR(math_trunc_doc, +"trunc(x:Real) -> Integral\n" +"\n" +"Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic" +"method."); + +static PyObject * math_frexp(PyObject *self, PyObject *arg) { int i; @@ -428,6 +461,7 @@ {"sqrt", math_sqrt, METH_O, math_sqrt_doc}, {"tan", math_tan, METH_O, math_tan_doc}, {"tanh", math_tanh, METH_O, math_tanh_doc}, + {"trunc", math_trunc, METH_O, math_trunc_doc}, {NULL, NULL} /* sentinel */ }; Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Fri Feb 1 09:12:03 2008 @@ -3616,11 +3616,11 @@ static PyObject * posix_fork1(PyObject *self, PyObject *noargs) { - int pid = fork1(); + pid_t pid = fork1(); if (pid == -1) return posix_error(); PyOS_AfterFork(); - return PyLong_FromLong((long)pid); + return PyLong_FromLong(pid); } #endif @@ -3634,12 +3634,12 @@ static PyObject * posix_fork(PyObject *self, PyObject *noargs) { - int pid = fork(); + pid_t pid = fork(); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); - return PyLong_FromLong((long)pid); + return PyLong_FromLong(pid); } #endif @@ -3741,14 +3741,15 @@ static PyObject * posix_forkpty(PyObject *self, PyObject *noargs) { - int master_fd = -1, pid; + int master_fd = -1; + pid_t pid; pid = forkpty(&master_fd, NULL, NULL, NULL); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); - return Py_BuildValue("(ii)", pid, master_fd); + return Py_BuildValue("(li)", pid, master_fd); } #endif Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Fri Feb 1 09:12:03 2008 @@ -1570,40 +1570,6 @@ Without arguments, equivalent to locals().\n\ With an argument, equivalent to object.__dict__."); -static PyObject * -builtin_trunc(PyObject *self, PyObject *number) -{ - static PyObject *trunc_str = NULL; - PyObject *trunc; - - if (Py_TYPE(number)->tp_dict == NULL) { - if (PyType_Ready(Py_TYPE(number)) < 0) - return NULL; - } - - if (trunc_str == NULL) { - trunc_str = PyUnicode_InternFromString("__trunc__"); - if (trunc_str == NULL) - return NULL; - } - - trunc = _PyType_Lookup(Py_TYPE(number), trunc_str); - if (trunc == NULL) { - PyErr_Format(PyExc_TypeError, - "type %.100s doesn't define __trunc__ method", - Py_TYPE(number)->tp_name); - return NULL; - } - return PyObject_CallFunction(trunc, "O", number); -} - -PyDoc_STRVAR(trunc_doc, -"trunc(Real) -> Integral\n\ -\n\ -returns the integral closest to x between 0 and x."); - - - static PyObject* builtin_sum(PyObject *self, PyObject *args) { @@ -1870,7 +1836,6 @@ {"sorted", (PyCFunction)builtin_sorted, METH_VARARGS | METH_KEYWORDS, sorted_doc}, {"sum", builtin_sum, METH_VARARGS, sum_doc}, {"vars", builtin_vars, METH_VARARGS, vars_doc}, - {"trunc", builtin_trunc, METH_O, trunc_doc}, {"zip", builtin_zip, METH_VARARGS, zip_doc}, {NULL, NULL}, }; Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Fri Feb 1 09:12:03 2008 @@ -885,24 +885,59 @@ { PyObject *t, *v; Py_ssize_t arg; + unsigned char *p, *q; + Py_complex z; + double d; + int real_part_zero, imag_part_zero; /* necessary to make sure types aren't coerced (e.g., int and long) */ /* _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms */ if (PyFloat_Check(o)) { - double d = PyFloat_AS_DOUBLE(o); - unsigned char* p = (unsigned char*) &d; - /* all we need is to make the tuple different in either the 0.0 - * or -0.0 case from all others, just to avoid the "coercion". - */ - if (*p==0 && p[sizeof(double)-1]==0) - t = PyTuple_Pack(3, o, o->ob_type, Py_None); - else - t = PyTuple_Pack(2, o, o->ob_type); - } else { - t = PyTuple_Pack(2, o, o->ob_type); + d = PyFloat_AS_DOUBLE(o); + p = (unsigned char*) &d; + /* all we need is to make the tuple different in either the 0.0 + * or -0.0 case from all others, just to avoid the "coercion". + */ + if (*p==0 && p[sizeof(double)-1]==0) + t = PyTuple_Pack(3, o, o->ob_type, Py_None); + else + t = PyTuple_Pack(2, o, o->ob_type); + } + else if (PyComplex_Check(o)) { + /* complex case is even messier: we need to make complex(x, + 0.) different from complex(x, -0.) and complex(0., y) + different from complex(-0., y), for any x and y. In + particular, all four complex zeros should be + distinguished.*/ + z = PyComplex_AsCComplex(o); + p = (unsigned char*) &(z.real); + q = (unsigned char*) &(z.imag); + /* all that matters here is that on IEEE platforms + real_part_zero will be true if z.real == 0., and false if + z.real == -0. In fact, real_part_zero will also be true + for some other rarely occurring nonzero floats, but this + doesn't matter. Similar comments apply to + imag_part_zero. */ + real_part_zero = *p==0 && p[sizeof(double)-1]==0; + imag_part_zero = *q==0 && q[sizeof(double)-1]==0; + if (real_part_zero && imag_part_zero) { + t = PyTuple_Pack(4, o, o->ob_type, Py_True, Py_True); + } + else if (real_part_zero && !imag_part_zero) { + t = PyTuple_Pack(4, o, o->ob_type, Py_True, Py_False); + } + else if (!real_part_zero && imag_part_zero) { + t = PyTuple_Pack(4, o, o->ob_type, Py_False, Py_True); + } + else { + t = PyTuple_Pack(2, o, o->ob_type); + } + } + else { + t = PyTuple_Pack(2, o, o->ob_type); } if (t == NULL) - return -1; + return -1; v = PyDict_GetItem(dict, t); if (!v) { Modified: python/branches/py3k/Python/marshal.c ============================================================================== --- python/branches/py3k/Python/marshal.c (original) +++ python/branches/py3k/Python/marshal.c Fri Feb 1 09:12:03 2008 @@ -833,6 +833,7 @@ v = NULL; break; } + Py_DECREF(v2); } retval = v; break; Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Fri Feb 1 09:12:03 2008 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 60144 . +# From configure.in Revision: 60476 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -10131,6 +10131,411 @@ _ACEOF +{ echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } +if test "${ac_cv_type_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef pid_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_pid_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_pid_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of pid_t" >&5 +echo $ECHO_N "checking size of pid_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef pid_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef pid_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef pid_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef pid_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef pid_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_pid_t=$ac_lo;; +'') if test "$ac_cv_type_pid_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (pid_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (pid_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_pid_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef pid_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_pid_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_pid_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (pid_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (pid_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_pid_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_pid_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_pid_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_PID_T $ac_cv_sizeof_pid_t +_ACEOF + + { echo "$as_me:$LINENO: checking for long long support" >&5 echo $ECHO_N "checking for long long support... $ECHO_C" >&6; } Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Fri Feb 1 09:12:03 2008 @@ -1177,7 +1177,7 @@ AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_TYPE_UID_T -AC_CHECK_TYPE(ssize_t, +AC_CHECK_TYPE(ssize_t, AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,) # Sizes of various common basic types @@ -1190,6 +1190,7 @@ AC_CHECK_SIZEOF(double, 8) AC_CHECK_SIZEOF(fpos_t, 4) AC_CHECK_SIZEOF(size_t, 4) +AC_CHECK_SIZEOF(pid_t, 4) AC_MSG_CHECKING(for long long support) have_long_long=no Modified: python/branches/py3k/pyconfig.h.in ============================================================================== --- python/branches/py3k/pyconfig.h.in (original) +++ python/branches/py3k/pyconfig.h.in Fri Feb 1 09:12:03 2008 @@ -872,6 +872,9 @@ /* The number of bytes in an off_t. */ #undef SIZEOF_OFF_T +/* The size of `pid_t', as computed by sizeof. */ +#undef SIZEOF_PID_T + /* The number of bytes in a pthread_t. */ #undef SIZEOF_PTHREAD_T From python-3000-checkins at python.org Fri Feb 1 12:30:18 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 1 Feb 2008 12:30:18 +0100 (CET) Subject: [Python-3000-checkins] r60491 - python/branches/py3k/Modules/arraymodule.c Message-ID: <20080201113018.E4A431E4012@bag.python.org> Author: georg.brandl Date: Fri Feb 1 12:30:18 2008 New Revision: 60491 Modified: python/branches/py3k/Modules/arraymodule.c Log: Remove the deprecated array.read/write methods. Modified: python/branches/py3k/Modules/arraymodule.c ============================================================================== --- python/branches/py3k/Modules/arraymodule.c (original) +++ python/branches/py3k/Modules/arraymodule.c Fri Feb 1 12:30:18 2008 @@ -1241,7 +1241,7 @@ "fromfile(f, n)\n\ \n\ Read n objects from the file object f and append them to the end of the\n\ -array. Also called as read."); +array."); static PyObject * @@ -1281,8 +1281,7 @@ PyDoc_STRVAR(tofile_doc, "tofile(f)\n\ \n\ -Write all items (as machine values) to the file object f. Also called as\n\ -write."); +Write all items (as machine values) to the file object f."); static PyObject * @@ -1523,8 +1522,6 @@ insert_doc}, {"pop", (PyCFunction)array_pop, METH_VARARGS, pop_doc}, - {"read", (PyCFunction)array_fromfile, METH_VARARGS, - fromfile_doc}, {"__reduce__", (PyCFunction)array_reduce, METH_NOARGS, array_doc}, {"remove", (PyCFunction)array_remove, METH_O, @@ -1541,8 +1538,6 @@ tostring_doc}, {"tounicode", (PyCFunction)array_tounicode, METH_NOARGS, tounicode_doc}, - {"write", (PyCFunction)array_tofile, METH_O, - tofile_doc}, {NULL, NULL} /* sentinel */ }; @@ -2010,13 +2005,11 @@ index() -- return index of first occurence of an object\n\ insert() -- insert a new item into the array at a provided position\n\ pop() -- remove and return item (default last)\n\ -read() -- DEPRECATED, use fromfile()\n\ remove() -- remove first occurence of an object\n\ reverse() -- reverse the order of the items in the array\n\ tofile() -- write all items to a file object\n\ tolist() -- return the array converted to an ordinary list\n\ tostring() -- return the array converted to a string\n\ -write() -- DEPRECATED, use tofile()\n\ \n\ Attributes:\n\ \n\ From python-3000-checkins at python.org Fri Feb 1 12:56:51 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 1 Feb 2008 12:56:51 +0100 (CET) Subject: [Python-3000-checkins] r60492 - in python/branches/py3k/Doc: extending/extending.rst howto/functional.rst howto/regex.rst howto/unicode.rst library/array.rst library/collections.rst library/configparser.rst library/csv.rst library/datatypes.rst library/easydialogs.rst library/email.charset.rst library/email.header.rst library/email.util.rst library/fcntl.rst library/fileinput.rst library/functions.rst library/gettext.rst library/imp.rst library/itertools.rst library/logging.rst library/mailbox.rst library/marshal.rst library/operator.rst library/os.path.rst library/os.rst library/pickle.rst library/pkgutil.rst library/re.rst library/simplexmlrpcserver.rst library/sqlite3.rst library/stdtypes.rst library/string.rst library/stringio.rst library/traceback.rst library/undoc.rst library/unicodedata.rst library/userdict.rst library/wsgiref.rst library/xml.dom.minidom.rst library/xml.dom.rst library/xml.etree.elementtree.rst library/xml.sax.handler.rst library/xml.sax.reader.rst library/xmlrpclib.rst reference/datamodel.rst tutorial/classes.rst tutorial/datastructures.rst tutorial/stdlib.rst Message-ID: <20080201115651.BFE191E4015@bag.python.org> Author: georg.brandl Date: Fri Feb 1 12:56:49 2008 New Revision: 60492 Modified: python/branches/py3k/Doc/extending/extending.rst python/branches/py3k/Doc/howto/functional.rst python/branches/py3k/Doc/howto/regex.rst python/branches/py3k/Doc/howto/unicode.rst python/branches/py3k/Doc/library/array.rst python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/configparser.rst python/branches/py3k/Doc/library/csv.rst python/branches/py3k/Doc/library/datatypes.rst python/branches/py3k/Doc/library/easydialogs.rst python/branches/py3k/Doc/library/email.charset.rst python/branches/py3k/Doc/library/email.header.rst python/branches/py3k/Doc/library/email.util.rst python/branches/py3k/Doc/library/fcntl.rst python/branches/py3k/Doc/library/fileinput.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/gettext.rst python/branches/py3k/Doc/library/imp.rst python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Doc/library/logging.rst python/branches/py3k/Doc/library/mailbox.rst python/branches/py3k/Doc/library/marshal.rst python/branches/py3k/Doc/library/operator.rst python/branches/py3k/Doc/library/os.path.rst python/branches/py3k/Doc/library/os.rst python/branches/py3k/Doc/library/pickle.rst python/branches/py3k/Doc/library/pkgutil.rst python/branches/py3k/Doc/library/re.rst python/branches/py3k/Doc/library/simplexmlrpcserver.rst python/branches/py3k/Doc/library/sqlite3.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Doc/library/string.rst python/branches/py3k/Doc/library/stringio.rst python/branches/py3k/Doc/library/traceback.rst python/branches/py3k/Doc/library/undoc.rst python/branches/py3k/Doc/library/unicodedata.rst python/branches/py3k/Doc/library/userdict.rst python/branches/py3k/Doc/library/wsgiref.rst python/branches/py3k/Doc/library/xml.dom.minidom.rst python/branches/py3k/Doc/library/xml.dom.rst python/branches/py3k/Doc/library/xml.etree.elementtree.rst python/branches/py3k/Doc/library/xml.sax.handler.rst python/branches/py3k/Doc/library/xml.sax.reader.rst python/branches/py3k/Doc/library/xmlrpclib.rst python/branches/py3k/Doc/reference/datamodel.rst python/branches/py3k/Doc/tutorial/classes.rst python/branches/py3k/Doc/tutorial/datastructures.rst python/branches/py3k/Doc/tutorial/stdlib.rst Log: Update docs w.r.t. PEP 3100 changes -- patch for GHOP by Dan Finnie. Modified: python/branches/py3k/Doc/extending/extending.rst ============================================================================== --- python/branches/py3k/Doc/extending/extending.rst (original) +++ python/branches/py3k/Doc/extending/extending.rst Fri Feb 1 12:56:49 2008 @@ -826,10 +826,9 @@ interfaces and the ability to disable the detector at runtime. The cycle detector is considered an optional component; though it is included by default, it can be disabled at build time using the :option:`--without-cycle-gc` option -to the :program:`configure` script on Unix platforms (including Mac OS X) or by -removing the definition of ``WITH_CYCLE_GC`` in the :file:`pyconfig.h` header on -other platforms. If the cycle detector is disabled in this way, the :mod:`gc` -module will not be available. +to the :program:`configure` script on Unix platforms (including Mac OS X). If +the cycle detector is disabled in this way, the :mod:`gc` module will not be +available. .. _refcountsinpython: Modified: python/branches/py3k/Doc/howto/functional.rst ============================================================================== --- python/branches/py3k/Doc/howto/functional.rst (original) +++ python/branches/py3k/Doc/howto/functional.rst Fri Feb 1 12:56:49 2008 @@ -314,7 +314,7 @@ Sets can take their contents from an iterable and let you iterate over the set's elements:: - S = set((2, 3, 5, 7, 11, 13)) + S = {2, 3, 5, 7, 11, 13} for i in S: print(i) @@ -616,29 +616,26 @@ Let's look in more detail at built-in functions often used with iterators. -Two of Python's built-in functions, :func:`map` and :func:`filter`, are somewhat -obsolete; they duplicate the features of list comprehensions but return actual -lists instead of iterators. +Two of Python's built-in functions, :func:`map` and :func:`filter` duplicate the +features of generator expressions: -``map(f, iterA, iterB, ...)`` returns a list containing ``f(iterA[0], iterB[0]), -f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``. +``map(f, iterA, iterB, ...)`` returns an iterator over the sequence + ``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``. :: def upper(s): return s.upper() - map(upper, ['sentence', 'fragment']) => + list(map(upper, ['sentence', 'fragment'])) => ['SENTENCE', 'FRAGMENT'] - [upper(s) for s in ['sentence', 'fragment']] => + list(upper(s) for s in ['sentence', 'fragment']) => ['SENTENCE', 'FRAGMENT'] -As shown above, you can achieve the same effect with a list comprehension. The -:func:`itertools.imap` function does the same thing but can handle infinite -iterators; it'll be discussed later, in the section on the :mod:`itertools` module. +You can of course achieve the same effect with a list comprehension. -``filter(predicate, iter)`` returns a list that contains all the sequence -elements that meet a certain condition, and is similarly duplicated by list +``filter(predicate, iter)`` returns an iterator over all the sequence elements +that meet a certain condition, and is similarly duplicated by list comprehensions. A **predicate** is a function that returns the truth value of some condition; for use with :func:`filter`, the predicate must take a single value. @@ -648,69 +645,61 @@ def is_even(x): return (x % 2) == 0 - filter(is_even, range(10)) => + list(filter(is_even, range(10))) => [0, 2, 4, 6, 8] -This can also be written as a list comprehension:: +This can also be written as a generator expression:: - >>> [x for x in range(10) if is_even(x)] + >>> list(x for x in range(10) if is_even(x)) [0, 2, 4, 6, 8] -:func:`filter` also has a counterpart in the :mod:`itertools` module, -:func:`itertools.ifilter`, that returns an iterator and can therefore handle -infinite sequences just as :func:`itertools.imap` can. - -``reduce(func, iter, [initial_value])`` doesn't have a counterpart in the -:mod:`itertools` module because it cumulatively performs an operation on all the -iterable's elements and therefore can't be applied to infinite iterables. -``func`` must be a function that takes two elements and returns a single value. -:func:`reduce` takes the first two elements A and B returned by the iterator and -calculates ``func(A, B)``. It then requests the third element, C, calculates -``func(func(A, B), C)``, combines this result with the fourth element returned, -and continues until the iterable is exhausted. If the iterable returns no -values at all, a :exc:`TypeError` exception is raised. If the initial value is -supplied, it's used as a starting point and ``func(initial_value, A)`` is the -first calculation. - -:: - - import operator - reduce(operator.concat, ['A', 'BB', 'C']) => - 'ABBC' - reduce(operator.concat, []) => - TypeError: reduce() of empty sequence with no initial value - reduce(operator.mul, [1,2,3], 1) => - 6 - reduce(operator.mul, [], 1) => - 1 - -If you use :func:`operator.add` with :func:`reduce`, you'll add up all the -elements of the iterable. This case is so common that there's a special +``functools.reduce(func, iter, [initial_value])`` cumulatively performs an +operation on all the iterable's elements and, therefore, can't be applied to +infinite iterables. ``func`` must be a function that takes two elements and +returns a single value. :func:`functools.reduce` takes the first two elements A +and B returned by the iterator and calculates ``func(A, B)``. It then requests +the third element, C, calculates ``func(func(A, B), C)``, combines this result +with the fourth element returned, and continues until the iterable is exhausted. +If the iterable returns no values at all, a :exc:`TypeError` exception is +raised. If the initial value is supplied, it's used as a starting point and +``func(initial_value, A)`` is the first calculation. :: + + import operator + import functools + functools.reduce(operator.concat, ['A', 'BB', 'C']) => + 'ABBC' + functools.reduce(operator.concat, []) => + TypeError: reduce() of empty sequence with no initial value + functools.reduce(operator.mul, [1,2,3], 1) => + 6 + functools.reduce(operator.mul, [], 1) => + 1 + +If you use :func:`operator.add` with :func:`functools.reduce`, you'll add up all +the elements of the iterable. This case is so common that there's a special built-in called :func:`sum` to compute it:: - reduce(operator.add, [1,2,3,4], 0) => - 10 - sum([1,2,3,4]) => - 10 - sum([]) => - 0 + functools.reduce(operator.add, [1,2,3,4], 0) => + 10 + sum([1,2,3,4]) => + 10 + sum([]) => + 0 For many uses of :func:`reduce`, though, it can be clearer to just write the obvious :keyword:`for` loop:: - # Instead of: - product = reduce(operator.mul, [1,2,3], 1) + # Instead of: + product = functools.reduce(operator.mul, [1,2,3], 1) - # You can write: - product = 1 - for i in [1,2,3]: - product *= i + # You can write: + product = 1 + for i in [1,2,3]: + product *= i ``enumerate(iter)`` counts off the elements in the iterable, returning 2-tuples -containing the count and each element. - -:: +containing the count and each element. :: enumerate(['subject', 'verb', 'object']) => (0, 'subject'), (1, 'verb'), (2, 'object') @@ -723,12 +712,10 @@ if line.strip() == '': print('Blank line at line #%i' % i) -``sorted(iterable, [cmp=None], [key=None], [reverse=False)`` collects all the -elements of the iterable into a list, sorts the list, and returns the sorted -result. The ``cmp``, ``key``, and ``reverse`` arguments are passed through to -the constructed list's ``.sort()`` method. - -:: +``sorted(iterable, [key=None], [reverse=False)`` collects all the elements of +the iterable into a list, sorts the list, and returns the sorted result. The +``key``, and ``reverse`` arguments are passed through to the constructed list's +``sort()`` method. :: import random # Generate 8 random numbers between [0, 10000) @@ -962,14 +949,7 @@ Calling functions on elements ----------------------------- -Two functions are used for calling other functions on the contents of an -iterable. - -``itertools.imap(f, iterA, iterB, ...)`` returns a stream containing -``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``:: - - itertools.imap(operator.add, [5, 6, 5], [1, 2, 3]) => - 6, 8, 8 +``itertools.imap(func, iter)`` is the same as built-in :func:`map`. The ``operator`` module contains a set of functions corresponding to Python's operators. Some examples are ``operator.add(a, b)`` (adds two values), @@ -992,14 +972,7 @@ Another group of functions chooses a subset of an iterator's elements based on a predicate. -``itertools.ifilter(predicate, iter)`` returns all the elements for which the -predicate returns true:: - - def is_even(x): - return (x % 2) == 0 - - itertools.ifilter(is_even, itertools.count()) => - 0, 2, 4, 6, 8, 10, 12, 14, ... +``itertools.ifilter(predicate, iter)`` is the same as built-in :func:`filter`. ``itertools.ifilterfalse(predicate, iter)`` is the opposite, returning all elements for which the predicate returns false:: @@ -1117,8 +1090,7 @@ Some of the functions in this module are: -* Math operations: ``add()``, ``sub()``, ``mul()``, ``div()``, ``floordiv()``, - ``abs()``, ... +* Math operations: ``add()``, ``sub()``, ``mul()``, ``floordiv()``, ``abs()``, ... * Logical operations: ``not_()``, ``truth()``. * Bitwise operations: ``and_()``, ``or_()``, ``invert()``. * Comparisons: ``eq()``, ``ne()``, ``lt()``, ``le()``, ``gt()``, and ``ge()``. @@ -1190,7 +1162,7 @@ f(*g(5, 6)) Even though ``compose()`` only accepts two functions, it's trivial to build up a -version that will compose any number of functions. We'll use ``reduce()``, +version that will compose any number of functions. We'll use ``functools.reduce()``, ``compose()`` and ``partial()`` (the last of which is provided by both ``functional`` and ``functools``). @@ -1198,7 +1170,7 @@ from functional import compose, partial - multi_compose = partial(reduce, compose) + multi_compose = partial(functools.reduce, compose) We can also use ``map()``, ``compose()`` and ``partial()`` to craft a version of Modified: python/branches/py3k/Doc/howto/regex.rst ============================================================================== --- python/branches/py3k/Doc/howto/regex.rst (original) +++ python/branches/py3k/Doc/howto/regex.rst Fri Feb 1 12:56:49 2008 @@ -497,7 +497,7 @@ the same ones in several locations, then it might be worthwhile to collect all the definitions in one place, in a section of code that compiles all the REs ahead of time. To take an example from the standard library, here's an extract -from :file:`xmllib.py`:: +from the now deprecated :file:`xmllib.py`:: ref = re.compile( ... ) entityref = re.compile( ... ) Modified: python/branches/py3k/Doc/howto/unicode.rst ============================================================================== --- python/branches/py3k/Doc/howto/unicode.rst (original) +++ python/branches/py3k/Doc/howto/unicode.rst Fri Feb 1 12:56:49 2008 @@ -237,129 +237,83 @@ Now that you've learned the rudiments of Unicode, we can look at Python's Unicode features. +The String Type +--------------- -The Unicode Type ----------------- +Since Python 3.0, the language features a ``str`` type that contain Unicode +characters, meaning any string created using ``"unicode rocks!"``, ``'unicode +rocks!``, or the triple-quoted string syntax is stored as Unicode. + +To insert a Unicode character that is not part ASCII, e.g., any letters with +accents, one can use escape sequences in their string literals as such:: + + >>> "\N{GREEK CAPITAL LETTER DELTA}" # Using the character name + '\u0394' + >>> "\u0394" # Using a 16-bit hex value + '\u0394' + >>> "\U00000394" # Using a 32-bit hex value + '\u0394' + +In addition, one can create a string using the :func:`decode` method of +:class:`bytes`. This method takes an encoding, such as UTF-8, and, optionally, +an *errors* argument. -Unicode strings are expressed as instances of the :class:`unicode` type, one of -Python's repertoire of built-in types. It derives from an abstract type called -:class:`basestring`, which is also an ancestor of the :class:`str` type; you can -therefore check if a value is a string type with ``isinstance(value, -basestring)``. Under the hood, Python represents Unicode strings as either 16- -or 32-bit integers, depending on how the Python interpreter was compiled. - -The :func:`unicode` constructor has the signature ``unicode(string[, encoding, -errors])``. All of its arguments should be 8-bit strings. The first argument -is converted to Unicode using the specified encoding; if you leave off the -``encoding`` argument, the ASCII encoding is used for the conversion, so -characters greater than 127 will be treated as errors:: - - >>> unicode('abcdef') - u'abcdef' - >>> s = unicode('abcdef') - >>> type(s) - - >>> unicode('abcdef' + chr(255)) - Traceback (most recent call last): - File "", line 1, in ? - UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 6: - ordinal not in range(128) - -The ``errors`` argument specifies the response when the input string can't be +The *errors* argument specifies the response when the input string can't be converted according to the encoding's rules. Legal values for this argument are -'strict' (raise a ``UnicodeDecodeError`` exception), 'replace' (add U+FFFD, +'strict' (raise a :exc:`UnicodeDecodeError` exception), 'replace' (add U+FFFD, 'REPLACEMENT CHARACTER'), or 'ignore' (just leave the character out of the Unicode result). The following examples show the differences:: - >>> unicode('\x80abc', errors='strict') + >>> b'\x80abc'.decode("utf-8", "strict") Traceback (most recent call last): File "", line 1, in ? UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in range(128) - >>> unicode('\x80abc', errors='replace') - u'\ufffdabc' - >>> unicode('\x80abc', errors='ignore') - u'abc' + >>> b'\x80abc'.decode("utf-8", "replace") + '\ufffdabc' + >>> b'\x80abc'.decode("utf-8", "ignore") + 'abc' -Encodings are specified as strings containing the encoding's name. Python 2.4 +Encodings are specified as strings containing the encoding's name. Python comes with roughly 100 different encodings; see the Python Library Reference at for a list. Some encodings have multiple names; for example, 'latin-1', 'iso_8859_1' and '8859' are all synonyms for the same encoding. -One-character Unicode strings can also be created with the :func:`unichr` +One-character Unicode strings can also be created with the :func:`chr` built-in function, which takes integers and returns a Unicode string of length 1 that contains the corresponding code point. The reverse operation is the built-in :func:`ord` function that takes a one-character Unicode string and returns the code point value:: - >>> unichr(40960) - u'\ua000' - >>> ord(u'\ua000') + >>> chr(40960) + '\ua000' + >>> ord('\ua000') 40960 -Instances of the :class:`unicode` type have many of the same methods as the -8-bit string type for operations such as searching and formatting:: +Converting to Bytes +------------------- - >>> s = u'Was ever feather so lightly blown to and fro as this multitude?' - >>> s.count('e') - 5 - >>> s.find('feather') - 9 - >>> s.find('bird') - -1 - >>> s.replace('feather', 'sand') - u'Was ever sand so lightly blown to and fro as this multitude?' - >>> s.upper() - u'WAS EVER FEATHER SO LIGHTLY BLOWN TO AND FRO AS THIS MULTITUDE?' - -Note that the arguments to these methods can be Unicode strings or 8-bit -strings. 8-bit strings will be converted to Unicode before carrying out the -operation; Python's default ASCII encoding will be used, so characters greater -than 127 will cause an exception:: - - >>> s.find('Was\x9f') - Traceback (most recent call last): - File "", line 1, in ? - UnicodeDecodeError: 'ascii' codec can't decode byte 0x9f in position 3: ordinal not in range(128) - >>> s.find(u'Was\x9f') - -1 - -Much Python code that operates on strings will therefore work with Unicode -strings without requiring any changes to the code. (Input and output code needs -more updating for Unicode; more on this later.) - -Another important method is ``.encode([encoding], [errors='strict'])``, which -returns an 8-bit string version of the Unicode string, encoded in the requested -encoding. The ``errors`` parameter is the same as the parameter of the -``unicode()`` constructor, with one additional possibility; as well as 'strict', +Another important str method is ``.encode([encoding], [errors='strict'])``, +which returns a ``bytes`` representation of the Unicode string, encoded in the +requested encoding. The ``errors`` parameter is the same as the parameter of +the :meth:`decode` method, with one additional possibility; as well as 'strict', 'ignore', and 'replace', you can also pass 'xmlcharrefreplace' which uses XML's character references. The following example shows the different results:: - >>> u = unichr(40960) + u'abcd' + unichr(1972) + >>> u = chr(40960) + 'abcd' + chr(1972) >>> u.encode('utf-8') - '\xea\x80\x80abcd\xde\xb4' + b'\xea\x80\x80abcd\xde\xb4' >>> u.encode('ascii') Traceback (most recent call last): File "", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character '\ua000' in position 0: ordinal not in range(128) >>> u.encode('ascii', 'ignore') - 'abcd' + b'abcd' >>> u.encode('ascii', 'replace') - '?abcd?' + b'?abcd?' >>> u.encode('ascii', 'xmlcharrefreplace') - 'ꀀabcd޴' - -Python's 8-bit strings have a ``.decode([encoding], [errors])`` method that -interprets the string using the given encoding:: - - >>> u = unichr(40960) + u'abcd' + unichr(1972) # Assemble a string - >>> utf8_version = u.encode('utf-8') # Encode as UTF-8 - >>> type(utf8_version), utf8_version - (, '\xea\x80\x80abcd\xde\xb4') - >>> u2 = utf8_version.decode('utf-8') # Decode using UTF-8 - >>> u == u2 # The two strings match - True + b'ꀀabcd޴' The low-level routines for registering and accessing the available encodings are found in the :mod:`codecs` module. However, the encoding and decoding functions @@ -377,22 +331,14 @@ Unicode Literals in Python Source Code -------------------------------------- -In Python source code, Unicode literals are written as strings prefixed with the -'u' or 'U' character: ``u'abcdefghijk'``. Specific code points can be written -using the ``\u`` escape sequence, which is followed by four hex digits giving -the code point. The ``\U`` escape sequence is similar, but expects 8 hex -digits, not 4. - -Unicode literals can also use the same escape sequences as 8-bit strings, -including ``\x``, but ``\x`` only takes two hex digits so it can't express an -arbitrary code point. Octal escapes can go up to U+01ff, which is octal 777. - -:: - - >>> s = u"a\xac\u1234\u20ac\U00008000" - ^^^^ two-digit hex escape - ^^^^^^ four-digit Unicode escape - ^^^^^^^^^^ eight-digit Unicode escape +In Python source code, specific Unicode code points can be written using the +``\u`` escape sequence, which is followed by four hex digits giving the code +point. The ``\U`` escape sequence is similar, but expects 8 hex digits, not 4:: + + >>> s = "a\xac\u1234\u20ac\U00008000" + ^^^^ two-digit hex escape + ^^^^^ four-digit Unicode escape + ^^^^^^^^^^ eight-digit Unicode escape >>> for c in s: print(ord(c), end=" ") ... 97 172 4660 8364 32768 @@ -400,7 +346,7 @@ Using escape sequences for code points greater than 127 is fine in small doses, but becomes an annoyance if you're using many accented characters, as you would in a program with messages in French or some other accent-using language. You -can also assemble strings using the :func:`unichr` built-in function, but this is +can also assemble strings using the :func:`chr` built-in function, but this is even more tedious. Ideally, you'd want to be able to write literals in your language's natural @@ -408,14 +354,15 @@ which would display the accented characters naturally, and have the right characters used at runtime. -Python supports writing Unicode literals in any encoding, but you have to -declare the encoding being used. This is done by including a special comment as -either the first or second line of the source file:: +Python supports writing Unicode literals in UTF-8 by default, but you can use +(almost) any encoding if you declare the encoding being used. This is done by +including a special comment as either the first or second line of the source +file:: #!/usr/bin/env python # -*- coding: latin-1 -*- - u = u'abcd?' + u = 'abcd?' print(ord(u[-1])) The syntax is inspired by Emacs's notation for specifying variables local to a @@ -424,22 +371,8 @@ them, you must supply the name ``coding`` and the name of your chosen encoding, separated by ``':'``. -If you don't include such a comment, the default encoding used will be ASCII. -Versions of Python before 2.4 were Euro-centric and assumed Latin-1 as a default -encoding for string literals; in Python 2.4, characters greater than 127 still -work but result in a warning. For example, the following program has no -encoding declaration:: - - #!/usr/bin/env python - u = u'abcd?' - print(ord(u[-1])) - -When you run it with Python 2.4, it will output the following warning:: - - amk:~$ python p263.py - sys:1: DeprecationWarning: Non-ASCII character '\xe9' - in file p263.py on line 2, but no encoding declared; - see http://www.python.org/peps/pep-0263.html for details +If you don't include such a comment, the default encoding used will be UTF-8 as +already mentioned. Unicode Properties @@ -457,7 +390,7 @@ import unicodedata - u = unichr(233) + unichr(0x0bf2) + unichr(3972) + unichr(6000) + unichr(13231) + u = chr(233) + chr(0x0bf2) + chr(3972) + chr(6000) + chr(13231) for i, c in enumerate(u): print(i, '%04x' % ord(c), unicodedata.category(c), end=" ") @@ -487,8 +420,8 @@ References ---------- -The Unicode and 8-bit string types are described in the Python library reference -at :ref:`typesseq`. +The ``str`` type is described in the Python library reference at +:ref:`typesseq`. The documentation for the :mod:`unicodedata` module. @@ -557,7 +490,7 @@ writing:: f = codecs.open('test', encoding='utf-8', mode='w+') - f.write(u'\u4500 blah blah blah\n') + f.write('\u4500 blah blah blah\n') f.seek(0) print(repr(f.readline()[:1])) f.close() @@ -590,7 +523,7 @@ usually just provide the Unicode string as the filename, and it will be automatically converted to the right encoding for you:: - filename = u'filename\u4500abc' + filename = 'filename\u4500abc' f = open(filename, 'w') f.write('blah\n') f.close() @@ -607,7 +540,7 @@ path will return the 8-bit versions of the filenames. For example, assuming the default filesystem encoding is UTF-8, running the following program:: - fn = u'filename\u4500abc' + fn = 'filename\u4500abc' f = open(fn, 'w') f.close() @@ -619,7 +552,7 @@ amk:~$ python t.py ['.svn', 'filename\xe4\x94\x80abc', ...] - [u'.svn', u'filename\u4500abc', ...] + ['.svn', 'filename\u4500abc', ...] The first list contains UTF-8-encoded filenames, and the second list contains the Unicode versions. Modified: python/branches/py3k/Doc/library/array.rst ============================================================================== --- python/branches/py3k/Doc/library/array.rst (original) +++ python/branches/py3k/Doc/library/array.rst Fri Feb 1 12:56:49 2008 @@ -183,18 +183,6 @@ returned. -.. method:: array.read(f, n) - - .. deprecated:: 1.5.1 - Use the :meth:`fromfile` method. - - Read *n* items (as machine values) from the file object *f* and append them to - the end of the array. If less than *n* items are available, :exc:`EOFError` is - raised, but the items that were available are still inserted into the array. - *f* must be a real built-in file object; something else with a :meth:`read` - method won't do. - - .. method:: array.remove(x) Remove the first occurrence of *x* from the array. @@ -229,13 +217,6 @@ obtain a unicode string from an array of some other type. -.. method:: array.write(f) - - .. deprecated:: 1.5.1 - Use the :meth:`tofile` method. - - Write all items (as machine values) to the file object *f*. - When an array object is printed or converted to a string, it is represented as ``array(typecode, initializer)``. The *initializer* is omitted if the array is empty, otherwise it is a string if the *typecode* is ``'c'``, otherwise it is a Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Fri Feb 1 12:56:49 2008 @@ -403,7 +403,7 @@ Any valid Python identifier may be used for a fieldname except for names starting with an underscore. Valid identifiers consist of letters, digits, and underscores but do not start with a digit or underscore and cannot be - a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, *print*, + a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or *raise*. If *verbose* is true, the class definition is printed just before being built. Modified: python/branches/py3k/Doc/library/configparser.rst ============================================================================== --- python/branches/py3k/Doc/library/configparser.rst (original) +++ python/branches/py3k/Doc/library/configparser.rst Fri Feb 1 12:56:49 2008 @@ -199,7 +199,7 @@ .. method:: RawConfigParser.read(filenames) Attempt to read and parse a list of filenames, returning a list of filenames - which were successfully parsed. If *filenames* is a string or Unicode string, + which were successfully parsed. If *filenames* is a string, it is treated as a single filename. If a file named in *filenames* cannot be opened, that file will be ignored. This is designed so that you can specify a list of potential configuration file locations (for example, the current @@ -330,8 +330,8 @@ .. method:: SafeConfigParser.set(section, option, value) If the given section exists, set the given option to the specified value; - otherwise raise :exc:`NoSectionError`. *value* must be a string (:class:`str` - or :class:`unicode`); if not, :exc:`TypeError` is raised. + otherwise raise :exc:`NoSectionError`. *value* must be a string; if it is + not, :exc:`TypeError` is raised. Examples @@ -373,12 +373,12 @@ # getint() and getboolean() also do this for their respective types float = config.getfloat('Section1', 'float') int = config.getint('Section1', 'int') - print float + int + print(float + int) # Notice that the next output does not interpolate '%(bar)s' or '%(baz)s'. # This is because we are using a RawConfigParser(). if config.getboolean('Section1', 'bool'): - print config.get('Section1', 'foo') + print(config.get('Section1', 'foo')) To get interpolation, you will need to use a :class:`ConfigParser` or :class:`SafeConfigParser`:: @@ -389,13 +389,13 @@ config.read('example.cfg') # Set the third, optional argument of get to 1 if you wish to use raw mode. - print config.get('Section1', 'foo', 0) # -> "Python is fun!" - print config.get('Section1', 'foo', 1) # -> "%(bar)s is %(baz)s!" + print(config.get('Section1', 'foo', 0)) # -> "Python is fun!" + print(config.get('Section1', 'foo', 1)) # -> "%(bar)s is %(baz)s!" # The optional fourth argument is a dict with members that will take # precedence in interpolation. - print config.get('Section1', 'foo', 0, {'bar': 'Documentation', - 'baz': 'evil'}) + print(config.get('Section1', 'foo', 0, {'bar': 'Documentation', + 'baz': 'evil'})) Defaults are available in all three types of ConfigParsers. They are used in interpolation if an option used is not defined elsewhere. :: @@ -406,10 +406,10 @@ config = ConfigParser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'}) config.read('example.cfg') - print config.get('Section1', 'foo') # -> "Python is fun!" + print(config.get('Section1', 'foo')) # -> "Python is fun!" config.remove_option('Section1', 'bar') config.remove_option('Section1', 'baz') - print config.get('Section1', 'foo') # -> "Life is hard!" + print(config.get('Section1', 'foo')) # -> "Life is hard!" The function ``opt_move`` below can be used to move options between sections:: Modified: python/branches/py3k/Doc/library/csv.rst ============================================================================== --- python/branches/py3k/Doc/library/csv.rst (original) +++ python/branches/py3k/Doc/library/csv.rst Fri Feb 1 12:56:49 2008 @@ -86,7 +86,7 @@ >>> import csv >>> spamReader = csv.reader(open('eggs.csv'), delimiter=' ', quotechar='|') >>> for row in spamReader: - ... print ', '.join(row) + ... print(', '.join(row)) Spam, Spam, Spam, Spam, Spam, Baked Beans Spam, Lovely Spam, Wonderful Spam @@ -121,7 +121,7 @@ .. function:: register_dialect(name[, dialect][, fmtparam]) - Associate *dialect* with *name*. *name* must be a string or Unicode object. The + Associate *dialect* with *name*. *name* must be a string. The dialect can be specified either by passing a sub-class of :class:`Dialect`, or by *fmtparam* keyword arguments, or both, with keyword arguments overriding parameters of the dialect. For full details about the dialect and formatting Modified: python/branches/py3k/Doc/library/datatypes.rst ============================================================================== --- python/branches/py3k/Doc/library/datatypes.rst (original) +++ python/branches/py3k/Doc/library/datatypes.rst Fri Feb 1 12:56:49 2008 @@ -11,8 +11,8 @@ Python also provides some built-in data types, in particular, :class:`dict`, :class:`list`, :class:`set` and :class:`frozenset`, and -:class:`tuple`. The :class:`str` class can be used to handle binary data -and 8-bit text, and the :class:`unicode` class to handle Unicode text. +:class:`tuple`. The :class:`str` class can be used to strings, including +Unicode strings, and the :class:`bytes` class to handle binary data. The following modules are documented in this chapter: Modified: python/branches/py3k/Doc/library/easydialogs.rst ============================================================================== --- python/branches/py3k/Doc/library/easydialogs.rst (original) +++ python/branches/py3k/Doc/library/easydialogs.rst Fri Feb 1 12:56:49 2008 @@ -107,7 +107,7 @@ *actionButtonLabel* is a string to show instead of "Open" in the OK button, *cancelButtonLabel* is a string to show instead of "Cancel" in the cancel button, *wanted* is the type of value wanted as a return: :class:`str`, - :class:`unicode`, :class:`FSSpec`, :class:`FSRef` and subtypes thereof are + :class:`FSSpec`, :class:`FSRef` and subtypes thereof are acceptable. .. index:: single: Navigation Services Modified: python/branches/py3k/Doc/library/email.charset.rst ============================================================================== --- python/branches/py3k/Doc/library/email.charset.rst (original) +++ python/branches/py3k/Doc/library/email.charset.rst Fri Feb 1 12:56:49 2008 @@ -242,6 +242,6 @@ Add a codec that map characters in the given character set to and from Unicode. *charset* is the canonical name of a character set. *codecname* is the name of a - Python codec, as appropriate for the second argument to the :func:`unicode` - built-in, or to the :meth:`encode` method of a Unicode string. + Python codec, as appropriate for the second argument to the :class:`str`'s + :func:`decode` method Modified: python/branches/py3k/Doc/library/email.header.rst ============================================================================== --- python/branches/py3k/Doc/library/email.header.rst (original) +++ python/branches/py3k/Doc/library/email.header.rst Fri Feb 1 12:56:49 2008 @@ -53,8 +53,8 @@ Optional *s* is the initial header value. If ``None`` (the default), the initial header value is not set. You can later append to the header with - :meth:`append` method calls. *s* may be a byte string or a Unicode string, but - see the :meth:`append` documentation for semantics. + :meth:`append` method calls. *s* may be an instance of :class:`bytes` or + :class:`str`, but see the :meth:`append` documentation for semantics. Optional *charset* serves two purposes: it has the same meaning as the *charset* argument to the :meth:`append` method. It also sets the default character set @@ -86,19 +86,19 @@ a :class:`Charset` instance. A value of ``None`` (the default) means that the *charset* given in the constructor is used. - *s* may be a byte string or a Unicode string. If it is a byte string (i.e. - ``isinstance(s, str)`` is true), then *charset* is the encoding of that byte - string, and a :exc:`UnicodeError` will be raised if the string cannot be decoded - with that character set. + *s* may be an instance of :class:`bytes` or :class:`str`. If it is an instance + of :class:`bytes`, then *charset* is the encoding of that byte string, and a + :exc:`UnicodeError` will be raised if the string cannot be decoded with that + character set. - If *s* is a Unicode string, then *charset* is a hint specifying the character - set of the characters in the string. In this case, when producing an + If *s* is an instance of :class:`str`, then *charset* is a hint specifying the + character set of the characters in the string. In this case, when producing an :rfc:`2822`\ -compliant header using :rfc:`2047` rules, the Unicode string will be encoded using the following charsets in order: ``us-ascii``, the *charset* hint, ``utf-8``. The first character set to not provoke a :exc:`UnicodeError` is used. - Optional *errors* is passed through to any :func:`unicode` or + Optional *errors* is passed through to any :func:`encode` or :func:`ustr.encode` call, and defaults to "strict". @@ -121,7 +121,7 @@ .. method:: Header.__unicode__() - A helper for the built-in :func:`unicode` function. Returns the header as a + A helper for :class:`str`'s :func:`encode` method. Returns the header as a Unicode string. Modified: python/branches/py3k/Doc/library/email.util.rst ============================================================================== --- python/branches/py3k/Doc/library/email.util.rst (original) +++ python/branches/py3k/Doc/library/email.util.rst Fri Feb 1 12:56:49 2008 @@ -130,10 +130,10 @@ When a header parameter is encoded in :rfc:`2231` format, :meth:`Message.get_param` may return a 3-tuple containing the character set, language, and value. :func:`collapse_rfc2231_value` turns this into a unicode - string. Optional *errors* is passed to the *errors* argument of the built-in - :func:`unicode` function; it defaults to ``replace``. Optional + string. Optional *errors* is passed to the *errors* argument of :class:`str`'s + :func:`encode` method; it defaults to ``'replace'``. Optional *fallback_charset* specifies the character set to use if the one in the - :rfc:`2231` header is not known by Python; it defaults to ``us-ascii``. + :rfc:`2231` header is not known by Python; it defaults to ``'us-ascii'``. For convenience, if the *value* passed to :func:`collapse_rfc2231_value` is not a tuple, it should be a string and it is returned unquoted. Modified: python/branches/py3k/Doc/library/fcntl.rst ============================================================================== --- python/branches/py3k/Doc/library/fcntl.rst (original) +++ python/branches/py3k/Doc/library/fcntl.rst Fri Feb 1 12:56:49 2008 @@ -47,7 +47,6 @@ .. function:: ioctl(fd, op[, arg[, mutate_flag]]) This function is identical to the :func:`fcntl` function, except that the - operations are typically defined in the library module :mod:`termios` and the argument handling is even more complicated. The parameter *arg* can be one of an integer, absent (treated identically to the Modified: python/branches/py3k/Doc/library/fileinput.rst ============================================================================== --- python/branches/py3k/Doc/library/fileinput.rst (original) +++ python/branches/py3k/Doc/library/fileinput.rst Fri Feb 1 12:56:49 2008 @@ -168,9 +168,3 @@ Usage example: ``fi = fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))`` - - .. note:: - - With this hook, :class:`FileInput` might return Unicode strings depending on the - specified *encoding*. - Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Fri Feb 1 12:56:49 2008 @@ -129,7 +129,7 @@ different ways: * If it is a *string*, you must also give the *encoding* (and optionally, - *errors*) parameters; :func:`bytearray` then converts the Unicode string to + *errors*) parameters; :func:`bytearray` then converts the string to bytes using :meth:`str.encode`. * If it is an *integer*, the array will have that size and will be @@ -415,10 +415,9 @@ .. warning:: The default *locals* act as described for function :func:`locals` below: - modifications to the default *locals* dictionary should not be attempted. Pass - an explicit *locals* dictionary if you need to see effects of the code on - *locals* after function :func:`execfile` returns. :func:`exec` cannot be - used reliably to modify a function's locals. + modifications to the default *locals* dictionary should not be attempted. + Pass an explicit *locals* dictionary if you need to see effects of the + code on *locals* after function :func:`exec` returns. .. function:: filter(function, iterable) @@ -805,16 +804,17 @@ :mod:`fileinput`, :mod:`os`, :mod:`os.path`, :mod:`tempfile`, and :mod:`shutil`. + +.. XXX works for bytes too, but should it? .. function:: ord(c) Given a string of length one, return an integer representing the Unicode code - point of the character when the argument is a unicode object, or the value of - the byte when the argument is an 8-bit string. For example, ``ord('a')`` returns - the integer ``97``, ``ord(u'\u2020')`` returns ``8224``. This is the inverse of - :func:`chr` for 8-bit strings and of :func:`unichr` for unicode objects. If a - unicode argument is given and Python was built with UCS2 Unicode, then the - character's code point must be in the range [0..65535] inclusive; otherwise the - string length is two, and a :exc:`TypeError` will be raised. + point of the character. For example, ``ord('a')`` returns the integer ``97`` + and ``ord('\u2020')`` returns ``8224``. This is the inverse of :func:`chr`. + + If the argument length is not one, a :exc:`TypeError` will be raised. (If + Python was built with UCS2 Unicode, then the character's code point must be + in the range [0..65535] inclusive; otherwise the string length is two!) .. function:: pow(x, y[, z]) @@ -838,6 +838,22 @@ accidents.) +.. function:: print([object, ...][, sep=' '][, end='\n'][, file=sys.stdout]) + + Print *object*\(s) to the stream *file*, separated by *sep* and followed by + *end*. *sep*, *end* and *file*, if present, must be given as keyword + arguments. + + All non-keyword arguments are converted to strings like :func:`str` does and + written to the stream, separated by *sep* and followed by *end*. Both *sep* + and *end* must be strings; they can also be ``None``, which means to use the + default values. If no *object* is given, :func:`print` will just write + *end*. + + The *file* argument must be an object with a ``write(string)`` method; if it + is not present or ``None``, :data:`sys.stdout` will be used. + + .. function:: property([fget[, fset[, fdel[, doc]]]]) Return a property attribute. Modified: python/branches/py3k/Doc/library/gettext.rst ============================================================================== --- python/branches/py3k/Doc/library/gettext.rst (original) +++ python/branches/py3k/Doc/library/gettext.rst Fri Feb 1 12:56:49 2008 @@ -136,9 +136,9 @@ greater convenience than the GNU :program:`gettext` API. It is the recommended way of localizing your Python applications and modules. :mod:`gettext` defines a "translations" class which implements the parsing of GNU :file:`.mo` format -files, and has methods for returning either standard 8-bit strings or Unicode -strings. Instances of this "translations" class can also install themselves in -the built-in namespace as the function :func:`_`. +files, and has methods for returning strings. Instances of this "translations" +class can also install themselves in the built-in namespace as the function +:func:`_`. .. function:: find(domain[, localedir[, languages[, all]]]) @@ -257,8 +257,7 @@ .. method:: NullTranslations.ugettext(message) If a fallback has been set, forward :meth:`ugettext` to the fallback. Otherwise, - return the translated message as a Unicode string. Overridden in derived - classes. + return the translated message as a string. Overridden in derived classes. .. method:: NullTranslations.ngettext(singular, plural, n) @@ -276,7 +275,7 @@ .. method:: NullTranslations.ungettext(singular, plural, n) If a fallback has been set, forward :meth:`ungettext` to the fallback. - Otherwise, return the translated message as a Unicode string. Overridden in + Otherwise, return the translated message as a string. Overridden in derived classes. @@ -347,8 +346,8 @@ ``None`` if not found. If the charset encoding is specified, then all message ids and message strings read from the catalog are converted to Unicode using this encoding. The :meth:`ugettext` method always returns a Unicode, while the -:meth:`gettext` returns an encoded 8-bit string. For the message id arguments -of both methods, either Unicode strings or 8-bit strings containing only +:meth:`gettext` returns an encoded bytestring. For the message id arguments +of both methods, either Unicode strings or bytestrings containing only US-ASCII characters are acceptable. Note that the Unicode version of the methods (i.e. :meth:`ugettext` and :meth:`ungettext`) are the recommended interface to use for internationalized Python programs. @@ -366,7 +365,7 @@ .. method:: GNUTranslations.gettext(message) Look up the *message* id in the catalog and return the corresponding message - string, as an 8-bit string encoded with the catalog's charset encoding, if + string, as a bytestring encoded with the catalog's charset encoding, if known. If there is no entry in the catalog for the *message* id, and a fallback has been set, the look up is forwarded to the fallback's :meth:`gettext` method. Otherwise, the *message* id is returned. @@ -382,7 +381,7 @@ .. method:: GNUTranslations.ugettext(message) Look up the *message* id in the catalog and return the corresponding message - string, as a Unicode string. If there is no entry in the catalog for the + string, as a string. If there is no entry in the catalog for the *message* id, and a fallback has been set, the look up is forwarded to the fallback's :meth:`ugettext` method. Otherwise, the *message* id is returned. @@ -391,7 +390,7 @@ Do a plural-forms lookup of a message id. *singular* is used as the message id for purposes of lookup in the catalog, while *n* is used to determine which - plural form to use. The returned message string is an 8-bit string encoded with + plural form to use. The returned message string is a bytestring encoded with the catalog's charset encoding, if known. If the message id is not found in the catalog, and a fallback is specified, the @@ -410,7 +409,7 @@ Do a plural-forms lookup of a message id. *singular* is used as the message id for purposes of lookup in the catalog, while *n* is used to determine which - plural form to use. The returned message string is a Unicode string. + plural form to use. The returned message string is a string. If the message id is not found in the catalog, and a fallback is specified, the request is forwarded to the fallback's :meth:`ungettext` method. Otherwise, Modified: python/branches/py3k/Doc/library/imp.rst ============================================================================== --- python/branches/py3k/Doc/library/imp.rst (original) +++ python/branches/py3k/Doc/library/imp.rst Fri Feb 1 12:56:49 2008 @@ -185,6 +185,19 @@ continue to use the old class definition. The same is true for derived classes. +.. function:: acquire_lock() + + Acquires the interpreter's import lock for the current thread. This lock should + be used by import hooks to ensure thread-safety when importing modules. On + platforms without threads, this function does nothing. + + +.. function:: release_lock() + + Release the interpreter's import lock. On platforms without threads, this + function does nothing. + + The following constants with integer values, defined in this module, are used to indicate the search result of :func:`find_module`. Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Fri Feb 1 12:56:49 2008 @@ -177,7 +177,8 @@ Make an iterator that filters elements from iterable returning only those for which the predicate is ``True``. If *predicate* is ``None``, return the items - that are true. Equivalent to:: + that are true. This function is the same as the built-in :func:`filter` + function. Equivalent to:: def ifilter(predicate, iterable): if predicate is None: @@ -204,7 +205,8 @@ .. function:: imap(function, *iterables) Make an iterator that computes the function using arguments from each of the - iterables. Equivalent to:: + iterables. This function is the same as the built-in :func:`map` function. + Equivalent to:: def imap(function, *iterables): iterables = [iter(it) for it in iterables) @@ -230,7 +232,7 @@ def islice(iterable, *args): s = slice(*args) - it = iter(range(s.start or 0, s.stop or sys.maxsize, s.step or 1)) + it = range(s.start or 0, s.stop or sys.maxsize, s.step or 1) nexti = next(it) for i, element in enumerate(iterable): if i == nexti: Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Fri Feb 1 12:56:49 2008 @@ -95,7 +95,7 @@ logfiles = glob.glob('%s*' % LOG_FILENAME) for filename in logfiles: - print filename + print(filename) The result should be 6 separate files, each with part of the log history for the application:: @@ -2428,13 +2428,13 @@ HOST = 'localhost' PORT = 9999 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - print "connecting..." + print("connecting...") s.connect((HOST, PORT)) - print "sending config..." + print("sending config...") s.send(struct.pack(">L", len(data_to_send))) s.send(data_to_send) s.close() - print "complete" + print("complete") More examples Modified: python/branches/py3k/Doc/library/mailbox.rst ============================================================================== --- python/branches/py3k/Doc/library/mailbox.rst (original) +++ python/branches/py3k/Doc/library/mailbox.rst Fri Feb 1 12:56:49 2008 @@ -1643,7 +1643,7 @@ list_names = ('python-list', 'python-dev', 'python-bugs') - boxes = dict((name, mailbox.mbox('~/email/%s' % name)) for name in list_names) + boxes = {name: mailbox.mbox('~/email/%s' % name) for name in list_names} inbox = mailbox.Maildir('~/Maildir', factory=None) for key in inbox.iterkeys(): Modified: python/branches/py3k/Doc/library/marshal.rst ============================================================================== --- python/branches/py3k/Doc/library/marshal.rst (original) +++ python/branches/py3k/Doc/library/marshal.rst Fri Feb 1 12:56:49 2008 @@ -38,7 +38,7 @@ Not all Python object types are supported; in general, only objects whose value is independent from a particular invocation of Python can be written and read by this module. The following types are supported: ``None``, integers, -floating point numbers, strings, Unicode objects, tuples, lists, sets, +floating point numbers, strings, bytes, bytearrays, tuples, lists, sets, dictionaries, and code objects, where it should be understood that tuples, lists and dictionaries are only supported as long as the values contained therein are themselves supported; and recursive lists and dictionaries should not be written Modified: python/branches/py3k/Doc/library/operator.rst ============================================================================== --- python/branches/py3k/Doc/library/operator.rst (original) +++ python/branches/py3k/Doc/library/operator.rst Fri Feb 1 12:56:49 2008 @@ -93,13 +93,6 @@ Return the bitwise and of *a* and *b*. -.. function:: div(a, b) - __div__(a, b) - - Return ``a / b`` when ``__future__.division`` is not in effect. This is - also known as "classic" division. - - .. function:: floordiv(a, b) __floordiv__(a, b) @@ -171,8 +164,8 @@ .. function:: truediv(a, b) __truediv__(a, b) - Return ``a / b`` when ``__future__.division`` is in effect. This is also - known as "true" division. + Return ``a / b`` where 2/3 is .66 rather than 0. This is also known as + "true" division. .. function:: xor(a, b) @@ -211,7 +204,7 @@ Remove the value of *a* at index *b*. - + .. function:: delslice(a, b, c) __delslice__(a, b, c) @@ -241,14 +234,6 @@ Return ``a * b`` where *a* is a sequence and *b* is an integer. -.. function:: sequenceIncludes(...) - - .. deprecated:: 2.0 - Use :func:`contains` instead. - - Alias for :func:`contains`. - - .. function:: setitem(a, b, c) __setitem__(a, b, c) @@ -260,6 +245,7 @@ Set the slice of *a* from index *b* to index *c-1* to the sequence *v*. + Many operations have an "in-place" version. The following functions provide a more primitive access to in-place operators than the usual syntax does; for example, the :term:`statement` ``x += y`` is equivalent to @@ -285,13 +271,6 @@ ``a = iconcat(a, b)`` is equivalent to ``a += b`` for *a* and *b* sequences. -.. function:: idiv(a, b) - __idiv__(a, b) - - ``a = idiv(a, b)`` is equivalent to ``a /= b`` when ``__future__.division`` is - not in effect. - - .. function:: ifloordiv(a, b) __ifloordiv__(a, b) @@ -350,8 +329,7 @@ .. function:: itruediv(a, b) __itruediv__(a, b) - ``a = itruediv(a, b)`` is equivalent to ``a /= b`` when ``__future__.division`` - is in effect. + ``a = itruediv(a, b)`` is equivalent to ``a /= b``. .. function:: ixor(a, b) @@ -363,10 +341,11 @@ The :mod:`operator` module also defines a few predicates to test the type of objects. +.. XXX just remove them? .. note:: - Be careful not to misinterpret the results of these functions; only - :func:`isCallable` has any measure of reliability with instance objects. + Be careful not to misinterpret the results of these functions; none have any + measure of reliability with instance objects. For example:: >>> class C: @@ -379,21 +358,10 @@ .. note:: - Python 3 is expected to introduce abstract base classes for - collection types, so it should be possible to write, for example, - ``isinstance(obj, collections.Mapping)`` and ``isinstance(obj, + Since there are now abstract classes for collection types, you should write, + for example, ``isinstance(obj, collections.Mapping)`` and ``isinstance(obj, collections.Sequence)``. -.. function:: isCallable(obj) - - .. deprecated:: 2.0 - Use the :func:`callable` built-in function instead. - - Returns true if the object *obj* can be called like a function, otherwise it - returns false. True is returned for functions, instance methods, class - objects, and instance objects which support the :meth:`__call__` method. - - .. function:: isMappingType(obj) Returns true if the object *obj* supports the mapping interface. This is true for @@ -492,11 +460,7 @@ +-----------------------+-------------------------+---------------------------------+ | Containment Test | ``obj in seq`` | ``contains(seq, obj)`` | +-----------------------+-------------------------+---------------------------------+ -| Division | ``a / b`` | ``div(a, b)`` (without | -| | | ``__future__.division``) | -+-----------------------+-------------------------+---------------------------------+ -| Division | ``a / b`` | ``truediv(a, b)`` (with | -| | | ``__future__.division``) | +| Division | ``a / b`` | ``truediv(a, b)`` | +-----------------------+-------------------------+---------------------------------+ | Division | ``a // b`` | ``floordiv(a, b)`` | +-----------------------+-------------------------+---------------------------------+ Modified: python/branches/py3k/Doc/library/os.path.rst ============================================================================== --- python/branches/py3k/Doc/library/os.path.rst (original) +++ python/branches/py3k/Doc/library/os.path.rst Fri Feb 1 12:56:49 2008 @@ -288,5 +288,5 @@ .. data:: supports_unicode_filenames True if arbitrary Unicode strings can be used as file names (within limitations - imposed by the file system), and if :func:`os.listdir` returns Unicode strings - for a Unicode argument. + imposed by the file system), and if :func:`os.listdir` returns strings that + contain characters that cannot be represented by ASCII. Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Fri Feb 1 12:56:49 2008 @@ -701,13 +701,13 @@ .. function:: getcwd() - Return a string representing the current working directory. Availability: - Macintosh, Unix, Windows. + Return a bytestring representing the current working directory. + Availability: Macintosh, Unix, Windows. .. function:: getcwdu() - Return a Unicode object representing the current working directory. + Return a string representing the current working directory. Availability: Macintosh, Unix, Windows. Modified: python/branches/py3k/Doc/library/pickle.rst ============================================================================== --- python/branches/py3k/Doc/library/pickle.rst (original) +++ python/branches/py3k/Doc/library/pickle.rst Fri Feb 1 12:56:49 2008 @@ -327,7 +327,7 @@ * integers, floating point numbers, complex numbers -* normal and Unicode strings +* strings, bytes, bytearrays * tuples, lists, sets, and dictionaries containing only picklable objects @@ -659,7 +659,7 @@ import pickle data1 = {'a': [1, 2.0, 3, 4+6j], - 'b': ('string', u'Unicode string'), + 'b': ("string", "string using Unicode features \u0394"), 'c': None} selfref_list = [1, 2, 3] Modified: python/branches/py3k/Doc/library/pkgutil.rst ============================================================================== --- python/branches/py3k/Doc/library/pkgutil.rst (original) +++ python/branches/py3k/Doc/library/pkgutil.rst Fri Feb 1 12:56:49 2008 @@ -34,8 +34,7 @@ returned. Items are only appended to the copy at the end. It is assumed that ``sys.path`` is a sequence. Items of ``sys.path`` that are - not (Unicode or 8-bit) strings referring to existing directories are ignored. - Unicode items on ``sys.path`` that cause errors when used as filenames may cause - this function to raise an exception (in line with :func:`os.path.isdir` - behavior). + not strings referring to existing directories are ignored. Unicode items on + ``sys.path`` that cause errors when used as filenames may cause this function + to raise an exception (in line with :func:`os.path.isdir` behavior). Modified: python/branches/py3k/Doc/library/re.rst ============================================================================== --- python/branches/py3k/Doc/library/re.rst (original) +++ python/branches/py3k/Doc/library/re.rst Fri Feb 1 12:56:49 2008 @@ -1153,7 +1153,7 @@ >>> text = "He was carefully disguised but captured quickly by police." >>> for m in re.finditer(r"\w+ly", text): - print '%02d-%02d: %s' % (m.start(), m.end(), m.group(0)) + print('%02d-%02d: %s' % (m.start(), m.end(), m.group(0))) 07-16: carefully 40-47: quickly Modified: python/branches/py3k/Doc/library/simplexmlrpcserver.rst ============================================================================== --- python/branches/py3k/Doc/library/simplexmlrpcserver.rst (original) +++ python/branches/py3k/Doc/library/simplexmlrpcserver.rst Fri Feb 1 12:56:49 2008 @@ -149,7 +149,7 @@ s = xmlrpclib.ServerProxy('http://localhost:8000') print(s.pow(2,3)) # Returns 2**3 = 8 print(s.add(2,3)) # Returns 5 - print(s.div(5,2)) # Returns 5//2 = 2 + print(s.mul(5,2)) # Returns 5*2 = 10 # Print list of available methods print(s.system.listMethods()) Modified: python/branches/py3k/Doc/library/sqlite3.rst ============================================================================== --- python/branches/py3k/Doc/library/sqlite3.rst (original) +++ python/branches/py3k/Doc/library/sqlite3.rst Fri Feb 1 12:56:49 2008 @@ -184,7 +184,7 @@ Registers a callable to convert the custom Python type *type* into one of SQLite's supported types. The callable *callable* accepts as single parameter the Python value, and must return a value of the following types: int, - float, str (UTF-8 encoded), unicode or buffer. + float, str, bytes (UTF-8 encoded) or buffer. .. function:: complete_statement(sql) @@ -258,7 +258,7 @@ parameters the function accepts, and *func* is a Python callable that is called as the SQL function. - The function can return any of the types supported by SQLite: unicode, str, int, + The function can return any of the types supported by SQLite: bytes, str, int, float, buffer and None. Example: @@ -275,7 +275,7 @@ final result of the aggregate. The ``finalize`` method can return any of the types supported by SQLite: - unicode, str, int, float, buffer and None. + bytes, str, int, float, buffer and None. Example: @@ -354,13 +354,13 @@ .. attribute:: Connection.text_factory Using this attribute you can control what objects are returned for the TEXT data - type. By default, this attribute is set to :class:`unicode` and the - :mod:`sqlite3` module will return Unicode objects for TEXT. If you want to - return bytestrings instead, you can set it to :class:`str`. - - For efficiency reasons, there's also a way to return Unicode objects only for - non-ASCII data, and bytestrings otherwise. To activate it, set this attribute to - :const:`sqlite3.OptimizedUnicode`. + type. By default, this attribute is set to :class:`str` and the + :mod:`sqlite3` module will return strings for TEXT. If you want to + return bytestrings instead, you can set it to :class:`bytes`. + + For efficiency reasons, there's also a way to return :class:`str` objects + only for non-ASCII data, and :class:`bytes` otherwise. To activate it, set + this attribute to :const:`sqlite3.OptimizedUnicode`. You can also set it to any other callable that accepts a single bytestring parameter and returns the resulting object. @@ -424,7 +424,7 @@ at once. It issues a COMMIT statement first, then executes the SQL script it gets as a parameter. - *sql_script* can be a bytestring or a Unicode string. + *sql_script* can be an instance of :class:`str` or :class:`bytes`. Example: @@ -493,21 +493,21 @@ The following Python types can thus be sent to SQLite without any problem: -+------------------------+-------------+ -| Python type | SQLite type | -+========================+=============+ -| ``None`` | NULL | -+------------------------+-------------+ -| ``int`` | INTEGER | -+------------------------+-------------+ -| ``float`` | REAL | -+------------------------+-------------+ -| ``str (UTF8-encoded)`` | TEXT | -+------------------------+-------------+ -| ``unicode`` | TEXT | -+------------------------+-------------+ -| ``buffer`` | BLOB | -+------------------------+-------------+ ++-------------------------------+-------------+ +| Python type | SQLite type | ++===============================+=============+ +| ``None`` | NULL | ++-------------------------------+-------------+ +| :class:`int` | INTEGER | ++-------------------------------+-------------+ +| :class:`float` | REAL | ++-------------------------------+-------------+ +| :class:`bytes` (UTF8-encoded) | TEXT | ++-------------------------------+-------------+ +| :class:`str` | TEXT | ++-------------------------------+-------------+ +| :class:`buffer` | BLOB | ++-------------------------------+-------------+ This is how SQLite types are converted to Python types by default: @@ -520,7 +520,7 @@ +-------------+---------------------------------------------+ | ``REAL`` | float | +-------------+---------------------------------------------+ -| ``TEXT`` | depends on text_factory, unicode by default | +| ``TEXT`` | depends on text_factory, str by default | +-------------+---------------------------------------------+ | ``BLOB`` | buffer | +-------------+---------------------------------------------+ @@ -537,7 +537,7 @@ As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must **adapt** them to one of the sqlite3 module's supported types for SQLite: one of NoneType, int, float, -str, unicode, buffer. +str, bytes, buffer. The :mod:`sqlite3` module uses Python object adaptation, as described in :pep:`246` for this. The protocol to use is :class:`PrepareProtocol`. Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Fri Feb 1 12:56:49 2008 @@ -2070,13 +2070,13 @@ .. XXX does this still apply? .. attribute:: file.encoding - The encoding that this file uses. When Unicode strings are written to a file, + The encoding that this file uses. When strings are written to a file, they will be converted to byte strings using this encoding. In addition, when the file is connected to a terminal, the attribute gives the encoding that the terminal is likely to use (that information might be incorrect if the user has misconfigured the terminal). The attribute is read-only and may not be present on all file-like objects. It may also be ``None``, in which case the file uses - the system default encoding for converting Unicode strings. + the system default encoding for converting strings. .. attribute:: file.mode Modified: python/branches/py3k/Doc/library/string.rst ============================================================================== --- python/branches/py3k/Doc/library/string.rst (original) +++ python/branches/py3k/Doc/library/string.rst Fri Feb 1 12:56:49 2008 @@ -538,7 +538,7 @@ String functions ---------------- -The following functions are available to operate on string and Unicode objects. +The following functions are available to operate on string objects. They are not available as string methods. Modified: python/branches/py3k/Doc/library/stringio.rst ============================================================================== --- python/branches/py3k/Doc/library/stringio.rst (original) +++ python/branches/py3k/Doc/library/stringio.rst Fri Feb 1 12:56:49 2008 @@ -1,3 +1,4 @@ +.. XXX this whole file is outdated :mod:`StringIO` --- Read and write strings as files =================================================== @@ -9,7 +10,7 @@ This module implements a file-like class, :class:`StringIO`, that reads and writes a string buffer (also known as *memory files*). See the description of file objects for operations (section :ref:`bltin-file-objects`). (For -standard strings, see :class:`str` and :class:`unicode`.) +standard strings, see :class:`str`.) .. class:: StringIO([buffer]) @@ -19,20 +20,13 @@ :class:`StringIO` will start empty. In both cases, the initial file position starts at zero. - The :class:`StringIO` object can accept either Unicode or 8-bit strings, but - mixing the two may take some care. If both are used, 8-bit strings that cannot - be interpreted as 7-bit ASCII (that use the 8th bit) will cause a - :exc:`UnicodeError` to be raised when :meth:`getvalue` is called. - The following methods of :class:`StringIO` objects require special mention: .. method:: StringIO.getvalue() Retrieve the entire contents of the "file" at any time before the - :class:`StringIO` object's :meth:`close` method is called. See the note above - for information about mixing Unicode and 8-bit strings; such mixing can cause - this method to raise :exc:`UnicodeError`. + :class:`StringIO` object's :meth:`close` method is called. .. method:: StringIO.close() @@ -75,11 +69,11 @@ original :mod:`StringIO` module in that case. Unlike the memory files implemented by the :mod:`StringIO` module, those -provided by this module are not able to accept Unicode strings that cannot be -encoded as plain ASCII strings. +provided by this module are not able to accept strings that cannot be +encoded in plain ASCII. -Calling :func:`StringIO` with a Unicode string parameter populates -the object with the buffer representation of the Unicode string, instead of +Calling :func:`StringIO` with a string parameter populates +the object with the buffer representation of the string, instead of encoding the string. Another difference from the :mod:`StringIO` module is that calling Modified: python/branches/py3k/Doc/library/traceback.rst ============================================================================== --- python/branches/py3k/Doc/library/traceback.rst (original) +++ python/branches/py3k/Doc/library/traceback.rst Fri Feb 1 12:56:49 2008 @@ -42,7 +42,7 @@ .. function:: print_exc([limit[, file]]) - This is a shorthand for ``print_exception(*sys.exc_info()``. + This is a shorthand for ``print_exception(*sys.exc_info())``. .. function:: format_exc([limit]) @@ -172,26 +172,26 @@ lumberjack() except: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() - print "*** print_tb:" + print("*** print_tb:") traceback.print_tb(exceptionTraceback, limit=1, file=sys.stdout) - print "*** print_exception:" + print("*** print_exception:") traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback, limit=2, file=sys.stdout) - print "*** print_exc:" + print("*** print_exc:") traceback.print_exc() - print "*** format_exc, first and last line:" + print("*** format_exc, first and last line:") formatted_lines = traceback.format_exc().splitlines() - print formatted_lines[0] - print formatted_lines[-1] - print "*** format_exception:" - print repr(traceback.format_exception(exceptionType, exceptionValue, - exceptionTraceback)) - print "*** extract_tb:" - print repr(traceback.extract_tb(exceptionTraceback)) - print "*** format_tb:" - print repr(traceback.format_tb(exceptionTraceback)) - print "*** tb_lineno:", traceback.tb_lineno(exceptionTraceback) - print "*** print_last:" + print(formatted_lines[0]) + print(formatted_lines[-1]) + print("*** format_exception:") + print(repr(traceback.format_exception(exceptionType, exceptionValue, + exceptionTraceback))) + print("*** extract_tb:") + print(repr(traceback.extract_tb(exceptionTraceback))) + print("*** format_tb:") + print(repr(traceback.format_tb(exceptionTraceback))) + print("*** tb_lineno:", traceback.tb_lineno(exceptionTraceback)) + print("*** print_last:") traceback.print_last() @@ -249,8 +249,8 @@ ... >>> def lumberstack(): ... traceback.print_stack() - ... print repr(traceback.extract_stack()) - ... print repr(traceback.format_stack()) + ... print(repr(traceback.extract_stack())) + ... print(repr(traceback.format_stack())) ... >>> another_function() File "", line 10, in @@ -261,10 +261,10 @@ traceback.print_stack() [('', 10, '', 'another_function()'), ('', 3, 'another_function', 'lumberstack()'), - ('', 7, 'lumberstack', 'print repr(traceback.extract_stack())')] + ('', 7, 'lumberstack', 'print(repr(traceback.extract_stack()))')] [' File "", line 10, in \n another_function()\n', ' File "", line 3, in another_function\n lumberstack()\n', - ' File "", line 8, in lumberstack\n print repr(traceback.format_stack())\n'] + ' File "", line 8, in lumberstack\n print(repr(traceback.format_stack()))\n'] This last example demonstrates the final few formatting functions:: Modified: python/branches/py3k/Doc/library/undoc.rst ============================================================================== --- python/branches/py3k/Doc/library/undoc.rst (original) +++ python/branches/py3k/Doc/library/undoc.rst Fri Feb 1 12:56:49 2008 @@ -61,18 +61,6 @@ :synopsis: Rudimentary decoder for AppleSingle format files. - -:mod:`buildtools` --- Helper module for BuildApplet and Friends ---------------------------------------------------------------- - -.. module:: buildtools - :platform: Mac - :synopsis: Helper module for BuildApplet, BuildApplication and macfreeze. - - -.. deprecated:: 2.4 - - :mod:`icopen` --- Internet Config replacement for :meth:`open` -------------------------------------------------------------- Modified: python/branches/py3k/Doc/library/unicodedata.rst ============================================================================== --- python/branches/py3k/Doc/library/unicodedata.rst (original) +++ python/branches/py3k/Doc/library/unicodedata.rst Fri Feb 1 12:56:49 2008 @@ -27,72 +27,72 @@ .. function:: lookup(name) Look up character by name. If a character with the given name is found, return - the corresponding Unicode character. If not found, :exc:`KeyError` is raised. + the corresponding character. If not found, :exc:`KeyError` is raised. -.. function:: name(unichr[, default]) +.. function:: name(chr[, default]) - Returns the name assigned to the Unicode character *unichr* as a string. If no + Returns the name assigned to the character *chr* as a string. If no name is defined, *default* is returned, or, if not given, :exc:`ValueError` is raised. -.. function:: decimal(unichr[, default]) +.. function:: decimal(chr[, default]) - Returns the decimal value assigned to the Unicode character *unichr* as integer. + Returns the decimal value assigned to the character *chr* as integer. If no such value is defined, *default* is returned, or, if not given, :exc:`ValueError` is raised. -.. function:: digit(unichr[, default]) +.. function:: digit(chr[, default]) - Returns the digit value assigned to the Unicode character *unichr* as integer. + Returns the digit value assigned to the character *chr* as integer. If no such value is defined, *default* is returned, or, if not given, :exc:`ValueError` is raised. -.. function:: numeric(unichr[, default]) +.. function:: numeric(chr[, default]) - Returns the numeric value assigned to the Unicode character *unichr* as float. + Returns the numeric value assigned to the character *chr* as float. If no such value is defined, *default* is returned, or, if not given, :exc:`ValueError` is raised. -.. function:: category(unichr) +.. function:: category(chr) - Returns the general category assigned to the Unicode character *unichr* as + Returns the general category assigned to the character *chr* as string. -.. function:: bidirectional(unichr) +.. function:: bidirectional(chr) - Returns the bidirectional category assigned to the Unicode character *unichr* as + Returns the bidirectional category assigned to the character *chr* as string. If no such value is defined, an empty string is returned. -.. function:: combining(unichr) +.. function:: combining(chr) - Returns the canonical combining class assigned to the Unicode character *unichr* + Returns the canonical combining class assigned to the character *chr* as integer. Returns ``0`` if no combining class is defined. -.. function:: east_asian_width(unichr) +.. function:: east_asian_width(chr) - Returns the east asian width assigned to the Unicode character *unichr* as + Returns the east asian width assigned to the character *chr* as string. -.. function:: mirrored(unichr) +.. function:: mirrored(chr) - Returns the mirrored property assigned to the Unicode character *unichr* as + Returns the mirrored property assigned to the character *chr* as integer. Returns ``1`` if the character has been identified as a "mirrored" character in bidirectional text, ``0`` otherwise. -.. function:: decomposition(unichr) +.. function:: decomposition(chr) - Returns the character decomposition mapping assigned to the Unicode character - *unichr* as string. An empty string is returned in case no such mapping is + Returns the character decomposition mapping assigned to the character + *chr* as string. An empty string is returned in case no such mapping is defined. @@ -146,16 +146,16 @@ >>> unicodedata.lookup('LEFT CURLY BRACKET') u'{' - >>> unicodedata.name(u'/') + >>> unicodedata.name('/') 'SOLIDUS' - >>> unicodedata.decimal(u'9') + >>> unicodedata.decimal('9') 9 - >>> unicodedata.decimal(u'a') + >>> unicodedata.decimal('a') Traceback (most recent call last): File "", line 1, in ? ValueError: not a decimal - >>> unicodedata.category(u'A') # 'L'etter, 'u'ppercase + >>> unicodedata.category('A') # 'L'etter, 'u'ppercase 'Lu' - >>> unicodedata.bidirectional(u'\u0660') # 'A'rabic, 'N'umber + >>> unicodedata.bidirectional('\u0660') # 'A'rabic, 'N'umber 'AN' Modified: python/branches/py3k/Doc/library/userdict.rst ============================================================================== --- python/branches/py3k/Doc/library/userdict.rst (original) +++ python/branches/py3k/Doc/library/userdict.rst Fri Feb 1 12:56:49 2008 @@ -146,7 +146,7 @@ behaviors to strings. It should be noted that these classes are highly inefficient compared to real -string or Unicode objects; this is especially the case for +string or bytes objects; this is especially the case for :class:`MutableString`. The :mod:`UserString` module defines the following classes: @@ -158,9 +158,9 @@ content is kept in a regular string or Unicode string object, which is accessible via the :attr:`data` attribute of :class:`UserString` instances. The instance's contents are initially set to a copy of *sequence*. *sequence* can - be either a regular Python string or Unicode string, an instance of - :class:`UserString` (or a subclass) or an arbitrary sequence which can be - converted into a string using the built-in :func:`str` function. + be an instance of :class:`bytes`, :class:`str`, :class:`UserString` (or a + subclass) or an arbitrary sequence which can be converted into a string using + the built-in :func:`str` function. .. class:: MutableString([sequence]) @@ -173,13 +173,13 @@ mutable object as dictionary key, which would be otherwise very error prone and hard to track down. -In addition to supporting the methods and operations of string and Unicode +In addition to supporting the methods and operations of bytes and string objects (see section :ref:`string-methods`), :class:`UserString` instances provide the following attribute: .. attribute:: MutableString.data - A real Python string or Unicode object used to store the content of the + A real Python string or bytes object used to store the content of the :class:`UserString` class. Modified: python/branches/py3k/Doc/library/wsgiref.rst ============================================================================== --- python/branches/py3k/Doc/library/wsgiref.rst (original) +++ python/branches/py3k/Doc/library/wsgiref.rst Fri Feb 1 12:56:49 2008 @@ -169,7 +169,7 @@ wrapper = FileWrapper(filelike, blksize=5) for chunk in wrapper: - print chunk + print(chunk) @@ -428,7 +428,7 @@ validator_app = validator(simple_app) httpd = make_server('', 8000, validator_app) - print "Listening on port 8000...." + print("Listening on port 8000....") httpd.serve_forever() @@ -720,7 +720,7 @@ return ["Hello World"] httpd = make_server('', 8000, hello_world_app) - print "Serving on port 8000..." + print("Serving on port 8000...") # Serve until process is killed httpd.serve_forever() Modified: python/branches/py3k/Doc/library/xml.dom.minidom.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.dom.minidom.rst (original) +++ python/branches/py3k/Doc/library/xml.dom.minidom.rst Fri Feb 1 12:56:49 2008 @@ -147,10 +147,10 @@ document. Encoding this string in an encoding other than UTF-8 is likely incorrect, since UTF-8 is the default encoding of XML. - With an explicit *encoding* argument, the result is a byte string in the - specified encoding. It is recommended that this argument is always specified. To - avoid :exc:`UnicodeError` exceptions in case of unrepresentable text data, the - encoding argument should be specified as "utf-8". + With an explicit *encoding* argument, the result is a :class:`bytes` object + in the specified encoding. It is recommended that this argument is always + specified. To avoid :exc:`UnicodeError` exceptions in case of unrepresentable + text data, the encoding argument should be specified as "utf-8". .. method:: Node.toprettyxml([indent[, newl[, encoding]]]) @@ -212,7 +212,7 @@ ``boolean`` all map to Python integer objects. * The type ``DOMString`` maps to Python strings. :mod:`xml.dom.minidom` supports - either byte or Unicode strings, but will normally produce Unicode strings. + either bytes or strings, but will normally produce strings. Values of type ``DOMString`` may also be ``None`` where allowed to have the IDL ``null`` value by the DOM specification from the W3C. Modified: python/branches/py3k/Doc/library/xml.dom.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.dom.rst (original) +++ python/branches/py3k/Doc/library/xml.dom.rst Fri Feb 1 12:56:49 2008 @@ -985,7 +985,7 @@ +------------------+-------------------------------------------+ Additionally, the :class:`DOMString` defined in the recommendation is mapped to -a Python string or Unicode string. Applications should be able to handle +a bytes or string object. Applications should be able to handle Unicode whenever a string is returned from the DOM. The IDL ``null`` value is mapped to ``None``, which may be accepted or Modified: python/branches/py3k/Doc/library/xml.etree.elementtree.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.etree.elementtree.rst (original) +++ python/branches/py3k/Doc/library/xml.etree.elementtree.rst Fri Feb 1 12:56:49 2008 @@ -43,10 +43,11 @@ .. function:: Comment([text]) - 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 8-bit - ASCII string or a Unicode string. *text* is a string containing the comment - string. Returns an element instance representing a comment. + 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 + representing a comment. .. function:: dump(elem) @@ -67,10 +68,11 @@ 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 8-bit - ASCII strings or Unicode strings. *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. + 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. .. function:: fromstring(text) @@ -114,11 +116,11 @@ 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 8-bit - ASCII strings 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. + 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:: tostring(element[, encoding]) @@ -275,7 +277,7 @@ with subelements: :meth:`__delitem__`, :meth:`__getitem__`, :meth:`__setitem__`, :meth:`__len__`. -Caution: Because Element objects do not define a :meth:`__nonzero__` method, +Caution: Because Element objects do not define a :meth:`__bool__` method, elements with no subelements will test as ``False``. :: element = root.find('foo') @@ -426,7 +428,7 @@ .. method:: TreeBuilder.data(data) Adds text to the current element. *data* is a string. This should be either an - 8-bit string containing ASCII text, or a Unicode string. + ASCII-only :class:`bytes` object or a :class:`str` object. .. method:: TreeBuilder.end(tag) Modified: python/branches/py3k/Doc/library/xml.sax.handler.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.sax.handler.rst (original) +++ python/branches/py3k/Doc/library/xml.sax.handler.rst Fri Feb 1 12:56:49 2008 @@ -281,8 +281,8 @@ must come from the same external entity so that the Locator provides useful information. - *content* may be a Unicode string or a byte string; the ``expat`` reader module - produces always Unicode strings. + *content* may be a string or bytes instance; the ``expat`` reader module + always produces strings. .. note:: Modified: python/branches/py3k/Doc/library/xml.sax.reader.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.sax.reader.rst (original) +++ python/branches/py3k/Doc/library/xml.sax.reader.rst Fri Feb 1 12:56:49 2008 @@ -307,7 +307,7 @@ .. method:: InputSource.setCharacterStream(charfile) Set the character stream for this input source. (The stream must be a Python 1.6 - Unicode-wrapped file-like that performs conversion to Unicode strings.) + Unicode-wrapped file-like that performs conversion to strings.) If there is a character stream specified, the SAX parser will ignore any byte stream and will not attempt to open a URI connection to the system identifier. Modified: python/branches/py3k/Doc/library/xmlrpclib.rst ============================================================================== --- python/branches/py3k/Doc/library/xmlrpclib.rst (original) +++ python/branches/py3k/Doc/library/xmlrpclib.rst Fri Feb 1 12:56:49 2008 @@ -194,7 +194,7 @@ return n%2 == 0 server = SimpleXMLRPCServer(("localhost", 8000)) - print "Listening on port 8000..." + print("Listening on port 8000...") server.register_function(is_even, "is_even") server.serve_forever() @@ -203,8 +203,8 @@ import xmlrpclib proxy = xmlrpclib.ServerProxy("http://localhost:8000/") - print "3 is even: %s" % str(proxy.is_even(3)) - print "100 is even: %s" % str(proxy.is_even(100)) + print("3 is even: %s" % str(proxy.is_even(3))) + print("100 is even: %s" % str(proxy.is_even(100))) .. _datetime-objects: @@ -241,7 +241,7 @@ return xmlrpclib.DateTime(today) server = SimpleXMLRPCServer(("localhost", 8000)) - print "Listening on port 8000..." + print("Listening on port 8000...") server.register_function(today, "today") server.serve_forever() @@ -255,7 +255,7 @@ today = proxy.today() # convert the ISO8601 string to a datetime object converted = datetime.datetime.strptime(today.value, "%Y%m%dT%H:%M:%S") - print "Today: %s" % converted.strftime("%d.%m.%Y, %H:%M") + print("Today: %s" % converted.strftime("%d.%m.%Y, %H:%M")) .. _binary-objects: @@ -300,7 +300,7 @@ handle.close() server = SimpleXMLRPCServer(("localhost", 8000)) - print "Listening on port 8000..." + print("Listening on port 8000...") server.register_function(python_logo, 'python_logo') server.serve_forever() @@ -343,7 +343,7 @@ return x+y+0j server = SimpleXMLRPCServer(("localhost", 8000)) - print "Listening on port 8000..." + print("Listening on port 8000...") server.register_function(add, 'add') server.serve_forever() @@ -356,9 +356,9 @@ try: proxy.add(2, 5) except xmlrpclib.Fault, err: - print "A fault occured" - print "Fault code: %d" % err.faultCode - print "Fault string: %s" % err.faultString + print("A fault occured") + print("Fault code: %d" % err.faultCode) + print("Fault string: %s" % err.faultString) @@ -403,11 +403,11 @@ try: proxy.some_method() except xmlrpclib.ProtocolError, err: - print "A protocol error occured" - print "URL: %s" % err.url - print "HTTP/HTTPS headers: %s" % err.headers - print "Error code: %d" % err.errcode - print "Error message: %s" % err.errmsg + print("A protocol error occured") + print("URL: %s" % err.url) + print("HTTP/HTTPS headers: %s" % err.headers) + print("Error code: %d" % err.errcode) + print("Error message: %s" % err.errmsg) MultiCall Objects ----------------- @@ -444,7 +444,7 @@ # A simple server with simple arithmetic functions server = SimpleXMLRPCServer(("localhost", 8000)) - print "Listening on port 8000..." + print("Listening on port 8000...") server.register_multicall_functions() server.register_function(add, 'add') server.register_function(subtract, 'subtract') @@ -464,7 +464,7 @@ multicall.divide(7,3) result = multicall() - print "7+3=%d, 7-3=%d, 7*3=%d, 7/3=%d" % tuple(result) + print("7+3=%d, 7-3=%d, 7*3=%d, 7/3=%d" % tuple(result)) Convenience Functions Modified: python/branches/py3k/Doc/reference/datamodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/datamodel.rst (original) +++ python/branches/py3k/Doc/reference/datamodel.rst Fri Feb 1 12:56:49 2008 @@ -901,7 +901,6 @@ pair: exception; handler pair: execution; stack single: exc_info (in module sys) - single: exc_traceback (in module sys) single: last_traceback (in module sys) single: sys.exc_info single: sys.last_traceback Modified: python/branches/py3k/Doc/tutorial/classes.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/classes.rst (original) +++ python/branches/py3k/Doc/tutorial/classes.rst Fri Feb 1 12:56:49 2008 @@ -811,7 +811,7 @@ 260 >>> from math import pi, sin - >>> sine_table = dict((x, sin(x*pi/180)) for x in range(0, 91)) + >>> sine_table = {x: sin(x*pi/180) for x in range(0, 91)} >>> unique_words = set(word for line in page for word in line.split()) Modified: python/branches/py3k/Doc/tutorial/datastructures.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/datastructures.rst (original) +++ python/branches/py3k/Doc/tutorial/datastructures.rst Fri Feb 1 12:56:49 2008 @@ -273,7 +273,7 @@ List comprehensions can be applied to complex expressions and nested functions:: - >>> [str(round(355/113.0, i)) for i in range(1, 6)] + >>> [str(round(355/113, i)) for i in range(1, 6)] ['3.1', '3.14', '3.142', '3.1416', '3.14159'] @@ -437,6 +437,9 @@ >>> fruit = set(basket) # create a set without duplicates >>> fruit {'orange', 'pear', 'apple', 'banana'} + >>> fruit = {'orange', 'apple'} # {} syntax is equivalent to [] for lists + >>> fruit + {'orange', 'apple'} >>> 'orange' in fruit # fast membership testing True >>> 'crabgrass' in fruit @@ -457,6 +460,11 @@ >>> a ^ b # letters in a or b but not both {'r', 'd', 'b', 'm', 'z', 'l'} +Like for lists, there is a set comprehension syntax:: + + >>> a = {x for x in 'abracadabra' if x not in 'abc'} + >>> a + {'r', 'd'} @@ -518,12 +526,12 @@ >>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)]) {'sape': 4139, 'jack': 4098, 'guido': 4127} - >>> dict([(x, x**2) for x in (2, 4, 6)]) # use a list comprehension - {2: 4, 4: 16, 6: 36} -Later in the tutorial, we will learn about Generator Expressions which are even -better suited for the task of supplying key-values pairs to the :func:`dict` -constructor. +In addition, dict comprehensions can be used to create dictionaries from +arbitrary key and value expressions:: + + >>> {x: x**2 for x in (2, 4, 6)} + {2: 4, 4: 16, 6: 36} When the keys are simple strings, it is sometimes easier to specify pairs using keyword arguments:: @@ -532,9 +540,8 @@ {'sape': 4139, 'jack': 4098, 'guido': 4127} +.. XXX Find out the right way to do these DUBOIS .. _tut-loopidioms: -.. % - Find out the right way to do these DUBOIS Looping Techniques ================== Modified: python/branches/py3k/Doc/tutorial/stdlib.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/stdlib.rst (original) +++ python/branches/py3k/Doc/tutorial/stdlib.rst Fri Feb 1 12:56:49 2008 @@ -121,7 +121,7 @@ floating point math:: >>> import math - >>> math.cos(math.pi / 4.0) + >>> math.cos(math.pi / 4) 0.70710678118654757 >>> math.log(1024, 2) 10.0 @@ -264,7 +264,7 @@ >>> print(average([20, 30, 70])) 40.0 """ - return sum(values, 0.0) / len(values) + return sum(values) / len(values) import doctest doctest.testmod() # automatically validate the embedded tests From python-3000-checkins at python.org Fri Feb 1 16:47:37 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 1 Feb 2008 16:47:37 +0100 (CET) Subject: [Python-3000-checkins] r60495 - python/branches/py3k/Python/bltinmodule.c Message-ID: <20080201154737.7D4261E4033@bag.python.org> Author: georg.brandl Date: Fri Feb 1 16:47:37 2008 New Revision: 60495 Modified: python/branches/py3k/Python/bltinmodule.c Log: Make print docstring consistent with its docs. Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Fri Feb 1 16:47:37 2008 @@ -1267,7 +1267,7 @@ } PyDoc_STRVAR(print_doc, -"print(value, ..., file=None, sep=' ', end='\\n')\n\ +"print(value, ..., sep=' ', end='\\n', file=sys.stdout)\n\ \n\ Prints the values to a stream, or to sys.stdout by default.\n\ Optional keyword arguments:\n\ From python-3000-checkins at python.org Fri Feb 1 17:56:30 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Fri, 1 Feb 2008 17:56:30 +0100 (CET) Subject: [Python-3000-checkins] r60498 - python/branches/py3k/Objects/longobject.c Message-ID: <20080201165630.9F91C1E4016@bag.python.org> Author: christian.heimes Date: Fri Feb 1 17:56:30 2008 New Revision: 60498 Modified: python/branches/py3k/Objects/longobject.c Log: Get the ref counting for static allocated longs right. Modified: python/branches/py3k/Objects/longobject.c ============================================================================== --- python/branches/py3k/Objects/longobject.c (original) +++ python/branches/py3k/Objects/longobject.c Fri Feb 1 17:56:30 2008 @@ -3714,17 +3714,15 @@ /* The element is already initialized, most likely * the Python interpreter was initialized before. */ - /* _Py_NewReference((PyObject*)v); - * XXX: It sets the ref count to 1 but it may be - * larger. Emulate new reference w/o setting refcnt - * to 1. - */ + Py_ssize_t refcnt; PyObject* op = (PyObject*)v; - _Py_INC_REFTOTAL; - op->ob_refcnt = (op->ob_refcnt < 1) ? 1 : op->ob_refcnt; - _Py_AddToAllObjects(op, 1); - _Py_INC_TPALLOCS(op); + refcnt = Py_REFCNT(op) < 0 ? 0 : Py_REFCNT(op); + _Py_NewReference(op); + /* _Py_NewReference sets the ref count to 1 but + * the ref count might be larger. Set the refcnt + * to the original refcnt + 1 */ + Py_REFCNT(op) = refcnt + 1; assert(Py_SIZE(op) == size); assert(v->ob_digit[0] == abs(ival)); } From python-3000-checkins at python.org Fri Feb 1 21:38:13 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Fri, 1 Feb 2008 21:38:13 +0100 (CET) Subject: [Python-3000-checkins] r60508 - in python/branches/py3k: Doc/library/decimal.rst Lib/decimal.py Message-ID: <20080201203813.490BB1E4034@bag.python.org> Author: raymond.hettinger Date: Fri Feb 1 21:38:12 2008 New Revision: 60508 Modified: python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Lib/decimal.py Log: Context flags get set, not incremented. Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Fri Feb 1 21:38:12 2008 @@ -75,7 +75,7 @@ :const:`Overflow`, and :const:`Underflow`. For each signal there is a flag and a trap enabler. When a signal is -encountered, its flag is incremented from zero and, then, if the trap enabler is +encountered, its flag is set to one, then, if the trap enabler is set to one, an exception is raised. Flags are sticky, so the user needs to reset them before monitoring a calculation. @@ -1045,7 +1045,7 @@ Signals represent conditions that arise during computation. Each corresponds to one context flag and one context trap enabler. -The context flag is incremented whenever the condition is encountered. After the +The context flag is set whenever the condition is encountered. After the computation, flags may be checked for informational purposes (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation. Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Fri Feb 1 21:38:12 2008 @@ -3411,7 +3411,7 @@ traps - If traps[exception] = 1, then the exception is raised when it is caused. Otherwise, a value is substituted in. - flags - When an exception is caused, flags[exception] is incremented. + flags - When an exception is caused, flags[exception] is set. (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. Emin - Minimum exponent @@ -3477,16 +3477,16 @@ """Handles an error If the flag is in _ignored_flags, returns the default response. - Otherwise, it increments the flag, then, if the corresponding + Otherwise, it sets the flag, then, if the corresponding trap_enabler is set, it reaises the exception. Otherwise, it returns - the default value after incrementing the flag. + the default value after setting the flag. """ error = _condition_map.get(condition, condition) if error in self._ignored_flags: # Don't touch the flag return error().handle(self, *args) - self.flags[error] += 1 + self.flags[error] = 1 if not self.traps[error]: # The errors define how to handle themselves. return condition().handle(self, *args) From python-3000-checkins at python.org Sat Feb 2 11:30:19 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Sat, 2 Feb 2008 11:30:19 +0100 (CET) Subject: [Python-3000-checkins] r60523 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: <20080202103019.472A51E400B@bag.python.org> Author: georg.brandl Date: Sat Feb 2 11:30:18 2008 New Revision: 60523 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Log: Some new 3.0 whatsnew items, written for GHOP by Andreas Freund. Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Sat Feb 2 11:30:18 2008 @@ -182,19 +182,31 @@ PEP 3101: A New Approach to String Formatting ============================================= -XXX +.. XXX expand this +* A new system for built-in string formatting operations replaces + the ``%`` string formatting operator. -PEP 3106: Revamping ``.keys()``, ``.items()`` and ``.values()`` -=============================================================== -XXX +PEP 3106: Revamping dict ``.keys()``, ``.items()`` and ``.values()`` +==================================================================== + +.. XXX expand this + +* The ``.iterkeys()``, ``.itervalues()`` and ``.iteritems()`` methods + have been removed. + +* ``.keys()``, ``.values()`` and ``.items()`` return objects with set + behavior that reference the underlying dict. PEP 3107: Function Annotations ============================== -XXX +.. XXX expand this + +* A standardized way of annotating a function's parameters and return + values. Exception Stuff @@ -216,6 +228,11 @@ * PEP 3134: Exception chaining. (The ``__context__`` feature from the PEP hasn't been implemented yet in 3.0a1.) +* A few exception messages are improved when Windows fails to load an + extension module. For example, ``error code 193`` is now ``%1 is not + a valid Win32 application``. Strings now deal with non-English + locales. + New Class and Metaclass Stuff ============================= @@ -242,8 +259,13 @@ * Removed ``<>`` (use ``!=`` instead). +* ``!=`` now returns the opposite of ``==``, unless ``==`` returns + ``NotImplemented``. + * ``as`` and ``with`` are keywords. +* ``True``, ``False``, and ``None`` are keywords. + * PEP 237: ``long`` renamed to ``int``. That is, there is only one built-in integral type, named ``int``; but it behaves like the old ``long`` type, with the exception that the literal suffix ``L`` is @@ -312,6 +334,23 @@ * ``exec`` is now a function. +* There is a new free format floating point representation, which is + based on "Floating-Point Printer Sample Code", by Robert G. Burger. + ``repr(11./5)`` now returns ``2.2`` instead of ``2.2000000000000002``. + +* The ``__oct__()`` and ``__hex__()`` special methods are removed -- + ``oct()`` and ``hex()`` use ``__index__()`` now to convert the + argument to an integer. + +* There is now a ``bin()`` builtin function. + +* Support is removed for ``__members__`` and ``__methods__``. + +* ``nb_nonzero`` is now ``nb_bool`` and ``__nonzero__`` is now + ``__bool__``. + +* Removed ``sys.maxint``. Use ``sys.maxsize``. + .. ====================================================================== @@ -341,6 +380,18 @@ * The ``cPickle`` module is gone. Use ``pickle`` instead. Eventually we'll have a transparent accelerator module. +* The ``imageop`` module is gone. + +* The ``audiodev``, ``Bastion``, ``bsddb185``, ``exceptions``, + ``linuxaudiodev``, ``md5``, ``MimeWriter``, ``mimify``, ``popen2``, + ``rexec``, ``sets``, ``sha``, ``stringold``, ``strop``, ``sunaudiodev``, + ``timing``, and ``xmllib`` modules are gone. + +* The ``new`` module is gone. + +* The methods ``os.tmpnam()``, ``os.tempnam()`` and ``os.tmpfile()`` have + been removed in favor of the ``tempfile`` module. + .. ====================================================================== .. whole new modules get described in subsections here @@ -358,6 +409,15 @@ * PEP 3123: Making ``PyObject_HEAD`` conform to standard C. +* No more C API support for restricted execution. + +* ``PyNumber_Coerce()``, ``PyNumber_CoerceEx()``, ``PyMember_Get``, + and ``PyMember_Set`` C APIs are removed. + +* New C API ``PyImport_ImportModuleNoBlock()``, works like + ``PyImport_ImportModule()`` but won't block on the import lock (returning + an error instead). + .. ====================================================================== @@ -366,6 +426,7 @@ Platform-specific changes go here. + .. ====================================================================== From python-3000-checkins at python.org Sat Feb 2 11:44:39 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Sat, 2 Feb 2008 11:44:39 +0100 (CET) Subject: [Python-3000-checkins] r60524 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: <20080202104439.19DDA1E400B@bag.python.org> Author: georg.brandl Date: Sat Feb 2 11:44:37 2008 New Revision: 60524 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Log: Update whatsnew document to use specific markup for identifiers, thus enabling cross-linking. Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Sat Feb 2 11:44:37 2008 @@ -79,7 +79,7 @@ remains syntactically valid that trips people up. I'm also omitting changes to rarely used features.) -* The ``print`` statement has been replaced with a ``print()`` function, +* The ``print`` statement has been replaced with a :func:`print` function, with keyword arguments to replace most of the special syntax of the old ``print`` statement (PEP 3105). Examples:: @@ -106,9 +106,9 @@ There are <4294967296> possibilities! - Notes about the ``print()`` function: + Notes about the :func:`print` function: - * The ``print()`` function doesn't support the "softspace" feature of + * The :func:`print` function doesn't support the "softspace" feature of the old ``print`` statement. For example, in Python 2.x, ``print "A\n", "B"`` would write ``"A\nB\n"``; but in Python 3.0, ``print("A\n", "B")`` writes ``"A\n B\n"``. @@ -118,7 +118,7 @@ ``print(x)`` instead! * When using the ``2to3`` source-to-source conversion tool, all - ``print`` statements are autmatically converted to ``print()`` + ``print`` statements are autmatically converted to :func:`print` function calls, so this is mostly a non-issue for larger projects. * Python 3.0 uses strings and bytes instead of the Unicode strings and @@ -131,19 +131,19 @@ that if a file is opened using an incorrect mode or encoding, I/O will likely fail. -* ``map()`` and ``filter()`` return iterators. A quick fix is e.g. +* :func:`map` and :func:`filter` return iterators. A quick fix is e.g. ``list(map(...))``, but a better fix is often to use a list - comprehension (especially when the original code uses ``lambda``). - Particularly tricky is ``map()`` invoked for the side effects of the + comprehension (especially when the original code uses :keyword:`lambda`). + Particularly tricky is :func:`map` invoked for the side effects of the function; the correct transformation is to use a for-loop. -* ``dict`` methods ``.keys()``, ``.items()`` and ``.values()`` return - views instead of lists. For example, this no longer works: - ``k = d.keys(); k.sort()``. Use ``k = sorted(d)`` instead. +* :class:`dict` methods :meth:`dict.keys`, :meth:`dict.items` and + :meth:`dict.values` return views instead of lists. For example, this no + longer works: ``k = d.keys(); k.sort()``. Use ``k = sorted(d)`` instead. * ``1/2`` returns a float. Use ``1//2`` to get the truncating behavior. -* The ``repr()`` of a long integer doesn't include the trailing ``L`` +* The :func:`repr` of a long integer doesn't include the trailing ``L`` anymore, so code that unconditionally strips that character will chop off the last digit instead. @@ -151,32 +151,33 @@ Strings and Bytes ================= -* There is only one string type; its name is ``str`` but its behavior - and implementation are more like ``unicode`` in 2.x. +* There is only one string type; its name is :class:`str` but its behavior and + implementation are like :class:`unicode` in 2.x. -* The ``basestring`` superclass has been removed. The ``2to3`` tool - replaces every occurence of ``basestring`` with ``str``. +* The :class:`basestring` superclass has been removed. The ``2to3`` tool + replaces every occurence of :class:`basestring` with :class:`str`. -* PEP 3137: There is a new type, ``bytes``, to represent binary data - (and encoded text, which is treated as binary data until you decide - to decode it). The ``str`` and ``bytes`` types cannot be mixed; you - must always explicitly convert between them, using the ``.encode()`` - (str -> bytes) or ``.decode()`` (bytes -> str) methods. +* PEP 3137: There is a new type, :class:`bytes`, to represent binary data (and + encoded text, which is treated as binary data until you decide to decode it). + The :class:`str` and :class:`bytes` types cannot be mixed; you must always + explicitly convert between them, using the :meth:`str.encode` (str -> bytes) + or :meth:`bytes.decode` (bytes -> str) methods. -* PEP 3112: Bytes literals. E.g. b"abc". +.. XXX add bytearray + +* PEP 3112: Bytes literals, e.g. ``b"abc"``, create :class:`bytes` instances. * PEP 3120: UTF-8 default source encoding. -* PEP 3131: Non-ASCII identifiers. (However, the standard library - remains ASCII-only with the exception of contributor names in - comments.) +* PEP 3131: Non-ASCII identifiers. (However, the standard library remains + ASCII-only with the exception of contributor names in comments.) * PEP 3116: New I/O Implementation. The API is nearly 100% backwards - compatible, but completely reimplemented (currently mostly in - Python). Also, binary files use bytes instead of strings. + compatible, but completely reimplemented (currently mostly in Python). Also, + binary files use bytes instead of strings. -* The ``StringIO`` and ``cStringIO`` modules are gone. Instead, - import ``StringIO`` or ``BytesIO`` from the ``io`` module. +* The :mod:`StringIO` and :mod:`cStringIO` modules are gone. Instead, import + :class:`io.StringIO` or :class:`io.BytesIO`. PEP 3101: A New Approach to String Formatting @@ -184,20 +185,20 @@ .. XXX expand this -* A new system for built-in string formatting operations replaces - the ``%`` string formatting operator. +* A new system for built-in string formatting operations replaces the ``%`` + string formatting operator. -PEP 3106: Revamping dict ``.keys()``, ``.items()`` and ``.values()`` -==================================================================== +PEP 3106: Revamping dict :meth:`dict.keys`, :meth:`dict.items` and :meth:`dict.values` +====================================================================================== .. XXX expand this -* The ``.iterkeys()``, ``.itervalues()`` and ``.iteritems()`` methods - have been removed. +* The :meth:`dict.iterkeys`, :meth:`dict.itervalues` and :meth:`dict.iteritems` + methods have been removed. -* ``.keys()``, ``.values()`` and ``.items()`` return objects with set - behavior that reference the underlying dict. +* :meth:`dict.keys`, :meth:`dict.values` and :meth:`dict.items` return objects + with set behavior that reference the underlying dict. PEP 3107: Function Annotations @@ -205,33 +206,31 @@ .. XXX expand this -* A standardized way of annotating a function's parameters and return - values. +* A standardized way of annotating a function's parameters and return values. Exception Stuff =============== -* PEP 352: Exceptions must derive from BaseException. This is the - root of the exception hierarchy. +* PEP 352: Exceptions must derive from :exc:`BaseException`. This is the root + of the exception hierarchy. -* StandardException was removed (already in 2.6). +* :exc:`StandardError` was removed (already in 2.6). -* Dropping sequence behavior (slicing!) and ``.message`` attribute of +* Dropping sequence behavior (slicing!) and :attr:`message` attribute of exception instances. -* PEP 3109: Raising exceptions. You must now use ``raise - Exception(args)`` instead of ``raise Exception, args``. +* PEP 3109: Raising exceptions. You must now use ``raise Exception(args)`` + instead of ``raise Exception, args``. * PEP 3110: Catching exceptions. -* PEP 3134: Exception chaining. (The ``__context__`` feature from the - PEP hasn't been implemented yet in 3.0a1.) +* PEP 3134: Exception chaining. (The :attr:`__context__` feature from the PEP + hasn't been implemented yet in 3.0a2.) -* A few exception messages are improved when Windows fails to load an - extension module. For example, ``error code 193`` is now ``%1 is not - a valid Win32 application``. Strings now deal with non-English - locales. +* A few exception messages are improved when Windows fails to load an extension + module. For example, ``error code 193`` is now ``%1 is not a valid Win32 + application``. Strings now deal with non-English locales. New Class and Metaclass Stuff @@ -255,101 +254,97 @@ Here are most of the changes that Python 3.0 makes to the core Python language and built-in functions. -* Removed backticks (use ``repr()`` instead). +* Removed backticks (use :func:`repr` instead). * Removed ``<>`` (use ``!=`` instead). * ``!=`` now returns the opposite of ``==``, unless ``==`` returns ``NotImplemented``. -* ``as`` and ``with`` are keywords. +* :keyword:`as` and :keyword:`with` are keywords. * ``True``, ``False``, and ``None`` are keywords. -* PEP 237: ``long`` renamed to ``int``. That is, there is only one - built-in integral type, named ``int``; but it behaves like the old - ``long`` type, with the exception that the literal suffix ``L`` is - neither supported by the parser nor produced by ``repr()`` anymore. - ``sys.maxint`` was also removed since the int type has no maximum - value anymore. +* PEP 237: :class:`long` renamed to :class:`int`. That is, there is only one + built-in integral type, named :class:`int`; but it behaves like the old + :class:`long` type, with the exception that the literal suffix ``L`` is + neither supported by the parser nor produced by :func:`repr` anymore. + :data:`sys.maxint` was also removed since the int type has no maximum value + anymore. * PEP 238: int division returns a float. -* The ordering operators behave differently: for example, ``x < y`` - where ``x`` and ``y`` have incompatible types raises ``TypeError`` - instead of returning a pseudo-random boolean. - -* ``__getslice__()`` and friends killed. The syntax ``a[i:j]`` now - translates to ``a.__getitem__(slice(i, j))`` (or ``__setitem__`` - or ``__delitem__``, depending on context). - -* PEP 3102: Keyword-only arguments. Named parameters occurring after - ``*args`` in the parameter list *must* be specified using keyword - syntax in the call. You can also use a bare ``*`` in the parameter - list to indicate that you don't accept a variable-length argument - list, but you do have keyword-only arguments. +* The ordering operators behave differently: for example, ``x < y`` where ``x`` + and ``y`` have incompatible types raises :exc:`TypeError` instead of returning + a pseudo-random boolean. + +* :meth:`__getslice__` and friends killed. The syntax ``a[i:j]`` now translates + to ``a.__getitem__(slice(i, j))`` (or :meth:`__setitem__` or + :meth:`__delitem__`, depending on context). + +* PEP 3102: Keyword-only arguments. Named parameters occurring after ``*args`` + in the parameter list *must* be specified using keyword syntax in the call. + You can also use a bare ``*`` in the parameter list to indicate that you don't + accept a variable-length argument list, but you do have keyword-only + arguments. -* PEP 3104: ``nonlocal`` statement. Using ``nonlocal x`` you can now +* PEP 3104: :keyword:`nonlocal` statement. Using ``nonlocal x`` you can now assign directly to a variable in an outer (but non-global) scope. -* PEP 3111: ``raw_input()`` renamed to ``input()``. That is, the new - ``input()`` function reads a line from ``sys.stdin`` and returns it - with the trailing newline stripped. It raises ``EOFError`` if the - input is terminated prematurely. To get the old behavior of - ``input()``, use ``eval(input())``. - -* ``xrange()`` renamed to ``range()``. - -* PEP 3113: Tuple parameter unpacking removed. You can no longer write - ``def foo(a, (b, c)): ...``. Use ``def foo(a, b_c): b, c = b_c`` - instead. - -* PEP 3114: ``.next()`` renamed to ``.__next__()``, new builtin - ``next()`` to call the ``__next__()`` method on an object. - -* PEP 3127: New octal literals; binary literals and ``bin()``. - Instead of ``0666``, you write ``0o666``. The oct() function is - modified accordingly. Also, ``0b1010`` equals 10, and ``bin(10)`` - returns ``"0b1010"``. ``0666`` is now a ``SyntaxError``. - -* PEP 3132: Extended Iterable Unpacking. You can now write things - like ``a, b, *rest = some_sequence``. And even ``*rest, a = - stuff``. The ``rest`` object is always a list; the right-hand - side may be any iterable. - -* PEP 3135: New ``super()``. You can now invoke ``super()`` without - arguments and the right class and instance will automatically be - chosen. With arguments, its behavior is unchanged. +* PEP 3111: :func:`raw_input` renamed to :func:`input`. That is, the new + :func:`input` function reads a line from :data:`sys.stdin` and returns it with + the trailing newline stripped. It raises :exc:`EOFError` if the input is + terminated prematurely. To get the old behavior of :func:`input`, use + ``eval(input())``. -* ``zip()``, ``map()`` and ``filter()`` return iterators. +* :func:`xrange` renamed to :func:`range`. -* ``string.letters`` and its friends (``.lowercase`` and - ``.uppercase``) are gone. Use ``string.ascii_letters`` - etc. instead. +* PEP 3113: Tuple parameter unpacking removed. You can no longer write ``def + foo(a, (b, c)): ...``. Use ``def foo(a, b_c): b, c = b_c`` instead. + +* PEP 3114: ``.next()`` renamed to :meth:`__next__`, new builtin :func:`next` to + call the :meth:`__next__` method on an object. + +* PEP 3127: New octal literals; binary literals and :func:`bin`. Instead of + ``0666``, you write ``0o666``. The :func:`oct` function is modified + accordingly. Also, ``0b1010`` equals 10, and ``bin(10)`` returns + ``"0b1010"``. ``0666`` is now a :exc:`SyntaxError`. -* Removed: ``apply()``, ``callable()``, ``coerce()``, ``execfile()``, - ``file()``, ``reduce()``, ``reload()``. +* PEP 3132: Extended Iterable Unpacking. You can now write things like ``a, b, + *rest = some_sequence``. And even ``*rest, a = stuff``. The ``rest`` object + is always a list; the right-hand side may be any iterable. + +* PEP 3135: New :func:`super`. You can now invoke :func:`super` without + arguments and the right class and instance will automatically be chosen. With + arguments, its behavior is unchanged. + +* :func:`zip`, :func:`map` and :func:`filter` return iterators. + +* :data:`string.letters` and its friends (:data:`string.lowercase` and + :data:`string.uppercase`) are gone. Use :data:`string.ascii_letters` + etc. instead. -* Removed: ``dict.has_key()``. +* Removed: :func:`apply`, :func:`callable`, :func:`coerce`, :func:`execfile`, + :func:`file`, :func:`reduce`, :func:`reload`. -* ``exec`` is now a function. +* Removed: :meth:`dict.has_key`. -* There is a new free format floating point representation, which is - based on "Floating-Point Printer Sample Code", by Robert G. Burger. - ``repr(11./5)`` now returns ``2.2`` instead of ``2.2000000000000002``. +* :func:`exec` is now a function. -* The ``__oct__()`` and ``__hex__()`` special methods are removed -- - ``oct()`` and ``hex()`` use ``__index__()`` now to convert the - argument to an integer. +* There is a new free format floating point representation, which is based on + "Floating-Point Printer Sample Code", by Robert G. Burger. ``repr(11./5)`` + now returns ``2.2`` instead of ``2.2000000000000002``. -* There is now a ``bin()`` builtin function. +* The :meth:`__oct__` and :meth:`__hex__` special methods are removed -- + :func:`oct` and :func:`hex` use :meth:`__index__` now to convert the argument + to an integer. -* Support is removed for ``__members__`` and ``__methods__``. +* Support is removed for :attr:`__members__` and :attr:`__methods__`. -* ``nb_nonzero`` is now ``nb_bool`` and ``__nonzero__`` is now - ``__bool__``. +* Renamed the boolean conversion C-level slot and method: ``nb_nonzero`` is now + ``nb_bool`` and :meth:`__nonzero__` is now :meth:`__bool__`. -* Removed ``sys.maxint``. Use ``sys.maxsize``. +* Removed :data:`sys.maxint`. Use :data:`sys.maxsize`. .. ====================================================================== @@ -360,10 +355,10 @@ * Detailed changes are listed here. -The net result of the 3.0 generalizations is that Python 3.0 runs the -pystone benchmark around 33% slower than Python 2.5. There's room for -improvement; we expect to be optimizing string and integer operations -significantly before the final 3.0 release! +The net result of the 3.0 generalizations is that Python 3.0 runs the pystone +benchmark around 33% slower than Python 2.5. There's room for improvement; we +expect to be optimizing string and integer operations significantly before the +final 3.0 release! .. ====================================================================== @@ -371,26 +366,27 @@ New, Improved, and Deprecated Modules ===================================== -As usual, Python's standard library received a number of enhancements -and bug fixes. Here's a partial list of the most notable changes, -sorted alphabetically by module name. Consult the :file:`Misc/NEWS` -file in the source tree for a more complete list of changes, or look -through the Subversion logs for all the details. +As usual, Python's standard library received a number of enhancements and bug +fixes. Here's a partial list of the most notable changes, sorted alphabetically +by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more +complete list of changes, or look through the Subversion logs for all the +details. -* The ``cPickle`` module is gone. Use ``pickle`` instead. Eventually +* The :mod:`cPickle` module is gone. Use :mod:`pickle` instead. Eventually we'll have a transparent accelerator module. -* The ``imageop`` module is gone. +* The :mod:`imageop` module is gone. -* The ``audiodev``, ``Bastion``, ``bsddb185``, ``exceptions``, - ``linuxaudiodev``, ``md5``, ``MimeWriter``, ``mimify``, ``popen2``, - ``rexec``, ``sets``, ``sha``, ``stringold``, ``strop``, ``sunaudiodev``, - ``timing``, and ``xmllib`` modules are gone. +* The :mod:`audiodev`, :mod:`Bastion`, :mod:`bsddb185`, :mod:`exceptions`, + :mod:`linuxaudiodev`, :mod:`md5`, :mod:`MimeWriter`, :mod:`mimify`, + :mod:`popen2`, :mod:`rexec`, :mod:`sets`, :mod:`sha`, :mod:`stringold`, + :mod:`strop`, :mod:`sunaudiodev`, :mod:`timing`, and :mod:`xmllib` modules are + gone. -* The ``new`` module is gone. +* The :mod:`new` module is gone. -* The methods ``os.tmpnam()``, ``os.tempnam()`` and ``os.tmpfile()`` have - been removed in favor of the ``tempfile`` module. +* The functions :func:`os.tmpnam`, :func:`os.tempnam` and :func:`os.tmpfile` + have been removed in favor of the :mod:`tempfile` module. .. ====================================================================== .. whole new modules get described in subsections here @@ -407,15 +403,15 @@ * PEP 3121: Extension Module Initialization & Finalization. -* PEP 3123: Making ``PyObject_HEAD`` conform to standard C. +* PEP 3123: Making :cmacro:`PyObject_HEAD` conform to standard C. * No more C API support for restricted execution. -* ``PyNumber_Coerce()``, ``PyNumber_CoerceEx()``, ``PyMember_Get``, - and ``PyMember_Set`` C APIs are removed. +* :cfunc:`PyNumber_Coerce`, :cfunc:`PyNumber_CoerceEx`, :cfunc:`PyMember_Get`, + and :cfunc:`PyMember_Set` C APIs are removed. -* New C API ``PyImport_ImportModuleNoBlock()``, works like - ``PyImport_ImportModule()`` but won't block on the import lock (returning +* New C API :cfunc:`PyImport_ImportModuleNoBlock`, works like + :cfunc:`PyImport_ImportModule` but won't block on the import lock (returning an error instead). .. ====================================================================== From python-3000-checkins at python.org Sun Feb 3 17:51:10 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 3 Feb 2008 17:51:10 +0100 (CET) Subject: [Python-3000-checkins] r60552 - in python/branches/py3k: Doc/Makefile Doc/README.txt Doc/builddoc.bat Doc/conf.py Doc/includes/email-alternative.py Doc/library/email-examples.rst Doc/library/queue.rst Doc/library/socket.rst Doc/library/urllib2.rst Doc/make.bat Doc/reference/datamodel.rst Lib/distutils/__init__.py Lib/distutils/command/build_ext.py Lib/rational.py Lib/test/test_builtin.py Lib/test/test_rational.py Lib/test/test_socketserver.py Misc/ACKS Misc/build.sh Modules/_bsddb.c Modules/mathmodule.c Modules/posixmodule.c Objects/floatobject.c PC/os2emx/Makefile PC/os2emx/README.os2emx PC/os2emx/python25.def PC/os2emx/python26.def PCbuild/_bsddb.vcproj PCbuild/build.bat PCbuild/readme.txt configure configure.in setup.py Message-ID: <20080203165110.67FF61E401D@bag.python.org> Author: christian.heimes Date: Sun Feb 3 17:51:08 2008 New Revision: 60552 Added: python/branches/py3k/Doc/includes/email-alternative.py - copied unchanged from r60527, python/trunk/Doc/includes/email-alternative.py python/branches/py3k/Doc/make.bat - copied unchanged from r60520, python/trunk/Doc/make.bat python/branches/py3k/PC/os2emx/python26.def Removed: python/branches/py3k/Doc/builddoc.bat python/branches/py3k/PC/os2emx/python25.def Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/Makefile python/branches/py3k/Doc/README.txt python/branches/py3k/Doc/conf.py python/branches/py3k/Doc/library/email-examples.rst python/branches/py3k/Doc/library/queue.rst python/branches/py3k/Doc/library/socket.rst python/branches/py3k/Doc/library/urllib2.rst python/branches/py3k/Doc/reference/datamodel.rst python/branches/py3k/Lib/distutils/__init__.py python/branches/py3k/Lib/distutils/command/build_ext.py python/branches/py3k/Lib/rational.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_rational.py python/branches/py3k/Lib/test/test_socketserver.py python/branches/py3k/Misc/ACKS python/branches/py3k/Misc/build.sh python/branches/py3k/Modules/_bsddb.c python/branches/py3k/Modules/mathmodule.c python/branches/py3k/Modules/posixmodule.c python/branches/py3k/Objects/floatobject.c python/branches/py3k/PC/os2emx/Makefile python/branches/py3k/PC/os2emx/README.os2emx python/branches/py3k/PCbuild/_bsddb.vcproj python/branches/py3k/PCbuild/build.bat python/branches/py3k/PCbuild/readme.txt python/branches/py3k/configure python/branches/py3k/configure.in python/branches/py3k/setup.py Log: Merged revisions 60481,60485,60489-60520,60523-60527,60530-60533,60535-60538,60540-60551 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk NOTE: I blocked the following revisions: svnmerge.py block -r 60521,60522,60528,60529,60534,60539 The new tests must be merged with lots of manual work. ........ r60493 | georg.brandl | 2008-02-01 12:59:08 +0100 (Fri, 01 Feb 2008) | 2 lines Update IPv6 RFC number. ........ r60497 | georg.brandl | 2008-02-01 16:50:15 +0100 (Fri, 01 Feb 2008) | 2 lines Add link checker builder, written for GHOP by Thomas Lamb. ........ r60500 | georg.brandl | 2008-02-01 19:08:09 +0100 (Fri, 01 Feb 2008) | 2 lines Rename batch file. ........ r60504 | christian.heimes | 2008-02-01 19:49:26 +0100 (Fri, 01 Feb 2008) | 1 line More int -> pid_t. ........ r60507 | georg.brandl | 2008-02-01 20:24:01 +0100 (Fri, 01 Feb 2008) | 2 lines Wording nit. ........ r60510 | georg.brandl | 2008-02-01 21:45:33 +0100 (Fri, 01 Feb 2008) | 2 lines Update for latest sphinx latex writer. ........ r60511 | raymond.hettinger | 2008-02-01 22:30:23 +0100 (Fri, 01 Feb 2008) | 1 line Issue #1996: float.as_integer_ratio() should return fraction in lowest terms. ........ r60512 | raymond.hettinger | 2008-02-01 23:15:52 +0100 (Fri, 01 Feb 2008) | 1 line Integer ratio should return ints instead of longs whereever possible. ........ r60513 | raymond.hettinger | 2008-02-01 23:22:50 +0100 (Fri, 01 Feb 2008) | 1 line labs() takes a long for an input. ........ r60514 | raymond.hettinger | 2008-02-01 23:42:59 +0100 (Fri, 01 Feb 2008) | 1 line Test round-trip on float.as_integer_ratio() and float.__truediv__(). ........ r60515 | marc-andre.lemburg | 2008-02-01 23:58:17 +0100 (Fri, 01 Feb 2008) | 3 lines Bump distutils version number to match Python version. ........ r60516 | raymond.hettinger | 2008-02-02 00:12:19 +0100 (Sat, 02 Feb 2008) | 1 line Fix int/long typecase. Add check for non-binary floating point. ........ r60517 | raymond.hettinger | 2008-02-02 00:45:44 +0100 (Sat, 02 Feb 2008) | 1 line Add protection from weirdness while scaling the mantissa to an integer. ........ r60518 | raymond.hettinger | 2008-02-02 06:11:40 +0100 (Sat, 02 Feb 2008) | 1 line Simpler solution to handling non-IEEE 754 environments. ........ r60519 | raymond.hettinger | 2008-02-02 06:24:44 +0100 (Sat, 02 Feb 2008) | 1 line Neaten-up a bit. ........ r60520 | georg.brandl | 2008-02-02 10:56:20 +0100 (Sat, 02 Feb 2008) | 2 lines Amendments to the urllib2 docs, written for GHOP by Thomas Lamb. ........ r60525 | georg.brandl | 2008-02-02 11:49:58 +0100 (Sat, 02 Feb 2008) | 3 lines Add email example how to send a multipart message. Written for GHOP by Martin Matejek. ........ r60526 | georg.brandl | 2008-02-02 12:05:00 +0100 (Sat, 02 Feb 2008) | 2 lines Rewrite test_socketserver as unittest, written for GHOP by Benjamin Petersen. ........ r60527 | georg.brandl | 2008-02-02 12:05:34 +0100 (Sat, 02 Feb 2008) | 2 lines Add GHOP contributor. ........ r60530 | mark.dickinson | 2008-02-02 18:16:13 +0100 (Sat, 02 Feb 2008) | 2 lines Make the Rational constructor accept '3.' and '.2' as well as '3.2'. ........ r60531 | neal.norwitz | 2008-02-02 19:52:51 +0100 (Sat, 02 Feb 2008) | 1 line Update the leaky tests (ie, ignore these tests if they report leaks). This version has been running for a while. ........ r60533 | skip.montanaro | 2008-02-02 20:11:57 +0100 (Sat, 02 Feb 2008) | 7 lines Split the refleak mail body into two parts, the first being those failing tests which are deemed more important issues, the second those which are known to have difficult to solve problems and are generally expected to leak. Hopefully this doesn't break the script... ........ r60535 | georg.brandl | 2008-02-03 01:04:50 +0100 (Sun, 03 Feb 2008) | 3 lines Wait for a delay before reaping children -- this should fix the test_socketserver failures on several platforms. ........ r60536 | brett.cannon | 2008-02-03 03:07:55 +0100 (Sun, 03 Feb 2008) | 2 lines Fix a minor typo. ........ r60537 | brett.cannon | 2008-02-03 03:08:45 +0100 (Sun, 03 Feb 2008) | 3 lines Directories from CPPFLAGS and LDFLAGS were being added in the reverse order for searches as to how they were listed in the environment variable. ........ r60538 | brett.cannon | 2008-02-03 03:34:14 +0100 (Sun, 03 Feb 2008) | 2 lines Remove extra tick marks and add a missing closing parenthesis. ........ r60540 | andrew.macintyre | 2008-02-03 07:58:06 +0100 (Sun, 03 Feb 2008) | 2 lines Update OS/2 EMX build bits for 2.6. ........ r60541 | andrew.macintyre | 2008-02-03 08:01:11 +0100 (Sun, 03 Feb 2008) | 2 lines Rename module definition file to reflect v2.6. ........ r60542 | andrew.macintyre | 2008-02-03 08:07:31 +0100 (Sun, 03 Feb 2008) | 6 lines The wrapper function is supposed to be for spawnvpe() so that's what we should call [this wrapper only available on OS/2]. Backport candidate to 2.5. ........ r60544 | gregory.p.smith | 2008-02-03 08:20:53 +0100 (Sun, 03 Feb 2008) | 6 lines Merge this fix from the pybsddb tree: r293 | jcea | 2008-01-31 01:08:19 -0800 (Thu, 31 Jan 2008) | 4 lines Solved memory leak when using cursors with databases without environment. ........ r60546 | gregory.p.smith | 2008-02-03 09:01:46 +0100 (Sun, 03 Feb 2008) | 2 lines remove a repeated occurance of a hardcoded berkeleydb library version number ........ r60549 | brett.cannon | 2008-02-03 10:59:21 +0100 (Sun, 03 Feb 2008) | 2 lines Add an entry for r60537. ........ r60550 | georg.brandl | 2008-02-03 13:29:00 +0100 (Sun, 03 Feb 2008) | 2 lines #2003: fix sentence. ........ r60551 | christian.heimes | 2008-02-03 15:34:18 +0100 (Sun, 03 Feb 2008) | 2 lines Fixed paths to Windows build directories in build_ext.py Use vsbuild instead of devenv in build.bat and _bsddb.vcproj ........ Modified: python/branches/py3k/Doc/Makefile ============================================================================== --- python/branches/py3k/Doc/Makefile (original) +++ python/branches/py3k/Doc/Makefile Sun Feb 3 17:51:08 2008 @@ -16,11 +16,12 @@ help: @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " web to make file usable by Sphinx.web" - @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 " changes to make an overview over all changed/added/deprecated items" + @echo " html to make standalone HTML files" + @echo " web to make file usable by Sphinx.web" + @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 " changes to make an overview over all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" checkout: @if [ ! -d tools/sphinx ]; then \ @@ -71,6 +72,11 @@ changes: build @echo "The overview file is in build/changes." +linkcheck: BUILDER = linkcheck +linkcheck: build + @echo "Link check complete; look for any errors in the above output "\ + "or in build/$(BUILDER)/output.txt" + clean: -rm -rf build/* -rm -rf tools/sphinx Modified: python/branches/py3k/Doc/README.txt ============================================================================== --- python/branches/py3k/Doc/README.txt (original) +++ python/branches/py3k/Doc/README.txt Sun Feb 3 17:51:08 2008 @@ -55,6 +55,10 @@ * "latex", which builds LaTeX source files that can be run with "pdflatex" to produce PDF documents. + + * "linkcheck", which checks all external references to see whether they are + broken, redirected or malformed, and outputs this information to stdout + as well as a plain-text (.txt) file. * "changes", which builds an overview over all versionadded/versionchanged/ deprecated items in the current version. This is meant as a help for the Deleted: /python/branches/py3k/Doc/builddoc.bat ============================================================================== --- /python/branches/py3k/Doc/builddoc.bat Sun Feb 3 17:51:08 2008 +++ (empty file) @@ -1,52 +0,0 @@ - at echo off -setlocal - -set SVNROOT=http://svn.python.org/projects -if "%PYTHON%" EQU "" set PYTHON=python25 - -if "%1" EQU "" goto help -if "%1" EQU "html" goto build -if "%1" EQU "htmlhelp" goto build -if "%1" EQU "web" goto build -if "%1" EQU "webrun" goto webrun -if "%1" EQU "checkout" goto checkout -if "%1" EQU "update" goto update - -:help -echo HELP -echo. -echo builddoc checkout -echo builddoc update -echo builddoc html -echo builddoc htmlhelp -echo builddoc web -echo builddoc webrun -echo. -goto end - -:checkout -svn co %SVNROOT%/doctools/trunk/sphinx tools/sphinx -svn co %SVNROOT%/external/docutils-0.4/docutils tools/docutils -svn co %SVNROOT%/external/Pygments-0.9/pygments tools/pygments -goto end - -:update -svn update tools/sphinx -svn update tools/docutils -svn update tools/pygments -goto end - -:build -if not exist build mkdir build -if not exist build\%1 mkdir build\%1 -if not exist build\doctrees mkdir build\doctrees -cmd /C %PYTHON% tools\sphinx-build.py -b%1 -dbuild\doctrees . build\%1 -if "%1" EQU "htmlhelp" "%ProgramFiles%\HTML Help Workshop\hhc.exe" build\htmlhelp\pydoc.hhp -goto end - -:webrun -set PYTHONPATH=tools -%PYTHON% -m sphinx.web build\web -goto end - -:end Modified: python/branches/py3k/Doc/conf.py ============================================================================== --- python/branches/py3k/Doc/conf.py (original) +++ python/branches/py3k/Doc/conf.py Sun Feb 3 17:51:08 2008 @@ -103,29 +103,29 @@ # (source start file, target name, title, author, document class [howto/manual]). _stdauthor = r'Guido van Rossum\\Fred L. Drake, Jr., editor' latex_documents = [ - ('c-api/index.rst', 'c-api.tex', + ('c-api/index', 'c-api.tex', 'The Python/C API', _stdauthor, 'manual'), - ('distutils/index.rst', 'distutils.tex', + ('distutils/index', 'distutils.tex', 'Distributing Python Modules', _stdauthor, 'manual'), - ('documenting/index.rst', 'documenting.tex', + ('documenting/index', 'documenting.tex', 'Documenting Python', 'Georg Brandl', 'manual'), - ('extending/index.rst', 'extending.tex', + ('extending/index', 'extending.tex', 'Extending and Embedding Python', _stdauthor, 'manual'), - ('install/index.rst', 'install.tex', + ('install/index', 'install.tex', 'Installing Python Modules', _stdauthor, 'manual'), - ('library/index.rst', 'library.tex', + ('library/index', 'library.tex', 'The Python Library Reference', _stdauthor, 'manual'), - ('reference/index.rst', 'reference.tex', + ('reference/index', 'reference.tex', 'The Python Language Reference', _stdauthor, 'manual'), - ('tutorial/index.rst', 'tutorial.tex', + ('tutorial/index', 'tutorial.tex', 'Python Tutorial', _stdauthor, 'manual'), - ('using/index.rst', 'using.tex', + ('using/index', 'using.tex', 'Using Python', _stdauthor, 'manual'), - ('whatsnew/' + version + '.rst', 'whatsnew.tex', + ('whatsnew/' + version, 'whatsnew.tex', 'What\'s New in Python', 'A. M. Kuchling', 'howto'), ] # Collect all HOWTOs individually -latex_documents.extend(('howto/' + fn, 'howto-' + fn[:-4] + '.tex', +latex_documents.extend(('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex', 'HOWTO', _stdauthor, 'howto') for fn in os.listdir('howto') if fn.endswith('.rst') and fn != 'index.rst') @@ -139,4 +139,4 @@ ''' # Documents to append as an appendix to all manuals. -latex_appendices = ['glossary.rst', 'about.rst', 'license.rst', 'copyright.rst'] +latex_appendices = ['glossary', 'about', 'license', 'copyright'] Modified: python/branches/py3k/Doc/library/email-examples.rst ============================================================================== --- python/branches/py3k/Doc/library/email-examples.rst (original) +++ python/branches/py3k/Doc/library/email-examples.rst Sun Feb 3 17:51:08 2008 @@ -16,18 +16,23 @@ Here's an example of how to send the entire contents of a directory as an email -message: [1]_ +message: [1]_ .. literalinclude:: ../includes/email-dir.py -And finally, here's an example of how to unpack a MIME message like the one +Here's an example of how to unpack a MIME message like the one above, into a directory of files: .. literalinclude:: ../includes/email-unpack.py +Here's an example of how to create an HTML message with an alternative plain +text version: [2]_ + +.. literalinclude:: ../includes/email-alternative.py + .. rubric:: Footnotes .. [1] Thanks to Matthew Dixon Cowles for the original inspiration and examples. - +.. [2] Contributed by Martin Matejek. Modified: python/branches/py3k/Doc/library/queue.rst ============================================================================== --- python/branches/py3k/Doc/library/queue.rst (original) +++ python/branches/py3k/Doc/library/queue.rst Sun Feb 3 17:51:08 2008 @@ -71,7 +71,7 @@ Queue Objects ------------- -Queue objects (:class:``Queue``, :class:``LifoQueue``, or :class:``PriorityQueue`` +Queue objects (:class:`Queue`, :class:`LifoQueue`, or :class:`PriorityQueue`) provide the public methods described below. Modified: python/branches/py3k/Doc/library/socket.rst ============================================================================== --- python/branches/py3k/Doc/library/socket.rst (original) +++ python/branches/py3k/Doc/library/socket.rst Sun Feb 3 17:51:08 2008 @@ -23,7 +23,7 @@ socket-related system calls are also a valuable source of information on the details of socket semantics. For Unix, refer to the manual pages; for Windows, see the WinSock (or Winsock 2) specification. For IPv6-ready APIs, readers may -want to refer to :rfc:`2553` titled Basic Socket Interface Extensions for IPv6. +want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv6. .. index:: object: socket Modified: python/branches/py3k/Doc/library/urllib2.rst ============================================================================== --- python/branches/py3k/Doc/library/urllib2.rst (original) +++ python/branches/py3k/Doc/library/urllib2.rst Sun Feb 3 17:51:08 2008 @@ -33,10 +33,12 @@ This function returns a file-like object with two additional methods: - * :meth:`geturl` --- return the URL of the resource retrieved + * :meth:`geturl` --- return the URL of the resource retrieved, commonly used to + determine if a redirect was followed - * :meth:`info` --- return the meta-information of the page, as a dictionary-like - object + * :meth:`info` --- return the meta-information of the page, such as headers, in + the form of an ``httplib.HTTPMessage`` instance + (see `Quick Reference to HTTP Headers `_) Raises :exc:`URLError` on errors. @@ -81,18 +83,32 @@ The handlers raise this exception (or derived exceptions) when they run into a problem. It is a subclass of :exc:`IOError`. + .. attribute:: reason + + The reason for this error. It can be a message string or another exception + instance (:exc:`socket.error` for remote URLs, :exc:`OSError` for local + URLs). + .. exception:: HTTPError - A subclass of :exc:`URLError`, it can also function as a non-exceptional - file-like return value (the same thing that :func:`urlopen` returns). This - is useful when handling exotic HTTP errors, such as requests for - authentication. + Though being an exception (a subclass of :exc:`URLError`), an :exc:`HTTPError` + can also function as a non-exceptional file-like return value (the same thing + that :func:`urlopen` returns). This is useful when handling exotic HTTP + errors, such as requests for authentication. + + .. attribute:: code + + An HTTP status code as defined in `RFC 2616 `_. + This numeric value corresponds to a value found in the dictionary of + codes as found in :attr:`BaseHTTPServer.BaseHTTPRequestHandler.responses`. + + The following classes are provided: -.. class:: Request(url[, data][, headers] [, origin_req_host][, unverifiable]) +.. class:: Request(url[, data][, headers][, origin_req_host][, unverifiable]) This class is an abstraction of a URL request. @@ -107,7 +123,12 @@ returns a string in this format. *headers* should be a dictionary, and will be treated as if :meth:`add_header` - was called with each key and value as arguments. + was called with each key and value as arguments. This is often used to "spoof" + the ``User-Agent`` header, which is used by a browser to identify itself -- + some HTTP servers only allow requests coming from common browsers as opposed + to scripts. For example, Mozilla Firefox may identify itself as ``"Mozilla/5.0 + (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"``, while :mod:`urllib2`'s + default user agent string is ``"Python-urllib/2.6"`` (on Python 2.6). The final two arguments are only of interest for correct handling of third-party HTTP cookies: Modified: python/branches/py3k/Doc/reference/datamodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/datamodel.rst (original) +++ python/branches/py3k/Doc/reference/datamodel.rst Sun Feb 3 17:51:08 2008 @@ -991,7 +991,7 @@ a single built-in type, called ``instance``. New-style classes were introduced in Python 2.2 to unify classes and types. A -new-style class neither more nor less than a user-defined type. If *x* is an +new-style class is neither more nor less than a user-defined type. If *x* is an instance of a new-style class, then ``type(x)`` is the same as ``x.__class__``. The major motivation for introducing new-style classes is to provide a unified Modified: python/branches/py3k/Lib/distutils/__init__.py ============================================================================== --- python/branches/py3k/Lib/distutils/__init__.py (original) +++ python/branches/py3k/Lib/distutils/__init__.py Sun Feb 3 17:51:08 2008 @@ -18,4 +18,4 @@ # In general, major and minor version should loosely follow the Python # version number the distutils code was shipped with. # -__version__ = "2.5.1" +__version__ = "2.6.0" Modified: python/branches/py3k/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/build_ext.py (original) +++ python/branches/py3k/Lib/distutils/command/build_ext.py Sun Feb 3 17:51:08 2008 @@ -178,13 +178,13 @@ self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) if MSVC_VERSION == 9: self.library_dirs.append(os.path.join(sys.exec_prefix, - 'PCBuild9')) + 'PCbuild')) elif MSVC_VERSION == 8: self.library_dirs.append(os.path.join(sys.exec_prefix, - 'PCBuild8', 'win32release')) + 'PC', 'VS8.0', 'win32release')) else: self.library_dirs.append(os.path.join(sys.exec_prefix, - 'PCBuild')) + 'PC', 'VS7.1')) # OS/2 (EMX) doesn't support Debug vs Release builds, but has the # import libraries in its "Config" subdirectory Modified: python/branches/py3k/Lib/rational.py ============================================================================== --- python/branches/py3k/Lib/rational.py (original) +++ python/branches/py3k/Lib/rational.py Sun Feb 3 17:51:08 2008 @@ -24,9 +24,18 @@ return a -_RATIONAL_FORMAT = re.compile( - r'^\s*(?P[-+]?)(?P\d+)' - r'(?:/(?P\d+)|\.(?P\d+))?\s*$') +_RATIONAL_FORMAT = re.compile(r""" + \A\s* # optional whitespace at the start, then + (?P[-+]?) # an optional sign, then + (?=\d|\.\d) # lookahead for digit or .digit + (?P\d*) # numerator (possibly empty) + (?: # followed by an optional + /(?P\d+) # / and denominator + | # or + \.(?P\d*) # decimal point and fractional part + )? + \s*\Z # and optional whitespace to finish +""", re.VERBOSE) class Rational(RationalAbc): Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Sun Feb 3 17:51:08 2008 @@ -593,6 +593,20 @@ self.assertEqual(format(0, C('10')), ' 0') def test_floatasratio(self): + for f, ratio in [ + (0.875, (7, 8)), + (-0.875, (-7, 8)), + (0.0, (0, 1)), + (11.5, (23, 2)), + ]: + self.assertEqual(f.as_integer_ratio(), ratio) + + for i in range(10000): + f = random.random() + f *= 10 ** random.randint(-100, 100) + n, d = f.as_integer_ratio() + self.assertEqual(float(n).__truediv__(d), f) + R = rational.Rational self.assertEqual(R(0, 1), R(*float(0.0).as_integer_ratio())) Modified: python/branches/py3k/Lib/test/test_rational.py ============================================================================== --- python/branches/py3k/Lib/test/test_rational.py (original) +++ python/branches/py3k/Lib/test/test_rational.py Sun Feb 3 17:51:08 2008 @@ -77,6 +77,8 @@ self.assertEquals((3, 2), _components(R(" 03/02 \n "))) self.assertEquals((16, 5), _components(R(" 3.2 "))) self.assertEquals((-16, 5), _components(R(" -3.2 "))) + self.assertEquals((-3, 1), _components(R(" -3. "))) + self.assertEquals((3, 5), _components(R(" .6 "))) self.assertRaisesMessage( ZeroDivisionError, "Rational(3, 0)", @@ -111,6 +113,10 @@ # Don't accept combinations of decimals and rationals. ValueError, "Invalid literal for Rational: 3.2/7", R, "3.2/7") + self.assertRaisesMessage( + # Allow 3. and .3, but not . + ValueError, "Invalid literal for Rational: .", + R, ".") def testImmutable(self): r = R(7, 3) Modified: python/branches/py3k/Lib/test/test_socketserver.py ============================================================================== --- python/branches/py3k/Lib/test/test_socketserver.py (original) +++ python/branches/py3k/Lib/test/test_socketserver.py Sun Feb 3 17:51:08 2008 @@ -1,20 +1,32 @@ -# Test suite for SocketServer.py +""" +Test suite for SocketServer.py. +""" -from test import test_support -from test.test_support import (verbose, verify, TESTFN, TestSkipped, - reap_children) -test_support.requires('network') - -from SocketServer import * +import os import socket import errno +import imp import select import time import threading -import os +from functools import wraps +import unittest +import SocketServer + +import test.test_support +from test.test_support import reap_children, verbose, TestSkipped +from test.test_support import TESTFN as TEST_FILE + +test.test_support.requires("network") NREQ = 3 DELAY = 0.5 +TEST_STR = b"hello world\n" +HOST = "localhost" + +HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") +HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" + class MyMixinHandler: def handle(self): @@ -23,23 +35,41 @@ time.sleep(DELAY) self.wfile.write(line) -class MyStreamHandler(MyMixinHandler, StreamRequestHandler): + +def receive(sock, n, timeout=20): + r, w, x = select.select([sock], [], [], timeout) + if sock in r: + return sock.recv(n) + else: + raise RuntimeError("timed out on %r" % (sock,)) + + +class MyStreamHandler(MyMixinHandler, SocketServer.StreamRequestHandler): + pass + +class MyDatagramHandler(MyMixinHandler, + SocketServer.DatagramRequestHandler): pass -class MyDatagramHandler(MyMixinHandler, DatagramRequestHandler): +class ForkingUnixStreamServer(SocketServer.ForkingMixIn, + SocketServer.UnixStreamServer): pass +class ForkingUnixDatagramServer(SocketServer.ForkingMixIn, + SocketServer.UnixDatagramServer): + pass + + class MyMixinServer: def serve_a_few(self): for i in range(NREQ): self.handle_request() + def handle_error(self, request, client_address): self.close_request(request) self.server_close() raise -teststring = b"hello world\n" - def receive(sock, n, timeout=20): r, w, x = select.select([sock], [], [], timeout) if sock in r: @@ -75,6 +105,7 @@ self.__svrcls = svrcls self.__hdlrcls = hdlrcls self.ready = threading.Event() + def run(self): class svrcls(MyMixinServer, self.__svrcls): pass @@ -93,64 +124,8 @@ svr.serve_a_few() if verbose: print("thread: done") -seed = 0 -def pickport(): - global seed - seed += 1 - return 10000 + (os.getpid() % 1000)*10 + seed - -host = "localhost" -testfiles = [] -def pickaddr(proto): - if proto == socket.AF_INET: - return (host, pickport()) - else: - fn = TESTFN + str(pickport()) - if os.name == 'os2': - # AF_UNIX socket names on OS/2 require a specific prefix - # which can't include a drive letter and must also use - # backslashes as directory separators - if fn[1] == ':': - fn = fn[2:] - if fn[0] in (os.sep, os.altsep): - fn = fn[1:] - fn = os.path.join('\socket', fn) - if os.sep == '/': - fn = fn.replace(os.sep, os.altsep) - else: - fn = fn.replace(os.altsep, os.sep) - testfiles.append(fn) - return fn - -def cleanup(): - for fn in testfiles: - try: - os.remove(fn) - except os.error: - pass - testfiles[:] = [] - -def testloop(proto, servers, hdlrcls, testfunc): - for svrcls in servers: - addr = pickaddr(proto) - if verbose: - print("ADDR =", addr) - print("CLASS =", svrcls) - t = ServerThread(addr, svrcls, hdlrcls) - if verbose: print("server created") - t.start() - if verbose: print("server running") - for i in range(NREQ): - t.ready.wait(10*DELAY) - if not t.ready.isSet(): - raise RuntimeError("Server not ready within a reasonable time") - if verbose: print("test client", i) - testfunc(proto, addr) - if verbose: print("waiting for server") - t.join() - if verbose: print("done") -class ForgivingTCPServer(TCPServer): +class ForgivingTCPServer(SocketServer.TCPServer): # prevent errors if another process is using the port we want def server_bind(self): host, default_port = self.server_address @@ -160,7 +135,7 @@ for port in [default_port, 3434, 8798, 23833]: try: self.server_address = host, port - TCPServer.server_bind(self) + SocketServer.TCPServer.server_bind(self) break except socket.error as e: (err, msg) = e @@ -168,56 +143,139 @@ raise print(' WARNING: failed to listen on port %d, trying another' % port, file=sys.__stderr__) -tcpservers = [ForgivingTCPServer, ThreadingTCPServer] -if hasattr(os, 'fork') and os.name not in ('os2',): - tcpservers.append(ForkingTCPServer) -udpservers = [UDPServer, ThreadingUDPServer] -if hasattr(os, 'fork') and os.name not in ('os2',): - udpservers.append(ForkingUDPServer) - -if not hasattr(socket, 'AF_UNIX'): - streamservers = [] - dgramservers = [] -else: - class ForkingUnixStreamServer(ForkingMixIn, UnixStreamServer): pass - streamservers = [UnixStreamServer, ThreadingUnixStreamServer] - if hasattr(os, 'fork') and os.name not in ('os2',): - streamservers.append(ForkingUnixStreamServer) - class ForkingUnixDatagramServer(ForkingMixIn, UnixDatagramServer): pass - dgramservers = [UnixDatagramServer, ThreadingUnixDatagramServer] - if hasattr(os, 'fork') and os.name not in ('os2',): - dgramservers.append(ForkingUnixDatagramServer) - -def sloppy_cleanup(): - # See http://python.org/sf/1540386 - # We need to reap children here otherwise a child from one server - # can be left running for the next server and cause a test failure. - time.sleep(DELAY) - reap_children() - -def testall(): - testloop(socket.AF_INET, tcpservers, MyStreamHandler, teststream) - sloppy_cleanup() - testloop(socket.AF_INET, udpservers, MyDatagramHandler, testdgram) - if hasattr(socket, 'AF_UNIX'): - sloppy_cleanup() - testloop(socket.AF_UNIX, streamservers, MyStreamHandler, teststream) - # Alas, on Linux (at least) recvfrom() doesn't return a meaningful - # client address so this cannot work: - ##testloop(socket.AF_UNIX, dgramservers, MyDatagramHandler, testdgram) +class SocketServerTest(unittest.TestCase): + """Test all socket servers.""" + + def setUp(self): + self.port_seed = 0 + self.test_files = [] + + def tearDown(self): + time.sleep(DELAY) + reap_children() + + for fn in self.test_files: + try: + os.remove(fn) + except os.error: + pass + self.test_files[:] = [] + + def pickport(self): + self.port_seed += 1 + return 10000 + (os.getpid() % 1000)*10 + self.port_seed + + def pickaddr(self, proto): + if proto == socket.AF_INET: + return (HOST, self.pickport()) + else: + fn = TEST_FILE + str(self.pickport()) + if os.name == 'os2': + # AF_UNIX socket names on OS/2 require a specific prefix + # which can't include a drive letter and must also use + # backslashes as directory separators + if fn[1] == ':': + fn = fn[2:] + if fn[0] in (os.sep, os.altsep): + fn = fn[1:] + fn = os.path.join('\socket', fn) + if os.sep == '/': + fn = fn.replace(os.sep, os.altsep) + else: + fn = fn.replace(os.altsep, os.sep) + self.test_files.append(fn) + return fn + + def run_servers(self, proto, servers, hdlrcls, testfunc): + for svrcls in servers: + addr = self.pickaddr(proto) + if verbose: + print "ADDR =", addr + print "CLASS =", svrcls + t = ServerThread(addr, svrcls, hdlrcls) + if verbose: print "server created" + t.start() + if verbose: print "server running" + for i in range(NREQ): + t.ready.wait(10*DELAY) + self.assert_(t.ready.isSet(), + "Server not ready within a reasonable time") + if verbose: print "test client", i + testfunc(proto, addr) + if verbose: print "waiting for server" + t.join() + if verbose: print "done" + + def stream_examine(self, proto, addr): + s = socket.socket(proto, socket.SOCK_STREAM) + s.connect(addr) + s.sendall(TEST_STR) + buf = data = receive(s, 100) + while data and '\n' not in buf: + data = receive(s, 100) + buf += data + self.assertEquals(buf, TEST_STR) + s.close() + + def dgram_examine(self, proto, addr): + s = socket.socket(proto, socket.SOCK_DGRAM) + s.sendto(TEST_STR, addr) + buf = data = receive(s, 100) + while data and '\n' not in buf: + data = receive(s, 100) + buf += data + self.assertEquals(buf, TEST_STR) + s.close() + + def test_TCPServers(self): + # Test SocketServer.TCPServer + servers = [ForgivingTCPServer, SocketServer.ThreadingTCPServer] + if HAVE_FORKING: + servers.append(SocketServer.ForkingTCPServer) + self.run_servers(socket.AF_INET, servers, + MyStreamHandler, self.stream_examine) + + def test_UDPServers(self): + # Test SocketServer.UDPServer + servers = [SocketServer.UDPServer, + SocketServer.ThreadingUDPServer] + if HAVE_FORKING: + servers.append(SocketServer.ForkingUDPServer) + self.run_servers(socket.AF_INET, servers, MyDatagramHandler, + self.dgram_examine) + + def test_stream_servers(self): + # Test SocketServer's stream servers + if not HAVE_UNIX_SOCKETS: + return + servers = [SocketServer.UnixStreamServer, + SocketServer.ThreadingUnixStreamServer] + if HAVE_FORKING: + servers.append(ForkingUnixStreamServer) + self.run_servers(socket.AF_UNIX, servers, MyStreamHandler, + self.stream_examine) + + # Alas, on Linux (at least) recvfrom() doesn't return a meaningful + # client address so this cannot work: + + # def test_dgram_servers(self): + # # Test SocketServer.UnixDatagramServer + # if not HAVE_UNIX_SOCKETS: + # return + # servers = [SocketServer.UnixDatagramServer, + # SocketServer.ThreadingUnixDatagramServer] + # if HAVE_FORKING: + # servers.append(ForkingUnixDatagramServer) + # self.run_servers(socket.AF_UNIX, servers, MyDatagramHandler, + # self.dgram_examine) + def test_main(): - import imp if imp.lock_held(): - # If the import lock is held, the threads will hang. + # If the import lock is held, the threads will hang raise TestSkipped("can't run when import lock is held") - reap_children() - try: - testall() - finally: - cleanup() - reap_children() + test.test_support.run_unittest(SocketServerTest) if __name__ == "__main__": test_main() Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Sun Feb 3 17:51:08 2008 @@ -512,6 +512,7 @@ Mark Perrego Trevor Perrin Tim Peters +Benjamin Peterson Chris Petrilli Bjorn Pettersen Geoff Philbrick Modified: python/branches/py3k/Misc/build.sh ============================================================================== --- python/branches/py3k/Misc/build.sh (original) +++ python/branches/py3k/Misc/build.sh Sun Feb 3 17:51:08 2008 @@ -67,7 +67,7 @@ # Note: test_XXX (none currently) really leak, but are disabled # so we don't send spam. Any test which really leaks should only # be listed here if there are also test cases under Lib/test/leakers. -LEAKY_TESTS="test_(cmd_line|popen2|socket|threading_local|urllib2_localnet)" +LEAKY_TESTS="test_(cmd_line|popen2|socket|sys|threadsignals|urllib2_localnet)" # These tests always fail, so skip them so we don't get false positives. _ALWAYS_SKIP="" @@ -99,7 +99,17 @@ if [ "$FAILURE_CC" != "" ]; then dest="$dest -c $FAILURE_CC" fi - mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest < $2 + if [ "x$3" != "x" ] ; then + (echo "More important issues:" + echo "----------------------" + egrep -v "$3" < $2 + echo "" + echo "Less important issues:" + echo "----------------------" + egrep "$3" < $2) + else + cat $2 + fi | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest fi } @@ -194,9 +204,10 @@ ## ensure that the reflog exists so the grep doesn't fail touch $REFLOG $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F - NUM_FAILURES=`egrep -vc "($LEAKY_TESTS|sum=0)" $REFLOG` + LEAK_PAT="($LEAKY_TESTS|sum=0)" + NUM_FAILURES=`egrep -vc "$LEAK_PAT" $REFLOG` update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start - mail_on_failure "refleak" $REFLOG + mail_on_failure "refleak" $REFLOG "$LEAK_PAT" ## now try to run all the tests F=make-testall.out Modified: python/branches/py3k/Modules/_bsddb.c ============================================================================== --- python/branches/py3k/Modules/_bsddb.c (original) +++ python/branches/py3k/Modules/_bsddb.c Sun Feb 3 17:51:08 2008 @@ -904,7 +904,6 @@ } if (self->dbc != NULL) { - MYDB_BEGIN_ALLOW_THREADS; /* If the underlying database has been closed, we don't need to do anything. If the environment has been closed we need to leak, as BerkeleyDB will crash trying to access @@ -913,9 +912,14 @@ a database open. */ if (self->mydb->db && self->mydb->myenvobj && !self->mydb->myenvobj->closed) + /* test for: open db + no environment or non-closed environment */ + if (self->mydb->db && (!self->mydb->myenvobj || (self->mydb->myenvobj && + !self->mydb->myenvobj->closed))) { + MYDB_BEGIN_ALLOW_THREADS; err = self->dbc->c_close(self->dbc); + MYDB_END_ALLOW_THREADS; + } self->dbc = NULL; - MYDB_END_ALLOW_THREADS; } Py_XDECREF( self->mydb ); PyObject_Del(self); Modified: python/branches/py3k/Modules/mathmodule.c ============================================================================== --- python/branches/py3k/Modules/mathmodule.c (original) +++ python/branches/py3k/Modules/mathmodule.c Sun Feb 3 17:51:08 2008 @@ -235,8 +235,7 @@ PyDoc_STRVAR(math_trunc_doc, "trunc(x:Real) -> Integral\n" "\n" -"Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic" -"method."); +"Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method."); static PyObject * math_frexp(PyObject *self, PyObject *arg) Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Sun Feb 3 17:51:08 2008 @@ -3579,9 +3579,9 @@ Py_BEGIN_ALLOW_THREADS #if defined(PYCC_GCC) - spawnval = spawnve(mode, path, argvlist, envlist); + spawnval = spawnvpe(mode, path, argvlist, envlist); #else - spawnval = _spawnve(mode, path, argvlist, envlist); + spawnval = _spawnvpe(mode, path, argvlist, envlist); #endif Py_END_ALLOW_THREADS @@ -3964,7 +3964,8 @@ static PyObject * posix_kill(PyObject *self, PyObject *args) { - int pid, sig; + pid_t pid; + int sig; if (!PyArg_ParseTuple(args, "ii:kill", &pid, &sig)) return NULL; #if defined(PYOS_OS2) && !defined(PYCC_GCC) @@ -4209,7 +4210,7 @@ #if defined(HAVE_WAIT3) || defined(HAVE_WAIT4) static PyObject * -wait_helper(int pid, int status, struct rusage *ru) +wait_helper(pid_t pid, int status, struct rusage *ru) { PyObject *result; static PyObject *struct_rusage; @@ -4275,7 +4276,8 @@ static PyObject * posix_wait3(PyObject *self, PyObject *args) { - int pid, options; + pid_t pid; + int options; struct rusage ru; WAIT_TYPE status; WAIT_STATUS_INT(status) = 0; @@ -4299,7 +4301,8 @@ static PyObject * posix_wait4(PyObject *self, PyObject *args) { - int pid, options; + pid_t pid; + int options; struct rusage ru; WAIT_TYPE status; WAIT_STATUS_INT(status) = 0; @@ -4323,7 +4326,8 @@ static PyObject * posix_waitpid(PyObject *self, PyObject *args) { - int pid, options; + pid_t pid; + int options; WAIT_TYPE status; WAIT_STATUS_INT(status) = 0; @@ -4372,7 +4376,7 @@ static PyObject * posix_wait(PyObject *self, PyObject *noargs) { - int pid; + pid_t pid; WAIT_TYPE status; WAIT_STATUS_INT(status) = 0; @@ -4567,7 +4571,8 @@ static PyObject * posix_getsid(PyObject *self, PyObject *args) { - int pid, sid; + pid_t pid; + int sid; if (!PyArg_ParseTuple(args, "i:getsid", &pid)) return NULL; sid = getsid(pid); @@ -4601,7 +4606,8 @@ static PyObject * posix_setpgid(PyObject *self, PyObject *args) { - int pid, pgrp; + pid_t pid; + int pgrp; if (!PyArg_ParseTuple(args, "ii:setpgid", &pid, &pgrp)) return NULL; if (setpgid(pid, pgrp) < 0) Modified: python/branches/py3k/Objects/floatobject.c ============================================================================== --- python/branches/py3k/Objects/floatobject.c (original) +++ python/branches/py3k/Objects/floatobject.c Sun Feb 3 17:51:08 2008 @@ -1066,20 +1066,19 @@ } static PyObject * -float_as_integer_ratio(PyObject *v) +float_as_integer_ratio(PyObject *v, PyObject *unused) { double self; double float_part; int exponent; - int is_negative; - const int chunk_size = 28; + int i; + PyObject *prev; - PyObject *py_chunk = NULL; PyObject *py_exponent = NULL; PyObject *numerator = NULL; PyObject *denominator = NULL; PyObject *result_pair = NULL; - PyNumberMethods *long_methods; + PyNumberMethods *long_methods = PyLong_Type.tp_as_number; #define INPLACE_UPDATE(obj, call) \ prev = obj; \ @@ -1101,93 +1100,31 @@ } #endif - if (self == 0) { - numerator = PyLong_FromLong(0); - if (numerator == NULL) goto error; - denominator = PyLong_FromLong(1); - if (denominator == NULL) goto error; - result_pair = PyTuple_Pack(2, numerator, denominator); - /* Hand ownership over to the tuple. If the tuple - wasn't created successfully, we want to delete the - ints anyway. */ - Py_DECREF(numerator); - Py_DECREF(denominator); - return result_pair; - } - - /* XXX: Could perhaps handle FLT_RADIX!=2 by using ilogb and - scalbn, but those may not be in C89. */ PyFPE_START_PROTECT("as_integer_ratio", goto error); - float_part = frexp(self, &exponent); - is_negative = 0; - if (float_part < 0) { - float_part = -float_part; - is_negative = 1; - /* 0.5 <= float_part < 1.0 */ - } + float_part = frexp(self, &exponent); /* self == float_part * 2**exponent exactly */ PyFPE_END_PROTECT(float_part); - /* abs(self) == float_part * 2**exponent exactly */ + + for (i=0; i<300 && float_part != floor(float_part) ; i++) { + float_part *= 2.0; + exponent--; + } + /* self == float_part * 2**exponent exactly and float_part is integral. + If FLT_RADIX != 2, the 300 steps may leave a tiny fractional part + to be truncated by PyLong_FromDouble(). */ - /* Suck up chunk_size bits at a time; 28 is enough so that we - suck up all bits in 2 iterations for all known binary - double-precision formats, and small enough to fit in a - long. */ - numerator = PyLong_FromLong(0); + numerator = PyLong_FromDouble(float_part); if (numerator == NULL) goto error; - long_methods = PyLong_Type.tp_as_number; - - py_chunk = PyLong_FromLong(chunk_size); - if (py_chunk == NULL) goto error; - - while (float_part != 0) { - /* invariant: abs(self) == - (numerator + float_part) * 2**exponent exactly */ - long digit; - PyObject *py_digit; - - PyFPE_START_PROTECT("as_integer_ratio", goto error); - /* Pull chunk_size bits out of float_part, into digits. */ - float_part = ldexp(float_part, chunk_size); - digit = (long)float_part; - float_part -= digit; - /* 0 <= float_part < 1 */ - exponent -= chunk_size; - PyFPE_END_PROTECT(float_part); - - /* Shift digits into numerator. */ - // numerator <<= chunk_size - INPLACE_UPDATE(numerator, - long_methods->nb_lshift(numerator, py_chunk)); - if (numerator == NULL) goto error; - - // numerator |= digit - py_digit = PyLong_FromLong(digit); - if (py_digit == NULL) goto error; - INPLACE_UPDATE(numerator, - long_methods->nb_or(numerator, py_digit)); - Py_DECREF(py_digit); - if (numerator == NULL) goto error; - } - - /* Add in the sign bit. */ - if (is_negative) { - INPLACE_UPDATE(numerator, - long_methods->nb_negative(numerator)); - if (numerator == NULL) goto error; - } - - /* now self = numerator * 2**exponent exactly; fold in 2**exponent */ + /* fold in 2**exponent */ denominator = PyLong_FromLong(1); - py_exponent = PyLong_FromLong(labs(exponent)); + py_exponent = PyLong_FromLong(labs((long)exponent)); if (py_exponent == NULL) goto error; INPLACE_UPDATE(py_exponent, long_methods->nb_lshift(denominator, py_exponent)); if (py_exponent == NULL) goto error; if (exponent > 0) { INPLACE_UPDATE(numerator, - long_methods->nb_multiply(numerator, - py_exponent)); + long_methods->nb_multiply(numerator, py_exponent)); if (numerator == NULL) goto error; } else { @@ -1196,12 +1133,17 @@ py_exponent = NULL; } + /* Returns ints instead of longs where possible */ + INPLACE_UPDATE(numerator, PyNumber_Int(numerator)); + if (numerator == NULL) goto error; + INPLACE_UPDATE(denominator, PyNumber_Int(denominator)); + if (denominator == NULL) goto error; + result_pair = PyTuple_Pack(2, numerator, denominator); #undef INPLACE_UPDATE error: Py_XDECREF(py_exponent); - Py_XDECREF(py_chunk); Py_XDECREF(denominator); Py_XDECREF(numerator); return result_pair; @@ -1210,17 +1152,16 @@ PyDoc_STRVAR(float_as_integer_ratio_doc, "float.as_integer_ratio() -> (int, int)\n" "\n" -"Returns a pair of integers, not necessarily in lowest terms, whose\n" -"ratio is exactly equal to the original float. This method raises an\n" -"OverflowError on infinities and a ValueError on nans. The resulting\n" -"denominator will be positive.\n" +"Returns a pair of integers, whose ratio is exactly equal to the original\n" +"float and with a positive denominator.\n" +"Raises OverflowError on infinities and a ValueError on nans.\n" "\n" ">>> (10.0).as_integer_ratio()\n" -"(167772160L, 16777216L)\n" +"(10, 1)\n" ">>> (0.0).as_integer_ratio()\n" "(0, 1)\n" ">>> (-.25).as_integer_ratio()\n" -"(-134217728L, 536870912L)"); +"(-1, 4)"); static PyObject * Modified: python/branches/py3k/PC/os2emx/Makefile ============================================================================== --- python/branches/py3k/PC/os2emx/Makefile (original) +++ python/branches/py3k/PC/os2emx/Makefile Sun Feb 3 17:51:08 2008 @@ -1,16 +1,16 @@ #####################==================---------------- # -# Top-Level Makefile for Building Python 2.4 for OS/2 using GCC/EMX +# Top-Level Makefile for Building Python 2.6 for OS/2 using GCC/EMX # Originally written by Andrew Zabolotny, for Python 1.5.2 -# Modified by Andrew MacIntyre, for Python 2.5 +# Modified by Andrew MacIntyre, for Python 2.6 # # This makefile was developed for use with [P]GCC/EMX compiler any # version and GNU Make. # -# The output of the build is a largish Python25.DLL containing the +# The output of the build is a largish Python26.DLL containing the # essential modules of Python and a small Python.exe program to start # the interpreter. When embedding Python within another program, only -# Python25.DLL is needed. We also build python_s.a static library (which +# Python26.DLL is needed. We also build python_s.a static library (which # can be converted into OMF (.lib) format using emxomf tool) and both # python.a and python.lib import libraries. Then the optional # extension modules, which are OS/2 DLLs renamed with a PYD file extension. @@ -64,7 +64,7 @@ # === install locations === # default value of PYTHONHOME -LIB_DIR=C:/Python25 +LIB_DIR=C:/Python26 # default is to have everything in or under PYTHONHOME EXE_DIR=$(LIB_DIR) DLL_DIR=$(EXE_DIR) @@ -236,8 +236,8 @@ @echo STACKSIZE 2097152 >>$@ # Output file names -PYTHON_VER= 2.5 -PYTHON_LIB= python25 +PYTHON_VER= 2.6 +PYTHON_LIB= python26 PYTHON.LIB= $(PYTHON_LIB)_s$A PYTHON.IMPLIB= $(PYTHON_LIB)$A ifeq ($(EXEOMF),yes) Modified: python/branches/py3k/PC/os2emx/README.os2emx ============================================================================== --- python/branches/py3k/PC/os2emx/README.os2emx (original) +++ python/branches/py3k/PC/os2emx/README.os2emx Sun Feb 3 17:51:08 2008 @@ -1,4 +1,4 @@ -This is a port of Python 2.5 to OS/2 using the EMX development tools +This is a port of Python 2.6 to OS/2 using the EMX development tools ========================================================================= What's new since the previous release @@ -10,11 +10,11 @@ Licenses and info about Python and EMX -------------------------------------- -Please read the file README.Python-2.5 included in this package for -information about Python 2.5. This file is the README file from the -Python 2.5 source distribution available via http://www.python.org/ -and its mirrors. The file LICENCE.Python-2.5 is the text of the Licence -from the Python 2.5 source distribution. +Please read the file README.Python-2.6 included in this package for +information about Python 2.6. This file is the README file from the +Python 2.6 source distribution available via http://www.python.org/ +and its mirrors. The file LICENCE.Python-2.6 is the text of the Licence +from the Python 2.6 source distribution. Note that the EMX package that this package depends on is released under the GNU General Public Licence. Please refer to the documentation @@ -46,7 +46,7 @@ The best known would be that by Jeff Rush, most recently of version 1.5.2. Jeff used IBM's Visual Age C++ (v3) for his ports, and his -patches have been included in the Python 2.5 source distribution. +patches have been included in the Python 2.6 source distribution. Andy Zabolotny implemented a port of Python v1.5.2 using the EMX development tools. His patches against the Python v1.5.2 source @@ -92,7 +92,7 @@ to compile & link the executable. This is so that fork() works (see "YOU HAVE BEEN WARNED" item 1). -Python25.dll is created as a normal OMF DLL, with an OMF import +Python26.dll is created as a normal OMF DLL, with an OMF import library and module definition file. There is also an a.out (.a) import library to support linking the DLL to a.out executables. The DLL requires the EMX runtime DLLs. @@ -148,7 +148,7 @@ Upstream source patches: -No updates to the Python 2.5 release have become available. +No updates to the Python 2.6 release have become available. Eberhard Mattes' EMXFIX04 update to his EMX 0.9d tools suite includes bug fixes for the BSD DB library. The bsddb module included in this @@ -157,7 +157,7 @@ Library and other distributed Python code: The Python standard library lives in the Lib directory. All the standard -library code included with the Python 2.5 source distribution is included +library code included with the Python 2.6 source distribution is included in the binary archive, with the exception of the dos-8x3 and tkinter subdirectories which have been omitted to reduce the size of the binary archive - the dos-8x3 components are unnecessary duplicates and Tkinter @@ -172,7 +172,7 @@ also been omitted. All subdirectories omitted from the binary archive can be reconstituted -from the Python 2.5 source distribution, if desired. +from the Python 2.6 source distribution, if desired. Support for building Python extensions: @@ -190,15 +190,15 @@ --------- This port is packaged as follows: -- python-2.5-os2emx-bin-03????.zip (binaries, library modules) -- python-2.5-os2emx-src-03???? (patches+makefiles for non-Python code) +- python-2.6-os2emx-bin-03????.zip (binaries, library modules) +- python-2.6-os2emx-src-03???? (patches+makefiles for non-Python code) As all the Python specific patches for the port are now part of the Python release tarball, only the patches and makefiles involved in building external libraries for optional extensions are included in the source archive. -Documentation for the Python language, as well as the Python 2.5 +Documentation for the Python language, as well as the Python 2.6 source distibution, can be obtained from the Python website (http://www.python.org/) or the Python project pages at Sourceforge (http://sf.net/projects/python/). @@ -213,7 +213,7 @@ Unpack this archive, preserving the subdirectories, in the root directory of the drive where you want Python to live. -Add the Python directory (eg C:\Python25) to the PATH and LIBPATH +Add the Python directory (eg C:\Python26) to the PATH and LIBPATH variables in CONFIG.SYS. You should then set the PYTHONHOME and PYTHONPATH environment variables @@ -223,9 +223,9 @@ should be set to the semicolon separated list of principal Python library directories. I use: - SET PYTHONHOME=F:/Python25 - SET PYTHONPATH=F:/Python25/Lib;F:/Python25/Lib/plat-os2emx; - F:/Python25/Lib/lib-dynload;F:/Python25/Lib/site-packages + SET PYTHONHOME=F:/Python26 + SET PYTHONPATH=F:/Python26/Lib;F:/Python26/Lib/plat-os2emx; + F:/Python26/Lib/lib-dynload;F:/Python26/Lib/site-packages NOTE!: the PYTHONPATH setting above is linewrapped for this document - it should all be on one line in CONFIG.SYS! @@ -238,7 +238,7 @@ distribution. This can be used by setting the TERMINFO environment variable to the path of the Terminfo subdirectory below the Python home directory. On my system this looks like: - SET TERMINFO=F:/Python25/Terminfo + SET TERMINFO=F:/Python26/Terminfo For the TERM environment variable, I would try one of the following: SET TERM=ansi @@ -252,8 +252,8 @@ you can change into the Python home directory and run the COMPILEALL.CMD batch file. -You can execute the regression tests included with the Python 2.5 source -distribution by changing to the Python 2.5 home directory and executing the +You can execute the regression tests included with the Python 2.6 source +distribution by changing to the Python 2.6 home directory and executing the REGRTEST.CMD batch file. The following tests are known to fail at this time: - test_mhlib (I don't know of any port of MH to OS/2); @@ -299,7 +299,7 @@ 1. decide if you need to change the location of the Python installation. If you wish to do this, set the value of the Makefile variable LIB_DIR to the directory you wish to use for PYTHONHOME - (eg /usr/local/lib/python2.5). + (eg /usr/local/lib/python2.6). If you want Python to find its library without the PYTHONHOME environment variable set, set the value of the Makefile variable @@ -309,7 +309,7 @@ to be installed in a directory other than the PYTHONHOME directory, set the value of the Makefile variable EXE_DIR to the appropriate directory. -3. If you wish the Python core DLL (python25.dll) to be installed in a +3. If you wish the Python core DLL (python26.dll) to be installed in a directory other than the directory in which the Python executables are installed (by default, the PYTHONHOME directory), set the value of the Makefile variable DLL_DIR to the appropriate directory. This DLL must @@ -698,4 +698,4 @@ E-mail: andymac at bullseye.apana.org.au, or andymac at pcug.org.au Web: http://www.andymac.org/ -23 July, 2006. +28 January, 2008. Deleted: /python/branches/py3k/PC/os2emx/python25.def ============================================================================== --- /python/branches/py3k/PC/os2emx/python25.def Sun Feb 3 17:51:08 2008 +++ (empty file) @@ -1,1263 +0,0 @@ -LIBRARY python25 INITINSTANCE TERMINSTANCE -DESCRIPTION "Python 2.5 Core DLL" -PROTMODE -DATA MULTIPLE NONSHARED -EXPORTS - -; From python25_s.lib(config) - "_PyImport_Inittab" - -; From python25_s.lib(dlfcn) -; "dlopen" -; "dlsym" -; "dlclose" -; "dlerror" - -; From python25_s.lib(getpathp) - "Py_GetProgramFullPath" - "Py_GetPrefix" - "Py_GetExecPrefix" - "Py_GetPath" - -; From python25_s.lib(getbuildinfo) - "Py_GetBuildInfo" - "_Py_svnversion" - -; From python25_s.lib(main) - "Py_Main" - "Py_GetArgcArgv" - -; From python25_s.lib(acceler) - "PyGrammar_AddAccelerators" - "PyGrammar_RemoveAccelerators" - -; From python25_s.lib(grammar1) - "PyGrammar_FindDFA" - "PyGrammar_LabelRepr" - -; From python25_s.lib(listnode) - "PyNode_ListTree" - -; From python25_s.lib(node) - "PyNode_New" - "PyNode_AddChild" - "PyNode_Free" - -; From python25_s.lib(parser) - "PyParser_AddToken" - "PyParser_New" - "PyParser_Delete" - -; From python25_s.lib(parsetok) - "Py_TabcheckFlag" - "PyParser_ParseString" - "PyParser_ParseStringFlagsFilename" - "PyParser_ParseFile" - "PyParser_ParseFileFlags" - "PyParser_ParseStringFlags" - -; From python25_s.lib(bitset) - "_Py_newbitset" - "_Py_delbitset" - "_Py_addbit" - "_Py_samebitset" - "_Py_mergebitset" - -; From python25_s.lib(metagrammar) - "_Py_meta_grammar" - "Py_meta_grammar" - -; From python25_s.lib(tokenizer) - "PyToken_OneChar" - "PyToken_TwoChars" - "PyToken_ThreeChars" - "PyTokenizer_FromString" - "PyTokenizer_Free" - "PyTokenizer_FromFile" - "PyTokenizer_Get" - "_PyParser_TokenNames" - -; From python25_s.lib(myreadline) - "_PyOS_ReadlineTState" - "PyOS_ReadlineFunctionPointer" - "PyOS_StdioReadline" - "PyOS_Readline" - "PyOS_InputHook" - -; From python25_s.lib(abstract) - "_PyObject_LengthHint" - "PyMapping_Size" - "PyObject_CallMethod" - "PyObject_GetItem" - "PySequence_GetItem" - "PyObject_SetItem" - "PySequence_SetItem" - "PyObject_DelItem" - "PySequence_DelItem" - "PyNumber_Multiply" - "PyNumber_InPlaceAdd" - "PyNumber_InPlaceMultiply" - "PyNumber_Int" - "PyNumber_Long" - "PyNumber_Float" - "PySequence_Concat" - "PySequence_Repeat" - "PySequence_InPlaceConcat" - "PySequence_InPlaceRepeat" - "PySequence_GetSlice" - "PySequence_SetSlice" - "PySequence_Tuple" - "PyObject_GetIter" - "PyIter_Next" - "PySequence_Fast" - "_PySequence_IterSearch" - "PyObject_CallFunction" - "_PyObject_CallFunction_SizeT" - "_PyObject_CallMethod_SizeT" - "PyObject_CallMethodObjArgs" - "PyObject_CallFunctionObjArgs" - "PyObject_Cmp" - "PyObject_Call" - "PyObject_CallObject" - "PyObject_Type" - "PyObject_Size" - "PyObject_Length" - "PyObject_DelItemString" - "PyObject_AsCharBuffer" - "PyObject_CheckReadBuffer" - "PyObject_AsReadBuffer" - "PyObject_AsWriteBuffer" - "PyNumber_Check" - "PyNumber_Add" - "PyNumber_Subtract" - "PyNumber_Divide" - "PyNumber_FloorDivide" - "PyNumber_TrueDivide" - "PyNumber_Remainder" - "PyNumber_Divmod" - "PyNumber_Power" - "PyNumber_Negative" - "PyNumber_Positive" - "PyNumber_Absolute" - "PyNumber_Invert" - "PyNumber_Lshift" - "PyNumber_Rshift" - "PyNumber_And" - "PyNumber_Xor" - "PyNumber_Or" - "PyNumber_Index" - "PyNumber_InPlaceSubtract" - "PyNumber_InPlaceDivide" - "PyNumber_InPlaceFloorDivide" - "PyNumber_InPlaceTrueDivide" - "PyNumber_InPlaceRemainder" - "PyNumber_InPlacePower" - "PyNumber_InPlaceLshift" - "PyNumber_InPlaceRshift" - "PyNumber_InPlaceAnd" - "PyNumber_InPlaceXor" - "PyNumber_InPlaceOr" - "PySequence_Check" - "PySequence_Size" - "PySequence_Length" - "PySequence_DelSlice" - "PySequence_List" - "PySequence_Count" - "PySequence_Contains" - "PySequence_In" - "PySequence_Index" - "PyMapping_Check" - "PyMapping_Length" - "PyMapping_HasKeyString" - "PyMapping_HasKey" - "PyMapping_GetItemString" - "PyMapping_SetItemString" - "PyObject_IsInstance" - "PyObject_IsSubclass" - -; From python25_s.lib(boolobject) - "PyBool_FromLong" - "PyBool_Type" - "_Py_ZeroStruct" - "_Py_TrueStruct" - -; From python25_s.lib(cellobject) - "PyCell_New" - "PyCell_Get" - "PyCell_Set" - "PyCell_Type" - -; From python25_s.lib(classobject) - "PyClass_New" - "PyClass_IsSubclass" - "PyInstance_New" - "PyInstance_NewRaw" - "PyMethod_New" - "PyMethod_Function" - "PyMethod_Self" - "PyMethod_Class" - "_PyInstance_Lookup" - "PyMethod_Fini" - "PyClass_Type" - "PyInstance_Type" - "PyMethod_Type" - -; From python25_s.lib(cobject) - "PyCObject_FromVoidPtr" - "PyCObject_FromVoidPtrAndDesc" - "PyCObject_AsVoidPtr" - "PyCObject_GetDesc" - "PyCObject_Import" - "PyCObject_SetVoidPtr" - "PyCObject_Type" - -; From python25_s.lib(codeobject) - "PyCode_New" - "PyCode_Addr2Line" - "PyCode_CheckLineNumber" - "PyCode_Type" - -; From python25_s.lib(complexobject) - "_Py_c_pow" - "_Py_c_sum" - "_Py_c_diff" - "_Py_c_neg" - "_Py_c_prod" - "_Py_c_quot" - "PyComplex_FromCComplex" - "PyComplex_FromDoubles" - "PyComplex_RealAsDouble" - "PyComplex_ImagAsDouble" - "PyComplex_AsCComplex" - "PyComplex_Type" - -; From python25_s.lib(descrobject) - "PyWrapper_New" - "PyDescr_NewMethod" - "PyDescr_NewClassMethod" - "PyDescr_NewMember" - "PyDescr_NewGetSet" - "PyDescr_NewWrapper" - "PyDictProxy_New" - "PyWrapperDescr_Type" - "PyProperty_Type" - -; From python25_s.lib(dictobject) - "PyDict_New" - "PyDict_GetItem" - "PyDict_SetItem" - "PyDict_DelItem" - "PyDict_Clear" - "PyDict_MergeFromSeq2" - "PyDict_Merge" - "PyDict_Keys" - "PyDict_Values" - "PyDict_Contains" - "PyDict_Next" - "PyDict_Items" - "PyDict_Size" - "PyDict_Copy" - "PyDict_Update" - "PyDict_GetItemString" - "PyDict_SetItemString" - "PyDict_DelItemString" - "PyDict_Type" - "PyDictIterKey_Type" - "PyDictIterValue_Type" - "PyDictIterItem_Type" - -; From python25_s.lib(enumobject) - "PyEnum_Type" - "PyReversed_Type" - -; From python25_s.lib(fileobject) - "PyFile_FromString" - "Py_UniversalNewlineFread" - "PyFile_GetLine" - "PyFile_SoftSpace" - "PyFile_WriteObject" - "PyFile_WriteString" - "PyObject_AsFileDescriptor" - "Py_UniversalNewlineFgets" - "PyFile_SetBufSize" - "PyFile_SetEncoding" - "PyFile_FromFile" - "PyFile_AsFile" - "PyFile_Name" - "PyFile_Type" - -; From python25_s.lib(floatobject) - "PyFloat_FromString" - "PyFloat_AsDouble" - "PyFloat_Fini" - "_PyFloat_Pack4" - "_PyFloat_Pack8" - "_PyFloat_Unpack4" - "_PyFloat_Unpack8" - "PyFloat_FromDouble" - "PyFloat_AsReprString" - "PyFloat_AsString" - "_PyFloat_Init" - "PyFloat_AsStringEx" - "PyFloat_Type" - -; From python25_s.lib(frameobject) - "PyFrame_New" - "PyFrame_FastToLocals" - "PyFrame_LocalsToFast" - "_PyFrame_Init" - "PyFrame_Fini" - "PyFrame_BlockSetup" - "PyFrame_BlockPop" - "PyFrame_Type" - -; From python25_s.lib(funcobject) - "PyFunction_New" - "PyFunction_GetCode" - "PyFunction_GetGlobals" - "PyFunction_GetModule" - "PyFunction_GetDefaults" - "PyFunction_SetDefaults" - "PyFunction_GetClosure" - "PyFunction_SetClosure" - "PyClassMethod_New" - "PyStaticMethod_New" - "PyFunction_Type" - "PyClassMethod_Type" - "PyStaticMethod_Type" - -; From python25_s.lib(genobject) - "PyGen_New" - "PyGen_NeedsFinalizing" - "PyGen_Type" - -; From python25_s.lib(iterobject) - "PySeqIter_New" - "PyCallIter_New" - "PySeqIter_Type" - "PyCallIter_Type" - -; From python25_s.lib(listobject) - "PyList_New" - "PyList_Append" - "PyList_Size" - "PyList_GetItem" - "PyList_SetItem" - "PyList_Insert" - "PyList_GetSlice" - "PyList_SetSlice" - "PyList_Sort" - "PyList_Reverse" - "PyList_AsTuple" - "_PyList_Extend" - "PyList_Fini" - "PyList_Type" - "PyListIter_Type" - "PyListRevIter_Type" - -; From python25_s.lib(longobject) - "PyLong_FromDouble" - "PyLong_AsLong" - "_PyLong_AsSsize_t" - "PyLong_AsUnsignedLong" - "_PyLong_FromByteArray" - "_PyLong_AsByteArray" - "PyLong_AsDouble" - "PyLong_FromLongLong" - "PyLong_AsLongLong" - "PyLong_FromString" - "PyLong_FromLong" - "PyLong_FromUnsignedLong" - "PyLong_AsUnsignedLongMask" - "_PyLong_FromSize_t" - "_PyLong_FromSsize_t" - "_PyLong_AsScaledDouble" - "PyLong_FromVoidPtr" - "PyLong_AsVoidPtr" - "PyLong_FromUnsignedLongLong" - "PyLong_AsUnsignedLongLong" - "PyLong_AsUnsignedLongLongMask" - "PyLong_FromUnicode" - "_PyLong_Sign" - "_PyLong_NumBits" - "_PyLong_New" - "_PyLong_Copy" - "PyLong_Type" - "_PyLong_DigitValue" - -; From python25_s.lib(methodobject) - "PyCFunction_Call" - "Py_FindMethodInChain" - "PyCFunction_GetFunction" - "PyCFunction_GetSelf" - "PyCFunction_GetFlags" - "Py_FindMethod" - "PyCFunction_NewEx" - "PyCFunction_Fini" - "PyCFunction_New" - "PyCFunction_Type" - -; From python25_s.lib(moduleobject) - "PyModule_New" - "_PyModule_Clear" - "PyModule_GetDict" - "PyModule_GetName" - "PyModule_GetFilename" - "PyModule_Type" - -; From python25_s.lib(object) - "Py_DivisionWarningFlag" - "PyObject_Str" - "PyObject_Repr" - "_PyObject_Str" - "PyObject_Unicode" - "PyObject_GetAttr" - "PyObject_IsTrue" - "PyNumber_CoerceEx" - "PyObject_Compare" - "PyObject_RichCompare" - "_Py_HashDouble" - "PyObject_Hash" - "PyObject_SetAttr" - "PyObject_GenericGetAttr" - "PyObject_GenericSetAttr" - "PyCallable_Check" - "PyObject_Dir" - "PyMem_Malloc" - "PyMem_Realloc" - "PyMem_Free" - "PyObject_Print" - "_PyObject_Dump" - "PyObject_RichCompareBool" - "PyObject_GetAttrString" - "PyObject_SetAttrString" - "PyObject_HasAttrString" - "PyObject_HasAttr" - "_PyObject_GetDictPtr" - "PyObject_SelfIter" - "PyObject_Not" - "PyNumber_Coerce" - "Py_ReprEnter" - "Py_ReprLeave" - "_Py_HashPointer" - "Py_IncRef" - "Py_DecRef" - "_PyTrash_deposit_object" - "_PyTrash_destroy_chain" - "PyObject_Init" - "PyObject_InitVar" - "_PyObject_New" - "_PyObject_NewVar" - "_Py_ReadyTypes" - "_Py_SwappedOp" - "_Py_NotImplementedStruct" - "_Py_NoneStruct" - "_Py_cobject_hack" - "_Py_abstract_hack" - "_PyTrash_delete_nesting" - "_PyTrash_delete_later" - -; From python25_s.lib(obmalloc) - "PyObject_Malloc" - "PyObject_Free" - "PyObject_Realloc" - -; From python25_s.lib(rangeobject) - "PyRange_Type" - -; From python25_s.lib(setobject) - "PySet_Pop" - "PySet_New" - "PyFrozenSet_New" - "PySet_Size" - "PySet_Clear" - "PySet_Contains" - "PySet_Discard" - "PySet_Add" - "_PySet_Next" - "_PySet_Update" - "PySet_Fini" - "PySet_Type" - "PyFrozenSet_Type" - -; From python25_s.lib(sliceobject) - "_PySlice_FromIndices" - "PySlice_GetIndices" - "PySlice_GetIndicesEx" - "PySlice_New" - "_Py_EllipsisObject" - "PySlice_Type" - -; From python25_s.lib(stringobject) - "PyString_FromStringAndSize" - "PyString_InternInPlace" - "PyString_FromString" - "PyString_FromFormatV" - "PyString_AsString" - "_PyString_Resize" - "PyString_FromFormat" - "PyString_AsDecodedString" - "PyString_AsEncodedString" - "PyString_DecodeEscape" - "PyString_Repr" - "PyString_AsStringAndSize" - "_PyString_FormatLong" - "PyString_Format" - "_Py_ReleaseInternedStrings" - "PyString_Size" - "PyString_Concat" - "PyString_ConcatAndDel" - "_PyString_Eq" - "PyString_InternImmortal" - "PyString_InternFromString" - "_PyString_Join" - "PyString_Decode" - "PyString_Encode" - "PyString_AsEncodedObject" - "PyString_AsDecodedObject" - "PyString_Fini" - "PyString_Type" - "PyBaseString_Type" - -; From python25_s.lib(structseq) - "PyStructSequence_InitType" - "PyStructSequence_New" - "PyStructSequence_UnnamedField" - -; From python25_s.lib(tupleobject) - "PyTuple_New" - "PyTuple_Pack" - "_PyTuple_Resize" - "PyTuple_Size" - "PyTuple_GetItem" - "PyTuple_SetItem" - "PyTuple_GetSlice" - "PyTuple_Fini" - "PyTuple_Type" - "PyTupleIter_Type" - -; From python25_s.lib(typeobject) - "PyType_IsSubtype" - "_PyType_Lookup" - "PyType_Ready" - "PyType_GenericAlloc" - "_PyObject_SlotCompare" - "PyType_GenericNew" - "PyType_Type" - "PyBaseObject_Type" - "PySuper_Type" - -; From python25_s.lib(unicodeobject) - "PyUnicodeUCS2_Resize" - "PyUnicodeUCS2_FromOrdinal" - "PyUnicodeUCS2_FromObject" - "PyUnicodeUCS2_FromEncodedObject" - "PyUnicodeUCS2_Decode" - "PyUnicodeUCS2_GetDefaultEncoding" - "PyUnicodeUCS2_DecodeUTF8" - "PyUnicodeUCS2_DecodeLatin1" - "PyUnicodeUCS2_DecodeASCII" - "PyUnicodeUCS2_AsEncodedString" - "PyUnicodeUCS2_AsUTF8String" - "PyUnicodeUCS2_AsLatin1String" - "PyUnicodeUCS2_AsASCIIString" - "PyUnicode_DecodeUTF7" - "PyUnicode_EncodeUTF7" - "PyUnicodeUCS2_DecodeUTF8Stateful" - "PyUnicodeUCS2_EncodeUTF8" - "PyUnicodeUCS2_DecodeUTF16Stateful" - "PyUnicodeUCS2_AsUTF16String" - "PyUnicodeUCS2_DecodeUnicodeEscape" - "PyUnicodeUCS2_DecodeRawUnicodeEscape" - "PyUnicodeUCS2_EncodeRawUnicodeEscape" - "_PyUnicode_DecodeUnicodeInternal" - "PyUnicodeUCS2_DecodeCharmap" - "PyUnicode_BuildEncodingMap" - "PyUnicodeUCS2_EncodeCharmap" - "PyUnicodeUCS2_TranslateCharmap" - "PyUnicodeUCS2_EncodeDecimal" - "PyUnicodeUCS2_Count" - "PyUnicodeUCS2_Find" - "PyUnicodeUCS2_Join" - "PyUnicodeUCS2_Splitlines" - "PyUnicodeUCS2_Compare" - "PyUnicodeUCS2_Contains" - "PyUnicodeUCS2_Concat" - "_PyUnicode_XStrip" - "PyUnicodeUCS2_Replace" - "PyUnicodeUCS2_Split" - "PyUnicodeUCS2_RSplit" - "PyUnicodeUCS2_Format" - "_PyUnicodeUCS2_Init" - "_PyUnicodeUCS2_Fini" - "PyUnicodeUCS2_FromUnicode" - "PyUnicodeUCS2_AsUnicode" - "PyUnicodeUCS2_GetSize" - "PyUnicodeUCS2_GetMax" - "_PyUnicodeUCS2_AsDefaultEncodedString" - "PyUnicodeUCS2_SetDefaultEncoding" - "PyUnicodeUCS2_Encode" - "PyUnicodeUCS2_AsEncodedObject" - "PyUnicodeUCS2_DecodeUTF16" - "PyUnicodeUCS2_EncodeUTF16" - "PyUnicodeUCS2_AsUnicodeEscapeString" - "PyUnicodeUCS2_EncodeUnicodeEscape" - "PyUnicodeUCS2_AsRawUnicodeEscapeString" - "PyUnicodeUCS2_EncodeLatin1" - "PyUnicodeUCS2_EncodeASCII" - "PyUnicodeUCS2_AsCharmapString" - "PyUnicodeUCS2_Partition" - "PyUnicodeUCS2_RPartition" - "PyUnicodeUCS2_Translate" - "PyUnicodeUCS2_Tailmatch" - "PyUnicode_AsDecodedObject" - "PyUnicode_Type" - -; From python25_s.lib(unicodectype) - "_PyUnicode_TypeRecords" - "_PyUnicodeUCS2_ToNumeric" - "_PyUnicodeUCS2_IsLowercase" - "_PyUnicodeUCS2_IsUppercase" - "_PyUnicodeUCS2_IsTitlecase" - "_PyUnicodeUCS2_IsWhitespace" - "_PyUnicodeUCS2_IsLinebreak" - "_PyUnicodeUCS2_ToLowercase" - "_PyUnicodeUCS2_ToUppercase" - "_PyUnicodeUCS2_ToTitlecase" - "_PyUnicodeUCS2_ToDecimalDigit" - "_PyUnicodeUCS2_ToDigit" - "_PyUnicodeUCS2_IsDecimalDigit" - "_PyUnicodeUCS2_IsDigit" - "_PyUnicodeUCS2_IsNumeric" - "_PyUnicodeUCS2_IsAlpha" - -; From python25_s.lib(weakrefobject) - "PyWeakref_NewRef" - "PyWeakref_NewProxy" - "PyObject_ClearWeakRefs" - "PyWeakref_GetObject" - "_PyWeakref_GetWeakrefCount" - "_PyWeakref_ClearRef" - "_PyWeakref_RefType" - "_PyWeakref_ProxyType" - "_PyWeakref_CallableProxyType" - -; From python25_s.lib(Python-ast) -; "init_ast" - "Module" - "Interactive" - "Expression" - "Suite" - "FunctionDef" - "ClassDef" - "Return" - "Delete" - "Assign" - "AugAssign" - "Print" - "For" - "While" - "If" - "With" - "Raise" - "TryExcept" - "TryFinally" - "Assert" - "Import" - "ImportFrom" - "Exec" - "Global" - "Expr" - "Pass" - "Break" - "Continue" - "BoolOp" - "BinOp" - "UnaryOp" - "Lambda" - "IfExp" - "Dict" - "ListComp" - "GeneratorExp" - "Yield" - "Compare" - "Call" - "Repr" - "Num" - "Str" - "Attribute" - "Subscript" - "Name" - "List" - "Tuple" - "Ellipsis" - "Slice" - "ExtSlice" - "Index" - "comprehension" - "excepthandler" - "arguments" - "keyword" - "alias" - "PyAST_mod2obj" - -; From python25_s.lib(asdl) - "asdl_seq_new" - "asdl_int_seq_new" - -; From python25_s.lib(ast) - "PyAST_FromNode" - -; From python25_s.lib(bltinmodule) - "_PyBuiltin_Init" - "Py_FileSystemDefaultEncoding" - -; From python25_s.lib(exceptions) - "PyUnicodeEncodeError_GetStart" - "PyUnicodeDecodeError_GetStart" - "PyUnicodeEncodeError_GetEnd" - "PyUnicodeDecodeError_GetEnd" - "_PyExc_Init" - "PyUnicodeDecodeError_Create" - "PyUnicodeEncodeError_Create" - "PyUnicodeTranslateError_Create" - "PyUnicodeEncodeError_GetEncoding" - "PyUnicodeDecodeError_GetEncoding" - "PyUnicodeEncodeError_GetObject" - "PyUnicodeDecodeError_GetObject" - "PyUnicodeTranslateError_GetObject" - "PyUnicodeTranslateError_GetStart" - "PyUnicodeEncodeError_SetStart" - "PyUnicodeDecodeError_SetStart" - "PyUnicodeTranslateError_SetStart" - "PyUnicodeTranslateError_GetEnd" - "PyUnicodeEncodeError_SetEnd" - "PyUnicodeDecodeError_SetEnd" - "PyUnicodeTranslateError_SetEnd" - "PyUnicodeEncodeError_GetReason" - "PyUnicodeDecodeError_GetReason" - "PyUnicodeTranslateError_GetReason" - "PyUnicodeEncodeError_SetReason" - "PyUnicodeDecodeError_SetReason" - "PyUnicodeTranslateError_SetReason" - "_PyExc_Fini" - "PyExc_BaseException" - "PyExc_Exception" - "PyExc_TypeError" - "PyExc_StopIteration" - "PyExc_GeneratorExit" - "PyExc_SystemExit" - "PyExc_KeyboardInterrupt" - "PyExc_ImportError" - "PyExc_EnvironmentError" - "PyExc_IOError" - "PyExc_OSError" - "PyExc_EOFError" - "PyExc_RuntimeError" - "PyExc_NotImplementedError" - "PyExc_NameError" - "PyExc_UnboundLocalError" - "PyExc_AttributeError" - "PyExc_IndexError" - "PyExc_SyntaxError" - "PyExc_IndentationError" - "PyExc_TabError" - "PyExc_LookupError" - "PyExc_KeyError" - "PyExc_ValueError" - "PyExc_UnicodeError" - "PyExc_UnicodeEncodeError" - "PyExc_UnicodeDecodeError" - "PyExc_UnicodeTranslateError" - "PyExc_AssertionError" - "PyExc_ArithmeticError" - "PyExc_FloatingPointError" - "PyExc_OverflowError" - "PyExc_ZeroDivisionError" - "PyExc_SystemError" - "PyExc_ReferenceError" - "PyExc_MemoryError" - "PyExc_Warning" - "PyExc_UserWarning" - "PyExc_DeprecationWarning" - "PyExc_PendingDeprecationWarning" - "PyExc_SyntaxWarning" - "PyExc_RuntimeWarning" - "PyExc_FutureWarning" - "PyExc_ImportWarning" - "PyExc_MemoryErrorInst" - -; From python25_s.lib(ceval) - "PyEval_EvalFrameEx" - "PyEval_CallObjectWithKeywords" - "PyEval_EvalCodeEx" - "PyEval_GetFrame" - "PyEval_CallObject" - "PyEval_SetProfile" - "PyEval_SetTrace" - "PyEval_GetBuiltins" - "PyEval_GetGlobals" - "PyEval_GetLocals" - "PyEval_GetRestricted" - "PyEval_MergeCompilerFlags" - "Py_FlushLine" - "Py_AddPendingCall" - "Py_MakePendingCalls" - "Py_SetRecursionLimit" - "Py_GetRecursionLimit" - "_Py_CheckRecursiveCall" - "PyEval_GetFuncName" - "PyEval_GetFuncDesc" - "PyEval_GetCallStats" - "PyEval_EvalFrame" - "PyEval_SaveThread" - "PyEval_RestoreThread" - "PyEval_ThreadsInitialized" - "PyEval_InitThreads" - "PyEval_AcquireLock" - "PyEval_ReleaseLock" - "PyEval_AcquireThread" - "PyEval_ReleaseThread" - "PyEval_ReInitThreads" - "_PyEval_SliceIndex" - "PyEval_EvalCode" - "_PyEval_CallTracing" - "_Py_CheckRecursionLimit" - "_Py_CheckInterval" - "_Py_Ticker" - -; From python25_s.lib(compile) - "_Py_Mangle" - "PyAST_Compile" - "PyNode_Compile" - "Py_OptimizeFlag" - -; From python25_s.lib(codecs) - "_PyCodec_Lookup" - "PyCodec_Encode" - "PyCodec_Decode" - "PyCodec_IgnoreErrors" - "PyCodec_ReplaceErrors" - "PyCodec_XMLCharRefReplaceErrors" - "PyCodec_BackslashReplaceErrors" - "PyCodec_Register" - "PyCodec_Encoder" - "PyCodec_Decoder" - "PyCodec_IncrementalEncoder" - "PyCodec_IncrementalDecoder" - "PyCodec_StreamReader" - "PyCodec_StreamWriter" - "PyCodec_RegisterError" - "PyCodec_LookupError" - "PyCodec_StrictErrors" - -; From python25_s.lib(errors) - "PyErr_SetNone" - "PyErr_SetString" - "PyErr_GivenExceptionMatches" - "PyErr_NormalizeException" - "PyErr_Fetch" - "PyErr_Clear" - "PyErr_NoMemory" - "PyErr_SetFromErrnoWithFilenameObject" - "PyErr_Format" - "PyErr_NewException" - "PyErr_WriteUnraisable" - "PyErr_SyntaxLocation" - "PyErr_ProgramText" - "PyErr_SetObject" - "PyErr_Occurred" - "PyErr_Restore" - "PyErr_ExceptionMatches" - "PyErr_BadArgument" - "PyErr_SetFromErrno" - "PyErr_SetFromErrnoWithFilename" - "PyErr_BadInternalCall" - "_PyErr_BadInternalCall" - "PyErr_Warn" - "PyErr_WarnExplicit" - -; From python25_s.lib(frozen) - "PyImport_FrozenModules" - -; From python25_s.lib(frozenmain) - "Py_FrozenMain" - -; From python25_s.lib(future) - "PyFuture_FromAST" - -; From python25_s.lib(getargs) - "PyArg_Parse" - "_PyArg_Parse_SizeT" - "PyArg_ParseTuple" - "_PyArg_ParseTuple_SizeT" - "PyArg_ParseTupleAndKeywords" - "_PyArg_ParseTupleAndKeywords_SizeT" - "PyArg_UnpackTuple" - "_PyArg_NoKeywords" - "PyArg_VaParse" - "PyArg_VaParseTupleAndKeywords" - "_PyArg_VaParse_SizeT" - "_PyArg_VaParseTupleAndKeywords_SizeT" - -; From python25_s.lib(getcompiler) - "Py_GetCompiler" - -; From python25_s.lib(getcopyright) - "Py_GetCopyright" - -; From python25_s.lib(getmtime) - "PyOS_GetLastModificationTime" - -; From python25_s.lib(getplatform) - "Py_GetPlatform" - -; From python25_s.lib(getversion) - "Py_GetVersion" - -; From python25_s.lib(graminit) - "_PyParser_Grammar" - -; From python25_s.lib(import) - "_PyImport_Init" - "_PyImportHooks_Init" - "PyImport_ImportModule" - "PyImport_Cleanup" - "_PyImport_FixupExtension" - "PyImport_AddModule" - "PyImport_ExecCodeModuleEx" - "PyImport_ImportFrozenModule" - "PyImport_ImportModuleEx" - "PyImport_ImportModuleLevel" - "PyImport_ReloadModule" - "PyImport_Import" -; "initimp" - "_PyImport_Fini" - "PyImport_GetMagicNumber" - "PyImport_ExecCodeModule" - "PyImport_GetModuleDict" - "_PyImport_FindModule" - "_PyImport_IsScript" - "_PyImport_ReInitLock" - "_PyImport_FindExtension" - "PyImport_AppendInittab" - "PyImport_ExtendInittab" - "PyImport_Inittab" - "_PyImport_Filetab" - -; From python25_s.lib(importdl) - "_PyImport_LoadDynamicModule" - -; From python25_s.lib(marshal) - "PyMarshal_ReadLongFromFile" - "PyMarshal_WriteObjectToString" - "PyMarshal_WriteLongToFile" - "PyMarshal_WriteObjectToFile" - "PyMarshal_ReadShortFromFile" - "PyMarshal_ReadObjectFromFile" - "PyMarshal_ReadLastObjectFromFile" - "PyMarshal_ReadObjectFromString" - "PyMarshal_Init" - -; From python25_s.lib(modsupport) - "Py_InitModule4" - "Py_BuildValue" - "_Py_BuildValue_SizeT" - "PyEval_CallFunction" - "PyEval_CallMethod" - "_Py_VaBuildValue_SizeT" - "Py_VaBuildValue" - "PyModule_AddObject" - "PyModule_AddIntConstant" - "PyModule_AddStringConstant" - "_Py_PackageContext" - -; From python25_s.lib(mysnprintf) - "PyOS_snprintf" - "PyOS_vsnprintf" - -; From python25_s.lib(mystrtoul) - "PyOS_strtoul" - "PyOS_strtol" - -; From python25_s.lib(pyarena) - "PyArena_New" - "PyArena_Free" - "PyArena_Malloc" - "PyArena_AddPyObject" - -; From python25_s.lib(pyfpe) - "PyFPE_dummy" - -; From python25_s.lib(pystate) - "PyInterpreterState_Clear" - "PyThreadState_Clear" - "_PyThread_CurrentFrames" - "PyGILState_Ensure" - "PyGILState_Release" - "PyInterpreterState_New" - "PyInterpreterState_Delete" - "PyThreadState_Delete" - "PyThreadState_New" - "PyThreadState_DeleteCurrent" - "PyThreadState_Get" - "PyThreadState_Swap" - "PyThreadState_GetDict" - "PyThreadState_SetAsyncExc" - "PyGILState_GetThisThreadState" - "PyInterpreterState_Head" - "PyInterpreterState_Next" - "PyInterpreterState_ThreadHead" - "PyThreadState_Next" - "_PyGILState_Init" - "_PyGILState_Fini" - "_PyThreadState_Current" - "_PyThreadState_GetFrame" - -; From python25_s.lib(pystrtod) - "PyOS_ascii_strtod" - "PyOS_ascii_formatd" - "PyOS_ascii_atof" - -; From python25_s.lib(pythonrun) - "Py_IgnoreEnvironmentFlag" - "Py_DebugFlag" - "Py_VerboseFlag" - "Py_NoSiteFlag" - "Py_InteractiveFlag" - "Py_FrozenFlag" - "Py_InitializeEx" - "Py_FatalError" - "Py_NewInterpreter" - "PyErr_Print" - "PyRun_InteractiveOneFlags" - "PyParser_ASTFromFile" - "PyRun_SimpleFileExFlags" - "PyRun_FileExFlags" - "Py_Exit" - "PyErr_PrintEx" - "PyErr_Display" - "Py_SetProgramName" - "Py_GetProgramName" - "Py_SetPythonHome" - "Py_GetPythonHome" - "Py_Initialize" - "Py_Finalize" - "Py_IsInitialized" - "Py_EndInterpreter" - "PyRun_AnyFileFlags" - "Py_FdIsInteractive" - "PyRun_InteractiveLoopFlags" - "PyRun_AnyFileExFlags" - "PyRun_SimpleStringFlags" - "PyRun_StringFlags" - "PyParser_ASTFromString" - "PyParser_SimpleParseStringFlags" - "PyParser_SimpleParseFileFlags" - "Py_CompileStringFlags" - "Py_SymtableString" - "Py_AtExit" - "PyOS_getsig" - "PyOS_setsig" - "PyParser_SetError" - "PyModule_GetWarningsModule" - "PyParser_SimpleParseStringFlagsFilename" - "PyParser_SimpleParseStringFilename" - "PyParser_SimpleParseFile" - "PyParser_SimpleParseString" - "PyRun_AnyFile" - "PyRun_AnyFileEx" - "PyRun_File" - "PyRun_FileEx" - "PyRun_FileFlags" - "PyRun_SimpleFile" - "PyRun_SimpleFileEx" - "PyRun_String" - "PyRun_SimpleString" - "Py_CompileString" - "PyRun_InteractiveOne" - "PyRun_InteractiveLoop" - "Py_UseClassExceptionsFlag" - "Py_UnicodeFlag" - "_Py_QnewFlag" - -; From python25_s.lib(structmember) - "PyMember_GetOne" - "PyMember_SetOne" - -; From python25_s.lib(symtable) - "PySymtable_Build" - "PySymtable_Free" - "PyST_GetScope" - "PySymtable_Lookup" - "PySTEntry_Type" - -; From python25_s.lib(sysmodule) - "_PySys_Init" - "PySys_WriteStderr" - "PySys_SetPath" - "PySys_SetArgv" - "PySys_WriteStdout" - "Py_SubversionRevision" - "Py_SubversionShortBranch" - "PySys_GetObject" - "PySys_SetObject" - "PySys_GetFile" - "PySys_ResetWarnOptions" - "PySys_AddWarnOption" - -; From python25_s.lib(traceback) - "PyTraceBack_Here" - "PyTraceBack_Print" - "PyTraceBack_Type" - -; From python25_s.lib(getopt) - "_PyOS_GetOpt" - "_PyOS_opterr" - "_PyOS_optind" - "_PyOS_optarg" - -; From python25_s.lib(dynload_shlib) - "_PyImport_DynLoadFiletab" - "_PyImport_GetDynLoadFunc" - -; From python25_s.lib(thread) - "PyThread_delete_key_value" - "PyThread_init_thread" - "PyThread_start_new_thread" - "PyThread_exit_thread" - "PyThread_get_thread_ident" - "PyThread_allocate_lock" - "PyThread_free_lock" - "PyThread_acquire_lock" - "PyThread_release_lock" - "PyThread_get_stacksize" - "PyThread_set_stacksize" - "PyThread_create_key" - "PyThread_delete_key" - "PyThread_set_key_value" - "PyThread_get_key_value" - "PyThread__exit_thread" - -; From python25_s.lib(gcmodule) -; "initgc" - "_PyObject_GC_New" - "_PyObject_GC_NewVar" - "PyGC_Collect" - "_PyObject_GC_Resize" - "_PyObject_GC_Malloc" - "PyObject_GC_Track" - "PyObject_GC_UnTrack" - "PyObject_GC_Del" - "_PyGC_Dump" - "_PyObject_GC_Track" - "_PyObject_GC_UnTrack" - "_PyObject_GC_Del" - "_PyGC_generation0" - -; From python25_s.lib(signalmodule) -; "initsignal" - "PyErr_CheckSignals" - "PyErr_SetInterrupt" - "PyOS_FiniInterrupts" - "PyOS_InterruptOccurred" - "PyOS_InitInterrupts" - "PyOS_AfterFork" - -; From python25_s.lib(posixmodule) -; "initos2" - -; From python25_s.lib(threadmodule) -; "initthread" - -; From python25_s.lib(arraymodule) -; "initarray" -; "array_methods" - -; From python25_s.lib(binascii) -; "initbinascii" - -; From python25_s.lib(cmathmodule) -; "initcmath" - -; From python25_s.lib(_codecsmodule) -; "init_codecs" - -; From python25_s.lib(collectionsmodule) -; "initcollections" - "dequeiter_type" - "dequereviter_type" - -; From python25_s.lib(cStringIO) -; "initcStringIO" - -; From python25_s.lib(_csv) -; "init_csv" - -; From python25_s.lib(datetimemodule) -; "initdatetime" - -; From python25_s.lib(dlmodule) -; "initdl" - -; From python25_s.lib(errnomodule) -; "initerrno" - -; From python25_s.lib(fcntlmodule) -; "initfcntl" - -; From python25_s.lib(_functoolsmodule) -; "init_functools" - -; From python25_s.lib(_heapqmodule) -; "init_heapq" - -; From python25_s.lib(imageop) -; "initimageop" - -; From python25_s.lib(itertoolsmodule) -; "inititertools" - -; From python25_s.lib(_localemodule) -; "init_locale" - -; From python25_s.lib(mathmodule) -; "initmath" - -; From python25_s.lib(operator) -; "initoperator" - -; From python25_s.lib(_randommodule) -; "init_random" - -; From python25_s.lib(sha256module) -; "init_sha256" - -; From python25_s.lib(sha512module) -; "init_sha512" - -; From python25_s.lib(_sre) -; "init_sre" - -; From python25_s.lib(_struct) -; "init_struct" - -; From python25_s.lib(symtablemodule) -; "init_symtable" - -; From python25_s.lib(termios) -; "inittermios" - -; From python25_s.lib(timemodule) -; "inittime" - "_PyTime_DoubleToTimet" -; "inittimezone" - -; From python25_s.lib(_weakref) -; "init_weakref" - -; From python25_s.lib(xxsubtype) -; "initxxsubtype" - -; From python25_s.lib(zipimport) -; "initzipimport" Added: python/branches/py3k/PC/os2emx/python26.def ============================================================================== --- (empty file) +++ python/branches/py3k/PC/os2emx/python26.def Sun Feb 3 17:51:08 2008 @@ -0,0 +1,1314 @@ +LIBRARY python26 INITINSTANCE TERMINSTANCE +DESCRIPTION "Python 2.6 Core DLL" +PROTMODE +DATA MULTIPLE NONSHARED +EXPORTS + +; From python26_s.lib(config) + "_PyImport_Inittab" + +; From python26_s.lib(dlfcn) +; "dlopen" +; "dlsym" +; "dlclose" +; "dlerror" + +; From python26_s.lib(getpathp) + "Py_GetProgramFullPath" + "Py_GetPrefix" + "Py_GetExecPrefix" + "Py_GetPath" + +; From python26_s.lib(getbuildinfo) + "Py_GetBuildInfo" + "_Py_svnversion" + +; From python26_s.lib(main) + "Py_Main" + "Py_GetArgcArgv" + +; From python26_s.lib(acceler) + "PyGrammar_AddAccelerators" + "PyGrammar_RemoveAccelerators" + +; From python26_s.lib(grammar1) + "PyGrammar_FindDFA" + "PyGrammar_LabelRepr" + +; From python26_s.lib(listnode) + "PyNode_ListTree" + +; From python26_s.lib(node) + "PyNode_New" + "PyNode_AddChild" + "PyNode_Free" + +; From python26_s.lib(parser) + "PyParser_AddToken" + "PyParser_New" + "PyParser_Delete" + +; From python26_s.lib(parsetok) + "Py_TabcheckFlag" + "PyParser_ParseString" + "PyParser_ParseStringFlagsFilename" + "PyParser_ParseFile" + "PyParser_ParseFileFlags" + "PyParser_ParseStringFlags" + +; From python26_s.lib(bitset) + "_Py_newbitset" + "_Py_delbitset" + "_Py_addbit" + "_Py_samebitset" + "_Py_mergebitset" + +; From python26_s.lib(metagrammar) + "_Py_meta_grammar" + "Py_meta_grammar" + +; From python26_s.lib(tokenizer) + "PyToken_OneChar" + "PyToken_TwoChars" + "PyToken_ThreeChars" + "PyTokenizer_FromString" + "PyTokenizer_Free" + "PyTokenizer_FromFile" + "PyTokenizer_Get" + "_PyParser_TokenNames" + +; From python26_s.lib(myreadline) + "_PyOS_ReadlineTState" + "PyOS_ReadlineFunctionPointer" + "PyOS_StdioReadline" + "PyOS_Readline" + "PyOS_InputHook" + +; From python26_s.lib(abstract) + "_PyObject_LengthHint" + "PyMapping_Size" + "PyObject_CallMethod" + "PyObject_GetItem" + "PySequence_GetItem" + "PyObject_SetItem" + "PySequence_SetItem" + "PyObject_DelItem" + "PySequence_DelItem" + "PyNumber_Multiply" + "PyNumber_InPlaceAdd" + "PyNumber_InPlaceMultiply" + "PyNumber_Int" + "PyNumber_Long" + "PyNumber_Float" + "PySequence_Concat" + "PySequence_Repeat" + "PySequence_InPlaceConcat" + "PySequence_InPlaceRepeat" + "PySequence_GetSlice" + "PySequence_SetSlice" + "PySequence_Tuple" + "PyObject_GetIter" + "PyIter_Next" + "PySequence_Fast" + "_PySequence_IterSearch" + "PyObject_CallFunction" + "_PyObject_CallFunction_SizeT" + "_PyObject_CallMethod_SizeT" + "PyObject_CallMethodObjArgs" + "PyObject_CallFunctionObjArgs" + "PyObject_Cmp" + "PyObject_Call" + "PyObject_CallObject" + "PyObject_Type" + "PyObject_Size" + "PyObject_Length" + "PyObject_DelItemString" + "PyObject_AsCharBuffer" + "PyObject_CheckReadBuffer" + "PyObject_AsReadBuffer" + "PyObject_AsWriteBuffer" + "PyNumber_Check" + "PyNumber_Add" + "PyNumber_Subtract" + "PyNumber_Divide" + "PyNumber_FloorDivide" + "PyNumber_TrueDivide" + "PyNumber_Remainder" + "PyNumber_Divmod" + "PyNumber_Power" + "PyNumber_Negative" + "PyNumber_Positive" + "PyNumber_Absolute" + "PyNumber_Invert" + "PyNumber_Lshift" + "PyNumber_Rshift" + "PyNumber_And" + "PyNumber_Xor" + "PyNumber_Or" + "PyNumber_Index" + "PyNumber_InPlaceSubtract" + "PyNumber_InPlaceDivide" + "PyNumber_InPlaceFloorDivide" + "PyNumber_InPlaceTrueDivide" + "PyNumber_InPlaceRemainder" + "PyNumber_InPlacePower" + "PyNumber_InPlaceLshift" + "PyNumber_InPlaceRshift" + "PyNumber_InPlaceAnd" + "PyNumber_InPlaceXor" + "PyNumber_InPlaceOr" + "PySequence_Check" + "PySequence_Size" + "PySequence_Length" + "PySequence_DelSlice" + "PySequence_List" + "PySequence_Count" + "PySequence_Contains" + "PySequence_In" + "PySequence_Index" + "PyMapping_Check" + "PyMapping_Length" + "PyMapping_HasKeyString" + "PyMapping_HasKey" + "PyMapping_GetItemString" + "PyMapping_SetItemString" + "PyObject_IsInstance" + "PyObject_IsSubclass" + +; From python26_s.lib(boolobject) + "PyBool_FromLong" + "PyBool_Type" + "_Py_ZeroStruct" + "_Py_TrueStruct" + +; From python26_s.lib(bufferobject) + "PyBuffer_FromObject" + "PyBuffer_FromReadWriteObject" + "PyBuffer_FromMemory" + "PyBuffer_FromReadWriteMemory" + "PyBuffer_New" + "PyBuffer_Type" + +; From python26_s.lib(cellobject) + "PyCell_New" + "PyCell_Get" + "PyCell_Set" + "PyCell_Type" + +; From python26_s.lib(classobject) + "PyClass_New" + "PyClass_IsSubclass" + "PyInstance_New" + "PyInstance_NewRaw" + "PyMethod_New" + "PyMethod_Function" + "PyMethod_Self" + "PyMethod_Class" + "_PyInstance_Lookup" + "PyMethod_Fini" + "PyClass_Type" + "PyInstance_Type" + "PyMethod_Type" + +; From python26_s.lib(cobject) + "PyCObject_FromVoidPtr" + "PyCObject_FromVoidPtrAndDesc" + "PyCObject_AsVoidPtr" + "PyCObject_GetDesc" + "PyCObject_Import" + "PyCObject_SetVoidPtr" + "PyCObject_Type" + +; From python26_s.lib(codeobject) + "PyCode_New" + "PyCode_Addr2Line" + "PyCode_CheckLineNumber" + "PyCode_Type" + +; From python26_s.lib(complexobject) + "_Py_c_pow" + "_Py_c_sum" + "_Py_c_diff" + "_Py_c_neg" + "_Py_c_prod" + "_Py_c_quot" + "PyComplex_FromCComplex" + "PyComplex_FromDoubles" + "PyComplex_RealAsDouble" + "PyComplex_ImagAsDouble" + "PyComplex_AsCComplex" + "PyComplex_Type" + +; From python26_s.lib(descrobject) + "PyWrapper_New" + "PyDescr_NewMethod" + "PyDescr_NewClassMethod" + "PyDescr_NewMember" + "PyDescr_NewGetSet" + "PyDescr_NewWrapper" + "PyDictProxy_New" + "PyWrapperDescr_Type" + "PyProperty_Type" + +; From python26_s.lib(dictobject) + "PyDict_New" + "PyDict_GetItem" + "PyDict_SetItem" + "PyDict_DelItem" + "PyDict_Clear" + "PyDict_MergeFromSeq2" + "PyDict_Merge" + "PyDict_Keys" + "PyDict_Values" + "PyDict_Contains" + "PyDict_Next" + "PyDict_Items" + "PyDict_Size" + "PyDict_Copy" + "PyDict_Update" + "PyDict_GetItemString" + "PyDict_SetItemString" + "PyDict_DelItemString" + "PyDict_Type" + "PyDictIterKey_Type" + "PyDictIterValue_Type" + "PyDictIterItem_Type" + +; From python26_s.lib(enumobject) + "PyEnum_Type" + "PyReversed_Type" + +; From python26_s.lib(fileobject) + "PyFile_FromString" + "Py_UniversalNewlineFread" + "PyFile_GetLine" + "PyFile_SoftSpace" + "PyFile_WriteObject" + "PyFile_WriteString" + "PyObject_AsFileDescriptor" + "Py_UniversalNewlineFgets" + "PyFile_SetBufSize" + "PyFile_SetEncoding" + "PyFile_FromFile" + "PyFile_AsFile" + "PyFile_Name" + "PyFile_Type" + +; From python26_s.lib(floatobject) + "PyFloat_FromString" + "PyFloat_AsDouble" + "PyFloat_Fini" + "_PyFloat_Pack4" + "_PyFloat_Pack8" + "_PyFloat_Unpack4" + "_PyFloat_Unpack8" + "PyFloat_FromDouble" + "PyFloat_AsReprString" + "PyFloat_AsString" + "_PyFloat_Init" + "PyFloat_AsStringEx" + "PyFloat_Type" + +; From python26_s.lib(frameobject) + "PyFrame_New" + "PyFrame_FastToLocals" + "PyFrame_LocalsToFast" + "_PyFrame_Init" + "PyFrame_Fini" + "PyFrame_BlockSetup" + "PyFrame_BlockPop" + "PyFrame_Type" + +; From python26_s.lib(funcobject) + "PyFunction_New" + "PyFunction_GetCode" + "PyFunction_GetGlobals" + "PyFunction_GetModule" + "PyFunction_GetDefaults" + "PyFunction_SetDefaults" + "PyFunction_GetClosure" + "PyFunction_SetClosure" + "PyClassMethod_New" + "PyStaticMethod_New" + "PyFunction_Type" + "PyClassMethod_Type" + "PyStaticMethod_Type" + +; From python26_s.lib(genobject) + "PyGen_New" + "PyGen_NeedsFinalizing" + "PyGen_Type" + +; From python26_s.lib(intobject) + "PyInt_AsLong" + "PyInt_AsUnsignedLongMask" + "PyInt_AsUnsignedLongLongMask" + "PyInt_FromString" + "PyInt_AsSsize_t" + "PyInt_Fini" + "PyInt_FromUnicode" + "PyInt_FromLong" + "PyInt_FromSize_t" + "PyInt_FromSsize_t" + "PyInt_GetMax" + "_PyInt_Init" + "PyInt_Type" + +; From python26_s.lib(iterobject) + "PySeqIter_New" + "PyCallIter_New" + "PySeqIter_Type" + "PyCallIter_Type" + +; From python26_s.lib(listobject) + "PyList_New" + "PyList_Append" + "PyList_Size" + "PyList_GetItem" + "PyList_SetItem" + "PyList_Insert" + "PyList_GetSlice" + "PyList_SetSlice" + "PyList_Sort" + "PyList_Reverse" + "PyList_AsTuple" + "_PyList_Extend" + "PyList_Fini" + "PyList_Type" + "PyListIter_Type" + "PyListRevIter_Type" + +; From python26_s.lib(longobject) + "PyLong_FromDouble" + "PyLong_AsLong" + "_PyLong_AsSsize_t" + "PyLong_AsUnsignedLong" + "_PyLong_FromByteArray" + "_PyLong_AsByteArray" + "PyLong_AsDouble" + "PyLong_FromLongLong" + "PyLong_AsLongLong" + "PyLong_FromString" + "PyLong_FromLong" + "PyLong_FromUnsignedLong" + "PyLong_AsUnsignedLongMask" + "_PyLong_FromSize_t" + "_PyLong_FromSsize_t" + "_PyLong_AsScaledDouble" + "PyLong_FromVoidPtr" + "PyLong_AsVoidPtr" + "PyLong_FromUnsignedLongLong" + "PyLong_AsUnsignedLongLong" + "PyLong_AsUnsignedLongLongMask" + "PyLong_FromUnicode" + "_PyLong_Sign" + "_PyLong_NumBits" + "_PyLong_New" + "_PyLong_Copy" + "PyLong_Type" + "_PyLong_DigitValue" + +; From python26_s.lib(methodobject) + "PyCFunction_Call" + "Py_FindMethodInChain" + "PyCFunction_GetFunction" + "PyCFunction_GetSelf" + "PyCFunction_GetFlags" + "Py_FindMethod" + "PyCFunction_NewEx" + "PyCFunction_Fini" + "PyCFunction_New" + "PyCFunction_Type" + +; From python26_s.lib(moduleobject) + "PyModule_New" + "_PyModule_Clear" + "PyModule_GetDict" + "PyModule_GetName" + "PyModule_GetFilename" + "PyModule_Type" + +; From python26_s.lib(object) + "Py_DivisionWarningFlag" + "PyObject_Str" + "PyObject_Repr" + "_PyObject_Str" + "PyObject_Unicode" + "PyObject_GetAttr" + "PyObject_IsTrue" + "PyNumber_CoerceEx" + "PyObject_Compare" + "PyObject_RichCompare" + "_Py_HashDouble" + "PyObject_Hash" + "PyObject_SetAttr" + "PyObject_GenericGetAttr" + "PyObject_GenericSetAttr" + "PyCallable_Check" + "PyObject_Dir" + "PyMem_Malloc" + "PyMem_Realloc" + "PyMem_Free" + "PyObject_Print" + "_PyObject_Dump" + "PyObject_RichCompareBool" + "PyObject_GetAttrString" + "PyObject_SetAttrString" + "PyObject_HasAttrString" + "PyObject_HasAttr" + "_PyObject_GetDictPtr" + "PyObject_SelfIter" + "PyObject_Not" + "PyNumber_Coerce" + "Py_ReprEnter" + "Py_ReprLeave" + "_Py_HashPointer" + "Py_IncRef" + "Py_DecRef" + "_PyTrash_deposit_object" + "_PyTrash_destroy_chain" + "PyObject_Init" + "PyObject_InitVar" + "_PyObject_New" + "_PyObject_NewVar" + "_PyObject_Del" + "_Py_ReadyTypes" + "_Py_SwappedOp" + "_Py_NotImplementedStruct" + "_Py_NoneStruct" + "_Py_cobject_hack" + "_Py_abstract_hack" + "_PyTrash_delete_nesting" + "_PyTrash_delete_later" + +; From python26_s.lib(obmalloc) + "PyObject_Malloc" + "PyObject_Free" + "PyObject_Realloc" + +; From python26_s.lib(rangeobject) + "PyRange_Type" + +; From python26_s.lib(setobject) + "PySet_Pop" + "PySet_New" + "PyFrozenSet_New" + "PySet_Size" + "PySet_Clear" + "PySet_Contains" + "PySet_Discard" + "PySet_Add" + "_PySet_Next" + "_PySet_Update" + "PySet_Fini" + "PySet_Type" + "PyFrozenSet_Type" + +; From python26_s.lib(sliceobject) + "_PySlice_FromIndices" + "PySlice_GetIndices" + "PySlice_GetIndicesEx" + "PySlice_New" + "_Py_EllipsisObject" + "PySlice_Type" + +; From python26_s.lib(stringobject) + "PyString_FromStringAndSize" + "PyString_InternInPlace" + "PyString_FromString" + "PyString_FromFormatV" + "PyString_AsString" + "_PyString_Resize" + "PyString_FromFormat" + "PyString_AsDecodedString" + "PyString_AsEncodedString" + "PyString_DecodeEscape" + "PyString_Repr" + "PyString_AsStringAndSize" + "_PyString_FormatLong" + "PyString_Format" + "_Py_ReleaseInternedStrings" + "PyString_Size" + "PyString_Concat" + "PyString_ConcatAndDel" + "_PyString_Eq" + "PyString_InternImmortal" + "PyString_InternFromString" + "_PyString_Join" + "PyString_Decode" + "PyString_Encode" + "PyString_AsEncodedObject" + "PyString_AsDecodedObject" + "PyString_Fini" + "PyString_Type" + "PyBaseString_Type" + +; From python26_s.lib(structseq) + "PyStructSequence_InitType" + "PyStructSequence_New" + "PyStructSequence_UnnamedField" + +; From python26_s.lib(tupleobject) + "PyTuple_New" + "PyTuple_Pack" + "_PyTuple_Resize" + "PyTuple_Size" + "PyTuple_GetItem" + "PyTuple_SetItem" + "PyTuple_GetSlice" + "PyTuple_Fini" + "PyTuple_Type" + "PyTupleIter_Type" + +; From python26_s.lib(typeobject) + "PyType_IsSubtype" + "_PyType_Lookup" + "PyType_Ready" + "PyType_GenericAlloc" + "_PyObject_SlotCompare" + "PyType_GenericNew" + "PyType_Type" + "PyBaseObject_Type" + "PySuper_Type" + +; From python26_s.lib(unicodeobject) + "PyUnicodeUCS2_Resize" + "PyUnicodeUCS2_FromOrdinal" + "PyUnicodeUCS2_FromObject" + "PyUnicodeUCS2_FromEncodedObject" + "PyUnicodeUCS2_Decode" + "PyUnicodeUCS2_GetDefaultEncoding" + "PyUnicodeUCS2_DecodeUTF8" + "PyUnicodeUCS2_DecodeLatin1" + "PyUnicodeUCS2_DecodeASCII" + "PyUnicodeUCS2_AsEncodedString" + "PyUnicodeUCS2_AsUTF8String" + "PyUnicodeUCS2_AsLatin1String" + "PyUnicodeUCS2_AsASCIIString" + "PyUnicode_DecodeUTF7" + "PyUnicode_EncodeUTF7" + "PyUnicodeUCS2_DecodeUTF8Stateful" + "PyUnicodeUCS2_EncodeUTF8" + "PyUnicodeUCS2_DecodeUTF16Stateful" + "PyUnicodeUCS2_AsUTF16String" + "PyUnicodeUCS2_DecodeUnicodeEscape" + "PyUnicodeUCS2_DecodeRawUnicodeEscape" + "PyUnicodeUCS2_EncodeRawUnicodeEscape" + "_PyUnicode_DecodeUnicodeInternal" + "PyUnicodeUCS2_DecodeCharmap" + "PyUnicode_BuildEncodingMap" + "PyUnicodeUCS2_EncodeCharmap" + "PyUnicodeUCS2_TranslateCharmap" + "PyUnicodeUCS2_EncodeDecimal" + "PyUnicodeUCS2_Count" + "PyUnicodeUCS2_Find" + "PyUnicodeUCS2_Join" + "PyUnicodeUCS2_Splitlines" + "PyUnicodeUCS2_Compare" + "PyUnicodeUCS2_Contains" + "PyUnicodeUCS2_Concat" + "_PyUnicode_XStrip" + "PyUnicodeUCS2_Replace" + "PyUnicodeUCS2_Split" + "PyUnicodeUCS2_RSplit" + "PyUnicodeUCS2_Format" + "_PyUnicodeUCS2_Init" + "_PyUnicodeUCS2_Fini" + "PyUnicodeUCS2_FromUnicode" + "PyUnicodeUCS2_AsUnicode" + "PyUnicodeUCS2_GetSize" + "PyUnicodeUCS2_GetMax" + "_PyUnicodeUCS2_AsDefaultEncodedString" + "PyUnicodeUCS2_SetDefaultEncoding" + "PyUnicodeUCS2_Encode" + "PyUnicodeUCS2_AsEncodedObject" + "PyUnicodeUCS2_DecodeUTF16" + "PyUnicodeUCS2_EncodeUTF16" + "PyUnicodeUCS2_AsUnicodeEscapeString" + "PyUnicodeUCS2_EncodeUnicodeEscape" + "PyUnicodeUCS2_AsRawUnicodeEscapeString" + "PyUnicodeUCS2_EncodeLatin1" + "PyUnicodeUCS2_EncodeASCII" + "PyUnicodeUCS2_AsCharmapString" + "PyUnicodeUCS2_Partition" + "PyUnicodeUCS2_RPartition" + "PyUnicodeUCS2_Translate" + "PyUnicodeUCS2_Tailmatch" + "PyUnicode_AsDecodedObject" + "PyUnicode_Type" + +; From python26_s.lib(unicodectype) + "_PyUnicode_TypeRecords" + "_PyUnicodeUCS2_ToNumeric" + "_PyUnicodeUCS2_IsLowercase" + "_PyUnicodeUCS2_IsUppercase" + "_PyUnicodeUCS2_IsTitlecase" + "_PyUnicodeUCS2_IsWhitespace" + "_PyUnicodeUCS2_IsLinebreak" + "_PyUnicodeUCS2_ToLowercase" + "_PyUnicodeUCS2_ToUppercase" + "_PyUnicodeUCS2_ToTitlecase" + "_PyUnicodeUCS2_ToDecimalDigit" + "_PyUnicodeUCS2_ToDigit" + "_PyUnicodeUCS2_IsDecimalDigit" + "_PyUnicodeUCS2_IsDigit" + "_PyUnicodeUCS2_IsNumeric" + "_PyUnicodeUCS2_IsAlpha" + +; From python26_s.lib(weakrefobject) + "PyWeakref_NewRef" + "PyWeakref_NewProxy" + "PyObject_ClearWeakRefs" + "PyWeakref_GetObject" + "_PyWeakref_GetWeakrefCount" + "_PyWeakref_ClearRef" + "_PyWeakref_RefType" + "_PyWeakref_ProxyType" + "_PyWeakref_CallableProxyType" + +; From python26_s.lib(Python-ast) +; "init_ast" + "Module" + "Interactive" + "Expression" + "Suite" + "FunctionDef" + "ClassDef" + "Return" + "Delete" + "Assign" + "AugAssign" + "Print" + "For" + "While" + "If" + "With" + "Raise" + "TryExcept" + "TryFinally" + "Assert" + "Import" + "ImportFrom" + "Exec" + "Global" + "Expr" + "Pass" + "Break" + "Continue" + "BoolOp" + "BinOp" + "UnaryOp" + "Lambda" + "IfExp" + "Dict" + "ListComp" + "GeneratorExp" + "Yield" + "Compare" + "Call" + "Repr" + "Num" + "Str" + "Attribute" + "Subscript" + "Name" + "List" + "Tuple" + "Ellipsis" + "Slice" + "ExtSlice" + "Index" + "comprehension" + "excepthandler" + "arguments" + "keyword" + "alias" + "PyAST_mod2obj" + +; From python26_s.lib(asdl) + "asdl_seq_new" + "asdl_int_seq_new" + +; From python26_s.lib(ast) + "PyAST_FromNode" + +; From python26_s.lib(bltinmodule) + "_PyBuiltin_Init" + "Py_FileSystemDefaultEncoding" + +; From python26_s.lib(exceptions) + "PyUnicodeEncodeError_GetStart" + "PyUnicodeDecodeError_GetStart" + "PyUnicodeEncodeError_GetEnd" + "PyUnicodeDecodeError_GetEnd" + "_PyExc_Init" + "PyUnicodeDecodeError_Create" + "PyUnicodeEncodeError_Create" + "PyUnicodeTranslateError_Create" + "PyUnicodeEncodeError_GetEncoding" + "PyUnicodeDecodeError_GetEncoding" + "PyUnicodeEncodeError_GetObject" + "PyUnicodeDecodeError_GetObject" + "PyUnicodeTranslateError_GetObject" + "PyUnicodeTranslateError_GetStart" + "PyUnicodeEncodeError_SetStart" + "PyUnicodeDecodeError_SetStart" + "PyUnicodeTranslateError_SetStart" + "PyUnicodeTranslateError_GetEnd" + "PyUnicodeEncodeError_SetEnd" + "PyUnicodeDecodeError_SetEnd" + "PyUnicodeTranslateError_SetEnd" + "PyUnicodeEncodeError_GetReason" + "PyUnicodeDecodeError_GetReason" + "PyUnicodeTranslateError_GetReason" + "PyUnicodeEncodeError_SetReason" + "PyUnicodeDecodeError_SetReason" + "PyUnicodeTranslateError_SetReason" + "_PyExc_Fini" + "PyExc_BaseException" + "PyExc_Exception" + "PyExc_StandardError" + "PyExc_TypeError" + "PyExc_StopIteration" + "PyExc_GeneratorExit" + "PyExc_SystemExit" + "PyExc_KeyboardInterrupt" + "PyExc_ImportError" + "PyExc_EnvironmentError" + "PyExc_IOError" + "PyExc_OSError" + "PyExc_EOFError" + "PyExc_RuntimeError" + "PyExc_NotImplementedError" + "PyExc_NameError" + "PyExc_UnboundLocalError" + "PyExc_AttributeError" + "PyExc_IndexError" + "PyExc_SyntaxError" + "PyExc_IndentationError" + "PyExc_TabError" + "PyExc_LookupError" + "PyExc_KeyError" + "PyExc_ValueError" + "PyExc_UnicodeError" + "PyExc_UnicodeEncodeError" + "PyExc_UnicodeDecodeError" + "PyExc_UnicodeTranslateError" + "PyExc_AssertionError" + "PyExc_ArithmeticError" + "PyExc_FloatingPointError" + "PyExc_OverflowError" + "PyExc_ZeroDivisionError" + "PyExc_SystemError" + "PyExc_ReferenceError" + "PyExc_MemoryError" + "PyExc_Warning" + "PyExc_UserWarning" + "PyExc_DeprecationWarning" + "PyExc_PendingDeprecationWarning" + "PyExc_SyntaxWarning" + "PyExc_RuntimeWarning" + "PyExc_FutureWarning" + "PyExc_ImportWarning" + "PyExc_MemoryErrorInst" + +; From python26_s.lib(ceval) + "PyEval_EvalFrameEx" + "PyEval_CallObjectWithKeywords" + "PyEval_EvalCodeEx" + "PyEval_GetFrame" + "PyEval_CallObject" + "PyEval_SetProfile" + "PyEval_SetTrace" + "PyEval_GetBuiltins" + "PyEval_GetGlobals" + "PyEval_GetLocals" + "PyEval_GetRestricted" + "PyEval_MergeCompilerFlags" + "Py_FlushLine" + "Py_AddPendingCall" + "Py_MakePendingCalls" + "Py_SetRecursionLimit" + "Py_GetRecursionLimit" + "_Py_CheckRecursiveCall" + "PyEval_GetFuncName" + "PyEval_GetFuncDesc" + "PyEval_GetCallStats" + "PyEval_EvalFrame" + "PyEval_SaveThread" + "PyEval_RestoreThread" + "PyEval_ThreadsInitialized" + "PyEval_InitThreads" + "PyEval_AcquireLock" + "PyEval_ReleaseLock" + "PyEval_AcquireThread" + "PyEval_ReleaseThread" + "PyEval_ReInitThreads" + "_PyEval_SliceIndex" + "PyEval_EvalCode" + "_PyEval_CallTracing" + "_Py_CheckRecursionLimit" + "_Py_CheckInterval" + "_Py_Ticker" + +; From python26_s.lib(compile) + "_Py_Mangle" + "PyAST_Compile" + "PyNode_Compile" + "Py_OptimizeFlag" + +; From python26_s.lib(codecs) + "_PyCodec_Lookup" + "PyCodec_Encode" + "PyCodec_Decode" + "PyCodec_IgnoreErrors" + "PyCodec_ReplaceErrors" + "PyCodec_XMLCharRefReplaceErrors" + "PyCodec_BackslashReplaceErrors" + "PyCodec_Register" + "PyCodec_Encoder" + "PyCodec_Decoder" + "PyCodec_IncrementalEncoder" + "PyCodec_IncrementalDecoder" + "PyCodec_StreamReader" + "PyCodec_StreamWriter" + "PyCodec_RegisterError" + "PyCodec_LookupError" + "PyCodec_StrictErrors" + +; From python26_s.lib(errors) + "PyErr_SetNone" + "PyErr_SetString" + "PyErr_GivenExceptionMatches" + "PyErr_NormalizeException" + "PyErr_Fetch" + "PyErr_Clear" + "PyErr_NoMemory" + "PyErr_SetFromErrnoWithFilenameObject" + "PyErr_Format" + "PyErr_NewException" + "PyErr_WriteUnraisable" + "PyErr_SyntaxLocation" + "PyErr_ProgramText" + "PyErr_SetObject" + "PyErr_Occurred" + "PyErr_Restore" + "PyErr_ExceptionMatches" + "PyErr_BadArgument" + "PyErr_SetFromErrno" + "PyErr_SetFromErrnoWithFilename" + "PyErr_BadInternalCall" + "_PyErr_BadInternalCall" + "PyErr_Warn" + "PyErr_WarnExplicit" + +; From python26_s.lib(frozen) + "PyImport_FrozenModules" + +; From python26_s.lib(frozenmain) + "Py_FrozenMain" + +; From python26_s.lib(future) + "PyFuture_FromAST" + +; From python26_s.lib(getargs) + "PyArg_Parse" + "_PyArg_Parse_SizeT" + "PyArg_ParseTuple" + "_PyArg_ParseTuple_SizeT" + "PyArg_ParseTupleAndKeywords" + "_PyArg_ParseTupleAndKeywords_SizeT" + "PyArg_UnpackTuple" + "_PyArg_NoKeywords" + "PyArg_VaParse" + "PyArg_VaParseTupleAndKeywords" + "_PyArg_VaParse_SizeT" + "_PyArg_VaParseTupleAndKeywords_SizeT" + +; From python26_s.lib(getcompiler) + "Py_GetCompiler" + +; From python26_s.lib(getcopyright) + "Py_GetCopyright" + +; From python26_s.lib(getmtime) + "PyOS_GetLastModificationTime" + +; From python26_s.lib(getplatform) + "Py_GetPlatform" + +; From python26_s.lib(getversion) + "Py_GetVersion" + +; From python26_s.lib(graminit) + "_PyParser_Grammar" + +; From python26_s.lib(import) + "_PyImport_Init" + "_PyImportHooks_Init" + "PyImport_ImportModule" + "PyImport_Cleanup" + "_PyImport_FixupExtension" + "PyImport_AddModule" + "PyImport_ExecCodeModuleEx" + "PyImport_ImportFrozenModule" + "PyImport_ImportModuleEx" + "PyImport_ImportModuleLevel" + "PyImport_ReloadModule" + "PyImport_Import" +; "initimp" + "_PyImport_Fini" + "PyImport_GetMagicNumber" + "PyImport_ExecCodeModule" + "PyImport_GetModuleDict" + "_PyImport_FindModule" + "_PyImport_IsScript" + "_PyImport_ReInitLock" + "_PyImport_FindExtension" + "PyImport_AppendInittab" + "PyImport_ExtendInittab" + "PyImport_Inittab" + "_PyImport_Filetab" + +; From python26_s.lib(importdl) + "_PyImport_LoadDynamicModule" + +; From python26_s.lib(marshal) + "PyMarshal_ReadLongFromFile" + "PyMarshal_WriteObjectToString" + "PyMarshal_WriteLongToFile" + "PyMarshal_WriteObjectToFile" + "PyMarshal_ReadShortFromFile" + "PyMarshal_ReadObjectFromFile" + "PyMarshal_ReadLastObjectFromFile" + "PyMarshal_ReadObjectFromString" + "PyMarshal_Init" + +; From python26_s.lib(modsupport) + "Py_InitModule4" + "Py_BuildValue" + "_Py_BuildValue_SizeT" + "PyEval_CallFunction" + "PyEval_CallMethod" + "_Py_VaBuildValue_SizeT" + "Py_VaBuildValue" + "PyModule_AddObject" + "PyModule_AddIntConstant" + "PyModule_AddStringConstant" + "_Py_PackageContext" + +; From python26_s.lib(mysnprintf) + "PyOS_snprintf" + "PyOS_vsnprintf" + +; From python26_s.lib(mystrtoul) + "PyOS_strtoul" + "PyOS_strtol" + +; From python26_s.lib(pyarena) + "PyArena_New" + "PyArena_Free" + "PyArena_Malloc" + "PyArena_AddPyObject" + +; From python26_s.lib(pyfpe) + "PyFPE_dummy" + +; From python26_s.lib(pystate) + "PyInterpreterState_Clear" + "PyThreadState_Clear" + "_PyThread_CurrentFrames" + "PyGILState_Ensure" + "PyGILState_Release" + "PyInterpreterState_New" + "PyInterpreterState_Delete" + "PyThreadState_Delete" + "PyThreadState_New" + "PyThreadState_DeleteCurrent" + "PyThreadState_Get" + "PyThreadState_Swap" + "PyThreadState_GetDict" + "PyThreadState_SetAsyncExc" + "PyGILState_GetThisThreadState" + "PyInterpreterState_Head" + "PyInterpreterState_Next" + "PyInterpreterState_ThreadHead" + "PyThreadState_Next" + "_PyGILState_Init" + "_PyGILState_Fini" + "_PyThreadState_Current" + "_PyThreadState_GetFrame" + +; From python26_s.lib(pystrtod) + "PyOS_ascii_strtod" + "PyOS_ascii_formatd" + "PyOS_ascii_atof" + +; From python26_s.lib(pythonrun) + "Py_IgnoreEnvironmentFlag" + "Py_DebugFlag" + "Py_VerboseFlag" + "Py_NoSiteFlag" + "Py_InteractiveFlag" + "Py_FrozenFlag" + "Py_InitializeEx" + "Py_FatalError" + "Py_NewInterpreter" + "PyErr_Print" + "PyRun_InteractiveOneFlags" + "PyParser_ASTFromFile" + "PyRun_SimpleFileExFlags" + "PyRun_FileExFlags" + "Py_Exit" + "PyErr_PrintEx" + "PyErr_Display" + "Py_SetProgramName" + "Py_GetProgramName" + "Py_SetPythonHome" + "Py_GetPythonHome" + "Py_Initialize" + "Py_Finalize" + "Py_IsInitialized" + "Py_EndInterpreter" + "PyRun_AnyFileFlags" + "Py_FdIsInteractive" + "PyRun_InteractiveLoopFlags" + "PyRun_AnyFileExFlags" + "PyRun_SimpleStringFlags" + "PyRun_StringFlags" + "PyParser_ASTFromString" + "PyParser_SimpleParseStringFlags" + "PyParser_SimpleParseFileFlags" + "Py_CompileStringFlags" + "Py_SymtableString" + "Py_AtExit" + "PyOS_getsig" + "PyOS_setsig" + "PyParser_SetError" + "PyModule_GetWarningsModule" + "PyParser_SimpleParseStringFlagsFilename" + "PyParser_SimpleParseStringFilename" + "PyParser_SimpleParseFile" + "PyParser_SimpleParseString" + "PyRun_AnyFile" + "PyRun_AnyFileEx" + "PyRun_File" + "PyRun_FileEx" + "PyRun_FileFlags" + "PyRun_SimpleFile" + "PyRun_SimpleFileEx" + "PyRun_String" + "PyRun_SimpleString" + "Py_CompileString" + "PyRun_InteractiveOne" + "PyRun_InteractiveLoop" + "Py_UseClassExceptionsFlag" + "Py_UnicodeFlag" + "_Py_QnewFlag" + +; From python26_s.lib(structmember) + "PyMember_Get" + "PyMember_GetOne" + "PyMember_SetOne" + "PyMember_Set" + +; From python26_s.lib(symtable) + "PySymtable_Build" + "PySymtable_Free" + "PyST_GetScope" + "PySymtable_Lookup" + "PySTEntry_Type" + +; From python26_s.lib(sysmodule) + "_PySys_Init" + "PySys_WriteStderr" + "PySys_SetPath" + "PySys_SetArgv" + "PySys_WriteStdout" + "Py_SubversionRevision" + "Py_SubversionShortBranch" + "PySys_GetObject" + "PySys_SetObject" + "PySys_GetFile" + "PySys_ResetWarnOptions" + "PySys_AddWarnOption" + +; From python26_s.lib(traceback) + "PyTraceBack_Here" + "PyTraceBack_Print" + "PyTraceBack_Type" + +; From python26_s.lib(getopt) + "_PyOS_GetOpt" + "_PyOS_opterr" + "_PyOS_optind" + "_PyOS_optarg" + +; From python26_s.lib(dynload_shlib) + "_PyImport_DynLoadFiletab" + "_PyImport_GetDynLoadFunc" + +; From python26_s.lib(thread) + "PyThread_delete_key_value" + "PyThread_init_thread" + "PyThread_start_new_thread" + "PyThread_exit_thread" + "PyThread_get_thread_ident" + "PyThread_allocate_lock" + "PyThread_free_lock" + "PyThread_acquire_lock" + "PyThread_release_lock" + "PyThread_get_stacksize" + "PyThread_set_stacksize" + "PyThread_create_key" + "PyThread_delete_key" + "PyThread_set_key_value" + "PyThread_get_key_value" + "PyThread__exit_thread" + +; From python26_s.lib(gcmodule) +; "initgc" + "_PyObject_GC_New" + "_PyObject_GC_NewVar" + "PyGC_Collect" + "_PyObject_GC_Resize" + "_PyObject_GC_Malloc" + "PyObject_GC_Track" + "PyObject_GC_UnTrack" + "PyObject_GC_Del" + "_PyGC_Dump" + "_PyObject_GC_Track" + "_PyObject_GC_UnTrack" + "_PyObject_GC_Del" + "_PyGC_generation0" + +; From python26_s.lib(signalmodule) +; "initsignal" + "PyErr_CheckSignals" + "PyErr_SetInterrupt" + "PyOS_FiniInterrupts" + "PyOS_InterruptOccurred" + "PyOS_InitInterrupts" + "PyOS_AfterFork" + +; From python26_s.lib(posixmodule) +; "initos2" + +; From python26_s.lib(threadmodule) +; "initthread" + +; From python26_s.lib(arraymodule) +; "initarray" +; "array_methods" + +; From python26_s.lib(binascii) +; "initbinascii" + +; From python26_s.lib(cmathmodule) +; "initcmath" + +; From python26_s.lib(_codecsmodule) +; "init_codecs" + +; From python26_s.lib(collectionsmodule) +; "initcollections" + "dequeiter_type" + "dequereviter_type" + +; From python26_s.lib(cPickle) +; "initcPickle" +; "fast_save_leave" + +; From python26_s.lib(cStringIO) +; "initcStringIO" + +; From python26_s.lib(_csv) +; "init_csv" + +; From python26_s.lib(datetimemodule) +; "initdatetime" + +; From python26_s.lib(dlmodule) +; "initdl" + +; From python26_s.lib(errnomodule) +; "initerrno" + +; From python26_s.lib(fcntlmodule) +; "initfcntl" + +; From python26_s.lib(_functoolsmodule) +; "init_functools" + +; From python26_s.lib(_heapqmodule) +; "init_heapq" + +; From python26_s.lib(imageop) +; "initimageop" + +; From python26_s.lib(itertoolsmodule) +; "inititertools" + +; From python26_s.lib(_localemodule) +; "init_locale" + +; From python26_s.lib(mathmodule) +; "initmath" + +; From python26_s.lib(md5) + "md5_finish" + "md5_init" + "md5_append" + +; From python26_s.lib(md5module) +; "init_md5" + +; From python26_s.lib(operator) +; "initoperator" + +; From python26_s.lib(_randommodule) +; "init_random" + +; From python26_s.lib(rgbimgmodule) +; "initrgbimg" + +; From python26_s.lib(shamodule) +; "init_sha" + +; From python26_s.lib(sha256module) +; "init_sha256" + +; From python26_s.lib(sha512module) +; "init_sha512" + +; From python26_s.lib(_sre) +; "init_sre" + +; From python26_s.lib(stropmodule) +; "initstrop" + +; From python26_s.lib(_struct) +; "init_struct" + +; From python26_s.lib(symtablemodule) +; "init_symtable" + +; From python26_s.lib(termios) +; "inittermios" + +; From python26_s.lib(timemodule) +; "inittime" + "_PyTime_DoubleToTimet" +; "inittimezone" + +; From python26_s.lib(timingmodule) +; "inittiming" + +; From python26_s.lib(_weakref) +; "init_weakref" + +; From python26_s.lib(xxsubtype) +; "initxxsubtype" + +; From python26_s.lib(zipimport) +; "initzipimport" Modified: python/branches/py3k/PCbuild/_bsddb.vcproj ============================================================================== --- python/branches/py3k/PCbuild/_bsddb.vcproj (original) +++ python/branches/py3k/PCbuild/_bsddb.vcproj Sun Feb 3 17:51:08 2008 @@ -52,7 +52,7 @@ /> Options -> Projects and Solutions -> VC++ Directories, + Platform: Win32, Show directories for: Executable files). The _bsddb subprojects depends only on the db_static project of Berkeley DB. You have to choose either "Release", "Release AMD64", "Debug" Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Sun Feb 3 17:51:08 2008 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 60476 . +# From configure.in Revision: 60489 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -1312,7 +1312,7 @@ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-universalsdk[SDKDIR] - Build agains Mac OS X 10.4u SDK (ppc/i386) + Build against Mac OS X 10.4u SDK (ppc/i386) --enable-framework[=INSTALLDIR] Build (MacOSX|Darwin) framework --enable-shared disable/enable building shared python library Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Sun Feb 3 17:51:08 2008 @@ -61,7 +61,7 @@ CONFIG_ARGS="$ac_configure_args" AC_ARG_ENABLE(universalsdk, - AC_HELP_STRING(--enable-universalsdk@<:@SDKDIR@:>@, Build agains Mac OS X 10.4u SDK (ppc/i386)), + AC_HELP_STRING(--enable-universalsdk@<:@SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)), [ case $enableval in yes) Modified: python/branches/py3k/setup.py ============================================================================== --- python/branches/py3k/setup.py (original) +++ python/branches/py3k/setup.py Sun Feb 3 17:51:08 2008 @@ -327,7 +327,7 @@ parser.add_option(arg_name, dest="dirs", action="append") options = parser.parse_args(env_val.split())[0] if options.dirs: - for directory in options.dirs: + for directory in reversed(options.dirs): add_dir_to_list(dir_list, directory) if os.path.normpath(sys.prefix) != '/usr': @@ -698,10 +698,10 @@ for dn in inc_dirs: std_variants.append(os.path.join(dn, 'db3')) std_variants.append(os.path.join(dn, 'db4')) - for x in (0,1,2,3,4,5,6): + for x in range(max_db_ver[1]+1): std_variants.append(os.path.join(dn, "db4%d"%x)) std_variants.append(os.path.join(dn, "db4.%d"%x)) - for x in (2,3): + for x in (3,): std_variants.append(os.path.join(dn, "db3%d"%x)) std_variants.append(os.path.join(dn, "db3.%d"%x)) From python-3000-checkins at python.org Sun Feb 3 18:32:14 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 3 Feb 2008 18:32:14 +0100 (CET) Subject: [Python-3000-checkins] r60554 - python/branches/py3k/Lib/test/test_socketserver.py Message-ID: <20080203173214.1E4EC1E403B@bag.python.org> Author: christian.heimes Date: Sun Feb 3 18:32:13 2008 New Revision: 60554 Modified: python/branches/py3k/Lib/test/test_socketserver.py Log: Fixed socketserver tests Modified: python/branches/py3k/Lib/test/test_socketserver.py ============================================================================== --- python/branches/py3k/Lib/test/test_socketserver.py (original) +++ python/branches/py3k/Lib/test/test_socketserver.py Sun Feb 3 18:32:13 2008 @@ -190,28 +190,28 @@ for svrcls in servers: addr = self.pickaddr(proto) if verbose: - print "ADDR =", addr - print "CLASS =", svrcls + print("ADDR =", addr) + print("CLASS =", svrcls) t = ServerThread(addr, svrcls, hdlrcls) - if verbose: print "server created" + if verbose: print("server created") t.start() - if verbose: print "server running" + if verbose: print("server running") for i in range(NREQ): t.ready.wait(10*DELAY) self.assert_(t.ready.isSet(), "Server not ready within a reasonable time") - if verbose: print "test client", i + if verbose: print("test client", i) testfunc(proto, addr) - if verbose: print "waiting for server" + if verbose: print("waiting for server") t.join() - if verbose: print "done" + if verbose: print("done") def stream_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_STREAM) s.connect(addr) s.sendall(TEST_STR) buf = data = receive(s, 100) - while data and '\n' not in buf: + while data and b'\n' not in buf: data = receive(s, 100) buf += data self.assertEquals(buf, TEST_STR) @@ -221,7 +221,7 @@ s = socket.socket(proto, socket.SOCK_DGRAM) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) - while data and '\n' not in buf: + while data and b'\n' not in buf: data = receive(s, 100) buf += data self.assertEquals(buf, TEST_STR) From python-3000-checkins at python.org Mon Feb 4 19:48:50 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 4 Feb 2008 19:48:50 +0100 (CET) Subject: [Python-3000-checkins] r60569 - in python/branches/py3k: Doc/c-api/float.rst Doc/c-api/set.rst Doc/library/sys.rst Include/abstract.h Include/floatobject.h Include/setobject.h Lib/rational.py Lib/test/regrtest.py Lib/test/test_builtin.py Lib/test/test_mailbox.py Lib/test/test_socketserver.py Lib/test/test_sys.py Misc/build.sh Modules/posixmodule.c Objects/abstract.c Objects/floatobject.c Objects/setobject.c Python/sysmodule.c Message-ID: <20080204184850.B05D21E4026@bag.python.org> Author: christian.heimes Date: Mon Feb 4 19:48:49 2008 New Revision: 60569 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/float.rst python/branches/py3k/Doc/c-api/set.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Include/abstract.h python/branches/py3k/Include/floatobject.h python/branches/py3k/Include/setobject.h python/branches/py3k/Lib/rational.py python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_mailbox.py python/branches/py3k/Lib/test/test_socketserver.py python/branches/py3k/Lib/test/test_sys.py python/branches/py3k/Misc/build.sh python/branches/py3k/Modules/posixmodule.c python/branches/py3k/Objects/abstract.c python/branches/py3k/Objects/floatobject.c python/branches/py3k/Objects/setobject.c python/branches/py3k/Python/sysmodule.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552-60567 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60553 | neal.norwitz | 2008-02-03 17:53:09 +0100 (Sun, 03 Feb 2008) | 1 line Ignore leaky warnings from test_asynchat ........ r60555 | christian.heimes | 2008-02-03 20:51:13 +0100 (Sun, 03 Feb 2008) | 1 line Another int -> pid_t case ........ r60560 | amaury.forgeotdarc | 2008-02-03 23:51:43 +0100 (Sun, 03 Feb 2008) | 6 lines Ensure that PySet_Add() operates on a newly created frozenset, like PyTuple_SetItem does. Add PyFrozenSet_Check(), which was not needed before; The list of Py*Set_Check* macros seems to be complete now. Add missing NEWS entries about all this. ........ r60563 | amaury.forgeotdarc | 2008-02-04 00:14:32 +0100 (Mon, 04 Feb 2008) | 2 lines Nasty typo in setobject.h ........ r60564 | amaury.forgeotdarc | 2008-02-04 00:15:32 +0100 (Mon, 04 Feb 2008) | 3 lines Correct test_mailbox on win32: since the test sets a custom 'colon' attribute to the main mailbox, copy it to secondary mailbox instances. ........ r60565 | amaury.forgeotdarc | 2008-02-04 00:57:24 +0100 (Mon, 04 Feb 2008) | 2 lines Let test_socketserver pass on win32, which does not have AF_UNIX sockets. ........ r60566 | jeffrey.yasskin | 2008-02-04 02:04:35 +0100 (Mon, 04 Feb 2008) | 2 lines Make int() and long() fall back to __trunc__(). See issue 2002. ........ r60567 | christian.heimes | 2008-02-04 19:00:12 +0100 (Mon, 04 Feb 2008) | 3 lines Patch #1953 I implemented the function sys._compact_freelists() and C API functions PyInt_/PyFloat_CompactFreeList() to compact the pre-allocated blocks of ints and floats. They allow the user to reduce the memory usage of a Python process that deals with lots of numbers. The patch also renames sys._cleartypecache to sys._clear_type_cache ........ Modified: python/branches/py3k/Doc/c-api/float.rst ============================================================================== --- python/branches/py3k/Doc/c-api/float.rst (original) +++ python/branches/py3k/Doc/c-api/float.rst Mon Feb 4 19:48:49 2008 @@ -72,3 +72,9 @@ .. cfunction:: double PyFloat_GetMin(void) Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`. + +.. cfunction:: void PyFloat_CompactFreeList(size_t *bc, size_t *bf, size_t *sum) + + Compact the float free list. *bc* is the number of allocated blocks before + blocks are freed, *bf* is the number of freed blocks and *sum* is the number + of remaining objects in the blocks. Modified: python/branches/py3k/Doc/c-api/set.rst ============================================================================== --- python/branches/py3k/Doc/c-api/set.rst (original) +++ python/branches/py3k/Doc/c-api/set.rst Mon Feb 4 19:48:49 2008 @@ -56,6 +56,13 @@ .. versionadded:: 2.6 +.. cfunction:: int PyFrozenSet_Check(PyObject *p) + + Return true if *p* is a :class:`frozenset` object or an instance of a + subtype. + + .. versionadded:: 2.6 + .. cfunction:: int PyAnySet_Check(PyObject *p) Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or an Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Mon Feb 4 19:48:49 2008 @@ -54,9 +54,28 @@ A string containing the copyright pertaining to the Python interpreter. -.. function:: _cleartypecache() +.. function:: _compact_freelists() - Clear the internal type lookup cache. + Compact the free list of floats by deallocating unused blocks. + It can reduce the memory usage of the Python process several tenth of + thousands of integers or floats have been allocated at once. + + The return value is a tuple of tuples each containing three elements, + amount of used objects, total block count before the blocks are deallocated + and amount of freed blocks. + + This function should be used for specialized purposes only. + + .. versionadded:: 2.6 + + +.. function:: _clear_type_cache() + + Clear the internal type cache. The type cache is used to speed up attribute + and method lookups. Use the function *only* to drop unnecessary references + during reference leak debugging. + + This function should be used for internal and specialized purposes only. .. versionadded:: 2.6 Modified: python/branches/py3k/Include/abstract.h ============================================================================== --- python/branches/py3k/Include/abstract.h (original) +++ python/branches/py3k/Include/abstract.h Mon Feb 4 19:48:49 2008 @@ -793,6 +793,19 @@ PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc); /* + Returns the Integral instance converted to an int. The + instance is expected to be int or long or have an __int__ + method. Steals integral's reference. error_format will be + used to create the TypeError if integral isn't actually an + Integral instance. error_format should be a format string + that can accept a char* naming integral's type. + */ + + PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt( + PyObject *integral, + const char* error_format); + + /* Returns the object converted to Py_ssize_t by going through PyNumber_Index first. If an overflow error occurs while converting the int-or-long to Py_ssize_t, then the second argument Modified: python/branches/py3k/Include/floatobject.h ============================================================================== --- python/branches/py3k/Include/floatobject.h (original) +++ python/branches/py3k/Include/floatobject.h Mon Feb 4 19:48:49 2008 @@ -91,6 +91,9 @@ PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le); PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le); +/* free list api */ +PyAPI_FUNC(void) PyFloat_CompactFreeList(size_t *, size_t *, size_t *); + #ifdef __cplusplus } #endif Modified: python/branches/py3k/Include/setobject.h ============================================================================== --- python/branches/py3k/Include/setobject.h (original) +++ python/branches/py3k/Include/setobject.h Mon Feb 4 19:48:49 2008 @@ -75,7 +75,11 @@ PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) #define PySet_Check(ob) \ - (Py_TYPE(ob) == &PySet_Type || PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) + (Py_TYPE(ob) == &PySet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) +#define PyFrozenSet_Check(ob) \ + (Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) PyAPI_FUNC(PyObject *) PySet_New(PyObject *); PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); Modified: python/branches/py3k/Lib/rational.py ============================================================================== --- python/branches/py3k/Lib/rational.py (original) +++ python/branches/py3k/Lib/rational.py Mon Feb 4 19:48:49 2008 @@ -406,8 +406,6 @@ else: return a.numerator // a.denominator - __int__ = __trunc__ - def __floor__(a): """Will be math.floor(a) in 3.0.""" return a.numerator // a.denominator Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Mon Feb 4 19:48:49 2008 @@ -753,7 +753,7 @@ sys.path_importer_cache.update(pic) # clear type cache - sys._cleartypecache() + sys._clear_type_cache() # Clear ABC registries, restoring previously saved ABC registries. for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Mon Feb 4 19:48:49 2008 @@ -861,6 +861,14 @@ def test_intconversion(self): # Test __int__() + class ClassicMissingMethods: + pass + self.assertRaises(TypeError, int, ClassicMissingMethods()) + + class MissingMethods(object): + pass + self.assertRaises(TypeError, int, MissingMethods()) + class Foo0: def __int__(self): return 42 @@ -892,6 +900,49 @@ self.assertEqual(int(Foo4()), 42) self.assertRaises(TypeError, int, Foo5()) + class Classic: + pass + for base in (object, Classic): + class IntOverridesTrunc(base): + def __int__(self): + return 42 + def __trunc__(self): + return -12 + self.assertEqual(int(IntOverridesTrunc()), 42) + + class JustTrunc(base): + def __trunc__(self): + return 42 + self.assertEqual(int(JustTrunc()), 42) + + for trunc_result_base in (object, Classic): + class Integral(trunc_result_base): + def __int__(self): + return 42 + + class TruncReturnsNonInt(base): + def __trunc__(self): + return Integral() + self.assertEqual(int(TruncReturnsNonInt()), 42) + + class NonIntegral(trunc_result_base): + def __trunc__(self): + # Check that we avoid infinite recursion. + return NonIntegral() + + class TruncReturnsNonIntegral(base): + def __trunc__(self): + return NonIntegral() + try: + int(TruncReturnsNonIntegral()) + except TypeError as e: + self.assertEquals(str(e), + "__trunc__ returned non-Integral" + " (type NonIntegral)") + else: + self.fail("Failed to raise TypeError with %s" % + ((base, trunc_result_base),)) + def test_iter(self): self.assertRaises(TypeError, iter) self.assertRaises(TypeError, iter, 42, 42) @@ -1095,7 +1146,6 @@ self.assertEqual(int('2br45qc', 35), 4294967297) self.assertEqual(int('1z141z5', 36), 4294967297) - def test_longconversion(self): # Test __long__() class Foo0: Modified: python/branches/py3k/Lib/test/test_mailbox.py ============================================================================== --- python/branches/py3k/Lib/test/test_mailbox.py (original) +++ python/branches/py3k/Lib/test/test_mailbox.py Mon Feb 4 19:48:49 2008 @@ -517,6 +517,7 @@ class FakeMessage(mailbox.MaildirMessage): pass box = mailbox.Maildir(self._path, factory=FakeMessage) + box.colon = self._box.colon msg2 = box.get_message(key) self.assert_(isinstance(msg2, FakeMessage)) Modified: python/branches/py3k/Lib/test/test_socketserver.py ============================================================================== --- python/branches/py3k/Lib/test/test_socketserver.py (original) +++ python/branches/py3k/Lib/test/test_socketserver.py Mon Feb 4 19:48:49 2008 @@ -51,13 +51,14 @@ SocketServer.DatagramRequestHandler): pass -class ForkingUnixStreamServer(SocketServer.ForkingMixIn, - SocketServer.UnixStreamServer): - pass - -class ForkingUnixDatagramServer(SocketServer.ForkingMixIn, - SocketServer.UnixDatagramServer): - pass +if HAVE_UNIX_SOCKETS: + class ForkingUnixStreamServer(SocketServer.ForkingMixIn, + SocketServer.UnixStreamServer): + pass + + class ForkingUnixDatagramServer(SocketServer.ForkingMixIn, + SocketServer.UnixDatagramServer): + pass class MyMixinServer: Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Mon Feb 4 19:48:49 2008 @@ -330,6 +330,20 @@ self.assertEqual(type(getattr(sys.flags, attr)), int, attr) self.assert_(repr(sys.flags)) + def test_clear_type_cache(self): + sys._clear_type_cache() + + def test_compact_freelists(self): + sys._compact_freelists() + r = sys._compact_freelists() + # freed blocks shouldn't change + self.assertEqual(r[0][2], 0) + # fill freelists + floats = [float(i) for i in range(12000)] + del floats + # should free more than 200 blocks + r = sys._compact_freelists() + self.assert_(r[0][2] > 200, r[0][2]) def test_main(): test.test_support.run_unittest(SysModuleTest) Modified: python/branches/py3k/Misc/build.sh ============================================================================== --- python/branches/py3k/Misc/build.sh (original) +++ python/branches/py3k/Misc/build.sh Mon Feb 4 19:48:49 2008 @@ -67,7 +67,7 @@ # Note: test_XXX (none currently) really leak, but are disabled # so we don't send spam. Any test which really leaks should only # be listed here if there are also test cases under Lib/test/leakers. -LEAKY_TESTS="test_(cmd_line|popen2|socket|sys|threadsignals|urllib2_localnet)" +LEAKY_TESTS="test_(asynchat|cmd_line|popen2|socket|sys|threadsignals|urllib2_localnet)" # These tests always fail, so skip them so we don't get false positives. _ALWAYS_SKIP="" Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Mon Feb 4 19:48:49 2008 @@ -4626,7 +4626,8 @@ static PyObject * posix_tcgetpgrp(PyObject *self, PyObject *args) { - int fd, pgid; + int fd; + pid_t pgid; if (!PyArg_ParseTuple(args, "i:tcgetpgrp", &fd)) return NULL; pgid = tcgetpgrp(fd); Modified: python/branches/py3k/Objects/abstract.c ============================================================================== --- python/branches/py3k/Objects/abstract.c (original) +++ python/branches/py3k/Objects/abstract.c Mon Feb 4 19:48:49 2008 @@ -1242,6 +1242,40 @@ } +PyObject * +_PyNumber_ConvertIntegralToInt(PyObject *integral, const char* error_format) +{ + static PyObject *int_name = NULL; + if (int_name == NULL) { + int_name = PyUnicode_InternFromString("__int__"); + if (int_name == NULL) + return NULL; + } + + if (integral && !PyLong_Check(integral)) { + /* Don't go through tp_as_number->nb_int to avoid + hitting the classic class fallback to __trunc__. */ + PyObject *int_func = PyObject_GetAttr(integral, int_name); + if (int_func == NULL) { + PyErr_Clear(); /* Raise a different error. */ + goto non_integral_error; + } + Py_DECREF(integral); + integral = PyEval_CallObject(int_func, NULL); + Py_DECREF(int_func); + if (integral && !PyLong_Check(integral)) { + goto non_integral_error; + } + } + return integral; + +non_integral_error: + PyErr_Format(PyExc_TypeError, error_format, Py_TYPE(integral)->tp_name); + Py_DECREF(integral); + return NULL; +} + + /* Add a check for embedded NULL-bytes in the argument. */ static PyObject * long_from_string(const char *s, Py_ssize_t len) @@ -1265,9 +1299,17 @@ PyNumber_Long(PyObject *o) { PyNumberMethods *m; + static PyObject *trunc_name = NULL; + PyObject *trunc_func; const char *buffer; Py_ssize_t buffer_len; + if (trunc_name == NULL) { + trunc_name = PyUnicode_InternFromString("__trunc__"); + if (trunc_name == NULL) + return NULL; + } + if (o == NULL) return null_error(); if (PyLong_CheckExact(o)) { @@ -1287,6 +1329,7 @@ return res; } if (m && m->nb_long) { /* This should include subclasses of long */ + /* Classic classes always take this branch. */ PyObject *res = m->nb_long(o); if (res && !PyLong_Check(res)) { PyErr_Format(PyExc_TypeError, @@ -1299,6 +1342,27 @@ } if (PyLong_Check(o)) /* A long subclass without nb_long */ return _PyLong_Copy((PyLongObject *)o); + trunc_func = PyObject_GetAttr(o, trunc_name); + if (trunc_func) { + PyObject *truncated = PyEval_CallObject(trunc_func, NULL); + PyObject *int_instance; + Py_DECREF(trunc_func); + /* __trunc__ is specified to return an Integral type, + but long() needs to return a long. */ + int_instance = _PyNumber_ConvertIntegralToInt( + truncated, + "__trunc__ returned non-Integral (type %.200s)"); + return int_instance; + } + PyErr_Clear(); /* It's not an error if o.__trunc__ doesn't exist. */ + + if (PyString_Check(o)) + /* need to do extra error checking that PyLong_FromString() + * doesn't do. In particular long('9.5') must raise an + * exception, not truncate the float. + */ + return long_from_string(PyString_AS_STRING(o), + PyString_GET_SIZE(o)); if (PyUnicode_Check(o)) /* The above check is done in PyLong_FromUnicode(). */ return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o), Modified: python/branches/py3k/Objects/floatobject.c ============================================================================== --- python/branches/py3k/Objects/floatobject.c (original) +++ python/branches/py3k/Objects/floatobject.c Mon Feb 4 19:48:49 2008 @@ -1540,17 +1540,15 @@ } void -PyFloat_Fini(void) +PyFloat_CompactFreeList(size_t *pbc, size_t *pbf, size_t *bsum) { PyFloatObject *p; PyFloatBlock *list, *next; unsigned i; - int bc, bf; /* block count, number of freed blocks */ - int frem, fsum; /* remaining unfreed floats per block, total */ + size_t bc = 0, bf = 0; /* block count, number of freed blocks */ + size_t fsum = 0; /* total unfreed ints */ + int frem; /* remaining unfreed ints per block */ - bc = 0; - bf = 0; - fsum = 0; list = block_list; block_list = NULL; free_list = NULL; @@ -1585,6 +1583,22 @@ fsum += frem; list = next; } + *pbc = bc; + *pbf = bf; + *bsum = fsum; +} + +void +PyFloat_Fini(void) +{ + PyFloatObject *p; + PyFloatBlock *list; + unsigned i; + size_t bc, bf; /* block count, number of freed blocks */ + size_t fsum; /* total unfreed floats per block */ + + PyFloat_CompactFreeList(&bc, &bf, &fsum); + if (!Py_VerboseFlag) return; fprintf(stderr, "# cleanup floats"); @@ -1593,7 +1607,9 @@ } else { fprintf(stderr, - ": %d unfreed float%s in %d out of %d block%s\n", + ": %" PY_FORMAT_SIZE_T "d unfreed floats%s in %" + PY_FORMAT_SIZE_T "d out of %" + PY_FORMAT_SIZE_T "d block%s\n", fsum, fsum == 1 ? "" : "s", bc - bf, bc, bc == 1 ? "" : "s"); } Modified: python/branches/py3k/Objects/setobject.c ============================================================================== --- python/branches/py3k/Objects/setobject.c (original) +++ python/branches/py3k/Objects/setobject.c Mon Feb 4 19:48:49 2008 @@ -2173,7 +2173,8 @@ int PySet_Add(PyObject *anyset, PyObject *key) { - if (!PyAnySet_Check(anyset)) { + if (!PySet_Check(anyset) && + (!PyFrozenSet_Check(anyset) || Py_REFCNT(anyset) != 1)) { PyErr_BadInternalCall(); return -1; } @@ -2277,6 +2278,10 @@ f = PyFrozenSet_New(dup); assertRaises(PySet_Clear(f) == -1, PyExc_SystemError); assertRaises(_PySet_Update(f, dup) == -1, PyExc_SystemError); + assert(PySet_Add(f, elem) == 0); + Py_INCREF(f); + assertRaises(PySet_Add(f, elem) == -1, PyExc_SystemError); + Py_DECREF(f); Py_DECREF(f); /* Exercise direct iteration */ Modified: python/branches/py3k/Python/sysmodule.c ============================================================================== --- python/branches/py3k/Python/sysmodule.c (original) +++ python/branches/py3k/Python/sysmodule.c Mon Feb 4 19:48:49 2008 @@ -730,17 +730,6 @@ 10. Number of stack pops performed by call_function()" ); -static PyObject * -sys_cleartypecache(PyObject* self, PyObject* args) -{ - PyType_ClearCache(); - Py_RETURN_NONE; -} - -PyDoc_STRVAR(cleartypecache_doc, -"_cleartypecache() -> None\n\ -Clear the internal type lookup cache."); - #ifdef __cplusplus extern "C" { #endif @@ -759,12 +748,41 @@ } #endif +static PyObject * +sys_clear_type_cache(PyObject* self, PyObject* args) +{ + PyType_ClearCache(); + Py_RETURN_NONE; +} + +PyDoc_STRVAR(sys_clear_type_cache__doc__, +"_clear_type_cache() -> None\n\ +Clear the internal type lookup cache."); + + +static PyObject * +sys_compact_freelists(PyObject* self, PyObject* args) +{ + size_t fsum, fbc, fbf; + + PyFloat_CompactFreeList(&fbc, &fbf, &fsum); + + return Py_BuildValue("((kkk))", fsum, fbc, fbf); + +} + +PyDoc_STRVAR(sys_compact_freelists__doc__, +"_compact_freelists() -> ((remaing_objects, total_blocks, freed_blocks),)\n\ +Compact the free lists of floats."); + static PyMethodDef sys_methods[] = { /* Might as well keep this in alphabetic order */ {"callstats", (PyCFunction)PyEval_GetCallStats, METH_NOARGS, callstats_doc}, - {"_cleartypecache", sys_cleartypecache, METH_NOARGS, - cleartypecache_doc}, + {"_clear_type_cache", sys_clear_type_cache, METH_NOARGS, + sys_clear_type_cache__doc__}, + {"_compact_freelists", sys_compact_freelists, METH_NOARGS, + sys_compact_freelists__doc__}, {"_current_frames", sys_current_frames, METH_NOARGS, current_frames_doc}, {"displayhook", sys_displayhook, METH_O, displayhook_doc}, From python-3000-checkins at python.org Mon Feb 4 21:44:32 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Mon, 4 Feb 2008 21:44:32 +0100 (CET) Subject: [Python-3000-checkins] r60571 - in python/branches/py3k/Lib: _abcoll.py bsddb/dbshelve.py dumbdbm.py shelve.py Message-ID: <20080204204432.3E1DA1E4006@bag.python.org> Author: raymond.hettinger Date: Mon Feb 4 21:44:31 2008 New Revision: 60571 Modified: python/branches/py3k/Lib/_abcoll.py python/branches/py3k/Lib/bsddb/dbshelve.py python/branches/py3k/Lib/dumbdbm.py python/branches/py3k/Lib/shelve.py Log: Start replacing UserDict.DictMixin with collections.MutableMapping (the bsddb modules are next). Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Mon Feb 4 21:44:31 2008 @@ -378,6 +378,11 @@ def values(self): return ValuesView(self) + def __eq__(self, other): + return set(self) == set(other) + + def __ne__(self, other): + return set(self) == set(other) class MappingView(metaclass=ABCMeta): @@ -485,6 +490,13 @@ for key, value in kwds.items(): self[key] = value + def setdefault(self, key, default=None): + try: + return self[key] + except KeyError: + self[key] = default + return default + MutableMapping.register(dict) Modified: python/branches/py3k/Lib/bsddb/dbshelve.py ============================================================================== --- python/branches/py3k/Lib/bsddb/dbshelve.py (original) +++ python/branches/py3k/Lib/bsddb/dbshelve.py Mon Feb 4 21:44:31 2008 @@ -38,12 +38,12 @@ HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL def _dumps(object, protocol): return pickle.dumps(object, protocol=protocol) - from UserDict import DictMixin + from collections import MutableMapping else: HIGHEST_PROTOCOL = None def _dumps(object, protocol): return pickle.dumps(object, bin=protocol) - class DictMixin: pass + class MutableMapping: pass from . import db Modified: python/branches/py3k/Lib/dumbdbm.py ============================================================================== --- python/branches/py3k/Lib/dumbdbm.py (original) +++ python/branches/py3k/Lib/dumbdbm.py Mon Feb 4 21:44:31 2008 @@ -23,13 +23,13 @@ import io as _io import os as _os -import UserDict +import collections _BLOCKSIZE = 512 error = IOError # For anydbm -class _Database(UserDict.DictMixin): +class _Database(collections.MutableMapping): # The on-disk directory and data files can remain in mutually # inconsistent states for an arbitrarily long time (see comments Modified: python/branches/py3k/Lib/shelve.py ============================================================================== --- python/branches/py3k/Lib/shelve.py (original) +++ python/branches/py3k/Lib/shelve.py Mon Feb 4 21:44:31 2008 @@ -59,12 +59,12 @@ from pickle import Pickler, Unpickler from io import BytesIO -import UserDict +import collections import warnings __all__ = ["Shelf","BsdDbShelf","DbfilenameShelf","open"] -class Shelf(UserDict.DictMixin): +class Shelf(collections.MutableMapping): """Base class for shelf implementations. This is initialized with a dictionary-like object. @@ -81,7 +81,7 @@ self.cache = {} self.keyencoding = "utf-8" - def keys(self): + def __iter__(self): for k in self.dict.keys(): yield k.decode(self.keyencoding) From python-3000-checkins at python.org Mon Feb 4 21:50:22 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Mon, 4 Feb 2008 21:50:22 +0100 (CET) Subject: [Python-3000-checkins] r60572 - python/branches/py3k/Lib/bsddb/dbshelve.py Message-ID: <20080204205022.F090B1E4006@bag.python.org> Author: raymond.hettinger Date: Mon Feb 4 21:50:22 2008 New Revision: 60572 Modified: python/branches/py3k/Lib/bsddb/dbshelve.py Log: Save bsddb changes for a separate check-in. Modified: python/branches/py3k/Lib/bsddb/dbshelve.py ============================================================================== --- python/branches/py3k/Lib/bsddb/dbshelve.py (original) +++ python/branches/py3k/Lib/bsddb/dbshelve.py Mon Feb 4 21:50:22 2008 @@ -38,12 +38,12 @@ HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL def _dumps(object, protocol): return pickle.dumps(object, protocol=protocol) - from collections import MutableMapping + from UserDict import DictMixin else: HIGHEST_PROTOCOL = None def _dumps(object, protocol): return pickle.dumps(object, bin=protocol) - class MutableMapping: pass + class DictMixin: pass from . import db From python-3000-checkins at python.org Mon Feb 4 22:26:28 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Mon, 4 Feb 2008 22:26:28 +0100 (CET) Subject: [Python-3000-checkins] r60574 - python/branches/py3k/Lib/bsddb/__init__.py python/branches/py3k/Lib/bsddb/dbobj.py python/branches/py3k/Lib/bsddb/dbshelve.py Message-ID: <20080204212628.30FD61E4006@bag.python.org> Author: raymond.hettinger Date: Mon Feb 4 22:26:27 2008 New Revision: 60574 Modified: python/branches/py3k/Lib/bsddb/__init__.py python/branches/py3k/Lib/bsddb/dbobj.py python/branches/py3k/Lib/bsddb/dbshelve.py Log: In bsddb, replace UserDict.DictMixin with collections.MutableMapping. I can't test this directly on my build, so letting the buildbots do it for me. If it fails, expect a reversion. Modified: python/branches/py3k/Lib/bsddb/__init__.py ============================================================================== --- python/branches/py3k/Lib/bsddb/__init__.py (original) +++ python/branches/py3k/Lib/bsddb/__init__.py Mon Feb 4 22:26:27 2008 @@ -64,10 +64,10 @@ #---------------------------------------------------------------------- -import sys, os, UserDict +import sys, os, collections from weakref import ref -class _iter_mixin(UserDict.DictMixin): +class _iter_mixin(collections.MutableMapping): def _make_iter_cursor(self): cur = _DeadlockWrap(self.db.cursor) key = id(cur) @@ -289,7 +289,7 @@ def _cursor_refs(self): return self.db._cursor_refs -class StringKeys(UserDict.DictMixin, _ExposedProperties): +class StringKeys(collections.MutableMapping, _ExposedProperties): """Wrapper around DB object that automatically encodes all keys as UTF-8; the keys must be strings.""" @@ -357,7 +357,7 @@ def sync(self): return self.db.sync() -class StringValues(UserDict.DictMixin, _ExposedProperties): +class StringValues(collections.MutableMapping, _ExposedProperties): """Wrapper around DB object that automatically encodes and decodes all values as UTF-8; input values must be strings.""" Modified: python/branches/py3k/Lib/bsddb/dbobj.py ============================================================================== --- python/branches/py3k/Lib/bsddb/dbobj.py (original) +++ python/branches/py3k/Lib/bsddb/dbobj.py Mon Feb 4 22:26:27 2008 @@ -24,10 +24,9 @@ from . import db try: - from UserDict import DictMixin + from collections import MutableMapping except ImportError: - # DictMixin is new in Python 2.3 - class DictMixin: pass + class MutableMapping: pass class DBEnv: def __init__(self, *args, **kwargs): @@ -113,7 +112,7 @@ return self._cobj.lsn_reset(*args, **kwargs) -class DB(DictMixin): +class DB(MutableMapping): def __init__(self, dbenv, *args, **kwargs): # give it the proper DBEnv C object that its expecting self._cobj = db.DB(dbenv._cobj, *args, **kwargs) @@ -127,6 +126,8 @@ self._cobj[key] = value def __delitem__(self, arg): del self._cobj[arg] + def __iter__(self): + return iter(self.keys()) def append(self, *args, **kwargs): return self._cobj.append(*args, **kwargs) Modified: python/branches/py3k/Lib/bsddb/dbshelve.py ============================================================================== --- python/branches/py3k/Lib/bsddb/dbshelve.py (original) +++ python/branches/py3k/Lib/bsddb/dbshelve.py Mon Feb 4 22:26:27 2008 @@ -38,12 +38,12 @@ HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL def _dumps(object, protocol): return pickle.dumps(object, protocol=protocol) - from UserDict import DictMixin + from collections import MutableMapping else: HIGHEST_PROTOCOL = None def _dumps(object, protocol): return pickle.dumps(object, bin=protocol) - class DictMixin: pass + class MutableMapping: pass from . import db @@ -90,7 +90,7 @@ class DBShelveError(db.DBError): pass -class DBShelf(DictMixin): +class DBShelf(MutableMapping): """A shelf to hold pickled objects, built upon a bsddb DB object. It automatically pickles/unpickles data objects going to/from the DB. """ @@ -141,6 +141,8 @@ else: return self.db.keys() + def __iter__(self): + return iter(self.keys()) def open(self, *args, **kwargs): self.db.open(*args, **kwargs) From ncoghlan at gmail.com Mon Feb 4 23:06:02 2008 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 05 Feb 2008 08:06:02 +1000 Subject: [Python-3000-checkins] r60571 - in python/branches/py3k/Lib: _abcoll.py bsddb/dbshelve.py dumbdbm.py shelve.py In-Reply-To: <20080204204432.3E1DA1E4006@bag.python.org> References: <20080204204432.3E1DA1E4006@bag.python.org> Message-ID: <47A78C4A.4060805@gmail.com> > Modified: python/branches/py3k/Lib/_abcoll.py > ============================================================================== > --- python/branches/py3k/Lib/_abcoll.py (original) > +++ python/branches/py3k/Lib/_abcoll.py Mon Feb 4 21:44:31 2008 > @@ -378,6 +378,11 @@ > def values(self): > return ValuesView(self) > > + def __eq__(self, other): > + return set(self) == set(other) > + > + def __ne__(self, other): > + return set(self) == set(other) Was that meant to be != in the __ne__ implementation? Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org From python-3000-checkins at python.org Mon Feb 4 23:07:15 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Mon, 4 Feb 2008 23:07:15 +0100 (CET) Subject: [Python-3000-checkins] r60577 - in python/branches/py3k: Doc/library/userdict.rst Lib/UserDict.py Lib/bsddb/dbshelve.py Lib/test/test_shelve.py Lib/test/test_userdict.py Misc/NEWS Message-ID: <20080204220715.9626B1E4006@bag.python.org> Author: raymond.hettinger Date: Mon Feb 4 23:07:15 2008 New Revision: 60577 Modified: python/branches/py3k/Doc/library/userdict.rst python/branches/py3k/Lib/UserDict.py python/branches/py3k/Lib/bsddb/dbshelve.py python/branches/py3k/Lib/test/test_shelve.py python/branches/py3k/Lib/test/test_userdict.py python/branches/py3k/Misc/NEWS Log: Remove DictMixin which is superceded by collections.MutableMapping Modified: python/branches/py3k/Doc/library/userdict.rst ============================================================================== --- python/branches/py3k/Doc/library/userdict.rst (original) +++ python/branches/py3k/Doc/library/userdict.rst Mon Feb 4 23:07:15 2008 @@ -52,24 +52,6 @@ A real dictionary used to store the contents of the :class:`UserDict` class. -.. class:: DictMixin() - - Mixin defining all dictionary methods for classes that already have a minimum - dictionary interface including :meth:`__getitem__`, :meth:`__setitem__`, - :meth:`__delitem__`, and :meth:`keys`. - - This mixin should be used as a superclass. Adding each of the above methods - adds progressively more functionality. For instance, defining all but - :meth:`__delitem__` will preclude only :meth:`pop` and :meth:`popitem` from the - full interface. - - In addition to the four base methods, progressively more efficiency comes - with defining :meth:`__contains__` and :meth:`__iter__`. - - Since the mixin has no knowledge of the subclass constructor, it does not define - :meth:`__init__` or :meth:`copy`. - - :mod:`UserList` --- Class wrapper for list objects ================================================== Modified: python/branches/py3k/Lib/UserDict.py ============================================================================== --- python/branches/py3k/Lib/UserDict.py (original) +++ python/branches/py3k/Lib/UserDict.py Mon Feb 4 23:07:15 2008 @@ -79,103 +79,3 @@ class IterableUserDict(UserDict): def __iter__(self): return iter(self.data) - -class DictMixin: - # Mixin defining all dictionary methods for classes that already have - # a minimum dictionary interface including getitem, setitem, delitem, - # and keys. Without knowledge of the subclass constructor, the mixin - # does not define __init__() or copy(). In addition to the four base - # methods, progressively more efficiency comes with defining - # __contains__(), __iter__(), and iteritems(). - - # XXX It would make more sense to expect __iter__ to be primitive. - - # second level definitions support higher levels - def __iter__(self): - for k in self.keys(): - yield k - def __contains__(self, key): - try: - value = self[key] - except KeyError: - return False - return True - - # third level takes advantage of second level definitions - def iterkeys(self): - return self.__iter__() - def iteritems(self): - for k in self: - yield (k, self[k]) - - # fourth level uses definitions from lower levels - def itervalues(self): - for _, v in self.iteritems(): - yield v - def values(self): - return [v for _, v in self.iteritems()] - def items(self): - return list(self.iteritems()) - def clear(self): - for key in list(self.iterkeys()): - del self[key] - def setdefault(self, key, default=None): - try: - return self[key] - except KeyError: - self[key] = default - return default - def pop(self, key, *args): - if len(args) > 1: - raise TypeError("pop expected at most 2 arguments, got " - + repr(1 + len(args))) - try: - value = self[key] - except KeyError: - if args: - return args[0] - raise - del self[key] - return value - def popitem(self): - try: - k, v = next(self.iteritems()) - except StopIteration: - raise KeyError('container is empty') - del self[k] - return (k, v) - def update(self, other=None, **kwargs): - # Make progressively weaker assumptions about "other" - if other is None: - pass - elif hasattr(other, 'iteritems'): # iteritems saves memory and lookups - for k, v in other.iteritems(): - self[k] = v - elif hasattr(other, 'items'): # items may also save memory and lookups - for k, v in other.items(): - self[k] = v - elif hasattr(other, 'keys'): - for k in other.keys(): - self[k] = other[k] - else: - for k, v in other: - self[k] = v - if kwargs: - self.update(kwargs) - def get(self, key, default=None): - try: - return self[key] - except KeyError: - return default - def __repr__(self): - return repr(dict(self.iteritems())) - def __eq__(self, other): - if isinstance(other, DictMixin): - other = dict(other.iteritems()) - return dict(self.iteritems()) == other - def __ne__(self, other): - if isinstance(other, DictMixin): - other = dict(other.iteritems()) - return dict(self.iteritems()) != other - def __len__(self): - return len(self.keys()) Modified: python/branches/py3k/Lib/bsddb/dbshelve.py ============================================================================== --- python/branches/py3k/Lib/bsddb/dbshelve.py (original) +++ python/branches/py3k/Lib/bsddb/dbshelve.py Mon Feb 4 23:07:15 2008 @@ -32,8 +32,7 @@ import pickle import sys -#At version 2.3 cPickle switched to using protocol instead of bin and -#DictMixin was added +#At version 2.3 cPickle switched to using protocol instead of bin if sys.version_info[:3] >= (2, 3, 0): HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL def _dumps(object, protocol): Modified: python/branches/py3k/Lib/test/test_shelve.py ============================================================================== --- python/branches/py3k/Lib/test/test_shelve.py (original) +++ python/branches/py3k/Lib/test/test_shelve.py Mon Feb 4 23:07:15 2008 @@ -2,13 +2,13 @@ import shelve import glob from test import test_support -from UserDict import DictMixin +from collections import MutableMapping from test.test_anydbm import dbm_iterator def L1(s): return s.decode("latin-1") -class byteskeydict(DictMixin): +class byteskeydict(MutableMapping): "Mapping that supports bytes keys" def __init__(self): @@ -23,10 +23,15 @@ def __delitem__(self, key): del self.d[L1(key)] + def __len__(self): + return len(self.d) + def iterkeys(self): for k in self.d.keys(): yield k.encode("latin-1") + __iter__ = iterkeys + def keys(self): return list(self.iterkeys()) Modified: python/branches/py3k/Lib/test/test_userdict.py ============================================================================== --- python/branches/py3k/Lib/test/test_userdict.py (original) +++ python/branches/py3k/Lib/test/test_userdict.py Mon Feb 4 23:07:15 2008 @@ -194,150 +194,11 @@ else: self.fail("g[42] didn't raise KeyError") -########################## -# Test Dict Mixin -class SeqDict(UserDict.DictMixin): - """Dictionary lookalike implemented with lists. - - Used to test and demonstrate DictMixin - """ - def __init__(self, other=None, **kwargs): - self.keylist = [] - self.valuelist = [] - if other is not None: - for (key, value) in other: - self[key] = value - for (key, value) in kwargs.items(): - self[key] = value - def __getitem__(self, key): - try: - i = self.keylist.index(key) - except ValueError: - raise KeyError - return self.valuelist[i] - def __setitem__(self, key, value): - try: - i = self.keylist.index(key) - self.valuelist[i] = value - except ValueError: - self.keylist.append(key) - self.valuelist.append(value) - def __delitem__(self, key): - try: - i = self.keylist.index(key) - except ValueError: - raise KeyError - self.keylist.pop(i) - self.valuelist.pop(i) - def keys(self): - return list(self.keylist) - def copy(self): - d = self.__class__() - for key, value in self.items(): - d[key] = value - return d - @classmethod - def fromkeys(cls, keys, value=None): - d = cls() - for key in keys: - d[key] = value - return d - -class UserDictMixinTest(mapping_tests.TestMappingProtocol): - type2test = SeqDict - - def test_all(self): - ## Setup test and verify working of the test class - - # check init - s = SeqDict() - - # exercise setitem - s[10] = 'ten' - s[20] = 'twenty' - s[30] = 'thirty' - - # exercise delitem - del s[20] - # check getitem and setitem - self.assertEqual(s[10], 'ten') - # check keys() and delitem - self.assertEqual(s.keys(), [10, 30]) - - ## Now, test the DictMixin methods one by one - - # __contains__ - self.assert_(10 in s) - self.assert_(20 not in s) - - # __iter__ - self.assertEqual([k for k in s], [10, 30]) - - # __len__ - self.assertEqual(len(s), 2) - - # iteritems - self.assertEqual(list(s.items()), [(10,'ten'), (30, 'thirty')]) - - # iterkeys - self.assertEqual(list(s.keys()), [10, 30]) - - # itervalues - self.assertEqual(list(s.values()), ['ten', 'thirty']) - - # values - self.assertEqual(s.values(), ['ten', 'thirty']) - - # items - self.assertEqual(s.items(), [(10,'ten'), (30, 'thirty')]) - - # get - self.assertEqual(s.get(10), 'ten') - self.assertEqual(s.get(15,'fifteen'), 'fifteen') - self.assertEqual(s.get(15), None) - - # setdefault - self.assertEqual(s.setdefault(40, 'forty'), 'forty') - self.assertEqual(s.setdefault(10, 'null'), 'ten') - del s[40] - - # pop - self.assertEqual(s.pop(10), 'ten') - self.assert_(10 not in s) - s[10] = 'ten' - self.assertEqual(s.pop("x", 1), 1) - s["x"] = 42 - self.assertEqual(s.pop("x", 1), 42) - - # popitem - k, v = s.popitem() - self.assert_(k not in s) - s[k] = v - - # clear - s.clear() - self.assertEqual(len(s), 0) - - # empty popitem - self.assertRaises(KeyError, s.popitem) - - # update - s.update({10: 'ten', 20:'twenty'}) - self.assertEqual(s[10], 'ten') - self.assertEqual(s[20], 'twenty') - - # cmp - self.assertEqual(s, {10: 'ten', 20:'twenty'}) - t = SeqDict() - t[20] = 'twenty' - t[10] = 'ten' - self.assertEqual(s, t) def test_main(): test_support.run_unittest( UserDictTest, - UserDictMixinTest ) if __name__ == "__main__": Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Feb 4 23:07:15 2008 @@ -70,6 +70,8 @@ Library ------- +- Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. + - Issue #1703: getpass() should flush after writing prompt. - Issue #1585: IDLE uses non-existent xrange() function. From python-3000-checkins at python.org Mon Feb 4 23:09:30 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Mon, 4 Feb 2008 23:09:30 +0100 (CET) Subject: [Python-3000-checkins] r60578 - python/branches/py3k/Lib/_abcoll.py Message-ID: <20080204220930.909241E4006@bag.python.org> Author: raymond.hettinger Date: Mon Feb 4 23:09:30 2008 New Revision: 60578 Modified: python/branches/py3k/Lib/_abcoll.py Log: Fix typo (thanks Nick). Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Mon Feb 4 23:09:30 2008 @@ -382,7 +382,7 @@ return set(self) == set(other) def __ne__(self, other): - return set(self) == set(other) + return set(self) != set(other) class MappingView(metaclass=ABCMeta): From brett at python.org Mon Feb 4 23:10:21 2008 From: brett at python.org (Brett Cannon) Date: Mon, 4 Feb 2008 14:10:21 -0800 Subject: [Python-3000-checkins] r60577 - in python/branches/py3k: Doc/library/userdict.rst Lib/UserDict.py Lib/bsddb/dbshelve.py Lib/test/test_shelve.py Lib/test/test_userdict.py Misc/NEWS In-Reply-To: <20080204220715.9626B1E4006@bag.python.org> References: <20080204220715.9626B1E4006@bag.python.org> Message-ID: If DictMixin is gone, is UserDict worth even keeping? UserDict.UserDict seemed only useful back before types could not be subclassed. And every time I suggested removing UserDict and friends people always pointed to the mixin classes as reasons for keeping them around. -Brett On Feb 4, 2008 2:07 PM, raymond.hettinger wrote: > Author: raymond.hettinger > Date: Mon Feb 4 23:07:15 2008 > New Revision: 60577 > > Modified: > python/branches/py3k/Doc/library/userdict.rst > python/branches/py3k/Lib/UserDict.py > python/branches/py3k/Lib/bsddb/dbshelve.py > python/branches/py3k/Lib/test/test_shelve.py > python/branches/py3k/Lib/test/test_userdict.py > python/branches/py3k/Misc/NEWS > Log: > Remove DictMixin which is superceded by collections.MutableMapping > > Modified: python/branches/py3k/Doc/library/userdict.rst > ============================================================================== > --- python/branches/py3k/Doc/library/userdict.rst (original) > +++ python/branches/py3k/Doc/library/userdict.rst Mon Feb 4 23:07:15 2008 > @@ -52,24 +52,6 @@ > A real dictionary used to store the contents of the :class:`UserDict` class. > > > -.. class:: DictMixin() > - > - Mixin defining all dictionary methods for classes that already have a minimum > - dictionary interface including :meth:`__getitem__`, :meth:`__setitem__`, > - :meth:`__delitem__`, and :meth:`keys`. > - > - This mixin should be used as a superclass. Adding each of the above methods > - adds progressively more functionality. For instance, defining all but > - :meth:`__delitem__` will preclude only :meth:`pop` and :meth:`popitem` from the > - full interface. > - > - In addition to the four base methods, progressively more efficiency comes > - with defining :meth:`__contains__` and :meth:`__iter__`. > - > - Since the mixin has no knowledge of the subclass constructor, it does not define > - :meth:`__init__` or :meth:`copy`. > - > - > :mod:`UserList` --- Class wrapper for list objects > ================================================== > > > Modified: python/branches/py3k/Lib/UserDict.py > ============================================================================== > --- python/branches/py3k/Lib/UserDict.py (original) > +++ python/branches/py3k/Lib/UserDict.py Mon Feb 4 23:07:15 2008 > @@ -79,103 +79,3 @@ > class IterableUserDict(UserDict): > def __iter__(self): > return iter(self.data) > - > -class DictMixin: > - # Mixin defining all dictionary methods for classes that already have > - # a minimum dictionary interface including getitem, setitem, delitem, > - # and keys. Without knowledge of the subclass constructor, the mixin > - # does not define __init__() or copy(). In addition to the four base > - # methods, progressively more efficiency comes with defining > - # __contains__(), __iter__(), and iteritems(). > - > - # XXX It would make more sense to expect __iter__ to be primitive. > - > - # second level definitions support higher levels > - def __iter__(self): > - for k in self.keys(): > - yield k > - def __contains__(self, key): > - try: > - value = self[key] > - except KeyError: > - return False > - return True > - > - # third level takes advantage of second level definitions > - def iterkeys(self): > - return self.__iter__() > - def iteritems(self): > - for k in self: > - yield (k, self[k]) > - > - # fourth level uses definitions from lower levels > - def itervalues(self): > - for _, v in self.iteritems(): > - yield v > - def values(self): > - return [v for _, v in self.iteritems()] > - def items(self): > - return list(self.iteritems()) > - def clear(self): > - for key in list(self.iterkeys()): > - del self[key] > - def setdefault(self, key, default=None): > - try: > - return self[key] > - except KeyError: > - self[key] = default > - return default > - def pop(self, key, *args): > - if len(args) > 1: > - raise TypeError("pop expected at most 2 arguments, got " > - + repr(1 + len(args))) > - try: > - value = self[key] > - except KeyError: > - if args: > - return args[0] > - raise > - del self[key] > - return value > - def popitem(self): > - try: > - k, v = next(self.iteritems()) > - except StopIteration: > - raise KeyError('container is empty') > - del self[k] > - return (k, v) > - def update(self, other=None, **kwargs): > - # Make progressively weaker assumptions about "other" > - if other is None: > - pass > - elif hasattr(other, 'iteritems'): # iteritems saves memory and lookups > - for k, v in other.iteritems(): > - self[k] = v > - elif hasattr(other, 'items'): # items may also save memory and lookups > - for k, v in other.items(): > - self[k] = v > - elif hasattr(other, 'keys'): > - for k in other.keys(): > - self[k] = other[k] > - else: > - for k, v in other: > - self[k] = v > - if kwargs: > - self.update(kwargs) > - def get(self, key, default=None): > - try: > - return self[key] > - except KeyError: > - return default > - def __repr__(self): > - return repr(dict(self.iteritems())) > - def __eq__(self, other): > - if isinstance(other, DictMixin): > - other = dict(other.iteritems()) > - return dict(self.iteritems()) == other > - def __ne__(self, other): > - if isinstance(other, DictMixin): > - other = dict(other.iteritems()) > - return dict(self.iteritems()) != other > - def __len__(self): > - return len(self.keys()) > > Modified: python/branches/py3k/Lib/bsddb/dbshelve.py > ============================================================================== > --- python/branches/py3k/Lib/bsddb/dbshelve.py (original) > +++ python/branches/py3k/Lib/bsddb/dbshelve.py Mon Feb 4 23:07:15 2008 > @@ -32,8 +32,7 @@ > import pickle > import sys > > -#At version 2.3 cPickle switched to using protocol instead of bin and > -#DictMixin was added > +#At version 2.3 cPickle switched to using protocol instead of bin > if sys.version_info[:3] >= (2, 3, 0): > HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL > def _dumps(object, protocol): > > Modified: python/branches/py3k/Lib/test/test_shelve.py > ============================================================================== > --- python/branches/py3k/Lib/test/test_shelve.py (original) > +++ python/branches/py3k/Lib/test/test_shelve.py Mon Feb 4 23:07:15 2008 > @@ -2,13 +2,13 @@ > import shelve > import glob > from test import test_support > -from UserDict import DictMixin > +from collections import MutableMapping > from test.test_anydbm import dbm_iterator > > def L1(s): > return s.decode("latin-1") > > -class byteskeydict(DictMixin): > +class byteskeydict(MutableMapping): > "Mapping that supports bytes keys" > > def __init__(self): > @@ -23,10 +23,15 @@ > def __delitem__(self, key): > del self.d[L1(key)] > > + def __len__(self): > + return len(self.d) > + > def iterkeys(self): > for k in self.d.keys(): > yield k.encode("latin-1") > > + __iter__ = iterkeys > + > def keys(self): > return list(self.iterkeys()) > > > Modified: python/branches/py3k/Lib/test/test_userdict.py > ============================================================================== > --- python/branches/py3k/Lib/test/test_userdict.py (original) > +++ python/branches/py3k/Lib/test/test_userdict.py Mon Feb 4 23:07:15 2008 > @@ -194,150 +194,11 @@ > else: > self.fail("g[42] didn't raise KeyError") > > -########################## > -# Test Dict Mixin > > -class SeqDict(UserDict.DictMixin): > - """Dictionary lookalike implemented with lists. > - > - Used to test and demonstrate DictMixin > - """ > - def __init__(self, other=None, **kwargs): > - self.keylist = [] > - self.valuelist = [] > - if other is not None: > - for (key, value) in other: > - self[key] = value > - for (key, value) in kwargs.items(): > - self[key] = value > - def __getitem__(self, key): > - try: > - i = self.keylist.index(key) > - except ValueError: > - raise KeyError > - return self.valuelist[i] > - def __setitem__(self, key, value): > - try: > - i = self.keylist.index(key) > - self.valuelist[i] = value > - except ValueError: > - self.keylist.append(key) > - self.valuelist.append(value) > - def __delitem__(self, key): > - try: > - i = self.keylist.index(key) > - except ValueError: > - raise KeyError > - self.keylist.pop(i) > - self.valuelist.pop(i) > - def keys(self): > - return list(self.keylist) > - def copy(self): > - d = self.__class__() > - for key, value in self.items(): > - d[key] = value > - return d > - @classmethod > - def fromkeys(cls, keys, value=None): > - d = cls() > - for key in keys: > - d[key] = value > - return d > - > -class UserDictMixinTest(mapping_tests.TestMappingProtocol): > - type2test = SeqDict > - > - def test_all(self): > - ## Setup test and verify working of the test class > - > - # check init > - s = SeqDict() > - > - # exercise setitem > - s[10] = 'ten' > - s[20] = 'twenty' > - s[30] = 'thirty' > - > - # exercise delitem > - del s[20] > - # check getitem and setitem > - self.assertEqual(s[10], 'ten') > - # check keys() and delitem > - self.assertEqual(s.keys(), [10, 30]) > - > - ## Now, test the DictMixin methods one by one > - > - # __contains__ > - self.assert_(10 in s) > - self.assert_(20 not in s) > - > - # __iter__ > - self.assertEqual([k for k in s], [10, 30]) > - > - # __len__ > - self.assertEqual(len(s), 2) > - > - # iteritems > - self.assertEqual(list(s.items()), [(10,'ten'), (30, 'thirty')]) > - > - # iterkeys > - self.assertEqual(list(s.keys()), [10, 30]) > - > - # itervalues > - self.assertEqual(list(s.values()), ['ten', 'thirty']) > - > - # values > - self.assertEqual(s.values(), ['ten', 'thirty']) > - > - # items > - self.assertEqual(s.items(), [(10,'ten'), (30, 'thirty')]) > - > - # get > - self.assertEqual(s.get(10), 'ten') > - self.assertEqual(s.get(15,'fifteen'), 'fifteen') > - self.assertEqual(s.get(15), None) > - > - # setdefault > - self.assertEqual(s.setdefault(40, 'forty'), 'forty') > - self.assertEqual(s.setdefault(10, 'null'), 'ten') > - del s[40] > - > - # pop > - self.assertEqual(s.pop(10), 'ten') > - self.assert_(10 not in s) > - s[10] = 'ten' > - self.assertEqual(s.pop("x", 1), 1) > - s["x"] = 42 > - self.assertEqual(s.pop("x", 1), 42) > - > - # popitem > - k, v = s.popitem() > - self.assert_(k not in s) > - s[k] = v > - > - # clear > - s.clear() > - self.assertEqual(len(s), 0) > - > - # empty popitem > - self.assertRaises(KeyError, s.popitem) > - > - # update > - s.update({10: 'ten', 20:'twenty'}) > - self.assertEqual(s[10], 'ten') > - self.assertEqual(s[20], 'twenty') > - > - # cmp > - self.assertEqual(s, {10: 'ten', 20:'twenty'}) > - t = SeqDict() > - t[20] = 'twenty' > - t[10] = 'ten' > - self.assertEqual(s, t) > > def test_main(): > test_support.run_unittest( > UserDictTest, > - UserDictMixinTest > ) > > if __name__ == "__main__": > > Modified: python/branches/py3k/Misc/NEWS > ============================================================================== > --- python/branches/py3k/Misc/NEWS (original) > +++ python/branches/py3k/Misc/NEWS Mon Feb 4 23:07:15 2008 > @@ -70,6 +70,8 @@ > Library > ------- > > +- Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. > + > - Issue #1703: getpass() should flush after writing prompt. > > - Issue #1585: IDLE uses non-existent xrange() function. > _______________________________________________ > Python-3000-checkins mailing list > Python-3000-checkins at python.org > http://mail.python.org/mailman/listinfo/python-3000-checkins > From python at rcn.com Mon Feb 4 23:16:06 2008 From: python at rcn.com (Raymond Hettinger) Date: Mon, 4 Feb 2008 17:16:06 -0500 (EST) Subject: [Python-3000-checkins] r60577 - in python/branches/py3k: Doc/library/userdict.rst Lib/UserDict.py Lib/bsddb/dbshelve.py Lib/test/test_shelve.py Lib/test/test_userdict.py Misc/NEWS Message-ID: <20080204171606.AGH66181@ms19.lnh.mail.rcn.net> [Brett] > If DictMixin is gone, is UserDict worth even keeping? Going one step at a time. Am looking at killing UserDict next. If it can't be killed, then at least it will need to have its API matched to the new dict API. Raymond From python-3000-checkins at python.org Mon Feb 4 23:43:28 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Mon, 4 Feb 2008 23:43:28 +0100 (CET) Subject: [Python-3000-checkins] r60580 - python/branches/py3k/Lib/cgi.py Message-ID: <20080204224328.1950A1E4006@bag.python.org> Author: raymond.hettinger Date: Mon Feb 4 23:43:27 2008 New Revision: 60580 Modified: python/branches/py3k/Lib/cgi.py Log: Remove one use of UserDict.UserDict Modified: python/branches/py3k/Lib/cgi.py ============================================================================== --- python/branches/py3k/Lib/cgi.py (original) +++ python/branches/py3k/Lib/cgi.py Mon Feb 4 23:43:27 2008 @@ -40,7 +40,7 @@ import urllib import mimetools import rfc822 -import UserDict +import collections from io import StringIO __all__ = ["MiniFieldStorage", "FieldStorage", "FormContentDict", @@ -781,7 +781,7 @@ # Backwards Compatibility Classes # =============================== -class FormContentDict(UserDict.UserDict): +class FormContentDict(collections.Mapping): """Form content as dictionary with a list of values per field. form = FormContentDict() @@ -800,6 +800,15 @@ strict_parsing=strict_parsing) self.query_string = environ['QUERY_STRING'] + def __len__(self): + return len(self.dict) + + def __iter__(self): + return iter(self.dict) + + def __getitem__(self, key): + return self.dict[key] + class SvFormContentDict(FormContentDict): """Form content as dictionary expecting a single value per field. From brett at python.org Tue Feb 5 00:05:02 2008 From: brett at python.org (Brett Cannon) Date: Mon, 4 Feb 2008 15:05:02 -0800 Subject: [Python-3000-checkins] r60577 - in python/branches/py3k: Doc/library/userdict.rst Lib/UserDict.py Lib/bsddb/dbshelve.py Lib/test/test_shelve.py Lib/test/test_userdict.py Misc/NEWS In-Reply-To: <20080204171606.AGH66181@ms19.lnh.mail.rcn.net> References: <20080204171606.AGH66181@ms19.lnh.mail.rcn.net> Message-ID: On Feb 4, 2008 2:16 PM, Raymond Hettinger wrote: > [Brett] > > If DictMixin is gone, is UserDict worth even keeping? > > Going one step at a time. > > Am looking at killing UserDict next. Great! -Brett From python-3000-checkins at python.org Tue Feb 5 01:20:01 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Tue, 5 Feb 2008 01:20:01 +0100 (CET) Subject: [Python-3000-checkins] r60583 - python/branches/py3k/Lib/_weakrefset.py python/branches/py3k/Lib/abc.py python/branches/py3k/Lib/weakref.py Message-ID: <20080205002001.899721E4006@bag.python.org> Author: raymond.hettinger Date: Tue Feb 5 01:20:01 2008 New Revision: 60583 Added: python/branches/py3k/Lib/_weakrefset.py Modified: python/branches/py3k/Lib/abc.py python/branches/py3k/Lib/weakref.py Log: Moved WeakSet into a bootstap module use by abc.py. This makes it possible to use ABCs in weakref.py (which will be done in a later checkin). Added: python/branches/py3k/Lib/_weakrefset.py ============================================================================== --- (empty file) +++ python/branches/py3k/Lib/_weakrefset.py Tue Feb 5 01:20:01 2008 @@ -0,0 +1,111 @@ +# Access WeakSet through the weakref module. +# This code is separated-out because it is needed +# by abc.py to load everything else at startup. + +from _weakref import ref + +__all__ = ['WeakSet'] + +class WeakSet: + def __init__(self, data=None): + self.data = set() + def _remove(item, selfref=ref(self)): + self = selfref() + if self is not None: + self.data.discard(item) + self._remove = _remove + if data is not None: + self.update(data) + + def __iter__(self): + for itemref in self.data: + item = itemref() + if item is not None: + yield item + + def __contains__(self, item): + return ref(item) in self.data + + def __reduce__(self): + return (self.__class__, (list(self),), + getattr(self, '__dict__', None)) + + def add(self, item): + self.data.add(ref(item, self._remove)) + + def clear(self): + self.data.clear() + + def copy(self): + return self.__class__(self) + + def pop(self): + while True: + itemref = self.data.pop() + item = itemref() + if item is not None: + return item + + def remove(self, item): + self.data.remove(ref(item)) + + def discard(self, item): + self.data.discard(ref(item)) + + def update(self, other): + if isinstance(other, self.__class__): + self.data.update(other.data) + else: + for element in other: + self.add(element) + __ior__ = update + + # Helper functions for simple delegating methods. + def _apply(self, other, method): + if not isinstance(other, self.__class__): + other = self.__class__(other) + newdata = method(other.data) + newset = self.__class__() + newset.data = newdata + return newset + + def _apply_mutate(self, other, method): + if not isinstance(other, self.__class__): + other = self.__class__(other) + method(other) + + def difference(self, other): + return self._apply(other, self.data.difference) + __sub__ = difference + + def difference_update(self, other): + self._apply_mutate(self, self.data.difference_update) + __isub__ = difference_update + + def intersection(self, other): + return self._apply(other, self.data.intersection) + __and__ = intersection + + def intersection_update(self, other): + self._apply_mutate(self, self.data.intersection_update) + __iand__ = intersection_update + + def issubset(self, other): + return self.data.issubset(ref(item) for item in other) + __lt__ = issubset + + def issuperset(self, other): + return self.data.issuperset(ref(item) for item in other) + __gt__ = issuperset + + def symmetric_difference(self, other): + return self._apply(other, self.data.symmetric_difference) + __xor__ = symmetric_difference + + def symmetric_difference_update(self, other): + self._apply_mutate(other, self.data.symmetric_difference_update) + __ixor__ = symmetric_difference_update + + def union(self, other): + self._apply_mutate(other, self.data.union) + __or__ = union Modified: python/branches/py3k/Lib/abc.py ============================================================================== --- python/branches/py3k/Lib/abc.py (original) +++ python/branches/py3k/Lib/abc.py Tue Feb 5 01:20:01 2008 @@ -3,7 +3,7 @@ """Abstract Base Classes (ABCs) according to PEP 3119.""" -from weakref import WeakSet +from _weakrefset import WeakSet def abstractmethod(funcobj): """A decorator indicating abstract methods. Modified: python/branches/py3k/Lib/weakref.py ============================================================================== --- python/branches/py3k/Lib/weakref.py (original) +++ python/branches/py3k/Lib/weakref.py Tue Feb 5 01:20:01 2008 @@ -20,12 +20,14 @@ ProxyType, ReferenceType) +from _weakrefset import WeakSet ProxyTypes = (ProxyType, CallableProxyType) __all__ = ["ref", "proxy", "getweakrefcount", "getweakrefs", "WeakKeyDictionary", "ReferenceType", "ProxyType", - "CallableProxyType", "ProxyTypes", "WeakValueDictionary"] + "CallableProxyType", "ProxyTypes", "WeakValueDictionary", + "WeakSet"] class WeakValueDictionary(UserDict.UserDict): @@ -337,108 +339,3 @@ d[ref(key, self._remove)] = value if len(kwargs): self.update(kwargs) - - -class WeakSet: - def __init__(self, data=None): - self.data = set() - def _remove(item, selfref=ref(self)): - self = selfref() - if self is not None: - self.data.discard(item) - self._remove = _remove - if data is not None: - self.update(data) - - def __iter__(self): - for itemref in self.data: - item = itemref() - if item is not None: - yield item - - def __contains__(self, item): - return ref(item) in self.data - - def __reduce__(self): - return (self.__class__, (list(self),), - getattr(self, '__dict__', None)) - - def add(self, item): - self.data.add(ref(item, self._remove)) - - def clear(self): - self.data.clear() - - def copy(self): - return self.__class__(self) - - def pop(self): - while True: - itemref = self.data.pop() - item = itemref() - if item is not None: - return item - - def remove(self, item): - self.data.remove(ref(item)) - - def discard(self, item): - self.data.discard(ref(item)) - - def update(self, other): - if isinstance(other, self.__class__): - self.data.update(other.data) - else: - for element in other: - self.add(element) - __ior__ = update - - # Helper functions for simple delegating methods. - def _apply(self, other, method): - if not isinstance(other, self.__class__): - other = self.__class__(other) - newdata = method(other.data) - newset = self.__class__() - newset.data = newdata - return newset - - def _apply_mutate(self, other, method): - if not isinstance(other, self.__class__): - other = self.__class__(other) - method(other) - - def difference(self, other): - return self._apply(other, self.data.difference) - __sub__ = difference - - def difference_update(self, other): - self._apply_mutate(self, self.data.difference_update) - __isub__ = difference_update - - def intersection(self, other): - return self._apply(other, self.data.intersection) - __and__ = intersection - - def intersection_update(self, other): - self._apply_mutate(self, self.data.intersection_update) - __iand__ = intersection_update - - def issubset(self, other): - return self.data.issubset(ref(item) for item in other) - __lt__ = issubset - - def issuperset(self, other): - return self.data.issuperset(ref(item) for item in other) - __gt__ = issuperset - - def symmetric_difference(self, other): - return self._apply(other, self.data.symmetric_difference) - __xor__ = symmetric_difference - - def symmetric_difference_update(self, other): - self._apply_mutate(other, self.data.symmetric_difference_update) - __ixor__ = symmetric_difference_update - - def union(self, other): - self._apply_mutate(other, self.data.union) - __or__ = union From python-3000-checkins at python.org Tue Feb 5 02:15:58 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Tue, 5 Feb 2008 02:15:58 +0100 (CET) Subject: [Python-3000-checkins] r60585 - python/branches/py3k/Lib/weakref.py Message-ID: <20080205011558.409E81E4021@bag.python.org> Author: raymond.hettinger Date: Tue Feb 5 02:15:57 2008 New Revision: 60585 Modified: python/branches/py3k/Lib/weakref.py Log: Decouple weakref containers from UserDict and teach them to use ABC instead. More work left to do later. Still need to modernize the API of the dictlike objects to more closely match regulars dicts. Modified: python/branches/py3k/Lib/weakref.py ============================================================================== --- python/branches/py3k/Lib/weakref.py (original) +++ python/branches/py3k/Lib/weakref.py Tue Feb 5 02:15:57 2008 @@ -9,7 +9,7 @@ # they are called this instead of "ref" to avoid name collisions with # the module-global ref() function imported from _weakref. -import UserDict +import collections from _weakref import ( getweakrefcount, @@ -30,7 +30,7 @@ "WeakSet"] -class WeakValueDictionary(UserDict.UserDict): +class WeakValueDictionary(collections.MutableMapping): """Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong @@ -48,7 +48,8 @@ if self is not None: del self.data[wr.key] self._remove = remove - UserDict.UserDict.__init__(self, *args, **kw) + self.data = d = {} + d.update(*args, **kw) def __getitem__(self, key): o = self.data[key]() @@ -57,6 +58,12 @@ else: return o + def __delitem__(self, key): + del self.data[key] + + def __len__(self): + return sum(wr() is not None for wr in self.data.values()) + def __contains__(self, key): try: o = self.data[key]() @@ -187,6 +194,7 @@ L.append(o) return L +collections.MutableMapping.register(WeakValueDictionary) class KeyedRef(ref): """Specialized reference that includes a key corresponding to the value. @@ -209,7 +217,7 @@ super().__init__(ob, callback) -class WeakKeyDictionary(UserDict.UserDict): +class WeakKeyDictionary(collections.MutableMapping): """ Mapping class that references keys weakly. Entries in the dictionary will be discarded when there is no @@ -235,6 +243,9 @@ def __getitem__(self, key): return self.data[ref(key)] + def __len__(self): + return len(self.data) + def __repr__(self): return "" % id(self) @@ -339,3 +350,5 @@ d[ref(key, self._remove)] = value if len(kwargs): self.update(kwargs) + +collections.MutableMapping.register(WeakKeyDictionary) From python-3000-checkins at python.org Tue Feb 5 02:53:00 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Tue, 5 Feb 2008 02:53:00 +0100 (CET) Subject: [Python-3000-checkins] r60586 - in python/branches/py3k: Lib/collections.py Misc/NEWS Message-ID: <20080205015300.D41F81E4006@bag.python.org> Author: raymond.hettinger Date: Tue Feb 5 02:53:00 2008 New Revision: 60586 Modified: python/branches/py3k/Lib/collections.py python/branches/py3k/Misc/NEWS Log: Put an updated UserDict class in the collections module and register it as a compliant Mutable Mapping. Todo: Convert the UserDict dependent tests to the new API and then remove the old UserDict module. Move the UserDict docs to collections.rst. Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Tue Feb 5 02:53:00 2008 @@ -1,4 +1,4 @@ -__all__ = ['deque', 'defaultdict', 'namedtuple'] +__all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict'] # For bootstrapping reasons, the collection ABCs are defined in _abcoll.py. # They should however be considered an integral part of collections.py. from _abcoll import * @@ -10,6 +10,10 @@ from keyword import iskeyword as _iskeyword import sys as _sys +################################################################################ +### namedtuple +################################################################################ + def namedtuple(typename, field_names, verbose=False): """Returns a new subclass of tuple with named fields. @@ -106,7 +110,60 @@ +################################################################################ +### UserDict +################################################################################ + +class UserDict(MutableMapping): + + # Start by filling-out the abstract methods + def __init__(self, dict=None, **kwargs): + self.data = {} + if dict is not None: + self.update(dict) + if len(kwargs): + self.update(kwargs) + def __len__(self): return len(self.data) + def __getitem__(self, key): + if key in self.data: + return self.data[key] + if hasattr(self.__class__, "__missing__"): + return self.__class__.__missing__(self, key) + raise KeyError(key) + def __setitem__(self, key, item): self.data[key] = item + def __delitem__(self, key): del self.data[key] + def __iter__(self): + return iter(self.data) + + + # Now, add the methods in dicts but not in MutableMapping + def __repr__(self): return repr(self.data) + def copy(self): + if self.__class__ is UserDict: + return UserDict(self.data.copy()) + import copy + data = self.data + try: + self.data = {} + c = copy.copy(self) + finally: + self.data = data + c.update(self) + return c + @classmethod + def fromkeys(cls, iterable, value=None): + d = cls() + for key in iterable: + d[key] = value + return d + +MutableMapping.register(UserDict) + + +################################################################################ +### Simple tests +################################################################################ if __name__ == '__main__': # verify that instances can be pickled Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Feb 5 02:53:00 2008 @@ -70,6 +70,13 @@ Library ------- +- Weakref dictionaries now inherit from MutableMapping. + XXX their API still needs to be modernized (i.e. eliminate the iter methods). + +- Created new UserDict class in collections module. This one inherits from and + complies with the MutableMapping ABC. + XXX still need to covert old UserDict based tests and eliminate the old UserDict module. + - Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. - Issue #1703: getpass() should flush after writing prompt. From python-3000-checkins at python.org Tue Feb 5 13:10:30 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Tue, 5 Feb 2008 13:10:30 +0100 (CET) Subject: [Python-3000-checkins] r60591 - python/branches/py3k/Lib/_abcoll.py Message-ID: <20080205121030.382091E402C@bag.python.org> Author: raymond.hettinger Date: Tue Feb 5 13:10:29 2008 New Revision: 60591 Modified: python/branches/py3k/Lib/_abcoll.py Log: Fix-up mapping equality tests to include both keys and values Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Tue Feb 5 13:10:29 2008 @@ -379,10 +379,10 @@ return ValuesView(self) def __eq__(self, other): - return set(self) == set(other) + return dict(self.items()) == dict(other.items()) def __ne__(self, other): - return set(self) != set(other) + return dict(self.items()) != dict(other.items()) class MappingView(metaclass=ABCMeta): From guido at python.org Tue Feb 5 18:54:17 2008 From: guido at python.org (Guido van Rossum) Date: Tue, 5 Feb 2008 09:54:17 -0800 Subject: [Python-3000-checkins] r60591 - python/branches/py3k/Lib/_abcoll.py In-Reply-To: <20080205121030.382091E402C@bag.python.org> References: <20080205121030.382091E402C@bag.python.org> Message-ID: I know I was lax and didn't include full unittests for these -- but now that they are maturing, perhaps someone could add some? This and the previous slip would have caught by pretty basic unittests... --Guido On Feb 5, 2008 4:10 AM, raymond.hettinger wrote: > Author: raymond.hettinger > Date: Tue Feb 5 13:10:29 2008 > New Revision: 60591 > > Modified: > python/branches/py3k/Lib/_abcoll.py > Log: > Fix-up mapping equality tests to include both keys and values > > Modified: python/branches/py3k/Lib/_abcoll.py > ============================================================================== > --- python/branches/py3k/Lib/_abcoll.py (original) > +++ python/branches/py3k/Lib/_abcoll.py Tue Feb 5 13:10:29 2008 > @@ -379,10 +379,10 @@ > return ValuesView(self) > > def __eq__(self, other): > - return set(self) == set(other) > + return dict(self.items()) == dict(other.items()) > > def __ne__(self, other): > - return set(self) != set(other) > + return dict(self.items()) != dict(other.items()) > > class MappingView(metaclass=ABCMeta): > > _______________________________________________ > Python-3000-checkins mailing list > Python-3000-checkins at python.org > http://mail.python.org/mailman/listinfo/python-3000-checkins > -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-3000-checkins at python.org Tue Feb 5 19:13:17 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 5 Feb 2008 19:13:17 +0100 (CET) Subject: [Python-3000-checkins] r60597 - python/branches/py3k/Lib/test/test_descr.py Message-ID: <20080205181317.0C1AA1E4023@bag.python.org> Author: georg.brandl Date: Tue Feb 5 19:13:15 2008 New Revision: 60597 Modified: python/branches/py3k/Lib/test/test_descr.py Log: Manually merge r60521 from trunk. Modified: python/branches/py3k/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k/Lib/test/test_descr.py (original) +++ python/branches/py3k/Lib/test/test_descr.py Tue Feb 5 19:13:15 2008 @@ -1,4137 +1,3980 @@ -# Test enhancements related to descriptors and new-style classes +import types +import unittest +import warnings + +from copy import deepcopy +from test import test_support + + +class OperatorsTest(unittest.TestCase): + + def __init__(self, *args, **kwargs): + unittest.TestCase.__init__(self, *args, **kwargs) + self.binops = { + 'add': '+', + 'sub': '-', + 'mul': '*', + 'div': '/', + 'divmod': 'divmod', + 'pow': '**', + 'lshift': '<<', + 'rshift': '>>', + 'and': '&', + 'xor': '^', + 'or': '|', + 'cmp': 'cmp', + 'lt': '<', + 'le': '<=', + 'eq': '==', + 'ne': '!=', + 'gt': '>', + 'ge': '>=', + } + + for name, expr in list(self.binops.items()): + if expr.islower(): + expr = expr + "(a, b)" + else: + expr = 'a %s b' % expr + self.binops[name] = expr + + self.unops = { + 'pos': '+', + 'neg': '-', + 'abs': 'abs', + 'invert': '~', + 'int': 'int', + 'float': 'float', + 'oct': 'oct', + 'hex': 'hex', + } + + for name, expr in list(self.unops.items()): + if expr.islower(): + expr = expr + "(a)" + else: + expr = '%s a' % expr + self.unops[name] = expr + + def unop_test(self, a, res, expr="len(a)", meth="__len__"): + d = {'a': a} + self.assertEqual(eval(expr, d), res) + t = type(a) + m = getattr(t, meth) + + # Find method in parent class + while meth not in t.__dict__: + t = t.__bases__[0] + + self.assertEqual(m, t.__dict__[meth]) + self.assertEqual(m(a), res) + bm = getattr(a, meth) + self.assertEqual(bm(), res) + + def binop_test(self, a, b, res, expr="a+b", meth="__add__"): + d = {'a': a, 'b': b} + + # XXX Hack so this passes before 2.3 when -Qnew is specified. + if meth == "__div__" and 1/2 == 0.5: + meth = "__truediv__" + + if meth == '__divmod__': pass + + self.assertEqual(eval(expr, d), res) + t = type(a) + m = getattr(t, meth) + while meth not in t.__dict__: + t = t.__bases__[0] + self.assertEqual(m, t.__dict__[meth]) + self.assertEqual(m(a, b), res) + bm = getattr(a, meth) + self.assertEqual(bm(b), res) + + def sliceop_test(self, a, b, c, res, expr="a[b:c]", meth="__getitem__"): + d = {'a': a, 'b': b, 'c': c} + self.assertEqual(eval(expr, d), res) + t = type(a) + m = getattr(t, meth) + while meth not in t.__dict__: + t = t.__bases__[0] + self.assertEqual(m, t.__dict__[meth]) + self.assertEqual(m(a, slice(b, c)), res) + bm = getattr(a, meth) + self.assertEqual(bm(slice(b, c)), res) + + def setop_test(self, a, b, res, stmt="a+=b", meth="__iadd__"): + d = {'a': deepcopy(a), 'b': b} + exec(stmt, d) + self.assertEqual(d['a'], res) + t = type(a) + m = getattr(t, meth) + while meth not in t.__dict__: + t = t.__bases__[0] + self.assertEqual(m, t.__dict__[meth]) + d['a'] = deepcopy(a) + m(d['a'], b) + self.assertEqual(d['a'], res) + d['a'] = deepcopy(a) + bm = getattr(d['a'], meth) + bm(b) + self.assertEqual(d['a'], res) + + def set2op_test(self, a, b, c, res, stmt="a[b]=c", meth="__setitem__"): + d = {'a': deepcopy(a), 'b': b, 'c': c} + exec(stmt, d) + self.assertEqual(d['a'], res) + t = type(a) + m = getattr(t, meth) + while meth not in t.__dict__: + t = t.__bases__[0] + self.assertEqual(m, t.__dict__[meth]) + d['a'] = deepcopy(a) + m(d['a'], b, c) + self.assertEqual(d['a'], res) + d['a'] = deepcopy(a) + bm = getattr(d['a'], meth) + bm(b, c) + self.assertEqual(d['a'], res) + + def setsliceop_test(self, a, b, c, d, res, stmt="a[b:c]=d", meth="__setitem__"): + dictionary = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d} + exec(stmt, dictionary) + self.assertEqual(dictionary['a'], res) + t = type(a) + while meth not in t.__dict__: + t = t.__bases__[0] + m = getattr(t, meth) + self.assertEqual(m, t.__dict__[meth]) + dictionary['a'] = deepcopy(a) + m(dictionary['a'], slice(b, c), d) + self.assertEqual(dictionary['a'], res) + dictionary['a'] = deepcopy(a) + bm = getattr(dictionary['a'], meth) + bm(slice(b, c), d) + self.assertEqual(dictionary['a'], res) + + def test_lists(self): + # Testing list operations... + # Asserts are within individual test methods + self.binop_test([1], [2], [1,2], "a+b", "__add__") + self.binop_test([1,2,3], 2, 1, "b in a", "__contains__") + self.binop_test([1,2,3], 4, 0, "b in a", "__contains__") + self.binop_test([1,2,3], 1, 2, "a[b]", "__getitem__") + self.sliceop_test([1,2,3], 0, 2, [1,2], "a[b:c]", "__getitem__") + self.setop_test([1], [2], [1,2], "a+=b", "__iadd__") + self.setop_test([1,2], 3, [1,2,1,2,1,2], "a*=b", "__imul__") + self.unop_test([1,2,3], 3, "len(a)", "__len__") + self.binop_test([1,2], 3, [1,2,1,2,1,2], "a*b", "__mul__") + self.binop_test([1,2], 3, [1,2,1,2,1,2], "b*a", "__rmul__") + self.set2op_test([1,2], 1, 3, [1,3], "a[b]=c", "__setitem__") + self.setsliceop_test([1,2,3,4], 1, 3, [5,6], [1,5,6,4], "a[b:c]=d", + "__setitem__") + + def test_dicts(self): + # Testing dict operations... + ## self.binop_test({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__") + self.binop_test({1:2,3:4}, 1, 1, "b in a", "__contains__") + self.binop_test({1:2,3:4}, 2, 0, "b in a", "__contains__") + self.binop_test({1:2,3:4}, 1, 2, "a[b]", "__getitem__") + + d = {1:2, 3:4} + l1 = [] + for i in list(d.keys()): + l1.append(i) + l = [] + for i in iter(d): + l.append(i) + self.assertEqual(l, l1) + l = [] + for i in d.__iter__(): + l.append(i) + self.assertEqual(l, l1) + l = [] + for i in dict.__iter__(d): + l.append(i) + self.assertEqual(l, l1) + d = {1:2, 3:4} + self.unop_test(d, 2, "len(a)", "__len__") + self.assertEqual(eval(repr(d), {}), d) + self.assertEqual(eval(d.__repr__(), {}), d) + self.set2op_test({1:2,3:4}, 2, 3, {1:2,2:3,3:4}, "a[b]=c", + "__setitem__") + + # Tests for unary and binary operators + def number_operators(self, a, b, skip=[]): + dict = {'a': a, 'b': b} + + for name, expr in list(self.binops.items()): + if name not in skip: + name = "__%s__" % name + if hasattr(a, name): + res = eval(expr, dict) + self.binop_test(a, b, res, expr, name) + + for name, expr in list(self.unops.items()): + if name not in skip: + name = "__%s__" % name + if hasattr(a, name): + res = eval(expr, dict) + self.unop_test(a, res, expr, name) + + def test_ints(self): + # Testing int operations... + self.number_operators(100, 3) + # The following crashes in Python 2.2 + self.assertEqual((1).__bool__(), 1) + self.assertEqual((0).__bool__(), 0) + # This returns 'NotImplemented' in Python 2.2 + class C(int): + def __add__(self, other): + return NotImplemented + self.assertEqual(C(5), 5) + try: + C() + "" + except TypeError: + pass + else: + self.fail("NotImplemented should have caused TypeError") + + def test_longs(self): + # Testing long operations... + self.number_operators(100, 3) + + def test_floats(self): + # Testing float operations... + self.number_operators(100.0, 3.0) + + def test_complexes(self): + # Testing complex operations... + self.number_operators(100.0j, 3.0j, skip=['lt', 'le', 'gt', 'ge', + 'int', 'long', 'float', + 'divmod', 'mod']) + + class Number(complex): + __slots__ = ['prec'] + def __new__(cls, *args, **kwds): + result = complex.__new__(cls, *args) + result.prec = kwds.get('prec', 12) + return result + def __repr__(self): + prec = self.prec + if self.imag == 0.0: + return "%.*g" % (prec, self.real) + if self.real == 0.0: + return "%.*gj" % (prec, self.imag) + return "(%.*g+%.*gj)" % (prec, self.real, prec, self.imag) + __str__ = __repr__ + + a = Number(3.14, prec=6) + self.assertEqual(repr(a), "3.14") + self.assertEqual(a.prec, 6) + + a = Number(a, prec=2) + self.assertEqual(repr(a), "3.1") + self.assertEqual(a.prec, 2) + + a = Number(234.5) + self.assertEqual(repr(a), "234.5") + self.assertEqual(a.prec, 12) + + def test_spam_lists(self): + # Testing spamlist operations... + import copy, xxsubtype as spam + + def spamlist(l, memo=None): + import xxsubtype as spam + return spam.spamlist(l) + + # This is an ugly hack: + copy._deepcopy_dispatch[spam.spamlist] = spamlist + + self.binop_test(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+b", + "__add__") + self.binop_test(spamlist([1,2,3]), 2, 1, "b in a", "__contains__") + self.binop_test(spamlist([1,2,3]), 4, 0, "b in a", "__contains__") + self.binop_test(spamlist([1,2,3]), 1, 2, "a[b]", "__getitem__") + self.sliceop_test(spamlist([1,2,3]), 0, 2, spamlist([1,2]), "a[b:c]", + "__getitem__") + self.setop_test(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+=b", + "__iadd__") + self.setop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*=b", + "__imul__") + self.unop_test(spamlist([1,2,3]), 3, "len(a)", "__len__") + self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*b", + "__mul__") + self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "b*a", + "__rmul__") + self.set2op_test(spamlist([1,2]), 1, 3, spamlist([1,3]), "a[b]=c", + "__setitem__") + self.setsliceop_test(spamlist([1,2,3,4]), 1, 3, spamlist([5,6]), + spamlist([1,5,6,4]), "a[b:c]=d", "__setitem__") + # Test subclassing + class C(spam.spamlist): + def foo(self): return 1 + a = C() + self.assertEqual(a, []) + self.assertEqual(a.foo(), 1) + a.append(100) + self.assertEqual(a, [100]) + self.assertEqual(a.getstate(), 0) + a.setstate(42) + self.assertEqual(a.getstate(), 42) + + def test_spam_dicts(self): + # Testing spamdict operations... + import copy, xxsubtype as spam + def spamdict(d, memo=None): + import xxsubtype as spam + sd = spam.spamdict() + for k, v in list(d.items()): + sd[k] = v + return sd + # This is an ugly hack: + copy._deepcopy_dispatch[spam.spamdict] = spamdict + + ## self.binop_test(spamdict({1:2}), spamdict({2:1}), -1, "cmp(a,b)", + ## "__cmp__") + self.binop_test(spamdict({1:2,3:4}), 1, 1, "b in a", "__contains__") + self.binop_test(spamdict({1:2,3:4}), 2, 0, "b in a", "__contains__") + self.binop_test(spamdict({1:2,3:4}), 1, 2, "a[b]", "__getitem__") + d = spamdict({1:2,3:4}) + l1 = [] + for i in list(d.keys()): + l1.append(i) + l = [] + for i in iter(d): + l.append(i) + self.assertEqual(l, l1) + l = [] + for i in d.__iter__(): + l.append(i) + self.assertEqual(l, l1) + l = [] + for i in type(spamdict({})).__iter__(d): + l.append(i) + self.assertEqual(l, l1) + straightd = {1:2, 3:4} + spamd = spamdict(straightd) + self.unop_test(spamd, 2, "len(a)", "__len__") + self.unop_test(spamd, repr(straightd), "repr(a)", "__repr__") + self.set2op_test(spamdict({1:2,3:4}), 2, 3, spamdict({1:2,2:3,3:4}), + "a[b]=c", "__setitem__") + # Test subclassing + class C(spam.spamdict): + def foo(self): return 1 + a = C() + self.assertEqual(list(a.items()), []) + self.assertEqual(a.foo(), 1) + a['foo'] = 'bar' + self.assertEqual(list(a.items()), [('foo', 'bar')]) + self.assertEqual(a.getstate(), 0) + a.setstate(100) + self.assertEqual(a.getstate(), 100) + +class ClassPropertiesAndMethods(unittest.TestCase): + + def test_python_dicts(self): + # Testing Python subclass of dict... + self.assert_(issubclass(dict, dict)) + self.assert_(isinstance({}, dict)) + d = dict() + self.assertEqual(d, {}) + self.assert_(d.__class__ is dict) + self.assert_(isinstance(d, dict)) + class C(dict): + state = -1 + def __init__(self_local, *a, **kw): + if a: + self.assertEqual(len(a), 1) + self_local.state = a[0] + if kw: + for k, v in list(kw.items()): + self_local[v] = k + def __getitem__(self, key): + return self.get(key, 0) + def __setitem__(self_local, key, value): + self.assert_(isinstance(key, type(0))) + dict.__setitem__(self_local, key, value) + def setstate(self, state): + self.state = state + def getstate(self): + return self.state + self.assert_(issubclass(C, dict)) + a1 = C(12) + self.assertEqual(a1.state, 12) + a2 = C(foo=1, bar=2) + self.assertEqual(a2[1] == 'foo' and a2[2], 'bar') + a = C() + self.assertEqual(a.state, -1) + self.assertEqual(a.getstate(), -1) + a.setstate(0) + self.assertEqual(a.state, 0) + self.assertEqual(a.getstate(), 0) + a.setstate(10) + self.assertEqual(a.state, 10) + self.assertEqual(a.getstate(), 10) + self.assertEqual(a[42], 0) + a[42] = 24 + self.assertEqual(a[42], 24) + N = 50 + for i in range(N): + a[i] = C() + for j in range(N): + a[i][j] = i*j + for i in range(N): + for j in range(N): + self.assertEqual(a[i][j], i*j) + + def test_python_lists(self): + # Testing Python subclass of list... + class C(list): + def __getitem__(self, i): + if isinstance(i, slice): + return i.start, i.stop + return list.__getitem__(self, i) + 100 + a = C() + a.extend([0,1,2]) + self.assertEqual(a[0], 100) + self.assertEqual(a[1], 101) + self.assertEqual(a[2], 102) + self.assertEqual(a[100:200], (100,200)) + + def test_metaclass(self): + # Testing __metaclass__... + class C(metaclass=type): + def __init__(self): + self.__state = 0 + def getstate(self): + return self.__state + def setstate(self, state): + self.__state = state + a = C() + self.assertEqual(a.getstate(), 0) + a.setstate(10) + self.assertEqual(a.getstate(), 10) + class _metaclass(type): + def myself(cls): return cls + class D(metaclass=_metaclass): + pass + self.assertEqual(D.myself(), D) + d = D() + self.assertEqual(d.__class__, D) + class M1(type): + def __new__(cls, name, bases, dict): + dict['__spam__'] = 1 + return type.__new__(cls, name, bases, dict) + class C(metaclass=M1): + pass + self.assertEqual(C.__spam__, 1) + c = C() + self.assertEqual(c.__spam__, 1) + + class _instance(object): + pass + class M2(object): + @staticmethod + def __new__(cls, name, bases, dict): + self = object.__new__(cls) + self.name = name + self.bases = bases + self.dict = dict + return self + def __call__(self): + it = _instance() + # Early binding of methods + for key in self.dict: + if key.startswith("__"): + continue + setattr(it, key, self.dict[key].__get__(it, self)) + return it + class C(metaclass=M2): + def spam(self): + return 42 + self.assertEqual(C.name, 'C') + self.assertEqual(C.bases, ()) + self.assert_('spam' in C.dict) + c = C() + self.assertEqual(c.spam(), 42) + + # More metaclass examples + + class autosuper(type): + # Automatically add __super to the class + # This trick only works for dynamic classes + def __new__(metaclass, name, bases, dict): + cls = super(autosuper, metaclass).__new__(metaclass, + name, bases, dict) + # Name mangling for __super removes leading underscores + while name[:1] == "_": + name = name[1:] + if name: + name = "_%s__super" % name + else: + name = "__super" + setattr(cls, name, super(cls)) + return cls + class A(metaclass=autosuper): + def meth(self): + return "A" + class B(A): + def meth(self): + return "B" + self.__super.meth() + class C(A): + def meth(self): + return "C" + self.__super.meth() + class D(C, B): + def meth(self): + return "D" + self.__super.meth() + self.assertEqual(D().meth(), "DCBA") + class E(B, C): + def meth(self): + return "E" + self.__super.meth() + self.assertEqual(E().meth(), "EBCA") + + class autoproperty(type): + # Automatically create property attributes when methods + # named _get_x and/or _set_x are found + def __new__(metaclass, name, bases, dict): + hits = {} + for key, val in dict.items(): + if key.startswith("_get_"): + key = key[5:] + get, set = hits.get(key, (None, None)) + get = val + hits[key] = get, set + elif key.startswith("_set_"): + key = key[5:] + get, set = hits.get(key, (None, None)) + set = val + hits[key] = get, set + for key, (get, set) in hits.items(): + dict[key] = property(get, set) + return super(autoproperty, metaclass).__new__(metaclass, + name, bases, dict) + class A(metaclass=autoproperty): + def _get_x(self): + return -self.__x + def _set_x(self, x): + self.__x = -x + a = A() + self.assert_(not hasattr(a, "x")) + a.x = 12 + self.assertEqual(a.x, 12) + self.assertEqual(a._A__x, -12) + + class multimetaclass(autoproperty, autosuper): + # Merge of multiple cooperating metaclasses + pass + class A(metaclass=multimetaclass): + def _get_x(self): + return "A" + class B(A): + def _get_x(self): + return "B" + self.__super._get_x() + class C(A): + def _get_x(self): + return "C" + self.__super._get_x() + class D(C, B): + def _get_x(self): + return "D" + self.__super._get_x() + self.assertEqual(D().x, "DCBA") + + # Make sure type(x) doesn't call x.__class__.__init__ + class T(type): + counter = 0 + def __init__(self, *args): + T.counter += 1 + class C(metaclass=T): + pass + self.assertEqual(T.counter, 1) + a = C() + self.assertEqual(type(a), C) + self.assertEqual(T.counter, 1) + + class C(object): pass + c = C() + try: c() + except TypeError: pass + else: self.fail("calling object w/o call method should raise " + "TypeError") + + # Testing code to find most derived baseclass + class A(type): + def __new__(*args, **kwargs): + return type.__new__(*args, **kwargs) + + class B(object): + pass + + class C(object, metaclass=A): + pass + + # The most derived metaclass of D is A rather than type. + class D(B, C): + pass + + def test_module_subclasses(self): + # Testing Python subclass of module... + log = [] + import types, sys + MT = type(sys) + class MM(MT): + def __init__(self, name): + MT.__init__(self, name) + def __getattribute__(self, name): + log.append(("getattr", name)) + return MT.__getattribute__(self, name) + def __setattr__(self, name, value): + log.append(("setattr", name, value)) + MT.__setattr__(self, name, value) + def __delattr__(self, name): + log.append(("delattr", name)) + MT.__delattr__(self, name) + a = MM("a") + a.foo = 12 + x = a.foo + del a.foo + self.assertEqual(log, [("setattr", "foo", 12), + ("getattr", "foo"), + ("delattr", "foo")]) + + # http://python.org/sf/1174712 + try: + class Module(types.ModuleType, str): + pass + except TypeError: + pass + else: + self.fail("inheriting from ModuleType and str at the same time " + "should fail") + + def test_multiple_inheritance(self): + # Testing multiple inheritance... + class C(object): + def __init__(self): + self.__state = 0 + def getstate(self): + return self.__state + def setstate(self, state): + self.__state = state + a = C() + self.assertEqual(a.getstate(), 0) + a.setstate(10) + self.assertEqual(a.getstate(), 10) + class D(dict, C): + def __init__(self): + type({}).__init__(self) + C.__init__(self) + d = D() + self.assertEqual(list(d.keys()), []) + d["hello"] = "world" + self.assertEqual(list(d.items()), [("hello", "world")]) + self.assertEqual(d["hello"], "world") + self.assertEqual(d.getstate(), 0) + d.setstate(10) + self.assertEqual(d.getstate(), 10) + self.assertEqual(D.__mro__, (D, dict, C, object)) + + # SF bug #442833 + class Node(object): + def __int__(self): + return int(self.foo()) + def foo(self): + return "23" + class Frag(Node, list): + def foo(self): + return "42" + self.assertEqual(Node().__int__(), 23) + self.assertEqual(int(Node()), 23) + self.assertEqual(Frag().__int__(), 42) + self.assertEqual(int(Frag()), 42) + + def test_diamond_inheritence(self): + # Testing multiple inheritance special cases... + class A(object): + def spam(self): return "A" + self.assertEqual(A().spam(), "A") + class B(A): + def boo(self): return "B" + def spam(self): return "B" + self.assertEqual(B().spam(), "B") + self.assertEqual(B().boo(), "B") + class C(A): + def boo(self): return "C" + self.assertEqual(C().spam(), "A") + self.assertEqual(C().boo(), "C") + class D(B, C): pass + self.assertEqual(D().spam(), "B") + self.assertEqual(D().boo(), "B") + self.assertEqual(D.__mro__, (D, B, C, A, object)) + class E(C, B): pass + self.assertEqual(E().spam(), "B") + self.assertEqual(E().boo(), "C") + self.assertEqual(E.__mro__, (E, C, B, A, object)) + # MRO order disagreement + try: + class F(D, E): pass + except TypeError: + pass + else: + self.fail("expected MRO order disagreement (F)") + try: + class G(E, D): pass + except TypeError: + pass + else: + self.fail("expected MRO order disagreement (G)") + + # see thread python-dev/2002-October/029035.html + def test_ex5_from_c3_switch(self): + # Testing ex5 from C3 switch discussion... + class A(object): pass + class B(object): pass + class C(object): pass + class X(A): pass + class Y(A): pass + class Z(X,B,Y,C): pass + self.assertEqual(Z.__mro__, (Z, X, B, Y, A, C, object)) + + # see "A Monotonic Superclass Linearization for Dylan", + # by Kim Barrett et al. (OOPSLA 1996) + def test_monotonicity(self): + # Testing MRO monotonicity... + class Boat(object): pass + class DayBoat(Boat): pass + class WheelBoat(Boat): pass + class EngineLess(DayBoat): pass + class SmallMultihull(DayBoat): pass + class PedalWheelBoat(EngineLess,WheelBoat): pass + class SmallCatamaran(SmallMultihull): pass + class Pedalo(PedalWheelBoat,SmallCatamaran): pass + + self.assertEqual(PedalWheelBoat.__mro__, + (PedalWheelBoat, EngineLess, DayBoat, WheelBoat, Boat, object)) + self.assertEqual(SmallCatamaran.__mro__, + (SmallCatamaran, SmallMultihull, DayBoat, Boat, object)) + self.assertEqual(Pedalo.__mro__, + (Pedalo, PedalWheelBoat, EngineLess, SmallCatamaran, + SmallMultihull, DayBoat, WheelBoat, Boat, object)) + + # see "A Monotonic Superclass Linearization for Dylan", + # by Kim Barrett et al. (OOPSLA 1996) + def test_consistency_with_epg(self): + # Testing consistentcy with EPG... + class Pane(object): pass + class ScrollingMixin(object): pass + class EditingMixin(object): pass + class ScrollablePane(Pane,ScrollingMixin): pass + class EditablePane(Pane,EditingMixin): pass + class EditableScrollablePane(ScrollablePane,EditablePane): pass + + self.assertEqual(EditableScrollablePane.__mro__, + (EditableScrollablePane, ScrollablePane, EditablePane, Pane, + ScrollingMixin, EditingMixin, object)) + + def test_mro_disagreement(self): + # Testing error messages for MRO disagreement... + mro_err_msg = """Cannot create a consistent method resolution +order (MRO) for bases """ + + def raises(exc, expected, callable, *args): + try: + callable(*args) + except exc as msg: + if not str(msg).startswith(expected): + self.fail("Message %r, expected %r" % (str(msg), expected)) + else: + self.fail("Expected %s" % exc) + + class A(object): pass + class B(A): pass + class C(object): pass + + # Test some very simple errors + raises(TypeError, "duplicate base class A", + type, "X", (A, A), {}) + raises(TypeError, mro_err_msg, + type, "X", (A, B), {}) + raises(TypeError, mro_err_msg, + type, "X", (A, C, B), {}) + # Test a slightly more complex error + class GridLayout(object): pass + class HorizontalGrid(GridLayout): pass + class VerticalGrid(GridLayout): pass + class HVGrid(HorizontalGrid, VerticalGrid): pass + class VHGrid(VerticalGrid, HorizontalGrid): pass + raises(TypeError, mro_err_msg, + type, "ConfusedGrid", (HVGrid, VHGrid), {}) + + def test_object_class(self): + # Testing object class... + a = object() + self.assertEqual(a.__class__, object) + self.assertEqual(type(a), object) + b = object() + self.assertNotEqual(a, b) + self.assertFalse(hasattr(a, "foo")) + try: + a.foo = 12 + except (AttributeError, TypeError): + pass + else: + self.fail("object() should not allow setting a foo attribute") + self.assertFalse(hasattr(object(), "__dict__")) + + class Cdict(object): + pass + x = Cdict() + self.assertEqual(x.__dict__, {}) + x.foo = 1 + self.assertEqual(x.foo, 1) + self.assertEqual(x.__dict__, {'foo': 1}) + + def test_slots(self): + # Testing __slots__... + class C0(object): + __slots__ = [] + x = C0() + self.assertFalse(hasattr(x, "__dict__")) + self.assertFalse(hasattr(x, "foo")) + + class C1(object): + __slots__ = ['a'] + x = C1() + self.assertFalse(hasattr(x, "__dict__")) + self.assertFalse(hasattr(x, "a")) + x.a = 1 + self.assertEqual(x.a, 1) + x.a = None + self.assertEqual(x.a, None) + del x.a + self.assertFalse(hasattr(x, "a")) + + class C3(object): + __slots__ = ['a', 'b', 'c'] + x = C3() + self.assertFalse(hasattr(x, "__dict__")) + self.assertFalse(hasattr(x, 'a')) + self.assertFalse(hasattr(x, 'b')) + self.assertFalse(hasattr(x, 'c')) + x.a = 1 + x.b = 2 + x.c = 3 + self.assertEqual(x.a, 1) + self.assertEqual(x.b, 2) + self.assertEqual(x.c, 3) + + class C4(object): + """Validate name mangling""" + __slots__ = ['__a'] + def __init__(self, value): + self.__a = value + def get(self): + return self.__a + x = C4(5) + self.assertFalse(hasattr(x, '__dict__')) + self.assertFalse(hasattr(x, '__a')) + self.assertEqual(x.get(), 5) + try: + x.__a = 6 + except AttributeError: + pass + else: + self.fail("Double underscored names not mangled") + + # Make sure slot names are proper identifiers + try: + class C(object): + __slots__ = [None] + except TypeError: + pass + else: + self.fail("[None] slots not caught") + try: + class C(object): + __slots__ = ["foo bar"] + except TypeError: + pass + else: + self.fail("['foo bar'] slots not caught") + try: + class C(object): + __slots__ = ["foo\0bar"] + except TypeError: + pass + else: + self.fail("['foo\\0bar'] slots not caught") + try: + class C(object): + __slots__ = ["1"] + except TypeError: + pass + else: + self.fail("['1'] slots not caught") + try: + class C(object): + __slots__ = [""] + except TypeError: + pass + else: + self.fail("[''] slots not caught") + class C(object): + __slots__ = ["a", "a_b", "_a", "A0123456789Z"] + # XXX(nnorwitz): was there supposed to be something tested + # from the class above? + + # Test a single string is not expanded as a sequence. + class C(object): + __slots__ = "abc" + c = C() + c.abc = 5 + self.assertEqual(c.abc, 5) + + # Test unicode slot names + # Test a single unicode string is not expanded as a sequence. + class C(object): + __slots__ = "abc" + c = C() + c.abc = 5 + self.assertEqual(c.abc, 5) + + # _unicode_to_string used to modify slots in certain circumstances + slots = ("foo", "bar") + class C(object): + __slots__ = slots + x = C() + x.foo = 5 + self.assertEqual(x.foo, 5) + self.assert_(type(slots[0]) is str) + # this used to leak references + try: + class C(object): + __slots__ = [chr(128)] + except (TypeError, UnicodeEncodeError): + pass + else: + raise TestFailed("[chr(128)] slots not caught") + + # Test leaks + class Counted(object): + counter = 0 # counts the number of instances alive + def __init__(self): + Counted.counter += 1 + def __del__(self): + Counted.counter -= 1 + class C(object): + __slots__ = ['a', 'b', 'c'] + x = C() + x.a = Counted() + x.b = Counted() + x.c = Counted() + self.assertEqual(Counted.counter, 3) + del x + self.assertEqual(Counted.counter, 0) + class D(C): + pass + x = D() + x.a = Counted() + x.z = Counted() + self.assertEqual(Counted.counter, 2) + del x + self.assertEqual(Counted.counter, 0) + class E(D): + __slots__ = ['e'] + x = E() + x.a = Counted() + x.z = Counted() + x.e = Counted() + self.assertEqual(Counted.counter, 3) + del x + self.assertEqual(Counted.counter, 0) + + # Test cyclical leaks [SF bug 519621] + class F(object): + __slots__ = ['a', 'b'] + log = [] + s = F() + s.a = [Counted(), s] + self.assertEqual(Counted.counter, 1) + s = None + import gc + gc.collect() + self.assertEqual(Counted.counter, 0) + + # Test lookup leaks [SF bug 572567] + import sys,gc + class G(object): + def __cmp__(self, other): + return 0 + g = G() + orig_objects = len(gc.get_objects()) + for i in range(10): + g==g + new_objects = len(gc.get_objects()) + self.assertEqual(orig_objects, new_objects) + class H(object): + __slots__ = ['a', 'b'] + def __init__(self): + self.a = 1 + self.b = 2 + def __del__(self_): + self.assertEqual(self_.a, 1) + self.assertEqual(self_.b, 2) + + save_stderr = sys.stderr + sys.stderr = sys.stdout + h = H() + try: + del h + finally: + sys.stderr = save_stderr + + def test_slots_special(self): + # Testing __dict__ and __weakref__ in __slots__... + class D(object): + __slots__ = ["__dict__"] + a = D() + self.assert_(hasattr(a, "__dict__")) + self.assertFalse(hasattr(a, "__weakref__")) + a.foo = 42 + self.assertEqual(a.__dict__, {"foo": 42}) + + class W(object): + __slots__ = ["__weakref__"] + a = W() + self.assert_(hasattr(a, "__weakref__")) + self.assertFalse(hasattr(a, "__dict__")) + try: + a.foo = 42 + except AttributeError: + pass + else: + self.fail("shouldn't be allowed to set a.foo") + + class C1(W, D): + __slots__ = [] + a = C1() + self.assert_(hasattr(a, "__dict__")) + self.assert_(hasattr(a, "__weakref__")) + a.foo = 42 + self.assertEqual(a.__dict__, {"foo": 42}) + + class C2(D, W): + __slots__ = [] + a = C2() + self.assert_(hasattr(a, "__dict__")) + self.assert_(hasattr(a, "__weakref__")) + a.foo = 42 + self.assertEqual(a.__dict__, {"foo": 42}) + + def test_dynamics(self): + # Testing class attribute propagation... + class D(object): + pass + class E(D): + pass + class F(D): + pass + D.foo = 1 + self.assertEqual(D.foo, 1) + # Test that dynamic attributes are inherited + self.assertEqual(E.foo, 1) + self.assertEqual(F.foo, 1) + # Test dynamic instances + class C(object): + pass + a = C() + self.assertFalse(hasattr(a, "foobar")) + C.foobar = 2 + self.assertEqual(a.foobar, 2) + C.method = lambda self: 42 + self.assertEqual(a.method(), 42) + C.__repr__ = lambda self: "C()" + self.assertEqual(repr(a), "C()") + C.__int__ = lambda self: 100 + self.assertEqual(int(a), 100) + self.assertEqual(a.foobar, 2) + self.assertFalse(hasattr(a, "spam")) + def mygetattr(self, name): + if name == "spam": + return "spam" + raise AttributeError + C.__getattr__ = mygetattr + self.assertEqual(a.spam, "spam") + a.new = 12 + self.assertEqual(a.new, 12) + def mysetattr(self, name, value): + if name == "spam": + raise AttributeError + return object.__setattr__(self, name, value) + C.__setattr__ = mysetattr + try: + a.spam = "not spam" + except AttributeError: + pass + else: + self.fail("expected AttributeError") + self.assertEqual(a.spam, "spam") + class D(C): + pass + d = D() + d.foo = 1 + self.assertEqual(d.foo, 1) + + # Test handling of int*seq and seq*int + class I(int): + pass + self.assertEqual("a"*I(2), "aa") + self.assertEqual(I(2)*"a", "aa") + self.assertEqual(2*I(3), 6) + self.assertEqual(I(3)*2, 6) + self.assertEqual(I(3)*I(2), 6) + + # Test handling of long*seq and seq*long + class L(int): + pass + self.assertEqual("a"*L(2), "aa") + self.assertEqual(L(2)*"a", "aa") + self.assertEqual(2*L(3), 6) + self.assertEqual(L(3)*2, 6) + self.assertEqual(L(3)*L(2), 6) + + # Test comparison of classes with dynamic metaclasses + class dynamicmetaclass(type): + pass + class someclass(metaclass=dynamicmetaclass): + pass + self.assertNotEqual(someclass, object) + + def test_errors(self): + # Testing errors... + try: + class C(list, dict): + pass + except TypeError: + pass + else: + self.fail("inheritance from both list and dict should be illegal") + + try: + class C(object, None): + pass + except TypeError: + pass + else: + self.fail("inheritance from non-type should be illegal") + class Classic: + pass + + try: + class C(type(len)): + pass + except TypeError: + pass + else: + self.fail("inheritance from CFunction should be illegal") + + try: + class C(object): + __slots__ = 1 + except TypeError: + pass + else: + self.fail("__slots__ = 1 should be illegal") + + try: + class C(object): + __slots__ = [1] + except TypeError: + pass + else: + self.fail("__slots__ = [1] should be illegal") + + class M1(type): + pass + class M2(type): + pass + class A1(object, metaclass=M1): + pass + class A2(object, metaclass=M2): + pass + try: + class B(A1, A2): + pass + except TypeError: + pass + else: + self.fail("finding the most derived metaclass should have failed") + + def test_classmethods(self): + # Testing class methods... + class C(object): + def foo(*a): return a + goo = classmethod(foo) + c = C() + self.assertEqual(C.goo(1), (C, 1)) + self.assertEqual(c.goo(1), (C, 1)) + self.assertEqual(c.foo(1), (c, 1)) + class D(C): + pass + d = D() + self.assertEqual(D.goo(1), (D, 1)) + self.assertEqual(d.goo(1), (D, 1)) + self.assertEqual(d.foo(1), (d, 1)) + self.assertEqual(D.foo(d, 1), (d, 1)) + # Test for a specific crash (SF bug 528132) + def f(cls, arg): return (cls, arg) + ff = classmethod(f) + self.assertEqual(ff.__get__(0, int)(42), (int, 42)) + self.assertEqual(ff.__get__(0)(42), (int, 42)) + + # Test super() with classmethods (SF bug 535444) + self.assertEqual(C.goo.__self__, C) + self.assertEqual(D.goo.__self__, D) + self.assertEqual(super(D,D).goo.__self__, D) + self.assertEqual(super(D,d).goo.__self__, D) + self.assertEqual(super(D,D).goo(), (D,)) + self.assertEqual(super(D,d).goo(), (D,)) + + # Verify that argument is checked for callability (SF bug 753451) + try: + classmethod(1).__get__(1) + except TypeError: + pass + else: + self.fail("classmethod should check for callability") + + # Verify that classmethod() doesn't allow keyword args + try: + classmethod(f, kw=1) + except TypeError: + pass + else: + self.fail("classmethod shouldn't accept keyword args") + + def test_classmethods_in_c(self): + # Testing C-based class methods... + import xxsubtype as spam + a = (1, 2, 3) + d = {'abc': 123} + x, a1, d1 = spam.spamlist.classmeth(*a, **d) + self.assertEqual(x, spam.spamlist) + self.assertEqual(a, a1) + self.assertEqual(d, d1) + x, a1, d1 = spam.spamlist().classmeth(*a, **d) + self.assertEqual(x, spam.spamlist) + self.assertEqual(a, a1) + self.assertEqual(d, d1) + + def test_staticmethods(self): + # Testing static methods... + class C(object): + def foo(*a): return a + goo = staticmethod(foo) + c = C() + self.assertEqual(C.goo(1), (1,)) + self.assertEqual(c.goo(1), (1,)) + self.assertEqual(c.foo(1), (c, 1,)) + class D(C): + pass + d = D() + self.assertEqual(D.goo(1), (1,)) + self.assertEqual(d.goo(1), (1,)) + self.assertEqual(d.foo(1), (d, 1)) + self.assertEqual(D.foo(d, 1), (d, 1)) + + def test_staticmethods_in_c(self): + # Testing C-based static methods... + import xxsubtype as spam + a = (1, 2, 3) + d = {"abc": 123} + x, a1, d1 = spam.spamlist.staticmeth(*a, **d) + self.assertEqual(x, None) + self.assertEqual(a, a1) + self.assertEqual(d, d1) + x, a1, d2 = spam.spamlist().staticmeth(*a, **d) + self.assertEqual(x, None) + self.assertEqual(a, a1) + self.assertEqual(d, d1) + + def test_classic(self): + # Testing classic classes... + class C: + def foo(*a): return a + goo = classmethod(foo) + c = C() + self.assertEqual(C.goo(1), (C, 1)) + self.assertEqual(c.goo(1), (C, 1)) + self.assertEqual(c.foo(1), (c, 1)) + class D(C): + pass + d = D() + self.assertEqual(D.goo(1), (D, 1)) + self.assertEqual(d.goo(1), (D, 1)) + self.assertEqual(d.foo(1), (d, 1)) + self.assertEqual(D.foo(d, 1), (d, 1)) + class E: # *not* subclassing from C + foo = C.foo + self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound + self.assert_(repr(C.foo.__get__(C())).startswith("= 0) + self.assertEqual(str(c1), repr(c1)) + self.assert_(-1 not in c1) + for i in range(10): + self.assert_(i in c1) + self.assertFalse(10 in c1) + # Test the default behavior for dynamic classes + class D(object): + def __getitem__(self, i): + if 0 <= i < 10: return i + raise IndexError + d1 = D() + d2 = D() + self.assert_(not not d1) + self.assertNotEqual(id(d1), id(d2)) + hash(d1) + hash(d2) + ## self.assertEqual(cmp(d1, d2), cmp(id(d1), id(d2))) + self.assertEqual(d1, d1) + self.assertNotEqual(d1, d2) + self.assert_(not d1 != d1) + self.assert_(not d1 == d2) + # Note that the module name appears in str/repr, and that varies + # depending on whether this test is run standalone or from a framework. + self.assert_(str(d1).find('D object at ') >= 0) + self.assertEqual(str(d1), repr(d1)) + self.assert_(-1 not in d1) + for i in range(10): + self.assert_(i in d1) + self.assertFalse(10 in d1) + # Test overridden behavior for static classes + class Proxy(object): + def __init__(self, x): + self.x = x + def __bool__(self): + return not not self.x + def __hash__(self): + return hash(self.x) + def __eq__(self, other): + return self.x == other + def __ne__(self, other): + return self.x != other + def __cmp__(self, other): + return cmp(self.x, other.x) + def __str__(self): + return "Proxy:%s" % self.x + def __repr__(self): + return "Proxy(%r)" % self.x + def __contains__(self, value): + return value in self.x + p0 = Proxy(0) + p1 = Proxy(1) + p_1 = Proxy(-1) + self.assertFalse(p0) + self.assert_(not not p1) + self.assertEqual(hash(p0), hash(0)) + self.assertEqual(p0, p0) + self.assertNotEqual(p0, p1) + self.assert_(not p0 != p0) + self.assertEqual(not p0, p1) + self.assertEqual(cmp(p0, p1), -1) + self.assertEqual(cmp(p0, p0), 0) + self.assertEqual(cmp(p0, p_1), 1) + self.assertEqual(str(p0), "Proxy:0") + self.assertEqual(repr(p0), "Proxy(0)") + p10 = Proxy(range(10)) + self.assertFalse(-1 in p10) + for i in range(10): + self.assert_(i in p10) + self.assertFalse(10 in p10) + # Test overridden behavior for dynamic classes + class DProxy(object): + def __init__(self, x): + self.x = x + def __bool__(self): + return not not self.x + def __hash__(self): + return hash(self.x) + def __eq__(self, other): + return self.x == other + def __ne__(self, other): + return self.x != other + def __cmp__(self, other): + return cmp(self.x, other.x) + def __str__(self): + return "DProxy:%s" % self.x + def __repr__(self): + return "DProxy(%r)" % self.x + def __contains__(self, value): + return value in self.x + p0 = DProxy(0) + p1 = DProxy(1) + p_1 = DProxy(-1) + self.assertFalse(p0) + self.assert_(not not p1) + self.assertEqual(hash(p0), hash(0)) + self.assertEqual(p0, p0) + self.assertNotEqual(p0, p1) + self.assertNotEqual(not p0, p0) + self.assertEqual(not p0, p1) + self.assertEqual(cmp(p0, p1), -1) + self.assertEqual(cmp(p0, p0), 0) + self.assertEqual(cmp(p0, p_1), 1) + self.assertEqual(str(p0), "DProxy:0") + self.assertEqual(repr(p0), "DProxy(0)") + p10 = DProxy(range(10)) + self.assertFalse(-1 in p10) + for i in range(10): + self.assert_(i in p10) + self.assertFalse(10 in p10) + + ## # Safety test for __cmp__ + ## def unsafecmp(a, b): + ## try: + ## a.__class__.__cmp__(a, b) + ## except TypeError: + ## pass + ## else: + ## self.fail("shouldn't allow %s.__cmp__(%r, %r)" % ( + ## a.__class__, a, b)) + ## + ## unsafecmp("123", "123") + ## unsafecmp("123", "123") + ## unsafecmp(1, 1.0) + ## unsafecmp(1.0, 1) + ## unsafecmp(1, 1) + ## unsafecmp(1, 1) + + def test_weakrefs(self): + # Testing weak references... + import weakref + class C(object): + pass + c = C() + r = weakref.ref(c) + self.assertEqual(r(), c) + del c + self.assertEqual(r(), None) + del r + class NoWeak(object): + __slots__ = ['foo'] + no = NoWeak() + try: + weakref.ref(no) + except TypeError as msg: + self.assert_(str(msg).find("weak reference") >= 0) + else: + self.fail("weakref.ref(no) should be illegal") + class Weak(object): + __slots__ = ['foo', '__weakref__'] + yes = Weak() + r = weakref.ref(yes) + self.assertEqual(r(), yes) + del yes + self.assertEqual(r(), None) + del r + + def test_properties(self): + # Testing property... + class C(object): + def getx(self): + return self.__x + def setx(self, value): + self.__x = value + def delx(self): + del self.__x + x = property(getx, setx, delx, doc="I'm the x property.") + a = C() + self.assertFalse(hasattr(a, "x")) + a.x = 42 + self.assertEqual(a._C__x, 42) + self.assertEqual(a.x, 42) + del a.x + self.assertFalse(hasattr(a, "x")) + self.assertFalse(hasattr(a, "_C__x")) + C.x.__set__(a, 100) + self.assertEqual(C.x.__get__(a), 100) + C.x.__delete__(a) + self.assertFalse(hasattr(a, "x")) + + raw = C.__dict__['x'] + self.assert_(isinstance(raw, property)) + + attrs = dir(raw) + self.assert_("__doc__" in attrs) + self.assert_("fget" in attrs) + self.assert_("fset" in attrs) + self.assert_("fdel" in attrs) + + self.assertEqual(raw.__doc__, "I'm the x property.") + self.assert_(raw.fget is C.__dict__['getx']) + self.assert_(raw.fset is C.__dict__['setx']) + self.assert_(raw.fdel is C.__dict__['delx']) + + for attr in "__doc__", "fget", "fset", "fdel": + try: + setattr(raw, attr, 42) + except AttributeError as msg: + if str(msg).find('readonly') < 0: + self.fail("when setting readonly attr %r on a property, " + "got unexpected AttributeError msg %r" % (attr, str(msg))) + else: + self.fail("expected AttributeError from trying to set readonly %r " + "attr on a property" % attr) + + class D(object): + __getitem__ = property(lambda s: 1/0) + + d = D() + try: + for i in d: + str(i) + except ZeroDivisionError: + pass + else: + self.fail("expected ZeroDivisionError from bad property") + + class E(object): + def getter(self): + "getter method" + return 0 + def setter(self_, value): + "setter method" + pass + prop = property(getter) + self.assertEqual(prop.__doc__, "getter method") + prop2 = property(fset=setter) + self.assertEqual(prop2.__doc__, None) + + # this segfaulted in 2.5b2 + try: + import _testcapi + except ImportError: + pass + else: + class X(object): + p = property(_testcapi.test_with_docstring) + + def test_properties_plus(self): + class C(object): + foo = property(doc="hello") + @foo.getter + def foo(self): + return self._foo + @foo.setter + def foo(self, value): + self._foo = abs(value) + @foo.deleter + def foo(self): + del self._foo + c = C() + self.assertEqual(C.foo.__doc__, "hello") + self.assertFalse(hasattr(c, "foo")) + c.foo = -42 + self.assert_(hasattr(c, '_foo')) + self.assertEqual(c._foo, 42) + self.assertEqual(c.foo, 42) + del c.foo + self.assertFalse(hasattr(c, '_foo')) + self.assertFalse(hasattr(c, "foo")) + + class D(C): + @C.foo.deleter + def foo(self): + try: + del self._foo + except AttributeError: + pass + d = D() + d.foo = 24 + self.assertEqual(d.foo, 24) + del d.foo + del d.foo + + class E(object): + @property + def foo(self): + return self._foo + @foo.setter + def foo(self, value): + raise RuntimeError + @foo.setter + def foo(self, value): + self._foo = abs(value) + @foo.deleter + def foo(self, value=None): + del self._foo + + e = E() + e.foo = -42 + self.assertEqual(e.foo, 42) + del e.foo + + class F(E): + @E.foo.deleter + def foo(self): + del self._foo + @foo.setter + def foo(self, value): + self._foo = max(0, value) + f = F() + f.foo = -10 + self.assertEqual(f.foo, 0) + del f.foo + + def test_dict_constructors(self): + # Testing dict constructor ... + d = dict() + self.assertEqual(d, {}) + d = dict({}) + self.assertEqual(d, {}) + d = dict({1: 2, 'a': 'b'}) + self.assertEqual(d, {1: 2, 'a': 'b'}) + self.assertEqual(d, dict(list(d.items()))) + self.assertEqual(d, dict(iter(d.items()))) + d = dict({'one':1, 'two':2}) + self.assertEqual(d, dict(one=1, two=2)) + self.assertEqual(d, dict(**d)) + self.assertEqual(d, dict({"one": 1}, two=2)) + self.assertEqual(d, dict([("two", 2)], one=1)) + self.assertEqual(d, dict([("one", 100), ("two", 200)], **d)) + self.assertEqual(d, dict(**d)) + + for badarg in 0, 0, 0j, "0", [0], (0,): + try: + dict(badarg) + except TypeError: + pass + except ValueError: + if badarg == "0": + # It's a sequence, and its elements are also sequences (gotta + # love strings ), but they aren't of length 2, so this + # one seemed better as a ValueError than a TypeError. + pass + else: + self.fail("no TypeError from dict(%r)" % badarg) + else: + self.fail("no TypeError from dict(%r)" % badarg) + + try: + dict({}, {}) + except TypeError: + pass + else: + self.fail("no TypeError from dict({}, {})") + + class Mapping: + # Lacks a .keys() method; will be added later. + dict = {1:2, 3:4, 'a':1j} + + try: + dict(Mapping()) + except TypeError: + pass + else: + self.fail("no TypeError from dict(incomplete mapping)") + + Mapping.keys = lambda self: list(self.dict.keys()) + Mapping.__getitem__ = lambda self, i: self.dict[i] + d = dict(Mapping()) + self.assertEqual(d, Mapping.dict) + + # Init from sequence of iterable objects, each producing a 2-sequence. + class AddressBookEntry: + def __init__(self, first, last): + self.first = first + self.last = last + def __iter__(self): + return iter([self.first, self.last]) + + d = dict([AddressBookEntry('Tim', 'Warsaw'), + AddressBookEntry('Barry', 'Peters'), + AddressBookEntry('Tim', 'Peters'), + AddressBookEntry('Barry', 'Warsaw')]) + self.assertEqual(d, {'Barry': 'Warsaw', 'Tim': 'Peters'}) + + d = dict(zip(range(4), range(1, 5))) + self.assertEqual(d, dict([(i, i+1) for i in range(4)])) + + # Bad sequence lengths. + for bad in [('tooshort',)], [('too', 'long', 'by 1')]: + try: + dict(bad) + except ValueError: + pass + else: + self.fail("no ValueError from dict(%r)" % bad) + + def test_dir(self): + # Testing dir() ... + junk = 12 + self.assertEqual(dir(), ['junk', 'self']) + del junk + + # Just make sure these don't blow up! + for arg in 2, 2, 2j, 2e0, [2], "2", b"2", (2,), {2:2}, type, self.test_dir: + dir(arg) + + # Test dir on new-style classes. Since these have object as a + # base class, a lot more gets sucked in. + def interesting(strings): + return [s for s in strings if not s.startswith('_')] + + class C(object): + Cdata = 1 + def Cmethod(self): pass + + cstuff = ['Cdata', 'Cmethod'] + self.assertEqual(interesting(dir(C)), cstuff) + + c = C() + self.assertEqual(interesting(dir(c)), cstuff) + ## self.assert_('__self__' in dir(C.Cmethod)) + + c.cdata = 2 + c.cmethod = lambda self: 0 + self.assertEqual(interesting(dir(c)), cstuff + ['cdata', 'cmethod']) + ## self.assert_('__self__' in dir(c.Cmethod)) + + class A(C): + Adata = 1 + def Amethod(self): pass + + astuff = ['Adata', 'Amethod'] + cstuff + self.assertEqual(interesting(dir(A)), astuff) + ## self.assert_('__self__' in dir(A.Amethod)) + a = A() + self.assertEqual(interesting(dir(a)), astuff) + a.adata = 42 + a.amethod = lambda self: 3 + self.assertEqual(interesting(dir(a)), astuff + ['adata', 'amethod']) + ## self.assert_('__self__' in dir(a.Amethod)) + + # Try a module subclass. + import sys + class M(type(sys)): + pass + minstance = M("m") + minstance.b = 2 + minstance.a = 1 + names = [x for x in dir(minstance) if x not in ["__name__", "__doc__"]] + self.assertEqual(names, ['a', 'b']) + + class M2(M): + def getdict(self): + return "Not a dict!" + __dict__ = property(getdict) + + m2instance = M2("m2") + m2instance.b = 2 + m2instance.a = 1 + self.assertEqual(m2instance.__dict__, "Not a dict!") + try: + dir(m2instance) + except TypeError: + pass + + # Two essentially featureless objects, just inheriting stuff from + # object. + self.assertEqual(dir(None), dir(Ellipsis)) + + # Nasty test case for proxied objects + class Wrapper(object): + def __init__(self, obj): + self.__obj = obj + def __repr__(self): + return "Wrapper(%s)" % repr(self.__obj) + def __getitem__(self, key): + return Wrapper(self.__obj[key]) + def __len__(self): + return len(self.__obj) + def __getattr__(self, name): + return Wrapper(getattr(self.__obj, name)) + + class C(object): + def __getclass(self): + return Wrapper(type(self)) + __class__ = property(__getclass) + + dir(C()) # This used to segfault + + def test_supers(self): + # Testing super... + + class A(object): + def meth(self, a): + return "A(%r)" % a + + self.assertEqual(A().meth(1), "A(1)") + + class B(A): + def __init__(self): + self.__super = super(B, self) + def meth(self, a): + return "B(%r)" % a + self.__super.meth(a) + + self.assertEqual(B().meth(2), "B(2)A(2)") + + class C(A): + def meth(self, a): + return "C(%r)" % a + self.__super.meth(a) + C._C__super = super(C) + + self.assertEqual(C().meth(3), "C(3)A(3)") + + class D(C, B): + def meth(self, a): + return "D(%r)" % a + super(D, self).meth(a) + + self.assertEqual(D().meth(4), "D(4)C(4)B(4)A(4)") + + # Test for subclassing super + + class mysuper(super): + def __init__(self, *args): + return super(mysuper, self).__init__(*args) + + class E(D): + def meth(self, a): + return "E(%r)" % a + mysuper(E, self).meth(a) + + self.assertEqual(E().meth(5), "E(5)D(5)C(5)B(5)A(5)") + + class F(E): + def meth(self, a): + s = self.__super # == mysuper(F, self) + return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a) + F._F__super = mysuper(F) + + self.assertEqual(F().meth(6), "F(6)[mysuper]E(6)D(6)C(6)B(6)A(6)") + + # Make sure certain errors are raised + + try: + super(D, 42) + except TypeError: + pass + else: + self.fail("shouldn't allow super(D, 42)") + + try: + super(D, C()) + except TypeError: + pass + else: + self.fail("shouldn't allow super(D, C())") + + try: + super(D).__get__(12) + except TypeError: + pass + else: + self.fail("shouldn't allow super(D).__get__(12)") + + try: + super(D).__get__(C()) + except TypeError: + pass + else: + self.fail("shouldn't allow super(D).__get__(C())") + + # Make sure data descriptors can be overridden and accessed via super + # (new feature in Python 2.3) + + class DDbase(object): + def getx(self): return 42 + x = property(getx) + + class DDsub(DDbase): + def getx(self): return "hello" + x = property(getx) + + dd = DDsub() + self.assertEqual(dd.x, "hello") + self.assertEqual(super(DDsub, dd).x, 42) + + # Ensure that super() lookup of descriptor from classmethod + # works (SF ID# 743627) + + class Base(object): + aProp = property(lambda self: "foo") + + class Sub(Base): + @classmethod + def test(klass): + return super(Sub,klass).aProp + + self.assertEqual(Sub.test(), Base.aProp) + + # Verify that super() doesn't allow keyword args + try: + super(Base, kw=1) + except TypeError: + pass + else: + self.assertEqual("super shouldn't accept keyword args") + + def test_basic_inheritance(self): + # Testing inheritance from basic types... + + class hexint(int): + def __repr__(self): + return hex(self) + def __add__(self, other): + return hexint(int.__add__(self, other)) + # (Note that overriding __radd__ doesn't work, + # because the int type gets first dibs.) + self.assertEqual(repr(hexint(7) + 9), "0x10") + self.assertEqual(repr(hexint(1000) + 7), "0x3ef") + a = hexint(12345) + self.assertEqual(a, 12345) + self.assertEqual(int(a), 12345) + self.assert_(int(a).__class__ is int) + self.assertEqual(hash(a), hash(12345)) + self.assert_((+a).__class__ is int) + self.assert_((a >> 0).__class__ is int) + self.assert_((a << 0).__class__ is int) + self.assert_((hexint(0) << 12).__class__ is int) + self.assert_((hexint(0) >> 12).__class__ is int) + + class octlong(int): + __slots__ = [] + def __str__(self): + s = oct(self) + if s[-1] == 'L': + s = s[:-1] + return s + def __add__(self, other): + return self.__class__(super(octlong, self).__add__(other)) + __radd__ = __add__ + self.assertEqual(str(octlong(3) + 5), "0o10") + # (Note that overriding __radd__ here only seems to work + # because the example uses a short int left argument.) + self.assertEqual(str(5 + octlong(3000)), "0o5675") + a = octlong(12345) + self.assertEqual(a, 12345) + self.assertEqual(int(a), 12345) + self.assertEqual(hash(a), hash(12345)) + self.assert_(int(a).__class__ is int) + self.assert_((+a).__class__ is int) + self.assert_((-a).__class__ is int) + self.assert_((-octlong(0)).__class__ is int) + self.assert_((a >> 0).__class__ is int) + self.assert_((a << 0).__class__ is int) + self.assert_((a - 0).__class__ is int) + self.assert_((a * 1).__class__ is int) + self.assert_((a ** 1).__class__ is int) + self.assert_((a // 1).__class__ is int) + self.assert_((1 * a).__class__ is int) + self.assert_((a | 0).__class__ is int) + self.assert_((a ^ 0).__class__ is int) + self.assert_((a & -1).__class__ is int) + self.assert_((octlong(0) << 12).__class__ is int) + self.assert_((octlong(0) >> 12).__class__ is int) + self.assert_(abs(octlong(0)).__class__ is int) + + # Because octlong overrides __add__, we can't check the absence of +0 + # optimizations using octlong. + class longclone(int): + pass + a = longclone(1) + self.assert_((a + 0).__class__ is int) + self.assert_((0 + a).__class__ is int) + + # Check that negative clones don't segfault + a = longclone(-1) + self.assertEqual(a.__dict__, {}) + self.assertEqual(int(a), -1) # self.assert_ PyNumber_Long() copies the sign bit + + class precfloat(float): + __slots__ = ['prec'] + def __init__(self, value=0.0, prec=12): + self.prec = int(prec) + def __repr__(self): + return "%.*g" % (self.prec, self) + self.assertEqual(repr(precfloat(1.1)), "1.1") + a = precfloat(12345) + self.assertEqual(a, 12345.0) + self.assertEqual(float(a), 12345.0) + self.assert_(float(a).__class__ is float) + self.assertEqual(hash(a), hash(12345.0)) + self.assert_((+a).__class__ is float) + + class madcomplex(complex): + def __repr__(self): + return "%.17gj%+.17g" % (self.imag, self.real) + a = madcomplex(-3, 4) + self.assertEqual(repr(a), "4j-3") + base = complex(-3, 4) + self.assertEqual(base.__class__, complex) + self.assertEqual(a, base) + self.assertEqual(complex(a), base) + self.assertEqual(complex(a).__class__, complex) + a = madcomplex(a) # just trying another form of the constructor + self.assertEqual(repr(a), "4j-3") + self.assertEqual(a, base) + self.assertEqual(complex(a), base) + self.assertEqual(complex(a).__class__, complex) + self.assertEqual(hash(a), hash(base)) + self.assertEqual((+a).__class__, complex) + self.assertEqual((a + 0).__class__, complex) + self.assertEqual(a + 0, base) + self.assertEqual((a - 0).__class__, complex) + self.assertEqual(a - 0, base) + self.assertEqual((a * 1).__class__, complex) + self.assertEqual(a * 1, base) + self.assertEqual((a / 1).__class__, complex) + self.assertEqual(a / 1, base) + + class madtuple(tuple): + _rev = None + def rev(self): + if self._rev is not None: + return self._rev + L = list(self) + L.reverse() + self._rev = self.__class__(L) + return self._rev + a = madtuple((1,2,3,4,5,6,7,8,9,0)) + self.assertEqual(a, (1,2,3,4,5,6,7,8,9,0)) + self.assertEqual(a.rev(), madtuple((0,9,8,7,6,5,4,3,2,1))) + self.assertEqual(a.rev().rev(), madtuple((1,2,3,4,5,6,7,8,9,0))) + for i in range(512): + t = madtuple(range(i)) + u = t.rev() + v = u.rev() + self.assertEqual(v, t) + a = madtuple((1,2,3,4,5)) + self.assertEqual(tuple(a), (1,2,3,4,5)) + self.assert_(tuple(a).__class__ is tuple) + self.assertEqual(hash(a), hash((1,2,3,4,5))) + self.assert_(a[:].__class__ is tuple) + self.assert_((a * 1).__class__ is tuple) + self.assert_((a * 0).__class__ is tuple) + self.assert_((a + ()).__class__ is tuple) + a = madtuple(()) + self.assertEqual(tuple(a), ()) + self.assert_(tuple(a).__class__ is tuple) + self.assert_((a + a).__class__ is tuple) + self.assert_((a * 0).__class__ is tuple) + self.assert_((a * 1).__class__ is tuple) + self.assert_((a * 2).__class__ is tuple) + self.assert_(a[:].__class__ is tuple) + + class madstring(str): + _rev = None + def rev(self): + if self._rev is not None: + return self._rev + L = list(self) + L.reverse() + self._rev = self.__class__("".join(L)) + return self._rev + s = madstring("abcdefghijklmnopqrstuvwxyz") + self.assertEqual(s, "abcdefghijklmnopqrstuvwxyz") + self.assertEqual(s.rev(), madstring("zyxwvutsrqponmlkjihgfedcba")) + self.assertEqual(s.rev().rev(), madstring("abcdefghijklmnopqrstuvwxyz")) + for i in range(256): + s = madstring("".join(map(chr, range(i)))) + t = s.rev() + u = t.rev() + self.assertEqual(u, s) + s = madstring("12345") + self.assertEqual(str(s), "12345") + self.assert_(str(s).__class__ is str) + + base = "\x00" * 5 + s = madstring(base) + self.assertEqual(s, base) + self.assertEqual(str(s), base) + self.assert_(str(s).__class__ is str) + self.assertEqual(hash(s), hash(base)) + self.assertEqual({s: 1}[base], 1) + self.assertEqual({base: 1}[s], 1) + self.assert_((s + "").__class__ is str) + self.assertEqual(s + "", base) + self.assert_(("" + s).__class__ is str) + self.assertEqual("" + s, base) + self.assert_((s * 0).__class__ is str) + self.assertEqual(s * 0, "") + self.assert_((s * 1).__class__ is str) + self.assertEqual(s * 1, base) + self.assert_((s * 2).__class__ is str) + self.assertEqual(s * 2, base + base) + self.assert_(s[:].__class__ is str) + self.assertEqual(s[:], base) + self.assert_(s[0:0].__class__ is str) + self.assertEqual(s[0:0], "") + self.assert_(s.strip().__class__ is str) + self.assertEqual(s.strip(), base) + self.assert_(s.lstrip().__class__ is str) + self.assertEqual(s.lstrip(), base) + self.assert_(s.rstrip().__class__ is str) + self.assertEqual(s.rstrip(), base) + identitytab = {} + self.assert_(s.translate(identitytab).__class__ is str) + self.assertEqual(s.translate(identitytab), base) + self.assert_(s.replace("x", "x").__class__ is str) + self.assertEqual(s.replace("x", "x"), base) + self.assert_(s.ljust(len(s)).__class__ is str) + self.assertEqual(s.ljust(len(s)), base) + self.assert_(s.rjust(len(s)).__class__ is str) + self.assertEqual(s.rjust(len(s)), base) + self.assert_(s.center(len(s)).__class__ is str) + self.assertEqual(s.center(len(s)), base) + self.assert_(s.lower().__class__ is str) + self.assertEqual(s.lower(), base) + + class madunicode(str): + _rev = None + def rev(self): + if self._rev is not None: + return self._rev + L = list(self) + L.reverse() + self._rev = self.__class__("".join(L)) + return self._rev + u = madunicode("ABCDEF") + self.assertEqual(u, "ABCDEF") + self.assertEqual(u.rev(), madunicode("FEDCBA")) + self.assertEqual(u.rev().rev(), madunicode("ABCDEF")) + base = "12345" + u = madunicode(base) + self.assertEqual(str(u), base) + self.assert_(str(u).__class__ is str) + self.assertEqual(hash(u), hash(base)) + self.assertEqual({u: 1}[base], 1) + self.assertEqual({base: 1}[u], 1) + self.assert_(u.strip().__class__ is str) + self.assertEqual(u.strip(), base) + self.assert_(u.lstrip().__class__ is str) + self.assertEqual(u.lstrip(), base) + self.assert_(u.rstrip().__class__ is str) + self.assertEqual(u.rstrip(), base) + self.assert_(u.replace("x", "x").__class__ is str) + self.assertEqual(u.replace("x", "x"), base) + self.assert_(u.replace("xy", "xy").__class__ is str) + self.assertEqual(u.replace("xy", "xy"), base) + self.assert_(u.center(len(u)).__class__ is str) + self.assertEqual(u.center(len(u)), base) + self.assert_(u.ljust(len(u)).__class__ is str) + self.assertEqual(u.ljust(len(u)), base) + self.assert_(u.rjust(len(u)).__class__ is str) + self.assertEqual(u.rjust(len(u)), base) + self.assert_(u.lower().__class__ is str) + self.assertEqual(u.lower(), base) + self.assert_(u.upper().__class__ is str) + self.assertEqual(u.upper(), base) + self.assert_(u.capitalize().__class__ is str) + self.assertEqual(u.capitalize(), base) + self.assert_(u.title().__class__ is str) + self.assertEqual(u.title(), base) + self.assert_((u + "").__class__ is str) + self.assertEqual(u + "", base) + self.assert_(("" + u).__class__ is str) + self.assertEqual("" + u, base) + self.assert_((u * 0).__class__ is str) + self.assertEqual(u * 0, "") + self.assert_((u * 1).__class__ is str) + self.assertEqual(u * 1, base) + self.assert_((u * 2).__class__ is str) + self.assertEqual(u * 2, base + base) + self.assert_(u[:].__class__ is str) + self.assertEqual(u[:], base) + self.assert_(u[0:0].__class__ is str) + self.assertEqual(u[0:0], "") + + class sublist(list): + pass + a = sublist(range(5)) + self.assertEqual(a, list(range(5))) + a.append("hello") + self.assertEqual(a, list(range(5)) + ["hello"]) + a[5] = 5 + self.assertEqual(a, list(range(6))) + a.extend(range(6, 20)) + self.assertEqual(a, list(range(20))) + a[-5:] = [] + self.assertEqual(a, list(range(15))) + del a[10:15] + self.assertEqual(len(a), 10) + self.assertEqual(a, list(range(10))) + self.assertEqual(list(a), list(range(10))) + self.assertEqual(a[0], 0) + self.assertEqual(a[9], 9) + self.assertEqual(a[-10], 0) + self.assertEqual(a[-1], 9) + self.assertEqual(a[:5], list(range(5))) + + ## class CountedInput(file): + ## """Counts lines read by self.readline(). + ## + ## self.lineno is the 0-based ordinal of the last line read, up to + ## a maximum of one greater than the number of lines in the file. + ## + ## self.ateof is true if and only if the final "" line has been read, + ## at which point self.lineno stops incrementing, and further calls + ## to readline() continue to return "". + ## """ + ## + ## lineno = 0 + ## ateof = 0 + ## def readline(self): + ## if self.ateof: + ## return "" + ## s = file.readline(self) + ## # Next line works too. + ## # s = super(CountedInput, self).readline() + ## self.lineno += 1 + ## if s == "": + ## self.ateof = 1 + ## return s + ## + ## f = file(name=test_support.TESTFN, mode='w') + ## lines = ['a\n', 'b\n', 'c\n'] + ## try: + ## f.writelines(lines) + ## f.close() + ## f = CountedInput(test_support.TESTFN) + ## for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]): + ## got = f.readline() + ## self.assertEqual(expected, got) + ## self.assertEqual(f.lineno, i) + ## self.assertEqual(f.ateof, (i > len(lines))) + ## f.close() + ## finally: + ## try: + ## f.close() + ## except: + ## pass + ## test_support.unlink(test_support.TESTFN) + + def test_keywords(self): + # Testing keyword args to basic type constructors ... + self.assertEqual(int(x=1), 1) + self.assertEqual(float(x=2), 2.0) + self.assertEqual(int(x=3), 3) + self.assertEqual(complex(imag=42, real=666), complex(666, 42)) + self.assertEqual(str(object=500), '500') + self.assertEqual(str(object=b'abc', errors='strict'), 'abc') + self.assertEqual(tuple(sequence=range(3)), (0, 1, 2)) + self.assertEqual(list(sequence=(0, 1, 2)), list(range(3))) + # note: as of Python 2.3, dict() no longer has an "items" keyword arg + + for constructor in (int, float, int, complex, str, str, + tuple, list): + try: + constructor(bogus_keyword_arg=1) + except TypeError: + pass + else: + self.fail("expected TypeError from bogus keyword argument to %r" + % constructor) + + def test_str_subclass_as_dict_key(self): + # Testing a str subclass used as dict key .. + + class cistr(str): + """Sublcass of str that computes __eq__ case-insensitively. + + Also computes a hash code of the string in canonical form. + """ + + def __init__(self, value): + self.canonical = value.lower() + self.hashcode = hash(self.canonical) + + def __eq__(self, other): + if not isinstance(other, cistr): + other = cistr(other) + return self.canonical == other.canonical + + def __hash__(self): + return self.hashcode + + self.assertEqual(cistr('ABC'), 'abc') + self.assertEqual('aBc', cistr('ABC')) + self.assertEqual(str(cistr('ABC')), 'ABC') + + d = {cistr('one'): 1, cistr('two'): 2, cistr('tHree'): 3} + self.assertEqual(d[cistr('one')], 1) + self.assertEqual(d[cistr('tWo')], 2) + self.assertEqual(d[cistr('THrEE')], 3) + self.assert_(cistr('ONe') in d) + self.assertEqual(d.get(cistr('thrEE')), 3) + + def test_classic_comparisons(self): + # Testing classic comparisons... + class classic: + pass + + for base in (classic, int, object): + class C(base): + def __init__(self, value): + self.value = int(value) + def __eq__(self, other): + if isinstance(other, C): + return self.value == other.value + if isinstance(other, int) or isinstance(other, int): + return self.value == other + return NotImplemented + def __ne__(self, other): + if isinstance(other, C): + return self.value != other.value + if isinstance(other, int) or isinstance(other, int): + return self.value != other + return NotImplemented + def __lt__(self, other): + if isinstance(other, C): + return self.value < other.value + if isinstance(other, int) or isinstance(other, int): + return self.value < other + return NotImplemented + def __le__(self, other): + if isinstance(other, C): + return self.value <= other.value + if isinstance(other, int) or isinstance(other, int): + return self.value <= other + return NotImplemented + def __gt__(self, other): + if isinstance(other, C): + return self.value > other.value + if isinstance(other, int) or isinstance(other, int): + return self.value > other + return NotImplemented + def __ge__(self, other): + if isinstance(other, C): + return self.value >= other.value + if isinstance(other, int) or isinstance(other, int): + return self.value >= other + return NotImplemented + + c1 = C(1) + c2 = C(2) + c3 = C(3) + self.assertEqual(c1, 1) + c = {1: c1, 2: c2, 3: c3} + for x in 1, 2, 3: + for y in 1, 2, 3: + ## self.assert_(cmp(c[x], c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) + for op in "<", "<=", "==", "!=", ">", ">=": + self.assert_(eval("c[x] %s c[y]" % op) == eval("x %s y" % op), + "x=%d, y=%d" % (x, y)) + ## self.assert_(cmp(c[x], y) == cmp(x, y), "x=%d, y=%d" % (x, y)) + ## self.assert_(cmp(x, c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) + + def test_rich_comparisons(self): + # Testing rich comparisons... + class Z(complex): + pass + z = Z(1) + self.assertEqual(z, 1+0j) + self.assertEqual(1+0j, z) + class ZZ(complex): + def __eq__(self, other): + try: + return abs(self - other) <= 1e-6 + except: + return NotImplemented + zz = ZZ(1.0000003) + self.assertEqual(zz, 1+0j) + self.assertEqual(1+0j, zz) + + class classic: + pass + for base in (classic, int, object, list): + class C(base): + def __init__(self, value): + self.value = int(value) + def __cmp__(self_, other): + self.fail("shouldn't call __cmp__") + def __eq__(self, other): + if isinstance(other, C): + return self.value == other.value + if isinstance(other, int) or isinstance(other, int): + return self.value == other + return NotImplemented + def __ne__(self, other): + if isinstance(other, C): + return self.value != other.value + if isinstance(other, int) or isinstance(other, int): + return self.value != other + return NotImplemented + def __lt__(self, other): + if isinstance(other, C): + return self.value < other.value + if isinstance(other, int) or isinstance(other, int): + return self.value < other + return NotImplemented + def __le__(self, other): + if isinstance(other, C): + return self.value <= other.value + if isinstance(other, int) or isinstance(other, int): + return self.value <= other + return NotImplemented + def __gt__(self, other): + if isinstance(other, C): + return self.value > other.value + if isinstance(other, int) or isinstance(other, int): + return self.value > other + return NotImplemented + def __ge__(self, other): + if isinstance(other, C): + return self.value >= other.value + if isinstance(other, int) or isinstance(other, int): + return self.value >= other + return NotImplemented + c1 = C(1) + c2 = C(2) + c3 = C(3) + self.assertEqual(c1, 1) + c = {1: c1, 2: c2, 3: c3} + for x in 1, 2, 3: + for y in 1, 2, 3: + for op in "<", "<=", "==", "!=", ">", ">=": + self.assert_(eval("c[x] %s c[y]" % op) == eval("x %s y" % op), + "x=%d, y=%d" % (x, y)) + self.assert_(eval("c[x] %s y" % op) == eval("x %s y" % op), + "x=%d, y=%d" % (x, y)) + self.assert_(eval("x %s c[y]" % op) == eval("x %s y" % op), + "x=%d, y=%d" % (x, y)) + + def test_descrdoc(self): + # Testing descriptor doc strings... + from _fileio import _FileIO + def check(descr, what): + self.assertEqual(descr.__doc__, what) + check(_FileIO.closed, "True if the file is closed") # getset descriptor + check(complex.real, "the real part of a complex number") # member descriptor + + def test_doc_descriptor(self): + # Testing __doc__ descriptor... + # SF bug 542984 + class DocDescr(object): + def __get__(self, object, otype): + if object: + object = object.__class__.__name__ + ' instance' + if otype: + otype = otype.__name__ + return 'object=%s; type=%s' % (object, otype) + class OldClass: + __doc__ = DocDescr() + class NewClass(object): + __doc__ = DocDescr() + self.assertEqual(OldClass.__doc__, 'object=None; type=OldClass') + self.assertEqual(OldClass().__doc__, 'object=OldClass instance; type=OldClass') + self.assertEqual(NewClass.__doc__, 'object=None; type=NewClass') + self.assertEqual(NewClass().__doc__, 'object=NewClass instance; type=NewClass') + + def test_set_class(self): + # Testing __class__ assignment... + class C(object): pass + class D(object): pass + class E(object): pass + class F(D, E): pass + for cls in C, D, E, F: + for cls2 in C, D, E, F: + x = cls() + x.__class__ = cls2 + self.assert_(x.__class__ is cls2) + x.__class__ = cls + self.assert_(x.__class__ is cls) + def cant(x, C): + try: + x.__class__ = C + except TypeError: + pass + else: + self.fail("shouldn't allow %r.__class__ = %r" % (x, C)) + try: + delattr(x, "__class__") + except TypeError: + pass + else: + self.fail("shouldn't allow del %r.__class__" % x) + cant(C(), list) + cant(list(), C) + cant(C(), 1) + cant(C(), object) + cant(object(), list) + cant(list(), object) + class Int(int): __slots__ = [] + cant(2, Int) + cant(Int(), int) + cant(True, int) + cant(2, bool) + o = object() + cant(o, type(1)) + cant(o, type(None)) + del o + class G(object): + __slots__ = ["a", "b"] + class H(object): + __slots__ = ["b", "a"] + class I(object): + __slots__ = ["a", "b"] + class J(object): + __slots__ = ["c", "b"] + class K(object): + __slots__ = ["a", "b", "d"] + class L(H): + __slots__ = ["e"] + class M(I): + __slots__ = ["e"] + class N(J): + __slots__ = ["__weakref__"] + class P(J): + __slots__ = ["__dict__"] + class Q(J): + pass + class R(J): + __slots__ = ["__dict__", "__weakref__"] + + for cls, cls2 in ((G, H), (G, I), (I, H), (Q, R), (R, Q)): + x = cls() + x.a = 1 + x.__class__ = cls2 + self.assert_(x.__class__ is cls2, + "assigning %r as __class__ for %r silently failed" % (cls2, x)) + self.assertEqual(x.a, 1) + x.__class__ = cls + self.assert_(x.__class__ is cls, + "assigning %r as __class__ for %r silently failed" % (cls, x)) + self.assertEqual(x.a, 1) + for cls in G, J, K, L, M, N, P, R, list, Int: + for cls2 in G, J, K, L, M, N, P, R, list, Int: + if cls is cls2: + continue + cant(cls(), cls2) + + def test_set_dict(self): + # Testing __dict__ assignment... + class C(object): pass + a = C() + a.__dict__ = {'b': 1} + self.assertEqual(a.b, 1) + def cant(x, dict): + try: + x.__dict__ = dict + except (AttributeError, TypeError): + pass + else: + self.fail("shouldn't allow %r.__dict__ = %r" % (x, dict)) + cant(a, None) + cant(a, []) + cant(a, 1) + del a.__dict__ # Deleting __dict__ is allowed + + class Base(object): + pass + def verify_dict_readonly(x): + """ + x has to be an instance of a class inheriting from Base. + """ + cant(x, {}) + try: + del x.__dict__ + except (AttributeError, TypeError): + pass + else: + self.fail("shouldn't allow del %r.__dict__" % x) + dict_descr = Base.__dict__["__dict__"] + try: + dict_descr.__set__(x, {}) + except (AttributeError, TypeError): + pass + else: + self.fail("dict_descr allowed access to %r's dict" % x) + + # Classes don't allow __dict__ assignment and have readonly dicts + class Meta1(type, Base): + pass + class Meta2(Base, type): + pass + class D(object, metaclass=Meta1): + pass + class E(object, metaclass=Meta2): + pass + for cls in C, D, E: + verify_dict_readonly(cls) + class_dict = cls.__dict__ + try: + class_dict["spam"] = "eggs" + except TypeError: + pass + else: + self.fail("%r's __dict__ can be modified" % cls) + + # Modules also disallow __dict__ assignment + class Module1(types.ModuleType, Base): + pass + class Module2(Base, types.ModuleType): + pass + for ModuleType in Module1, Module2: + mod = ModuleType("spam") + verify_dict_readonly(mod) + mod.__dict__["spam"] = "eggs" + + # Exception's __dict__ can be replaced, but not deleted + class Exception1(Exception, Base): + pass + class Exception2(Base, Exception): + pass + for ExceptionType in Exception, Exception1, Exception2: + e = ExceptionType() + e.__dict__ = {"a": 1} + self.assertEqual(e.a, 1) + try: + del e.__dict__ + except (TypeError, AttributeError): + pass + else: + self.fail("%r's __dict__ can be deleted" % e) + + def test_pickles(self): + # Testing pickling and copying new-style classes and objects... + import pickle + + def sorteditems(d): + L = list(d.items()) + L.sort() + return L + + global C + class C(object): + def __init__(self, a, b): + super(C, self).__init__() + self.a = a + self.b = b + def __repr__(self): + return "C(%r, %r)" % (self.a, self.b) + + global C1 + class C1(list): + def __new__(cls, a, b): + return super(C1, cls).__new__(cls) + def __getnewargs__(self): + return (self.a, self.b) + def __init__(self, a, b): + self.a = a + self.b = b + def __repr__(self): + return "C1(%r, %r)<%r>" % (self.a, self.b, list(self)) + + global C2 + class C2(int): + def __new__(cls, a, b, val=0): + return super(C2, cls).__new__(cls, val) + def __getnewargs__(self): + return (self.a, self.b, int(self)) + def __init__(self, a, b, val=0): + self.a = a + self.b = b + def __repr__(self): + return "C2(%r, %r)<%r>" % (self.a, self.b, int(self)) + + global C3 + class C3(object): + def __init__(self, foo): + self.foo = foo + def __getstate__(self): + return self.foo + def __setstate__(self, foo): + self.foo = foo + + global C4classic, C4 + class C4classic: # classic + pass + class C4(C4classic, object): # mixed inheritance + pass + + for bin in 0, 1: + for cls in C, C1, C2: + s = pickle.dumps(cls, bin) + cls2 = pickle.loads(s) + self.assert_(cls2 is cls) + + a = C1(1, 2); a.append(42); a.append(24) + b = C2("hello", "world", 42) + s = pickle.dumps((a, b), bin) + x, y = pickle.loads(s) + self.assertEqual(x.__class__, a.__class__) + self.assertEqual(sorteditems(x.__dict__), sorteditems(a.__dict__)) + self.assertEqual(y.__class__, b.__class__) + self.assertEqual(sorteditems(y.__dict__), sorteditems(b.__dict__)) + self.assertEqual(repr(x), repr(a)) + self.assertEqual(repr(y), repr(b)) + # Test for __getstate__ and __setstate__ on new style class + u = C3(42) + s = pickle.dumps(u, bin) + v = pickle.loads(s) + self.assertEqual(u.__class__, v.__class__) + self.assertEqual(u.foo, v.foo) + # Test for picklability of hybrid class + u = C4() + u.foo = 42 + s = pickle.dumps(u, bin) + v = pickle.loads(s) + self.assertEqual(u.__class__, v.__class__) + self.assertEqual(u.foo, v.foo) + + # Testing copy.deepcopy() + import copy + for cls in C, C1, C2: + cls2 = copy.deepcopy(cls) + self.assert_(cls2 is cls) + + a = C1(1, 2); a.append(42); a.append(24) + b = C2("hello", "world", 42) + x, y = copy.deepcopy((a, b)) + self.assertEqual(x.__class__, a.__class__) + self.assertEqual(sorteditems(x.__dict__), sorteditems(a.__dict__)) + self.assertEqual(y.__class__, b.__class__) + self.assertEqual(sorteditems(y.__dict__), sorteditems(b.__dict__)) + self.assertEqual(repr(x), repr(a)) + self.assertEqual(repr(y), repr(b)) + + def test_pickle_slots(self): + # Testing pickling of classes with __slots__ ... + import pickle + # Pickling of classes with __slots__ but without __getstate__ should fail + # (if using protocol 0 or 1) + global B, C, D, E + class B(object): + pass + for base in [object, B]: + class C(base): + __slots__ = ['a'] + class D(C): + pass + try: + pickle.dumps(C(), 0) + except TypeError: + pass + else: + self.fail("should fail: pickle C instance - %s" % base) + try: + pickle.dumps(C(), 0) + except TypeError: + pass + else: + self.fail("should fail: pickle D instance - %s" % base) + # Give C a nice generic __getstate__ and __setstate__ + class C(base): + __slots__ = ['a'] + def __getstate__(self): + try: + d = self.__dict__.copy() + except AttributeError: + d = {} + for cls in self.__class__.__mro__: + for sn in cls.__dict__.get('__slots__', ()): + try: + d[sn] = getattr(self, sn) + except AttributeError: + pass + return d + def __setstate__(self, d): + for k, v in list(d.items()): + setattr(self, k, v) + class D(C): + pass + # Now it should work + x = C() + y = pickle.loads(pickle.dumps(x)) + self.assertEqual(hasattr(y, 'a'), 0) + x.a = 42 + y = pickle.loads(pickle.dumps(x)) + self.assertEqual(y.a, 42) + x = D() + x.a = 42 + x.b = 100 + y = pickle.loads(pickle.dumps(x)) + self.assertEqual(y.a + y.b, 142) + # A subclass that adds a slot should also work + class E(C): + __slots__ = ['b'] + x = E() + x.a = 42 + x.b = "foo" + y = pickle.loads(pickle.dumps(x)) + self.assertEqual(y.a, x.a) + self.assertEqual(y.b, x.b) + + def test_binary_operator_override(self): + # Testing overrides of binary operations... + class I(int): + def __repr__(self): + return "I(%r)" % int(self) + def __add__(self, other): + return I(int(self) + int(other)) + __radd__ = __add__ + def __pow__(self, other, mod=None): + if mod is None: + return I(pow(int(self), int(other))) + else: + return I(pow(int(self), int(other), int(mod))) + def __rpow__(self, other, mod=None): + if mod is None: + return I(pow(int(other), int(self), mod)) + else: + return I(pow(int(other), int(self), int(mod))) + + self.assertEqual(repr(I(1) + I(2)), "I(3)") + self.assertEqual(repr(I(1) + 2), "I(3)") + self.assertEqual(repr(1 + I(2)), "I(3)") + self.assertEqual(repr(I(2) ** I(3)), "I(8)") + self.assertEqual(repr(2 ** I(3)), "I(8)") + self.assertEqual(repr(I(2) ** 3), "I(8)") + self.assertEqual(repr(pow(I(2), I(3), I(5))), "I(3)") + class S(str): + def __eq__(self, other): + return self.lower() == other.lower() + + def test_subclass_propagation(self): + # Testing propagation of slot functions to subclasses... + class A(object): + pass + class B(A): + pass + class C(A): + pass + class D(B, C): + pass + d = D() + orig_hash = hash(d) # related to id(d) in platform-dependent ways + A.__hash__ = lambda self: 42 + self.assertEqual(hash(d), 42) + C.__hash__ = lambda self: 314 + self.assertEqual(hash(d), 314) + B.__hash__ = lambda self: 144 + self.assertEqual(hash(d), 144) + D.__hash__ = lambda self: 100 + self.assertEqual(hash(d), 100) + del D.__hash__ + self.assertEqual(hash(d), 144) + del B.__hash__ + self.assertEqual(hash(d), 314) + del C.__hash__ + self.assertEqual(hash(d), 42) + del A.__hash__ + self.assertEqual(hash(d), orig_hash) + d.foo = 42 + d.bar = 42 + self.assertEqual(d.foo, 42) + self.assertEqual(d.bar, 42) + def __getattribute__(self, name): + if name == "foo": + return 24 + return object.__getattribute__(self, name) + A.__getattribute__ = __getattribute__ + self.assertEqual(d.foo, 24) + self.assertEqual(d.bar, 42) + def __getattr__(self, name): + if name in ("spam", "foo", "bar"): + return "hello" + raise AttributeError(name) + B.__getattr__ = __getattr__ + self.assertEqual(d.spam, "hello") + self.assertEqual(d.foo, 24) + self.assertEqual(d.bar, 42) + del A.__getattribute__ + self.assertEqual(d.foo, 42) + del d.foo + self.assertEqual(d.foo, "hello") + self.assertEqual(d.bar, 42) + del B.__getattr__ + try: + d.foo + except AttributeError: + pass + else: + 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): + pass + del B + gc.collect() + A.__setitem__ = lambda *a: None # crash + + def test_buffer_inheritance(self): + # Testing that buffer interface is inherited ... + + import binascii + # SF bug [#470040] ParseTuple t# vs subclasses. + + class MyStr(str): + pass + base = 'abc' + m = MyStr(base) + # b2a_hex uses the buffer interface to get its argument's value, via + # PyArg_ParseTuple 't#' code. + self.assertEqual(binascii.b2a_hex(m), binascii.b2a_hex(base)) + + # It's not clear that unicode will continue to support the character + # buffer interface, and this test will fail if that's taken away. + class MyUni(str): + pass + base = 'abc' + m = MyUni(base) + self.assertEqual(binascii.b2a_hex(m), binascii.b2a_hex(base)) -# XXX Please, please, please, someone convert this to unittest style! -from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout -from copy import deepcopy -import types + class MyInt(int): + pass + m = MyInt(42) + try: + binascii.b2a_hex(m) + self.fail('subclass of int should not have a buffer interface') + except TypeError: + pass -def veris(a, b): - if a is not b: - raise TestFailed("%r is %r" % (a, b)) - -def testunop(a, res, expr="len(a)", meth="__len__"): - if verbose: print("checking", expr) - dict = {'a': a} - vereq(eval(expr, dict), res) - t = type(a) - m = getattr(t, meth) - while meth not in t.__dict__: - t = t.__bases__[0] - vereq(m, t.__dict__[meth]) - vereq(m(a), res) - bm = getattr(a, meth) - vereq(bm(), res) - -def testbinop(a, b, res, expr="a+b", meth="__add__"): - if verbose: print("checking", expr) - dict = {'a': a, 'b': b} - - vereq(eval(expr, dict), res) - t = type(a) - m = getattr(t, meth) - while meth not in t.__dict__: - t = t.__bases__[0] - vereq(m, t.__dict__[meth]) - vereq(m(a, b), res) - bm = getattr(a, meth) - vereq(bm(b), res) - -def testsliceop(a, b, c, res, expr="a[b:c]", meth="__getitem__"): - if verbose: print("checking", expr) - dict = {'a': a, 'b': b, 'c': c} - vereq(eval(expr, dict), res) - t = type(a) - m = getattr(t, meth) - while meth not in t.__dict__: - t = t.__bases__[0] - vereq(m, t.__dict__[meth]) - vereq(m(a, slice(b, c)), res) - bm = getattr(a, meth) - vereq(bm(slice(b, c)), res) - -def testsetop(a, b, res, stmt="a+=b", meth="__iadd__"): - if verbose: print("checking", stmt) - dict = {'a': deepcopy(a), 'b': b} - exec(stmt, dict) - vereq(dict['a'], res) - t = type(a) - m = getattr(t, meth) - while meth not in t.__dict__: - t = t.__bases__[0] - vereq(m, t.__dict__[meth]) - dict['a'] = deepcopy(a) - m(dict['a'], b) - vereq(dict['a'], res) - dict['a'] = deepcopy(a) - bm = getattr(dict['a'], meth) - bm(b) - vereq(dict['a'], res) - -def testset2op(a, b, c, res, stmt="a[b]=c", meth="__setitem__"): - if verbose: print("checking", stmt) - dict = {'a': deepcopy(a), 'b': b, 'c': c} - exec(stmt, dict) - vereq(dict['a'], res) - t = type(a) - m = getattr(t, meth) - while meth not in t.__dict__: - t = t.__bases__[0] - vereq(m, t.__dict__[meth]) - dict['a'] = deepcopy(a) - m(dict['a'], b, c) - vereq(dict['a'], res) - dict['a'] = deepcopy(a) - bm = getattr(dict['a'], meth) - bm(b, c) - vereq(dict['a'], res) - -def testsetsliceop(a, b, c, d, res, stmt="a[b:c]=d", meth="__setitem__"): - if verbose: print("checking", stmt) - dict = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d} - exec(stmt, dict) - vereq(dict['a'], res) - t = type(a) - while meth not in t.__dict__: - t = t.__bases__[0] - m = getattr(t, meth) - vereq(m, t.__dict__[meth]) - dict['a'] = deepcopy(a) - m(dict['a'], slice(b, c), d) - vereq(dict['a'], res) - dict['a'] = deepcopy(a) - bm = getattr(dict['a'], meth) - bm(slice(b, c), d) - vereq(dict['a'], res) - -def class_docstrings(): - class Classic: - "A classic docstring." - vereq(Classic.__doc__, "A classic docstring.") - vereq(Classic.__dict__['__doc__'], "A classic docstring.") - - class Classic2: - pass - verify(Classic2.__doc__ is None) - - class NewStatic(object): - "Another docstring." - vereq(NewStatic.__doc__, "Another docstring.") - vereq(NewStatic.__dict__['__doc__'], "Another docstring.") - - class NewStatic2(object): - pass - verify(NewStatic2.__doc__ is None) - - class NewDynamic(object): - "Another docstring." - vereq(NewDynamic.__doc__, "Another docstring.") - vereq(NewDynamic.__dict__['__doc__'], "Another docstring.") - - class NewDynamic2(object): - pass - verify(NewDynamic2.__doc__ is None) - -def lists(): - if verbose: print("Testing list operations...") - testbinop([1], [2], [1,2], "a+b", "__add__") - testbinop([1,2,3], 2, 1, "b in a", "__contains__") - testbinop([1,2,3], 4, 0, "b in a", "__contains__") - testbinop([1,2,3], 1, 2, "a[b]", "__getitem__") - testsliceop([1,2,3], 0, 2, [1,2], "a[b:c]", "__getitem__") - testsetop([1], [2], [1,2], "a+=b", "__iadd__") - testsetop([1,2], 3, [1,2,1,2,1,2], "a*=b", "__imul__") - testunop([1,2,3], 3, "len(a)", "__len__") - testbinop([1,2], 3, [1,2,1,2,1,2], "a*b", "__mul__") - testbinop([1,2], 3, [1,2,1,2,1,2], "b*a", "__rmul__") - testset2op([1,2], 1, 3, [1,3], "a[b]=c", "__setitem__") - testsetsliceop([1,2,3,4], 1, 3, [5,6], [1,5,6,4], "a[b:c]=d", - "__setitem__") - -def dicts(): - if verbose: print("Testing dict operations...") - ##testbinop({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__") - testbinop({1:2,3:4}, 1, 1, "b in a", "__contains__") - testbinop({1:2,3:4}, 2, 0, "b in a", "__contains__") - testbinop({1:2,3:4}, 1, 2, "a[b]", "__getitem__") - d = {1:2,3:4} - l1 = [] - for i in d.keys(): l1.append(i) - l = [] - for i in iter(d): l.append(i) - vereq(l, l1) - l = [] - for i in d.__iter__(): l.append(i) - vereq(l, l1) - l = [] - for i in dict.__iter__(d): l.append(i) - vereq(l, l1) - d = {1:2, 3:4} - testunop(d, 2, "len(a)", "__len__") - vereq(eval(repr(d), {}), d) - vereq(eval(d.__repr__(), {}), d) - testset2op({1:2,3:4}, 2, 3, {1:2,2:3,3:4}, "a[b]=c", "__setitem__") - -def dict_constructor(): - if verbose: - print("Testing dict constructor ...") - d = dict() - vereq(d, {}) - d = dict({}) - vereq(d, {}) - d = dict({1: 2, 'a': 'b'}) - vereq(d, {1: 2, 'a': 'b'}) - vereq(d, dict(d.items())) - vereq(d, dict(d.items())) - d = dict({'one':1, 'two':2}) - vereq(d, dict(one=1, two=2)) - vereq(d, dict(**d)) - vereq(d, dict({"one": 1}, two=2)) - vereq(d, dict([("two", 2)], one=1)) - vereq(d, dict([("one", 100), ("two", 200)], **d)) - verify(d is not dict(**d)) - for badarg in 0, 0, 0j, "0", [0], (0,): - try: - dict(badarg) - except TypeError: - pass - except ValueError: - if badarg == "0": - # It's a sequence, and its elements are also sequences (gotta - # love strings ), but they aren't of length 2, so this - # one seemed better as a ValueError than a TypeError. - pass - else: - raise TestFailed("no TypeError from dict(%r)" % badarg) + def test_str_of_str_subclass(self): + # Testing __str__ defined in subclass of str ... + import binascii + import io + + class octetstring(str): + def __str__(self): + return binascii.b2a_hex(self).decode("ascii") + def __repr__(self): + return self + " repr" + + o = octetstring('A') + self.assertEqual(type(o), octetstring) + self.assertEqual(type(str(o)), str) + self.assertEqual(type(repr(o)), str) + self.assertEqual(ord(o), 0x41) + self.assertEqual(str(o), '41') + self.assertEqual(repr(o), 'A repr') + self.assertEqual(o.__str__(), '41') + self.assertEqual(o.__repr__(), 'A repr') + + capture = io.StringIO() + # Calling str() or not exercises different internal paths. + print(o, file=capture) + print(str(o), file=capture) + self.assertEqual(capture.getvalue(), '41\n41\n') + capture.close() + + def test_keyword_arguments(self): + # Testing keyword arguments to __init__, __call__... + def f(a): return a + self.assertEqual(f.__call__(a=42), 42) + a = [] + list.__init__(a, sequence=[0, 1, 2]) + self.assertEqual(a, [0, 1, 2]) + + def test_recursive_call(self): + # Testing recursive __call__() by setting to instance of class... + class A(object): + pass + + A.__call__ = A() + try: + A()() + except RuntimeError: + pass else: - raise TestFailed("no TypeError from dict(%r)" % badarg) + self.fail("Recursion limit should have been reached for __call__()") - try: - dict({}, {}) - except TypeError: - pass - else: - raise TestFailed("no TypeError from dict({}, {})") - - class Mapping: - # Lacks a .keys() method; will be added later. - dict = {1:2, 3:4, 'a':1j} - - try: - dict(Mapping()) - except TypeError: - pass - else: - raise TestFailed("no TypeError from dict(incomplete mapping)") - - Mapping.keys = lambda self: self.dict.keys() - Mapping.__getitem__ = lambda self, i: self.dict[i] - d = dict(Mapping()) - vereq(d, Mapping.dict) - - # Init from sequence of iterable objects, each producing a 2-sequence. - class AddressBookEntry: - def __init__(self, first, last): - self.first = first - self.last = last - def __iter__(self): - return iter([self.first, self.last]) - - d = dict([AddressBookEntry('Tim', 'Warsaw'), - AddressBookEntry('Barry', 'Peters'), - AddressBookEntry('Tim', 'Peters'), - AddressBookEntry('Barry', 'Warsaw')]) - vereq(d, {'Barry': 'Warsaw', 'Tim': 'Peters'}) - - d = dict(zip(range(4), range(1, 5))) - vereq(d, dict([(i, i+1) for i in range(4)])) - - # Bad sequence lengths. - for bad in [('tooshort',)], [('too', 'long', 'by 1')]: - try: - dict(bad) - except ValueError: - pass - else: - raise TestFailed("no ValueError from dict(%r)" % bad) - -def test_dir(): - if verbose: - print("Testing dir() ...") - junk = 12 - vereq(dir(), ['junk']) - del junk - - # Just make sure these don't blow up! - for arg in 2, 2, 2j, 2e0, [2], "2", b"2", (2,), {2:2}, type, test_dir: - dir(arg) - - # Test dir on custom classes. Since these have object as a - # base class, a lot of stuff gets sucked in. - def interesting(strings): - return [s for s in strings if not s.startswith('_')] - - class C(object): - Cdata = 1 - def Cmethod(self): pass - - cstuff = ['Cdata', 'Cmethod'] - vereq(interesting(dir(C)), cstuff) - - c = C() - vereq(interesting(dir(c)), cstuff) - #verify('__self__' in dir(C.Cmethod)) - - c.cdata = 2 - c.cmethod = lambda self: 0 - vereq(interesting(dir(c)), cstuff + ['cdata', 'cmethod']) - #verify('__self__' in dir(c.Cmethod)) - - class A(C): - Adata = 1 - def Amethod(self): pass - - astuff = ['Adata', 'Amethod'] + cstuff - vereq(interesting(dir(A)), astuff) - #verify('__self__' in dir(A.Amethod)) - a = A() - vereq(interesting(dir(a)), astuff) - a.adata = 42 - a.amethod = lambda self: 3 - vereq(interesting(dir(a)), astuff + ['adata', 'amethod']) - #verify('__self__' in dir(a.Amethod)) - - # Try a module subclass. - import sys - class M(type(sys)): - pass - minstance = M("m") - minstance.b = 2 - minstance.a = 1 - names = [x for x in dir(minstance) if x not in ["__name__", "__doc__"]] - vereq(names, ['a', 'b']) - - class M2(M): - def getdict(self): - return "Not a dict!" - __dict__ = property(getdict) - - m2instance = M2("m2") - m2instance.b = 2 - m2instance.a = 1 - vereq(m2instance.__dict__, "Not a dict!") - try: - dir(m2instance) - except TypeError: - pass - - # Two essentially featureless objects, just inheriting stuff from - # object. - vereq(dir(None), dir(Ellipsis)) - - # Nasty test case for proxied objects - class Wrapper(object): - def __init__(self, obj): - self.__obj = obj - def __repr__(self): - return "Wrapper(%s)" % repr(self.__obj) - def __getitem__(self, key): - return Wrapper(self.__obj[key]) - def __len__(self): - return len(self.__obj) - def __getattr__(self, name): - return Wrapper(getattr(self.__obj, name)) + def test_delete_hook(self): + # Testing __del__ hook... + log = [] + class C(object): + def __del__(self): + log.append(1) + c = C() + self.assertEqual(log, []) + del c + self.assertEqual(log, [1]) + + class D(object): pass + d = D() + try: del d[0] + except TypeError: pass + else: self.fail("invalid del() didn't raise TypeError") - class C(object): - def __getclass(self): - return Wrapper(type(self)) - __class__ = property(__getclass) - - dir(C()) # This used to segfault - -binops = { - 'add': '+', - 'sub': '-', - 'mul': '*', - 'div': '/', - 'mod': '%', - 'divmod': 'divmod', - 'pow': '**', - 'lshift': '<<', - 'rshift': '>>', - 'and': '&', - 'xor': '^', - 'or': '|', - 'cmp': 'cmp', - 'lt': '<', - 'le': '<=', - 'eq': '==', - 'ne': '!=', - 'gt': '>', - 'ge': '>=', - } - -for name, expr in binops.items(): - if expr.islower(): - expr = expr + "(a, b)" - else: - expr = 'a %s b' % expr - binops[name] = expr - -unops = { - 'pos': '+', - 'neg': '-', - 'abs': 'abs', - 'invert': '~', - 'int': 'int', - 'float': 'float', - 'oct': 'oct', - 'hex': 'hex', - } - -for name, expr in unops.items(): - if expr.islower(): - expr = expr + "(a)" - else: - expr = '%s a' % expr - unops[name] = expr - -def numops(a, b, skip=[]): - dict = {'a': a, 'b': b} - for name, expr in binops.items(): - if name not in skip: - name = "__%s__" % name - if hasattr(a, name): - res = eval(expr, dict) - testbinop(a, b, res, expr, name) - for name, expr in unops.items(): - if name not in skip: - name = "__%s__" % name - if hasattr(a, name): - res = eval(expr, dict) - testunop(a, res, expr, name) - -def ints(): - if verbose: print("Testing int operations...") - numops(100, 3) - # The following crashes in Python 2.2 - vereq((1).__bool__(), True) - vereq((0).__bool__(), False) - # This returns 'NotImplemented' in Python 2.2 - class C(int): - def __add__(self, other): - return NotImplemented - vereq(C(5), 5) - try: - C() + "" - except TypeError: - pass - else: - raise TestFailed("NotImplemented should have caused TypeError") - -def longs(): - if verbose: print("Testing long operations...") - numops(100, 3) - -def floats(): - if verbose: print("Testing float operations...") - numops(100.0, 3.0) - -def complexes(): - if verbose: print("Testing complex operations...") - numops(100.0j, 3.0j, - skip=['lt', 'le', 'gt', 'ge', 'int', 'long', 'float', - 'divmod', 'mod']) - class Number(complex): - __slots__ = ['prec'] - def __new__(cls, *args, **kwds): - result = complex.__new__(cls, *args) - result.prec = kwds.get('prec', 12) - return result - def __repr__(self): - prec = self.prec - if self.imag == 0.0: - return "%.*g" % (prec, self.real) - if self.real == 0.0: - return "%.*gj" % (prec, self.imag) - return "(%.*g+%.*gj)" % (prec, self.real, prec, self.imag) - __str__ = __repr__ - - a = Number(3.14, prec=6) - vereq(repr(a), "3.14") - vereq(a.prec, 6) - - a = Number(a, prec=2) - vereq(repr(a), "3.1") - vereq(a.prec, 2) - - a = Number(234.5) - vereq(repr(a), "234.5") - vereq(a.prec, 12) - -def spamlists(): - if verbose: print("Testing spamlist operations...") - import copy, xxsubtype as spam - def spamlist(l, memo=None): - import xxsubtype as spam - return spam.spamlist(l) - # This is an ugly hack: - copy._deepcopy_dispatch[spam.spamlist] = spamlist - - testbinop(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+b", "__add__") - testbinop(spamlist([1,2,3]), 2, 1, "b in a", "__contains__") - testbinop(spamlist([1,2,3]), 4, 0, "b in a", "__contains__") - testbinop(spamlist([1,2,3]), 1, 2, "a[b]", "__getitem__") - testsliceop(spamlist([1,2,3]), 0, 2, spamlist([1,2]), - "a[b:c]", "__getitem__") - testsetop(spamlist([1]), spamlist([2]), spamlist([1,2]), - "a+=b", "__iadd__") - testsetop(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*=b", "__imul__") - testunop(spamlist([1,2,3]), 3, "len(a)", "__len__") - testbinop(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*b", "__mul__") - testbinop(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "b*a", "__rmul__") - testset2op(spamlist([1,2]), 1, 3, spamlist([1,3]), "a[b]=c", "__setitem__") - testsetsliceop(spamlist([1,2,3,4]), 1, 3, spamlist([5,6]), - spamlist([1,5,6,4]), "a[b:c]=d", "__setitem__") - # Test subclassing - class C(spam.spamlist): - def foo(self): return 1 - a = C() - vereq(a, []) - vereq(a.foo(), 1) - a.append(100) - vereq(a, [100]) - vereq(a.getstate(), 0) - a.setstate(42) - vereq(a.getstate(), 42) - -def spamdicts(): - if verbose: print("Testing spamdict operations...") - import copy, xxsubtype as spam - def spamdict(d, memo=None): - import xxsubtype as spam - sd = spam.spamdict() - for k, v in d.items(): sd[k] = v - return sd - # This is an ugly hack: - copy._deepcopy_dispatch[spam.spamdict] = spamdict - - ##testbinop(spamdict({1:2}), spamdict({2:1}), -1, "cmp(a,b)", "__cmp__") - testbinop(spamdict({1:2,3:4}), 1, 1, "b in a", "__contains__") - testbinop(spamdict({1:2,3:4}), 2, 0, "b in a", "__contains__") - testbinop(spamdict({1:2,3:4}), 1, 2, "a[b]", "__getitem__") - d = spamdict({1:2,3:4}) - l1 = [] - for i in d.keys(): l1.append(i) - l = [] - for i in iter(d): l.append(i) - vereq(l, l1) - l = [] - for i in d.__iter__(): l.append(i) - vereq(l, l1) - l = [] - for i in type(spamdict({})).__iter__(d): l.append(i) - vereq(l, l1) - straightd = {1:2, 3:4} - spamd = spamdict(straightd) - testunop(spamd, 2, "len(a)", "__len__") - testunop(spamd, repr(straightd), "repr(a)", "__repr__") - testset2op(spamdict({1:2,3:4}), 2, 3, spamdict({1:2,2:3,3:4}), - "a[b]=c", "__setitem__") - # Test subclassing - class C(spam.spamdict): - def foo(self): return 1 - a = C() - vereq(list(a.items()), []) - vereq(a.foo(), 1) - a['foo'] = 'bar' - vereq(list(a.items()), [('foo', 'bar')]) - vereq(a.getstate(), 0) - a.setstate(100) - vereq(a.getstate(), 100) - -def pydicts(): - if verbose: print("Testing Python subclass of dict...") - verify(issubclass(dict, dict)) - verify(isinstance({}, dict)) - d = dict() - vereq(d, {}) - verify(d.__class__ is dict) - verify(isinstance(d, dict)) - class C(dict): - state = -1 - def __init__(self, *a, **kw): - if a: - vereq(len(a), 1) - self.state = a[0] - if kw: - for k, v in kw.items(): self[v] = k - def __getitem__(self, key): - return self.get(key, 0) - def __setitem__(self, key, value): - verify(isinstance(key, type(0))) - dict.__setitem__(self, key, value) - def setstate(self, state): - self.state = state - def getstate(self): - return self.state - verify(issubclass(C, dict)) - a1 = C(12) - vereq(a1.state, 12) - a2 = C(foo=1, bar=2) - vereq(a2[1] == 'foo' and a2[2], 'bar') - a = C() - vereq(a.state, -1) - vereq(a.getstate(), -1) - a.setstate(0) - vereq(a.state, 0) - vereq(a.getstate(), 0) - a.setstate(10) - vereq(a.state, 10) - vereq(a.getstate(), 10) - vereq(a[42], 0) - a[42] = 24 - vereq(a[42], 24) - if verbose: print("pydict stress test ...") - N = 50 - for i in range(N): - a[i] = C() - for j in range(N): - a[i][j] = i*j - for i in range(N): - for j in range(N): - vereq(a[i][j], i*j) - -def pylists(): - if verbose: print("Testing Python subclass of list...") - class C(list): - def __getitem__(self, i): - if isinstance(i, slice): - return (i.start, i.stop) - return list.__getitem__(self, i) + 100 - a = C() - a.extend([0,1,2]) - vereq(a[0], 100) - vereq(a[1], 101) - vereq(a[2], 102) - vereq(a[100:200], (100,200)) - -def metaclass(): - if verbose: print("Testing metaclass...") - class C(metaclass=type): - def __init__(self): - self.__state = 0 - def getstate(self): - return self.__state - def setstate(self, state): - self.__state = state - a = C() - vereq(a.getstate(), 0) - a.setstate(10) - vereq(a.getstate(), 10) - class _metaclass(type): - def myself(cls): return cls - class D(metaclass=_metaclass): - pass - vereq(D.myself(), D) - d = D() - verify(d.__class__ is D) - class M1(type): - def __new__(cls, name, bases, dict): - dict['__spam__'] = 1 - return type.__new__(cls, name, bases, dict) - class C(metaclass=M1): - pass - vereq(C.__spam__, 1) - c = C() - vereq(c.__spam__, 1) - - class _instance(object): - pass - class M2(object): - @staticmethod - def __new__(cls, name, bases, dict): - self = object.__new__(cls) - self.name = name - self.bases = bases - self.dict = dict - return self - def __call__(self): - it = _instance() - # Early binding of methods - for key in self.dict: - if key.startswith("__"): - continue - setattr(it, key, self.dict[key].__get__(it, self)) - return it - class C(metaclass=M2): - def spam(self): - return 42 - vereq(C.name, 'C') - vereq(C.bases, ()) - verify('spam' in C.dict) - c = C() - vereq(c.spam(), 42) - - # More metaclass examples - - class autosuper(type): - # Automatically add __super to the class - # This trick only works for dynamic classes - def __new__(metaclass, name, bases, dict): - cls = super(autosuper, metaclass).__new__(metaclass, - name, bases, dict) - # Name mangling for __super removes leading underscores - while name[:1] == "_": - name = name[1:] - if name: - name = "_%s__super" % name - else: - name = "__super" - setattr(cls, name, super(cls)) - return cls - class A(metaclass=autosuper): - def meth(self): - return "A" - class B(A): - def meth(self): - return "B" + self.__super.meth() - class C(A): - def meth(self): - return "C" + self.__super.meth() - class D(C, B): - def meth(self): - return "D" + self.__super.meth() - vereq(D().meth(), "DCBA") - class E(B, C): - def meth(self): - return "E" + self.__super.meth() - vereq(E().meth(), "EBCA") - - class autoproperty(type): - # Automatically create property attributes when methods - # named _get_x and/or _set_x are found - def __new__(metaclass, name, bases, dict): - hits = {} - for key, val in dict.items(): - if key.startswith("_get_"): - key = key[5:] - get, set = hits.get(key, (None, None)) - get = val - hits[key] = get, set - elif key.startswith("_set_"): - key = key[5:] - get, set = hits.get(key, (None, None)) - set = val - hits[key] = get, set - for key, (get, set) in hits.items(): - dict[key] = property(get, set) - return super(autoproperty, metaclass).__new__(metaclass, - name, bases, dict) - class A(metaclass=autoproperty): - def _get_x(self): - return -self.__x - def _set_x(self, x): - self.__x = -x - a = A() - verify(not hasattr(a, "x")) - a.x = 12 - vereq(a.x, 12) - vereq(a._A__x, -12) - - class multimetaclass(autoproperty, autosuper): - # Merge of multiple cooperating metaclasses - pass - class A(metaclass=multimetaclass): - def _get_x(self): - return "A" - class B(A): - def _get_x(self): - return "B" + self.__super._get_x() - class C(A): - def _get_x(self): - return "C" + self.__super._get_x() - class D(C, B): - def _get_x(self): - return "D" + self.__super._get_x() - vereq(D().x, "DCBA") - - # Make sure type(x) doesn't call x.__class__.__init__ - class T(type): - counter = 0 - def __init__(self, *args): - T.counter += 1 - class C(metaclass=T): - pass - vereq(T.counter, 1) - a = C() - vereq(type(a), C) - vereq(T.counter, 1) - - class C(object): pass - c = C() - try: c() - except TypeError: pass - else: raise TestFailed("calling object w/o call method should raise TypeError") - - # Testing code to find most derived baseclass - class A(type): - def __new__(*args, **kwargs): - return type.__new__(*args, **kwargs) - - class B(object): - pass - - class C(object, metaclass=A): - pass - - # The most derived metaclass of D is A rather than type. - class D(B, C): - pass - - -def pymods(): - if verbose: print("Testing Python subclass of module...") - log = [] - import sys - MT = type(sys) - class MM(MT): - def __init__(self, name): - MT.__init__(self, name) - def __getattribute__(self, name): - log.append(("getattr", name)) - return MT.__getattribute__(self, name) - def __setattr__(self, name, value): - log.append(("setattr", name, value)) - MT.__setattr__(self, name, value) - def __delattr__(self, name): - log.append(("delattr", name)) - MT.__delattr__(self, name) - a = MM("a") - a.foo = 12 - x = a.foo - del a.foo - vereq(log, [("setattr", "foo", 12), - ("getattr", "foo"), - ("delattr", "foo")]) - - # http://python.org/sf/1174712 - try: - class Module(types.ModuleType, str): - pass - except TypeError: - pass - else: - raise TestFailed("inheriting from ModuleType and str at the " - "same time should fail") - -def multi(): - if verbose: print("Testing multiple inheritance...") - class C(object): - def __init__(self): - self.__state = 0 - def getstate(self): - return self.__state - def setstate(self, state): - self.__state = state - a = C() - vereq(a.getstate(), 0) - a.setstate(10) - vereq(a.getstate(), 10) - class D(dict, C): - def __init__(self): - type({}).__init__(self) - C.__init__(self) - d = D() - vereq(list(d.keys()), []) - d["hello"] = "world" - vereq(list(d.items()), [("hello", "world")]) - vereq(d["hello"], "world") - vereq(d.getstate(), 0) - d.setstate(10) - vereq(d.getstate(), 10) - vereq(D.__mro__, (D, dict, C, object)) - - # SF bug #442833 - class Node(object): - def __int__(self): - return int(self.foo()) - def foo(self): - return "23" - class Frag(Node, list): - def foo(self): - return "42" - vereq(Node().__int__(), 23) - vereq(int(Node()), 23) - vereq(Frag().__int__(), 42) - vereq(int(Frag()), 42) - -def diamond(): - if verbose: print("Testing multiple inheritance special cases...") - class A(object): - def spam(self): return "A" - vereq(A().spam(), "A") - class B(A): - def boo(self): return "B" - def spam(self): return "B" - vereq(B().spam(), "B") - vereq(B().boo(), "B") - class C(A): - def boo(self): return "C" - vereq(C().spam(), "A") - vereq(C().boo(), "C") - class D(B, C): pass - vereq(D().spam(), "B") - vereq(D().boo(), "B") - vereq(D.__mro__, (D, B, C, A, object)) - class E(C, B): pass - vereq(E().spam(), "B") - vereq(E().boo(), "C") - vereq(E.__mro__, (E, C, B, A, object)) - # MRO order disagreement - try: - class F(D, E): pass - except TypeError: - pass - else: - raise TestFailed("expected MRO order disagreement (F)") - try: - class G(E, D): pass - except TypeError: - pass - else: - raise TestFailed("expected MRO order disagreement (G)") - - -# see thread python-dev/2002-October/029035.html -def ex5(): - if verbose: print("Testing ex5 from C3 switch discussion...") - class A(object): pass - class B(object): pass - class C(object): pass - class X(A): pass - class Y(A): pass - class Z(X,B,Y,C): pass - vereq(Z.__mro__, (Z, X, B, Y, A, C, object)) - -# see "A Monotonic Superclass Linearization for Dylan", -# by Kim Barrett et al. (OOPSLA 1996) -def monotonicity(): - if verbose: print("Testing MRO monotonicity...") - class Boat(object): pass - class DayBoat(Boat): pass - class WheelBoat(Boat): pass - class EngineLess(DayBoat): pass - class SmallMultihull(DayBoat): pass - class PedalWheelBoat(EngineLess,WheelBoat): pass - class SmallCatamaran(SmallMultihull): pass - class Pedalo(PedalWheelBoat,SmallCatamaran): pass - - vereq(PedalWheelBoat.__mro__, - (PedalWheelBoat, EngineLess, DayBoat, WheelBoat, Boat, - object)) - vereq(SmallCatamaran.__mro__, - (SmallCatamaran, SmallMultihull, DayBoat, Boat, object)) - - vereq(Pedalo.__mro__, - (Pedalo, PedalWheelBoat, EngineLess, SmallCatamaran, - SmallMultihull, DayBoat, WheelBoat, Boat, object)) - -# see "A Monotonic Superclass Linearization for Dylan", -# by Kim Barrett et al. (OOPSLA 1996) -def consistency_with_epg(): - if verbose: print("Testing consistentcy with EPG...") - class Pane(object): pass - class ScrollingMixin(object): pass - class EditingMixin(object): pass - class ScrollablePane(Pane,ScrollingMixin): pass - class EditablePane(Pane,EditingMixin): pass - class EditableScrollablePane(ScrollablePane,EditablePane): pass - - vereq(EditableScrollablePane.__mro__, - (EditableScrollablePane, ScrollablePane, EditablePane, - Pane, ScrollingMixin, EditingMixin, object)) + def test_hash_inheritance(self): + # Testing hash of mutable subclasses... -mro_err_msg = """Cannot create a consistent method resolution -order (MRO) for bases """ + class mydict(dict): + pass + d = mydict() + try: + hash(d) + except TypeError: + pass + else: + self.fail("hash() of dict subclass should fail") -def mro_disagreement(): - if verbose: print("Testing error messages for MRO disagreement...") - def raises(exc, expected, callable, *args): - try: - callable(*args) - except exc as msg: - if not str(msg).startswith(expected): - raise TestFailed("Message %r, expected %r" % (str(msg), - expected)) - else: - raise TestFailed("Expected %s" % exc) - class A(object): pass - class B(A): pass - class C(object): pass - # Test some very simple errors - raises(TypeError, "duplicate base class A", - type, "X", (A, A), {}) - raises(TypeError, mro_err_msg, - type, "X", (A, B), {}) - raises(TypeError, mro_err_msg, - type, "X", (A, C, B), {}) - # Test a slightly more complex error - class GridLayout(object): pass - class HorizontalGrid(GridLayout): pass - class VerticalGrid(GridLayout): pass - class HVGrid(HorizontalGrid, VerticalGrid): pass - class VHGrid(VerticalGrid, HorizontalGrid): pass - raises(TypeError, mro_err_msg, - type, "ConfusedGrid", (HVGrid, VHGrid), {}) - -def objects(): - if verbose: print("Testing object class...") - a = object() - vereq(a.__class__, object) - vereq(type(a), object) - b = object() - verify(a is not b) - verify(not hasattr(a, "foo")) - try: - a.foo = 12 - except (AttributeError, TypeError): - pass - else: - verify(0, "object() should not allow setting a foo attribute") - verify(not hasattr(object(), "__dict__")) - - class Cdict(object): - pass - x = Cdict() - vereq(x.__dict__, {}) - x.foo = 1 - vereq(x.foo, 1) - vereq(x.__dict__, {'foo': 1}) - -def slots(): - if verbose: print("Testing __slots__...") - class C0(object): - __slots__ = [] - x = C0() - verify(not hasattr(x, "__dict__")) - verify(not hasattr(x, "foo")) - - class C1(object): - __slots__ = ['a'] - x = C1() - verify(not hasattr(x, "__dict__")) - verify(not hasattr(x, "a")) - x.a = 1 - vereq(x.a, 1) - x.a = None - veris(x.a, None) - del x.a - verify(not hasattr(x, "a")) - - class C3(object): - __slots__ = ['a', 'b', 'c'] - x = C3() - verify(not hasattr(x, "__dict__")) - verify(not hasattr(x, 'a')) - verify(not hasattr(x, 'b')) - verify(not hasattr(x, 'c')) - x.a = 1 - x.b = 2 - x.c = 3 - vereq(x.a, 1) - vereq(x.b, 2) - vereq(x.c, 3) - - class C4(object): - """Validate name mangling""" - __slots__ = ['__a'] - def __init__(self, value): - self.__a = value - def get(self): - return self.__a - x = C4(5) - verify(not hasattr(x, '__dict__')) - verify(not hasattr(x, '__a')) - vereq(x.get(), 5) - try: - x.__a = 6 - except AttributeError: - pass - else: - raise TestFailed("Double underscored names not mangled") + class mylist(list): + pass + d = mylist() + try: + hash(d) + except TypeError: + pass + else: + self.fail("hash() of list subclass should fail") - # Make sure slot names are proper identifiers - try: - class C(object): - __slots__ = [None] - except TypeError: - pass - else: - raise TestFailed("[None] slots not caught") - try: - class C(object): - __slots__ = ["foo bar"] - except TypeError: - pass - else: - raise TestFailed("['foo bar'] slots not caught") - try: - class C(object): - __slots__ = ["foo\0bar"] - except TypeError: - pass - else: - raise TestFailed("['foo\\0bar'] slots not caught") - try: + def test_str_operations(self): + try: 'a' + 5 + except TypeError: pass + else: self.fail("'' + 5 doesn't raise TypeError") + + try: ''.split('') + except ValueError: pass + else: self.fail("''.split('') doesn't raise ValueError") + + try: ''.join([0]) + except TypeError: pass + else: self.fail("''.join([0]) doesn't raise TypeError") + + try: ''.rindex('5') + except ValueError: pass + else: self.fail("''.rindex('5') doesn't raise ValueError") + + try: '%(n)s' % None + except TypeError: pass + else: self.fail("'%(n)s' % None doesn't raise TypeError") + + try: '%(n' % {} + except ValueError: pass + else: self.fail("'%(n' % {} '' doesn't raise ValueError") + + try: '%*s' % ('abc') + except TypeError: pass + else: self.fail("'%*s' % ('abc') doesn't raise TypeError") + + try: '%*.*s' % ('abc', 5) + except TypeError: pass + else: self.fail("'%*.*s' % ('abc', 5) doesn't raise TypeError") + + try: '%s' % (1, 2) + except TypeError: pass + else: self.fail("'%s' % (1, 2) doesn't raise TypeError") + + try: '%' % None + except ValueError: pass + else: self.fail("'%' % None doesn't raise ValueError") + + self.assertEqual('534253'.isdigit(), 1) + self.assertEqual('534253x'.isdigit(), 0) + self.assertEqual('%c' % 5, '\x05') + self.assertEqual('%c' % '5', '5') + + def test_deepcopy_recursive(self): + # Testing deepcopy of recursive objects... + class Node: + pass + a = Node() + b = Node() + a.b = b + b.a = a + z = deepcopy(a) # This blew up before + + def test_unintialized_modules(self): + # Testing uninitialized module objects... + from types import ModuleType as M + m = M.__new__(M) + str(m) + self.assertEqual(hasattr(m, "__name__"), 0) + self.assertEqual(hasattr(m, "__file__"), 0) + self.assertEqual(hasattr(m, "foo"), 0) + self.assertEqual(m.__dict__, None) + m.foo = 1 + self.assertEqual(m.__dict__, {"foo": 1}) + + def test_funny_new(self): + # Testing __new__ returning something unexpected... class C(object): - __slots__ = ["1"] - except TypeError: - pass - else: - raise TestFailed("['1'] slots not caught") - try: + def __new__(cls, arg): + if isinstance(arg, str): return [1, 2, 3] + elif isinstance(arg, int): return object.__new__(D) + else: return object.__new__(cls) + class D(C): + def __init__(self, arg): + self.foo = arg + self.assertEqual(C("1"), [1, 2, 3]) + self.assertEqual(D("1"), [1, 2, 3]) + d = D(None) + self.assertEqual(d.foo, None) + d = C(1) + self.assertEqual(isinstance(d, D), True) + self.assertEqual(d.foo, 1) + d = D(1) + self.assertEqual(isinstance(d, D), True) + self.assertEqual(d.foo, 1) + + def test_imul_bug(self): + # Testing for __imul__ problems... + # SF bug 544647 class C(object): - __slots__ = [""] - except TypeError: - pass - else: - raise TestFailed("[''] slots not caught") - class C(object): - __slots__ = ["a", "a_b", "_a", "A0123456789Z"] - # XXX(nnorwitz): was there supposed to be something tested - # from the class above? - - # Test a single string is not expanded as a sequence. - class C(object): - __slots__ = "abc" - c = C() - c.abc = 5 - vereq(c.abc, 5) - - # Test unicode slot names - # Test a single unicode string is not expanded as a sequence. - class C(object): - __slots__ = "abc" - c = C() - c.abc = 5 - vereq(c.abc, 5) - - # _unicode_to_string used to modify slots in certain circumstances - slots = ("foo", "bar") - class C(object): - __slots__ = slots - x = C() - x.foo = 5 - vereq(x.foo, 5) - veris(type(slots[0]), str) - # this used to leak references - try: + def __imul__(self, other): + return (self, other) + x = C() + y = x + y *= 1.0 + self.assertEqual(y, (x, 1.0)) + y = x + y *= 2 + self.assertEqual(y, (x, 2)) + y = x + y *= 3 + self.assertEqual(y, (x, 3)) + y = x + y *= 1<<100 + self.assertEqual(y, (x, 1<<100)) + y = x + y *= None + self.assertEqual(y, (x, None)) + y = x + y *= "foo" + self.assertEqual(y, (x, "foo")) + + def test_copy_setstate(self): + # Testing that copy.*copy() correctly uses __setstate__... + import copy class C(object): - __slots__ = [chr(128)] - except (TypeError, UnicodeEncodeError): - pass - else: - raise TestFailed("[unichr(128)] slots not caught") - - # Test leaks - class Counted(object): - counter = 0 # counts the number of instances alive - def __init__(self): - Counted.counter += 1 - def __del__(self): - Counted.counter -= 1 - class C(object): - __slots__ = ['a', 'b', 'c'] - x = C() - x.a = Counted() - x.b = Counted() - x.c = Counted() - vereq(Counted.counter, 3) - del x - vereq(Counted.counter, 0) - class D(C): - pass - x = D() - x.a = Counted() - x.z = Counted() - vereq(Counted.counter, 2) - del x - vereq(Counted.counter, 0) - class E(D): - __slots__ = ['e'] - x = E() - x.a = Counted() - x.z = Counted() - x.e = Counted() - vereq(Counted.counter, 3) - del x - vereq(Counted.counter, 0) - - # Test cyclical leaks [SF bug 519621] - class F(object): - __slots__ = ['a', 'b'] - log = [] - s = F() - s.a = [Counted(), s] - vereq(Counted.counter, 1) - s = None - import gc - gc.collect() - vereq(Counted.counter, 0) - - # Test lookup leaks [SF bug 572567] - import sys,gc - class G(object): - def __cmp__(self, other): - return 0 - g = G() - orig_objects = len(gc.get_objects()) - for i in range(10): - g==g - new_objects = len(gc.get_objects()) - vereq(orig_objects, new_objects) - class H(object): - __slots__ = ['a', 'b'] - def __init__(self): - self.a = 1 - self.b = 2 - def __del__(self): - assert self.a == 1 - assert self.b == 2 - - save_stderr = sys.stderr - sys.stderr = sys.stdout - h = H() - try: - del h - finally: - sys.stderr = save_stderr - -def slotspecials(): - if verbose: print("Testing __dict__ and __weakref__ in __slots__...") - - class D(object): - __slots__ = ["__dict__"] - a = D() - verify(hasattr(a, "__dict__")) - verify(not hasattr(a, "__weakref__")) - a.foo = 42 - vereq(a.__dict__, {"foo": 42}) - - class W(object): - __slots__ = ["__weakref__"] - a = W() - verify(hasattr(a, "__weakref__")) - verify(not hasattr(a, "__dict__")) - try: - a.foo = 42 - except AttributeError: - pass - else: - raise TestFailed("shouldn't be allowed to set a.foo") - - class C1(W, D): - __slots__ = [] - a = C1() - verify(hasattr(a, "__dict__")) - verify(hasattr(a, "__weakref__")) - a.foo = 42 - vereq(a.__dict__, {"foo": 42}) - - class C2(D, W): - __slots__ = [] - a = C2() - verify(hasattr(a, "__dict__")) - verify(hasattr(a, "__weakref__")) - a.foo = 42 - vereq(a.__dict__, {"foo": 42}) - -# MRO order disagreement -# -# class C3(C1, C2): -# __slots__ = [] -# -# class C4(C2, C1): -# __slots__ = [] - -def dynamics(): - if verbose: print("Testing class attribute propagation...") - class D(object): - pass - class E(D): - pass - class F(D): - pass - D.foo = 1 - vereq(D.foo, 1) - # Test that dynamic attributes are inherited - vereq(E.foo, 1) - vereq(F.foo, 1) - # Test dynamic instances - class C(object): - pass - a = C() - verify(not hasattr(a, "foobar")) - C.foobar = 2 - vereq(a.foobar, 2) - C.method = lambda self: 42 - vereq(a.method(), 42) - C.__repr__ = lambda self: "C()" - vereq(repr(a), "C()") - C.__int__ = lambda self: 100 - vereq(int(a), 100) - vereq(a.foobar, 2) - verify(not hasattr(a, "spam")) - def mygetattr(self, name): - if name == "spam": - return "spam" - raise AttributeError - C.__getattr__ = mygetattr - vereq(a.spam, "spam") - a.new = 12 - vereq(a.new, 12) - def mysetattr(self, name, value): - if name == "spam": - raise AttributeError - return object.__setattr__(self, name, value) - C.__setattr__ = mysetattr - try: - a.spam = "not spam" - except AttributeError: - pass - else: - verify(0, "expected AttributeError") - vereq(a.spam, "spam") - class D(C): - pass - d = D() - d.foo = 1 - vereq(d.foo, 1) - - # Test handling of int*seq and seq*int - class I(int): - pass - vereq("a"*I(2), "aa") - vereq(I(2)*"a", "aa") - vereq(2*I(3), 6) - vereq(I(3)*2, 6) - vereq(I(3)*I(2), 6) - - # Test handling of long*seq and seq*long - class L(int): - pass - vereq("a"*L(2), "aa") - vereq(L(2)*"a", "aa") - vereq(2*L(3), 6) - vereq(L(3)*2, 6) - vereq(L(3)*L(2), 6) - - # Test comparison of classes with dynamic metaclasses - class dynamicmetaclass(type): - pass - class someclass(metaclass=dynamicmetaclass): - pass - verify(someclass != object) - -def errors(): - if verbose: print("Testing errors...") - - try: - class C(list, dict): - pass - except TypeError: - pass - else: - verify(0, "inheritance from both list and dict should be illegal") - - try: - class C(object, None): - pass - except TypeError: - pass - else: - verify(0, "inheritance from non-type should be illegal") - class Classic: - pass - - try: - class C(type(len)): - pass - except TypeError: - pass - else: - verify(0, "inheritance from CFunction should be illegal") + def __init__(self, foo=None): + self.foo = foo + self.__foo = foo + def setfoo(self, foo=None): + self.foo = foo + def getfoo(self): + return self.__foo + def __getstate__(self): + return [self.foo] + def __setstate__(self_, lst): + self.assertEqual(len(lst), 1) + self_.__foo = self_.foo = lst[0] + a = C(42) + a.setfoo(24) + self.assertEqual(a.foo, 24) + self.assertEqual(a.getfoo(), 42) + b = copy.copy(a) + self.assertEqual(b.foo, 24) + self.assertEqual(b.getfoo(), 24) + b = copy.deepcopy(a) + self.assertEqual(b.foo, 24) + self.assertEqual(b.getfoo(), 24) + + def test_slices(self): + # Testing cases with slices and overridden __getitem__ ... + + # Strings + self.assertEqual("hello"[:4], "hell") + self.assertEqual("hello"[slice(4)], "hell") + self.assertEqual(str.__getitem__("hello", slice(4)), "hell") + class S(str): + def __getitem__(self, x): + return str.__getitem__(self, x) + self.assertEqual(S("hello")[:4], "hell") + self.assertEqual(S("hello")[slice(4)], "hell") + self.assertEqual(S("hello").__getitem__(slice(4)), "hell") + # Tuples + self.assertEqual((1,2,3)[:2], (1,2)) + self.assertEqual((1,2,3)[slice(2)], (1,2)) + self.assertEqual(tuple.__getitem__((1,2,3), slice(2)), (1,2)) + class T(tuple): + def __getitem__(self, x): + return tuple.__getitem__(self, x) + self.assertEqual(T((1,2,3))[:2], (1,2)) + self.assertEqual(T((1,2,3))[slice(2)], (1,2)) + self.assertEqual(T((1,2,3)).__getitem__(slice(2)), (1,2)) + # Lists + self.assertEqual([1,2,3][:2], [1,2]) + self.assertEqual([1,2,3][slice(2)], [1,2]) + self.assertEqual(list.__getitem__([1,2,3], slice(2)), [1,2]) + class L(list): + def __getitem__(self, x): + return list.__getitem__(self, x) + self.assertEqual(L([1,2,3])[:2], [1,2]) + self.assertEqual(L([1,2,3])[slice(2)], [1,2]) + self.assertEqual(L([1,2,3]).__getitem__(slice(2)), [1,2]) + # Now do lists and __setitem__ + a = L([1,2,3]) + a[slice(1, 3)] = [3,2] + self.assertEqual(a, [1,3,2]) + a[slice(0, 2, 1)] = [3,1] + self.assertEqual(a, [3,1,2]) + a.__setitem__(slice(1, 3), [2,1]) + self.assertEqual(a, [3,2,1]) + a.__setitem__(slice(0, 2, 1), [2,3]) + self.assertEqual(a, [2,3,1]) + + def test_subtype_resurrection(self): + # Testing resurrection of new-style instance... - try: class C(object): - __slots__ = 1 - except TypeError: - pass - else: - verify(0, "__slots__ = 1 should be illegal") + container = [] - try: + def __del__(self): + # resurrect the instance + C.container.append(self) + + c = C() + c.attr = 42 + + # The most interesting thing here is whether this blows up, due to flawed + # GC tracking logic in typeobject.c's call_finalizer() (a 2.2.1 bug). + del c + + # If that didn't blow up, it's also interesting to see whether clearing + # the last container slot works: that will attempt to delete c again, + # which will cause c to get appended back to the container again "during" + # the del. + del C.container[-1] + self.assertEqual(len(C.container), 1) + self.assertEqual(C.container[-1].attr, 42) + + # Make c mortal again, so that the test framework with -l doesn't report + # it as a leak. + del C.__del__ + + def test_slots_trash(self): + # Testing slot trash... + # Deallocating deeply nested slotted trash caused stack overflows + class trash(object): + __slots__ = ['x'] + def __init__(self, x): + self.x = x + o = None + for i in range(50000): + o = trash(o) + del o + + def test_slots_multiple_inheritance(self): + # SF bug 575229, multiple inheritance w/ slots dumps core + class A(object): + __slots__=() + class B(object): + pass + class C(A,B) : + __slots__=() + self.assertEqual(C.__basicsize__, B.__basicsize__) + self.assert_(hasattr(C, '__dict__')) + self.assert_(hasattr(C, '__weakref__')) + C().x = 2 + + def test_rmul(self): + # Testing correct invocation of __rmul__... + # SF patch 592646 class C(object): - __slots__ = [1] - except TypeError: - pass - else: - verify(0, "__slots__ = [1] should be illegal") - - class M1(type): - pass - class M2(type): - pass - class A1(object, metaclass=M1): - pass - class A2(object, metaclass=M2): - pass - try: - class B(A1, A2): - pass - except TypeError: - pass - else: - verify(0, "finding the most derived metaclass should have failed") - -def classmethods(): - if verbose: print("Testing class methods...") - class C(object): - def foo(*a): return a - goo = classmethod(foo) - c = C() - vereq(C.goo(1), (C, 1)) - vereq(c.goo(1), (C, 1)) - vereq(c.foo(1), (c, 1)) - class D(C): - pass - d = D() - vereq(D.goo(1), (D, 1)) - vereq(d.goo(1), (D, 1)) - vereq(d.foo(1), (d, 1)) - vereq(D.foo(d, 1), (d, 1)) - # Test for a specific crash (SF bug 528132) - def f(cls, arg): return (cls, arg) - ff = classmethod(f) - vereq(ff.__get__(0, int)(42), (int, 42)) - vereq(ff.__get__(0)(42), (int, 42)) - - # Test super() with classmethods (SF bug 535444) - veris(C.goo.__self__, C) - veris(D.goo.__self__, D) - veris(super(D,D).goo.__self__, D) - veris(super(D,d).goo.__self__, D) - vereq(super(D,D).goo(), (D,)) - vereq(super(D,d).goo(), (D,)) - - # Verify that argument is checked for callability (SF bug 753451) - try: - classmethod(1).__get__(1) - except TypeError: - pass - else: - raise TestFailed("classmethod should check for callability") - - # Verify that classmethod() doesn't allow keyword args - try: - classmethod(f, kw=1) - except TypeError: - pass - else: - raise TestFailed("classmethod shouldn't accept keyword args") - -def classmethods_in_c(): - if verbose: print("Testing C-based class methods...") - import xxsubtype as spam - a = (1, 2, 3) - d = {'abc': 123} - x, a1, d1 = spam.spamlist.classmeth(*a, **d) - veris(x, spam.spamlist) - vereq(a, a1) - vereq(d, d1) - x, a1, d1 = spam.spamlist().classmeth(*a, **d) - veris(x, spam.spamlist) - vereq(a, a1) - vereq(d, d1) - -def staticmethods(): - if verbose: print("Testing static methods...") - class C(object): - def foo(*a): return a - goo = staticmethod(foo) - c = C() - vereq(C.goo(1), (1,)) - vereq(c.goo(1), (1,)) - vereq(c.foo(1), (c, 1,)) - class D(C): - pass - d = D() - vereq(D.goo(1), (1,)) - vereq(d.goo(1), (1,)) - vereq(d.foo(1), (d, 1)) - vereq(D.foo(d, 1), (d, 1)) - -def staticmethods_in_c(): - if verbose: print("Testing C-based static methods...") - import xxsubtype as spam - a = (1, 2, 3) - d = {"abc": 123} - x, a1, d1 = spam.spamlist.staticmeth(*a, **d) - veris(x, None) - vereq(a, a1) - vereq(d, d1) - x, a1, d2 = spam.spamlist().staticmeth(*a, **d) - veris(x, None) - vereq(a, a1) - vereq(d, d1) - -def classic(): - if verbose: print("Testing classic classes...") - class C: - def foo(*a): return a - goo = classmethod(foo) - c = C() - vereq(C.goo(1), (C, 1)) - vereq(c.goo(1), (C, 1)) - vereq(c.foo(1), (c, 1)) - class D(C): - pass - d = D() - vereq(D.goo(1), (D, 1)) - vereq(d.goo(1), (D, 1)) - vereq(d.foo(1), (d, 1)) - vereq(D.foo(d, 1), (d, 1)) - class E: # *not* subclassing from C - foo = C.foo - r = repr(E().foo) - verify(r.startswith("= 0) - vereq(str(c1), repr(c1)) - verify(-1 not in c1) - for i in range(10): - verify(i in c1) - verify(10 not in c1) - # Test the default behavior for dynamic classes - class D(object): - def __getitem__(self, i): - if 0 <= i < 10: return i - raise IndexError - d1 = D() - d2 = D() - verify(not not d1) - verify(id(d1) != id(d2)) - hash(d1) - hash(d2) - ##vereq(cmp(d1, d2), cmp(id(d1), id(d2))) - vereq(d1, d1) - verify(d1 != d2) - verify(not d1 != d1) - verify(not d1 == d2) - # Note that the module name appears in str/repr, and that varies - # depending on whether this test is run standalone or from a framework. - verify(str(d1).find('D object at ') >= 0) - vereq(str(d1), repr(d1)) - verify(-1 not in d1) - for i in range(10): - verify(i in d1) - verify(10 not in d1) - # Test overridden behavior for static classes - class Proxy(object): - def __init__(self, x): - self.x = x - def __bool__(self): - return not not self.x - def __hash__(self): - return hash(self.x) - def __eq__(self, other): - return self.x == other - def __ne__(self, other): - return self.x != other - def __cmp__(self, other): - return cmp(self.x, other.x) - def __str__(self): - return "Proxy:%s" % self.x - def __repr__(self): - return "Proxy(%r)" % self.x - def __contains__(self, value): - return value in self.x - p0 = Proxy(0) - p1 = Proxy(1) - p_1 = Proxy(-1) - verify(not p0) - verify(not not p1) - vereq(hash(p0), hash(0)) - vereq(p0, p0) - verify(p0 != p1) - verify(not p0 != p0) - vereq(not p0, p1) - vereq(cmp(p0, p1), -1) - vereq(cmp(p0, p0), 0) - vereq(cmp(p0, p_1), 1) - vereq(str(p0), "Proxy:0") - vereq(repr(p0), "Proxy(0)") - p10 = Proxy(range(10)) - verify(-1 not in p10) - for i in range(10): - verify(i in p10) - verify(10 not in p10) - # Test overridden behavior for dynamic classes - class DProxy(object): - def __init__(self, x): - self.x = x - def __bool__(self): - return not not self.x - def __hash__(self): - return hash(self.x) - def __eq__(self, other): - return self.x == other - def __ne__(self, other): - return self.x != other - def __cmp__(self, other): - return cmp(self.x, other.x) - def __str__(self): - return "DProxy:%s" % self.x - def __repr__(self): - return "DProxy(%r)" % self.x - def __contains__(self, value): - return value in self.x - p0 = DProxy(0) - p1 = DProxy(1) - p_1 = DProxy(-1) - verify(not p0) - verify(not not p1) - vereq(hash(p0), hash(0)) - vereq(p0, p0) - verify(p0 != p1) - verify(not p0 != p0) - vereq(not p0, p1) - vereq(cmp(p0, p1), -1) - vereq(cmp(p0, p0), 0) - vereq(cmp(p0, p_1), 1) - vereq(str(p0), "DProxy:0") - vereq(repr(p0), "DProxy(0)") - p10 = DProxy(range(10)) - verify(-1 not in p10) - for i in range(10): - verify(i in p10) - verify(10 not in p10) -## # Safety test for __cmp__ -## def unsafecmp(a, b): -## try: -## a.__class__.__cmp__(a, b) -## except TypeError: -## pass -## else: -## raise TestFailed, "shouldn't allow %s.__cmp__(%r, %r)" % ( -## a.__class__, a, b) -## unsafecmp(u"123", "123") -## unsafecmp("123", u"123") -## unsafecmp(1, 1.0) -## unsafecmp(1.0, 1) -## unsafecmp(1, 1L) -## unsafecmp(1L, 1) - -def recursions(): - if verbose: - print("Testing recursion checks ...") - -## class Letter(str): -## def __new__(cls, letter): -## if letter == 'EPS': -## return str.__new__(cls) -## return str.__new__(cls, letter) -## def __str__(self): -## if not self: -## return 'EPS' -## return self -## # sys.stdout needs to be the original to trigger the recursion bug -## import sys -## test_stdout = sys.stdout -## sys.stdout = get_original_stdout() -## try: -## # nothing should actually be printed, this should raise an exception -## print(Letter('w')) -## except RuntimeError: -## pass -## else: -## raise TestFailed, "expected a RuntimeError for print recursion" -## sys.stdout = test_stdout - -def weakrefs(): - if verbose: print("Testing weak references...") - import weakref - class C(object): - pass - c = C() - r = weakref.ref(c) - verify(r() is c) - del c - verify(r() is None) - del r - class NoWeak(object): - __slots__ = ['foo'] - no = NoWeak() - try: - weakref.ref(no) - except TypeError as msg: - verify(str(msg).find("weak reference") >= 0) - else: - verify(0, "weakref.ref(no) should be illegal") - class Weak(object): - __slots__ = ['foo', '__weakref__'] - yes = Weak() - r = weakref.ref(yes) - verify(r() is yes) - del yes - verify(r() is None) - del r - -def properties(): - if verbose: print("Testing property...") - class C(object): - def getx(self): - return self.__x - def setx(self, value): - self.__x = value - def delx(self): - del self.__x - x = property(getx, setx, delx, doc="I'm the x property.") - a = C() - verify(not hasattr(a, "x")) - a.x = 42 - vereq(a._C__x, 42) - vereq(a.x, 42) - del a.x - verify(not hasattr(a, "x")) - verify(not hasattr(a, "_C__x")) - C.x.__set__(a, 100) - vereq(C.x.__get__(a), 100) - C.x.__delete__(a) - verify(not hasattr(a, "x")) - - raw = C.__dict__['x'] - verify(isinstance(raw, property)) - - attrs = dir(raw) - verify("__doc__" in attrs) - verify("fget" in attrs) - verify("fset" in attrs) - verify("fdel" in attrs) - - vereq(raw.__doc__, "I'm the x property.") - verify(raw.fget is C.__dict__['getx']) - verify(raw.fset is C.__dict__['setx']) - verify(raw.fdel is C.__dict__['delx']) - - for attr in "__doc__", "fget", "fset", "fdel": - try: - setattr(raw, attr, 42) - except AttributeError as msg: - if str(msg).find('readonly') < 0: - raise TestFailed("when setting readonly attr %r on a " - "property, got unexpected AttributeError " - "msg %r" % (attr, str(msg))) - else: - raise TestFailed("expected AttributeError from trying to set " - "readonly %r attr on a property" % attr) - - class D(object): - __getitem__ = property(lambda s: 1/0) - - d = D() - try: - for i in d: - str(i) - except ZeroDivisionError: - pass - else: - raise TestFailed("expected ZeroDivisionError from bad property") - - class E(object): - def getter(self): - "getter method" - return 0 - def setter(self, value): - "setter method" - pass - prop = property(getter) - vereq(prop.__doc__, "getter method") - prop2 = property(fset=setter) - vereq(prop2.__doc__, None) - - # this segfaulted in 2.5b2 - try: - import _testcapi - except ImportError: - pass - else: - class X(object): - p = property(_testcapi.test_with_docstring) - - -def properties_plus(): - class C(object): - foo = property(doc="hello") - @foo.getter - def foo(self): - return self._foo - @foo.setter - def foo(self, value): - self._foo = abs(value) - @foo.deleter - def foo(self): - del self._foo - c = C() - assert C.foo.__doc__ == "hello" - assert not hasattr(c, "foo") - c.foo = -42 - assert hasattr(c, '_foo') - assert c._foo == 42 - assert c.foo == 42 - del c.foo - assert not hasattr(c, '_foo') - assert not hasattr(c, "foo") - - class D(C): - @C.foo.deleter - def foo(self): - try: - del self._foo - except AttributeError: - pass - d = D() - d.foo = 24 - assert d.foo == 24 - del d.foo - del d.foo - - class E(object): - @property - def foo(self): - return self._foo - @foo.setter - def foo(self, value): - raise RuntimeError - @foo.setter - def foo(self, value): - self._foo = abs(value) - @foo.deleter - def foo(self, value=None): - del self._foo - - e = E() - e.foo = -42 - assert e.foo == 42 - del e.foo - - class F(E): - @E.foo.deleter - def foo(self): - del self._foo - @foo.setter - def foo(self, value): - self._foo = max(0, value) - f = F() - f.foo = -10 - assert f.foo == 0 - del f.foo - - -def supers(): - if verbose: print("Testing super...") - - class A(object): - def meth(self, a): - return "A(%r)" % a - - vereq(A().meth(1), "A(1)") - - class B(A): - def __init__(self): - self.__super = super(B, self) - def meth(self, a): - return "B(%r)" % a + self.__super.meth(a) - - vereq(B().meth(2), "B(2)A(2)") - - class C(A): - def meth(self, a): - return "C(%r)" % a + self.__super.meth(a) - C._C__super = super(C) - - vereq(C().meth(3), "C(3)A(3)") - - class D(C, B): - def meth(self, a): - return "D(%r)" % a + super(D, self).meth(a) - - vereq(D().meth(4), "D(4)C(4)B(4)A(4)") - - # Test for subclassing super - - class mysuper(super): - def __init__(self, *args): - return super(mysuper, self).__init__(*args) - - class E(D): - def meth(self, a): - return "E(%r)" % a + mysuper(E, self).meth(a) - - vereq(E().meth(5), "E(5)D(5)C(5)B(5)A(5)") - - class F(E): - def meth(self, a): - s = self.__super # == mysuper(F, self) - return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a) - F._F__super = mysuper(F) - - vereq(F().meth(6), "F(6)[mysuper]E(6)D(6)C(6)B(6)A(6)") - - # Make sure certain errors are raised - - try: - super(D, 42) - except TypeError: - pass - else: - raise TestFailed("shouldn't allow super(D, 42)") - - try: - super(D, C()) - except TypeError: - pass - else: - raise TestFailed("shouldn't allow super(D, C())") - - try: - super(D).__get__(12) - except TypeError: - pass - else: - raise TestFailed("shouldn't allow super(D).__get__(12)") - - try: - super(D).__get__(C()) - except TypeError: - pass - else: - raise TestFailed("shouldn't allow super(D).__get__(C())") - - # Make sure data descriptors can be overridden and accessed via super - # (new feature in Python 2.3) - - class DDbase(object): - def getx(self): return 42 - x = property(getx) - - class DDsub(DDbase): - def getx(self): return "hello" - x = property(getx) - - dd = DDsub() - vereq(dd.x, "hello") - vereq(super(DDsub, dd).x, 42) - - # Ensure that super() lookup of descriptor from classmethod - # works (SF ID# 743627) - - class Base(object): - aProp = property(lambda self: "foo") - - class Sub(Base): - @classmethod - def test(klass): - return super(Sub,klass).aProp - - veris(Sub.test(), Base.aProp) - - # Verify that super() doesn't allow keyword args - try: - super(Base, kw=1) - except TypeError: - pass - else: - raise TestFailed("super shouldn't accept keyword args") - -def inherits(): - if verbose: print("Testing inheritance from basic types...") - - class hexint(int): - def __repr__(self): - return hex(self) - def __add__(self, other): - return hexint(int.__add__(self, other)) - # (Note that overriding __radd__ doesn't work, - # because the int type gets first dibs.) - vereq(repr(hexint(7) + 9), "0x10") - vereq(repr(hexint(1000) + 7), "0x3ef") - a = hexint(12345) - vereq(a, 12345) - vereq(int(a), 12345) - verify(int(a).__class__ is int) - vereq(hash(a), hash(12345)) - verify((+a).__class__ is int) - verify((a >> 0).__class__ is int) - verify((a << 0).__class__ is int) - verify((hexint(0) << 12).__class__ is int) - verify((hexint(0) >> 12).__class__ is int) - - class octlong(int): - __slots__ = [] - def __str__(self): - return oct(self) - def __add__(self, other): - return self.__class__(super(octlong, self).__add__(other)) - __radd__ = __add__ - vereq(str(octlong(3) + 5), "0o10") - # (Note that overriding __radd__ here only seems to work - # because the example uses a short int left argument.) - vereq(str(5 + octlong(3000)), "0o5675") - a = octlong(12345) - vereq(a, 12345) - vereq(int(a), 12345) - vereq(hash(a), hash(12345)) - verify(int(a).__class__ is int) - verify((+a).__class__ is int) - verify((-a).__class__ is int) - verify((-octlong(0)).__class__ is int) - verify((a >> 0).__class__ is int) - verify((a << 0).__class__ is int) - verify((a - 0).__class__ is int) - verify((a * 1).__class__ is int) - verify((a ** 1).__class__ is int) - verify((a // 1).__class__ is int) - verify((1 * a).__class__ is int) - verify((a | 0).__class__ is int) - verify((a ^ 0).__class__ is int) - verify((a & -1).__class__ is int) - verify((octlong(0) << 12).__class__ is int) - verify((octlong(0) >> 12).__class__ is int) - verify(abs(octlong(0)).__class__ is int) - - # Because octlong overrides __add__, we can't check the absence of +0 - # optimizations using octlong. - class longclone(int): - pass - a = longclone(1) - verify((a + 0).__class__ is int) - verify((0 + a).__class__ is int) - - # Check that negative clones don't segfault - a = longclone(-1) - vereq(a.__dict__, {}) - vereq(int(a), -1) # verify PyNumber_Long() copies the sign bit - - class precfloat(float): - __slots__ = ['prec'] - def __init__(self, value=0.0, prec=12): - self.prec = int(prec) - def __repr__(self): - return "%.*g" % (self.prec, self) - vereq(repr(precfloat(1.1)), "1.1") - a = precfloat(12345) - vereq(a, 12345.0) - vereq(float(a), 12345.0) - verify(float(a).__class__ is float) - vereq(hash(a), hash(12345.0)) - verify((+a).__class__ is float) - - class madcomplex(complex): - def __repr__(self): - return "%.17gj%+.17g" % (self.imag, self.real) - a = madcomplex(-3, 4) - vereq(repr(a), "4j-3") - base = complex(-3, 4) - veris(base.__class__, complex) - vereq(a, base) - vereq(complex(a), base) - veris(complex(a).__class__, complex) - a = madcomplex(a) # just trying another form of the constructor - vereq(repr(a), "4j-3") - vereq(a, base) - vereq(complex(a), base) - veris(complex(a).__class__, complex) - vereq(hash(a), hash(base)) - veris((+a).__class__, complex) - veris((a + 0).__class__, complex) - vereq(a + 0, base) - veris((a - 0).__class__, complex) - vereq(a - 0, base) - veris((a * 1).__class__, complex) - vereq(a * 1, base) - veris((a / 1).__class__, complex) - vereq(a / 1, base) - - class madtuple(tuple): - _rev = None - def rev(self): - if self._rev is not None: - return self._rev - L = list(self) - L.reverse() - self._rev = self.__class__(L) - return self._rev - a = madtuple((1,2,3,4,5,6,7,8,9,0)) - vereq(a, (1,2,3,4,5,6,7,8,9,0)) - vereq(a.rev(), madtuple((0,9,8,7,6,5,4,3,2,1))) - vereq(a.rev().rev(), madtuple((1,2,3,4,5,6,7,8,9,0))) - for i in range(512): - t = madtuple(range(i)) - u = t.rev() - v = u.rev() - vereq(v, t) - a = madtuple((1,2,3,4,5)) - vereq(tuple(a), (1,2,3,4,5)) - verify(tuple(a).__class__ is tuple) - vereq(hash(a), hash((1,2,3,4,5))) - verify(a[:].__class__ is tuple) - verify((a * 1).__class__ is tuple) - verify((a * 0).__class__ is tuple) - verify((a + ()).__class__ is tuple) - a = madtuple(()) - vereq(tuple(a), ()) - verify(tuple(a).__class__ is tuple) - verify((a + a).__class__ is tuple) - verify((a * 0).__class__ is tuple) - verify((a * 1).__class__ is tuple) - verify((a * 2).__class__ is tuple) - verify(a[:].__class__ is tuple) - - class madstring(str): - _rev = None - def rev(self): - if self._rev is not None: - return self._rev - L = list(self) - L.reverse() - self._rev = self.__class__("".join(L)) - return self._rev - s = madstring("abcdefghijklmnopqrstuvwxyz") - vereq(s, "abcdefghijklmnopqrstuvwxyz") - vereq(s.rev(), madstring("zyxwvutsrqponmlkjihgfedcba")) - vereq(s.rev().rev(), madstring("abcdefghijklmnopqrstuvwxyz")) - for i in range(256): - s = madstring("".join(map(chr, range(i)))) - t = s.rev() - u = t.rev() - vereq(u, s) - s = madstring("12345") - vereq(str(s), "12345") - verify(str(s).__class__ is str) - - base = "\x00" * 5 - s = madstring(base) - vereq(s, base) - vereq(str(s), base) - verify(str(s).__class__ is str) - vereq(hash(s), hash(base)) - vereq({s: 1}[base], 1) - vereq({base: 1}[s], 1) - verify((s + "").__class__ is str) - vereq(s + "", base) - verify(("" + s).__class__ is str) - vereq("" + s, base) - verify((s * 0).__class__ is str) - vereq(s * 0, "") - verify((s * 1).__class__ is str) - vereq(s * 1, base) - verify((s * 2).__class__ is str) - vereq(s * 2, base + base) - verify(s[:].__class__ is str) - vereq(s[:], base) - verify(s[0:0].__class__ is str) - vereq(s[0:0], "") - verify(s.strip().__class__ is str) - vereq(s.strip(), base) - verify(s.lstrip().__class__ is str) - vereq(s.lstrip(), base) - verify(s.rstrip().__class__ is str) - vereq(s.rstrip(), base) - identitytab = {} - verify(s.translate(identitytab).__class__ is str) - vereq(s.translate(identitytab), base) - verify(s.replace("x", "x").__class__ is str) - vereq(s.replace("x", "x"), base) - verify(s.ljust(len(s)).__class__ is str) - vereq(s.ljust(len(s)), base) - verify(s.rjust(len(s)).__class__ is str) - vereq(s.rjust(len(s)), base) - verify(s.center(len(s)).__class__ is str) - vereq(s.center(len(s)), base) - verify(s.lower().__class__ is str) - vereq(s.lower(), base) - - class madunicode(str): - _rev = None - def rev(self): - if self._rev is not None: - return self._rev - L = list(self) - L.reverse() - self._rev = self.__class__("".join(L)) - return self._rev - u = madunicode("ABCDEF") - vereq(u, "ABCDEF") - vereq(u.rev(), madunicode("FEDCBA")) - vereq(u.rev().rev(), madunicode("ABCDEF")) - base = "12345" - u = madunicode(base) - vereq(str(u), base) - verify(str(u).__class__ is str) - vereq(hash(u), hash(base)) - vereq({u: 1}[base], 1) - vereq({base: 1}[u], 1) - verify(u.strip().__class__ is str) - vereq(u.strip(), base) - verify(u.lstrip().__class__ is str) - vereq(u.lstrip(), base) - verify(u.rstrip().__class__ is str) - vereq(u.rstrip(), base) - verify(u.replace("x", "x").__class__ is str) - vereq(u.replace("x", "x"), base) - verify(u.replace("xy", "xy").__class__ is str) - vereq(u.replace("xy", "xy"), base) - verify(u.center(len(u)).__class__ is str) - vereq(u.center(len(u)), base) - verify(u.ljust(len(u)).__class__ is str) - vereq(u.ljust(len(u)), base) - verify(u.rjust(len(u)).__class__ is str) - vereq(u.rjust(len(u)), base) - verify(u.lower().__class__ is str) - vereq(u.lower(), base) - verify(u.upper().__class__ is str) - vereq(u.upper(), base) - verify(u.capitalize().__class__ is str) - vereq(u.capitalize(), base) - verify(u.title().__class__ is str) - vereq(u.title(), base) - verify((u + "").__class__ is str) - vereq(u + "", base) - verify(("" + u).__class__ is str) - vereq("" + u, base) - verify((u * 0).__class__ is str) - vereq(u * 0, "") - verify((u * 1).__class__ is str) - vereq(u * 1, base) - verify((u * 2).__class__ is str) - vereq(u * 2, base + base) - verify(u[:].__class__ is str) - vereq(u[:], base) - verify(u[0:0].__class__ is str) - vereq(u[0:0], "") - - class sublist(list): - pass - a = sublist(range(5)) - vereq(a, list(range(5))) - a.append("hello") - vereq(a, list(range(5)) + ["hello"]) - a[5] = 5 - vereq(a, list(range(6))) - a.extend(range(6, 20)) - vereq(a, list(range(20))) - a[-5:] = [] - vereq(a, list(range(15))) - del a[10:15] - vereq(len(a), 10) - vereq(a, list(range(10))) - vereq(list(a), list(range(10))) - vereq(a[0], 0) - vereq(a[9], 9) - vereq(a[-10], 0) - vereq(a[-1], 9) - vereq(a[:5], list(range(5))) - -## class CountedInput(file): -## """Counts lines read by self.readline(). - -## self.lineno is the 0-based ordinal of the last line read, up to -## a maximum of one greater than the number of lines in the file. - -## self.ateof is true if and only if the final "" line has been read, -## at which point self.lineno stops incrementing, and further calls -## to readline() continue to return "". -## """ - -## lineno = 0 -## ateof = 0 -## def readline(self): -## if self.ateof: -## return "" -## s = file.readline(self) -## # Next line works too. -## # s = super(CountedInput, self).readline() -## self.lineno += 1 -## if s == "": -## self.ateof = 1 -## return s - -## f = open(name=TESTFN, mode='w') -## lines = ['a\n', 'b\n', 'c\n'] -## try: -## f.writelines(lines) -## f.close() -## f = CountedInput(TESTFN) -## for (i, expected) in zip(list(range(1, 5)) + [4], lines + 2 * [""]): -## got = f.readline() -## vereq(expected, got) -## vereq(f.lineno, i) -## vereq(f.ateof, (i > len(lines))) -## f.close() -## finally: -## try: -## f.close() -## except: -## pass -## try: -## import os -## os.unlink(TESTFN) -## except: -## pass - -def keywords(): - if verbose: - print("Testing keyword args to basic type constructors ...") - vereq(int(x=1), 1) - vereq(float(x=2), 2.0) - vereq(int(x=3), 3) - vereq(complex(imag=42, real=666), complex(666, 42)) - vereq(str(object=500), '500') - vereq(str(object=b'abc', errors='strict'), 'abc') - vereq(tuple(sequence=range(3)), (0, 1, 2)) - vereq(list(sequence=(0, 1, 2)), list(range(3))) - # note: as of Python 2.3, dict() no longer has an "items" keyword arg - - for constructor in (int, float, int, complex, str, str, tuple, list): - try: - constructor(bogus_keyword_arg=1) - except TypeError: - pass - else: - raise TestFailed("expected TypeError from bogus keyword " - "argument to %r" % constructor) - -def str_subclass_as_dict_key(): - if verbose: - print("Testing a str subclass used as dict key ..") - - class cistr(str): - """Sublcass of str that computes __eq__ case-insensitively. - - Also computes a hash code of the string in canonical form. - """ - - def __init__(self, value): - self.canonical = value.lower() - self.hashcode = hash(self.canonical) - - def __eq__(self, other): - if not isinstance(other, cistr): - other = cistr(other) - return self.canonical == other.canonical - - def __hash__(self): - return self.hashcode - - vereq(cistr('ABC'), 'abc') - vereq('aBc', cistr('ABC')) - vereq(str(cistr('ABC')), 'ABC') - - d = {cistr('one'): 1, cistr('two'): 2, cistr('tHree'): 3} - vereq(d[cistr('one')], 1) - vereq(d[cistr('tWo')], 2) - vereq(d[cistr('THrEE')], 3) - verify(cistr('ONe') in d) - vereq(d.get(cistr('thrEE')), 3) - -def classic_comparisons(): - if verbose: print("Testing classic comparisons...") - class classic: - pass - for base in (classic, int, object): - if verbose: print(" (base = %s)" % base) - class C(base): - def __init__(self, value): - self.value = int(value) - def __eq__(self, other): - if isinstance(other, C): - return self.value == other.value - if isinstance(other, int) or isinstance(other, int): - return self.value == other - return NotImplemented - def __ne__(self, other): - if isinstance(other, C): - return self.value != other.value - if isinstance(other, int) or isinstance(other, int): - return self.value != other - return NotImplemented - def __lt__(self, other): - if isinstance(other, C): - return self.value < other.value - if isinstance(other, int) or isinstance(other, int): - return self.value < other - return NotImplemented - def __le__(self, other): - if isinstance(other, C): - return self.value <= other.value - if isinstance(other, int) or isinstance(other, int): - return self.value <= other - return NotImplemented - def __gt__(self, other): - if isinstance(other, C): - return self.value > other.value - if isinstance(other, int) or isinstance(other, int): - return self.value > other - return NotImplemented - def __ge__(self, other): - if isinstance(other, C): - return self.value >= other.value - if isinstance(other, int) or isinstance(other, int): - return self.value >= other - return NotImplemented + try: + D.__bases__ = () + except TypeError as msg: + if str(msg) == "a new-style class can't have only classic bases": + self.fail("wrong error message for .__bases__ = ()") + else: + self.fail("shouldn't be able to set .__bases__ to ()") - c1 = C(1) - c2 = C(2) - c3 = C(3) - vereq(c1, 1) - c = {1: c1, 2: c2, 3: c3} - for x in 1, 2, 3: - for y in 1, 2, 3: - ##verify(cmp(c[x], c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) - for op in "<", "<=", "==", "!=", ">", ">=": - verify(eval("c[x] %s c[y]" % op) == eval("x %s y" % op), - "x=%d, y=%d" % (x, y)) - ##verify(cmp(c[x], y) == cmp(x, y), "x=%d, y=%d" % (x, y)) - ##verify(cmp(x, c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) - -def rich_comparisons(): - if verbose: - print("Testing rich comparisons...") - class Z(complex): - pass - z = Z(1) - vereq(z, 1+0j) - vereq(1+0j, z) - class ZZ(complex): - def __eq__(self, other): - try: - return abs(self - other) <= 1e-6 - except: - return NotImplemented - zz = ZZ(1.0000003) - vereq(zz, 1+0j) - vereq(1+0j, zz) - - class classic: - pass - for base in (classic, int, object, list): - if verbose: print(" (base = %s)" % base) - class C(base): - def __init__(self, value): - self.value = int(value) - def __cmp__(self, other): - raise TestFailed("shouldn't call __cmp__") - def __eq__(self, other): - if isinstance(other, C): - return self.value == other.value - if isinstance(other, int) or isinstance(other, int): - return self.value == other - return NotImplemented - def __ne__(self, other): - if isinstance(other, C): - return self.value != other.value - if isinstance(other, int) or isinstance(other, int): - return self.value != other - return NotImplemented - def __lt__(self, other): - if isinstance(other, C): - return self.value < other.value - if isinstance(other, int) or isinstance(other, int): - return self.value < other - return NotImplemented - def __le__(self, other): - if isinstance(other, C): - return self.value <= other.value - if isinstance(other, int) or isinstance(other, int): - return self.value <= other - return NotImplemented - def __gt__(self, other): - if isinstance(other, C): - return self.value > other.value - if isinstance(other, int) or isinstance(other, int): - return self.value > other - return NotImplemented - def __ge__(self, other): - if isinstance(other, C): - return self.value >= other.value - if isinstance(other, int) or isinstance(other, int): - return self.value >= other - return NotImplemented - c1 = C(1) - c2 = C(2) - c3 = C(3) - vereq(c1, 1) - c = {1: c1, 2: c2, 3: c3} - for x in 1, 2, 3: - for y in 1, 2, 3: - for op in "<", "<=", "==", "!=", ">", ">=": - verify(eval("c[x] %s c[y]" % op) == eval("x %s y" % op), - "x=%d, y=%d" % (x, y)) - verify(eval("c[x] %s y" % op) == eval("x %s y" % op), - "x=%d, y=%d" % (x, y)) - verify(eval("x %s c[y]" % op) == eval("x %s y" % op), - "x=%d, y=%d" % (x, y)) - -def descrdoc(): - if verbose: print("Testing descriptor doc strings...") - from _fileio import _FileIO - def check(descr, what): - vereq(descr.__doc__, what) - check(_FileIO.closed, "True if the file is closed") # getset descriptor - check(complex.real, "the real part of a complex number") # member descriptor - -def setclass(): - if verbose: print("Testing __class__ assignment...") - class C(object): pass - class D(object): pass - class E(object): pass - class F(D, E): pass - for cls in C, D, E, F: - for cls2 in C, D, E, F: - x = cls() - x.__class__ = cls2 - verify(x.__class__ is cls2) - x.__class__ = cls - verify(x.__class__ is cls) - def cant(x, C): try: - x.__class__ = C + D.__bases__ = (D,) except TypeError: pass else: - raise TestFailed("shouldn't allow %r.__class__ = %r" % (x, C)) + # actually, we'll have crashed by here... + self.fail("shouldn't be able to create inheritance cycles") + try: - delattr(x, "__class__") + D.__bases__ = (C, C) except TypeError: pass else: - raise TestFailed("shouldn't allow del %r.__class__" % x) - cant(C(), list) - cant(list(), C) - cant(C(), 1) - cant(C(), object) - cant(object(), list) - cant(list(), object) - class Int(int): __slots__ = [] - cant(2, Int) - cant(Int(), int) - cant(True, int) - cant(2, bool) - o = object() - cant(o, type(1)) - cant(o, type(None)) - del o - class G(object): - __slots__ = ["a", "b"] - class H(object): - __slots__ = ["b", "a"] - class I(object): - __slots__ = ["a", "b"] - class J(object): - __slots__ = ["c", "b"] - class K(object): - __slots__ = ["a", "b", "d"] - class L(H): - __slots__ = ["e"] - class M(I): - __slots__ = ["e"] - class N(J): - __slots__ = ["__weakref__"] - class P(J): - __slots__ = ["__dict__"] - class Q(J): - pass - class R(J): - __slots__ = ["__dict__", "__weakref__"] + self.fail("didn't detect repeated base classes") - for cls, cls2 in ((G, H), (G, I), (I, H), (Q, R), (R, Q)): - x = cls() - x.a = 1 - x.__class__ = cls2 - verify(x.__class__ is cls2, - "assigning %r as __class__ for %r silently failed" % (cls2, x)) - vereq(x.a, 1) - x.__class__ = cls - verify(x.__class__ is cls, - "assigning %r as __class__ for %r silently failed" % (cls, x)) - vereq(x.a, 1) - for cls in G, J, K, L, M, N, P, R, list, Int: - for cls2 in G, J, K, L, M, N, P, R, list, Int: - if cls is cls2: - continue - cant(cls(), cls2) - -def setdict(): - if verbose: print("Testing __dict__ assignment...") - class C(object): pass - a = C() - a.__dict__ = {'b': 1} - vereq(a.b, 1) - def cant(x, dict): try: - x.__dict__ = dict - except (AttributeError, TypeError): + D.__bases__ = (E,) + except TypeError: pass else: - raise TestFailed("shouldn't allow %r.__dict__ = %r" % (x, dict)) - cant(a, None) - cant(a, []) - cant(a, 1) - del a.__dict__ # Deleting __dict__ is allowed - - class Base(object): - pass - def verify_dict_readonly(x): - """ - x has to be an instance of a class inheriting from Base. - """ - cant(x, {}) - try: - del x.__dict__ - except (AttributeError, TypeError): + self.fail("shouldn't be able to create inheritance cycles") + + def test_mutable_bases_with_failing_mro(self): + # Testing mutable bases with failing mro... + class WorkOnce(type): + def __new__(self, name, bases, ns): + self.flag = 0 + return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns) + def mro(self): + if self.flag > 0: + raise RuntimeError("bozo") + else: + self.flag += 1 + return type.mro(self) + + class WorkAlways(type): + def mro(self): + # this is here to make sure that .mro()s aren't called + # with an exception set (which was possible at one point). + # An error message will be printed in a debug build. + # What's a good way to test for this? + return type.mro(self) + + class C(object): + pass + + class C2(object): + pass + + class D(C): + pass + + class E(D): + pass + + class F(D, metaclass=WorkOnce): + pass + + class G(D, metaclass=WorkAlways): pass + + # Immediate subclasses have their mro's adjusted in alphabetical + # order, so E's will get adjusted before adjusting F's fails. We + # check here that E's gets restored. + + E_mro_before = E.__mro__ + D_mro_before = D.__mro__ + + try: + D.__bases__ = (C2,) + except RuntimeError: + self.assertEqual(E.__mro__, E_mro_before) + self.assertEqual(D.__mro__, D_mro_before) else: - raise TestFailed("shouldn't allow del %r.__dict__" % x) - dict_descr = Base.__dict__["__dict__"] + self.fail("exception not propagated") + + def test_mutable_bases_catch_mro_conflict(self): + # Testing mutable bases catch mro conflict... + class A(object): + pass + + class B(object): + pass + + class C(A, B): + pass + + class D(A, B): + pass + + class E(C, D): + pass + try: - dict_descr.__set__(x, {}) - except (AttributeError, TypeError): + C.__bases__ = (B, A) + except TypeError: pass else: - raise TestFailed("dict_descr allowed access to %r's dict" % x) + self.fail("didn't catch MRO conflict") + + def test_mutable_names(self): + # Testing mutable names... + class C(object): + pass - # Classes don't allow __dict__ assignment and have readonly dicts - class Meta1(type, Base): - pass - class Meta2(Base, type): - pass - class D(object): - __metaclass__ = Meta1 - class E(object): - __metaclass__ = Meta2 - for cls in C, D, E: - verify_dict_readonly(cls) - class_dict = cls.__dict__ - try: - class_dict["spam"] = "eggs" - except TypeError: - pass - else: - raise TestFailed("%r's __dict__ can be modified" % cls) - - # Modules also disallow __dict__ assignment - class Module1(types.ModuleType, Base): - pass - class Module2(Base, types.ModuleType): - pass - for ModuleType in Module1, Module2: - mod = ModuleType("spam") - verify_dict_readonly(mod) - mod.__dict__["spam"] = "eggs" - - # Exception's __dict__ can be replaced, but not deleted - class Exception1(Exception, Base): - pass - class Exception2(Base, Exception): - pass - for ExceptionType in Exception, Exception1, Exception2: - e = ExceptionType() - e.__dict__ = {"a": 1} - vereq(e.a, 1) - try: - del e.__dict__ - except (TypeError, AttributeError): - pass - else: - raise TestFaied("%r's __dict__ can be deleted" % e) - - -def pickles(): - if verbose: - print("Testing pickling and copying new-style classes and objects...") - import pickle - - def sorteditems(d): - return sorted(d.items()) - - global C - class C(object): - def __init__(self, a, b): - super(C, self).__init__() - self.a = a - self.b = b - def __repr__(self): - return "C(%r, %r)" % (self.a, self.b) - - global C1 - class C1(list): - def __new__(cls, a, b): - return super(C1, cls).__new__(cls) - def __getnewargs__(self): - return (self.a, self.b) - def __init__(self, a, b): - self.a = a - self.b = b - def __repr__(self): - return "C1(%r, %r)<%r>" % (self.a, self.b, list(self)) - - global C2 - class C2(int): - def __new__(cls, a, b, val=0): - return super(C2, cls).__new__(cls, val) - def __getnewargs__(self): - return (self.a, self.b, int(self)) - def __init__(self, a, b, val=0): - self.a = a - self.b = b - def __repr__(self): - return "C2(%r, %r)<%r>" % (self.a, self.b, int(self)) - - global C3 - class C3(object): - def __init__(self, foo): - self.foo = foo - def __getstate__(self): - return self.foo - def __setstate__(self, foo): - self.foo = foo - - global C4classic, C4 - class C4classic: # classic - pass - class C4(C4classic, object): # mixed inheritance - pass + # C.__module__ could be 'test_descr' or '__main__' + mod = C.__module__ - for p in [pickle]: - for bin in 0, 1: - if verbose: - print(p.__name__, ["text", "binary"][bin]) + C.__name__ = 'D' + self.assertEqual((C.__module__, C.__name__), (mod, 'D')) - for cls in C, C1, C2: - s = p.dumps(cls, bin) - cls2 = p.loads(s) - verify(cls2 is cls) + C.__name__ = 'D.E' + self.assertEqual((C.__module__, C.__name__), (mod, 'D.E')) + + def test_subclass_right_op(self): + # Testing correct dispatch of subclass overloading __r__... + + # This code tests various cases where right-dispatch of a subclass + # should be preferred over left-dispatch of a base class. + + # Case 1: subclass of int; this tests code in abstract.c::binary_op1() + + class B(int): + def __floordiv__(self, other): + return "B.__floordiv__" + def __rfloordiv__(self, other): + return "B.__rfloordiv__" + + self.assertEqual(B(1) // 1, "B.__floordiv__") + self.assertEqual(1 // B(1), "B.__rfloordiv__") + + # Case 2: subclass of object; this is just the baseline for case 3 + + class C(object): + def __floordiv__(self, other): + return "C.__floordiv__" + def __rfloordiv__(self, other): + return "C.__rfloordiv__" + + self.assertEqual(C() // 1, "C.__floordiv__") + self.assertEqual(1 // C(), "C.__rfloordiv__") + + # Case 3: subclass of new-style class; here it gets interesting - a = C1(1, 2); a.append(42); a.append(24) - b = C2("hello", "world", 42) - s = p.dumps((a, b), bin) - x, y = p.loads(s) - vereq(x.__class__, a.__class__) - vereq(sorteditems(x.__dict__), sorteditems(a.__dict__)) - vereq(y.__class__, b.__class__) - vereq(sorteditems(y.__dict__), sorteditems(b.__dict__)) - vereq(repr(x), repr(a)) - vereq(repr(y), repr(b)) - if verbose: - print("a = x =", a) - print("b = y =", b) - # Test for __getstate__ and __setstate__ on new style class - u = C3(42) - s = p.dumps(u, bin) - v = p.loads(s) - veris(u.__class__, v.__class__) - vereq(u.foo, v.foo) - # Test for picklability of hybrid class - u = C4() - u.foo = 42 - s = p.dumps(u, bin) - v = p.loads(s) - veris(u.__class__, v.__class__) - vereq(u.foo, v.foo) - - # Testing copy.deepcopy() - if verbose: - print("deepcopy") - import copy - for cls in C, C1, C2: - cls2 = copy.deepcopy(cls) - verify(cls2 is cls) - - a = C1(1, 2); a.append(42); a.append(24) - b = C2("hello", "world", 42) - x, y = copy.deepcopy((a, b)) - vereq(x.__class__, a.__class__) - vereq(sorteditems(x.__dict__), sorteditems(a.__dict__)) - vereq(y.__class__, b.__class__) - vereq(sorteditems(y.__dict__), sorteditems(b.__dict__)) - vereq(repr(x), repr(a)) - vereq(repr(y), repr(b)) - if verbose: - print("a = x =", a) - print("b = y =", b) - -def pickleslots(): - if verbose: print("Testing pickling of classes with __slots__ ...") - import pickle - # Pickling of classes with __slots__ but without __getstate__ should fail - # (when using protocols 0 or 1) - global B, C, D, E - class B(object): - pass - for base in [object, B]: - class C(base): - __slots__ = ['a'] class D(C): + def __floordiv__(self, other): + return "D.__floordiv__" + def __rfloordiv__(self, other): + return "D.__rfloordiv__" + + self.assertEqual(D() // C(), "D.__floordiv__") + self.assertEqual(C() // D(), "D.__rfloordiv__") + + # Case 4: this didn't work right in 2.2.2 and 2.3a1 + + class E(C): pass + + self.assertEqual(E.__rfloordiv__, C.__rfloordiv__) + + self.assertEqual(E() // 1, "C.__floordiv__") + self.assertEqual(1 // E(), "C.__rfloordiv__") + self.assertEqual(E() // C(), "C.__floordiv__") + self.assertEqual(C() // E(), "C.__floordiv__") # This one would fail + + def test_meth_class_get(self): + # Testing __get__ method of METH_CLASS C methods... + # Full coverage of descrobject.c::classmethod_get() + + # Baseline + arg = [1, 2, 3] + res = {1: None, 2: None, 3: None} + self.assertEqual(dict.fromkeys(arg), res) + self.assertEqual({}.fromkeys(arg), res) + + # Now get the descriptor + descr = dict.__dict__["fromkeys"] + + # More baseline using the descriptor directly + self.assertEqual(descr.__get__(None, dict)(arg), res) + self.assertEqual(descr.__get__({})(arg), res) + + # Now check various error cases try: - pickle.dumps(C(), 0) + descr.__get__(None, None) except TypeError: pass else: - raise TestFailed("should fail: pickle C instance - %s" % base) + self.fail("shouldn't have allowed descr.__get__(None, None)") try: - pickle.dumps(C(), 0) + descr.__get__(42) except TypeError: pass else: - raise TestFailed("should fail: pickle D instance - %s" % base) - # Give C a nice generic __getstate__ and __setstate__ - class C(base): - __slots__ = ['a'] - def __getstate__(self): - try: - d = self.__dict__.copy() - except AttributeError: - d = {} - for cls in self.__class__.__mro__: - for sn in cls.__dict__.get('__slots__', ()): - try: - d[sn] = getattr(self, sn) - except AttributeError: - pass - return d - def __setstate__(self, d): - for k, v in d.items(): - setattr(self, k, v) + self.fail("shouldn't have allowed descr.__get__(42)") + try: + descr.__get__(None, 42) + except TypeError: + pass + else: + self.fail("shouldn't have allowed descr.__get__(None, 42)") + try: + descr.__get__(None, int) + except TypeError: + pass + else: + self.fail("shouldn't have allowed descr.__get__(None, int)") + + def test_isinst_isclass(self): + # Testing proxy isinstance() and isclass()... + class Proxy(object): + def __init__(self, obj): + self.__obj = obj + def __getattribute__(self, name): + if name.startswith("_Proxy__"): + return object.__getattribute__(self, name) + else: + return getattr(self.__obj, name) + # Test with a classic class + class C: + pass + a = C() + pa = Proxy(a) + self.assert_(isinstance(a, C)) # Baseline + self.assert_(isinstance(pa, C)) # Test + # Test with a classic subclass class D(C): pass - # Now it should work - x = C() - y = pickle.loads(pickle.dumps(x)) - vereq(hasattr(y, 'a'), 0) - x.a = 42 - y = pickle.loads(pickle.dumps(x)) - vereq(y.a, 42) - x = D() - x.a = 42 - x.b = 100 - y = pickle.loads(pickle.dumps(x)) - vereq(y.a + y.b, 142) - # A subclass that adds a slot should also work - class E(C): - __slots__ = ['b'] - x = E() - x.a = 42 - x.b = "foo" - y = pickle.loads(pickle.dumps(x)) - vereq(y.a, x.a) - vereq(y.b, x.b) - -def copies(): - if verbose: print("Testing copy.copy() and copy.deepcopy()...") - import copy - class C(object): - pass - - a = C() - a.foo = 12 - b = copy.copy(a) - vereq(b.__dict__, a.__dict__) - - a.bar = [1,2,3] - c = copy.copy(a) - vereq(c.bar, a.bar) - verify(c.bar is a.bar) - - d = copy.deepcopy(a) - vereq(d.__dict__, a.__dict__) - a.bar.append(4) - vereq(d.bar, [1,2,3]) - -def binopoverride(): - if verbose: print("Testing overrides of binary operations...") - class I(int): - def __repr__(self): - return "I(%r)" % int(self) - def __add__(self, other): - return I(int(self) + int(other)) - __radd__ = __add__ - def __pow__(self, other, mod=None): - if mod is None: - return I(pow(int(self), int(other))) - else: - return I(pow(int(self), int(other), int(mod))) - def __rpow__(self, other, mod=None): - if mod is None: - return I(pow(int(other), int(self), mod)) - else: - return I(pow(int(other), int(self), int(mod))) + a = D() + pa = Proxy(a) + self.assert_(isinstance(a, C)) # Baseline + self.assert_(isinstance(pa, C)) # Test + # Test with a new-style class + class C(object): + pass + a = C() + pa = Proxy(a) + self.assert_(isinstance(a, C)) # Baseline + self.assert_(isinstance(pa, C)) # Test + # Test with a new-style subclass + class D(C): + pass + a = D() + pa = Proxy(a) + self.assert_(isinstance(a, C)) # Baseline + self.assert_(isinstance(pa, C)) # Test + + def test_proxy_super(self): + # Testing super() for a proxy object... + class Proxy(object): + def __init__(self, obj): + self.__obj = obj + def __getattribute__(self, name): + if name.startswith("_Proxy__"): + return object.__getattribute__(self, name) + else: + return getattr(self.__obj, name) + + class B(object): + def f(self): + return "B.f" + + class C(B): + def f(self): + return super(C, self).f() + "->C.f" + + obj = C() + p = Proxy(obj) + self.assertEqual(C.__dict__["f"](p), "B.f->C.f") - vereq(repr(I(1) + I(2)), "I(3)") - vereq(repr(I(1) + 2), "I(3)") - vereq(repr(1 + I(2)), "I(3)") - vereq(repr(I(2) ** I(3)), "I(8)") - vereq(repr(2 ** I(3)), "I(8)") - vereq(repr(I(2) ** 3), "I(8)") - vereq(repr(pow(I(2), I(3), I(5))), "I(3)") - class S(str): - def __eq__(self, other): - return self.lower() == other.lower() - -def subclasspropagation(): - if verbose: print("Testing propagation of slot functions to subclasses...") - class A(object): - pass - class B(A): - pass - class C(A): - pass - class D(B, C): - pass - d = D() - orig_hash = hash(d) # related to id(d) in platform-dependent ways - A.__hash__ = lambda self: 42 - vereq(hash(d), 42) - C.__hash__ = lambda self: 314 - vereq(hash(d), 314) - B.__hash__ = lambda self: 144 - vereq(hash(d), 144) - D.__hash__ = lambda self: 100 - vereq(hash(d), 100) - del D.__hash__ - vereq(hash(d), 144) - del B.__hash__ - vereq(hash(d), 314) - del C.__hash__ - vereq(hash(d), 42) - del A.__hash__ - vereq(hash(d), orig_hash) - d.foo = 42 - d.bar = 42 - vereq(d.foo, 42) - vereq(d.bar, 42) - def __getattribute__(self, name): - if name == "foo": - return 24 - return object.__getattribute__(self, name) - A.__getattribute__ = __getattribute__ - vereq(d.foo, 24) - vereq(d.bar, 42) - def __getattr__(self, name): - if name in ("spam", "foo", "bar"): - return "hello" - raise AttributeError(name) - B.__getattr__ = __getattr__ - vereq(d.spam, "hello") - vereq(d.foo, 24) - vereq(d.bar, 42) - del A.__getattribute__ - vereq(d.foo, 42) - del d.foo - vereq(d.foo, "hello") - vereq(d.bar, 42) - del B.__getattr__ - try: - d.foo - except AttributeError: - pass - else: - raise TestFailed("d.foo should be undefined now") - - # Test a nasty bug in recurse_down_subclasses() - import gc - class A(object): - pass - class B(A): - pass - del B - gc.collect() - A.__setitem__ = lambda *a: None # crash - -def buffer_inherit(): - import binascii - # SF bug [#470040] ParseTuple t# vs subclasses. - if verbose: - print("Testing that buffer interface is inherited ...") - - class MyStr(str): - pass - base = 'abc' - m = MyStr(base) - # b2a_hex uses the buffer interface to get its argument's value, via - # PyArg_ParseTuple 't#' code. - vereq(binascii.b2a_hex(m), binascii.b2a_hex(base)) - - # It's not clear that unicode will continue to support the character - # buffer interface, and this test will fail if that's taken away. - class MyUni(str): - pass - base = 'abc' - m = MyUni(base) - vereq(binascii.b2a_hex(m), binascii.b2a_hex(base)) - - class MyInt(int): - pass - m = MyInt(42) - try: - binascii.b2a_hex(m) - raise TestFailed('subclass of int should not have a buffer interface') - except TypeError: - pass - -def str_of_str_subclass(): - import binascii - import io - - if verbose: - print("Testing __str__ defined in subclass of str ...") - - class octetstring(str): - def __str__(self): - return binascii.b2a_hex(self).decode("ascii") - def __repr__(self): - return self + " repr" - - o = octetstring('A') - vereq(type(o), octetstring) - vereq(type(str(o)), str) - vereq(type(repr(o)), str) - vereq(ord(o), 0x41) - vereq(str(o), '41') - vereq(repr(o), 'A repr') - vereq(o.__str__(), '41') - vereq(o.__repr__(), 'A repr') - - capture = io.StringIO() - # Calling str() or not exercises different internal paths. - print(o, file=capture) - print(str(o), file=capture) - vereq(capture.getvalue(), '41\n41\n') - capture.close() - -def kwdargs(): - if verbose: print("Testing keyword arguments to __init__, __call__...") - def f(a): return a - vereq(f.__call__(a=42), 42) - a = [] - list.__init__(a, sequence=[0, 1, 2]) - vereq(a, [0, 1, 2]) - -def recursive__call__(): - if verbose: print(("Testing recursive __call__() by setting to instance of " - "class ...")) - class A(object): - pass - - A.__call__ = A() - try: - A()() - except RuntimeError: - pass - else: - raise TestFailed("Recursion limit should have been reached for " - "__call__()") - -def delhook(): - if verbose: print("Testing __del__ hook...") - log = [] - class C(object): - def __del__(self): - log.append(1) - c = C() - vereq(log, []) - del c - vereq(log, [1]) - - class D(object): pass - d = D() - try: del d[0] - except TypeError: pass - else: raise TestFailed("invalid del() didn't raise TypeError") - -def hashinherit(): - if verbose: print("Testing hash of mutable subclasses...") - - class mydict(dict): - pass - d = mydict() - try: - hash(d) - except TypeError: - pass - else: - raise TestFailed("hash() of dict subclass should fail") - - class mylist(list): - pass - d = mylist() - try: - hash(d) - except TypeError: - pass - else: - raise TestFailed("hash() of list subclass should fail") - -def strops(): - try: 'a' + 5 - except TypeError: pass - else: raise TestFailed("'' + 5 doesn't raise TypeError") - - try: ''.split('') - except ValueError: pass - else: raise TestFailed("''.split('') doesn't raise ValueError") - - try: ''.rindex('5') - except ValueError: pass - else: raise TestFailed("''.rindex('5') doesn't raise ValueError") - - try: '%(n)s' % None - except TypeError: pass - else: raise TestFailed("'%(n)s' % None doesn't raise TypeError") - - try: '%(n' % {} - except ValueError: pass - else: raise TestFailed("'%(n' % {} '' doesn't raise ValueError") - - try: '%*s' % ('abc') - except TypeError: pass - else: raise TestFailed("'%*s' % ('abc') doesn't raise TypeError") - - try: '%*.*s' % ('abc', 5) - except TypeError: pass - else: raise TestFailed("'%*.*s' % ('abc', 5) doesn't raise TypeError") - - try: '%s' % (1, 2) - except TypeError: pass - else: raise TestFailed("'%s' % (1, 2) doesn't raise TypeError") - - try: '%' % None - except ValueError: pass - else: raise TestFailed("'%' % None doesn't raise ValueError") - - vereq('534253'.isdigit(), 1) - vereq('534253x'.isdigit(), 0) - vereq('%c' % 5, '\x05') - vereq('%c' % '5', '5') - -def deepcopyrecursive(): - if verbose: print("Testing deepcopy of recursive objects...") - class Node: - pass - a = Node() - b = Node() - a.b = b - b.a = a - z = deepcopy(a) # This blew up before - -def modules(): - if verbose: print("Testing uninitialized module objects...") - from types import ModuleType as M - m = M.__new__(M) - str(m) - vereq(hasattr(m, "__name__"), 0) - vereq(hasattr(m, "__file__"), 0) - vereq(hasattr(m, "foo"), 0) - vereq(m.__dict__, None) - m.foo = 1 - vereq(m.__dict__, {"foo": 1}) - -def dictproxyiterkeys(): - class C(object): - def meth(self): - pass - if verbose: print("Testing dict-proxy iterkeys...") - keys = [ key for key in C.__dict__.keys() ] - keys.sort() - vereq(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth']) - -def dictproxyitervalues(): - class C(object): - def meth(self): - pass - if verbose: print("Testing dict-proxy itervalues...") - values = [ values for values in C.__dict__.values() ] - vereq(len(values), 5) - -def dictproxyiteritems(): - class C(object): - def meth(self): - pass - if verbose: print("Testing dict-proxy iteritems...") - keys = [ key for (key, value) in C.__dict__.items() ] - keys.sort() - vereq(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth']) - -def funnynew(): - if verbose: print("Testing __new__ returning something unexpected...") - class C(object): - def __new__(cls, arg): - if isinstance(arg, str): return [1, 2, 3] - elif isinstance(arg, int): return object.__new__(D) - else: return object.__new__(cls) - class D(C): - def __init__(self, arg): - self.foo = arg - vereq(C("1"), [1, 2, 3]) - vereq(D("1"), [1, 2, 3]) - d = D(None) - veris(d.foo, None) - d = C(1) - vereq(isinstance(d, D), True) - vereq(d.foo, 1) - d = D(1) - vereq(isinstance(d, D), True) - vereq(d.foo, 1) - -def imulbug(): - # SF bug 544647 - if verbose: print("Testing for __imul__ problems...") - class C(object): - def __imul__(self, other): - return (self, other) - x = C() - y = x - y *= 1.0 - vereq(y, (x, 1.0)) - y = x - y *= 2 - vereq(y, (x, 2)) - y = x - y *= 3 - vereq(y, (x, 3)) - y = x - y *= 1<<100 - vereq(y, (x, 1<<100)) - y = x - y *= None - vereq(y, (x, None)) - y = x - y *= "foo" - vereq(y, (x, "foo")) - -def docdescriptor(): - # SF bug 542984 - if verbose: print("Testing __doc__ descriptor...") - class DocDescr(object): - def __get__(self, object, otype): - if object: - object = object.__class__.__name__ + ' instance' - if otype: - otype = otype.__name__ - return 'object=%s; type=%s' % (object, otype) - class OldClass: - __doc__ = DocDescr() - class NewClass(object): - __doc__ = DocDescr() - vereq(OldClass.__doc__, 'object=None; type=OldClass') - vereq(OldClass().__doc__, 'object=OldClass instance; type=OldClass') - vereq(NewClass.__doc__, 'object=None; type=NewClass') - vereq(NewClass().__doc__, 'object=NewClass instance; type=NewClass') - -def copy_setstate(): - if verbose: - print("Testing that copy.*copy() correctly uses __setstate__...") - import copy - class C(object): - def __init__(self, foo=None): - self.foo = foo - self.__foo = foo - def setfoo(self, foo=None): - self.foo = foo - def getfoo(self): - return self.__foo - def __getstate__(self): - return [self.foo] - def __setstate__(self, lst): - assert len(lst) == 1 - self.__foo = self.foo = lst[0] - a = C(42) - a.setfoo(24) - vereq(a.foo, 24) - vereq(a.getfoo(), 42) - b = copy.copy(a) - vereq(b.foo, 24) - vereq(b.getfoo(), 24) - b = copy.deepcopy(a) - vereq(b.foo, 24) - vereq(b.getfoo(), 24) - -def slices(): - if verbose: - print("Testing cases with slices and overridden __getitem__ ...") - # Strings - vereq("hello"[:4], "hell") - vereq("hello"[slice(4)], "hell") - vereq(str.__getitem__("hello", slice(4)), "hell") - class S(str): - def __getitem__(self, x): - return str.__getitem__(self, x) - vereq(S("hello")[:4], "hell") - vereq(S("hello")[slice(4)], "hell") - vereq(S("hello").__getitem__(slice(4)), "hell") - # Tuples - vereq((1,2,3)[:2], (1,2)) - vereq((1,2,3)[slice(2)], (1,2)) - vereq(tuple.__getitem__((1,2,3), slice(2)), (1,2)) - class T(tuple): - def __getitem__(self, x): - return tuple.__getitem__(self, x) - vereq(T((1,2,3))[:2], (1,2)) - vereq(T((1,2,3))[slice(2)], (1,2)) - vereq(T((1,2,3)).__getitem__(slice(2)), (1,2)) - # Lists - vereq([1,2,3][:2], [1,2]) - vereq([1,2,3][slice(2)], [1,2]) - vereq(list.__getitem__([1,2,3], slice(2)), [1,2]) - class L(list): - def __getitem__(self, x): - return list.__getitem__(self, x) - vereq(L([1,2,3])[:2], [1,2]) - vereq(L([1,2,3])[slice(2)], [1,2]) - vereq(L([1,2,3]).__getitem__(slice(2)), [1,2]) - # Now do lists and __setitem__ - a = L([1,2,3]) - a[slice(1, 3)] = [3,2] - vereq(a, [1,3,2]) - a[slice(0, 2, 1)] = [3,1] - vereq(a, [3,1,2]) - a.__setitem__(slice(1, 3), [2,1]) - vereq(a, [3,2,1]) - a.__setitem__(slice(0, 2, 1), [2,3]) - vereq(a, [2,3,1]) - -def subtype_resurrection(): - if verbose: - print("Testing resurrection of new-style instance...") - - class C(object): - container = [] - - def __del__(self): - # resurrect the instance - C.container.append(self) - - c = C() - c.attr = 42 - # The most interesting thing here is whether this blows up, due to flawed - # GC tracking logic in typeobject.c's call_finalizer() (a 2.2.1 bug). - del c - - # If that didn't blow up, it's also interesting to see whether clearing - # the last container slot works: that will attempt to delete c again, - # which will cause c to get appended back to the container again "during" - # the del. - del C.container[-1] - vereq(len(C.container), 1) - vereq(C.container[-1].attr, 42) - - # Make c mortal again, so that the test framework with -l doesn't report - # it as a leak. - del C.__del__ - -def slottrash(): - # Deallocating deeply nested slotted trash caused stack overflows - if verbose: - print("Testing slot trash...") - class trash(object): - __slots__ = ['x'] - def __init__(self, x): - self.x = x - o = None - for i in range(50000): - o = trash(o) - del o - -def slotmultipleinheritance(): - # SF bug 575229, multiple inheritance w/ slots dumps core - class A(object): - __slots__=() - class B(object): - pass - class C(A,B) : - __slots__=() - vereq(C.__basicsize__, B.__basicsize__) - verify(hasattr(C, '__dict__')) - verify(hasattr(C, '__weakref__')) - C().x = 2 - -def testrmul(): - # SF patch 592646 - if verbose: - print("Testing correct invocation of __rmul__...") - class C(object): - def __mul__(self, other): - return "mul" - def __rmul__(self, other): - return "rmul" - a = C() - vereq(a*2, "mul") - vereq(a*2.2, "mul") - vereq(2*a, "rmul") - vereq(2.2*a, "rmul") - -def testipow(): - # [SF bug 620179] - if verbose: - print("Testing correct invocation of __ipow__...") - class C(object): - def __ipow__(self, other): - pass - a = C() - a **= 2 - -def do_this_first(): - if verbose: - print("Testing SF bug 551412 ...") - # This dumps core when SF bug 551412 isn't fixed -- - # but only when test_descr.py is run separately. - # (That can't be helped -- as soon as PyType_Ready() - # is called for PyLong_Type, the bug is gone.) - class UserLong(object): - def __pow__(self, *args): - pass - try: - pow(0, UserLong(), 0) - except: - pass - - if verbose: - print("Testing SF bug 570483...") - # Another segfault only when run early - # (before PyType_Ready(tuple) is called) - type.mro(tuple) - -def test_mutable_bases(): - if verbose: - print("Testing mutable bases...") - # stuff that should work: - class C(object): - pass - class C2(object): - def __getattribute__(self, attr): - if attr == 'a': - return 2 - else: - return super(C2, self).__getattribute__(attr) - def meth(self): - return 1 - class D(C): - pass - class E(D): - pass - d = D() - e = E() - D.__bases__ = (C,) - D.__bases__ = (C2,) - vereq(d.meth(), 1) - vereq(e.meth(), 1) - vereq(d.a, 2) - vereq(e.a, 2) - vereq(C2.__subclasses__(), [D]) - - # stuff that shouldn't: - class L(list): - pass - - try: - L.__bases__ = (dict,) - except TypeError: - pass - else: - raise TestFailed("shouldn't turn list subclass into dict subclass") - - try: - list.__bases__ = (dict,) - except TypeError: - pass - else: - raise TestFailed("shouldn't be able to assign to list.__bases__") - - try: - D.__bases__ = (C2, list) - except TypeError: - pass - else: - assert 0, "best_base calculation found wanting" - - try: - del D.__bases__ - except TypeError: - pass - else: - raise TestFailed("shouldn't be able to delete .__bases__") - - try: - D.__bases__ = () - except TypeError as msg: - if str(msg) == "a new-style class can't have only classic bases": - raise TestFailed("wrong error message for .__bases__ = ()") - else: - raise TestFailed("shouldn't be able to set .__bases__ to ()") - - try: - D.__bases__ = (D,) - except TypeError: - pass - else: - # actually, we'll have crashed by here... - raise TestFailed("shouldn't be able to create inheritance cycles") - - try: - D.__bases__ = (C, C) - except TypeError: - pass - else: - raise TestFailed("didn't detect repeated base classes") - - try: - D.__bases__ = (E,) - except TypeError: - pass - else: - raise TestFailed("shouldn't be able to create inheritance cycles") - -def test_mutable_bases_with_failing_mro(): - if verbose: - print("Testing mutable bases with failing mro...") - class WorkOnce(type): - def __new__(self, name, bases, ns): - self.flag = 0 - return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns) - def mro(self): - if self.flag > 0: - raise RuntimeError("bozo") - else: - self.flag += 1 - return type.mro(self) + def test_carloverre(self): + # Testing prohibition of Carlo Verre's hack... + try: + object.__setattr__(str, "foo", 42) + except TypeError: + pass + else: + self.fail("Carlo Verre __setattr__ suceeded!") + try: + object.__delattr__(str, "lower") + except TypeError: + pass + else: + self.fail("Carlo Verre __delattr__ succeeded!") + + def test_weakref_segfault(self): + # Testing weakref segfault... + # SF 742911 + import weakref + + class Provoker: + def __init__(self, referrent): + self.ref = weakref.ref(referrent) + + def __del__(self): + x = self.ref() + + class Oops(object): + pass + + o = Oops() + o.whatever = Provoker(o) + del o + + def test_wrapper_segfault(self): + # SF 927248: deeply nested wrappers could cause stack overflow + f = lambda:None + for i in range(1000000): + f = f.__call__ + f = None + + def test_file_fault(self): + # Testing sys.stdout is changed in getattr... + import sys + class StdoutGuard: + def __getattr__(self, attr): + sys.stdout = sys.__stdout__ + raise RuntimeError("Premature access to sys.stdout.%s" % attr) + sys.stdout = StdoutGuard() + try: + print("Oops!") + except RuntimeError: + pass - class WorkAlways(type): - def mro(self): - # this is here to make sure that .mro()s aren't called - # with an exception set (which was possible at one point). - # An error message will be printed in a debug build. - # What's a good way to test for this? - return type.mro(self) + def test_vicious_descriptor_nonsense(self): + # Testing vicious_descriptor_nonsense... - class C(object): - pass + # A potential segfault spotted by Thomas Wouters in mail to + # python-dev 2003-04-17, turned into an example & fixed by Michael + # Hudson just less than four months later... - class C2(object): - pass + class Evil(object): + def __hash__(self): + return hash('attr') + def __eq__(self, other): + del C.attr + return 0 - class D(C): - pass + class Descr(object): + def __get__(self, ob, type=None): + return 1 - class E(D): - pass + class C(object): + attr = Descr() - class F(D, metaclass=WorkOnce): - pass + c = C() + c.__dict__[Evil()] = 0 - class G(D, metaclass=WorkAlways): - pass + self.assertEqual(c.attr, 1) + # this makes a crash more likely: + import gc; gc.collect() + self.assertEqual(hasattr(c, 'attr'), False) + + def test_init(self): + # SF 1155938 + class Foo(object): + def __init__(self): + return 10 + try: + Foo() + except TypeError: + pass + else: + self.fail("did not test __init__() for None return") - # Immediate subclasses have their mro's adjusted in alphabetical - # order, so E's will get adjusted before adjusting F's fails. We - # check here that E's gets restored. + def test_method_wrapper(self): + # Testing method-wrapper objects... + # did not support any reflection before 2.5 + + return # XXX should methods really support __eq__? + + l = [] + self.assertEqual(l.__add__, l.__add__) + self.assertEqual(l.__add__, [].__add__) + self.assert_(l.__add__ != [5].__add__) + self.assert_(l.__add__ != l.__mul__) + self.assert_(l.__add__.__name__ == '__add__') + self.assert_(l.__add__.__self__ is l) + self.assert_(l.__add__.__objclass__ is list) + self.assertEqual(l.__add__.__doc__, list.__add__.__doc__) + try: + hash(l.__add__) + except TypeError: + pass + else: + self.fail("no TypeError from hash([].__add__)") - E_mro_before = E.__mro__ - D_mro_before = D.__mro__ + t = () + t += (7,) + self.assertEqual(t.__add__, (7,).__add__) + self.assertEqual(hash(t.__add__), hash((7,).__add__)) + + def test_not_implemented(self): + # Testing NotImplemented... + # all binary methods should be able to return a NotImplemented + import sys + import types + import operator - try: - D.__bases__ = (C2,) - except RuntimeError: - vereq(E.__mro__, E_mro_before) - vereq(D.__mro__, D_mro_before) - else: - raise TestFailed("exception not propagated") - -def test_mutable_bases_catch_mro_conflict(): - if verbose: - print("Testing mutable bases catch mro conflict...") - class A(object): - pass - - class B(object): - pass - - class C(A, B): - pass - - class D(A, B): - pass - - class E(C, D): - pass - - try: - C.__bases__ = (B, A) - except TypeError: - pass - else: - raise TestFailed("didn't catch MRO conflict") - -def mutable_names(): - if verbose: - print("Testing mutable names...") - class C(object): - pass - - # C.__module__ could be 'test_descr' or '__main__' - mod = C.__module__ - - C.__name__ = 'D' - vereq((C.__module__, C.__name__), (mod, 'D')) - - C.__name__ = 'D.E' - vereq((C.__module__, C.__name__), (mod, 'D.E')) - -def subclass_right_op(): - if verbose: - print("Testing correct dispatch of subclass overloading __r__...") - - # This code tests various cases where right-dispatch of a subclass - # should be preferred over left-dispatch of a base class. - - # Case 1: subclass of int; this tests code in abstract.c::binary_op1() - - class B(int): - def __floordiv__(self, other): - return "B.__floordiv__" - def __rfloordiv__(self, other): - return "B.__rfloordiv__" - - vereq(B(1) // 1, "B.__floordiv__") - vereq(1 // B(1), "B.__rfloordiv__") - - # Case 2: subclass of object; this is just the baseline for case 3 - - class C(object): - def __floordiv__(self, other): - return "C.__floordiv__" - def __rfloordiv__(self, other): - return "C.__rfloordiv__" - - vereq(C() // 1, "C.__floordiv__") - vereq(1 // C(), "C.__rfloordiv__") - - # Case 3: subclass of new-style class; here it gets interesting - - class D(C): - def __floordiv__(self, other): - return "D.__floordiv__" - def __rfloordiv__(self, other): - return "D.__rfloordiv__" - - vereq(D() // C(), "D.__floordiv__") - vereq(C() // D(), "D.__rfloordiv__") - - # Case 4: this didn't work right in 2.2.2 and 2.3a1 - - class E(C): - pass - - vereq(E.__rfloordiv__, C.__rfloordiv__) - - vereq(E() // 1, "C.__floordiv__") - vereq(1 // E(), "C.__rfloordiv__") - vereq(E() // C(), "C.__floordiv__") - vereq(C() // E(), "C.__floordiv__") # This one would fail - -def dict_type_with_metaclass(): - if verbose: - print("Testing type of __dict__ when metaclass set...") - - class B(object): - pass - class M(type): - pass - class C(metaclass=M): - # In 2.3a1, C.__dict__ was a real dict rather than a dict proxy - pass - veris(type(C.__dict__), type(B.__dict__)) - -def meth_class_get(): - # Full coverage of descrobject.c::classmethod_get() - if verbose: - print("Testing __get__ method of METH_CLASS C methods...") - # Baseline - arg = [1, 2, 3] - res = {1: None, 2: None, 3: None} - vereq(dict.fromkeys(arg), res) - vereq({}.fromkeys(arg), res) - # Now get the descriptor - descr = dict.__dict__["fromkeys"] - # More baseline using the descriptor directly - vereq(descr.__get__(None, dict)(arg), res) - vereq(descr.__get__({})(arg), res) - # Now check various error cases - try: - descr.__get__(None, None) - except TypeError: - pass - else: - raise TestFailed("shouldn't have allowed descr.__get__(None, None)") - try: - descr.__get__(42) - except TypeError: - pass - else: - raise TestFailed("shouldn't have allowed descr.__get__(42)") - try: - descr.__get__(None, 42) - except TypeError: - pass - else: - raise TestFailed("shouldn't have allowed descr.__get__(None, 42)") - try: - descr.__get__(None, int) - except TypeError: - pass - else: - raise TestFailed("shouldn't have allowed descr.__get__(None, int)") - -def isinst_isclass(): - if verbose: - print("Testing proxy isinstance() and isclass()...") - class Proxy(object): - def __init__(self, obj): - self.__obj = obj - def __getattribute__(self, name): - if name.startswith("_Proxy__"): - return object.__getattribute__(self, name) - else: - return getattr(self.__obj, name) - # Test with a classic class - class C: - pass - a = C() - pa = Proxy(a) - verify(isinstance(a, C)) # Baseline - verify(isinstance(pa, C)) # Test - # Test with a classic subclass - class D(C): - pass - a = D() - pa = Proxy(a) - verify(isinstance(a, C)) # Baseline - verify(isinstance(pa, C)) # Test - # Test with a new-style class - class C(object): - pass - a = C() - pa = Proxy(a) - verify(isinstance(a, C)) # Baseline - verify(isinstance(pa, C)) # Test - # Test with a new-style subclass - class D(C): - pass - a = D() - pa = Proxy(a) - verify(isinstance(a, C)) # Baseline - verify(isinstance(pa, C)) # Test - -def proxysuper(): - if verbose: - print("Testing super() for a proxy object...") - class Proxy(object): - def __init__(self, obj): - self.__obj = obj - def __getattribute__(self, name): - if name.startswith("_Proxy__"): - return object.__getattribute__(self, name) + def specialmethod(self, other): + return NotImplemented + + def check(expr, x, y): + try: + exec(expr, {'x': x, 'y': y, 'operator': operator}) + except TypeError: + pass else: - return getattr(self.__obj, name) + self.fail("no TypeError from %r" % (expr,)) - class B(object): - def f(self): - return "B.f" - - class C(B): - def f(self): - return super(C, self).f() + "->C.f" - - obj = C() - p = Proxy(obj) - vereq(C.__dict__["f"](p), "B.f->C.f") - -def carloverre(): - if verbose: - print("Testing prohibition of Carlo Verre's hack...") - try: - object.__setattr__(str, "foo", 42) - except TypeError: - pass - else: - raise TestFailed("Carlo Verre __setattr__ suceeded!") - try: - object.__delattr__(str, "lower") - except TypeError: - pass - else: - raise TestFailed("Carlo Verre __delattr__ succeeded!") - -def weakref_segfault(): - # SF 742911 - if verbose: - print("Testing weakref segfault...") - - import weakref - - class Provoker: - def __init__(self, referrent): - self.ref = weakref.ref(referrent) - - def __del__(self): - x = self.ref() - - class Oops(object): - pass - - o = Oops() - o.whatever = Provoker(o) - del o - -def wrapper_segfault(): - # SF 927248: deeply nested wrappers could cause stack overflow - if verbose: - print("Testing wrapper segfault...") - f = lambda:None - for i in range(1000000): - f = f.__call__ - f = None - -# Fix SF #762455, segfault when sys.stdout is changed in getattr -def filefault(): - if verbose: - print("Testing sys.stdout is changed in getattr...") - import sys - class StdoutGuard: - def __getattr__(self, attr): - sys.stdout = sys.__stdout__ - raise RuntimeError("Premature access to sys.stdout.%s" % attr) - sys.stdout = StdoutGuard() - try: - print("Oops!") - except RuntimeError: - pass - -def vicious_descriptor_nonsense(): - # A potential segfault spotted by Thomas Wouters in mail to - # python-dev 2003-04-17, turned into an example & fixed by Michael - # Hudson just less than four months later... - if verbose: - print("Testing vicious_descriptor_nonsense...") - - class Evil(object): - def __hash__(self): - return hash('attr') - def __eq__(self, other): - del C.attr - return 0 - - class Descr(object): - def __get__(self, ob, type=None): - return 1 - - class C(object): - attr = Descr() - - c = C() - c.__dict__[Evil()] = 0 - - vereq(c.attr, 1) - # this makes a crash more likely: - import gc; gc.collect() - vereq(hasattr(c, 'attr'), False) - -def test_init(): - # SF 1155938 - class Foo(object): - def __init__(self): - return 10 - try: - Foo() - except TypeError: - pass - else: - raise TestFailed("did not test __init__() for None return") - -def methodwrapper(): - # did not support any reflection before 2.5 - if verbose: - print("Testing method-wrapper objects...") - - return # XXX should methods really support __eq__? - - l = [] - vereq(l.__add__, l.__add__) - vereq(l.__add__, [].__add__) - verify(l.__add__ != [5].__add__) - verify(l.__add__ != l.__mul__) - verify(l.__add__.__name__ == '__add__') - verify(l.__add__.__self__ is l) - verify(l.__add__.__objclass__ is list) - vereq(l.__add__.__doc__, list.__add__.__doc__) - try: - hash(l.__add__) - except TypeError: - pass - else: - raise TestFailed("no TypeError from hash([].__add__)") - - t = () - t += (7,) - vereq(t.__add__, (7,).__add__) - vereq(hash(t.__add__), hash((7,).__add__)) - -def notimplemented(): - # all binary methods should be able to return a NotImplemented - if verbose: - print("Testing NotImplemented...") - - import sys - import types - import operator - - def specialmethod(self, other): - return NotImplemented - - def check(expr, x, y): - try: - exec(expr, {'x': x, 'y': y, 'operator': operator}) - except TypeError: - pass - else: - raise TestFailed("no TypeError from %r" % (expr,)) - - N1 = sys.maxsize + 1 # might trigger OverflowErrors instead of TypeErrors - N2 = sys.maxsize # if sizeof(int) < sizeof(long), might trigger - # ValueErrors instead of TypeErrors - if 1: - metaclass = type + N1 = sys.maxsize + 1 # might trigger OverflowErrors instead of + # TypeErrors + N2 = sys.maxsize # if sizeof(int) < sizeof(long), might trigger + # ValueErrors instead of TypeErrors for name, expr, iexpr in [ ('__add__', 'x + y', 'x += y'), ('__sub__', 'x - y', 'x -= y'), ('__mul__', 'x * y', 'x *= y'), - ('__truediv__', 'x / y', None), - ('__floordiv__', 'x // y', None), + ('__truediv__', 'operator.truediv(x, y)', None), + ('__floordiv__', 'operator.floordiv(x, y)', None), + ('__div__', 'x / y', 'x /= y'), ('__mod__', 'x % y', 'x %= y'), ('__divmod__', 'divmod(x, y)', None), ('__pow__', 'x ** y', 'x **= y'), @@ -4139,241 +3982,102 @@ ('__rshift__', 'x >> y', 'x >>= y'), ('__and__', 'x & y', 'x &= y'), ('__or__', 'x | y', 'x |= y'), - ('__xor__', 'x ^ y', 'x ^= y'), - ]: + ('__xor__', 'x ^ y', 'x ^= y')]: rname = '__r' + name[2:] - A = metaclass('A', (), {name: specialmethod}) - B = metaclass('B', (), {rname: specialmethod}) + A = type('A', (), {name: specialmethod}) a = A() - b = B() check(expr, a, a) - check(expr, a, b) - check(expr, b, a) - check(expr, b, b) check(expr, a, N1) check(expr, a, N2) - check(expr, N1, b) - check(expr, N2, b) if iexpr: check(iexpr, a, a) - check(iexpr, a, b) - check(iexpr, b, a) - check(iexpr, b, b) check(iexpr, a, N1) check(iexpr, a, N2) iname = '__i' + name[2:] - C = metaclass('C', (), {iname: specialmethod}) + C = type('C', (), {iname: specialmethod}) c = C() check(iexpr, c, a) - check(iexpr, c, b) check(iexpr, c, N1) check(iexpr, c, N2) -def test_assign_slice(): - # ceval.c's assign_slice used to check for - # tp->tp_as_sequence->sq_slice instead of - # tp->tp_as_sequence->sq_ass_slice - if verbose: - print("Testing assign_slice...") - - class C(object): - def __setitem__(self, idx, value): - self.value = value - - c = C() - c[1:2] = 3 - vereq(c.value, 3) - -def test_weakref_in_del_segfault(): - # This used to segfault until r60057 - if verbose: - print("Testing weakref in del segfault...") - - import weakref - global ref - - class Target(): - def __del__(self): - global ref - ref = weakref.ref(self) - - w = Target() - del w - del ref - -def test_borrowed_ref_3_segfault(): - # This used to segfault until r60224 - if verbose: - print("Testing borrowed ref 3 segfault...") - - class KeyFunc(object): - def __call__(self, n): - del d['key'] - return 1 - - d = {'key': KeyFunc()} - try: - min(range(10), **d) - except: - pass - -def test_borrowed_ref_4_segfault(): - # This used to segfault until r60224 - if verbose: - print("Testing borrowed ref 4 segfault...") + def test_assign_slice(self): + # ceval.c's assign_slice used to check for + # tp->tp_as_sequence->sq_slice instead of + # tp->tp_as_sequence->sq_ass_slice - import types - import builtins + class C(object): + def __setitem__(self, idx, value): + self.value = value - class X(object): - def __getattr__(self, name): - # this is called with name == '__bases__' by PyObject_IsInstance() - # during the unbound method call -- it frees the unbound method - # itself before it invokes its im_func. - del builtins.__import__ - return () - - pseudoclass = X() - - class Y(object): - def __call__(self, *args): - # 'self' was freed already - return (self, args) - - # make an unbound method - orig_import = __import__ - try: - builtins.__import__ = types.MethodType(Y(), (pseudoclass, str)) - import spam - finally: - builtins.__import__ = orig_import - -def test_losing_dict_ref_segfault(): - # This used to segfault; - # derived from issue #1303614, test67.py - if verbose: - print("Testing losing dict ref segfault...") - - class Strange(object): - def __hash__(self): - return hash('hello') - - def __eq__(self, other): - x.__dict__ = {} # the old x.__dict__ is deallocated - return False - - class X(object): - pass - - v = 123 - x = X() - x.__dict__ = {Strange(): 42, 'hello': v+456} - x.hello + c = C() + c[1:2] = 3 + self.assertEqual(c.value, 3) -def test_main(): - weakref_segfault() # Must be first, somehow - wrapper_segfault() # NB This one is slow - do_this_first() - class_docstrings() - lists() - dicts() - dict_constructor() - test_dir() - ints() - longs() - floats() - complexes() - spamlists() - spamdicts() - pydicts() - pylists() - metaclass() - pymods() - multi() - mro_disagreement() - diamond() - ex5() - monotonicity() - consistency_with_epg() - objects() - slots() - slotspecials() - dynamics() - errors() - classmethods() - classmethods_in_c() - staticmethods() - staticmethods_in_c() - classic() - compattr() - newslot() - altmro() - overloading() - methods() - specials() - recursions() - weakrefs() - properties() - properties_plus() - supers() - inherits() - keywords() - str_subclass_as_dict_key() - classic_comparisons() - rich_comparisons() - descrdoc() - setclass() - setdict() - pickles() - copies() - binopoverride() - subclasspropagation() - buffer_inherit() - str_of_str_subclass() - kwdargs() - recursive__call__() - delhook() - hashinherit() - strops() - deepcopyrecursive() - modules() - dictproxyiterkeys() - dictproxyitervalues() - dictproxyiteritems() - pickleslots() - funnynew() - imulbug() - docdescriptor() - copy_setstate() - slices() - subtype_resurrection() - slottrash() - slotmultipleinheritance() - testrmul() - testipow() - test_mutable_bases() - test_mutable_bases_with_failing_mro() - test_mutable_bases_catch_mro_conflict() - mutable_names() - subclass_right_op() - dict_type_with_metaclass() - meth_class_get() - isinst_isclass() - proxysuper() - carloverre() - filefault() - vicious_descriptor_nonsense() - test_init() - methodwrapper() - notimplemented() - test_assign_slice() - test_weakref_in_del_segfault() - test_borrowed_ref_3_segfault() - test_borrowed_ref_4_segfault() - test_losing_dict_ref_segfault() +class DictProxyTests(unittest.TestCase): + def setUp(self): + class C(object): + def meth(self): + pass + self.C = C + + def test_iter_keys(self): + # Testing dict-proxy iterkeys... + keys = [ key for key in self.C.__dict__.keys() ] + keys.sort() + self.assertEquals(keys, ['__dict__', '__doc__', '__module__', + '__weakref__', 'meth']) + + def test_iter_values(self): + # Testing dict-proxy itervalues... + values = [ values for values in self.C.__dict__.values() ] + self.assertEqual(len(values), 5) + + def test_iter_items(self): + # Testing dict-proxy iteritems... + keys = [ key for (key, value) in self.C.__dict__.items() ] + keys.sort() + self.assertEqual(keys, ['__dict__', '__doc__', '__module__', + '__weakref__', 'meth']) + + def test_dict_type_with_metaclass(self): + # Testing type of __dict__ when metaclass set... + class B(object): + pass + class M(type): + pass + class C(metaclass=M): + # In 2.3a1, C.__dict__ was a real dict rather than a dict proxy + pass + self.assertEqual(type(C.__dict__), type(B.__dict__)) + + +class PTypesLongInitTest(unittest.TestCase): + # This is in its own TestCase so that it can be run before any other tests. + def test_pytype_long_ready(self): + # Testing SF bug 551412 ... + + # This dumps core when SF bug 551412 isn't fixed -- + # but only when test_descr.py is run separately. + # (That can't be helped -- as soon as PyType_Ready() + # is called for PyLong_Type, the bug is gone.) + class UserLong(object): + def __pow__(self, *args): + pass + try: + pow(0, UserLong(), 0) + except: + pass + + # Another segfault only when run early + # (before PyType_Ready(tuple) is called) + type.mro(tuple) - if verbose: print("All OK") + +def test_main(): + # Run all local test cases, with PTypesLongInitTest first. + test_support.run_unittest(PTypesLongInitTest, OperatorsTest, + ClassPropertiesAndMethods, DictProxyTests) if __name__ == "__main__": test_main() From python-3000-checkins at python.org Tue Feb 5 19:31:42 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 5 Feb 2008 19:31:42 +0100 (CET) Subject: [Python-3000-checkins] r60598 - python/branches/py3k/Lib/test/test_funcattrs.py Message-ID: <20080205183142.1C03B1E4017@bag.python.org> Author: georg.brandl Date: Tue Feb 5 19:31:41 2008 New Revision: 60598 Modified: python/branches/py3k/Lib/test/test_funcattrs.py Log: Merge r60522 from trunk. Modified: python/branches/py3k/Lib/test/test_funcattrs.py ============================================================================== --- python/branches/py3k/Lib/test/test_funcattrs.py (original) +++ python/branches/py3k/Lib/test/test_funcattrs.py Tue Feb 5 19:31:41 2008 @@ -1,369 +1,233 @@ -from test.test_support import verbose, TestFailed, verify +from test import test_support import types +import unittest -class F: - def a(self): - pass - -def b(): - 'my docstring' - pass - -# __module__ is a special attribute -verify(b.__module__ == __name__) -verify(verify.__module__ == "test.test_support") - -# setting attributes on functions -try: - b.publish -except AttributeError: pass -else: raise TestFailed('expected AttributeError') - -if b.__dict__ != {}: - raise TestFailed('expected unassigned func.__dict__ to be {}') - -b.publish = 1 -if b.publish != 1: - raise TestFailed('function attribute not set to expected value') - -docstring = 'its docstring' -b.__doc__ = docstring -if b.__doc__ != docstring: - raise TestFailed('problem with setting __doc__ attribute') - -if 'publish' not in dir(b): - raise TestFailed('attribute not in dir()') - -try: - del b.__dict__ -except TypeError: pass -else: raise TestFailed('del func.__dict__ expected TypeError') - -b.publish = 1 -try: - b.__dict__ = None -except TypeError: pass -else: raise TestFailed('func.__dict__ = None expected TypeError') - -d = {'hello': 'world'} -b.__dict__ = d -if b.__dict__ is not d: - raise TestFailed('func.__dict__ assignment to dictionary failed') -if b.hello != 'world': - raise TestFailed('attribute after func.__dict__ assignment failed') - -f1 = F() -f2 = F() - -try: - F.a.publish -except AttributeError: pass -else: raise TestFailed('expected AttributeError') - -try: - f1.a.publish -except AttributeError: pass -else: raise TestFailed('expected AttributeError') - -# In Python 2.1 beta 1, we disallowed setting attributes on unbound methods -# (it was already disallowed on bound methods). See the PEP for details. -# In Python 3.0 unbound methods are gone. -F.a.publish = 1 - -if F.a.publish != 1: - raise TestFailed('unbound method attribute not set to expected value') - -if f1.a.publish != 1: - raise TestFailed('bound method attribute access did not work') - -if f2.a.publish != 1: - raise TestFailed('bound method attribute access did not work') - -if 'publish' not in dir(F.a): - raise TestFailed('attribute not in dir()') - -try: - f1.a.publish = 0 -except (AttributeError, TypeError): pass -else: raise TestFailed('expected AttributeError or TypeError') - -# try setting __dict__ -F.a.__dict__ = {'one': 11, 'two': 22, 'three': 33} - -if f1.a.two != 22: - raise TestFailed('setting __dict__') - -from UserDict import UserDict -d = UserDict({'four': 44, 'five': 55}) - -try: - F.a.__dict__ = d -except (AttributeError, TypeError): pass -else: raise TestFailed +class FuncAttrsTest(unittest.TestCase): + def setUp(self): + class F: + def a(self): + pass + def b(): + return 3 + self.fi = F() + self.F = F + self.b = b + + def cannot_set_attr(self, obj, name, value, exceptions): + try: + setattr(obj, name, value) + except exceptions: + pass + else: + self.fail("shouldn't be able to set %s to %r" % (name, value)) + try: + delattr(obj, name) + except exceptions: + pass + else: + self.fail("shouldn't be able to del %s" % name) + + +class FunctionPropertiesTest(FuncAttrsTest): + # Include the external setUp method that is common to all tests + def test_module(self): + self.assertEqual(self.b.__module__, __name__) + + def test_dir_includes_correct_attrs(self): + self.b.known_attr = 7 + self.assert_('known_attr' in dir(self.b), + "set attributes not in dir listing of method") + # Test on underlying function object of method + self.F.a.known_attr = 7 + self.assert_('known_attr' in dir(self.fi.a), "set attribute on function " + "implementations, should show up in next dir") + + def test_duplicate_function_equality(self): + # Body of `duplicate' is the exact same as self.b + def duplicate(): + 'my docstring' + return 3 + self.assertNotEqual(self.b, duplicate) + + def test_copying___code__(self): + def test(): pass + self.assertEqual(test(), None) + test.__code__ = self.b.__code__ + self.assertEqual(test(), 3) # self.b always returns 3, arbitrarily + + def test___globals__(self): + self.assertEqual(self.b.__globals__, globals()) + self.cannot_set_attr(self.b, '__globals__', 2, (AttributeError, TypeError)) + + def test___name__(self): + self.assertEqual(self.b.__name__, 'b') + self.b.__name__ = 'c' + self.assertEqual(self.b.__name__, 'c') + self.b.__name__ = 'd' + self.assertEqual(self.b.__name__, 'd') + # __name__ and __name__ must be a string + self.cannot_set_attr(self.b, '__name__', 7, TypeError) + # __name__ must be available when in restricted mode. Exec will raise + # AttributeError if __name__ is not available on f. + s = """def f(): pass\nf.__name__""" + exec(s, {'__builtins__': {}}) + # Test on methods, too + self.assertEqual(self.fi.a.__name__, 'a') + self.cannot_set_attr(self.fi.a, "__name__", 'a', AttributeError) + + def test___code__(self): + num_one, num_two = 7, 8 + def a(): pass + def b(): return 12 + def c(): return num_one + def d(): return num_two + def e(): return num_one, num_two + for func in [a, b, c, d, e]: + self.assertEqual(type(func.__code__), types.CodeType) + self.assertEqual(c(), 7) + self.assertEqual(d(), 8) + d.__code__ = c.__code__ + self.assertEqual(c.__code__, d.__code__) + self.assertEqual(c(), 7) + # self.assertEqual(d(), 7) + try: b.__code__ = c.__code__ + except ValueError: pass + else: self.fail( + "__code__ with different numbers of free vars should not be " + "possible") + try: e.__code__ = d.__code__ + except ValueError: pass + else: self.fail( + "__code__ with different numbers of free vars should not be " + "possible") + + def test_blank_func_defaults(self): + self.assertEqual(self.b.__defaults__, None) + del self.b.__defaults__ + self.assertEqual(self.b.__defaults__, None) + + def test_func_default_args(self): + def first_func(a, b): + return a+b + def second_func(a=1, b=2): + return a+b + self.assertEqual(first_func.__defaults__, None) + self.assertEqual(second_func.__defaults__, (1, 2)) + first_func.__defaults__ = (1, 2) + self.assertEqual(first_func.__defaults__, (1, 2)) + self.assertEqual(first_func(), 3) + self.assertEqual(first_func(3), 5) + self.assertEqual(first_func(3, 5), 8) + del second_func.__defaults__ + self.assertEqual(second_func.__defaults__, None) + try: second_func() + except TypeError: pass + else: self.fail( + "func_defaults does not update; deleting it does not remove " + "requirement") + +class ImplicitReferencesTest(FuncAttrsTest): + + def test___class__(self): + self.assertEqual(self.fi.a.__self__.__class__, self.F) + self.cannot_set_attr(self.fi.a, "__class__", self.F, TypeError) + + def test___func__(self): + self.assertEqual(self.fi.a.__func__, self.F.a) + self.cannot_set_attr(self.fi.a, "__func__", self.F.a, AttributeError) + + def test___self__(self): + self.assertEqual(self.fi.a.__self__, self.fi) + self.cannot_set_attr(self.fi.a, "__self__", self.fi, AttributeError) + + def test___func___non_method(self): + # Behavior should be the same when a method is added via an attr + # assignment + self.fi.id = types.MethodType(id, self.fi) + self.assertEqual(self.fi.id(), id(self.fi)) + # Test usage + try: self.fi.id.unknown_attr + except AttributeError: pass + else: self.fail("using unknown attributes should raise AttributeError") + # Test assignment and deletion + self.cannot_set_attr(self.fi.id, 'unknown_attr', 2, AttributeError) + +class ArbitraryFunctionAttrTest(FuncAttrsTest): + def test_set_attr(self): + self.b.known_attr = 7 + self.assertEqual(self.b.known_attr, 7) + try: self.fi.a.known_attr = 7 + except AttributeError: pass + else: self.fail("setting attributes on methods should raise error") + + def test_delete_unknown_attr(self): + try: del self.b.unknown_attr + except AttributeError: pass + else: self.fail("deleting unknown attribute should raise TypeError") + + def test_unset_attr(self): + for func in [self.b, self.fi.a]: + try: func.non_existant_attr + except AttributeError: pass + else: self.fail("using unknown attributes should raise " + "AttributeError") + +class FunctionDictsTest(FuncAttrsTest): + def test_setting_dict_to_invalid(self): + self.cannot_set_attr(self.b, '__dict__', None, TypeError) + from UserDict import UserDict + d = UserDict({'known_attr': 7}) + self.cannot_set_attr(self.fi.a.__func__, '__dict__', d, TypeError) + + def test_setting_dict_to_valid(self): + d = {'known_attr': 7} + self.b.__dict__ = d + # Test assignment + self.assertEqual(d, self.b.__dict__) + # ... and on all the different ways of referencing the method's func + self.F.a.__dict__ = d + self.assertEqual(d, self.fi.a.__func__.__dict__) + self.assertEqual(d, self.fi.a.__dict__) + # Test value + self.assertEqual(self.b.known_attr, 7) + self.assertEqual(self.b.__dict__['known_attr'], 7) + # ... and again, on all the different method's names + self.assertEqual(self.fi.a.__func__.known_attr, 7) + self.assertEqual(self.fi.a.known_attr, 7) + + def test_delete___dict__(self): + try: del self.b.__dict__ + except TypeError: pass + else: self.fail("deleting function dictionary should raise TypeError") + + def test_unassigned_dict(self): + self.assertEqual(self.b.__dict__, {}) + + def test_func_as_dict_key(self): + value = "Some string" + d = {} + d[self.b] = value + self.assertEqual(d[self.b], value) + +class FunctionDocstringTest(FuncAttrsTest): + def test_set_docstring_attr(self): + self.assertEqual(self.b.__doc__, None) + docstr = "A test method that does nothing" + self.b.__doc__ = docstr + self.F.a.__doc__ = docstr + self.assertEqual(self.b.__doc__, docstr) + self.assertEqual(self.fi.a.__doc__, docstr) + self.cannot_set_attr(self.fi.a, "__doc__", docstr, AttributeError) + + def test_delete_docstring(self): + self.b.__doc__ = "The docstring" + del self.b.__doc__ + self.assertEqual(self.b.__doc__, None) + +def test_main(): + test_support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest, + ArbitraryFunctionAttrTest, FunctionDictsTest, + FunctionDocstringTest) -if f2.a.one != f1.a.one != F.a.one != 11: - raise TestFailed - -# __func__ may not be a Python method! -import types -F.id = id - -eff = F() -eff.id = types.MethodType(id, eff) -if eff.id() != id(eff): - raise TestFailed - -try: - F.id.foo -except AttributeError: pass -else: raise TestFailed - -try: - F.id.foo = 12 -except (AttributeError, TypeError): pass -else: raise TestFailed - -try: - F.id.foo -except AttributeError: pass -else: raise TestFailed - -try: - eff.id.foo -except AttributeError: pass -else: raise TestFailed - -try: - eff.id.foo = 12 -except (AttributeError, TypeError): pass -else: raise TestFailed - -try: - eff.id.foo -except AttributeError: pass -else: raise TestFailed - -# Regression test for a crash in pre-2.1a1 -def another(): - pass - -try: - del another.__dict__ -except TypeError: pass -else: raise TestFailed - -try: - del another.__dict__ -except TypeError: pass -else: raise TestFailed - -try: - another.__dict__ = None -except TypeError: pass -else: raise TestFailed - -try: - del another.bar -except AttributeError: pass -else: raise TestFailed - -# This isn't specifically related to function attributes, but it does test a -# core dump regression in funcobject.c -del another.__defaults__ - -def foo(): - pass - -def bar(): - pass - -def temp(): - print(1) - -if foo==bar: - raise TestFailed - -d={} -d[foo] = 1 - -foo.__code__ = temp.__code__ - -d[foo] - -# Test all predefined function attributes systematically - -def cantset(obj, name, value, exception=(AttributeError, TypeError)): - verify(hasattr(obj, name)) # Otherwise it's probably a typo - try: - setattr(obj, name, value) - except exception: - pass - else: - raise TestFailed("shouldn't be able to set %s to %r" % (name, value)) - try: - delattr(obj, name) - except (AttributeError, TypeError): - pass - else: - raise TestFailed("shouldn't be able to del %s" % name) - -def test_func_closure(): - a = 12 - def f(): print(a) - c = f.__closure__ - verify(isinstance(c, tuple)) - verify(len(c) == 1) - verify(c[0].__class__.__name__ == "cell") # don't have a type object handy - cantset(f, "__closure__", c) - -def test_empty_cell(): - def f(): print(a) - try: - f.__closure__[0].cell_contents - except ValueError: - pass - else: - raise TestFailed("shouldn't be able to read an empty cell") - - a = 12 - -def test_func_doc(): - def f(): pass - verify(f.__doc__ is None) - f.__doc__ = "hello" - verify(f.__doc__ == "hello") - del f.__doc__ - verify(f.__doc__ is None) - -def test_func_globals(): - def f(): pass - verify(f.__globals__ is globals()) - cantset(f, "__globals__", globals()) - -def test_func_name(): - def f(): pass - verify(f.__name__ == "f") - f.__name__ = "g" - verify(f.__name__ == "g") - cantset(f, "__globals__", 1) - cantset(f, "__name__", 1) - # test that you can access func.__name__ in restricted mode - s = """def f(): pass\nf.__name__""" - exec(s, {'__builtins__':{}}) - - -def test_func_code(): - a = b = 24 - def f(): pass - def g(): print(12) - def f1(): print(a) - def g1(): print(b) - def f2(): print(a, b) - verify(type(f.__code__) is types.CodeType) - f.__code__ = g.__code__ - cantset(f, "__code__", None) - # can't change the number of free vars - cantset(f, "__code__", f1.__code__, exception=ValueError) - cantset(f1, "__code__", f.__code__, exception=ValueError) - cantset(f1, "__code__", f2.__code__, exception=ValueError) - f1.__code__ = g1.__code__ - -def test_func_defaults(): - def f(a, b): return (a, b) - verify(f.__defaults__ is None) - f.__defaults__ = (1, 2) - verify(f.__defaults__ == (1, 2)) - verify(f(10) == (10, 2)) - def g(a=1, b=2): return (a, b) - verify(g.__defaults__ == (1, 2)) - del g.__defaults__ - verify(g.__defaults__ is None) - try: - g() - except TypeError: - pass - else: - raise TestFailed("shouldn't be allowed to call g() w/o defaults") - -def test_func_dict(): - def f(): pass - a = f.__dict__ - verify(a == {}) - f.hello = 'world' - verify(a == {'hello': 'world'}) - verify(a is f.__dict__) - f.__dict__ = {'world': 'hello'} - verify(f.world == "hello") - verify(f.__dict__ == {'world': 'hello'}) - cantset(f, "__dict__", None) - -def test___self__(): - class C: - def foo(self): pass - #verify(C.foo.__self__.__class__ is C) - verify(C().foo.__self__.__class__ is C) - #cantset(C.foo, "__self__.__class__", C) - cantset(C().foo, "__self__.__class__", C) - -def test___func__(): - def foo(self): pass - class C: - pass - C.foo = foo - #verify(C.foo.__func__ is foo) - verify(C().foo.__func__ is foo) - #cantset(C.foo, "__func__", foo) - cantset(C().foo, "__func__", foo) - -def test___self__(): - class C: - def foo(self): pass - #verify(C.foo.__self__ is None) - c = C() - #verify(c.foo.__self__ is c) - #cantset(C.foo, "__self__", None) - #cantset(c.foo, "__self__", c) - -def test_im_dict(): - class C: - def foo(self): pass - foo.bar = 42 - verify(C.foo.__dict__ == {'bar': 42}) - verify(C().foo.__dict__ == {'bar': 42}) - #cantset(C.foo, "__dict__", C.foo.__dict__) - #cantset(C().foo, "__dict__", C.foo.__dict__) - -def test_im_doc(): - class C: - def foo(self): "hello" - verify(C.foo.__doc__ == "hello") - verify(C().foo.__doc__ == "hello") - #cantset(C.foo, "__doc__", "hello") - #cantset(C().foo, "__doc__", "hello") - -def test_im_name(): - class C: - def foo(self): pass - verify(C.foo.__name__ == "foo") - verify(C().foo.__name__ == "foo") - #cantset(C.foo, "__name__", "foo") - #cantset(C().foo, "__name__", "foo") - -def testmore(): - test_func_closure() - test_empty_cell() - test_func_doc() - test_func_globals() - test_func_name() - test_func_code() - test_func_defaults() - test_func_dict() - # Tests for instance method attributes - test___self__() - test___func__() - test___self__() - test_im_dict() - test_im_doc() - test_im_name() - -testmore() +if __name__ == "__main__": + test_main() From python-3000-checkins at python.org Tue Feb 5 19:33:59 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 5 Feb 2008 19:33:59 +0100 (CET) Subject: [Python-3000-checkins] r60600 - python/branches/py3k Message-ID: <20080205183359.2F94B1E401D@bag.python.org> Author: georg.brandl Date: Tue Feb 5 19:33:58 2008 New Revision: 60600 Modified: python/branches/py3k/ (props changed) Log: Blocked revisions 60599 via svnmerge ........ r60599 | georg.brandl | 2008-02-05 19:32:47 +0100 (Tue, 05 Feb 2008) | 2 lines Fix unittest conversion breakage. ........ From python-3000-checkins at python.org Tue Feb 5 19:48:51 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 5 Feb 2008 19:48:51 +0100 (CET) Subject: [Python-3000-checkins] r60601 - python/branches/py3k/Lib/test/test_queue.py Message-ID: <20080205184851.B36481E4017@bag.python.org> Author: georg.brandl Date: Tue Feb 5 19:48:51 2008 New Revision: 60601 Modified: python/branches/py3k/Lib/test/test_queue.py Log: Merge r60528, r60534 and r60539 from trunk. Modified: python/branches/py3k/Lib/test/test_queue.py ============================================================================== --- python/branches/py3k/Lib/test/test_queue.py (original) +++ python/branches/py3k/Lib/test/test_queue.py Tue Feb 5 19:48:51 2008 @@ -4,8 +4,8 @@ import sys import threading import time - -from test.test_support import verify, TestFailed, verbose +import unittest +from test import test_support QUEUE_SIZE = 5 @@ -33,50 +33,177 @@ self.startedEvent.set() self.fn(*self.args) + # Execute a function that blocks, and in a separate thread, a function that -# triggers the release. Returns the result of the blocking function. -# Caution: block_func must guarantee to block until trigger_func is -# called, and trigger_func must guarantee to change queue state so that -# block_func can make enough progress to return. In particular, a -# block_func that just raises an exception regardless of whether trigger_func -# is called will lead to timing-dependent sporadic failures, and one of -# those went rarely seen but undiagnosed for years. Now block_func -# must be unexceptional. If block_func is supposed to raise an exception, -# call _doExceptionalBlockingTest() instead. -def _doBlockingTest(block_func, block_args, trigger_func, trigger_args): - t = _TriggerThread(trigger_func, trigger_args) - t.start() - result = block_func(*block_args) - # If block_func returned before our thread made the call, we failed! - if not t.startedEvent.isSet(): - raise TestFailed("blocking function '%r' appeared not to block" % - block_func) - t.join(10) # make sure the thread terminates - if t.isAlive(): - raise TestFailed("trigger function '%r' appeared to not return" % - trigger_func) - return result - -# Call this instead if block_func is supposed to raise an exception. -def _doExceptionalBlockingTest(block_func, block_args, trigger_func, - trigger_args, expected_exception_class): - t = _TriggerThread(trigger_func, trigger_args) - t.start() - try: - try: - block_func(*block_args) - except expected_exception_class: - raise +# triggers the release. Returns the result of the blocking function. Caution: +# block_func must guarantee to block until trigger_func is called, and +# trigger_func must guarantee to change queue state so that block_func can make +# enough progress to return. In particular, a block_func that just raises an +# exception regardless of whether trigger_func is called will lead to +# timing-dependent sporadic failures, and one of those went rarely seen but +# undiagnosed for years. Now block_func must be unexceptional. If block_func +# is supposed to raise an exception, call do_exceptional_blocking_test() +# instead. + +class BlockingTestMixin: + + def do_blocking_test(self, block_func, block_args, trigger_func, trigger_args): + self.t = _TriggerThread(trigger_func, trigger_args) + self.t.start() + self.result = block_func(*block_args) + # If block_func returned before our thread made the call, we failed! + if not self.t.startedEvent.isSet(): + self.fail("blocking function '%r' appeared not to block" % + block_func) + self.t.join(10) # make sure the thread terminates + if self.t.isAlive(): + self.fail("trigger function '%r' appeared to not return" % + trigger_func) + return self.result + + # Call this instead if block_func is supposed to raise an exception. + def do_exceptional_blocking_test(self,block_func, block_args, trigger_func, + trigger_args, expected_exception_class): + self.t = _TriggerThread(trigger_func, trigger_args) + self.t.start() + try: + try: + block_func(*block_args) + except expected_exception_class: + raise + else: + self.fail("expected exception of kind %r" % + expected_exception_class) + finally: + self.t.join(10) # make sure the thread terminates + if self.t.isAlive(): + self.fail("trigger function '%r' appeared to not return" % + trigger_func) + if not self.t.startedEvent.isSet(): + self.fail("trigger thread ended but event never set") + + +class BaseQueueTest(unittest.TestCase, BlockingTestMixin): + def setUp(self): + self.cum = 0 + self.cumlock = threading.Lock() + + def simple_queue_test(self, q): + if q.qsize(): + raise RuntimeError("Call this function with an empty queue") + # I guess we better check things actually queue correctly a little :) + q.put(111) + q.put(333) + q.put(222) + target_order = dict(Queue = [111, 333, 222], + LifoQueue = [222, 333, 111], + PriorityQueue = [111, 222, 333]) + actual_order = [q.get(), q.get(), q.get()] + self.assertEquals(actual_order, target_order[q.__class__.__name__], + "Didn't seem to queue the correct data!") + for i in range(QUEUE_SIZE-1): + q.put(i) + self.assert_(q.qsize(), "Queue should not be empty") + self.assert_(not qfull(q), "Queue should not be full") + last = 2 * QUEUE_SIZE + full = 3 * 2 * QUEUE_SIZE + q.put(last) + self.assert_(qfull(q), "Queue should be full") + try: + q.put(full, block=0) + self.fail("Didn't appear to block with a full queue") + except Queue.Full: + pass + try: + q.put(full, timeout=0.01) + self.fail("Didn't appear to time-out with a full queue") + except Queue.Full: + pass + # Test a blocking put + self.do_blocking_test(q.put, (full,), q.get, ()) + self.do_blocking_test(q.put, (full, True, 10), q.get, ()) + # Empty it + for i in range(QUEUE_SIZE): + q.get() + self.assert_(not q.qsize(), "Queue should be empty") + try: + q.get(block=0) + self.fail("Didn't appear to block with an empty queue") + except Queue.Empty: + pass + try: + q.get(timeout=0.01) + self.fail("Didn't appear to time-out with an empty queue") + except Queue.Empty: + pass + # Test a blocking get + self.do_blocking_test(q.get, (), q.put, ('empty',)) + self.do_blocking_test(q.get, (True, 10), q.put, ('empty',)) + + + def worker(self, q): + while True: + x = q.get() + if x is None: + q.task_done() + return + with self.cumlock: + self.cum += x + q.task_done() + + def queue_join_test(self, q): + self.cum = 0 + for i in (0,1): + threading.Thread(target=self.worker, args=(q,)).start() + for i in range(100): + q.put(i) + q.join() + self.assertEquals(self.cum, sum(range(100)), + "q.join() did not block until all tasks were done") + q.put(None) # instruct the threads to close + q.join() # verify that you can join twice + + def test_queue_task_done(self): + # Test to make sure a queue task completed successfully. + q = self.type2test() + try: + q.task_done() + except ValueError: + pass else: - raise TestFailed("expected exception of kind %r" % - expected_exception_class) - finally: - t.join(10) # make sure the thread terminates - if t.isAlive(): - raise TestFailed("trigger function '%r' appeared to not return" % - trigger_func) - if not t.startedEvent.isSet(): - raise TestFailed("trigger thread ended but event never set") + self.fail("Did not detect task count going negative") + + def test_queue_join(self): + # Test that a queue join()s successfully, and before anything else + # (done twice for insurance). + q = self.type2test() + self.queue_join_test(q) + self.queue_join_test(q) + try: + q.task_done() + except ValueError: + pass + else: + self.fail("Did not detect task count going negative") + + def test_simple_queue(self): + # Do it a couple of times on the same queue. + # Done twice to make sure works with same instance reused. + q = self.type2test(QUEUE_SIZE) + self.simple_queue_test(q) + self.simple_queue_test(q) + + +class QueueTest(BaseQueueTest): + type2test = Queue.Queue + +class LifoQueueTest(BaseQueueTest): + type2test = Queue.LifoQueue + +class PriorityQueueTest(BaseQueueTest): + type2test = Queue.PriorityQueue + + # A Queue subclass that can provoke failure at a moment's notice :) class FailingQueueException(Exception): @@ -98,195 +225,101 @@ raise FailingQueueException("You Lose") return Queue.Queue._get(self) -def FailingQueueTest(q): - if q.qsize(): - raise RuntimeError("Call this function with an empty queue") - for i in range(QUEUE_SIZE-1): - q.put(i) - # Test a failing non-blocking put. - q.fail_next_put = True - try: - q.put("oops", block=0) - raise TestFailed("The queue didn't fail when it should have") - except FailingQueueException: - pass - q.fail_next_put = True - try: - q.put("oops", timeout=0.1) - raise TestFailed("The queue didn't fail when it should have") - except FailingQueueException: - pass - q.put("last") - verify(qfull(q), "Queue should be full") - # Test a failing blocking put - q.fail_next_put = True - try: - _doBlockingTest(q.put, ("full",), q.get, ()) - raise TestFailed("The queue didn't fail when it should have") - except FailingQueueException: - pass - # Check the Queue isn't damaged. - # put failed, but get succeeded - re-add - q.put("last") - # Test a failing timeout put - q.fail_next_put = True - try: - _doExceptionalBlockingTest(q.put, ("full", True, 10), q.get, (), - FailingQueueException) - raise TestFailed("The queue didn't fail when it should have") - except FailingQueueException: - pass - # Check the Queue isn't damaged. - # put failed, but get succeeded - re-add - q.put("last") - verify(qfull(q), "Queue should be full") - q.get() - verify(not qfull(q), "Queue should not be full") - q.put("last") - verify(qfull(q), "Queue should be full") - # Test a blocking put - _doBlockingTest( q.put, ("full",), q.get, ()) - # Empty it - for i in range(QUEUE_SIZE): - q.get() - verify(not q.qsize(), "Queue should be empty") - q.put("first") - q.fail_next_get = True - try: +class FailingQueueTest(unittest.TestCase, BlockingTestMixin): + + def failing_queue_test(self, q): + if q.qsize(): + raise RuntimeError("Call this function with an empty queue") + for i in range(QUEUE_SIZE-1): + q.put(i) + # Test a failing non-blocking put. + q.fail_next_put = True + try: + q.put("oops", block=0) + self.fail("The queue didn't fail when it should have") + except FailingQueueException: + pass + q.fail_next_put = True + try: + q.put("oops", timeout=0.1) + self.fail("The queue didn't fail when it should have") + except FailingQueueException: + pass + q.put("last") + self.assert_(qfull(q), "Queue should be full") + # Test a failing blocking put + q.fail_next_put = True + try: + self.do_blocking_test(q.put, ("full",), q.get, ()) + self.fail("The queue didn't fail when it should have") + except FailingQueueException: + pass + # Check the Queue isn't damaged. + # put failed, but get succeeded - re-add + q.put("last") + # Test a failing timeout put + q.fail_next_put = True + try: + self.do_exceptional_blocking_test(q.put, ("full", True, 10), q.get, (), + FailingQueueException) + self.fail("The queue didn't fail when it should have") + except FailingQueueException: + pass + # Check the Queue isn't damaged. + # put failed, but get succeeded - re-add + q.put("last") + self.assert_(qfull(q), "Queue should be full") q.get() - raise TestFailed("The queue didn't fail when it should have") - except FailingQueueException: - pass - verify(q.qsize(), "Queue should not be empty") - q.fail_next_get = True - try: - q.get(timeout=0.1) - raise TestFailed("The queue didn't fail when it should have") - except FailingQueueException: - pass - verify(q.qsize(), "Queue should not be empty") - q.get() - verify(not q.qsize(), "Queue should be empty") - q.fail_next_get = True - try: - _doExceptionalBlockingTest(q.get, (), q.put, ('empty',), - FailingQueueException) - raise TestFailed("The queue didn't fail when it should have") - except FailingQueueException: - pass - # put succeeded, but get failed. - verify(q.qsize(), "Queue should not be empty") - q.get() - verify(not q.qsize(), "Queue should be empty") - -def SimpleQueueTest(q): - if q.qsize(): - raise RuntimeError("Call this function with an empty queue") - # I guess we better check things actually queue correctly a little :) - q.put(111) - q.put(333) - q.put(222) - target_order = dict(Queue = [111, 333, 222], - LifoQueue = [222, 333, 111], - PriorityQueue = [111, 222, 333]) - actual_order = [q.get(), q.get(), q.get()] - verify(actual_order == target_order[q.__class__.__name__], - "Didn't seem to queue the correct data!") - for i in range(QUEUE_SIZE-1): - q.put(i) - verify(q.qsize(), "Queue should not be empty") - verify(not qfull(q), "Queue should not be full") - last = 2*QUEUE_SIZE - full = 3*2*QUEUE_SIZE - q.put(last) - verify(qfull(q), "Queue should be full") - try: - q.put(full, block=0) - raise TestFailed("Didn't appear to block with a full queue") - except Queue.Full: - pass - try: - q.put(full, timeout=0.01) - raise TestFailed("Didn't appear to time-out with a full queue") - except Queue.Full: - pass - # Test a blocking put - _doBlockingTest(q.put, (full,), q.get, ()) - _doBlockingTest(q.put, (full, True, 10), q.get, ()) - # Empty it - for i in range(QUEUE_SIZE): + self.assert_(not qfull(q), "Queue should not be full") + q.put("last") + self.assert_(qfull(q), "Queue should be full") + # Test a blocking put + self.do_blocking_test(q.put, ("full",), q.get, ()) + # Empty it + for i in range(QUEUE_SIZE): + q.get() + self.assert_(not q.qsize(), "Queue should be empty") + q.put("first") + q.fail_next_get = True + try: + q.get() + self.fail("The queue didn't fail when it should have") + except FailingQueueException: + pass + self.assert_(q.qsize(), "Queue should not be empty") + q.fail_next_get = True + try: + q.get(timeout=0.1) + self.fail("The queue didn't fail when it should have") + except FailingQueueException: + pass + self.assert_(q.qsize(), "Queue should not be empty") q.get() - verify(not q.qsize(), "Queue should be empty") - try: - q.get(block=0) - raise TestFailed("Didn't appear to block with an empty queue") - except Queue.Empty: - pass - try: - q.get(timeout=0.01) - raise TestFailed("Didn't appear to time-out with an empty queue") - except Queue.Empty: - pass - # Test a blocking get - _doBlockingTest(q.get, (), q.put, ('empty',)) - _doBlockingTest(q.get, (True, 10), q.put, ('empty',)) - -cum = 0 -cumlock = threading.Lock() - -def worker(q): - global cum - while True: - x = q.get() - if x is None: - q.task_done() - return - cumlock.acquire() + self.assert_(not q.qsize(), "Queue should be empty") + q.fail_next_get = True try: - cum += x - finally: - cumlock.release() - q.task_done() + self.do_exceptional_blocking_test(q.get, (), q.put, ('empty',), + FailingQueueException) + self.fail("The queue didn't fail when it should have") + except FailingQueueException: + pass + # put succeeded, but get failed. + self.assert_(q.qsize(), "Queue should not be empty") + q.get() + self.assert_(not q.qsize(), "Queue should be empty") + + def test_failing_queue(self): + # Test to make sure a queue is functioning correctly. + # Done twice to the same instance. + q = FailingQueue(QUEUE_SIZE) + self.failing_queue_test(q) + self.failing_queue_test(q) + + +def test_main(): + test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, + FailingQueueTest) -def QueueJoinTest(q): - global cum - cum = 0 - for i in (0,1): - threading.Thread(target=worker, args=(q,)).start() - for i in range(100): - q.put(i) - q.join() - verify(cum==sum(range(100)), "q.join() did not block until all tasks were done") - q.put(None) # instruct the threads to close - q.join() # verify that you can join twice - -def QueueTaskDoneTest(q): - try: - q.task_done() - except ValueError: - pass - else: - raise TestFailed("Did not detect task count going negative") - -def test(): - for Q in Queue.Queue, Queue.LifoQueue, Queue.PriorityQueue: - q = Q() - QueueTaskDoneTest(q) - QueueJoinTest(q) - QueueJoinTest(q) - QueueTaskDoneTest(q) - - q = Q(QUEUE_SIZE) - # Do it a couple of times on the same queue - SimpleQueueTest(q) - SimpleQueueTest(q) - if verbose: - print("Simple Queue tests seemed to work for", Q.__name__) - - q = FailingQueue(QUEUE_SIZE) - FailingQueueTest(q) - FailingQueueTest(q) - if verbose: - print("Failing Queue tests seemed to work") -test() +if __name__ == "__main__": + test_main() From python-3000-checkins at python.org Tue Feb 5 21:48:58 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 5 Feb 2008 21:48:58 +0100 (CET) Subject: [Python-3000-checkins] r60607 - python/branches/py3k/Lib/test/test_support.py Message-ID: <20080205204858.7D5961E4010@bag.python.org> Author: georg.brandl Date: Tue Feb 5 21:48:58 2008 New Revision: 60607 Modified: python/branches/py3k/Lib/test/test_support.py Log: Respect EOL 80. Modified: python/branches/py3k/Lib/test/test_support.py ============================================================================== --- python/branches/py3k/Lib/test/test_support.py (original) +++ python/branches/py3k/Lib/test/test_support.py Tue Feb 5 21:48:58 2008 @@ -118,7 +118,8 @@ (err, msg) = e.args if err != errno.EADDRINUSE: raise - print(' WARNING: failed to listen on port %d, trying another' % port, file=sys.__stderr__) + print(' WARNING: failed to listen on port %d, trying another' % + (port, file=sys.__stderr__)) raise TestFailed('unable to find port to listen on') FUZZ = 1e-6 @@ -179,9 +180,9 @@ except UnicodeEncodeError: pass else: - print('WARNING: The filename %r CAN be encoded by the filesystem. ' \ - 'Unicode filename tests may not be effective' \ - % TESTFN_UNICODE_UNENCODEABLE) + print('WARNING: The filename %r CAN be encoded by the filesystem. ' + 'Unicode filename tests may not be effective' + % TESTFN_UNICODE_UNENCODEABLE) # Make sure we can write to TESTFN, try in /tmp if we can't fp = None @@ -424,7 +425,8 @@ return decorator #======================================================================= -# Big-memory-test support. Separate from 'resources' because memory use should be configurable. +# Big-memory-test support. Separate from 'resources' because memory use +# should be configurable. # Some handy shorthands. Note that these are used for byte-limits as well # as size-limits, in the various bigmem tests @@ -578,7 +580,8 @@ finally: sys.stdout = save_stdout if verbose: - print('doctest (%s) ... %d tests with zero failures' % (module.__name__, t)) + print('doctest (%s) ... %d tests with zero failures' % + (module.__name__, t)) return f, t #======================================================================= From python-3000-checkins at python.org Tue Feb 5 22:00:53 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 5 Feb 2008 22:00:53 +0100 (CET) Subject: [Python-3000-checkins] r60608 - python/branches/py3k/Lib/test/test_support.py Message-ID: <20080205210053.A7AB21E4010@bag.python.org> Author: georg.brandl Date: Tue Feb 5 22:00:53 2008 New Revision: 60608 Modified: python/branches/py3k/Lib/test/test_support.py Log: Fix. Modified: python/branches/py3k/Lib/test/test_support.py ============================================================================== --- python/branches/py3k/Lib/test/test_support.py (original) +++ python/branches/py3k/Lib/test/test_support.py Tue Feb 5 22:00:53 2008 @@ -118,8 +118,8 @@ (err, msg) = e.args if err != errno.EADDRINUSE: raise - print(' WARNING: failed to listen on port %d, trying another' % - (port, file=sys.__stderr__)) + print(' WARNING: failed to listen on port %d, ' % port + + 'trying another', file=sys.__stderr__) raise TestFailed('unable to find port to listen on') FUZZ = 1e-6 From python-3000-checkins at python.org Tue Feb 5 23:54:43 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Tue, 5 Feb 2008 23:54:43 +0100 (CET) Subject: [Python-3000-checkins] r60609 - in python/branches/py3k/Lib: _abcoll.py collections.py test/test_userdict.py Message-ID: <20080205225443.CC0911E4010@bag.python.org> Author: raymond.hettinger Date: Tue Feb 5 23:54:43 2008 New Revision: 60609 Modified: python/branches/py3k/Lib/_abcoll.py python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/test/test_userdict.py Log: Convert test_userdict to use the collections.UserDict. Fix-up collections.UserDict.__contains__ to work correctly when __missing__ is defined. Fix-up Mapping.__eq__ to only match instances of Mapping. Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Tue Feb 5 23:54:43 2008 @@ -379,10 +379,11 @@ return ValuesView(self) def __eq__(self, other): - return dict(self.items()) == dict(other.items()) + return isinstance(other, Mapping) and \ + dict(self.items()) == dict(other.items()) def __ne__(self, other): - return dict(self.items()) != dict(other.items()) + return not (self == other) class MappingView(metaclass=ABCMeta): Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Tue Feb 5 23:54:43 2008 @@ -135,6 +135,9 @@ def __iter__(self): return iter(self.data) + # Modify __contains__ to work correctly when __missing__ is present + def __contains__(self, key): + return key in self.data # Now, add the methods in dicts but not in MutableMapping def __repr__(self): return repr(self.data) Modified: python/branches/py3k/Lib/test/test_userdict.py ============================================================================== --- python/branches/py3k/Lib/test/test_userdict.py (original) +++ python/branches/py3k/Lib/test/test_userdict.py Tue Feb 5 23:54:43 2008 @@ -2,7 +2,7 @@ import unittest from test import test_support, mapping_tests -import UserDict +import collections d0 = {} d1 = {"one": 1} @@ -12,36 +12,36 @@ d5 = {"one": 1, "two": 1} class UserDictTest(mapping_tests.TestHashMappingProtocol): - type2test = UserDict.IterableUserDict + type2test = collections.UserDict def test_all(self): # Test constructors - u = UserDict.UserDict() - u0 = UserDict.UserDict(d0) - u1 = UserDict.UserDict(d1) - u2 = UserDict.IterableUserDict(d2) - - uu = UserDict.UserDict(u) - uu0 = UserDict.UserDict(u0) - uu1 = UserDict.UserDict(u1) - uu2 = UserDict.UserDict(u2) + u = collections.UserDict() + u0 = collections.UserDict(d0) + u1 = collections.UserDict(d1) + u2 = collections.UserDict(d2) + + uu = collections.UserDict(u) + uu0 = collections.UserDict(u0) + uu1 = collections.UserDict(u1) + uu2 = collections.UserDict(u2) # keyword arg constructor - self.assertEqual(UserDict.UserDict(one=1, two=2), d2) + self.assertEqual(collections.UserDict(one=1, two=2), d2) # item sequence constructor - self.assertEqual(UserDict.UserDict([('one',1), ('two',2)]), d2) - self.assertEqual(UserDict.UserDict(dict=[('one',1), ('two',2)]), d2) + self.assertEqual(collections.UserDict([('one',1), ('two',2)]), d2) + self.assertEqual(collections.UserDict(dict=[('one',1), ('two',2)]), d2) # both together - self.assertEqual(UserDict.UserDict([('one',1), ('two',2)], two=3, three=5), d3) + self.assertEqual(collections.UserDict([('one',1), ('two',2)], two=3, three=5), d3) # alternate constructor - self.assertEqual(UserDict.UserDict.fromkeys('one two'.split()), d4) - self.assertEqual(UserDict.UserDict().fromkeys('one two'.split()), d4) - self.assertEqual(UserDict.UserDict.fromkeys('one two'.split(), 1), d5) - self.assertEqual(UserDict.UserDict().fromkeys('one two'.split(), 1), d5) + self.assertEqual(collections.UserDict.fromkeys('one two'.split()), d4) + self.assertEqual(collections.UserDict().fromkeys('one two'.split()), d4) + self.assertEqual(collections.UserDict.fromkeys('one two'.split(), 1), d5) + self.assertEqual(collections.UserDict().fromkeys('one two'.split(), 1), d5) self.assert_(u1.fromkeys('one two'.split()) is not u1) - self.assert_(isinstance(u1.fromkeys('one two'.split()), UserDict.UserDict)) - self.assert_(isinstance(u2.fromkeys('one two'.split()), UserDict.IterableUserDict)) + self.assert_(isinstance(u1.fromkeys('one two'.split()), collections.UserDict)) + self.assert_(isinstance(u2.fromkeys('one two'.split()), collections.UserDict)) # Test __repr__ self.assertEqual(str(u0), str(d0)) @@ -59,7 +59,7 @@ self.assertRaises(KeyError, u1.__getitem__, "two") # Test __setitem__ - u3 = UserDict.UserDict(u2) + u3 = collections.UserDict(u2) u3["two"] = 2 u3["three"] = 3 @@ -74,11 +74,11 @@ # Test copy() u2a = u2.copy() self.assertEqual(u2a, u2) - u2b = UserDict.UserDict(x=42, y=23) + u2b = collections.UserDict(x=42, y=23) u2c = u2b.copy() # making a copy of a UserDict is special cased self.assertEqual(u2b, u2c) - class MyUserDict(UserDict.UserDict): + class MyUserDict(collections.UserDict): def display(self): print(self) m2 = MyUserDict(u2) @@ -101,15 +101,9 @@ self.assertEqual(i in u0, i in d0) # Test update - t = UserDict.UserDict() + t = collections.UserDict() t.update(u2) self.assertEqual(t, u2) - class Items: - def items(self): - return (("x", 42), ("y", 23)) - t = UserDict.UserDict() - t.update(Items()) - self.assertEqual(t, {"x": 42, "y": 23}) # Test get for i in u2.keys(): @@ -127,13 +121,13 @@ self.assertEqual(set(ikeys), set(keys)) # Test setdefault - t = UserDict.UserDict() + t = collections.UserDict() self.assertEqual(t.setdefault("x", 42), 42) self.assert_("x" in t) self.assertEqual(t.setdefault("x", 23), 42) # Test pop - t = UserDict.UserDict(x=42) + t = collections.UserDict(x=42) self.assertEqual(t.pop("x"), 42) self.assertRaises(KeyError, t.pop, "x") self.assertEqual(t.pop("x", 1), 1) @@ -141,19 +135,19 @@ self.assertEqual(t.pop("x", 1), 42) # Test popitem - t = UserDict.UserDict(x=42) + t = collections.UserDict(x=42) self.assertEqual(t.popitem(), ("x", 42)) self.assertRaises(KeyError, t.popitem) def test_missing(self): # Make sure UserDict doesn't have a __missing__ method - self.assertEqual(hasattr(UserDict, "__missing__"), False) + self.assertEqual(hasattr(collections.UserDict, "__missing__"), False) # Test several cases: # (D) subclass defines __missing__ method returning a value # (E) subclass defines __missing__ method raising RuntimeError # (F) subclass sets __missing__ instance variable (no effect) # (G) subclass doesn't define __missing__ at a all - class D(UserDict.UserDict): + class D(collections.UserDict): def __missing__(self, key): return 42 d = D({1: 2, 3: 4}) @@ -162,7 +156,7 @@ self.assert_(2 not in d) self.assert_(2 not in d.keys()) self.assertEqual(d[2], 42) - class E(UserDict.UserDict): + class E(collections.UserDict): def __missing__(self, key): raise RuntimeError(key) e = E() @@ -172,11 +166,11 @@ self.assertEqual(err.args, (42,)) else: self.fail("e[42] didn't raise RuntimeError") - class F(UserDict.UserDict): + class F(collections.UserDict): def __init__(self): # An instance variable __missing__ should have no effect self.__missing__ = lambda key: None - UserDict.UserDict.__init__(self) + collections.UserDict.__init__(self) f = F() try: f[42] @@ -184,7 +178,7 @@ self.assertEqual(err.args, (42,)) else: self.fail("f[42] didn't raise KeyError") - class G(UserDict.UserDict): + class G(collections.UserDict): pass g = G() try: From python-3000-checkins at python.org Wed Feb 6 01:07:11 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 01:07:11 +0100 (CET) Subject: [Python-3000-checkins] r60610 - python/branches/py3k/Lib/test/mapping_tests.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_cfgparser.py python/branches/py3k/Lib/test/test_dict.py python/branches/py3k/Lib/test/test_extcall.py python/branches/py3k/Lib/test/test_funcattrs.py Message-ID: <20080206000711.DAF251E4010@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 01:07:11 2008 New Revision: 60610 Modified: python/branches/py3k/Lib/test/mapping_tests.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_cfgparser.py python/branches/py3k/Lib/test/test_dict.py python/branches/py3k/Lib/test/test_extcall.py python/branches/py3k/Lib/test/test_funcattrs.py Log: Migrate remaining tests from UserDict.UserDict to collections.UserDict. Modified: python/branches/py3k/Lib/test/mapping_tests.py ============================================================================== --- python/branches/py3k/Lib/test/mapping_tests.py (original) +++ python/branches/py3k/Lib/test/mapping_tests.py Wed Feb 6 01:07:11 2008 @@ -1,6 +1,6 @@ # tests common to dict and UserDict import unittest -import UserDict +import collections class BasicTestMappingProtocol(unittest.TestCase): @@ -438,11 +438,11 @@ # self.assert_(type(dictlike.fromkeys('a')) is dictlike) class mydict(self.type2test): def __new__(cls): - return UserDict.UserDict() + return collections.UserDict() ud = mydict.fromkeys('ab') self.assertEqual(ud, {'a':None, 'b':None}) # FIXME: the following won't work with UserDict, because it's an old style class - # self.assert_(isinstance(ud, UserDict.UserDict)) + # self.assert_(isinstance(ud, collections.UserDict)) self.assertRaises(TypeError, dict.fromkeys) class Exc(Exception): pass @@ -574,10 +574,10 @@ TestMappingProtocol.test_fromkeys(self) class mydict(self.type2test): def __new__(cls): - return UserDict.UserDict() + return collections.UserDict() ud = mydict.fromkeys('ab') self.assertEqual(ud, {'a':None, 'b':None}) - self.assert_(isinstance(ud, UserDict.UserDict)) + self.assert_(isinstance(ud, collections.UserDict)) def test_pop(self): TestMappingProtocol.test_pop(self) Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Wed Feb 6 01:07:11 2008 @@ -5,7 +5,7 @@ run_with_locale from operator import neg -import sys, warnings, random, UserDict, io, rational +import sys, warnings, random, collections, io, rational warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) warnings.filterwarnings("ignore", "integer argument expected", @@ -400,7 +400,7 @@ # Verify locals stores (used by list comps) eval('[locals() for i in (2,3)]', g, d) - eval('[locals() for i in (2,3)]', g, UserDict.UserDict()) + eval('[locals() for i in (2,3)]', g, collections.UserDict()) class SpreadSheet: "Sample application showing nested, calculated lookups." Modified: python/branches/py3k/Lib/test/test_cfgparser.py ============================================================================== --- python/branches/py3k/Lib/test/test_cfgparser.py (original) +++ python/branches/py3k/Lib/test/test_cfgparser.py Wed Feb 6 01:07:11 2008 @@ -1,11 +1,11 @@ import ConfigParser import io import unittest -import UserDict +import collections from test import test_support -class SortedDict(UserDict.UserDict): +class SortedDict(collections.UserDict): def items(self): return sorted(self.data.items()) Modified: python/branches/py3k/Lib/test/test_dict.py ============================================================================== --- python/branches/py3k/Lib/test/test_dict.py (original) +++ python/branches/py3k/Lib/test/test_dict.py Wed Feb 6 01:07:11 2008 @@ -1,7 +1,7 @@ import unittest from test import test_support -import sys, UserDict, random, string +import sys, collections, random, string class DictTest(unittest.TestCase): @@ -209,10 +209,10 @@ self.assert_(type(dictlike().fromkeys('a')) is dictlike) class mydict(dict): def __new__(cls): - return UserDict.UserDict() + return collections.UserDict() ud = mydict.fromkeys('ab') self.assertEqual(ud, {'a':None, 'b':None}) - self.assert_(isinstance(ud, UserDict.UserDict)) + self.assert_(isinstance(ud, collections.UserDict)) self.assertRaises(TypeError, dict.fromkeys) class Exc(Exception): pass Modified: python/branches/py3k/Lib/test/test_extcall.py ============================================================================== --- python/branches/py3k/Lib/test/test_extcall.py (original) +++ python/branches/py3k/Lib/test/test_extcall.py Wed Feb 6 01:07:11 2008 @@ -1,6 +1,6 @@ from test.test_support import verify, verbose, TestFailed, sortdict from UserList import UserList -from UserDict import UserDict +from collections import UserDict def e(a, b): print(a, b) Modified: python/branches/py3k/Lib/test/test_funcattrs.py ============================================================================== --- python/branches/py3k/Lib/test/test_funcattrs.py (original) +++ python/branches/py3k/Lib/test/test_funcattrs.py Wed Feb 6 01:07:11 2008 @@ -175,7 +175,7 @@ class FunctionDictsTest(FuncAttrsTest): def test_setting_dict_to_invalid(self): self.cannot_set_attr(self.b, '__dict__', None, TypeError) - from UserDict import UserDict + from collections import UserDict d = UserDict({'known_attr': 7}) self.cannot_set_attr(self.fi.a.__func__, '__dict__', d, TypeError) From python-3000-checkins at python.org Wed Feb 6 01:15:42 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 01:15:42 +0100 (CET) Subject: [Python-3000-checkins] r60611 - in python/branches/py3k: Lib/UserDict.py Misc/NEWS Message-ID: <20080206001542.B75831E4010@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 01:15:42 2008 New Revision: 60611 Removed: python/branches/py3k/Lib/UserDict.py Modified: python/branches/py3k/Misc/NEWS Log: Remove the old UserDict module. Deleted: /python/branches/py3k/Lib/UserDict.py ============================================================================== --- /python/branches/py3k/Lib/UserDict.py Wed Feb 6 01:15:42 2008 +++ (empty file) @@ -1,81 +0,0 @@ -"""A more or less complete user-defined wrapper around dictionary objects.""" - -class UserDict: - def __init__(self, dict=None, **kwargs): - self.data = {} - if dict is not None: - self.update(dict) - if len(kwargs): - self.update(kwargs) - def __repr__(self): return repr(self.data) - def __eq__(self, dict): - if isinstance(dict, UserDict): - return self.data == dict.data - else: - return self.data == dict - def __ne__(self, dict): - if isinstance(dict, UserDict): - return self.data != dict.data - else: - return self.data != dict - def __len__(self): return len(self.data) - def __getitem__(self, key): - if key in self.data: - return self.data[key] - if hasattr(self.__class__, "__missing__"): - return self.__class__.__missing__(self, key) - raise KeyError(key) - def __setitem__(self, key, item): self.data[key] = item - def __delitem__(self, key): del self.data[key] - def clear(self): self.data.clear() - def copy(self): - if self.__class__ is UserDict: - return UserDict(self.data.copy()) - import copy - data = self.data - try: - self.data = {} - c = copy.copy(self) - finally: - self.data = data - c.update(self) - return c - def keys(self): return self.data.keys() - def items(self): return self.data.items() - def values(self): return self.data.values() - def update(self, dict=None, **kwargs): - if dict is None: - pass - elif isinstance(dict, UserDict): - self.data.update(dict.data) - elif isinstance(dict, type({})) or not hasattr(dict, 'items'): - self.data.update(dict) - else: - for k, v in dict.items(): - self[k] = v - if len(kwargs): - self.data.update(kwargs) - def get(self, key, failobj=None): - if key not in self: - return failobj - return self[key] - def setdefault(self, key, failobj=None): - if key not in self: - self[key] = failobj - return self[key] - def pop(self, key, *args): - return self.data.pop(key, *args) - def popitem(self): - return self.data.popitem() - def __contains__(self, key): - return key in self.data - @classmethod - def fromkeys(cls, iterable, value=None): - d = cls() - for key in iterable: - d[key] = value - return d - -class IterableUserDict(UserDict): - def __iter__(self): - return iter(self.data) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Feb 6 01:15:42 2008 @@ -75,7 +75,7 @@ - Created new UserDict class in collections module. This one inherits from and complies with the MutableMapping ABC. - XXX still need to covert old UserDict based tests and eliminate the old UserDict module. + XXX still need to move docs - Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. From python-3000-checkins at python.org Wed Feb 6 02:23:58 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 02:23:58 +0100 (CET) Subject: [Python-3000-checkins] r60612 - in python/branches/py3k: Doc/library/collections.rst Doc/library/userdict.rst Misc/NEWS Message-ID: <20080206012358.719661E4010@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 02:23:58 2008 New Revision: 60612 Modified: python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/userdict.rst python/branches/py3k/Misc/NEWS Log: Update docs for collections ABCs and for collections.UserDict. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Wed Feb 6 02:23:58 2008 @@ -32,25 +32,32 @@ :class:`collections.Iterable` Defines ``__iter__()`` :class:`collections.Iterator` Derived from :class:`Iterable` and in addition defines ``__next__()`` +:class:`collections.Sized` Defines ``__len__()`` :class:`collections.Mapping` Derived from :class:`Container`, :class:`Iterable`, and :class:`Sized`, and in addition defines ``__getitem__()``, ``get()``, ``__contains__()``, ``__len__()``, + ``__eq__()``, ``__ne__()``, ``__iter__()``, ``keys()``, ``items()``, and ``values()`` :class:`collections.MutableMapping` Derived from :class:`Mapping` +:class:`collections.Sequence` Derived from :class:`Container`, + :class:`Iterable`, and :class:`Sized`, + and in addition defines + ``__getitem__()` :class:`collections.MutableSequence` Derived from :class:`Sequence` +:class:`collections.Set` Derived from :class:`Container`, :class:`Iterable`, :class:`Sized`. + add in addition defines + ``__le__()``, ``__lt__()``, ``__eq__()``, + ``__and__()``, ``__or__()``, ``__sub__()``, + ``__xor__()``, and ``isdisjoint()``, :class:`collections.MutableSet` Derived from :class:`Set` and in addition defines ``add()``, ``clear()``, ``discard()``, ``pop()``, - and ``toggle()`` -:class:`collections.Sequence` Derived from :class:`Container`, - :class:`Iterable`, and :class:`Sized`, - and in addition defines - ``__getitem__()`` -:class:`collections.Set` Derived from :class:`Container`, :class:`Iterable`, and :class:`Sized` -:class:`collections.Sized` Defines ``__len__()`` + ``remove()``, ``__ior__()``, ``__iand__()``, + ``__ixor__()``, and ``__isub__()`` + ===================================== ======================================== .. XXX Have not included them all and the notes are incomplete @@ -577,3 +584,30 @@ .. [#] For information on the double-star-operator see :ref:`tut-unpacking-arguments` and :ref:`calls`. + + + +:class:`UserDict` objects +---------------------- + +The class, :class:`UserDict` acts as a wrapper around dictionary objects. +The need for this class has been partially supplanted by the ability to +subclass directly from :class:`dict`; however, this class can be easier +to work with because the underlying dictionary is accessible as an +attribute. + +.. class:: UserDict([initialdata]) + + Class that simulates a dictionary. The instance's contents are kept in a + regular dictionary, which is accessible via the :attr:`data` attribute of + :class:`UserDict` instances. If *initialdata* is provided, :attr:`data` is + initialized with its contents; note that a reference to *initialdata* will not + be kept, allowing it be used for other purposes. + +In addition to supporting the methods and operations of mappings, +:class:`UserDict` and :class:`IterableUserDict` instances +provide the following attribute: + +.. attribute:: UserDict.data + + A real dictionary used to store the contents of the :class:`UserDict` class. Modified: python/branches/py3k/Doc/library/userdict.rst ============================================================================== --- python/branches/py3k/Doc/library/userdict.rst (original) +++ python/branches/py3k/Doc/library/userdict.rst Wed Feb 6 02:23:58 2008 @@ -1,56 +1,4 @@ -:mod:`UserDict` --- Class wrapper for dictionary objects -======================================================== - -.. module:: UserDict - :synopsis: Class wrapper for dictionary objects. - - -The module defines a mixin, :class:`DictMixin`, defining all dictionary methods -for classes that already have a minimum mapping interface. This greatly -simplifies writing classes that need to be substitutable for dictionaries (such -as the shelve module). - -This also module defines a class, :class:`UserDict`, that acts as a wrapper -around dictionary objects. The need for this class has been largely supplanted -by the ability to subclass directly from :class:`dict` (a feature that became -available starting with Python version 2.2). Prior to the introduction of -:class:`dict`, the :class:`UserDict` class was used to create dictionary-like -sub-classes that obtained new behaviors by overriding existing methods or adding -new ones. - -The :mod:`UserDict` module defines the :class:`UserDict` class and -:class:`DictMixin`: - - -.. class:: UserDict([initialdata]) - - Class that simulates a dictionary. The instance's contents are kept in a - regular dictionary, which is accessible via the :attr:`data` attribute of - :class:`UserDict` instances. If *initialdata* is provided, :attr:`data` is - initialized with its contents; note that a reference to *initialdata* will not - be kept, allowing it be used for other purposes. - - .. note:: - - For backward compatibility, instances of :class:`UserDict` are not - iterable. - - -.. class:: IterableUserDict([initialdata]) - - Subclass of :class:`UserDict` that supports direct iteration (e.g. ``for key in - myDict``). - -In addition to supporting the methods and operations of mappings (see section -:ref:`typesmapping`), :class:`UserDict` and :class:`IterableUserDict` instances -provide the following attribute: - - -.. attribute:: IterableUserDict.data - - A real dictionary used to store the contents of the :class:`UserDict` class. - :mod:`UserList` --- Class wrapper for list objects ================================================== Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Feb 6 02:23:58 2008 @@ -75,7 +75,6 @@ - Created new UserDict class in collections module. This one inherits from and complies with the MutableMapping ABC. - XXX still need to move docs - Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. From python-3000-checkins at python.org Wed Feb 6 14:30:46 2008 From: python-3000-checkins at python.org (mark.summerfield) Date: Wed, 6 Feb 2008 14:30:46 +0100 (CET) Subject: [Python-3000-checkins] r60615 - python/branches/py3k/Doc/library/collections.rst Message-ID: <20080206133046.5F7F61E4021@bag.python.org> Author: mark.summerfield Date: Wed Feb 6 14:30:44 2008 New Revision: 60615 Modified: python/branches/py3k/Doc/library/collections.rst Log: Fixed a table and a title that were broken. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Wed Feb 6 14:30:44 2008 @@ -24,9 +24,9 @@ a class provides a particular interface, for example, is it hashable or a mapping. The ABCs provided include those in the following table: -===================================== ======================================== +===================================== ================================================================================ ABC Notes -===================================== ======================================== +===================================== ================================================================================ :class:`collections.Container` Defines ``__contains__()`` :class:`collections.Hashable` Defines ``__hash__()`` :class:`collections.Iterable` Defines ``__iter__()`` @@ -45,23 +45,25 @@ :class:`collections.Sequence` Derived from :class:`Container`, :class:`Iterable`, and :class:`Sized`, and in addition defines - ``__getitem__()` + ``__getitem__()`` :class:`collections.MutableSequence` Derived from :class:`Sequence` -:class:`collections.Set` Derived from :class:`Container`, :class:`Iterable`, :class:`Sized`. +:class:`collections.Set` Derived from :class:`Container`, + :class:`Iterable`, and :class:`Sized`, add in addition defines - ``__le__()``, ``__lt__()``, ``__eq__()``, - ``__and__()``, ``__or__()``, ``__sub__()``, + ``__le__()``, ``__lt__()``, + ``__eq__()``, ``__and__()``, + ``__or__()``, ``__sub__()``, ``__xor__()``, and ``isdisjoint()``, :class:`collections.MutableSet` Derived from :class:`Set` and in addition defines ``add()``, ``clear()``, ``discard()``, ``pop()``, - ``remove()``, ``__ior__()``, ``__iand__()``, - ``__ixor__()``, and ``__isub__()`` - -===================================== ======================================== + ``remove()``, ``__ior__()``, + ``__iand__()``, ``__ixor__()``, and + ``__isub__()`` +===================================== ================================================================================ .. XXX Have not included them all and the notes are incomplete -.. Deliberately did one row wide to get a neater output +.. long = lines improves the layout These ABCs allow us to ask classes or instances if they provide particular functionality, for example:: @@ -588,7 +590,7 @@ :class:`UserDict` objects ----------------------- +------------------------- The class, :class:`UserDict` acts as a wrapper around dictionary objects. The need for this class has been partially supplanted by the ability to From python-3000-checkins at python.org Wed Feb 6 15:31:36 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 6 Feb 2008 15:31:36 +0100 (CET) Subject: [Python-3000-checkins] r60617 - in python/branches/py3k: Doc/howto/advocacy.rst Doc/howto/curses.rst Doc/howto/regex.rst Doc/howto/unicode.rst Doc/library/curses.rst Doc/library/re.rst Lib/DocXMLRPCServer.py Lib/_abcoll.py Lib/distutils/sysconfig.py Lib/pydoc.py Lib/re.py Lib/tarfile.py Lib/test/output/test_profile Lib/test/profilee.py Lib/test/test_docxmlrpc.py Lib/test/test_profile.py Lib/test/test_sys.py Lib/test/test_trace.py Lib/test/test_wave.py Misc/python-mode.el Objects/classobject.c Objects/dictobject.c Objects/frameobject.c Objects/listobject.c Objects/methodobject.c Objects/setobject.c Objects/tupleobject.c Objects/unicodeobject.c Python/compile.c Message-ID: <20080206143136.A81BA1E4021@bag.python.org> Author: christian.heimes Date: Wed Feb 6 15:31:34 2008 New Revision: 60617 Added: python/branches/py3k/Lib/test/profilee.py - copied unchanged from r60616, python/trunk/Lib/test/profilee.py Removed: python/branches/py3k/Lib/test/output/test_profile Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/howto/advocacy.rst python/branches/py3k/Doc/howto/curses.rst python/branches/py3k/Doc/howto/regex.rst python/branches/py3k/Doc/howto/unicode.rst python/branches/py3k/Doc/library/curses.rst python/branches/py3k/Doc/library/re.rst python/branches/py3k/Lib/DocXMLRPCServer.py python/branches/py3k/Lib/_abcoll.py python/branches/py3k/Lib/distutils/sysconfig.py python/branches/py3k/Lib/pydoc.py python/branches/py3k/Lib/re.py python/branches/py3k/Lib/tarfile.py python/branches/py3k/Lib/test/test_docxmlrpc.py python/branches/py3k/Lib/test/test_profile.py (contents, props changed) python/branches/py3k/Lib/test/test_sys.py python/branches/py3k/Lib/test/test_trace.py python/branches/py3k/Lib/test/test_wave.py python/branches/py3k/Misc/python-mode.el python/branches/py3k/Objects/classobject.c python/branches/py3k/Objects/dictobject.c python/branches/py3k/Objects/frameobject.c python/branches/py3k/Objects/listobject.c python/branches/py3k/Objects/methodobject.c python/branches/py3k/Objects/setobject.c python/branches/py3k/Objects/tupleobject.c python/branches/py3k/Objects/unicodeobject.c python/branches/py3k/Python/compile.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........ Modified: python/branches/py3k/Doc/howto/advocacy.rst ============================================================================== --- python/branches/py3k/Doc/howto/advocacy.rst (original) +++ python/branches/py3k/Doc/howto/advocacy.rst Wed Feb 6 15:31:34 2008 @@ -265,7 +265,7 @@ **What are the restrictions on Python's use?** They're practically nonexistent. Consult the :file:`Misc/COPYRIGHT` file in the -source distribution, or http://www.python.org/doc/Copyright.html for the full +source distribution, or the section :ref:`history-and-license` for the full language, but it boils down to three conditions. * You have to leave the copyright notice on the software; if you don't include Modified: python/branches/py3k/Doc/howto/curses.rst ============================================================================== --- python/branches/py3k/Doc/howto/curses.rst (original) +++ python/branches/py3k/Doc/howto/curses.rst Wed Feb 6 15:31:34 2008 @@ -1,3 +1,5 @@ +.. _curses-howto: + ********************************** Curses Programming with Python ********************************** Modified: python/branches/py3k/Doc/howto/regex.rst ============================================================================== --- python/branches/py3k/Doc/howto/regex.rst (original) +++ python/branches/py3k/Doc/howto/regex.rst Wed Feb 6 15:31:34 2008 @@ -1,3 +1,5 @@ +.. _regex-howto: + **************************** Regular Expression HOWTO **************************** Modified: python/branches/py3k/Doc/howto/unicode.rst ============================================================================== --- python/branches/py3k/Doc/howto/unicode.rst (original) +++ python/branches/py3k/Doc/howto/unicode.rst Wed Feb 6 15:31:34 2008 @@ -276,7 +276,7 @@ Encodings are specified as strings containing the encoding's name. Python comes with roughly 100 different encodings; see the Python Library Reference at - for a list. Some encodings +:ref:`standard-encodings` for a list. Some encodings have multiple names; for example, 'latin-1', 'iso_8859_1' and '8859' are all synonyms for the same encoding. Modified: python/branches/py3k/Doc/library/curses.rst ============================================================================== --- python/branches/py3k/Doc/library/curses.rst (original) +++ python/branches/py3k/Doc/library/curses.rst Wed Feb 6 15:31:34 2008 @@ -45,9 +45,9 @@ Convenience function to ensure proper terminal setup and resetting on application entry and exit. - `Curses Programming with Python `_ + :ref:`curses-howto` Tutorial material on using curses with Python, by Andrew Kuchling and Eric - Raymond, is available on the Python Web site. + Raymond. The :file:`Demo/curses/` directory in the Python source distribution contains some example programs using the curses bindings provided by this module. Modified: python/branches/py3k/Doc/library/re.rst ============================================================================== --- python/branches/py3k/Doc/library/re.rst (original) +++ python/branches/py3k/Doc/library/re.rst Wed Feb 6 15:31:34 2008 @@ -65,8 +65,7 @@ above, or almost any textbook about compiler construction. A brief explanation of the format of regular expressions follows. For further -information and a gentler presentation, consult the Regular Expression HOWTO, -accessible from http://www.python.org/doc/howto/. +information and a gentler presentation, consult the :ref:`regex-howto`. Regular expressions can contain both special and ordinary characters. Most ordinary characters, like ``'A'``, ``'a'``, or ``'0'``, are the simplest regular Modified: python/branches/py3k/Lib/DocXMLRPCServer.py ============================================================================== --- python/branches/py3k/Lib/DocXMLRPCServer.py (original) +++ python/branches/py3k/Lib/DocXMLRPCServer.py Wed Feb 6 15:31:34 2008 @@ -30,7 +30,7 @@ results = [] here = 0 - # XXX Note that this regular expressions does not allow for the + # XXX Note that this regular expression does not allow for the # hyperlinking of arbitrary strings being used as method # names. Only methods with names consisting of word characters # and '.'s are hyperlinked. @@ -52,7 +52,7 @@ url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) results.append('%s' % (url, escape(all))) elif pep: - url = 'http://www.python.org/peps/pep-%04d.html' % int(pep) + url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep) results.append('%s' % (url, escape(all))) elif text[end:end+1] == '(': results.append(self.namelink(name, methods, funcs, classes)) Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Wed Feb 6 15:31:34 2008 @@ -385,6 +385,7 @@ def __ne__(self, other): return not (self == other) + class MappingView(metaclass=ABCMeta): def __init__(self, mapping): Modified: python/branches/py3k/Lib/distutils/sysconfig.py ============================================================================== --- python/branches/py3k/Lib/distutils/sysconfig.py (original) +++ python/branches/py3k/Lib/distutils/sysconfig.py Wed Feb 6 15:31:34 2008 @@ -37,8 +37,12 @@ # different (hard-wired) directories. # Setup.local is available for Makefile builds including VPATH builds, # Setup.dist is available on Windows -python_build = any(os.path.isfile(os.path.join(project_base, "Modules", fn)) - for fn in ("Setup.dist", "Setup.local")) +def _python_build(): + for fn in ("Setup.dist", "Setup.local"): + if os.path.isfile(os.path.join(project_base, "Modules", fn)): + return True + return False +python_build = _python_build() def get_python_version(): """Return a string containing the major and minor Python version, Modified: python/branches/py3k/Lib/pydoc.py ============================================================================== --- python/branches/py3k/Lib/pydoc.py (original) +++ python/branches/py3k/Lib/pydoc.py Wed Feb 6 15:31:34 2008 @@ -536,7 +536,7 @@ url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) results.append('%s' % (url, escape(all))) elif pep: - url = 'http://www.python.org/peps/pep-%04d' % int(pep) + url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep) results.append('%s' % (url, escape(all))) elif text[end:end+1] == '(': results.append(self.namelink(name, methods, funcs, classes)) Modified: python/branches/py3k/Lib/re.py ============================================================================== --- python/branches/py3k/Lib/re.py (original) +++ python/branches/py3k/Lib/re.py Wed Feb 6 15:31:34 2008 @@ -294,8 +294,8 @@ p.append(sre_parse.SubPattern(s, [ (SUBPATTERN, (len(p)+1, sre_parse.parse(phrase, flags))), ])) + s.groups = len(p)+1 p = sre_parse.SubPattern(s, [(BRANCH, (None, p))]) - s.groups = len(p) self.scanner = sre_compile.compile(p) def scan(self, string): result = [] Modified: python/branches/py3k/Lib/tarfile.py ============================================================================== --- python/branches/py3k/Lib/tarfile.py (original) +++ python/branches/py3k/Lib/tarfile.py Wed Feb 6 15:31:34 2008 @@ -2005,15 +2005,11 @@ for tarinfo in members: if tarinfo.isdir(): - # Extract directory with a safe mode, so that - # all files below can be extracted as well. - try: - os.makedirs(os.path.join(path, tarinfo.name), 0o700) - except EnvironmentError: - pass + # Extract directories with a safe mode. directories.append(tarinfo) - else: - self.extract(tarinfo, path) + tarinfo = copy.copy(tarinfo) + tarinfo.mode = 0o700 + self.extract(tarinfo, path) # Reverse sort directories. directories.sort(key=lambda a: a.name) @@ -2118,6 +2114,8 @@ # Create all upper directories. upperdirs = os.path.dirname(targetpath) if upperdirs and not os.path.exists(upperdirs): + # Create directories that are not part of the archive with + # default permissions. os.makedirs(upperdirs) if tarinfo.islnk() or tarinfo.issym(): @@ -2154,7 +2152,9 @@ """Make a directory called targetpath. """ try: - os.mkdir(targetpath) + # Use a safe mode for the directory, the real mode is set + # later in _extract_member(). + os.mkdir(targetpath, 0o700) except EnvironmentError as e: if e.errno != errno.EEXIST: raise Deleted: /python/branches/py3k/Lib/test/output/test_profile ============================================================================== --- /python/branches/py3k/Lib/test/output/test_profile Wed Feb 6 15:31:34 2008 +++ (empty file) @@ -1,97 +0,0 @@ -test_profile - 125 function calls (105 primitive calls) in 1.000 CPU seconds - - Ordered by: standard name - - ncalls tottime percall cumtime percall filename:lineno(function) - 4 0.000 0.000 0.000 0.000 :0(append) - 4 0.000 0.000 0.000 0.000 :0(exc_info) - 1 0.000 0.000 1.000 1.000 :0(exec) - 12 0.000 0.000 0.012 0.001 :0(hasattr) - 1 0.000 0.000 0.000 0.000 :0(setprofile) - 1 0.000 0.000 1.000 1.000 :1() - 2 0.000 0.000 0.000 0.000 io.py:1213(flush) - 1 0.000 0.000 0.000 0.000 io.py:269(flush) - 1 0.000 0.000 0.000 0.000 io.py:656(closed) - 1 0.000 0.000 0.000 0.000 io.py:874(flush) - 0 0.000 0.000 profile:0(profiler) - 1 0.000 0.000 1.000 1.000 profile:0(testfunc()) - 8 0.064 0.008 0.080 0.010 test_profile.py:103(subhelper) - 28 0.028 0.001 0.028 0.001 test_profile.py:115(__getattr__) - 1 0.270 0.270 1.000 1.000 test_profile.py:30(testfunc) - 23/3 0.150 0.007 0.170 0.057 test_profile.py:40(factorial) - 20 0.020 0.001 0.020 0.001 test_profile.py:53(mul) - 2 0.040 0.020 0.600 0.300 test_profile.py:60(helper) - 4 0.116 0.029 0.120 0.030 test_profile.py:78(helper1) - 2 0.000 0.000 0.140 0.070 test_profile.py:89(helper2_indirect) - 8 0.312 0.039 0.400 0.050 test_profile.py:93(helper2) - - - Ordered by: standard name - -Function called... -:0(append) -> -:0(exc_info) -> -:0(exec) -> :1()(1) 1.000 - io.py:1213(flush)(2) 0.000 -:0(hasattr) -> test_profile.py:115(__getattr__)(12) 0.028 -:0(setprofile) -> -:1() -> test_profile.py:30(testfunc)(1) 1.000 -io.py:1213(flush) -> io.py:269(flush)(1) 0.000 - io.py:874(flush)(1) 0.000 -io.py:269(flush) -> -io.py:656(closed) -> -io.py:874(flush) -> io.py:656(closed)(1) 0.000 -profile:0(profiler) -> profile:0(testfunc())(1) 1.000 -profile:0(testfunc()) -> :0(exec)(1) 1.000 - :0(setprofile)(1) 0.000 -test_profile.py:103(subhelper) -> test_profile.py:115(__getattr__)(16) 0.028 -test_profile.py:115(__getattr__) -> -test_profile.py:30(testfunc) -> test_profile.py:40(factorial)(1) 0.170 - test_profile.py:60(helper)(2) 0.600 -test_profile.py:40(factorial) -> test_profile.py:40(factorial)(20) 0.170 - test_profile.py:53(mul)(20) 0.020 -test_profile.py:53(mul) -> -test_profile.py:60(helper) -> test_profile.py:78(helper1)(4) 0.120 - test_profile.py:89(helper2_indirect)(2) 0.140 - test_profile.py:93(helper2)(6) 0.400 -test_profile.py:78(helper1) -> :0(append)(4) 0.000 - :0(exc_info)(4) 0.000 - :0(hasattr)(4) 0.012 -test_profile.py:89(helper2_indirect) -> test_profile.py:40(factorial)(2) 0.170 - test_profile.py:93(helper2)(2) 0.400 -test_profile.py:93(helper2) -> :0(hasattr)(8) 0.012 - test_profile.py:103(subhelper)(8) 0.080 - - - Ordered by: standard name - -Function was called by... -:0(append) <- test_profile.py:78(helper1)(4) 0.120 -:0(exc_info) <- test_profile.py:78(helper1)(4) 0.120 -:0(exec) <- profile:0(testfunc())(1) 1.000 -:0(hasattr) <- test_profile.py:78(helper1)(4) 0.120 - test_profile.py:93(helper2)(8) 0.400 -:0(setprofile) <- profile:0(testfunc())(1) 1.000 -:1() <- :0(exec)(1) 1.000 -io.py:1213(flush) <- :0(exec)(2) 1.000 -io.py:269(flush) <- io.py:1213(flush)(1) 0.000 -io.py:656(closed) <- io.py:874(flush)(1) 0.000 -io.py:874(flush) <- io.py:1213(flush)(1) 0.000 -profile:0(profiler) <- -profile:0(testfunc()) <- profile:0(profiler)(1) 0.000 -test_profile.py:103(subhelper) <- test_profile.py:93(helper2)(8) 0.400 -test_profile.py:115(__getattr__) <- :0(hasattr)(12) 0.012 - test_profile.py:103(subhelper)(16) 0.080 -test_profile.py:30(testfunc) <- :1()(1) 1.000 -test_profile.py:40(factorial) <- test_profile.py:30(testfunc)(1) 1.000 - test_profile.py:40(factorial)(20) 0.170 - test_profile.py:89(helper2_indirect)(2) 0.140 -test_profile.py:53(mul) <- test_profile.py:40(factorial)(20) 0.170 -test_profile.py:60(helper) <- test_profile.py:30(testfunc)(2) 1.000 -test_profile.py:78(helper1) <- test_profile.py:60(helper)(4) 0.600 -test_profile.py:89(helper2_indirect) <- test_profile.py:60(helper)(2) 0.600 -test_profile.py:93(helper2) <- test_profile.py:60(helper)(6) 0.600 - test_profile.py:89(helper2_indirect)(2) 0.140 - - Modified: python/branches/py3k/Lib/test/test_docxmlrpc.py ============================================================================== --- python/branches/py3k/Lib/test/test_docxmlrpc.py (original) +++ python/branches/py3k/Lib/test/test_docxmlrpc.py Wed Feb 6 15:31:34 2008 @@ -117,11 +117,11 @@ The documentation for the "add" method contains the test material. """ self.client.request("GET", "/") - response = self.client.getresponse() + response = self.client.getresponse().read() self.assert_( # This is ugly ... how can it be made better? -b"""
add(x, y)
Add two instances together. This follows PEP008, but has nothing
\nto do with RFC1952. Case should matter: pEp008 and rFC1952.  Things
\nthat start with http and ftp should be auto-linked, too:
\nhttp://google.com.
""" - in response.read()) +b"""
add(x, y)
Add two instances together. This follows PEP008, but has nothing
\nto do with RFC1952. Case should matter: pEp008 and rFC1952.  Things
\nthat start with http and ftp should be auto-linked, too:
\nhttp://google.com.
""" + in response, response) def test_system_methods(self): """Test the precense of three consecutive system.* methods. Modified: python/branches/py3k/Lib/test/test_profile.py ============================================================================== --- python/branches/py3k/Lib/test/test_profile.py (original) +++ python/branches/py3k/Lib/test/test_profile.py Wed Feb 6 15:31:34 2008 @@ -1,123 +1,179 @@ """Test suite for the profile module.""" -import profile, pstats, sys +import os +import sys +import pstats +import unittest +from difflib import unified_diff +from io import StringIO +from test.test_support import run_unittest + +import profile +from test.profilee import testfunc, timer + + +class ProfileTest(unittest.TestCase): + + profilerclass = profile.Profile + methodnames = ['print_stats', 'print_callers', 'print_callees'] + expected_output = {} + + @classmethod + def do_profiling(cls): + results = [] + prof = cls.profilerclass(timer, 0.001) + prof.runctx("testfunc()", globals(), locals()) + results.append(timer()) + for methodname in cls.methodnames: + s = StringIO() + stats = pstats.Stats(prof, stream=s) + stats.strip_dirs().sort_stats("stdname") + getattr(stats, methodname)() + results.append(s.getvalue()) + return results + + def test_cprofile(self): + results = self.do_profiling() + self.assertEqual(results[0], 43000) + for i, method in enumerate(self.methodnames): + if results[i+1] != self.expected_output[method]: + print("Stats.%s output for %s doesn't fit expectation!" % + (method, self.profilerclass.__name__)) + print('\n'.join(unified_diff( + results[i+1].split('\n'), + self.expected_output[method].split('\n')))) + + +def regenerate_expected_output(filename, cls): + filename = filename.rstrip('co') + print('Regenerating %s...' % filename) + results = cls.do_profiling() + + newfile = [] + with open(filename, 'r') as f: + for line in f: + newfile.append(line) + if line[:6] == '#--cut': + break + + with open(filename, 'w') as f: + f.writelines(newfile) + for i, method in enumerate(cls.methodnames): + f.write('%s.expected_output[%r] = """\\\n%s"""\n' % ( + cls.__name__, method, results[i+1])) + f.write('\nif __name__ == "__main__":\n main()\n') -# In order to have reproducible time, we simulate a timer in the global -# variable 'ticks', which represents simulated time in milliseconds. -# (We can't use a helper function increment the timer since it would be -# included in the profile and would appear to consume all the time.) -ticks = 0 - -# IMPORTANT: this is an output test. *ALL* NUMBERS in the expected -# output are relevant. If you change the formatting of pstats, -# please don't just regenerate output/test_profile without checking -# very carefully that not a single number has changed. def test_main(): - global ticks - ticks = 42000 - prof = profile.Profile(timer) - prof.runctx("testfunc()", globals(), locals()) - assert ticks == 43000, ticks - st = pstats.Stats(prof) - st.strip_dirs().sort_stats('stdname').print_stats() - st.print_callees() - st.print_callers() - -def timer(): - return ticks*0.001 - -def testfunc(): - # 1 call - # 1000 ticks total: 270 ticks local, 730 ticks in subfunctions - global ticks - ticks += 99 - helper() # 300 - helper() # 300 - ticks += 171 - factorial(14) # 130 - -def factorial(n): - # 23 calls total - # 170 ticks total, 150 ticks local - # 3 primitive calls, 130, 20 and 20 ticks total - # including 116, 17, 17 ticks local - global ticks - if n > 0: - ticks += n - return mul(n, factorial(n-1)) + run_unittest(ProfileTest) + +def main(): + if '-r' not in sys.argv: + test_main() else: - ticks += 11 - return 1 + regenerate_expected_output(__file__, ProfileTest) + + +# Don't remove this comment. Everything below it is auto-generated. +#--cut-------------------------------------------------------------------------- +ProfileTest.expected_output['print_stats'] = """\ + 126 function calls (106 primitive calls) in 999.751 CPU seconds + + Ordered by: standard name + + ncalls tottime percall cumtime percall filename:lineno(function) + 4 -0.004 -0.001 -0.004 -0.001 :0(append) + 4 -0.004 -0.001 -0.004 -0.001 :0(exc_info) + 1 -0.004 -0.004 999.753 999.753 :0(exec) + 12 -0.024 -0.002 11.964 0.997 :0(hasattr) + 1 0.000 0.000 0.000 0.000 :0(setprofile) + 1 -0.002 -0.002 999.767 999.767 :1() + 2 -0.004 -0.002 -0.010 -0.005 io.py:1213(flush) + 2 -0.002 -0.001 -0.002 -0.001 io.py:656(closed) + 2 -0.004 -0.002 -0.006 -0.003 io.py:874(flush) + 0 0.000 0.000 profile:0(profiler) + 1 -0.002 -0.002 999.751 999.751 profile:0(testfunc()) + 28 27.972 0.999 27.972 0.999 profilee.py:110(__getattr__) + 1 269.996 269.996 999.769 999.769 profilee.py:25(testfunc) + 23/3 149.937 6.519 169.917 56.639 profilee.py:35(factorial) + 20 19.980 0.999 19.980 0.999 profilee.py:48(mul) + 2 39.986 19.993 599.830 299.915 profilee.py:55(helper) + 4 115.984 28.996 119.964 29.991 profilee.py:73(helper1) + 2 -0.006 -0.003 139.946 69.973 profilee.py:84(helper2_indirect) + 8 311.976 38.997 399.912 49.989 profilee.py:88(helper2) + 8 63.976 7.997 79.960 9.995 profilee.py:98(subhelper) + + +""" +ProfileTest.expected_output['print_callers'] = """\ + Ordered by: standard name + +Function was called by... +:0(append) <- profilee.py:73(helper1)(4) 119.964 +:0(exc_info) <- profilee.py:73(helper1)(4) 119.964 +:0(exec) <- profile:0(testfunc())(1) 999.751 +:0(hasattr) <- profilee.py:73(helper1)(4) 119.964 + profilee.py:88(helper2)(8) 399.912 +:0(setprofile) <- profile:0(testfunc())(1) 999.751 +:1() <- :0(exec)(1) 999.753 +io.py:1213(flush) <- :0(exec)(2) 999.753 +io.py:656(closed) <- io.py:874(flush)(2) -0.006 +io.py:874(flush) <- io.py:1213(flush)(2) -0.010 +profile:0(profiler) <- +profile:0(testfunc()) <- profile:0(profiler)(1) 0.000 +profilee.py:110(__getattr__) <- :0(hasattr)(12) 11.964 + profilee.py:98(subhelper)(16) 79.960 +profilee.py:25(testfunc) <- :1()(1) 999.767 +profilee.py:35(factorial) <- profilee.py:25(testfunc)(1) 999.769 + profilee.py:35(factorial)(20) 169.917 + profilee.py:84(helper2_indirect)(2) 139.946 +profilee.py:48(mul) <- profilee.py:35(factorial)(20) 169.917 +profilee.py:55(helper) <- profilee.py:25(testfunc)(2) 999.769 +profilee.py:73(helper1) <- profilee.py:55(helper)(4) 599.830 +profilee.py:84(helper2_indirect) <- profilee.py:55(helper)(2) 599.830 +profilee.py:88(helper2) <- profilee.py:55(helper)(6) 599.830 + profilee.py:84(helper2_indirect)(2) 139.946 +profilee.py:98(subhelper) <- profilee.py:88(helper2)(8) 399.912 + + +""" +ProfileTest.expected_output['print_callees'] = """\ + Ordered by: standard name + +Function called... +:0(append) -> +:0(exc_info) -> +:0(exec) -> :1()(1) 999.767 + io.py:1213(flush)(2) -0.010 +:0(hasattr) -> profilee.py:110(__getattr__)(12) 27.972 +:0(setprofile) -> +:1() -> profilee.py:25(testfunc)(1) 999.769 +io.py:1213(flush) -> io.py:874(flush)(2) -0.006 +io.py:656(closed) -> +io.py:874(flush) -> io.py:656(closed)(2) -0.002 +profile:0(profiler) -> profile:0(testfunc())(1) 999.751 +profile:0(testfunc()) -> :0(exec)(1) 999.753 + :0(setprofile)(1) 0.000 +profilee.py:110(__getattr__) -> +profilee.py:25(testfunc) -> profilee.py:35(factorial)(1) 169.917 + profilee.py:55(helper)(2) 599.830 +profilee.py:35(factorial) -> profilee.py:35(factorial)(20) 169.917 + profilee.py:48(mul)(20) 19.980 +profilee.py:48(mul) -> +profilee.py:55(helper) -> profilee.py:73(helper1)(4) 119.964 + profilee.py:84(helper2_indirect)(2) 139.946 + profilee.py:88(helper2)(6) 399.912 +profilee.py:73(helper1) -> :0(append)(4) -0.004 + :0(exc_info)(4) -0.004 + :0(hasattr)(4) 11.964 +profilee.py:84(helper2_indirect) -> profilee.py:35(factorial)(2) 169.917 + profilee.py:88(helper2)(2) 399.912 +profilee.py:88(helper2) -> :0(hasattr)(8) 11.964 + profilee.py:98(subhelper)(8) 79.960 +profilee.py:98(subhelper) -> profilee.py:110(__getattr__)(16) 27.972 + -def mul(a, b): - # 20 calls - # 1 tick, local - global ticks - ticks += 1 - return a * b - -def helper(): - # 2 calls - # 300 ticks total: 20 ticks local, 260 ticks in subfunctions - global ticks - ticks += 1 - helper1() # 30 - ticks += 2 - helper1() # 30 - ticks += 6 - helper2() # 50 - ticks += 3 - helper2() # 50 - ticks += 2 - helper2() # 50 - ticks += 5 - helper2_indirect() # 70 - ticks += 1 - -def helper1(): - # 4 calls - # 30 ticks total: 29 ticks local, 1 tick in subfunctions - global ticks - ticks += 10 - hasattr(C(), "foo") # 1 - ticks += 19 - lst = [] - lst.append(42) # 0 - sys.exc_info() # 0 - -def helper2_indirect(): - helper2() # 50 - factorial(3) # 20 - -def helper2(): - # 8 calls - # 50 ticks local: 39 ticks local, 11 ticks in subfunctions - global ticks - ticks += 11 - hasattr(C(), "bar") # 1 - ticks += 13 - subhelper() # 10 - ticks += 15 - -def subhelper(): - # 8 calls - # 10 ticks total: 8 ticks local, 2 ticks in subfunctions - global ticks - ticks += 2 - for i in range(2): # 0 - try: - C().foo # 1 x 2 - except AttributeError: - ticks += 3 # 3 x 2 - -class C: - def __getattr__(self, name): - # 28 calls - # 1 tick, local - global ticks - ticks += 1 - raise AttributeError +""" if __name__ == "__main__": - test_main() + main() Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Wed Feb 6 15:31:34 2008 @@ -339,11 +339,14 @@ # freed blocks shouldn't change self.assertEqual(r[0][2], 0) # fill freelists - floats = [float(i) for i in range(12000)] + ints = list(range(10000)) + floats = [float(i) for i in ints] + del ints del floats - # should free more than 200 blocks + # should free more than 100 blocks r = sys._compact_freelists() - self.assert_(r[0][2] > 200, r[0][2]) + self.assert_(r[0][1] > 100, r[0][1]) + self.assert_(r[0][2] > 100, r[0][2]) def test_main(): test.test_support.run_unittest(SysModuleTest) Modified: python/branches/py3k/Lib/test/test_trace.py ============================================================================== --- python/branches/py3k/Lib/test/test_trace.py (original) +++ python/branches/py3k/Lib/test/test_trace.py Wed Feb 6 15:31:34 2008 @@ -252,14 +252,16 @@ "\n".join(difflib.ndiff([str(x) for x in expected_events], [str(x) for x in events]))) - - def run_test(self, func): + def run_and_compare(self, func, events): tracer = Tracer() sys.settrace(tracer.trace) func() sys.settrace(None) self.compare_events(func.__code__.co_firstlineno, - tracer.events, func.events) + tracer.events, events) + + def run_test(self, func): + self.run_and_compare(func, func.events) def run_test2(self, func): tracer = Tracer() @@ -321,6 +323,59 @@ self.compare_events(generator_example.__code__.co_firstlineno, tracer.events, generator_example.events) + def test_14_onliner_if(self): + def onliners(): + if True: False + else: True + return 0 + self.run_and_compare( + onliners, + [(0, 'call'), + (1, 'line'), + (3, 'line'), + (3, 'return')]) + + def test_15_loops(self): + # issue1750076: "while" expression is skipped by debugger + def for_example(): + for x in range(2): + pass + self.run_and_compare( + for_example, + [(0, 'call'), + (1, 'line'), + (2, 'line'), + (1, 'line'), + (2, 'line'), + (1, 'line'), + (1, 'return')]) + + def while_example(): + # While expression should be traced on every loop + x = 2 + while x > 0: + x -= 1 + self.run_and_compare( + while_example, + [(0, 'call'), + (2, 'line'), + (3, 'line'), + (4, 'line'), + (3, 'line'), + (4, 'line'), + (3, 'line'), + (3, 'return')]) + + def test_16_blank_lines(self): + namespace = {} + exec("def f():\n" + "\n" * 256 + " pass", namespace) + self.run_and_compare( + namespace["f"], + [(0, 'call'), + (257, 'line'), + (257, 'return')]) + + class RaisingTraceFuncTestCase(unittest.TestCase): def trace(self, frame, event, arg): """A trace function that raises an exception in response to a Modified: python/branches/py3k/Lib/test/test_wave.py ============================================================================== --- python/branches/py3k/Lib/test/test_wave.py (original) +++ python/branches/py3k/Lib/test/test_wave.py Wed Feb 6 15:31:34 2008 @@ -1,32 +1,45 @@ -from test.test_support import TestFailed, TESTFN +from test.test_support import TESTFN, run_unittest import os import wave - -def check(t, msg=None): - if not t: - raise TestFailed(msg) +import unittest nchannels = 2 sampwidth = 2 framerate = 8000 nframes = 100 -f = wave.open(TESTFN, 'wb') -f.setnchannels(nchannels) -f.setsampwidth(sampwidth) -f.setframerate(framerate) -f.setnframes(nframes) -output = b'\0' * nframes * nchannels * sampwidth -f.writeframes(output) -f.close() - -f = wave.open(TESTFN, 'rb') -check(nchannels == f.getnchannels(), "nchannels") -check(sampwidth == f.getsampwidth(), "sampwidth") -check(framerate == f.getframerate(), "framerate") -check(nframes == f.getnframes(), "nframes") -input = f.readframes(nframes) -check(input == output, "data") -f.close() +class TestWave(unittest.TestCase): + + def setUp(self): + self.f = None + + def tearDown(self): + if self.f is not None: + self.f.close() + try: + os.remove(TESTFN) + except OSError: + pass + + def test_it(self): + self.f = wave.open(TESTFN, 'wb') + self.f.setnchannels(nchannels) + self.f.setsampwidth(sampwidth) + self.f.setframerate(framerate) + self.f.setnframes(nframes) + output = b'\0' * nframes * nchannels * sampwidth + self.f.writeframes(output) + self.f.close() + + self.f = wave.open(TESTFN, 'rb') + self.assertEqual(nchannels, self.f.getnchannels()) + self.assertEqual(sampwidth, self.f.getsampwidth()) + self.assertEqual(framerate, self.f.getframerate()) + self.assertEqual(nframes, self.f.getnframes()) + self.assertEqual(self.f.readframes(nframes), output) + +def test_main(): + run_unittest(TestWave) -os.remove(TESTFN) +if __name__ == '__main__': + test_main() Modified: python/branches/py3k/Misc/python-mode.el ============================================================================== --- python/branches/py3k/Misc/python-mode.el (original) +++ python/branches/py3k/Misc/python-mode.el Wed Feb 6 15:31:34 2008 @@ -2,7 +2,8 @@ ;; Copyright (C) 1992,1993,1994 Tim Peters -;; Author: 1995-2002 Barry A. Warsaw +;; Author: 2003-2007 http://sf.net/projects/python-mode +;; 1995-2002 Barry A. Warsaw ;; 1992-1994 Tim Peters ;; Maintainer: python-mode at python.org ;; Created: Feb 1992 @@ -19,19 +20,38 @@ ;;; Commentary: -;; This is a major mode for editing Python programs. It was developed -;; by Tim Peters after an original idea by Michael A. Guravage. Tim -;; subsequently left the net; in 1995, Barry Warsaw inherited the mode -;; and is the current maintainer. Tim's now back but disavows all -;; responsibility for the mode. Smart Tim :-) +;; This is a major mode for editing Python programs. It was developed by Tim +;; Peters after an original idea by Michael A. Guravage. Tim subsequently +;; left the net and in 1995, Barry Warsaw inherited the mode. Tim's now back +;; but disavows all responsibility for the mode. In fact, we suspect he +;; doesn't even use Emacs any more. In 2003, python-mode.el was moved to its +;; own SourceForge project apart from the Python project, and now is +;; maintained by the volunteers at the python-mode at python.org mailing list. -;; pdbtrack support contributed by Ken Manheimer, April 2001. +;; pdbtrack support contributed by Ken Manheimer, April 2001. Skip Montanaro +;; has also contributed significantly to python-mode's development. ;; Please use the SourceForge Python project to submit bugs or ;; patches: ;; ;; http://sourceforge.net/projects/python +;; INSTALLATION: + +;; To install, just drop this file into a directory on your load-path and +;; byte-compile it. To set up Emacs to automatically edit files ending in +;; ".py" using python-mode add the following to your ~/.emacs file (GNU +;; Emacs) or ~/.xemacs/init.el file (XEmacs): +;; (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) +;; (setq interpreter-mode-alist (cons '("python" . python-mode) +;; interpreter-mode-alist)) +;; (autoload 'python-mode "python-mode" "Python editing mode." t) +;; +;; In XEmacs syntax highlighting should be enabled automatically. In GNU +;; Emacs you may have to add these lines to your ~/.emacs file: +;; (global-font-lock-mode t) +;; (setq font-lock-maximum-decoration t) + ;; FOR MORE INFORMATION: ;; There is some information on python-mode.el at @@ -60,6 +80,7 @@ (require 'custom) (require 'cl) (require 'compile) +(require 'ansi-color) ;; user definable variables @@ -70,34 +91,41 @@ :group 'languages :prefix "py-") +(defcustom py-tab-always-indent t + "*Non-nil means TAB in Python mode should always reindent the current line, +regardless of where in the line point is when the TAB command is used." + :type 'boolean + :group 'python) + (defcustom py-python-command "python" "*Shell command used to start Python interpreter." :type 'string :group 'python) -(defcustom py-jpython-command "jpython" - "*Shell command used to start the JPython interpreter." +(make-obsolete-variable 'py-jpython-command 'py-jython-command) +(defcustom py-jython-command "jython" + "*Shell command used to start the Jython interpreter." :type 'string :group 'python - :tag "JPython Command") + :tag "Jython Command") (defcustom py-default-interpreter 'cpython "*Which Python interpreter is used by default. -The value for this variable can be either `cpython' or `jpython'. +The value for this variable can be either `cpython' or `jython'. When the value is `cpython', the variables `py-python-command' and `py-python-command-args' are consulted to determine the interpreter and arguments to use. -When the value is `jpython', the variables `py-jpython-command' and -`py-jpython-command-args' are consulted to determine the interpreter +When the value is `jython', the variables `py-jython-command' and +`py-jython-command-args' are consulted to determine the interpreter and arguments to use. Note that this variable is consulted only the first time that a Python mode buffer is visited during an Emacs session. After that, use \\[py-toggle-shells] to change the interpreter shell." :type '(choice (const :tag "Python (a.k.a. CPython)" cpython) - (const :tag "JPython" jpython)) + (const :tag "Jython" jython)) :group 'python) (defcustom py-python-command-args '("-i") @@ -105,11 +133,12 @@ :type '(repeat string) :group 'python) -(defcustom py-jpython-command-args '("-i") - "*List of string arguments to be used when starting a JPython shell." +(make-obsolete-variable 'py-jpython-command-args 'py-jython-command-args) +(defcustom py-jython-command-args '("-i") + "*List of string arguments to be used when starting a Jython shell." :type '(repeat string) :group 'python - :tag "JPython Command Args") + :tag "Jython Command Args") (defcustom py-indent-offset 4 "*Amount of offset per level of indentation. @@ -248,7 +277,7 @@ :type 'function :group 'python) -(defcustom py-imenu-show-method-args-p nil +(defcustom py-imenu-show-method-args-p nil "*Controls echoing of arguments of functions & methods in the Imenu buffer. When non-nil, arguments are printed." :type 'boolean @@ -275,19 +304,20 @@ 20000 "Maximum number of characters to search for a Java-ish import statement. When `python-mode' tries to calculate the shell to use (either a -CPython or a JPython shell), it looks at the so-called `shebang' line +CPython or a Jython shell), it looks at the so-called `shebang' line -- i.e. #! line. If that's not available, it looks at some of the file heading imports to see if they look Java-like." :type 'integer :group 'python ) -(defcustom py-jpython-packages +(make-obsolete-variable 'py-jpython-packages 'py-jython-packages) +(defcustom py-jython-packages '("java" "javax" "org" "com") - "Imported packages that imply `jpython-mode'." + "Imported packages that imply `jython-mode'." :type '(repeat string) :group 'python) - + ;; Not customizable (defvar py-master-file nil "If non-nil, execute the named file instead of the buffer's file. @@ -317,16 +347,39 @@ :tag "Pychecker Command Args") (defvar py-shell-alist - '(("jpython" . 'jpython) - ("jython" . 'jpython) + '(("jython" . 'jython) ("python" . 'cpython)) "*Alist of interpreters and python shells. Used by `py-choose-shell' to select the appropriate python interpreter mode for a file.") +(defcustom py-shell-input-prompt-1-regexp "^>>> " + "*A regular expression to match the input prompt of the shell." + :type 'string + :group 'python) + +(defcustom py-shell-input-prompt-2-regexp "^[.][.][.] " + "*A regular expression to match the input prompt of the shell after the + first line of input." + :type 'string + :group 'python) + +(defcustom py-shell-switch-buffers-on-execute t + "*Controls switching to the Python buffer where commands are + executed. When non-nil the buffer switches to the Python buffer, if + not no switching occurs." + :type 'boolean + :group 'python) + ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT +(defvar py-line-number-offset 0 + "When an exception occurs as a result of py-execute-region, a +subsequent py-up-exception needs the line number where the region +started, in order to jump to the correct file line. This variable is +set in py-execute-region and used in py-jump-to-exception.") + (defconst py-emacs-features (let (features) features) @@ -339,9 +392,31 @@ "Face for pseudo keywords in Python mode, like self, True, False, Ellipsis.") (make-face 'py-pseudo-keyword-face) +;; PEP 318 decorators +(defvar py-decorators-face 'py-decorators-face + "Face method decorators.") +(make-face 'py-decorators-face) + +;; Face for builtins +(defvar py-builtins-face 'py-builtins-face + "Face for builtins like TypeError, object, open, and exec.") +(make-face 'py-builtins-face) + +;; XXX, TODO, and FIXME comments and such +(defvar py-XXX-tag-face 'py-XXX-tag-face + "Face for XXX, TODO, and FIXME tags") +(make-face 'py-XXX-tag-face) + (defun py-font-lock-mode-hook () (or (face-differs-from-default-p 'py-pseudo-keyword-face) - (copy-face 'font-lock-keyword-face 'py-pseudo-keyword-face))) + (copy-face 'font-lock-keyword-face 'py-pseudo-keyword-face)) + (or (face-differs-from-default-p 'py-builtins-face) + (copy-face 'font-lock-keyword-face 'py-builtins-face)) + (or (face-differs-from-default-p 'py-decorators-face) + (copy-face 'py-pseudo-keyword-face 'py-decorators-face)) + (or (face-differs-from-default-p 'py-XXX-tag-face) + (copy-face 'font-lock-comment-face 'py-XXX-tag-face)) + ) (add-hook 'font-lock-mode-hook 'py-font-lock-mode-hook) (defvar python-font-lock-keywords @@ -352,7 +427,7 @@ "from" "global" "if" "import" "in" "is" "lambda" "not" "or" "pass" "print" "raise" - "return" "while" "yield" + "return" "while" "with" "yield" ) "\\|")) (kw2 (mapconcat 'identity @@ -391,26 +466,52 @@ "super" "tuple" "type" "unichr" "unicode" "vars" "zip") "\\|")) + (kw4 (mapconcat 'identity + ;; Exceptions and warnings + '("ArithmeticError" "AssertionError" + "AttributeError" "DeprecationWarning" "EOFError" + "EnvironmentError" "Exception" + "FloatingPointError" "FutureWarning" "IOError" + "ImportError" "IndentationError" "IndexError" + "KeyError" "KeyboardInterrupt" "LookupError" + "MemoryError" "NameError" "NotImplemented" + "NotImplementedError" "OSError" "OverflowError" + "OverflowWarning" "PendingDeprecationWarning" + "ReferenceError" "RuntimeError" "RuntimeWarning" + "StandardError" "StopIteration" "SyntaxError" + "SyntaxWarning" "SystemError" "SystemExit" + "TabError" "TypeError" "UnboundLocalError" + "UnicodeDecodeError" "UnicodeEncodeError" + "UnicodeError" "UnicodeTranslateError" + "UserWarning" "ValueError" "Warning" + "ZeroDivisionError") + "\\|")) ) (list + '("^[ \t]*\\(@.+\\)" 1 'py-decorators-face) ;; keywords - (cons (concat "\\b\\(" kw1 "\\)\\b[ \n\t(]") 1) + (cons (concat "\\<\\(" kw1 "\\)\\>[ \n\t(]") 1) ;; builtins when they don't appear as object attributes - (cons (concat "\\(\\b\\|[.]\\)\\(" kw3 "\\)\\b[ \n\t(]") 2) + (list (concat "\\([^. \t]\\|^\\)[ \t]*\\<\\(" kw3 "\\)\\>[ \n\t(]") 2 + 'py-builtins-face) ;; block introducing keywords with immediately following colons. ;; Yes "except" is in both lists. - (cons (concat "\\b\\(" kw2 "\\)[ \n\t(]") 1) - ;; `as' but only in "import foo as bar" - '("[ \t]*\\(\\bfrom\\b.*\\)?\\bimport\\b.*\\b\\(as\\)\\b" . 2) + (cons (concat "\\<\\(" kw2 "\\)[ \n\t(]") 1) + ;; Exceptions + (list (concat "\\<\\(" kw4 "\\)[ \n\t:,(]") 1 'py-builtins-face) + ;; `as' but only in "import foo as bar" or "with foo as bar" + '("[ \t]*\\(\\.*\\)?\\.*\\<\\(as\\)\\>" . 2) + '("[ \t]*\\.*\\<\\(as\\)\\>" . 1) ;; classes - '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" - 1 font-lock-type-face) + '("\\" 1 py-pseudo-keyword-face) + ;; XXX, TODO, and FIXME tags + '("XXX\\|TODO\\|FIXME" 0 py-XXX-tag-face t) )) "Additional expressions to highlight in Python mode.") (put 'python-mode 'font-lock-defaults '(python-font-lock-keywords)) @@ -421,13 +522,7 @@ Currently-active file is at the head of the list.") (defvar py-pdbtrack-is-tracking-p nil) -(defvar py-pdbtrack-last-grubbed-buffer nil - "Record of the last buffer used when the source path was invalid. -This buffer is consulted before the buffer-list history for satisfying -`py-pdbtrack-grub-for-buffer', since it's the most often the likely -prospect as debugging continues.") -(make-variable-buffer-local 'py-pdbtrack-last-grubbed-buffer) (defvar py-pychecker-history nil) @@ -461,7 +556,7 @@ "\\(" "[^#'\"\n\\]" "\\|" py-stringlit-re "\\)*" "\\\\$") "Regular expression matching Python backslash continuation lines.") - + (defconst py-blank-or-comment-re "[ \t]*\\($\\|#\\)" "Regular expression matching a blank or comment line.") @@ -474,7 +569,7 @@ "\\|") "\\)") "Regular expression matching statements to be dedented one level.") - + (defconst py-block-closing-keywords-re "\\(return\\|raise\\|break\\|continue\\|pass\\)" "Regular expression matching keywords which typically close a block.") @@ -495,30 +590,17 @@ "\\)") "Regular expression matching lines not to dedent after.") -(defconst py-defun-start-re - "^\\([ \t]*\\)def[ \t]+\\([a-zA-Z_0-9]+\\)\\|\\(^[a-zA-Z_0-9]+\\)[ \t]*=" - ;; If you change this, you probably have to change py-current-defun - ;; as well. This is only used by py-current-defun to find the name - ;; for add-log.el. - "Regular expression matching a function, method, or variable assignment.") - -(defconst py-class-start-re "^class[ \t]*\\([a-zA-Z_0-9]+\\)" - ;; If you change this, you probably have to change py-current-defun - ;; as well. This is only used by py-current-defun to find the name - ;; for add-log.el. - "Regular expression for finding a class name.") - -(defconst py-traceback-line-re +(defvar py-traceback-line-re "[ \t]+File \"\\([^\"]+\\)\", line \\([0-9]+\\)" "Regular expression that describes tracebacks.") -;; pdbtrack contants +;; pdbtrack constants (defconst py-pdbtrack-stack-entry-regexp ; "^> \\([^(]+\\)(\\([0-9]+\\))\\([?a-zA-Z0-9_]+\\)()" "^> \\(.*\\)(\\([0-9]+\\))\\([?a-zA-Z0-9_]+\\)()" "Regular expression pdbtrack uses to find a stack trace entry.") -(defconst py-pdbtrack-input-prompt "\n[(<]*pdb[>)]+ " +(defconst py-pdbtrack-input-prompt "\n[(<]*[Pp]db[>)]+ " "Regular expression pdbtrack uses to recognize a pdb prompt.") (defconst py-pdbtrack-track-range 10000 @@ -536,8 +618,9 @@ (defvar python-mode-hook nil "*Hook called by `python-mode'.") -(defvar jpython-mode-hook nil - "*Hook called by `jpython-mode'. `jpython-mode' also calls +(make-obsolete-variable 'jpython-mode-hook 'jython-mode-hook) +(defvar jython-mode-hook nil + "*Hook called by `jython-mode'. `jython-mode' also calls `python-mode-hook'.") (defvar py-shell-hook nil @@ -560,8 +643,6 @@ (define-key py-mode-map "\C-c\C-r" 'py-shift-region-right) (define-key py-mode-map "\C-c<" 'py-shift-region-left) (define-key py-mode-map "\C-c>" 'py-shift-region-right) - ;; paragraph and string filling - (define-key py-mode-map "\eq" 'py-fill-paragraph) ;; subprocess commands (define-key py-mode-map "\C-c\C-c" 'py-execute-buffer) (define-key py-mode-map "\C-c\C-m" 'py-execute-import-or-reload) @@ -624,7 +705,7 @@ ;; expect RET to do a `py-newline-and-indent' and any Emacsers who ;; dislike this are probably knowledgeable enough to do a rebind. ;; However, we do *not* change C-j since many Emacsers have already - ;; swapped RET and C-j and they don't want C-j bound to `newline' to + ;; swapped RET and C-j and they don't want C-j bound to `newline' to ;; change. (define-key py-mode-map "\C-m" 'py-newline-and-indent) ) @@ -740,8 +821,8 @@ (cond ((eq position 'bol) (beginning-of-line)) ((eq position 'eol) (end-of-line)) - ((eq position 'bod) (py-beginning-of-def-or-class)) - ((eq position 'eod) (py-end-of-def-or-class)) + ((eq position 'bod) (py-beginning-of-def-or-class 'either)) + ((eq position 'eod) (py-end-of-def-or-class 'either)) ;; Kind of funny, I know, but useful for py-up-exception. ((eq position 'bob) (beginning-of-buffer)) ((eq position 'eob) (end-of-buffer)) @@ -849,7 +930,7 @@ (defvar py-imenu-method-regexp (concat ; <> - "\\(" ; + "\\(" ; "^[ \t]*" ; new line and maybe whitespace "\\(def[ \t]+" ; function definitions start with def "\\([a-zA-Z0-9_]+\\)" ; name is here @@ -885,7 +966,7 @@ ;; it. (defvar py-imenu-generic-expression (cons - (concat + (concat py-imenu-class-regexp "\\|" ; or... py-imenu-method-regexp @@ -954,7 +1035,7 @@ looking-p def-name prev-name cur-indent def-pos - (class-paren (first py-imenu-generic-parens)) + (class-paren (first py-imenu-generic-parens)) (def-paren (second py-imenu-generic-parens))) (setq looking-p (re-search-forward py-imenu-generic-regexp (point-max) t)) @@ -1009,7 +1090,7 @@ (cons save-elmt sub-method-alist)) index-alist)))) ;; found less indented expression, we're done. - (t + (t (setq looking-p nil) (re-search-backward py-imenu-generic-regexp (point-min) t))) ;; end-cond @@ -1023,7 +1104,7 @@ (defun py-choose-shell-by-shebang () - "Choose CPython or JPython mode by looking at #! on the first line. + "Choose CPython or Jython mode by looking at #! on the first line. Returns the appropriate mode function. Used by `py-choose-shell', and similar to but distinct from `set-auto-mode', though it uses `auto-mode-interpreter-regexp' (if available)." @@ -1047,10 +1128,10 @@ (defun py-choose-shell-by-import () - "Choose CPython or JPython mode based imports. -If a file imports any packages in `py-jpython-packages', within + "Choose CPython or Jython mode based imports. +If a file imports any packages in `py-jython-packages', within `py-import-check-point-max' characters from the start of the file, -return `jpython', otherwise return nil." +return `jython', otherwise return nil." (let (mode) (save-excursion (goto-char (point-min)) @@ -1058,14 +1139,14 @@ (search-forward-regexp "^\\(\\(from\\)\\|\\(import\\)\\) \\([^ \t\n.]+\\)" py-import-check-point-max t)) - (setq mode (and (member (match-string 4) py-jpython-packages) - 'jpython + (setq mode (and (member (match-string 4) py-jython-packages) + 'jython )))) mode)) (defun py-choose-shell () - "Choose CPython or JPython mode. Returns the appropriate mode function. + "Choose CPython or Jython mode. Returns the appropriate mode function. This does the following: - look for an interpreter with `py-choose-shell-by-shebang' - examine imports using `py-choose-shell-by-import' @@ -1114,6 +1195,7 @@ (make-local-variable 'indent-region-function) (make-local-variable 'indent-line-function) (make-local-variable 'add-log-current-defun-function) + (make-local-variable 'fill-paragraph-function) ;; (set-syntax-table py-mode-syntax-table) (setq major-mode 'python-mode @@ -1132,6 +1214,8 @@ indent-line-function 'py-indent-line ;; tell add-log.el how to find the current function/method/variable add-log-current-defun-function 'py-current-defun + + fill-paragraph-function 'py-fill-paragraph ) (use-local-map py-mode-map) ;; add the menu @@ -1171,17 +1255,18 @@ (py-toggle-shells (py-choose-shell)))) -(defun jpython-mode () - "Major mode for editing JPython/Jython files. +(make-obsolete 'jpython-mode 'jython-mode) +(defun jython-mode () + "Major mode for editing Jython/Jython files. This is a simple wrapper around `python-mode'. -It runs `jpython-mode-hook' then calls `python-mode.' +It runs `jython-mode-hook' then calls `python-mode.' It is added to `interpreter-mode-alist' and `py-choose-shell'. " (interactive) (python-mode) - (py-toggle-shells 'jpython) - (when jpython-mode-hook - (run-hooks 'jpython-mode-hook))) + (py-toggle-shells 'jython) + (when jython-mode-hook + (run-hooks 'jython-mode-hook))) ;; It's handy to add recognition of Python files to the @@ -1189,16 +1274,16 @@ ;; can specify different `derived-modes' based on the #! line, but ;; with the latter, we can't. So we just won't add them if they're ;; already added. -(let ((modes '(("jpython" . jpython-mode) - ("jython" . jpython-mode) +;;;###autoload +(let ((modes '(("jython" . jython-mode) ("python" . python-mode)))) (while modes (when (not (assoc (car modes) interpreter-mode-alist)) (push (car modes) interpreter-mode-alist)) (setq modes (cdr modes)))) - +;;;###autoload (when (not (or (rassq 'python-mode auto-mode-alist) - (rassq 'jpython-mode auto-mode-alist))) + (rassq 'jython-mode auto-mode-alist))) (push '("\\.py$" . python-mode) auto-mode-alist)) @@ -1283,12 +1368,13 @@ (defun py-comint-output-filter-function (string) "Watch output for Python prompt and exec next file waiting in queue. This function is appropriate for `comint-output-filter-functions'." - ;; TBD: this should probably use split-string - (when (and (or (string-equal string ">>> ") - (and (>= (length string) 5) - (string-equal (substring string -5) "\n>>> "))) - py-file-queue) - (pop-to-buffer (current-buffer)) + ;;remove ansi terminal escape sequences from string, not sure why they are + ;;still around... + (setq string (ansi-color-filter-apply string)) + (when (and (string-match py-shell-input-prompt-1-regexp string) + py-file-queue) + (if py-shell-switch-buffers-on-execute + (pop-to-buffer (current-buffer))) (py-safe (delete-file (car py-file-queue))) (setq py-file-queue (cdr py-file-queue)) (if py-file-queue @@ -1344,7 +1430,7 @@ (- procmark py-pdbtrack-track-range)) procmark)) - target target_fname target_lineno) + target target_fname target_lineno target_buffer) (if (not (string-match (concat py-pdbtrack-input-prompt "$") block)) (py-pdbtrack-overlay-arrow nil) @@ -1372,8 +1458,7 @@ We look first to visit the file indicated in the trace. Failing that, we look for the most recently visited python-mode buffer -with the same name or having -having the named function. +with the same name or having the named function. If we're unable find the source code we return a string describing the problem as best as we can determine." @@ -1417,11 +1502,10 @@ (defun py-pdbtrack-grub-for-buffer (funcname lineno) "Find most recent buffer itself named or having function funcname. -We first check the last buffer this function found, if any, then walk -throught the buffer-list history for python-mode buffers that are +We walk the buffer-list history for python-mode buffers that are named for funcname or define a function funcname." (let ((buffers (buffer-list)) - curbuf + buf got) (while (and buffers (not got)) (setq buf (car buffers) @@ -1436,7 +1520,7 @@ (buffer-substring (point-min) (point-max)))))) (setq got buf))) - (setq py-pdbtrack-last-grubbed-buffer got))) + got)) (defun py-postprocess-output-buffer (buf) "Highlight exceptions found in BUF. @@ -1466,7 +1550,7 @@ (defconst py-output-buffer "*Python Output*") (make-variable-buffer-local 'py-output-buffer) -;; for toggling between CPython and JPython +;; for toggling between CPython and Jython (defvar py-which-shell nil) (defvar py-which-args py-python-command-args) (defvar py-which-bufname "Python") @@ -1475,14 +1559,14 @@ (make-variable-buffer-local 'py-which-bufname) (defun py-toggle-shells (arg) - "Toggles between the CPython and JPython shells. + "Toggles between the CPython and Jython shells. With positive argument ARG (interactively \\[universal-argument]), -uses the CPython shell, with negative ARG uses the JPython shell, and +uses the CPython shell, with negative ARG uses the Jython shell, and with a zero argument, toggles the shell. Programmatically, ARG can also be one of the symbols `cpython' or -`jpython', equivalent to positive arg and negative arg respectively." +`jython', equivalent to positive arg and negative arg respectively." (interactive "P") ;; default is to toggle (if (null arg) @@ -1495,7 +1579,7 @@ (setq arg -1) (setq arg 1))) ((equal arg 'cpython) (setq arg 1)) - ((equal arg 'jpython) (setq arg -1))) + ((equal arg 'jython) (setq arg -1))) (let (msg) (cond ((< 0 arg) @@ -1503,14 +1587,16 @@ (setq py-which-shell py-python-command py-which-args py-python-command-args py-which-bufname "Python" - msg "CPython" - mode-name "Python")) + msg "CPython") + (if (string-equal py-which-bufname "Jython") + (setq mode-name "Python"))) ((> 0 arg) - (setq py-which-shell py-jpython-command - py-which-args py-jpython-command-args - py-which-bufname "JPython" - msg "JPython" - mode-name "JPython")) + (setq py-which-shell py-jython-command + py-which-args py-jython-command-args + py-which-bufname "Jython" + msg "Jython") + (if (string-equal py-which-bufname "Python") + (setq mode-name "Jython"))) ) (message "Using the %s shell" msg) (setq py-output-buffer (format "*%s Output*" py-which-bufname)))) @@ -1532,9 +1618,9 @@ programmatically, or when running in Emacs 19.34 or older. Note: You can toggle between using the CPython interpreter and the -JPython interpreter by hitting \\[py-toggle-shells]. This toggles +Jython interpreter by hitting \\[py-toggle-shells]. This toggles buffer local variables which control whether all your subshell -interactions happen to the `*JPython*' or `*Python*' buffers (the +interactions happen to the `*Jython*' or `*Python*' buffers (the latter is the name used for the CPython buffer). Warning: Don't use an interactive Python if you change sys.ps1 or @@ -1568,10 +1654,14 @@ (concat (mapconcat 'identity py-which-args " ") " ") )))) - (switch-to-buffer-other-window - (apply 'make-comint py-which-bufname py-which-shell nil args)) + (if (not (equal (buffer-name) "*Python*")) + (switch-to-buffer-other-window + (apply 'make-comint py-which-bufname py-which-shell nil args)) + (apply 'make-comint py-which-bufname py-which-shell nil args)) (make-local-variable 'comint-prompt-regexp) - (setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) ") + (setq comint-prompt-regexp (concat py-shell-input-prompt-1-regexp "\\|" + py-shell-input-prompt-2-regexp "\\|" + "^([Pp]db) ")) (add-hook 'comint-output-filter-functions 'py-comint-output-filter-function) ;; pdbtrack @@ -1642,11 +1732,13 @@ (setq start (point)) (or (< start end) (error "Region is empty")) + (setq py-line-number-offset (count-lines 1 start)) (let ((needs-if (/= (py-point 'bol) (py-point 'boi)))) (set-buffer buf) (python-mode) (when needs-if - (insert "if 1:\n")) + (insert "if 1:\n") + (setq py-line-number-offset (- py-line-number-offset 1))) (insert-buffer-substring cur start end) ;; Set the shell either to the #! line command, or to the ;; py-which-shell buffer local variable. @@ -1683,8 +1775,9 @@ (setq py-exception-buffer (cons file (current-buffer)))) (t ;; TBD: a horrible hack, but why create new Custom variables? - (let ((cmd (concat shell (if (string-equal py-which-bufname "JPython") - " -" "")))) + (let ((cmd (concat py-which-shell (if (string-equal py-which-bufname + "Jython") + " -" "")))) ;; otherwise either run it synchronously in a subprocess (save-excursion (set-buffer buf) @@ -1718,12 +1811,14 @@ See the `\\[py-execute-region]' docs for an account of some subtleties, including the use of the optional ASYNC argument." (interactive "P") - (if py-master-file - (let* ((filename (expand-file-name py-master-file)) - (buffer (or (get-file-buffer filename) - (find-file-noselect filename)))) - (set-buffer buffer))) - (py-execute-region (point-min) (point-max) async)) + (let ((old-buffer (current-buffer))) + (if py-master-file + (let* ((filename (expand-file-name py-master-file)) + (buffer (or (get-file-buffer filename) + (find-file-noselect filename)))) + (set-buffer buffer))) + (py-execute-region (point-min) (point-max) async) + (pop-to-buffer old-buffer))) (defun py-execute-import-or-reload (&optional async) "Import the current buffer's file in a Python interpreter. @@ -1819,6 +1914,9 @@ (t (find-file (read-file-name "Exception file: " nil file t)))))) + ;; Fiddle about with line number + (setq line (+ py-line-number-offset line)) + (pop-to-buffer buffer) ;; Force Python mode (if (not (eq major-mode 'python-mode)) @@ -1999,16 +2097,29 @@ (interactive "P") (let* ((ci (current-indentation)) (move-to-indentation-p (<= (current-column) ci)) - (need (py-compute-indentation (not arg)))) - ;; see if we need to dedent - (if (py-outdent-p) - (setq need (- need py-indent-offset))) - (if (/= ci need) - (save-excursion - (beginning-of-line) - (delete-horizontal-space) - (indent-to need))) - (if move-to-indentation-p (back-to-indentation)))) + (need (py-compute-indentation (not arg))) + (cc (current-column))) + ;; dedent out a level if previous command was the same unless we're in + ;; column 1 + (if (and (equal last-command this-command) + (/= cc 0)) + (progn + (beginning-of-line) + (delete-horizontal-space) + (indent-to (* (/ (- cc 1) py-indent-offset) py-indent-offset))) + (progn + ;; see if we need to dedent + (if (py-outdent-p) + (setq need (- need py-indent-offset))) + (if (or py-tab-always-indent + move-to-indentation-p) + (progn (if (/= ci need) + (save-excursion + (beginning-of-line) + (delete-horizontal-space) + (indent-to need))) + (if move-to-indentation-p (back-to-indentation))) + (insert-tab)))))) (defun py-newline-and-indent () "Strives to act like the Emacs `newline-and-indent'. @@ -2052,39 +2163,23 @@ ((py-continuation-line-p) (let ((startpos (point)) (open-bracket-pos (py-nesting-level)) - endpos searching found state) + endpos searching found state cind cline) (if open-bracket-pos (progn - ;; align with first item in list; else a normal - ;; indent beyond the line with the open bracket - (goto-char (1+ open-bracket-pos)) ; just beyond bracket - ;; is the first list item on the same line? - (skip-chars-forward " \t") - (if (null (memq (following-char) '(?\n ?# ?\\))) - ; yes, so line up with it - (current-column) - ;; first list item on another line, or doesn't exist yet - (forward-line 1) - (while (and (< (point) startpos) - (looking-at "[ \t]*[#\n\\\\]")) ; skip noise - (forward-line 1)) - (if (and (< (point) startpos) - (/= startpos - (save-excursion - (goto-char (1+ open-bracket-pos)) - (forward-comment (point-max)) - (point)))) - ;; again mimic the first list item - (current-indentation) - ;; else they're about to enter the first item - (goto-char open-bracket-pos) - (setq placeholder (point)) - (py-goto-initial-line) - (py-goto-beginning-of-tqs - (save-excursion (nth 3 (parse-partial-sexp - placeholder (point))))) - (+ (current-indentation) py-indent-offset)))) - + (setq endpos (py-point 'bol)) + (py-goto-initial-line) + (setq cind (current-indentation)) + (setq cline cind) + (dolist (bp + (nth 9 (save-excursion + (parse-partial-sexp (point) endpos))) + cind) + (if (search-forward "\n" bp t) (setq cline cind)) + (goto-char (1+ bp)) + (skip-chars-forward " \t") + (setq cind (if (memq (following-char) '(?\n ?# ?\\)) + (+ cline py-indent-offset) + (current-column))))) ;; else on backslash continuation line (forward-line -1) (if (py-continuation-line-p) ; on at least 3rd line in block @@ -2832,7 +2927,7 @@ ;; ripped from cc-mode (defun py-forward-into-nomenclature (&optional arg) "Move forward to end of a nomenclature section or word. -With \\[universal-argument] (programmatically, optional argument ARG), +With \\[universal-argument] (programmatically, optional argument ARG), do it that many times. A `nomenclature' is a fancy way of saying AWordWithMixedCaseNotUnderscores." @@ -2886,6 +2981,11 @@ ;; Pychecker + +;; hack for FSF Emacs +(unless (fboundp 'read-shell-command) + (defalias 'read-shell-command 'read-string)) + (defun py-pychecker-run (command) "*Run pychecker (default on the file currently visited)." (interactive @@ -3410,7 +3510,7 @@ (defun py-statement-opens-block-p () "Return t iff the current statement opens a block. -I.e., iff it ends with a colon that is not in a comment. Point should +I.e., iff it ends with a colon that is not in a comment. Point should be at the start of a statement." (save-excursion (let ((start (point)) @@ -3494,8 +3594,8 @@ KEY is a regular expression describing a Python keyword. Skip blank lines and non-indenting comments. If the statement found starts with KEY, then stop, otherwise go back to first enclosing block starting -with KEY. If successful, leave point at the start of the KEY line and -return t. Otherwise, leav point at an undefined place and return nil." +with KEY. If successful, leave point at the start of the KEY line and +return t. Otherwise, leave point at an undefined place and return nil." ;; skip blanks and non-indenting # (py-goto-initial-line) (while (and @@ -3503,7 +3603,7 @@ (zerop (forward-line -1))) ; go back nil) (py-goto-initial-line) - (let* ((re (concat "[ \t]*" key "\\b")) + (let* ((re (concat "[ \t]*" key "\\>")) (case-fold-search nil) ; let* so looking-at sees this (found (looking-at re)) (dead nil)) @@ -3529,7 +3629,7 @@ `Keyword' is defined (essentially) as the regular expression ([a-z]+). Returns nil if none was found." (let ((case-fold-search nil)) - (if (looking-at "[ \t]*\\([a-z]+\\)\\b") + (if (looking-at "[ \t]*\\([a-z]+\\)\\>") (intern (buffer-substring (match-beginning 1) (match-end 1))) nil))) @@ -3537,14 +3637,49 @@ "Python value for `add-log-current-defun-function'. This tells add-log.el how to find the current function/method/variable." (save-excursion - (if (re-search-backward py-defun-start-re nil t) - (or (match-string 3) - (let ((method (match-string 2))) - (if (and (not (zerop (length (match-string 1)))) - (re-search-backward py-class-start-re nil t)) - (concat (match-string 1) "." method) - method))) - nil))) + + ;; Move back to start of the current statement. + + (py-goto-initial-line) + (back-to-indentation) + (while (and (or (looking-at py-blank-or-comment-re) + (py-in-literal)) + (not (bobp))) + (backward-to-indentation 1)) + (py-goto-initial-line) + + (let ((scopes "") + (sep "") + dead assignment) + + ;; Check for an assignment. If this assignment exists inside a + ;; def, it will be overwritten inside the while loop. If it + ;; exists at top lever or inside a class, it will be preserved. + + (when (looking-at "[ \t]*\\([a-zA-Z0-9_]+\\)[ \t]*=") + (setq scopes (buffer-substring (match-beginning 1) (match-end 1))) + (setq assignment t) + (setq sep ".")) + + ;; Prepend the name of each outer socpe (def or class). + + (while (not dead) + (if (and (py-go-up-tree-to-keyword "\\(class\\|def\\)") + (looking-at + "[ \t]*\\(class\\|def\\)[ \t]*\\([a-zA-Z0-9_]+\\)[ \t]*")) + (let ((name (buffer-substring (match-beginning 2) (match-end 2)))) + (if (and assignment (looking-at "[ \t]*def")) + (setq scopes name) + (setq scopes (concat name sep scopes)) + (setq sep ".")))) + (setq assignment nil) + (condition-case nil ; Terminate nicely at top level. + (py-goto-block-up 'no-mark) + (error (setq dead t)))) + (if (string= scopes "") + nil + scopes)))) + (defconst py-help-address "python-mode at python.org" @@ -3586,7 +3721,7 @@ "Dear Barry,") ;salutation (if enhancement-p nil (set-mark (point)) - (insert + (insert "Please replace this text with a sufficiently large code sample\n\ and an exact recipe so that I can reproduce your problem. Failure\n\ to do so may mean a greater delay in fixing your bug.\n\n") @@ -3606,7 +3741,7 @@ (add-hook 'comint-output-filter-functions 'py-pdbtrack-track-stack-file) ;; Add a designator to the minor mode strings -(or (assq 'py-pdbtrack-minor-mode-string minor-mode-alist) +(or (assq 'py-pdbtrack-is-tracking-p minor-mode-alist) (push '(py-pdbtrack-is-tracking-p py-pdbtrack-minor-mode-string) minor-mode-alist)) @@ -3745,20 +3880,35 @@ If point is inside a string, narrow to that string and fill. " (interactive "P") - (let* ((bod (py-point 'bod)) - (pps (parse-partial-sexp bod (point)))) - (cond - ;; are we inside a comment or on a line with only whitespace before - ;; the comment start? - ((or (nth 4 pps) - (save-excursion (beginning-of-line) (looking-at "[ \t]*#"))) - (py-fill-comment justify)) - ;; are we inside a string? - ((nth 3 pps) - (py-fill-string (nth 8 pps))) - ;; otherwise use the default - (t - (fill-paragraph justify))))) + ;; fill-paragraph will narrow incorrectly + (save-restriction + (widen) + (let* ((bod (py-point 'bod)) + (pps (parse-partial-sexp bod (point)))) + (cond + ;; are we inside a comment or on a line with only whitespace before + ;; the comment start? + ((or (nth 4 pps) + (save-excursion (beginning-of-line) (looking-at "[ \t]*#"))) + (py-fill-comment justify)) + ;; are we inside a string? + ((nth 3 pps) + (py-fill-string (nth 8 pps))) + ;; are we at the opening quote of a string, or in the indentation? + ((save-excursion + (forward-word 1) + (eq (py-in-literal) 'string)) + (save-excursion + (py-fill-string (py-point 'boi)))) + ;; are we at or after the closing quote of a string? + ((save-excursion + (backward-word 1) + (eq (py-in-literal) 'string)) + (save-excursion + (py-fill-string (py-point 'boi)))) + ;; otherwise use the default + (t + (fill-paragraph justify)))))) Modified: python/branches/py3k/Objects/classobject.c ============================================================================== --- python/branches/py3k/Objects/classobject.c (original) +++ python/branches/py3k/Objects/classobject.c Wed Feb 6 15:31:34 2008 @@ -5,6 +5,15 @@ #define TP_DESCR_GET(t) ((t)->tp_descr_get) +/* Free list for method objects to safe malloc/free overhead + * The im_self element is used to chain the elements. + */ +static PyMethodObject *free_list; +static int numfree = 0; +#ifndef PyMethod_MAXFREELIST +#define PyMethod_MAXFREELIST 256 +#endif + PyObject * PyMethod_Function(PyObject *im) { @@ -30,8 +39,6 @@ function. */ -static PyMethodObject *free_list; - PyObject * PyMethod_New(PyObject *func, PyObject *self) { @@ -48,6 +55,7 @@ if (im != NULL) { free_list = (PyMethodObject *)(im->im_self); PyObject_INIT(im, &PyMethod_Type); + numfree--; } else { im = PyObject_GC_New(PyMethodObject, &PyMethod_Type); @@ -165,8 +173,14 @@ PyObject_ClearWeakRefs((PyObject *)im); Py_DECREF(im->im_func); Py_XDECREF(im->im_self); - im->im_self = (PyObject *)free_list; - free_list = im; + if (numfree < PyMethod_MAXFREELIST) { + im->im_self = (PyObject *)free_list; + free_list = im; + numfree++; + } + else { + PyObject_GC_Del(im); + } } static PyObject * @@ -375,7 +389,9 @@ PyMethodObject *im = free_list; free_list = (PyMethodObject *)(im->im_self); PyObject_GC_Del(im); + numfree--; } + assert(numfree == 0); } /* ------------------------------------------------------------------------ Modified: python/branches/py3k/Objects/dictobject.c ============================================================================== --- python/branches/py3k/Objects/dictobject.c (original) +++ python/branches/py3k/Objects/dictobject.c Wed Feb 6 15:31:34 2008 @@ -184,9 +184,11 @@ } while(0) /* Dictionary reuse scheme to save calls to malloc, free, and memset */ -#define MAXFREEDICTS 80 -static PyDictObject *free_dicts[MAXFREEDICTS]; -static int num_free_dicts = 0; +#ifndef PyDict_MAXFREELIST +#define PyDict_MAXFREELIST 80 +#endif +static PyDictObject *free_list[PyDict_MAXFREELIST]; +static int numfree = 0; PyObject * PyDict_New(void) @@ -200,8 +202,8 @@ Py_AtExit(show_counts); #endif } - if (num_free_dicts) { - mp = free_dicts[--num_free_dicts]; + if (numfree) { + mp = free_list[--numfree]; assert (mp != NULL); assert (Py_TYPE(mp) == &PyDict_Type); _Py_NewReference((PyObject *)mp); @@ -897,8 +899,8 @@ } if (mp->ma_table != mp->ma_smalltable) PyMem_DEL(mp->ma_table); - if (num_free_dicts < MAXFREEDICTS && Py_TYPE(mp) == &PyDict_Type) - free_dicts[num_free_dicts++] = mp; + if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type) + free_list[numfree++] = mp; else Py_TYPE(mp)->tp_free((PyObject *)mp); Py_TRASHCAN_SAFE_END(mp) Modified: python/branches/py3k/Objects/frameobject.c ============================================================================== --- python/branches/py3k/Objects/frameobject.c (original) +++ python/branches/py3k/Objects/frameobject.c Wed Feb 6 15:31:34 2008 @@ -401,14 +401,15 @@ call depth of more than 20 or 30 is probably already exceptional unless the program contains run-away recursion. I hope. - Later, MAXFREELIST was added to bound the # of frames saved on + Later, PyFrame_MAXFREELIST was added to bound the # of frames saved on free_list. Else programs creating lots of cyclic trash involving frames could provoke free_list into growing without bound. */ static PyFrameObject *free_list = NULL; static int numfree = 0; /* number of frames currently in free_list */ -#define MAXFREELIST 200 /* max value for numfree */ +/* max value for numfree */ +#define PyFrame_MAXFREELIST 200 static void frame_dealloc(PyFrameObject *f) @@ -441,7 +442,7 @@ co = f->f_code; if (co->co_zombieframe == NULL) co->co_zombieframe = f; - else if (numfree < MAXFREELIST) { + else if (numfree < PyFrame_MAXFREELIST) { ++numfree; f->f_back = free_list; free_list = f; Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Wed Feb 6 15:31:34 2008 @@ -64,18 +64,20 @@ } /* Empty list reuse scheme to save calls to malloc and free */ -#define MAXFREELISTS 80 -static PyListObject *free_lists[MAXFREELISTS]; -static int num_free_lists = 0; +#ifndef PyList_MAXFREELIST +#define PyList_MAXFREELIST 80 +#endif +static PyListObject *free_list[PyList_MAXFREELIST]; +static int numfree = 0; void PyList_Fini(void) { PyListObject *op; - while (num_free_lists) { - num_free_lists--; - op = free_lists[num_free_lists]; + while (numfree) { + numfree--; + op = free_list[numfree]; assert(PyList_CheckExact(op)); PyObject_GC_Del(op); } @@ -95,9 +97,9 @@ /* Check for overflow */ if (nbytes / sizeof(PyObject *) != (size_t)size) return PyErr_NoMemory(); - if (num_free_lists) { - num_free_lists--; - op = free_lists[num_free_lists]; + if (numfree) { + numfree--; + op = free_list[numfree]; _Py_NewReference((PyObject *)op); } else { op = PyObject_GC_New(PyListObject, &PyList_Type); @@ -265,8 +267,8 @@ } PyMem_FREE(op->ob_item); } - if (num_free_lists < MAXFREELISTS && PyList_CheckExact(op)) - free_lists[num_free_lists++] = op; + if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op)) + free_list[numfree++] = op; else Py_TYPE(op)->tp_free((PyObject *)op); Py_TRASHCAN_SAFE_END(op) Modified: python/branches/py3k/Objects/methodobject.c ============================================================================== --- python/branches/py3k/Objects/methodobject.c (original) +++ python/branches/py3k/Objects/methodobject.c Wed Feb 6 15:31:34 2008 @@ -4,7 +4,14 @@ #include "Python.h" #include "structmember.h" +/* Free list for method objects to safe malloc/free overhead + * The m_self element is used to chain the objects. + */ static PyCFunctionObject *free_list = NULL; +static int numfree = 0; +#ifndef PyCFunction_MAXFREELIST +#define PyCFunction_MAXFREELIST 256 +#endif PyObject * PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) @@ -14,6 +21,7 @@ if (op != NULL) { free_list = (PyCFunctionObject *)(op->m_self); PyObject_INIT(op, &PyCFunction_Type); + numfree--; } else { op = PyObject_GC_New(PyCFunctionObject, &PyCFunction_Type); @@ -116,8 +124,14 @@ _PyObject_GC_UNTRACK(m); Py_XDECREF(m->m_self); Py_XDECREF(m->m_module); - m->m_self = (PyObject *)free_list; - free_list = m; + if (numfree < PyCFunction_MAXFREELIST) { + m->m_self = (PyObject *)free_list; + free_list = m; + numfree++; + } + else { + PyObject_GC_Del(m); + } } static PyObject * @@ -312,14 +326,16 @@ PyCFunctionObject *v = free_list; free_list = (PyCFunctionObject *)(v->m_self); PyObject_GC_Del(v); + numfree--; } + assert(numfree == 0); } /* PyCFunction_New() is now just a macro that calls PyCFunction_NewEx(), but it's part of the API so we need to keep a function around that existing C extensions can call. */ - + #undef PyCFunction_New PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *); Modified: python/branches/py3k/Objects/setobject.c ============================================================================== --- python/branches/py3k/Objects/setobject.c (original) +++ python/branches/py3k/Objects/setobject.c Wed Feb 6 15:31:34 2008 @@ -52,9 +52,11 @@ } while(0) /* Reuse scheme to save calls to malloc, free, and memset */ -#define MAXFREESETS 80 -static PySetObject *free_sets[MAXFREESETS]; -static int num_free_sets = 0; +#ifndef PySet_MAXFREELIST +#define PySet_MAXFREELIST 80 +#endif +static PySetObject *free_list[PySet_MAXFREELIST]; +static int numfree = 0; /* @@ -561,8 +563,8 @@ } if (so->table != so->smalltable) PyMem_DEL(so->table); - if (num_free_sets < MAXFREESETS && PyAnySet_CheckExact(so)) - free_sets[num_free_sets++] = so; + if (numfree < PySet_MAXFREELIST && PyAnySet_CheckExact(so)) + free_list[numfree++] = so; else Py_TYPE(so)->tp_free(so); Py_TRASHCAN_SAFE_END(so) @@ -975,9 +977,9 @@ } /* create PySetObject structure */ - if (num_free_sets && + if (numfree && (type == &PySet_Type || type == &PyFrozenSet_Type)) { - so = free_sets[--num_free_sets]; + so = free_list[--numfree]; assert (so != NULL && PyAnySet_CheckExact(so)); Py_TYPE(so) = type; _Py_NewReference((PyObject *)so); @@ -1045,9 +1047,9 @@ { PySetObject *so; - while (num_free_sets) { - num_free_sets--; - so = free_sets[num_free_sets]; + while (numfree) { + numfree--; + so = free_list[numfree]; PyObject_GC_Del(so); } Py_CLEAR(dummy); Modified: python/branches/py3k/Objects/tupleobject.c ============================================================================== --- python/branches/py3k/Objects/tupleobject.c (original) +++ python/branches/py3k/Objects/tupleobject.c Wed Feb 6 15:31:34 2008 @@ -4,19 +4,19 @@ #include "Python.h" /* Speed optimization to avoid frequent malloc/free of small tuples */ -#ifndef MAXSAVESIZE -#define MAXSAVESIZE 20 /* Largest tuple to save on free list */ +#ifndef PyTuple_MAXSAVESIZE +#define PyTuple_MAXSAVESIZE 20 /* Largest tuple to save on free list */ #endif -#ifndef MAXSAVEDTUPLES -#define MAXSAVEDTUPLES 2000 /* Maximum number of tuples of each size to save */ +#ifndef PyTuple_MAXFREELIST +#define PyTuple_MAXFREELIST 2000 /* Maximum number of tuples of each size to save */ #endif -#if MAXSAVESIZE > 0 -/* Entries 1 up to MAXSAVESIZE are free lists, entry 0 is the empty +#if PyTuple_MAXSAVESIZE > 0 +/* Entries 1 up to PyTuple_MAXSAVESIZE are free lists, entry 0 is the empty tuple () of which at most one instance will be allocated. */ -static PyTupleObject *free_tuples[MAXSAVESIZE]; -static int num_free_tuples[MAXSAVESIZE]; +static PyTupleObject *free_list[PyTuple_MAXSAVESIZE]; +static int numfree[PyTuple_MAXSAVESIZE]; #endif #ifdef COUNT_ALLOCS int fast_tuple_allocs; @@ -32,18 +32,18 @@ PyErr_BadInternalCall(); return NULL; } -#if MAXSAVESIZE > 0 - if (size == 0 && free_tuples[0]) { - op = free_tuples[0]; +#if PyTuple_MAXSAVESIZE > 0 + if (size == 0 && free_list[0]) { + op = free_list[0]; Py_INCREF(op); #ifdef COUNT_ALLOCS tuple_zero_allocs++; #endif return (PyObject *) op; } - if (size < MAXSAVESIZE && (op = free_tuples[size]) != NULL) { - free_tuples[size] = (PyTupleObject *) op->ob_item[0]; - num_free_tuples[size]--; + if (size < PyTuple_MAXSAVESIZE && (op = free_list[size]) != NULL) { + free_list[size] = (PyTupleObject *) op->ob_item[0]; + numfree[size]--; #ifdef COUNT_ALLOCS fast_tuple_allocs++; #endif @@ -71,10 +71,10 @@ } for (i=0; i < size; i++) op->ob_item[i] = NULL; -#if MAXSAVESIZE > 0 +#if PyTuple_MAXSAVESIZE > 0 if (size == 0) { - free_tuples[0] = op; - ++num_free_tuples[0]; + free_list[0] = op; + ++numfree[0]; Py_INCREF(op); /* extra INCREF so that this is never freed */ } #endif @@ -167,14 +167,14 @@ i = len; while (--i >= 0) Py_XDECREF(op->ob_item[i]); -#if MAXSAVESIZE > 0 - if (len < MAXSAVESIZE && - num_free_tuples[len] < MAXSAVEDTUPLES && +#if PyTuple_MAXSAVESIZE > 0 + if (len < PyTuple_MAXSAVESIZE && + numfree[len] < PyTuple_MAXFREELIST && Py_TYPE(op) == &PyTuple_Type) { - op->ob_item[0] = (PyObject *) free_tuples[len]; - num_free_tuples[len]++; - free_tuples[len] = op; + op->ob_item[0] = (PyObject *) free_list[len]; + numfree[len]++; + free_list[len] = op; goto done; /* return */ } #endif @@ -756,16 +756,16 @@ void PyTuple_Fini(void) { -#if MAXSAVESIZE > 0 +#if PyTuple_MAXSAVESIZE > 0 int i; - Py_XDECREF(free_tuples[0]); - free_tuples[0] = NULL; + Py_XDECREF(free_list[0]); + free_list[0] = NULL; - for (i = 1; i < MAXSAVESIZE; i++) { + for (i = 1; i < PyTuple_MAXSAVESIZE; i++) { PyTupleObject *p, *q; - p = free_tuples[i]; - free_tuples[i] = NULL; + p = free_list[i]; + free_list[i] = NULL; while (p) { q = p; p = (PyTupleObject *)(p->ob_item[0]); Modified: python/branches/py3k/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k/Objects/unicodeobject.c (original) +++ python/branches/py3k/Objects/unicodeobject.c Wed Feb 6 15:31:34 2008 @@ -54,7 +54,7 @@ /* Limit for the Unicode object free list */ -#define MAX_UNICODE_FREELIST_SIZE 1024 +#define PyUnicode_MAXFREELIST 1024 /* Limit for the Unicode object free list stay alive optimization. @@ -62,7 +62,7 @@ all objects on the free list having a size less than this limit. This reduces malloc() overhead for small Unicode objects. - At worst this will result in MAX_UNICODE_FREELIST_SIZE * + At worst this will result in PyUnicode_MAXFREELIST * (sizeof(PyUnicodeObject) + KEEPALIVE_SIZE_LIMIT + malloc()-overhead) bytes of unused garbage. @@ -106,8 +106,8 @@ static PyObject *interned; /* Free list for Unicode objects */ -static PyUnicodeObject *unicode_freelist; -static int unicode_freelist_size; +static PyUnicodeObject *free_list; +static int numfree; /* The empty Unicode object is shared to improve performance. */ static PyUnicodeObject *unicode_empty; @@ -313,10 +313,10 @@ } /* Unicode freelist & memory allocation */ - if (unicode_freelist) { - unicode = unicode_freelist; - unicode_freelist = *(PyUnicodeObject **)unicode; - unicode_freelist_size--; + if (free_list) { + unicode = free_list; + free_list = *(PyUnicodeObject **)unicode; + numfree--; if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, never downsize it. */ @@ -386,7 +386,7 @@ } if (PyUnicode_CheckExact(unicode) && - unicode_freelist_size < MAX_UNICODE_FREELIST_SIZE) { + numfree < PyUnicode_MAXFREELIST) { /* Keep-Alive optimization */ if (unicode->length >= KEEPALIVE_SIZE_LIMIT) { PyMem_DEL(unicode->str); @@ -398,9 +398,9 @@ unicode->defenc = NULL; } /* Add to free list */ - *(PyUnicodeObject **)unicode = unicode_freelist; - unicode_freelist = unicode; - unicode_freelist_size++; + *(PyUnicodeObject **)unicode = free_list; + free_list = unicode; + numfree++; } else { PyMem_DEL(unicode->str); @@ -8033,7 +8033,7 @@ static PyObject* unicode_freelistsize(PyUnicodeObject *self) { - return PyLong_FromLong(unicode_freelist_size); + return PyLong_FromLong(numfree); } #endif @@ -9090,8 +9090,8 @@ }; /* Init the implementation */ - unicode_freelist = NULL; - unicode_freelist_size = 0; + free_list = NULL; + numfree = 0; unicode_empty = _PyUnicode_New(0); if (!unicode_empty) return; @@ -9127,7 +9127,7 @@ } } - for (u = unicode_freelist; u != NULL;) { + for (u = free_list; u != NULL;) { PyUnicodeObject *v = u; u = *(PyUnicodeObject **)u; if (v->str) @@ -9135,8 +9135,8 @@ Py_XDECREF(v->defenc); PyObject_Del(v); } - unicode_freelist = NULL; - unicode_freelist_size = 0; + free_list = NULL; + numfree = 0; } void Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Wed Feb 6 15:31:34 2008 @@ -652,11 +652,16 @@ return b->b_iused++; } -/* Set the i_lineno member of the instruction at offse off if the - line number for the current expression/statement (?) has not +/* Set the i_lineno member of the instruction at offset off if the + line number for the current expression/statement has not already been set. If it has been set, the call has no effect. - Every time a new node is b + The line number is reset in the following cases: + - when entering a new scope + - on each statement + - on each expression that start a new line + - before the "except" clause + - before the "for" and "while" expressions */ static void @@ -1750,9 +1755,8 @@ VISIT(c, expr, s->v.For.iter); ADDOP(c, GET_ITER); compiler_use_next_block(c, start); - /* XXX(nnorwitz): is there a better way to handle this? - for loops are special, we want to be able to trace them - each time around, so we need to set an extra line number. */ + /* for expressions must be traced on each iteration, + so we need to set an extra line number. */ c->u->u_lineno_set = 0; ADDOP_JREL(c, FOR_ITER, cleanup); VISIT(c, expr, s->v.For.target); @@ -1799,6 +1803,9 @@ if (!compiler_push_fblock(c, LOOP, loop)) return 0; if (constant == -1) { + /* while expressions must be traced on each iteration, + so we need to set an extra line number. */ + c->u->u_lineno_set = 0; VISIT(c, expr, s->v.While.test); ADDOP_JREL(c, JUMP_IF_FALSE, anchor); ADDOP(c, POP_TOP); @@ -1979,8 +1986,8 @@ s->v.TryExcept.handlers, i); if (!handler->type && i < n-1) return compiler_error(c, "default 'except:' must be last"); - c->u->u_lineno_set = 0; - c->u->u_lineno = handler->lineno; + c->u->u_lineno_set = 0; + c->u->u_lineno = handler->lineno; except = compiler_new_block(c); if (except == NULL) return 0; @@ -3762,10 +3769,7 @@ assert(d_bytecode >= 0); assert(d_lineno >= 0); - /* XXX(nnorwitz): is there a better way to handle this? - for loops are special, we want to be able to trace them - each time around, so we need to set an extra line number. */ - if (d_lineno == 0 && i->i_opcode != FOR_ITER) + if(d_bytecode == 0 && d_lineno == 0) return 1; if (d_bytecode > 255) { From python-3000-checkins at python.org Wed Feb 6 20:54:00 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 20:54:00 +0100 (CET) Subject: [Python-3000-checkins] r60623 - python/branches/py3k/Doc/library/collections.rst Message-ID: <20080206195400.ACE011E4021@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 20:54:00 2008 New Revision: 60623 Modified: python/branches/py3k/Doc/library/collections.rst Log: Fix-up the collections docs. * Start filling in detail and examples for ABCs * Fix old reference to IterableUserDict. * Neaten-up the introduction. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Wed Feb 6 20:54:00 2008 @@ -10,19 +10,25 @@ This module implements high-performance container datatypes. Currently, there are two datatypes, :class:`deque` and :class:`defaultdict`, and -one datatype factory function, :func:`namedtuple`. Python already -includes built-in containers, :class:`dict`, :class:`list`, -:class:`set`, and :class:`tuple`. In addition, the optional :mod:`bsddb` -module has a :meth:`bsddb.btopen` method that can be used to create in-memory -or file based ordered dictionaries with string keys. +one datatype factory function, :func:`namedtuple`. -Future editions of the standard library may include balanced trees and -ordered dictionaries. +The specialized containers provided in this module provide alternatives +to Python's general purpose built-in containers, :class:`dict`, +:class:`list`, :class:`set`, and :class:`tuple`. + +Besides the containers provided here, the optional :mod:`bsddb` +module offers the ability to create in-memory or file based ordered +dictionaries with string keys using the :meth:`bsddb.btopen` method. In addition to containers, the collections module provides some ABCs -(abstract base classes) that can be used to test whether -a class provides a particular interface, for example, is it hashable or -a mapping. The ABCs provided include those in the following table: +(abstract base classes) that can be used to test whether a class +provides a particular interface, for example, is it hashable or +a mapping. + +ABCs - abstract base classes +---------------------------- + +The collections module offers the following ABCs: ===================================== ================================================================================ ABC Notes @@ -62,18 +68,36 @@ ``__isub__()`` ===================================== ================================================================================ -.. XXX Have not included them all and the notes are incomplete -.. long = lines improves the layout - These ABCs allow us to ask classes or instances if they provide particular functionality, for example:: - from collections import Sized - size = None - if isinstance(myvar, Sized): + if isinstance(myvar, collections.Sized): size = len(myvar) +Several of the ABCs are also useful as mixins that make it easier to develop +classes supporting container APIs. For example, to write a class supporting +the full :class:`Set` API, it only necessary to supply the three underlying +abstract methods: :meth:`__contains__`, :meth:`__iter__`, and :meth:`__len__`. +The ABC supplies the remaining methods such as :meth:`__and__` and +:meth:`isdisjoint` :: + + class ListBasedSet(collections.Set): + 'Alternate set implementation favoring space over speed' + def __init__(self, iterable): + self.elements = list(set(iterable)) + def __iter__(self): + return iter(self.elements) + def __contains__(self, value): + return value in self.elements + def __len__(self): + return len(self.elements) + + s1 = ListBasedSet('abcdef') + s2 = ListBasedSet('defghi') + overlap = s1 & s2 # The __and__() method is supported automatically + + (For more about ABCs, see the :mod:`abc` module and :pep:`3119`.) @@ -607,8 +631,7 @@ be kept, allowing it be used for other purposes. In addition to supporting the methods and operations of mappings, -:class:`UserDict` and :class:`IterableUserDict` instances -provide the following attribute: +:class:`UserDict` instances provide the following attribute: .. attribute:: UserDict.data From python-3000-checkins at python.org Wed Feb 6 21:47:09 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 21:47:09 +0100 (CET) Subject: [Python-3000-checkins] r60627 - python/branches/py3k/Lib/_abcoll.py Message-ID: <20080206204709.E76921E4031@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 21:47:09 2008 New Revision: 60627 Modified: python/branches/py3k/Lib/_abcoll.py Log: Fix-up the _from_iterable() method to return instances of the subclass where it is used. In its previous form, it always returned instance of frozenset which makes this ABC nearly useless as a mixin. In its new form, it needs to be able to assume that the constructor will take a frozenset input. This will usually be true. If it is not, then only one method (this one) will need to be overriden by the subclass to let it know about the unique constructor signature. Will add info on this to the docs. Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Wed Feb 6 21:47:09 2008 @@ -204,7 +204,12 @@ @classmethod def _from_iterable(cls, it): - return frozenset(it) + '''Construct an instance of the class from any iterable input. + + Must override this method if the class constructor signature + will not accept a frozenset for an input. + ''' + return cls(frozenset(it)) def __and__(self, other): if not isinstance(other, Iterable): From python-3000-checkins at python.org Wed Feb 6 21:59:41 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 21:59:41 +0100 (CET) Subject: [Python-3000-checkins] r60628 - python/branches/py3k/Lib/UserList.py python/branches/py3k/Lib/UserString.py Message-ID: <20080206205941.59B221E4021@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 21:59:41 2008 New Revision: 60628 Modified: python/branches/py3k/Lib/UserList.py python/branches/py3k/Lib/UserString.py Log: Let the world know that UserList is a MutableSequence. Modified: python/branches/py3k/Lib/UserList.py ============================================================================== --- python/branches/py3k/Lib/UserList.py (original) +++ python/branches/py3k/Lib/UserList.py Wed Feb 6 21:59:41 2008 @@ -1,6 +1,8 @@ """A more or less complete user-defined wrapper around list objects.""" -class UserList: +import collections + +class UserList(collections.MutableSequence): def __init__(self, initlist=None): self.data = [] if initlist is not None: @@ -69,3 +71,5 @@ self.data.extend(other.data) else: self.data.extend(other) + +collections.MutableSequence.register(UserList) Modified: python/branches/py3k/Lib/UserString.py ============================================================================== --- python/branches/py3k/Lib/UserString.py (original) +++ python/branches/py3k/Lib/UserString.py Wed Feb 6 21:59:41 2008 @@ -6,10 +6,11 @@ This module requires Python 1.6 or later. """ import sys +import collections __all__ = ["UserString","MutableString"] -class UserString: +class UserString(collections.Sequence): def __init__(self, seq): if isinstance(seq, str): self.data = seq @@ -161,7 +162,9 @@ def upper(self): return self.__class__(self.data.upper()) def zfill(self, width): return self.__class__(self.data.zfill(width)) -class MutableString(UserString): +collections.Sequence.register(UserString) + +class MutableString(UserString, collections.MutableSequence): """mutable string objects Python strings are immutable objects. This has the advantage, that @@ -230,6 +233,8 @@ self.data *= n return self +collections.MutableSequence.register(MutableString) + if __name__ == "__main__": # execute the regression test to stdout, if called as a script: import os From python-3000-checkins at python.org Wed Feb 6 23:14:56 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 23:14:56 +0100 (CET) Subject: [Python-3000-checkins] r60631 - python/branches/py3k/Lib/UserString.py Message-ID: <20080206221456.214A31E4020@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 23:14:55 2008 New Revision: 60631 Modified: python/branches/py3k/Lib/UserString.py Log: MutableSequence requires an insert() method. Modified: python/branches/py3k/Lib/UserString.py ============================================================================== --- python/branches/py3k/Lib/UserString.py (original) +++ python/branches/py3k/Lib/UserString.py Wed Feb 6 23:14:55 2008 @@ -232,6 +232,8 @@ def __imul__(self, n): self.data *= n return self + def insert(self, index, value): + self[index:index] = value collections.MutableSequence.register(MutableString) From python-3000-checkins at python.org Wed Feb 6 23:45:43 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Wed, 6 Feb 2008 23:45:43 +0100 (CET) Subject: [Python-3000-checkins] r60633 - python/branches/py3k/Lib/test/test_iterlen.py Message-ID: <20080206224543.BCE1D1E4020@bag.python.org> Author: raymond.hettinger Date: Wed Feb 6 23:45:43 2008 New Revision: 60633 Modified: python/branches/py3k/Lib/test/test_iterlen.py Log: Reversed UserLists are not required to support __length_hint__. Modified: python/branches/py3k/Lib/test/test_iterlen.py ============================================================================== --- python/branches/py3k/Lib/test/test_iterlen.py (original) +++ python/branches/py3k/Lib/test/test_iterlen.py Wed Feb 6 23:45:43 2008 @@ -45,7 +45,6 @@ from test import test_support from itertools import repeat from collections import deque -from UserList import UserList from builtins import len as _len n = 10 @@ -196,43 +195,6 @@ d.extend(range(20)) self.assertEqual(len(it), 0) -class TestSeqIter(TestInvariantWithoutMutations): - - def setUp(self): - self.it = iter(UserList(range(n))) - - def test_mutation(self): - d = UserList(range(n)) - it = iter(d) - next(it) - next(it) - self.assertEqual(len(it), n-2) - d.append(n) - self.assertEqual(len(it), n-1) # grow with append - d[1:] = [] - self.assertEqual(len(it), 0) - self.assertEqual(list(it), []) - d.extend(range(20)) - self.assertEqual(len(it), 0) - -class TestSeqIterReversed(TestInvariantWithoutMutations): - - def setUp(self): - self.it = reversed(UserList(range(n))) - - def test_mutation(self): - d = UserList(range(n)) - it = reversed(d) - next(it) - next(it) - self.assertEqual(len(it), n-2) - d.append(n) - self.assertEqual(len(it), n-2) # ignore append - d[1:] = [] - self.assertEqual(len(it), 0) - self.assertEqual(list(it), []) # confirm invariant - d.extend(range(20)) - self.assertEqual(len(it), 0) def test_main(): @@ -249,8 +211,6 @@ TestSet, TestList, TestListReversed, - TestSeqIter, - TestSeqIterReversed, ] test_support.run_unittest(*unittests) From python-3000-checkins at python.org Thu Feb 7 01:41:02 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Thu, 7 Feb 2008 01:41:02 +0100 (CET) Subject: [Python-3000-checkins] r60635 - in python/branches/py3k: Lib/test/seq_tests.py Misc/NEWS Objects/tupleobject.c Message-ID: <20080207004102.CB6481E4702@bag.python.org> Author: raymond.hettinger Date: Thu Feb 7 01:41:02 2008 New Revision: 60635 Modified: python/branches/py3k/Lib/test/seq_tests.py python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/tupleobject.c Log: Issue 2025: Add index() and count() methods to tuple so that it will follow the ABC for collections.Sequence. Modified: python/branches/py3k/Lib/test/seq_tests.py ============================================================================== --- python/branches/py3k/Lib/test/seq_tests.py (original) +++ python/branches/py3k/Lib/test/seq_tests.py Thu Feb 7 01:41:02 2008 @@ -4,6 +4,7 @@ import unittest from test import test_support +import sys # Various iterables # This is used for checking the constructor (here and in test_deque.py) @@ -326,3 +327,64 @@ self.assertEqual(a.__getitem__(slice(3,5)), self.type2test([])) self.assertRaises(ValueError, a.__getitem__, slice(0, 10, 0)) self.assertRaises(TypeError, a.__getitem__, 'x') + + def test_count(self): + a = self.type2test([0, 1, 2])*3 + self.assertEqual(a.count(0), 3) + self.assertEqual(a.count(1), 3) + self.assertEqual(a.count(3), 0) + + self.assertRaises(TypeError, a.count) + + class BadExc(Exception): + pass + + class BadCmp: + def __eq__(self, other): + if other == 2: + raise BadExc() + return False + + self.assertRaises(BadExc, a.count, BadCmp()) + + def test_index(self): + u = self.type2test([0, 1]) + self.assertEqual(u.index(0), 0) + self.assertEqual(u.index(1), 1) + self.assertRaises(ValueError, u.index, 2) + + u = self.type2test([-2, -1, 0, 0, 1, 2]) + self.assertEqual(u.count(0), 2) + self.assertEqual(u.index(0), 2) + self.assertEqual(u.index(0, 2), 2) + self.assertEqual(u.index(-2, -10), 0) + self.assertEqual(u.index(0, 3), 3) + self.assertEqual(u.index(0, 3, 4), 3) + self.assertRaises(ValueError, u.index, 2, 0, -10) + + self.assertRaises(TypeError, u.index) + + class BadExc(Exception): + pass + + class BadCmp: + def __eq__(self, other): + if other == 2: + raise BadExc() + return False + + a = self.type2test([0, 1, 2, 3]) + self.assertRaises(BadExc, a.index, BadCmp()) + + a = self.type2test([-2, -1, 0, 0, 1, 2]) + self.assertEqual(a.index(0), 2) + self.assertEqual(a.index(0, 2), 2) + self.assertEqual(a.index(0, -4), 2) + self.assertEqual(a.index(-2, -10), 0) + self.assertEqual(a.index(0, 3), 3) + self.assertEqual(a.index(0, -3), 3) + self.assertEqual(a.index(0, 3, 4), 3) + self.assertEqual(a.index(0, -3, -2), 3) + self.assertEqual(a.index(0, -4*sys.maxsize, 4*sys.maxsize), 2) + self.assertRaises(ValueError, a.index, 0, 4*sys.maxsize,-4*sys.maxsize) + self.assertRaises(ValueError, a.index, 2, 0, -10) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Feb 7 01:41:02 2008 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #2025 : Add tuple.count() and tuple.index() methods to comply with + the collections.Sequence API. + - Fixed multiple reinitialization of the Python interpreter. The small int list in longobject.c has caused a seg fault during the third finalization. Modified: python/branches/py3k/Objects/tupleobject.c ============================================================================== --- python/branches/py3k/Objects/tupleobject.c (original) +++ python/branches/py3k/Objects/tupleobject.c Thu Feb 7 01:41:02 2008 @@ -430,6 +430,53 @@ return (PyObject *) np; } +static PyObject * +tupleindex(PyTupleObject *self, PyObject *args) +{ + Py_ssize_t i, start=0, stop=Py_SIZE(self); + PyObject *v; + + if (!PyArg_ParseTuple(args, "O|O&O&:index", &v, + _PyEval_SliceIndex, &start, + _PyEval_SliceIndex, &stop)) + return NULL; + if (start < 0) { + start += Py_SIZE(self); + if (start < 0) + start = 0; + } + if (stop < 0) { + stop += Py_SIZE(self); + if (stop < 0) + stop = 0; + } + for (i = start; i < stop && i < Py_SIZE(self); i++) { + int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); + if (cmp > 0) + return PyLong_FromSsize_t(i); + else if (cmp < 0) + return NULL; + } + PyErr_SetString(PyExc_ValueError, "tuple.index(x): x not in list"); + return NULL; +} + +static PyObject * +tuplecount(PyTupleObject *self, PyObject *v) +{ + Py_ssize_t count = 0; + Py_ssize_t i; + + for (i = 0; i < Py_SIZE(self); i++) { + int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); + if (cmp > 0) + count++; + else if (cmp < 0) + return NULL; + } + return PyLong_FromSsize_t(count); +} + static int tupletraverse(PyTupleObject *o, visitproc visit, void *arg) { @@ -636,8 +683,15 @@ } +PyDoc_STRVAR(index_doc, +"T.index(value, [start, [stop]]) -> integer -- return first index of value"); +PyDoc_STRVAR(count_doc, +"T.count(value) -> integer -- return number of occurrences of value"); + static PyMethodDef tuple_methods[] = { {"__getnewargs__", (PyCFunction)tuple_getnewargs, METH_NOARGS}, + {"index", (PyCFunction)tupleindex, METH_VARARGS, index_doc}, + {"count", (PyCFunction)tuplecount, METH_O, count_doc}, {NULL, NULL} /* sentinel */ }; From python-3000-checkins at python.org Thu Feb 7 21:09:43 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Thu, 7 Feb 2008 21:09:43 +0100 (CET) Subject: [Python-3000-checkins] r60656 - python/branches/py3k/Doc/library/decimal.rst Message-ID: <20080207200943.EE2081E4002@bag.python.org> Author: raymond.hettinger Date: Thu Feb 7 21:09:43 2008 New Revision: 60656 Modified: python/branches/py3k/Doc/library/decimal.rst Log: Simplify float conversion recipe. Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Thu Feb 7 21:09:43 2008 @@ -1516,39 +1516,29 @@ A. Yes, all binary floating point numbers can be exactly expressed as a Decimal. An exact conversion may take more precision than intuition would -suggest, so trapping :const:`Inexact` will signal a need for more precision:: +suggest, so we trap :const:`Inexact` to signal a need for more precision:: - def floatToDecimal(f): - "Convert a floating point number to a Decimal with no loss of information" - # Transform (exactly) a float to a mantissa (0.5 <= abs(m) < 1.0) and an - # exponent. Double the mantissa until it is an integer. Use the integer - # mantissa and exponent to compute an equivalent Decimal. If this cannot - # be done exactly, then retry with more precision. - - mantissa, exponent = math.frexp(f) - while mantissa != int(mantissa): - mantissa *= 2.0 - exponent -= 1 - mantissa = int(mantissa) - - oldcontext = getcontext() - setcontext(Context(traps=[Inexact])) - try: - while True: - try: - return mantissa * Decimal(2) ** exponent - except Inexact: - getcontext().prec += 1 - finally: - setcontext(oldcontext) + def float_to_decimal(f): + "Convert a floating point number to a Decimal with no loss of information" + n, d = f.as_integer_ratio() + with localcontext() as ctx: + ctx.traps[Inexact] = True + while True: + try: + return Decimal(n) / Decimal(d) + except Inexact: + ctx.prec += 1 -Q. Why isn't the :func:`floatToDecimal` routine included in the module? + >>> float_to_decimal(math.pi) + Decimal("3.141592653589793115997963468544185161590576171875") + +Q. Why isn't the :func:`float_to_decimal` routine included in the module? A. There is some question about whether it is advisable to mix binary and decimal floating point. Also, its use requires some care to avoid the representation issues associated with binary floating point:: - >>> floatToDecimal(1.1) + >>> float_to_decimal(1.1) Decimal("1.100000000000000088817841970012523233890533447265625") Q. Within a complex calculation, how can I make sure that I haven't gotten a From python-3000-checkins at python.org Fri Feb 8 14:24:20 2008 From: python-3000-checkins at python.org (mark.summerfield) Date: Fri, 8 Feb 2008 14:24:20 +0100 (CET) Subject: [Python-3000-checkins] r60669 - python/branches/py3k/Doc/library/datatypes.rst Message-ID: <20080208132420.CCB891E4016@bag.python.org> Author: mark.summerfield Date: Fri Feb 8 14:24:20 2008 New Revision: 60669 Modified: python/branches/py3k/Doc/library/datatypes.rst Log: Tiny grammatical fix. Modified: python/branches/py3k/Doc/library/datatypes.rst ============================================================================== --- python/branches/py3k/Doc/library/datatypes.rst (original) +++ python/branches/py3k/Doc/library/datatypes.rst Fri Feb 8 14:24:20 2008 @@ -11,8 +11,8 @@ Python also provides some built-in data types, in particular, :class:`dict`, :class:`list`, :class:`set` and :class:`frozenset`, and -:class:`tuple`. The :class:`str` class can be used to strings, including -Unicode strings, and the :class:`bytes` class to handle binary data. +:class:`tuple`. The :class:`str` class is used to hold +Unicode strings, and the :class:`bytes` class is used to hold binary data. The following modules are documented in this chapter: From python-3000-checkins at python.org Sat Feb 9 00:46:23 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 00:46:23 +0100 (CET) Subject: [Python-3000-checkins] r60676 - python/branches/py3k/Doc/library/collections.rst Message-ID: <20080208234623.60C641E4003@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 00:46:23 2008 New Revision: 60676 Modified: python/branches/py3k/Doc/library/collections.rst Log: Smalls improvement to example in the docs for collections ABCs. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Sat Feb 9 00:46:23 2008 @@ -43,10 +43,8 @@ :class:`Iterable`, and :class:`Sized`, and in addition defines ``__getitem__()``, ``get()``, - ``__contains__()``, ``__len__()``, ``__eq__()``, ``__ne__()``, - ``__iter__()``, ``keys()``, - ``items()``, and ``values()`` + ``keys()``, ``items()``, and ``values()`` :class:`collections.MutableMapping` Derived from :class:`Mapping` :class:`collections.Sequence` Derived from :class:`Container`, :class:`Iterable`, and :class:`Sized`, @@ -83,9 +81,13 @@ :meth:`isdisjoint` :: class ListBasedSet(collections.Set): - 'Alternate set implementation favoring space over speed' + ''' Alternate set implementation favoring space over speed + and not requiring the set elements to be hashable. ''' def __init__(self, iterable): - self.elements = list(set(iterable)) + self.elements = lst = [] + for value in iterable: + if value not in lst: + lst.append(value) def __iter__(self): return iter(self.elements) def __contains__(self, value): From python-3000-checkins at python.org Sat Feb 9 01:08:17 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 01:08:17 +0100 (CET) Subject: [Python-3000-checkins] r60678 - python/branches/py3k/Lib/_abcoll.py Message-ID: <20080209000817.2E6FB1E4003@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 01:08:16 2008 New Revision: 60678 Modified: python/branches/py3k/Lib/_abcoll.py Log: Merge r60674 an 60675. Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Sat Feb 9 01:08:16 2008 @@ -197,11 +197,24 @@ return NotImplemented return len(self) < len(other) and self.__le__(other) + def __gt__(self, other): + if not isinstance(other, Set): + return NotImplemented + return other < self + + def __ge__(self, other): + if not isinstance(other, Set): + return NotImplemented + return other <= self + def __eq__(self, other): if not isinstance(other, Set): return NotImplemented return len(self) == len(other) and self.__le__(other) + def __ne__(self, other): + return not (self == other) + @classmethod def _from_iterable(cls, it): '''Construct an instance of the class from any iterable input. @@ -528,13 +541,13 @@ def __iter__(self): i = 0 - while True: - try: + try: + while True: v = self[i] - except IndexError: - break - yield v - i += 1 + yield v + i += 1 + except IndexError: + return def __contains__(self, value): for v in self: From python-3000-checkins at python.org Sat Feb 9 03:17:06 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 03:17:06 +0100 (CET) Subject: [Python-3000-checkins] r60680 - python/branches/py3k/Doc/library/collections.rst Message-ID: <20080209021706.9130E1E4004@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 03:17:06 2008 New Revision: 60680 Modified: python/branches/py3k/Doc/library/collections.rst Log: Finish the collections ABC table. Identify which abstract methods need to be defined. Show the inheritance hierarchy. List all of the mixin methods provided automatically. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Sat Feb 9 03:17:06 2008 @@ -30,41 +30,42 @@ The collections module offers the following ABCs: -===================================== ================================================================================ -ABC Notes -===================================== ================================================================================ -:class:`collections.Container` Defines ``__contains__()`` -:class:`collections.Hashable` Defines ``__hash__()`` -:class:`collections.Iterable` Defines ``__iter__()`` -:class:`collections.Iterator` Derived from :class:`Iterable` and in - addition defines ``__next__()`` -:class:`collections.Sized` Defines ``__len__()`` -:class:`collections.Mapping` Derived from :class:`Container`, - :class:`Iterable`, - and :class:`Sized`, and in addition - defines ``__getitem__()``, ``get()``, - ``__eq__()``, ``__ne__()``, - ``keys()``, ``items()``, and ``values()`` -:class:`collections.MutableMapping` Derived from :class:`Mapping` -:class:`collections.Sequence` Derived from :class:`Container`, - :class:`Iterable`, and :class:`Sized`, - and in addition defines - ``__getitem__()`` -:class:`collections.MutableSequence` Derived from :class:`Sequence` -:class:`collections.Set` Derived from :class:`Container`, - :class:`Iterable`, and :class:`Sized`, - add in addition defines - ``__le__()``, ``__lt__()``, - ``__eq__()``, ``__and__()``, - ``__or__()``, ``__sub__()``, - ``__xor__()``, and ``isdisjoint()``, -:class:`collections.MutableSet` Derived from :class:`Set` and in - addition defines ``add()``, - ``clear()``, ``discard()``, ``pop()``, - ``remove()``, ``__ior__()``, - ``__iand__()``, ``__ixor__()``, and - ``__isub__()`` -===================================== ================================================================================ +========================= ==================== ====================== ==================================================== +ABC Inherits Abstract Methods Mixin Methods +========================= ==================== ====================== ==================================================== +:class:`Container` ``__contains__`` +:class:`Hashable` ``__hash__`` +:class:`Iterable` ``__iter__`` +:class:`Iterator` :class:`Iterable` ``__next__`` ``__iter__`` +:class:`Sized` ``__len__`` + +:class:`Mapping` :class:`Sized`, ``__getitem__``, ``__contains__``, ``keys``, ``items``, ``values``, + :class:`Iterable`, ``__len__``. and ``get``, ``__eq__``, and ``__ne__`` + :class:`Container` ``__iter__`` + +:class:`MutableMapping` :class:`Mapping` ``__getitem__`` Inherited Mapping methods and + ``__setitem__``, ``pop``, ``popitem``, ``clear``, ``update``, + ``__delitem__``, and ``setdefault`` + ``__iter__``, and + ``__len__`` + +:class:`Sequence` :class:`Sized`, ``__getitem__`` ``__contains__``. ``__iter__``, ``__reversed__``. + :class:`Iterable`, and ``__len__`` ``index``, and ``count`` + :class:`Container` + +:class:`MutableSequnce` :class:`Sequence` ``__getitem__`` Inherited Sequence methods and + ``__delitem__``, ``append``, ``reverse``, ``extend``, ``pop``, + ``insert``, ``remove``, and ``__iadd__`` + and ``__len__`` + +:class:`Set` :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, + :class:`Iterable`, ``__iter__``, and ``__gt__``, ``__ge__``, ``__and__``, ``__or__`` + :class:`Container` ``__contains__`` ``__sub__``, ``__xor__``, and ``isdisjoint`` + +:class:`MutableSet` :class:`Set` ``add`` and Inherited Set methods and + ``discard`` ``clear``, ``pop``, ``remove``, ``__ior__``, + ``__iand__``, ``__ixor__``, and ``__isub__`` +========================= ==================== ====================== ==================================================== These ABCs allow us to ask classes or instances if they provide particular functionality, for example:: From python-3000-checkins at python.org Sat Feb 9 03:18:52 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 9 Feb 2008 03:18:52 +0100 (CET) Subject: [Python-3000-checkins] r60681 - in python/branches/py3k: Doc/library/calendar.rst Doc/library/decimal.rst Doc/library/userdict.rst Include/pythonrun.h Lib/calendar.py Lib/decimal.py Lib/numbers.py Lib/test/cjkencodings_test.py Lib/test/test_codecmaps_hk.py Lib/test/test_contains.py Lib/test/test_decimal.py Lib/test/test_defaultdict.py Lib/test/test_iterlen.py Lib/test/test_largefile.py Lib/test/test_rational.py Lib/test/test_urllib2.py Lib/urllib2.py Modules/_collectionsmodule.c Modules/_ctypes/_ctypes.c Modules/_ctypes/libffi/src/x86/ffi_darwin.c Modules/cjkcodecs/_codecs_hk.c Modules/cjkcodecs/mappings_hk.h Objects/dictobject.c Objects/listobject.c Python/compile.c Python/pythonrun.c Python/strtod.c Message-ID: <20080209021852.DE2FB1E4004@bag.python.org> Author: christian.heimes Date: Sat Feb 9 03:18:51 2008 New Revision: 60681 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/calendar.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/userdict.rst python/branches/py3k/Include/pythonrun.h python/branches/py3k/Lib/calendar.py python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/numbers.py python/branches/py3k/Lib/test/cjkencodings_test.py python/branches/py3k/Lib/test/test_codecmaps_hk.py python/branches/py3k/Lib/test/test_contains.py python/branches/py3k/Lib/test/test_decimal.py python/branches/py3k/Lib/test/test_defaultdict.py python/branches/py3k/Lib/test/test_iterlen.py python/branches/py3k/Lib/test/test_largefile.py python/branches/py3k/Lib/test/test_rational.py python/branches/py3k/Lib/test/test_urllib2.py python/branches/py3k/Lib/urllib2.py python/branches/py3k/Modules/_collectionsmodule.c python/branches/py3k/Modules/_ctypes/_ctypes.c python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi_darwin.c python/branches/py3k/Modules/cjkcodecs/_codecs_hk.c python/branches/py3k/Modules/cjkcodecs/mappings_hk.h python/branches/py3k/Objects/dictobject.c python/branches/py3k/Objects/listobject.c python/branches/py3k/Python/compile.c python/branches/py3k/Python/pythonrun.c python/branches/py3k/Python/strtod.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617-60678 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60618 | walter.doerwald | 2008-02-06 15:31:55 +0100 (Wed, 06 Feb 2008) | 6 lines Remove month parameter from Calendar.yeardatescalendar(), Calendar.yeardays2calendar() and Calendar.yeardayscalendar() as the methods don't have such a parameter. Fixes issue #2017. Rewrap content to 80 chars. ........ r60622 | facundo.batista | 2008-02-06 20:28:49 +0100 (Wed, 06 Feb 2008) | 4 lines Fixes issue 1959. Converted tests to unittest. Thanks Giampaolo Rodola. ........ r60626 | thomas.heller | 2008-02-06 21:29:17 +0100 (Wed, 06 Feb 2008) | 3 lines Fixed refcounts and error handling. Should not be merged to py3k branch. ........ r60630 | mark.dickinson | 2008-02-06 23:10:50 +0100 (Wed, 06 Feb 2008) | 4 lines Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaN raise InvalidOperation (and return False if InvalidOperation is trapped). ........ r60632 | mark.dickinson | 2008-02-06 23:25:16 +0100 (Wed, 06 Feb 2008) | 2 lines Remove incorrect usage of :const: in documentation. ........ r60634 | georg.brandl | 2008-02-07 00:45:51 +0100 (Thu, 07 Feb 2008) | 2 lines Revert accidental changes to test_queue in r60605. ........ r60636 | raymond.hettinger | 2008-02-07 01:54:20 +0100 (Thu, 07 Feb 2008) | 1 line Issue 2025: Add tuple.count() and tuple.index() to follow the ABC in collections.Sequence. ........ r60637 | mark.dickinson | 2008-02-07 02:14:23 +0100 (Thu, 07 Feb 2008) | 2 lines Fix broken link in decimal documentation. ........ r60638 | mark.dickinson | 2008-02-07 02:42:06 +0100 (Thu, 07 Feb 2008) | 3 lines IEEE 754 should be IEEE 854; give precise reference for comparisons involving NaNs. ........ r60639 | raymond.hettinger | 2008-02-07 03:12:52 +0100 (Thu, 07 Feb 2008) | 1 line Return ints instead of longs for tuple.count() and tuple.index(). ........ r60640 | raymond.hettinger | 2008-02-07 04:10:33 +0100 (Thu, 07 Feb 2008) | 1 line Merge 60627. ........ r60641 | raymond.hettinger | 2008-02-07 04:25:46 +0100 (Thu, 07 Feb 2008) | 1 line Merge r60628, r60631, and r60633. Register UserList and UserString will the appropriate ABCs. ........ r60642 | brett.cannon | 2008-02-07 08:47:31 +0100 (Thu, 07 Feb 2008) | 3 lines Cast a struct to a void pointer so as to do a type-safe pointer comparison (mistmatch found by clang). ........ r60643 | brett.cannon | 2008-02-07 09:04:07 +0100 (Thu, 07 Feb 2008) | 2 lines Remove unnecessary curly braces around an int literal. ........ r60644 | andrew.kuchling | 2008-02-07 12:43:47 +0100 (Thu, 07 Feb 2008) | 1 line Update URL ........ r60645 | facundo.batista | 2008-02-07 17:16:29 +0100 (Thu, 07 Feb 2008) | 4 lines Fixes issue 2026. Tests converted to unittest. Thanks Giampaolo Rodola. ........ r60646 | christian.heimes | 2008-02-07 18:15:30 +0100 (Thu, 07 Feb 2008) | 1 line Added some statistics code to dict and list object code. I wanted to test how a larger freelist affects the reusage of freed objects. Contrary to my gut feelings 80 objects is more than fine for small apps. I haven't profiled a large app yet. ........ r60648 | facundo.batista | 2008-02-07 20:06:52 +0100 (Thu, 07 Feb 2008) | 6 lines Fixes Issue 1401. When redirected, a possible POST get converted to GET, so it loses its payload. So, it also must lose the headers related to the payload (if it has no content any more, it shouldn't indicate content length and type). ........ r60649 | walter.doerwald | 2008-02-07 20:30:22 +0100 (Thu, 07 Feb 2008) | 3 lines Clarify that the output of TextCalendar.formatmonth() and TextCalendar.formatyear() for custom instances won't be influenced by calls to the module global setfirstweekday() function. Fixes #2018. ........ r60651 | walter.doerwald | 2008-02-07 20:48:34 +0100 (Thu, 07 Feb 2008) | 3 lines Fix documentation for Calendar.iterweekdays(): firstweekday is a property. Fixes second part of #2018. ........ r60653 | walter.doerwald | 2008-02-07 20:57:32 +0100 (Thu, 07 Feb 2008) | 2 lines Fix typo in docstring for Calendar.itermonthdays(). ........ r60655 | raymond.hettinger | 2008-02-07 21:04:37 +0100 (Thu, 07 Feb 2008) | 1 line The float conversion recipe is simpler in Py2.6 ........ r60657 | raymond.hettinger | 2008-02-07 21:10:49 +0100 (Thu, 07 Feb 2008) | 1 line Fix typo ........ r60660 | brett.cannon | 2008-02-07 23:27:10 +0100 (Thu, 07 Feb 2008) | 3 lines Make sure a switch statement does not have repetitive case statements. Error found through LLVM post-2.1 svn. ........ r60661 | christian.heimes | 2008-02-08 01:11:31 +0100 (Fri, 08 Feb 2008) | 1 line Deallocate content of the dict free list on interpreter shutdown ........ r60662 | christian.heimes | 2008-02-08 01:14:34 +0100 (Fri, 08 Feb 2008) | 1 line Use prefix decrement ........ r60663 | amaury.forgeotdarc | 2008-02-08 01:56:02 +0100 (Fri, 08 Feb 2008) | 5 lines issue 2045: Infinite recursion when printing a subclass of defaultdict, if default_factory is set to a bound method. Will backport. ........ r60667 | jeffrey.yasskin | 2008-02-08 07:45:40 +0100 (Fri, 08 Feb 2008) | 2 lines Oops! 2.6's Rational.__ne__ didn't work. ........ r60671 | hyeshik.chang | 2008-02-08 18:10:20 +0100 (Fri, 08 Feb 2008) | 2 lines Update big5hkscs codec to conform to the HKSCS:2004 revision. ........ r60673 | raymond.hettinger | 2008-02-08 23:30:04 +0100 (Fri, 08 Feb 2008) | 4 lines Remove unnecessary modulo division. The preceding test guarantees that 0 <= i < len. ........ r60674 | raymond.hettinger | 2008-02-09 00:02:27 +0100 (Sat, 09 Feb 2008) | 1 line Speed-up __iter__() mixin method. ........ r60675 | raymond.hettinger | 2008-02-09 00:34:21 +0100 (Sat, 09 Feb 2008) | 1 line Fill-in missing Set comparisons ........ r60677 | raymond.hettinger | 2008-02-09 00:57:06 +0100 (Sat, 09 Feb 2008) | 1 line Add advice on choosing between DictMixin and MutableMapping ........ Modified: python/branches/py3k/Doc/library/calendar.rst ============================================================================== --- python/branches/py3k/Doc/library/calendar.rst (original) +++ python/branches/py3k/Doc/library/calendar.rst Sat Feb 9 03:18:51 2008 @@ -37,9 +37,9 @@ .. method:: Calendar.iterweekdays(weekday) - Return an iterator for the week day numbers that will be used for one week. The - first number from the iterator will be the same as the number returned by - :meth:`firstweekday`. + Return an iterator for the week day numbers that will be used for one week. + The first value from the iterator will be the same as the value of the + :attr:`firstweekday` property. .. method:: Calendar.itermonthdates(year, month) @@ -81,22 +81,22 @@ Weeks are lists of seven day numbers. -.. method:: Calendar.yeardatescalendar(year, month[, width]) +.. method:: Calendar.yeardatescalendar(year[, width]) - Return the data for the specified year ready for formatting. The return value is - a list of month rows. Each month row contains up to *width* months (defaulting - to 3). Each month contains between 4 and 6 weeks and each week contains 1--7 - days. Days are :class:`datetime.date` objects. + Return the data for the specified year ready for formatting. The return value + is a list of month rows. Each month row contains up to *width* months + (defaulting to 3). Each month contains between 4 and 6 weeks and each week + contains 1--7 days. Days are :class:`datetime.date` objects. -.. method:: Calendar.yeardays2calendar(year, month[, width]) +.. method:: Calendar.yeardays2calendar(year[, width]) Return the data for the specified year ready for formatting (similar to - :meth:`yeardatescalendar`). Entries in the week lists are tuples of day numbers - and weekday numbers. Day numbers outside this month are zero. + :meth:`yeardatescalendar`). Entries in the week lists are tuples of day + numbers and weekday numbers. Day numbers outside this month are zero. -.. method:: Calendar.yeardayscalendar(year, month[, width]) +.. method:: Calendar.yeardayscalendar(year[, width]) Return the data for the specified year ready for formatting (similar to :meth:`yeardatescalendar`). Entries in the week lists are day numbers. Day @@ -113,9 +113,10 @@ .. method:: TextCalendar.formatmonth(theyear, themonth[, w[, l]]) Return a month's calendar in a multi-line string. If *w* is provided, it - specifies the width of the date columns, which are centered. If *l* is given, it - specifies the number of lines that each week will use. Depends on the first - weekday as set by :func:`setfirstweekday`. + specifies the width of the date columns, which are centered. If *l* is given, + it specifies the number of lines that each week will use. Depends on the + first weekday as specified in the constructor or set by the + :meth:`setfirstweekday` method. .. method:: TextCalendar.prmonth(theyear, themonth[, w[, l]]) @@ -125,11 +126,12 @@ .. method:: TextCalendar.formatyear(theyear, themonth[, w[, l[, c[, m]]]]) - Return a *m*-column calendar for an entire year as a multi-line string. Optional - parameters *w*, *l*, and *c* are for date column width, lines per week, and - number of spaces between month columns, respectively. Depends on the first - weekday as set by :meth:`setfirstweekday`. The earliest year for which a - calendar can be generated is platform-dependent. + Return a *m*-column calendar for an entire year as a multi-line string. + Optional parameters *w*, *l*, and *c* are for date column width, lines per + week, and number of spaces between month columns, respectively. Depends on + the first weekday as specified in the constructor or set by the + :meth:`setfirstweekday` method. The earliest year for which a calendar can + be generated is platform-dependent. .. method:: TextCalendar.pryear(theyear[, w[, l[, c[, m]]]]) Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Sat Feb 9 03:18:51 2008 @@ -86,7 +86,7 @@ Specification `_. * IEEE standard 854-1987, `Unofficial IEEE 854 Text - `_. + `_. .. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1238,6 +1238,19 @@ operation. This is a useful return value when an invalid result needs to interrupt a calculation for special handling. +The behavior of Python's comparison operators can be a little surprising where a +:const:`NaN` is involved. A test for equality where one of the operands is a +quiet or signaling :const:`NaN` always returns :const:`False` (even when doing +``Decimal('NaN')==Decimal('NaN')``), while a test for inequality always returns +:const:`True`. An attempt to compare two Decimals using any of the ``<``, +``<=``, ``>`` or ``>=`` operators will raise the :exc:`InvalidOperation` signal +if either operand is a :const:`NaN`, and return :const:`False` if this signal is +trapped. Note that the General Decimal Arithmetic specification does not +specify the behavior of direct comparisons; these rules for comparisons +involving a :const:`NaN` were taken from the IEEE 854 standard (see Table 3 in +section 5.7). To ensure strict standards-compliance, use the :meth:`compare` +and :meth:`compare-signal` methods instead. + The signed zeros can result from calculations that underflow. They keep the sign that would have resulted if the calculation had been carried out to greater precision. Since their magnitude is zero, both positive and negative zeros are Modified: python/branches/py3k/Doc/library/userdict.rst ============================================================================== --- python/branches/py3k/Doc/library/userdict.rst (original) +++ python/branches/py3k/Doc/library/userdict.rst Sat Feb 9 03:18:51 2008 @@ -1,5 +1,3 @@ - - :mod:`UserList` --- Class wrapper for list objects ================================================== Modified: python/branches/py3k/Include/pythonrun.h ============================================================================== --- python/branches/py3k/Include/pythonrun.h (original) +++ python/branches/py3k/Include/pythonrun.h Sat Feb 9 03:18:51 2008 @@ -134,6 +134,7 @@ PyAPI_FUNC(void) PyMethod_Fini(void); PyAPI_FUNC(void) PyFrame_Fini(void); PyAPI_FUNC(void) PyCFunction_Fini(void); +PyAPI_FUNC(void) PyDict_Fini(void); PyAPI_FUNC(void) PyTuple_Fini(void); PyAPI_FUNC(void) PyList_Fini(void); PyAPI_FUNC(void) PySet_Fini(void); Modified: python/branches/py3k/Lib/calendar.py ============================================================================== --- python/branches/py3k/Lib/calendar.py (original) +++ python/branches/py3k/Lib/calendar.py Sat Feb 9 03:18:51 2008 @@ -179,8 +179,8 @@ def itermonthdays(self, year, month): """ - Like itermonthdates(), but will yield day numbers tuples. For days - outside the specified month the day number is 0. + Like itermonthdates(), but will yield day numbers. For days outside + the specified month the day number is 0. """ for date in self.itermonthdates(year, month): if date.month != month: Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Sat Feb 9 03:18:51 2008 @@ -718,6 +718,39 @@ return other._fix_nan(context) return 0 + def _compare_check_nans(self, other, context): + """Version of _check_nans used for the signaling comparisons + compare_signal, __le__, __lt__, __ge__, __gt__. + + Signal InvalidOperation if either self or other is a (quiet + or signaling) NaN. Signaling NaNs take precedence over quiet + NaNs. + + Return 0 if neither operand is a NaN. + + """ + if context is None: + context = getcontext() + + if self._is_special or other._is_special: + if self.is_snan(): + return context._raise_error(InvalidOperation, + 'comparison involving sNaN', + self) + elif other.is_snan(): + return context._raise_error(InvalidOperation, + 'comparison involving sNaN', + other) + elif self.is_qnan(): + return context._raise_error(InvalidOperation, + 'comparison involving NaN', + self) + elif other.is_qnan(): + return context._raise_error(InvalidOperation, + 'comparison involving NaN', + other) + return 0 + def __bool__(self): """Return True if self is nonzero; otherwise return False. @@ -725,18 +758,13 @@ """ return self._is_special or self._int != '0' - def __cmp__(self, other): - other = _convert_other(other) - if other is NotImplemented: - # Never return NotImplemented - return 1 + def _cmp(self, other): + """Compare the two non-NaN decimal instances self and other. - if self._is_special or other._is_special: - # check for nans, without raising on a signaling nan - if self._isnan() or other._isnan(): - return 1 # Comparison involving NaN's always reports self > other + Returns -1 if self < other, 0 if self == other and 1 + if self > other. This routine is for internal use only.""" - # INF = INF + if self._is_special or other._is_special: return cmp(self._isinfinity(), other._isinfinity()) # check for zeros; note that cmp(0, -0) should return 0 @@ -765,35 +793,72 @@ else: # self_adjusted < other_adjusted return -((-1)**self._sign) + # Note: The Decimal standard doesn't cover rich comparisons for + # Decimals. In particular, the specification is silent on the + # subject of what should happen for a comparison involving a NaN. + # We take the following approach: + # + # == comparisons involving a NaN always return False + # != comparisons involving a NaN always return True + # <, >, <= and >= comparisons involving a (quiet or signaling) + # NaN signal InvalidOperation, and return False if the + # InvalidOperation is trapped. + # + # This behavior is designed to conform as closely as possible to + # that specified by IEEE 754. + def __eq__(self, other): - if not isinstance(other, (Decimal, int)): - return NotImplemented - return self.__cmp__(other) == 0 + other = _convert_other(other) + if other is NotImplemented: + return other + if self.is_nan() or other.is_nan(): + return False + return self._cmp(other) == 0 def __ne__(self, other): - if not isinstance(other, (Decimal, int)): - return NotImplemented - return self.__cmp__(other) != 0 + other = _convert_other(other) + if other is NotImplemented: + return other + if self.is_nan() or other.is_nan(): + return True + return self._cmp(other) != 0 - def __lt__(self, other): - if not isinstance(other, (Decimal, int)): - return NotImplemented - return self.__cmp__(other) < 0 - def __le__(self, other): - if not isinstance(other, (Decimal, int)): - return NotImplemented - return self.__cmp__(other) <= 0 + def __lt__(self, other, context=None): + other = _convert_other(other) + if other is NotImplemented: + return other + ans = self._compare_check_nans(other, context) + if ans: + return False + return self._cmp(other) < 0 - def __gt__(self, other): - if not isinstance(other, (Decimal, int)): - return NotImplemented - return self.__cmp__(other) > 0 + def __le__(self, other, context=None): + other = _convert_other(other) + if other is NotImplemented: + return other + ans = self._compare_check_nans(other, context) + if ans: + return False + return self._cmp(other) <= 0 - def __ge__(self, other): - if not isinstance(other, (Decimal, int)): - return NotImplemented - return self.__cmp__(other) >= 0 + def __gt__(self, other, context=None): + other = _convert_other(other) + if other is NotImplemented: + return other + ans = self._compare_check_nans(other, context) + if ans: + return False + return self._cmp(other) > 0 + + def __ge__(self, other, context=None): + other = _convert_other(other) + if other is NotImplemented: + return other + ans = self._compare_check_nans(other, context) + if ans: + return False + return self._cmp(other) >= 0 def compare(self, other, context=None): """Compares one to another. @@ -812,7 +877,7 @@ if ans: return ans - return Decimal(self.__cmp__(other)) + return Decimal(self._cmp(other)) def __hash__(self): """x.__hash__() <==> hash(x)""" @@ -2463,7 +2528,7 @@ return other._fix_nan(context) return self._check_nans(other, context) - c = self.__cmp__(other) + c = self._cmp(other) if c == 0: # If both operands are finite and equal in numerical value # then an ordering is applied: @@ -2505,7 +2570,7 @@ return other._fix_nan(context) return self._check_nans(other, context) - c = self.__cmp__(other) + c = self._cmp(other) if c == 0: c = self.compare_total(other) @@ -2553,23 +2618,10 @@ It's pretty much like compare(), but all NaNs signal, with signaling NaNs taking precedence over quiet NaNs. """ - if context is None: - context = getcontext() - - self_is_nan = self._isnan() - other_is_nan = other._isnan() - if self_is_nan == 2: - return context._raise_error(InvalidOperation, 'sNaN', - self) - if other_is_nan == 2: - return context._raise_error(InvalidOperation, 'sNaN', - other) - if self_is_nan: - return context._raise_error(InvalidOperation, 'NaN in compare_signal', - self) - if other_is_nan: - return context._raise_error(InvalidOperation, 'NaN in compare_signal', - other) + other = _convert_other(other, raiseit = True) + ans = self._compare_check_nans(other, context) + if ans: + return ans return self.compare(other, context=context) def compare_total(self, other): @@ -3076,7 +3128,7 @@ return other._fix_nan(context) return self._check_nans(other, context) - c = self.copy_abs().__cmp__(other.copy_abs()) + c = self.copy_abs()._cmp(other.copy_abs()) if c == 0: c = self.compare_total(other) @@ -3106,7 +3158,7 @@ return other._fix_nan(context) return self._check_nans(other, context) - c = self.copy_abs().__cmp__(other.copy_abs()) + c = self.copy_abs()._cmp(other.copy_abs()) if c == 0: c = self.compare_total(other) @@ -3181,7 +3233,7 @@ if ans: return ans - comparison = self.__cmp__(other) + comparison = self._cmp(other) if comparison == 0: return self.copy_sign(other) Modified: python/branches/py3k/Lib/numbers.py ============================================================================== --- python/branches/py3k/Lib/numbers.py (original) +++ python/branches/py3k/Lib/numbers.py Sat Feb 9 03:18:51 2008 @@ -154,7 +154,10 @@ """self == other""" raise NotImplementedError - # __ne__ is inherited from object and negates whatever __eq__ does. + def __ne__(self, other): + """self != other""" + # The default __ne__ doesn't negate __eq__ until 3.0. + return not (self == other) Complex.register(complex) Modified: python/branches/py3k/Lib/test/cjkencodings_test.py ============================================================================== --- python/branches/py3k/Lib/test/cjkencodings_test.py (original) +++ python/branches/py3k/Lib/test/cjkencodings_test.py Sat Feb 9 03:18:51 2008 @@ -64,8 +64,10 @@ b"\xab\x96\xe7\x9a\x84\xe5\x95\x8f\xe9\xa1\x8c\xe5\xb0\xb1\xe6\x98" b"\xaf\x3a\x0a\x0a"), 'big5hkscs': ( -b"\x88\x45\x88\x5c\x8a\x73\x8b\xda\x8d\xd8\x0a", -b"\xf0\xa0\x84\x8c\xc4\x9a\xe9\xb5\xae\xe7\xbd\x93\xe6\xb4\x86\x0a"), +b"\x88\x45\x88\x5c\x8a\x73\x8b\xda\x8d\xd8\x0a\x88\x66\x88\x62\x88" +b"\xa7\x20\x88\xa7\x88\xa3\x0a", +b"\xf0\xa0\x84\x8c\xc4\x9a\xe9\xb5\xae\xe7\xbd\x93\xe6\xb4\x86\x0a" +b"\xc3\x8a\xc3\x8a\xcc\x84\xc3\xaa\x20\xc3\xaa\xc3\xaa\xcc\x84\x0a"), 'cp949': ( b"\x8c\x63\xb9\xe6\xb0\xa2\xc7\xcf\x20\xbc\x84\xbd\xc3\xc4\xdd\xb6" b"\xf3\x0a\x0a\xa8\xc0\xa8\xc0\xb3\xb3\x21\x21\x20\xec\xd7\xce\xfa" Modified: python/branches/py3k/Lib/test/test_codecmaps_hk.py ============================================================================== --- python/branches/py3k/Lib/test/test_codecmaps_hk.py (original) +++ python/branches/py3k/Lib/test/test_codecmaps_hk.py Sat Feb 9 03:18:51 2008 @@ -11,10 +11,11 @@ class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping, unittest.TestCase): encoding = 'big5hkscs' - mapfileurl = 'http://people.freebsd.org/~perky/i18n/BIG5HKSCS.TXT' + mapfileurl = 'http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT' def test_main(): test_support.run_unittest(__name__) if __name__ == "__main__": + test_support.use_resources = ['urlfetch'] test_main() Modified: python/branches/py3k/Lib/test/test_contains.py ============================================================================== --- python/branches/py3k/Lib/test/test_contains.py (original) +++ python/branches/py3k/Lib/test/test_contains.py Sat Feb 9 03:18:51 2008 @@ -1,103 +1,88 @@ -from test.test_support import TestFailed +from test.test_support import run_unittest +import unittest -class base_set: +class base_set: def __init__(self, el): self.el = el class set(base_set): - def __contains__(self, el): return self.el == el class seq(base_set): - def __getitem__(self, n): return [self.el][n] -def check(ok, *args): - if not ok: - raise TestFailed(" ".join(map(str, args))) - -a = base_set(1) -b = set(1) -c = seq(1) - -check(1 in b, "1 not in set(1)") -check(0 not in b, "0 in set(1)") -check(1 in c, "1 not in seq(1)") -check(0 not in c, "0 in seq(1)") - -try: - 1 in a - check(0, "in base_set did not raise error") -except TypeError: - pass - -try: - 1 not in a - check(0, "not in base_set did not raise error") -except TypeError: - pass - -# Test char in string - -check('c' in 'abc', "'c' not in 'abc'") -check('d' not in 'abc', "'d' in 'abc'") - -check('' in '', "'' not in ''") -check('' in 'abc', "'' not in 'abc'") - -try: - None in 'abc' - check(0, "None in 'abc' did not raise error") -except TypeError: - pass - - -# A collection of tests on builtin sequence types -a = list(range(10)) -for i in a: - check(i in a, "%r not in %r" % (i, a)) -check(16 not in a, "16 not in %r" % (a,)) -check(a not in a, "%s not in %r" % (a, a)) - -a = tuple(a) -for i in a: - check(i in a, "%r not in %r" % (i, a)) -check(16 not in a, "16 not in %r" % (a,)) -check(a not in a, "%r not in %r" % (a, a)) - -class Deviant1: - """Behaves strangely when compared - - This class is designed to make sure that the contains code - works when the list is modified during the check. - """ - - aList = list(range(15)) - - def __cmp__(self, other): - if other == 12: - self.aList.remove(12) - self.aList.remove(13) - self.aList.remove(14) - return 1 - -check(Deviant1() not in Deviant1.aList, "Deviant1 failed") - -class Deviant2: - """Behaves strangely when compared - - This class raises an exception during comparison. That in - turn causes the comparison to fail with a TypeError. - """ - - def __cmp__(self, other): - if other == 4: - raise RuntimeError("gotcha") - -try: - check(Deviant2() not in a, "oops") -except TypeError: - pass +class TestContains(unittest.TestCase): + def test_common_tests(self): + a = base_set(1) + b = set(1) + c = seq(1) + self.assert_(1 in b) + self.assert_(0 not in b) + self.assert_(1 in c) + self.assert_(0 not in c) + self.assertRaises(TypeError, lambda: 1 in a) + self.assertRaises(TypeError, lambda: 1 not in a) + + # test char in string + self.assert_('c' in 'abc') + self.assert_('d' not in 'abc') + + self.assert_('' in '') + self.assert_('' in 'abc') + + self.assertRaises(TypeError, lambda: None in 'abc') + + def test_builtin_sequence_types(self): + # a collection of tests on builtin sequence types + a = range(10) + for i in a: + self.assert_(i in a) + self.assert_(16 not in a) + self.assert_(a not in a) + + a = tuple(a) + for i in a: + self.assert_(i in a) + self.assert_(16 not in a) + self.assert_(a not in a) + + class Deviant1: + """Behaves strangely when compared + + This class is designed to make sure that the contains code + works when the list is modified during the check. + """ + aList = range(15) + def __cmp__(self, other): + if other == 12: + self.aList.remove(12) + self.aList.remove(13) + self.aList.remove(14) + return 1 + + self.assert_(Deviant1() not in Deviant1.aList) + + class Deviant2: + """Behaves strangely when compared + + This class raises an exception during comparison. That in + turn causes the comparison to fail with a TypeError. + """ + def __cmp__(self, other): + if other == 4: + raise RuntimeError("gotcha") + + try: + self.assert_(Deviant2() not in a) + except TypeError: + pass + + +def test_main(): + run_unittest(TestContains) + +if __name__ == '__main__': + test_main() Modified: python/branches/py3k/Lib/test/test_decimal.py ============================================================================== --- python/branches/py3k/Lib/test/test_decimal.py (original) +++ python/branches/py3k/Lib/test/test_decimal.py Sat Feb 9 03:18:51 2008 @@ -833,6 +833,19 @@ self.assertEqual(-Decimal(45), Decimal(-45)) # - self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs + def test_nan_comparisons(self): + n = Decimal('NaN') + s = Decimal('sNaN') + i = Decimal('Inf') + f = Decimal('2') + for x, y in [(n, n), (n, i), (i, n), (n, f), (f, n), + (s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s)]: + self.assert_(x != y) + self.assert_(not (x == y)) + self.assert_(not (x < y)) + self.assert_(not (x <= y)) + self.assert_(not (x > y)) + self.assert_(not (x >= y)) # The following are two functions used to test threading in the next class @@ -1137,7 +1150,12 @@ checkSameDec("__abs__") checkSameDec("__add__", True) checkSameDec("__divmod__", True) - checkSameDec("__cmp__", True) + checkSameDec("__eq__", True) + checkSameDec("__ne__", True) + checkSameDec("__le__", True) + checkSameDec("__lt__", True) + checkSameDec("__ge__", True) + checkSameDec("__gt__", True) checkSameDec("__float__") checkSameDec("__floordiv__", True) checkSameDec("__hash__") Modified: python/branches/py3k/Lib/test/test_defaultdict.py ============================================================================== --- python/branches/py3k/Lib/test/test_defaultdict.py (original) +++ python/branches/py3k/Lib/test/test_defaultdict.py Sat Feb 9 03:18:51 2008 @@ -141,6 +141,29 @@ else: self.fail("expected KeyError") + def test_recursive_repr(self): + # Issue2045: stack overflow when default_factory is a bound method + class sub(defaultdict): + def __init__(self): + self.default_factory = self._factory + def _factory(self): + return [] + d = sub() + self.assert_(repr(d).startswith( + "defaultdict(2GB file (2GB = 2147483648 bytes) size = 2500000000 -name = test_support.TESTFN - - -# On Windows and Mac OSX this test comsumes large resources; It takes -# a long time to build the >2GB file and takes >2GB of disk space -# therefore the resource must be enabled to run this test. If not, -# nothing after this line stanza will be executed. -if sys.platform[:3] == 'win' or sys.platform == 'darwin': - test_support.requires( - 'largefile', - 'test requires %s bytes and a long time to run' % str(size)) -else: - # Only run if the current filesystem supports large files. - # (Skip this test on Windows, since we now always support large files.) - f = open(test_support.TESTFN, 'wb') - try: - # 2**31 == 2147483648 - f.seek(2147483649) - # Seeking is not enough of a test: you must write and flush, too! - f.write(b"x") - f.flush() - except (IOError, OverflowError): - f.close() - os.unlink(test_support.TESTFN) - raise test_support.TestSkipped( - "filesystem does not have largefile support") - else: - f.close() -def expect(got_this, expect_this): - if test_support.verbose: - print('%r =?= %r ...' % (got_this, expect_this), end=' ') - if got_this != expect_this: - if test_support.verbose: - print('no') - raise test_support.TestFailed('got %r, but expected %r' - % (got_this, expect_this)) +class TestCase(unittest.TestCase): + """Test that each file function works as expected for a large + (i.e. > 2GB, do we have to check > 4GB) files. + """ + + def test_seek(self): + if verbose: + print('create large file via seek (may be sparse file) ...') + f = open(TESTFN, 'wb') + try: + f.write('z') + f.seek(0) + f.seek(size) + f.write('a') + f.flush() + if verbose: + print('check file size with os.fstat') + self.assertEqual(os.fstat(f.fileno())[stat.ST_SIZE], size+1) + finally: + f.close() + + def test_osstat(self): + if verbose: + print('check file size with os.stat') + self.assertEqual(os.stat(TESTFN)[stat.ST_SIZE], size+1) + + def test_seek_read(self): + if verbose: + print('play around with seek() and read() with the built largefile') + f = open(TESTFN, 'rb') + try: + self.assertEqual(f.tell(), 0) + self.assertEqual(f.read(1), 'z') + self.assertEqual(f.tell(), 1) + f.seek(0) + self.assertEqual(f.tell(), 0) + f.seek(0, 0) + self.assertEqual(f.tell(), 0) + f.seek(42) + self.assertEqual(f.tell(), 42) + f.seek(42, 0) + self.assertEqual(f.tell(), 42) + f.seek(42, 1) + self.assertEqual(f.tell(), 84) + f.seek(0, 1) + self.assertEqual(f.tell(), 84) + f.seek(0, 2) # seek from the end + self.assertEqual(f.tell(), size + 1 + 0) + f.seek(-10, 2) + self.assertEqual(f.tell(), size + 1 - 10) + f.seek(-size-1, 2) + self.assertEqual(f.tell(), 0) + f.seek(size) + self.assertEqual(f.tell(), size) + # the 'a' that was written at the end of file above + self.assertEqual(f.read(1), 'a') + f.seek(-size-1, 1) + self.assertEqual(f.read(1), 'z') + self.assertEqual(f.tell(), 1) + finally: + f.close() + + def test_lseek(self): + if verbose: + print('play around with os.lseek() with the built largefile') + f = open(TESTFN, 'rb') + try: + self.assertEqual(os.lseek(f.fileno(), 0, 0), 0) + self.assertEqual(os.lseek(f.fileno(), 42, 0), 42) + self.assertEqual(os.lseek(f.fileno(), 42, 1), 84) + self.assertEqual(os.lseek(f.fileno(), 0, 1), 84) + self.assertEqual(os.lseek(f.fileno(), 0, 2), size+1+0) + self.assertEqual(os.lseek(f.fileno(), -10, 2), size+1-10) + self.assertEqual(os.lseek(f.fileno(), -size-1, 2), 0) + self.assertEqual(os.lseek(f.fileno(), size, 0), size) + # the 'a' that was written at the end of file above + self.assertEqual(f.read(1), 'a') + finally: + f.close() + + def test_truncate(self): + if verbose: + print('try truncate') + f = open(TESTFN, 'r+b') + # this is already decided before start running the test suite + # but we do it anyway for extra protection + if not hasattr(f, 'truncate'): + raise TestSkipped("open().truncate() not available on this system") + try: + f.seek(0, 2) + # else we've lost track of the true size + self.assertEqual(f.tell(), size+1) + # Cut it back via seek + truncate with no argument. + newsize = size - 10 + f.seek(newsize) + f.truncate() + self.assertEqual(f.tell(), newsize) # else pointer moved + f.seek(0, 2) + self.assertEqual(f.tell(), newsize) # else wasn't truncated + # Ensure that truncate(smaller than true size) shrinks + # the file. + newsize -= 1 + f.seek(42) + f.truncate(newsize) + self.assertEqual(f.tell(), 42) # else pointer moved + f.seek(0, 2) + self.assertEqual(f.tell(), newsize) # else wasn't truncated + # XXX truncate(larger than true size) is ill-defined + # across platform; cut it waaaaay back + f.seek(0) + f.truncate(1) + self.assertEqual(f.tell(), 0) # else pointer moved + self.assertEqual(len(f.read()), 1) # else wasn't truncated + finally: + f.close() + +def main_test(): + # On Windows and Mac OSX this test comsumes large resources; It + # takes a long time to build the >2GB file and takes >2GB of disk + # space therefore the resource must be enabled to run this test. + # If not, nothing after this line stanza will be executed. + if sys.platform[:3] == 'win' or sys.platform == 'darwin': + requires('largefile', + 'test requires %s bytes and a long time to run' % str(size)) else: - if test_support.verbose: - print('yes') - - -# test that each file function works as expected for a large (i.e. >2GB, do -# we have to check >4GB) files - -if test_support.verbose: - print('create large file via seek (may be sparse file) ...') -f = open(name, 'wb') -try: - f.write(b'z') - f.seek(0) - f.seek(size) - f.write(b'a') - f.flush() - if test_support.verbose: - print('check file size with os.fstat') - expect(os.fstat(f.fileno())[stat.ST_SIZE], size+1) -finally: - f.close() -if test_support.verbose: - print('check file size with os.stat') -expect(os.stat(name)[stat.ST_SIZE], size+1) - -if test_support.verbose: - print('play around with seek() and read() with the built largefile') -f = open(name, 'rb') -try: - expect(f.tell(), 0) - expect(f.read(1), b'z') - expect(f.tell(), 1) - f.seek(0) - expect(f.tell(), 0) - f.seek(0, 0) - expect(f.tell(), 0) - f.seek(42) - expect(f.tell(), 42) - f.seek(42, 0) - expect(f.tell(), 42) - f.seek(42, 1) - expect(f.tell(), 84) - f.seek(0, 1) - expect(f.tell(), 84) - f.seek(0, 2) # seek from the end - expect(f.tell(), size + 1 + 0) - f.seek(-10, 2) - expect(f.tell(), size + 1 - 10) - f.seek(-size-1, 2) - expect(f.tell(), 0) - f.seek(size) - expect(f.tell(), size) - expect(f.read(1), b'a') # the 'a' that was written at the end of file above - f.seek(-size-1, 1) - expect(f.read(1), b'z') - expect(f.tell(), 1) -finally: - f.close() - -if test_support.verbose: - print('play around with os.lseek() with the built largefile') -f = open(name, 'rb') -try: - expect(os.lseek(f.fileno(), 0, 0), 0) - expect(os.lseek(f.fileno(), 42, 0), 42) - expect(os.lseek(f.fileno(), 42, 1), 84) - expect(os.lseek(f.fileno(), 0, 1), 84) - expect(os.lseek(f.fileno(), 0, 2), size+1+0) - expect(os.lseek(f.fileno(), -10, 2), size+1-10) - expect(os.lseek(f.fileno(), -size-1, 2), 0) - expect(os.lseek(f.fileno(), size, 0), size) - expect(f.read(1), b'a') # the 'a' that was written at the end of file above -finally: - f.close() - -if hasattr(f, 'truncate'): - if test_support.verbose: - print('try truncate') - f = open(name, 'r+b') - try: - f.seek(0, 2) - expect(f.tell(), size+1) # else we've lost track of the true size - # Cut it back via seek + truncate with no argument. - newsize = size - 10 - f.seek(newsize) - f.truncate() - expect(f.tell(), newsize) # else pointer moved - f.seek(0, 2) - expect(f.tell(), newsize) # else wasn't truncated - # Ensure that truncate(smaller than true size) shrinks the file. - newsize -= 1 - f.seek(42) - f.truncate(newsize) - expect(f.tell(), 42) # else pointer moved - f.seek(0, 2) - expect(f.tell(), newsize) # else wasn't truncated - - # XXX truncate(larger than true size) is ill-defined across platforms - - # cut it waaaaay back - f.seek(0) - f.truncate(1) - expect(f.tell(), 0) # else pointer moved - expect(len(f.read()), 1) # else wasn't truncated - - finally: - f.close() + # Only run if the current filesystem supports large files. + # (Skip this test on Windows, since we now always support + # large files.) + f = open(TESTFN, 'wb') + try: + # 2**31 == 2147483648 + f.seek(2147483649) + # Seeking is not enough of a test: you must write and + # flush, too! + f.write("x") + f.flush() + except (IOError, OverflowError): + f.close() + unlink(TESTFN) + raise TestSkipped("filesystem does not have largefile support") + else: + f.close() + suite = unittest.TestSuite() + suite.addTest(TestCase('test_seek')) + suite.addTest(TestCase('test_osstat')) + suite.addTest(TestCase('test_seek_read')) + suite.addTest(TestCase('test_lseek')) + f = open(TESTFN, 'w') + if hasattr(f, 'truncate'): + suite.addTest(TestCase('test_truncate')) -os.unlink(name) +if __name__ == '__main__': + main_test() Modified: python/branches/py3k/Lib/test/test_rational.py ============================================================================== --- python/branches/py3k/Lib/test/test_rational.py (original) +++ python/branches/py3k/Lib/test/test_rational.py Sat Feb 9 03:18:51 2008 @@ -328,6 +328,8 @@ self.assertFalse(R(2, 3) <= R(1, 2)) self.assertTrue(R(1, 2) == R(1, 2)) self.assertFalse(R(1, 2) == R(1, 3)) + self.assertFalse(R(1, 2) != R(1, 2)) + self.assertTrue(R(1, 2) != R(1, 3)) def testMixedLess(self): self.assertTrue(2 < R(5, 2)) Modified: python/branches/py3k/Lib/test/test_urllib2.py ============================================================================== --- python/branches/py3k/Lib/test/test_urllib2.py (original) +++ python/branches/py3k/Lib/test/test_urllib2.py Sat Feb 9 03:18:51 2008 @@ -817,6 +817,8 @@ method = getattr(h, "http_error_%s" % code) req = Request(from_url, data) req.add_header("Nonsense", "viking=withhold") + if data is not None: + req.add_header("Content-Length", str(len(data))) req.add_unredirected_header("Spam", "spam") try: method(req, MockFile(), code, "Blah", @@ -829,6 +831,13 @@ self.assertEqual(o.req.get_method(), "GET") except AttributeError: self.assert_(not o.req.has_data()) + + # now it's a GET, there should not be headers regarding content + # (possibly dragged from before being a POST) + headers = [x.lower() for x in o.req.headers] + self.assertTrue("content-length" not in headers) + self.assertTrue("content-type" not in headers) + self.assertEqual(o.req.headers["Nonsense"], "viking=withhold") self.assert_("Spam" not in o.req.headers) Modified: python/branches/py3k/Lib/urllib2.py ============================================================================== --- python/branches/py3k/Lib/urllib2.py (original) +++ python/branches/py3k/Lib/urllib2.py Sat Feb 9 03:18:51 2008 @@ -531,8 +531,11 @@ # do the same. # be conciliant with URIs containing a space newurl = newurl.replace(' ', '%20') + newheaders = dict((k,v) for k,v in req.headers.items() + if k.lower() not in ("content-length", "content-type") + ) return Request(newurl, - headers=req.headers, + headers=newheaders, origin_req_host=req.get_origin_req_host(), unverifiable=True) else: Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Sat Feb 9 03:18:51 2008 @@ -1209,16 +1209,32 @@ defdict_repr(defdictobject *dd) { PyObject *baserepr; - PyObject *def; + PyObject *defrepr; PyObject *result; baserepr = PyDict_Type.tp_repr((PyObject *)dd); if (baserepr == NULL) return NULL; if (dd->default_factory == NULL) - def = Py_None; + defrepr = PyUnicode_FromString("None"); else - def = dd->default_factory; - result = PyUnicode_FromFormat("defaultdict(%R, %U)", def, baserepr); + { + int status = Py_ReprEnter(dd->default_factory); + if (status != 0) { + if (status < 0) + return NULL; + defrepr = PyUnicode_FromString("..."); + } + else + defrepr = PyObject_Repr(dd->default_factory); + Py_ReprLeave(dd->default_factory); + } + if (defrepr == NULL) { + Py_DECREF(baserepr); + return NULL; + } + result = PyUnicode_FromFormat("defaultdict(%U, %U)", + defrepr, baserepr); + Py_DECREF(defrepr); Py_DECREF(baserepr); return result; } Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Sat Feb 9 03:18:51 2008 @@ -4814,11 +4814,48 @@ static int create_comerror(void) { - PyComError_Type.tp_base = (PyTypeObject*)PyExc_Exception; - if (PyType_Ready(&PyComError_Type) < 0) + PyObject *dict = PyDict_New(); + PyMethodDef *methods = comerror_methods; + PyObject *s; + int status; + + if (dict == NULL) return -1; + + while (methods->ml_name) { + /* get a wrapper for the built-in function */ + PyObject *func = PyCFunction_New(methods, NULL); + PyObject *meth; + if (func == NULL) + goto error; + meth = PyMethod_New(func, NULL, ComError); + Py_DECREF(func); + if (meth == NULL) + goto error; + PyDict_SetItemString(dict, methods->ml_name, meth); + Py_DECREF(meth); + ++methods; + } + + s = PyString_FromString(comerror_doc); + if (s == NULL) + goto error; ComError = (PyObject*)&PyComError_Type; + status = PyDict_SetItemString(dict, "__doc__", s); + Py_DECREF(s); + if (status == -1) + goto error; + + ComError = PyErr_NewException("_ctypes.COMError", + NULL, + dict); + if (ComError == NULL) + goto error; + return 0; + error: + Py_DECREF(dict); + return -1; } #endif Modified: python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi_darwin.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi_darwin.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi_darwin.c Sat Feb 9 03:18:51 2008 @@ -146,7 +146,9 @@ case FFI_TYPE_SINT64: case FFI_TYPE_FLOAT: case FFI_TYPE_DOUBLE: +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: +#endif cif->flags = (unsigned) cif->rtype->type; break; Modified: python/branches/py3k/Modules/cjkcodecs/_codecs_hk.c ============================================================================== --- python/branches/py3k/Modules/cjkcodecs/_codecs_hk.c (original) +++ python/branches/py3k/Modules/cjkcodecs/_codecs_hk.c Sat Feb 9 03:18:51 2008 @@ -26,6 +26,16 @@ return 0; } +/* + * There are four possible pair unicode -> big5hkscs maps as in HKSCS 2004: + * U+00CA U+0304 -> 8862 (U+00CA alone is mapped to 8866) + * U+00CA U+030C -> 8864 + * U+00EA U+0304 -> 88a3 (U+00EA alone is mapped to 88a7) + * U+00EA U+030C -> 88a5 + * These are handled by not mapping tables but a hand-written code. + */ +static const DBCHAR big5hkscs_pairenc_table[4] = {0x8862, 0x8864, 0x88a3, 0x88a5}; + ENCODER(big5hkscs) { while (inleft > 0) { @@ -46,7 +56,27 @@ REQUIRE_OUTBUF(2) if (c < 0x10000) { - TRYMAP_ENC(big5hkscs_bmp, code, c); + TRYMAP_ENC(big5hkscs_bmp, code, c) { + if (code == MULTIC) { + if (inleft >= 2 && + ((c & 0xffdf) == 0x00ca) && + (((*inbuf)[1] & 0xfff7) == 0x0304)) { + code = big5hkscs_pairenc_table[ + ((c >> 4) | + ((*inbuf)[1] >> 3)) & 3]; + insize = 2; + } + else if (inleft < 2 && + !(flags & MBENC_FLUSH)) + return MBERR_TOOFEW; + else { + if (c == 0xca) + code = 0x8866; + else /* c == 0xea */ + code = 0x88a7; + } + } + } else TRYMAP_ENC(big5, code, c); else return 1; } @@ -67,7 +97,7 @@ return 0; } -#define BH2S(c1, c2) (((c1) - 0x88) * (0xfe - 0x40 + 1) + ((c2) - 0x40)) +#define BH2S(c1, c2) (((c1) - 0x87) * (0xfe - 0x40 + 1) + ((c2) - 0x40)) DECODER(big5hkscs) { @@ -96,19 +126,19 @@ int s = BH2S(c, IN2); const unsigned char *hintbase; - assert(0x88 <= c && c <= 0xfe); + assert(0x87 <= c && c <= 0xfe); assert(0x40 <= IN2 && IN2 <= 0xfe); - if (BH2S(0x88, 0x40) <= s && s <= BH2S(0xa0, 0xfe)) { + if (BH2S(0x87, 0x40) <= s && s <= BH2S(0xa0, 0xfe)) { hintbase = big5hkscs_phint_0; - s -= BH2S(0x88, 0x40); + s -= BH2S(0x87, 0x40); } else if (BH2S(0xc6,0xa1) <= s && s <= BH2S(0xc8,0xfe)){ - hintbase = big5hkscs_phint_11939; + hintbase = big5hkscs_phint_12130; s -= BH2S(0xc6, 0xa1); } else if (BH2S(0xf9,0xd6) <= s && s <= BH2S(0xfe,0xfe)){ - hintbase = big5hkscs_phint_21733; + hintbase = big5hkscs_phint_21924; s -= BH2S(0xf9, 0xd6); } else @@ -123,7 +153,17 @@ NEXT(2, 1) } } - else return 2; + else { + switch ((c << 8) | IN2) { + case 0x8862: WRITE2(0x00ca, 0x0304); break; + case 0x8864: WRITE2(0x00ca, 0x030c); break; + case 0x88a3: WRITE2(0x00ea, 0x0304); break; + case 0x88a5: WRITE2(0x00ea, 0x030c); break; + default: return 2; + } + + NEXT(2, 2) /* all decoded codepoints are pairs, above. */ + } } return 0; Modified: python/branches/py3k/Modules/cjkcodecs/mappings_hk.h ============================================================================== --- python/branches/py3k/Modules/cjkcodecs/mappings_hk.h (original) +++ python/branches/py3k/Modules/cjkcodecs/mappings_hk.h Sat Feb 9 03:18:51 2008 @@ -1,262 +1,271 @@ -static const ucs2_t __big5hkscs_decmap[6095] = { -62211,62212,62213,62214,62215,268,62217,209,205,62220,62221,203,8168,62224, -202,62226,62227,62228,62229,270,62231,62232,256,193,461,192,274,201,282,200, -332,211,465,210,62245,7870,62247,7872,202,257,225,462,224,593,275,233,283,232, -299,237,464,236,333,243,466,242,363,250,468,249,470,472,474,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,476,252,62276,7871,62278, -7873,234,609,62282,62283,41897,4421,U,25866,U,U,20029,28381,40270,37343,U,U, -30517,25745,20250,20264,20392,20822,20852,20892,20964,21153,21160,21307,21326, -21457,21464,22242,22768,22788,22791,22834,22836,23398,23454,23455,23706,24198, -24635,25993,26622,26628,26725,27982,28860,30005,32420,32428,32442,32455,32463, -32479,32518,32567,33402,33487,33647,35270,35774,35810,36710,36711,36718,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,29713,31996, -32205,26950,31433,21031,U,U,U,U,37260,30904,37214,32956,U,36107,33014,2535,U, -U,32927,40647,19661,40393,40460,19518,40438,28686,40458,41267,13761,U,28314, -33342,29977,U,18705,39532,39567,40857,31111,33900,7626,1488,10982,20004,20097, -20096,20103,20159,20203,20279,13388,20413,15944,20483,20616,13437,13459,13477, -20870,22789,20955,20988,20997,20105,21113,21136,21287,13767,21417,13649,21424, -13651,21442,21539,13677,13682,13953,21651,21667,21684,21689,21712,21743,21784, -21795,21800,13720,21823,13733,13759,21975,13765,32132,21797,U,3138,3349,20779, -21904,11462,14828,833,36422,19896,38117,16467,32958,30586,11320,14900,18389, -33117,27122,19946,25821,3452,4020,3285,4340,25741,36478,3734,3083,3940,11433, -33366,17619,U,3398,39501,33001,18420,20135,11458,39602,14951,38388,16365, -13574,21191,38868,30920,11588,40302,38933,U,17369,24741,25780,21731,11596, -11210,4215,14843,4207,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,26330,26390,31136,25834,20562,3139,36456,8609,35660,1841,U,18443, -425,16378,22643,11661,U,17864,1276,24727,3916,3478,21881,16571,17338,U,19124, -10854,4253,33194,39157,3484,25465,14846,10101,36288,22177,25724,15939,U,42497, -3593,10959,11465,U,4296,14786,14738,14854,33435,13688,24137,8391,22098,3889, -11442,38688,13500,27709,20027,U,U,30068,11915,8712,42587,36045,3706,3124, -26652,32659,4303,10243,10553,13819,20963,3724,3981,3754,16275,3888,3399,4431, -3660,U,3755,2985,3400,4288,4413,16377,9878,25650,4013,13300,30265,11214,3454, -3455,11345,11349,14872,3736,4295,3886,42546,27472,36050,36249,36042,38314, -21708,33476,21945,U,40643,39974,39606,30558,11758,28992,33133,33004,23580, -25970,33076,14231,21343,32957,37302,3834,3599,3703,3835,13789,19947,13833, -3286,22191,10165,4297,3600,3704,4216,4424,33287,5205,3705,20048,11684,23124, -4125,4126,4341,4342,22428,3601,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,30356,33485,4021,3707,20862,14083,4022,4480,21208,41661, -18906,6202,16759,33404,22681,21096,13850,22333,31666,23400,18432,19244,40743, -18919,39967,39821,23412,12605,22011,13810,22153,20008,22786,7105,63608,38737, -134,20059,20155,13630,23587,24401,24516,14586,25164,25909,27514,27701,27706, -28780,29227,20012,29357,18665,32594,31035,31993,32595,25194,13505,U,25419, -32770,32896,26130,26961,21341,34916,35265,30898,35744,36125,38021,38264,38271, -38376,36367,38886,39029,39118,39134,39267,38928,40060,40479,40644,27503,63751, -20023,135,38429,25143,38050,20539,28158,40051,62842,15817,34959,16718,28791, -23797,19232,20941,13657,23856,24866,35378,36775,37366,29073,26393,29626,12929, -41223,15499,6528,19216,30948,29698,20910,34575,16393,27235,41658,16931,34319, -U,31274,39239,35562,38741,28749,21284,8318,37876,30425,35299,62884,30685, -20131,20464,20668,20015,20247,62891,21556,32139,22674,22736,7606,24210,24217, -24514,10002,25995,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,13305,26905,27203,15459,27903,U,29184,17669,29580,16091,18963,23317, -29881,35715,23716,22165,31379,31724,31939,32364,33528,34199,62924,34960,62926, -36537,62928,36815,34143,39392,37409,62933,36281,5183,16497,17058,23066,U,U,U, -39016,26475,17014,22333,U,34262,18811,33471,28941,19585,28020,23931,27413, -28606,62956,62957,23446,62959,U,32347,23870,23880,23894,15868,14351,23972, -23993,14368,14392,24130,24253,24357,24451,14600,14612,14655,14669,24791,24893, -23781,14729,25015,25017,25039,14776,25132,25232,25317,25368,14840,22193,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,14851,25570, -25595,25607,25690,14923,25792,23829,22049,40863,14999,25990,15037,26111,26195, -15090,26258,15138,26390,15170,26532,26624,15192,26698,26756,15218,15217,15227, -26889,26947,29276,26980,27039,27013,15292,27094,15325,27237,27252,27249,27266, -15340,27289,15346,27307,27317,27348,27382,27521,27585,27626,27765,27818,15563, -27906,27910,27942,28033,15599,28068,28081,28181,28184,28201,28294,35264,28347, -28386,28378,40831,28392,28393,28452,28468,15686,16193,28545,28606,15722,15733, -29111,23705,15754,28716,15761,28752,28756,28783,28799,28809,805,17345,13809, -3800,16087,22462,28371,28990,22496,13902,27042,35817,23412,31305,22753,38105, -31333,31357,22956,31419,31408,31426,31427,29137,25741,16842,31450,31453,31466, -16879,21682,23553,31499,31573,31529,21262,23806,31650,31599,33692,23476,27775, -31696,33825,31634,U,23840,15789,23653,33938,31738,U,31797,23745,31812,31875, -18562,31910,26237,17784,31945,31943,31974,31860,31987,31989,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,32359,17693,28228,32093, -28374,29837,32137,32171,28981,32179,U,16471,24617,32228,15635,32245,6137, -32229,33645,U,24865,24922,32366,32402,17195,37996,32295,32576,32577,32583, -31030,25296,39393,32663,25425,32675,5729,104,17756,14182,17667,33594,32762, -25737,U,32776,32797,U,32815,41095,27843,32827,32828,32865,10004,18825,26150, -15843,26344,26405,32935,35400,33031,33050,22704,9974,27775,25752,20408,25831, -5258,33304,6238,27219,19045,19093,17530,33321,2829,27218,15742,20473,5373, -34018,33634,27402,18855,13616,6003,15864,33450,26907,63892,16859,34123,33488, -33562,3606,6068,14017,12669,13658,33403,33506,33560,16011,28067,27397,27543, -13774,15807,33565,21996,33669,17675,28069,33708,U,33747,13438,28372,27223, -34138,13462,28226,12015,33880,23524,33905,15827,17636,27303,33866,15541,31064, -U,27542,28279,28227,34014,U,33681,17568,33939,34020,23697,16960,23744,17731, -34100,23282,28313,17703,34163,17686,26559,34326,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,34341,34363,34241,28808,34306,5506, -28877,63922,17770,34344,13896,6306,21495,29594,34430,34673,41208,34798,11303, -34737,34778,34831,22113,34412,26710,17935,34885,34886,30176,15801,30180,34910, -34972,18011,34996,34997,25537,35013,30583,30479,35207,35210,U,U,35239,35260, -35365,35303,31012,31421,35484,30611,37374,35472,31321,31465,31546,16271,18195, -31544,29052,35596,35615,21552,21861,35647,35660,35661,35497,19066,35728,35739, -35503,5855,17941,34895,35995,32084,32143,63956,14117,32083,36054,32152,32189, -36114,36099,6416,36059,28764,36113,19657,16080,36265,32770,4116,18826,15228, -33212,28940,31463,36525,36534,36547,37588,36633,36653,33637,33810,36773,37635, -41631,2640,36787,18730,35294,34109,15803,24312,12898,36857,40980,34492,34049, -8997,14720,28375,36919,34108,31422,36961,34156,34315,37032,34579,37060,34534, -37038,U,37223,15088,37289,37316,31916,35123,7817,37390,27807,37441,37474, -21945,U,35526,15515,35596,21979,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,3377,37676,37739,35553,35819,28815,23235,35554,35557, -18789,37444,35820,35897,35839,37747,37979,36540,38277,38310,37926,38304,28662, -17081,9850,34520,4732,15918,18911,27676,38523,38550,16748,38563,28373,25050, -38582,30965,35552,38589,21452,18849,27832,628,25616,37039,37093,19153,6421, -13066,38705,34370,38710,18959,17725,17797,19177,28789,23361,38683,U,37333, -38743,23370,37355,38751,37925,20688,12471,12476,38793,38815,38833,38846,38848, -38866,38880,21612,38894,29724,37939,U,38901,37917,31098,19153,38964,38963, -38987,39014,15118,29045,15697,1584,16732,22278,39114,39095,39112,39111,19199, -27943,5843,21936,39137,39142,39148,37752,39225,18985,19314,38999,39173,39413, -39436,39483,39440,39512,22309,14020,37041,39893,39648,39650,39685,39668,19470, -39700,39725,34304,20532,39732,27048,14531,12413,39760,39744,40254,23109,6243, -39822,16971,39938,39935,39948,40552,40404,40887,41362,41387,41185,41251,41439, -40318,40323,41268,40462,26760,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,40388,8539,41363,41504,6459,41523,40249,41145,41652,40592, -40597,40606,40610,19764,40618,40623,17252,40641,15200,14821,15645,20274,14270, -35883,40706,40712,19350,37924,28066,40727,U,40761,22175,22154,40773,39352, -37003,38898,33919,40802,40809,31452,40846,29206,19390,18805,18875,29047,18936, -17224,19025,29598,35802,6394,31135,35198,36406,37737,37875,35396,37612,37761, -37835,35180,17593,29207,16107,30578,31299,28880,17523,17400,29054,6127,28835, -6334,13721,16071,6277,21551,6136,14114,5883,6201,14049,6004,6353,24395,14115, -5824,22363,18981,5118,4776,5062,5302,34051,13990,U,33877,18836,29029,15921, -21852,16123,28754,17652,14062,39325,28454,26617,14131,15381,15847,22636,6434, -26640,16471,14143,16609,16523,16655,27681,21707,22174,26289,22162,4063,2984, -3597,37830,35603,37788,20216,20779,14361,17462,20156,1125,895,20299,20362, -22097,23144,427,971,14745,778,1044,13365,20265,704,36531,629,35546,524,20120, -U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,20685, -20749,20386,20227,18958,16010,20290,20526,20588,20609,20428,20453,20568,20732, -U,U,U,U,28278,13717,15929,16063,28018,6276,16009,20904,20931,1504,17629,1187, -1170,1169,36218,35484,1806,21081,21156,2163,21217,U,18042,29068,17292,3104, -18860,4324,27089,3613,U,16094,29849,29716,29782,29592,19342,19132,16525,21456, -13700,29199,16585,21940,837,21709,3014,22301,37469,38644,37734,22493,22413, -22399,13886,22731,23193,35398,5882,5999,5904,23084,22968,37519,23166,23247, -23058,22854,6643,6241,17045,14069,27909,29763,23073,24195,23169,35799,1043, -37856,29836,4867,28933,18802,37896,35323,37821,14240,23582,23710,24158,24136, -6550,6524,15086,24269,23375,6403,6404,14081,6304,14045,5886,14035,33066,35399, -7610,13426,35240,24332,24334,6439,6059,23147,5947,23364,34324,30205,34912, -24702,10336,9771,24539,16056,9647,9662,37000,28531,25024,62,70,9755,24985, -24984,24693,11419,11527,18132,37197,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,25713,18021,11114,14889,11042,13392,39146,11896, -25399,42075,25782,25393,25553,18915,11623,25252,11425,25659,25963,26994,15348, -12430,12973,18825,12971,21773,13024,6361,37951,26318,12937,12723,15072,16784, -21892,35618,21903,5884,21851,21541,30958,12547,6186,12852,13412,12815,12674, -17097,26254,27940,26219,19347,26160,30832,7659,26211,13010,13025,26142,22642, -14545,14394,14268,15257,14242,13310,29904,15254,26511,17962,26806,26654,15300, -27326,14435,14293,17543,27187,27218,27337,27397,6418,25873,26776,27212,15319, -27258,27479,16320,15514,37792,37618,35818,35531,37513,32798,35292,37991,28069, -28427,18924,U,16255,15759,28164,16444,23101,28170,22599,27940,30786,28987, -17178,17014,28913,29264,29319,29332,18319,18213,20857,19108,1515,29818,16120, -13919,19018,18711,24545,16134,16049,19167,35875,16181,24743,16115,29900,29756, -37767,29751,17567,28138,17745,30083,16227,19673,19718,16216,30037,30323,42438, -15129,29800,35532,18859,18830,15099,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,15821,19022,16127,18885,18675,37370,22322,37698, -35555,6244,20703,21025,20967,30584,12850,30478,30479,30587,18071,14209,14942, -18672,29752,29851,16063,19130,19143,16584,19094,25006,37639,21889,30750,30861, -30856,30930,29648,31065,30529,22243,16654,U,33942,31141,27181,16122,31290, -31220,16750,5862,16690,37429,31217,3404,18828,665,15802,5998,13719,21867, -13680,13994,468,3085,31458,23129,9973,23215,23196,23053,603,30960,23082,23494, -31486,16889,31837,31853,16913,23475,24252,24230,31949,18937,6064,31886,31868, -31918,27314,32220,32263,32211,32590,25185,24924,31560,32151,24194,17002,27509, -2326,26582,78,13775,22468,25618,25592,18786,32733,31527,2092,23273,23875, -31500,24078,39398,34373,39523,27164,13375,14818,18935,26029,39455,26016,33920, -28967,27857,17642,33079,17410,32966,33033,33090,26548,39107,27202,33378,33381, -27217,33875,28071,34320,29211,23174,16767,6208,23339,6305,23268,6360,34464, -63932,15759,34861,29730,23042,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,34926,20293,34951,35007,35046,35173,35149,22147,35156, -30597,30596,35829,35801,35740,35321,16045,33955,18165,18127,14322,35389,35356, -37960,24397,37419,17028,26068,28969,28868,6213,40301,35999,36073,32220,22938, -30659,23024,17262,14036,36394,36519,19465,36656,36682,17140,27736,28603,8993, -18587,28537,28299,6106,39913,14005,18735,37051,U,21873,18694,37307,37892, -35403,16482,35580,37927,35869,35899,34021,35371,38297,38311,38295,38294,36148, -29765,16066,18687,19010,17386,16103,12837,38543,36583,36454,36453,16076,18925, -19064,16366,29714,29803,16124,38721,37040,26695,18973,37011,22495,U,37736, -35209,35878,35631,25534,37562,23313,35689,18748,29689,16923,38811,38769,39224, -3878,24001,35781,19122,38943,38106,37622,38359,37349,17600,35664,19047,35684, -39132,35397,16128,37418,18725,33812,39227,39245,31494,15869,39323,19311,39338, -39516,35685,22728,27279,39457,23294,39471,39153,19344,39240,39356,19389,19351, -37757,22642,4866,22562,18872,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,5352,30788,10015,15800,26821,15741,37976,14631,24912, -10113,10603,24839,40015,40019,40059,39989,39952,39807,39887,40493,39839,41461, -41214,40225,19630,16644,40472,19632,40204,41396,41197,41203,39215,40357,33981, -28178,28639,27522,34300,17715,28068,28292,28144,33824,34286,28160,14295,24676, -31202,13724,13888,18733,18910,15714,37851,37566,37704,703,30905,37495,37965, -20452,13376,36964,21853,30781,30804,30902,30795,5975,12745,18753,13978,20338, -28634,28633,U,28702,21524,16821,22459,22771,22410,40214,22487,28980,13487, -16812,29163,27712,20375,U,6069,35401,24844,23246,23051,17084,17544,14124, -19323,35324,37819,37816,6358,3869,33906,27840,5139,17146,11302,17345,22932, -15799,26433,32168,24923,24740,18873,18827,35322,37605,29666,16105,29876,35683, -6303,16097,19123,27352,29683,29691,16086,19006,19092,6105,19046,935,5156, -18917,29768,18710,28837,18806,37508,29670,37727,1278,37681,35534,35350,37766, -35815,21973,18741,35458,29035,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,18755,3327,22180,1562,3051,3256,21762,31172,6138,32254, -5826,19024,6226,17710,37889,14090,35520,18861,22960,6335,6275,29828,23201, -14050,15707,14000,37471,23161,35457,6242,37748,15565,2740,19094,14730,20724, -15721,15692,5020,29045,17147,33304,28175,37092,17643,27991,32335,28775,27823, -15574,16365,15917,28162,28428,15727,1013,30033,14012,13512,18048,16090,18545, -22980,37486,18750,36673,35868,27584,22546,22472,14038,5202,28926,17250,19057, -12259,4784,9149,26809,26983,5016,13541,31732,14047,35459,14294,13306,19615, -27162,13997,27831,33854,17631,17614,27942,27985,27778,28638,28439,28937,33597, -5946,33773,27776,28755,6107,22921,23170,6067,23137,23153,6405,16892,14125, -23023,5948,14023,29070,37776,26266,17061,23150,23083,17043,27179,16121,30518, -17499,17098,28957,16985,35297,20400,27944,23746,17614,32333,17341,27148,16982, -4868,28838,28979,17385,15781,27871,63525,19023,32357,23019,23855,15859,24412, -19037,6111,32164,33830,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,21637,15098,13056,532,22398,2261,1561,16357,8094,41654,28675, -37211,23920,29583,31955,35417,37920,20424,32743,29389,29456,31476,29496,29497, -22262,29505,29512,16041,31512,36972,29173,18674,29665,33270,16074,30476,16081, -27810,22269,29721,29726,29727,16098,16112,16116,16122,29907,16142,16211,30018, -30061,30066,30093,16252,30152,30172,16320,30285,16343,30324,16348,30330,20316, -29064,22051,35200,22633,16413,30531,16441,26465,16453,13787,30616,16490,16495, -23646,30654,30667,22770,30744,28857,30748,16552,30777,30791,30801,30822,33864, -21813,31027,26627,31026,16643,16649,31121,31129,36795,31238,36796,16743,31377, -16818,31420,33401,16836,31439,31451,16847,20001,31586,31596,31611,31762,31771, -16992,17018,31867,31900,17036,31928,17044,31981,36755,28864,3279,32207,32212, -32208,32253,32686,32692,29343,17303,32800,32805,31545,32814,32817,32852,15820, -22452,28832,32951,33001,17389,33036,29482,33038,33042,30048,33044,17409,15161, -33110,33113,33114,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,17427,22586,33148,33156,17445,33171,17453,33189,22511,33217,33252, -33364,17551,33446,33398,33482,33496,33535,17584,33623,38505,27018,33797,28917, -33892,24803,33928,17668,33982,34017,34040,34064,34104,34130,17723,34159,34160, -34272,17783,34418,34450,34482,34543,38469,34699,17926,17943,34990,35071,35108, -35143,35217,31079,35369,35384,35476,35508,35921,36052,36082,36124,18328,22623, -36291,18413,20206,36410,21976,22356,36465,22005,36528,18487,36558,36578,36580, -36589,36594,36791,36801,36810,36812,36915,39364,18605,39136,37395,18718,37416, -37464,37483,37553,37550,37567,37603,37611,37619,37620,37629,37699,37764,37805, -18757,18769,40639,37911,21249,37917,37933,37950,18794,37972,38009,38189,38306, -18855,38388,38451,18917,26528,18980,38720,18997,38834,38850,22100,19172,24808, -39097,19225,39153,22596,39182,39193,20916,39196,39223,39234,39261,39266,19312, -39365,19357,39484,39695,31363,39785,39809,39901,39921,39924,19565,39968,14191, -7106,40265,39994,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,40702,22096,40339,40381,40384,40444,38134,36790,40571,40620,40625, -40637,40646,38108,40674,40689,40696,31432,40772,148,695,928,26906,38083,22956, -1239,22592,38081,14265,1493,1557,1654,5818,22359,29043,2754,2765,3007,21610, -63547,3019,21662,3067,3131,3155,3173,3196,24807,3213,22138,3253,3293,3309, -3439,3506,3528,26965,39983,34725,3588,3598,3799,3984,3885,3699,23584,4028, -24075,4188,4175,4214,26398,4219,4232,4246,13895,4287,4307,4399,4411,21348, -33965,4835,4981,4918,35713,5495,5657,6083,6087,20088,28859,6189,6506,6701, -6725,7210,7280,7340,7880,25283,7893,7957,29080,26709,8261,27113,14024,8828, -9175,9210,10026,10353,10575,33533,10599,10643,10965,35237,10984,36768,11022, -38840,11071,38983,39613,11340,U,11400,11447,23528,11528,11538,11703,11669, -11842,12148,12236,12339,12390,13087,13278,24497,26184,26303,31353,13671,13811, -U,18874,U,13850,14102,U,838,22709,26382,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,26904,15015,30295,24546,15889,16057,30206,8346, -18640,19128,16665,35482,17134,17165,16443,17204,17302,19013,1482,20946,1553, -22943,7848,15294,15615,17412,17622,22408,18036,14747,18223,34280,39369,14178, -8643,35678,35662,U,18450,18683,18965,29193,19136,3192,22885,20133,20358,1913, -36570,20524,21135,22335,29041,21145,21529,16202,19111,21948,21574,21614,27474, -U,13427,21823,30258,21854,18200,21858,21862,22471,18751,22621,20582,13563, -13260,U,22787,18300,35144,23214,23433,23558,7568,22433,29009,U,24834,31762, -36950,25010,20378,35682,25602,25674,23899,27639,U,25732,6428,35562,18934, -25736,16367,25874,19392,26047,26293,10011,37989,22497,24981,23079,63693,U, -22201,17697,26364,20074,18740,38486,28047,27837,13848,35191,26521,26734,25617, -26718,U,26823,31554,37056,2577,26918,U,26937,31301,U,27130,39462,27181,13919, -25705,33,31107,27188,27483,23852,13593,U,27549,18128,27812,30011,34917,28078, -22710,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -14108,9613,28747,29133,15444,29312,29317,37505,8570,29323,37680,29414,18896, -27705,38047,29776,3832,34855,35061,10534,33907,6065,28344,18986,6176,14756, -14009,U,U,17727,26294,40109,39076,35139,30668,30808,22230,16607,5642,14753, -14127,33000,5061,29101,33638,31197,37288,U,19639,28847,35243,31229,31242, -31499,32102,16762,31555,31102,32777,28597,41695,27139,33560,21410,28167,37823, -26678,38749,33135,32803,27061,5101,12847,32840,23941,35888,32899,22293,38947, -35145,23979,18824,26046,27093,21458,19109,16257,15377,26422,32912,33012,33070, -8097,33103,33161,33199,33306,33542,33583,33674,13770,33896,34474,18682,25574, -35158,30728,37461,35256,17394,35303,17375,35304,35654,35796,23032,35849,U, -36805,37100,U,37136,37180,15863,37214,19146,36816,29327,22155,38119,38377, +static const ucs2_t __big5hkscs_decmap[6219] = { +17392,19506,17923,17830,17784,29287,19831,17843,31921,19682,31941,15253,18230, +18244,19527,19520,17087,13847,29522,28299,28882,19543,41809,18255,17882,19589, +31852,19719,19108,18081,27427,29221,23124,6755,15878,16225,26189,22267,U, +32149,22813,35769,15860,38708,31727,23515,7518,23204,13861,40624,23249,23479, +23804,26478,34195,39237,29793,29853,12736,12737,12738,12739,12740,268,12741, +209,205,12742,12743,203,8168,12744,202,12745,12746,12747,12748,270,12749, +12750,256,193,461,192,274,201,282,200,332,211,465,210,U,7870,U,7872,202,257, +225,462,224,593,275,233,283,232,299,237,464,236,333,243,466,242,363,250,468, +249,470,472,474,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,476,252,U,7871,U,7873,234,609,9178,9179,41897,4421,U,25866,U,U,20029, +28381,40270,37343,U,U,30517,25745,20250,20264,20392,20822,20852,20892,20964, +21153,21160,21307,21326,21457,21464,22242,22768,22788,22791,22834,22836,23398, +23454,23455,23706,24198,24635,25993,26622,26628,26725,27982,28860,30005,32420, +32428,32442,32455,32463,32479,32518,32567,33402,33487,33647,35270,35774,35810, +36710,36711,36718,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,29713,31996,32205,26950,31433,21031,U,U,U,U,37260,30904,37214,32956,U, +36107,33014,2535,U,U,32927,40647,19661,40393,40460,19518,40438,28686,40458, +41267,13761,U,28314,33342,29977,U,18705,39532,39567,40857,31111,33900,7626, +1488,10982,20004,20097,20096,20103,20159,20203,20279,13388,20413,15944,20483, +20616,13437,13459,13477,20870,22789,20955,20988,20997,20105,21113,21136,21287, +13767,21417,13649,21424,13651,21442,21539,13677,13682,13953,21651,21667,21684, +21689,21712,21743,21784,21795,21800,13720,21823,13733,13759,21975,13765,32132, +21797,U,3138,3349,20779,21904,11462,14828,833,36422,19896,38117,16467,32958, +30586,11320,14900,18389,33117,27122,19946,25821,3452,4020,3285,4340,25741, +36478,3734,3083,3940,11433,33366,17619,U,3398,39501,33001,18420,20135,11458, +39602,14951,38388,16365,13574,21191,38868,30920,11588,40302,38933,U,17369, +24741,25780,21731,11596,11210,4215,14843,4207,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,26330,26390,31136,25834,20562,3139,36456, +8609,35660,1841,U,18443,425,16378,22643,11661,U,17864,1276,24727,3916,3478, +21881,16571,17338,U,19124,10854,4253,33194,39157,3484,25465,14846,10101,36288, +22177,25724,15939,U,42497,3593,10959,11465,U,4296,14786,14738,14854,33435, +13688,24137,8391,22098,3889,11442,38688,13500,27709,20027,U,U,30068,11915, +8712,42587,36045,3706,3124,26652,32659,4303,10243,10553,13819,20963,3724,3981, +3754,16275,3888,3399,4431,3660,U,3755,2985,3400,4288,4413,16377,9878,25650, +4013,13300,30265,11214,3454,3455,11345,11349,14872,3736,4295,3886,42546,27472, +36050,36249,36042,38314,21708,33476,21945,U,40643,39974,39606,30558,11758, +28992,33133,33004,23580,25970,33076,14231,21343,32957,37302,3834,3599,3703, +3835,13789,19947,13833,3286,22191,10165,4297,3600,3704,4216,4424,33287,5205, +3705,20048,11684,23124,4125,4126,4341,4342,22428,3601,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,30356,33485,4021,3707,20862,14083, +4022,4480,21208,41661,18906,6202,16759,33404,22681,21096,13850,22333,31666, +23400,18432,19244,40743,18919,39967,39821,23412,12605,22011,13810,22153,20008, +22786,7105,63608,38737,134,20059,20155,13630,23587,24401,24516,14586,25164, +25909,27514,27701,27706,28780,29227,20012,29357,18665,32594,31035,31993,32595, +25194,13505,U,25419,32770,32896,26130,26961,21341,34916,35265,30898,35744, +36125,38021,38264,38271,38376,36367,38886,39029,39118,39134,39267,38928,40060, +40479,40644,27503,63751,20023,135,38429,25143,38050,20539,28158,40051,40870, +15817,34959,16718,28791,23797,19232,20941,13657,23856,24866,35378,36775,37366, +29073,26393,29626,12929,41223,15499,6528,19216,30948,29698,20910,34575,16393, +27235,41658,16931,34319,2671,31274,39239,35562,38741,28749,21284,8318,37876, +30425,35299,40871,30685,20131,20464,20668,20015,20247,40872,21556,32139,22674, +22736,7606,24210,24217,24514,10002,25995,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,13305,26905,27203,15459,27903,U,29184,17669, +29580,16091,18963,23317,29881,35715,23716,22165,31379,31724,31939,32364,33528, +34199,40873,34960,40874,36537,40875,36815,34143,39392,37409,40876,36281,5183, +16497,17058,23066,U,U,U,39016,26475,17014,22333,U,34262,18811,33471,28941, +19585,28020,23931,27413,28606,40877,40878,23446,40879,26343,32347,28247,31178, +15752,17603,12886,10134,17306,17718,U,23765,15130,35577,23672,15634,13649, +23928,40882,29015,17752,16620,7715,19575,14712,13386,420,27713,35532,20404, +569,22975,33132,38998,39162,24379,2975,U,8641,35181,16642,18107,36985,16135, +40883,41397,16632,14294,18167,27718,16764,34482,29695,17773,14548,21658,17761, +17691,19849,19579,19830,17898,16328,19215,13921,17630,17597,16877,23870,23880, +23894,15868,14351,23972,23993,14368,14392,24130,24253,24357,24451,14600,14612, +14655,14669,24791,24893,23781,14729,25015,25017,25039,14776,25132,25232,25317, +25368,14840,22193,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,14851,25570,25595,25607,25690,14923,25792,23829,22049,40863,14999, +25990,15037,26111,26195,15090,26258,15138,26390,15170,26532,26624,15192,26698, +26756,15218,15217,15227,26889,26947,29276,26980,27039,27013,15292,27094,15325, +27237,27252,27249,27266,15340,27289,15346,27307,27317,27348,27382,27521,27585, +27626,27765,27818,15563,27906,27910,27942,28033,15599,28068,28081,28181,28184, +28201,28294,35264,28347,28386,28378,40831,28392,28393,28452,28468,15686,16193, +28545,28606,15722,15733,29111,23705,15754,28716,15761,28752,28756,28783,28799, +28809,805,17345,13809,3800,16087,22462,28371,28990,22496,13902,27042,35817, +23412,31305,22753,38105,31333,31357,22956,31419,31408,31426,31427,29137,25741, +16842,31450,31453,31466,16879,21682,23553,31499,31573,31529,21262,23806,31650, +31599,33692,23476,27775,31696,33825,31634,U,23840,15789,23653,33938,31738,U, +31797,23745,31812,31875,18562,31910,26237,17784,31945,31943,31974,31860,31987, +31989,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +32359,17693,28228,32093,28374,29837,32137,32171,28981,32179,U,16471,24617, +32228,15635,32245,6137,32229,33645,U,24865,24922,32366,32402,17195,37996, +32295,32576,32577,32583,31030,25296,39393,32663,25425,32675,5729,104,17756, +14182,17667,33594,32762,25737,U,32776,32797,U,32815,41095,27843,32827,32828, +32865,10004,18825,26150,15843,26344,26405,32935,35400,33031,33050,22704,9974, +27775,25752,20408,25831,5258,33304,6238,27219,19045,19093,17530,33321,2829, +27218,15742,20473,5373,34018,33634,27402,18855,13616,6003,15864,33450,26907, +63892,16859,34123,33488,33562,3606,6068,14017,12669,13658,33403,33506,33560, +16011,28067,27397,27543,13774,15807,33565,21996,33669,17675,28069,33708,U, +33747,13438,28372,27223,34138,13462,28226,12015,33880,23524,33905,15827,17636, +27303,33866,15541,31064,U,27542,28279,28227,34014,U,33681,17568,33939,34020, +23697,16960,23744,17731,34100,23282,28313,17703,34163,17686,26559,34326,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,34341,34363, +34241,28808,34306,5506,28877,63922,17770,34344,13896,6306,21495,29594,34430, +34673,41208,34798,11303,34737,34778,34831,22113,34412,26710,17935,34885,34886, +30176,15801,30180,34910,34972,18011,34996,34997,25537,35013,30583,30479,35207, +35210,U,U,35239,35260,35365,35303,31012,31421,35484,30611,37374,35472,31321, +31465,31546,16271,18195,31544,29052,35596,35615,21552,21861,35647,35660,35661, +35497,19066,35728,35739,35503,5855,17941,34895,35995,32084,32143,63956,14117, +32083,36054,32152,32189,36114,36099,6416,36059,28764,36113,19657,16080,36265, +32770,4116,18826,15228,33212,28940,31463,36525,36534,36547,37588,36633,36653, +33637,33810,36773,37635,41631,2640,36787,18730,35294,34109,15803,24312,12898, +36857,40980,34492,34049,8997,14720,28375,36919,34108,31422,36961,34156,34315, +37032,34579,37060,34534,37038,U,37223,15088,37289,37316,31916,35123,7817, +37390,27807,37441,37474,21945,U,35526,15515,35596,21979,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,3377,37676,37739,35553,35819, +28815,23235,35554,35557,18789,37444,35820,35897,35839,37747,37979,36540,38277, +38310,37926,38304,28662,17081,9850,34520,4732,15918,18911,27676,38523,38550, +16748,38563,28373,25050,38582,30965,35552,38589,21452,18849,27832,628,25616, +37039,37093,19153,6421,13066,38705,34370,38710,18959,17725,17797,19177,28789, +23361,38683,U,37333,38743,23370,37355,38751,37925,20688,12471,12476,38793, +38815,38833,38846,38848,38866,38880,21612,38894,29724,37939,U,38901,37917, +31098,19153,38964,38963,38987,39014,15118,29045,15697,1584,16732,22278,39114, +39095,39112,39111,19199,27943,5843,21936,39137,39142,39148,37752,39225,18985, +19314,38999,39173,39413,39436,39483,39440,39512,22309,14020,37041,39893,39648, +39650,39685,39668,19470,39700,39725,34304,20532,39732,27048,14531,12413,39760, +39744,40254,23109,6243,39822,16971,39938,39935,39948,40552,40404,40887,41362, +41387,41185,41251,41439,40318,40323,41268,40462,26760,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,40388,8539,41363,41504,6459,41523, +40249,41145,41652,40592,40597,40606,40610,19764,40618,40623,17252,40641,15200, +14821,15645,20274,14270,35883,40706,40712,19350,37924,28066,40727,U,40761, +22175,22154,40773,39352,37003,38898,33919,40802,40809,31452,40846,29206,19390, +18805,18875,29047,18936,17224,19025,29598,35802,6394,31135,35198,36406,37737, +37875,35396,37612,37761,37835,35180,17593,29207,16107,30578,31299,28880,17523, +17400,29054,6127,28835,6334,13721,16071,6277,21551,6136,14114,5883,6201,14049, +6004,6353,24395,14115,5824,22363,18981,5118,4776,5062,5302,34051,13990,U, +33877,18836,29029,15921,21852,16123,28754,17652,14062,39325,28454,26617,14131, +15381,15847,22636,6434,26640,16471,14143,16609,16523,16655,27681,21707,22174, +26289,22162,4063,2984,3597,37830,35603,37788,20216,20779,14361,17462,20156, +1125,895,20299,20362,22097,23144,427,971,14745,778,1044,13365,20265,704,36531, +629,35546,524,20120,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,20685,20749,20386,20227,18958,16010,20290,20526,20588,20609,20428, +20453,20568,20732,U,U,U,U,28278,13717,15929,16063,28018,6276,16009,20904, +20931,1504,17629,1187,1170,1169,36218,35484,1806,21081,21156,2163,21217,U, +18042,29068,17292,3104,18860,4324,27089,3613,U,16094,29849,29716,29782,29592, +19342,19132,16525,21456,13700,29199,16585,21940,837,21709,3014,22301,37469, +38644,37734,22493,22413,22399,13886,22731,23193,35398,5882,5999,5904,23084, +22968,37519,23166,23247,23058,22854,6643,6241,17045,14069,27909,29763,23073, +24195,23169,35799,1043,37856,29836,4867,28933,18802,37896,35323,37821,14240, +23582,23710,24158,24136,6550,6524,15086,24269,23375,6403,6404,14081,6304, +14045,5886,14035,33066,35399,7610,13426,35240,24332,24334,6439,6059,23147, +5947,23364,34324,30205,34912,24702,10336,9771,24539,16056,9647,9662,37000, +28531,25024,62,70,9755,24985,24984,24693,11419,11527,18132,37197,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,25713,18021,11114, +14889,11042,13392,39146,11896,25399,42075,25782,25393,25553,18915,11623,25252, +11425,25659,25963,26994,15348,12430,12973,18825,12971,21773,13024,6361,37951, +26318,12937,12723,15072,16784,21892,35618,21903,5884,21851,21541,30958,12547, +6186,12852,13412,12815,12674,17097,26254,27940,26219,19347,26160,30832,7659, +26211,13010,13025,26142,22642,14545,14394,14268,15257,14242,13310,29904,15254, +26511,17962,26806,26654,15300,27326,14435,14293,17543,27187,27218,27337,27397, +6418,25873,26776,27212,15319,27258,27479,16320,15514,37792,37618,35818,35531, +37513,32798,35292,37991,28069,28427,18924,U,16255,15759,28164,16444,23101, +28170,22599,27940,30786,28987,17178,17014,28913,29264,29319,29332,18319,18213, +20857,19108,1515,29818,16120,13919,19018,18711,24545,16134,16049,19167,35875, +16181,24743,16115,29900,29756,37767,29751,17567,28138,17745,30083,16227,19673, +19718,16216,30037,30323,42438,15129,29800,35532,18859,18830,15099,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,15821,19022,16127, +18885,18675,37370,22322,37698,35555,6244,20703,21025,20967,30584,12850,30478, +30479,30587,18071,14209,14942,18672,29752,29851,16063,19130,19143,16584,19094, +25006,37639,21889,30750,30861,30856,30930,29648,31065,30529,22243,16654,U, +33942,31141,27181,16122,31290,31220,16750,5862,16690,37429,31217,3404,18828, +665,15802,5998,13719,21867,13680,13994,468,3085,31458,23129,9973,23215,23196, +23053,603,30960,23082,23494,31486,16889,31837,31853,16913,23475,24252,24230, +31949,18937,6064,31886,31868,31918,27314,32220,32263,32211,32590,25185,24924, +31560,32151,24194,17002,27509,2326,26582,78,13775,22468,25618,25592,18786, +32733,31527,2092,23273,23875,31500,24078,39398,34373,39523,27164,13375,14818, +18935,26029,39455,26016,33920,28967,27857,17642,33079,17410,32966,33033,33090, +26548,39107,27202,33378,33381,27217,33875,28071,34320,29211,23174,16767,6208, +23339,6305,23268,6360,34464,63932,15759,34861,29730,23042,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,34926,20293,34951,35007,35046, +35173,35149,22147,35156,30597,30596,35829,35801,35740,35321,16045,33955,18165, +18127,14322,35389,35356,37960,24397,37419,17028,26068,28969,28868,6213,40301, +35999,36073,32220,22938,30659,23024,17262,14036,36394,36519,19465,36656,36682, +17140,27736,28603,8993,18587,28537,28299,6106,39913,14005,18735,37051,U,21873, +18694,37307,37892,35403,16482,35580,37927,35869,35899,34021,35371,38297,38311, +38295,38294,36148,29765,16066,18687,19010,17386,16103,12837,38543,36583,36454, +36453,16076,18925,19064,16366,29714,29803,16124,38721,37040,26695,18973,37011, +22495,U,37736,35209,35878,35631,25534,37562,23313,35689,18748,29689,16923, +38811,38769,39224,3878,24001,35781,19122,38943,38106,37622,38359,37349,17600, +35664,19047,35684,39132,35397,16128,37418,18725,33812,39227,39245,31494,15869, +39323,19311,39338,39516,35685,22728,27279,39457,23294,39471,39153,19344,39240, +39356,19389,19351,37757,22642,4866,22562,18872,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,5352,30788,10015,15800,26821,15741, +37976,14631,24912,10113,10603,24839,40015,40019,40059,39989,39952,39807,39887, +40493,39839,41461,41214,40225,19630,16644,40472,19632,40204,41396,41197,41203, +39215,40357,33981,28178,28639,27522,34300,17715,28068,28292,28144,33824,34286, +28160,14295,24676,31202,13724,13888,18733,18910,15714,37851,37566,37704,703, +30905,37495,37965,20452,13376,36964,21853,30781,30804,30902,30795,5975,12745, +18753,13978,20338,28634,28633,U,28702,21524,16821,22459,22771,22410,40214, +22487,28980,13487,16812,29163,27712,20375,U,6069,35401,24844,23246,23051, +17084,17544,14124,19323,35324,37819,37816,6358,3869,33906,27840,5139,17146, +11302,17345,22932,15799,26433,32168,24923,24740,18873,18827,35322,37605,29666, +16105,29876,35683,6303,16097,19123,27352,29683,29691,16086,19006,19092,6105, +19046,935,5156,18917,29768,18710,28837,18806,37508,29670,37727,1278,37681, +35534,35350,37766,35815,21973,18741,35458,29035,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,18755,3327,22180,1562,3051,3256,21762, +31172,6138,32254,5826,19024,6226,17710,37889,14090,35520,18861,22960,6335, +6275,29828,23201,14050,15707,14000,37471,23161,35457,6242,37748,15565,2740, +19094,14730,20724,15721,15692,5020,29045,17147,33304,28175,37092,17643,27991, +32335,28775,27823,15574,16365,15917,28162,28428,15727,1013,30033,14012,13512, +18048,16090,18545,22980,37486,18750,36673,35868,27584,22546,22472,14038,5202, +28926,17250,19057,12259,4784,9149,26809,26983,5016,13541,31732,14047,35459, +14294,13306,19615,27162,13997,27831,33854,17631,17614,27942,27985,27778,28638, +28439,28937,33597,5946,33773,27776,28755,6107,22921,23170,6067,23137,23153, +6405,16892,14125,23023,5948,14023,29070,37776,26266,17061,23150,23083,17043, +27179,16121,30518,17499,17098,28957,16985,35297,20400,27944,23746,17614,32333, +17341,27148,16982,4868,28838,28979,17385,15781,27871,63525,19023,32357,23019, +23855,15859,24412,19037,6111,32164,33830,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,21637,15098,13056,532,22398,2261,1561,16357, +8094,41654,28675,37211,23920,29583,31955,35417,37920,20424,32743,29389,29456, +31476,29496,29497,22262,29505,29512,16041,31512,36972,29173,18674,29665,33270, +16074,30476,16081,27810,22269,29721,29726,29727,16098,16112,16116,16122,29907, +16142,16211,30018,30061,30066,30093,16252,30152,30172,16320,30285,16343,30324, +16348,30330,20316,29064,22051,35200,22633,16413,30531,16441,26465,16453,13787, +30616,16490,16495,23646,30654,30667,22770,30744,28857,30748,16552,30777,30791, +30801,30822,33864,21813,31027,26627,31026,16643,16649,31121,31129,36795,31238, +36796,16743,31377,16818,31420,33401,16836,31439,31451,16847,20001,31586,31596, +31611,31762,31771,16992,17018,31867,31900,17036,31928,17044,31981,36755,28864, +3279,32207,32212,32208,32253,32686,32692,29343,17303,32800,32805,31545,32814, +32817,32852,15820,22452,28832,32951,33001,17389,33036,29482,33038,33042,30048, +33044,17409,15161,33110,33113,33114,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,17427,22586,33148,33156,17445,33171,17453,33189, +22511,33217,33252,33364,17551,33446,33398,33482,33496,33535,17584,33623,38505, +27018,33797,28917,33892,24803,33928,17668,33982,34017,34040,34064,34104,34130, +17723,34159,34160,34272,17783,34418,34450,34482,34543,38469,34699,17926,17943, +34990,35071,35108,35143,35217,31079,35369,35384,35476,35508,35921,36052,36082, +36124,18328,22623,36291,18413,20206,36410,21976,22356,36465,22005,36528,18487, +36558,36578,36580,36589,36594,36791,36801,36810,36812,36915,39364,18605,39136, +37395,18718,37416,37464,37483,37553,37550,37567,37603,37611,37619,37620,37629, +37699,37764,37805,18757,18769,40639,37911,21249,37917,37933,37950,18794,37972, +38009,38189,38306,18855,38388,38451,18917,26528,18980,38720,18997,38834,38850, +22100,19172,24808,39097,19225,39153,22596,39182,39193,20916,39196,39223,39234, +39261,39266,19312,39365,19357,39484,39695,31363,39785,39809,39901,39921,39924, +19565,39968,14191,7106,40265,39994,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,40702,22096,40339,40381,40384,40444,38134,36790, +40571,40620,40625,40637,40646,38108,40674,40689,40696,31432,40772,148,695,928, +26906,38083,22956,1239,22592,38081,14265,1493,1557,1654,5818,22359,29043,2754, +2765,3007,21610,63547,3019,21662,3067,3131,3155,3173,3196,24807,3213,22138, +3253,3293,3309,3439,3506,3528,26965,39983,34725,3588,3598,3799,3984,3885,3699, +23584,4028,24075,4188,4175,4214,26398,4219,4232,4246,13895,4287,4307,4399, +4411,21348,33965,4835,4981,4918,35713,5495,5657,6083,6087,20088,28859,6189, +6506,6701,6725,7210,7280,7340,7880,25283,7893,7957,29080,26709,8261,27113, +14024,8828,9175,9210,10026,10353,10575,33533,10599,10643,10965,35237,10984, +36768,11022,38840,11071,38983,39613,11340,U,11400,11447,23528,11528,11538, +11703,11669,11842,12148,12236,12339,12390,13087,13278,24497,26184,26303,31353, +13671,13811,U,18874,U,13850,14102,U,838,22709,26382,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,26904,15015,30295,24546,15889,16057, +30206,8346,18640,19128,16665,35482,17134,17165,16443,17204,17302,19013,1482, +20946,1553,22943,7848,15294,15615,17412,17622,22408,18036,14747,18223,34280, +39369,14178,8643,35678,35662,U,18450,18683,18965,29193,19136,3192,22885,20133, +20358,1913,36570,20524,21135,22335,29041,21145,21529,16202,19111,21948,21574, +21614,27474,U,13427,21823,30258,21854,18200,21858,21862,22471,18751,22621, +20582,13563,13260,U,22787,18300,35144,23214,23433,23558,7568,22433,29009,U, +24834,31762,36950,25010,20378,35682,25602,25674,23899,27639,U,25732,6428, +35562,18934,25736,16367,25874,19392,26047,26293,10011,37989,22497,24981,23079, +63693,U,22201,17697,26364,20074,18740,38486,28047,27837,13848,35191,26521, +26734,25617,26718,U,26823,31554,37056,2577,26918,U,26937,31301,U,27130,39462, +27181,13919,25705,33,31107,27188,27483,23852,13593,U,27549,18128,27812,30011, +34917,28078,22710,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +U,U,U,U,14108,9613,28747,29133,15444,29312,29317,37505,8570,29323,37680,29414, +18896,27705,38047,29776,3832,34855,35061,10534,33907,6065,28344,18986,6176, +14756,14009,U,U,17727,26294,40109,39076,35139,30668,30808,22230,16607,5642, +14753,14127,33000,5061,29101,33638,31197,37288,U,19639,28847,35243,31229, +31242,31499,32102,16762,31555,31102,32777,28597,41695,27139,33560,21410,28167, +37823,26678,38749,33135,32803,27061,5101,12847,32840,23941,35888,32899,22293, +38947,35145,23979,18824,26046,27093,21458,19109,16257,15377,26422,32912,33012, +33070,8097,33103,33161,33199,33306,33542,33583,33674,13770,33896,34474,18682, +25574,35158,30728,37461,35256,17394,35303,17375,35304,35654,35796,23032,35849, +U,36805,37100,U,37136,37180,15863,37214,19146,36816,29327,22155,38119,38377, 38320,38328,38706,39121,39241,39274,39363,39464,39694,40282,40347,32415,40696, 40739,19620,38215,41619,29090,41727,19857,36882,42443,19868,3228,36798,21953, U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,36794, @@ -277,7 +286,7 @@ 19972,13687,23309,27826,21351,13996,14812,21373,13989,17944,22682,19310,33325, 21579,22442,23189,2425,U,14930,9317,29556,40620,19721,39917,15614,40752,19547, 20393,38302,40926,33884,15798,29362,26547,14112,25390,32037,16119,15916,14890, -36872,21196,15988,13946,17897,1166,30272,23280,3766,30842,18358,22695,16575, +36872,21196,15988,13946,17897,1166,30272,23280,3766,30842,32558,22695,16575, 22140,39819,23924,30292,42036,40581,19681,U,14331,24857,12506,17394,U,22109, 4777,22439,18787,40454,21044,28846,13741,U,40316,31830,39737,22494,5996,23635, 25811,38096,25397,29028,34477,3368,27938,19170,3441,U,20990,7951,23950,38659, @@ -327,9 +336,9 @@ 1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067, 1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081, 1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096, -1097,1098,1099,1100,1101,1102,1103,8679,8632,8633,63461,204,20058,138,20994, -63466,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, -63467,20872,63469,30215,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +1097,1098,1099,1100,1101,1102,1103,8679,8632,8633,12751,204,20058,138,20994, +17553,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, +40880,20872,40881,30215,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U, U,U,U,U,U,U,U,U,U,U,U,U,U,65506,65508,65287,65282,12849,8470,8481,12443,12444, 11904,11908,11910,11911,11912,11914,11916,11917,11925,11932,11933,11941,11943, 11946,11948,11950,11958,11964,11966,11974,11978,11980,11981,11983,11990,11991, @@ -417,67 +426,68 @@ },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 -},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, -0,0},{__big5hkscs_decmap+0,64,170},{__big5hkscs_decmap+107,64,254},{ -__big5hkscs_decmap+298,64,254},{__big5hkscs_decmap+489,64,253},{ -__big5hkscs_decmap+679,64,220},{__big5hkscs_decmap+836,96,254},{ -__big5hkscs_decmap+995,64,254},{__big5hkscs_decmap+1186,64,253},{ -__big5hkscs_decmap+1376,64,254},{__big5hkscs_decmap+1567,64,254},{ -__big5hkscs_decmap+1758,64,254},{__big5hkscs_decmap+1949,64,254},{ -__big5hkscs_decmap+2140,64,254},{__big5hkscs_decmap+2331,64,254},{ -__big5hkscs_decmap+2522,64,254},{__big5hkscs_decmap+2713,64,254},{ -__big5hkscs_decmap+2904,64,254},{__big5hkscs_decmap+3095,64,254},{ -__big5hkscs_decmap+3286,64,254},{__big5hkscs_decmap+3477,64,254},{ -__big5hkscs_decmap+3668,64,254},{__big5hkscs_decmap+3859,64,254},{ -__big5hkscs_decmap+4050,64,254},{__big5hkscs_decmap+4241,64,254},{ -__big5hkscs_decmap+4432,64,254},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 -},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, +},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ +__big5hkscs_decmap+0,64,121},{__big5hkscs_decmap+58,64,170},{ +__big5hkscs_decmap+165,64,254},{__big5hkscs_decmap+356,64,254},{ +__big5hkscs_decmap+547,64,253},{__big5hkscs_decmap+737,64,254},{ +__big5hkscs_decmap+928,64,254},{__big5hkscs_decmap+1119,64,254},{ +__big5hkscs_decmap+1310,64,253},{__big5hkscs_decmap+1500,64,254},{ +__big5hkscs_decmap+1691,64,254},{__big5hkscs_decmap+1882,64,254},{ +__big5hkscs_decmap+2073,64,254},{__big5hkscs_decmap+2264,64,254},{ +__big5hkscs_decmap+2455,64,254},{__big5hkscs_decmap+2646,64,254},{ +__big5hkscs_decmap+2837,64,254},{__big5hkscs_decmap+3028,64,254},{ +__big5hkscs_decmap+3219,64,254},{__big5hkscs_decmap+3410,64,254},{ +__big5hkscs_decmap+3601,64,254},{__big5hkscs_decmap+3792,64,254},{ +__big5hkscs_decmap+3983,64,254},{__big5hkscs_decmap+4174,64,254},{ +__big5hkscs_decmap+4365,64,254},{__big5hkscs_decmap+4556,64,254},{0,0,0},{0,0, +0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 -},{0,0,0},{0,0,0},{__big5hkscs_decmap+4623,161,254},{__big5hkscs_decmap+4717, -64,254},{__big5hkscs_decmap+4908,64,254},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0, -0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, +},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__big5hkscs_decmap+4747, +161,254},{__big5hkscs_decmap+4841,64,254},{__big5hkscs_decmap+5032,64,254},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, -0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__big5hkscs_decmap+5099,214,254},{ -__big5hkscs_decmap+5140,64,254},{__big5hkscs_decmap+5331,64,254},{ -__big5hkscs_decmap+5522,64,254},{__big5hkscs_decmap+5713,64,254},{ -__big5hkscs_decmap+5904,64,254},{0,0,0}, +0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ +0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ +__big5hkscs_decmap+5223,214,254},{__big5hkscs_decmap+5264,64,254},{ +__big5hkscs_decmap+5455,64,254},{__big5hkscs_decmap+5646,64,254},{ +__big5hkscs_decmap+5837,64,254},{__big5hkscs_decmap+6028,64,254},{0,0,0}, }; static const unsigned char big5hkscs_phint_0[] = { -160,89,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,8,0,0,0,0,0,0,0,0,0,0, -0,0,2,44,0,30,0,0,0,0,0,64,174,86,238,249,221,228,33,23,0,0,0,128,219,73,31, -76,130,55,237,228,223,189,247,245,239,31,100,136,94,253,223,11,0,0,0,192,247, -143,0,131,5,0,8,201,8,4,129,64,68,5,11,9,35,1,32,2,0,0,0,32,145,24,0,96,0,168, -6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,128,0,64,86,50,65,32,198, -80,72,2,0,0,0,0,160,192,168,1,164,85,48,58,209,106,46,159,176,241,65,136,5,57, -80,4,0,0,0,0,172,163,20,192,1,2,13,45,134,136,107,34,110,192,204,245,218,10, -24,122,0,0,0,0,50,115,0,15,68,252,3,33,49,32,25,232,96,160,65,19,82,42,250,9, -0,0,0,0,190,1,129,16,16,96,183,137,193,218,237,250,242,59,200,167,11,77,155, -11,0,0,0,0,24,0,220,116,19,94,192,168,0,60,240,208,68,224,172,60,75,230,29,15, -0,0,0,128,189,88,120,55,191,187,216,218,8,134,192,108,148,192,176,125,14,136, -145,3,0,0,0,64,99,139,197,22,24,68,124,152,75,112,3,92,219,185,208,26,40,149, -106,1,0,0,0,0,232,7,36,34,32,136,4,106,32,215,29,50,15,162,149,11,4,67,65,1,0, -0,0,104,48,64,19,207,57,183,16,8,7,4,180,33,217,183,15,11,127,69,91,0,0,0,0, -236,116,236,196,4,41,49,2,48,250,252,27,175,78,38,164,183,110,50,24,0,0,0,0, -220,22,67,34,1,0,0,128,0,0,0,4,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0, -0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,28,241,220,190,126,252,186,123,238,249,55,249, -93,165,255,31,215,2,0,0,0,128,63,255,213,117,117,187,120,231,62,245,177,173, -189,75,150,188,46,181,85,2,0,0,0,192,109,51,55,176,233,204,159,42,126,83,204, -255,77,234,218,198,255,55,165,0,0,0,0,160,192,252,222,50,83,161,28,0,0,33,176, -71,0,74,32,32,233,215,235,0,0,0,0,160,183,1,64,49,101,247,12,36,64,48,45,144, -123,18,0,0,2,0,0,0,0,0,0,0,8,80,144,69,0,4,0,0,32,64,4,161,128,96,2,0,32,0,8, -0,0,0,0,148,8,2,32,40,0,0,1,8,254,251,73, +32,5,95,68,15,82,130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,208,44,4,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,4,0,0,0,0,0,0,0,0,0,0,0,0,1,22,0,15,0,0,0,0,0, +32,87,43,247,252,110,242,144,11,0,0,0,192,237,164,15,38,193,155,118,242,239, +222,251,250,247,15,50,68,175,254,239,5,0,0,0,224,251,71,128,193,2,0,132,100,4, +130,64,32,162,130,133,164,145,0,16,1,0,0,0,144,72,12,0,48,0,84,3,48,68,24,19, +53,137,38,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,64,0,32,43,153,32,16,99,40,36, +1,0,0,0,0,80,96,212,0,210,42,24,157,104,53,151,79,216,248,32,196,130,28,40,2, +0,0,0,0,214,81,10,224,0,129,134,22,67,196,53,17,55,96,230,122,109,5,12,61,0,0, +0,0,153,57,128,7,34,254,129,144,24,144,12,116,48,208,160,9,41,21,253,4,0,0,0, +0,223,128,64,8,8,176,219,196,96,237,118,125,249,29,228,211,133,166,205,5,0,0, +0,0,12,0,110,186,9,47,96,84,0,30,120,104,34,112,86,158,37,243,142,7,0,0,0,192, +94,44,188,155,223,93,108,109,4,67,96,54,74,96,216,62,7,196,200,1,0,0,0,160, +177,197,98,11,12,34,62,204,37,184,1,174,237,92,104,13,148,74,181,0,0,0,0,0, +244,3,18,17,16,68,2,53,144,235,14,153,7,209,202,5,130,161,160,0,0,0,0,52,24, +160,137,231,156,91,8,132,3,2,218,144,236,219,135,133,191,162,45,0,0,0,0,118, +58,118,98,130,148,24,1,24,125,254,141,87,39,19,210,91,55,25,12,0,0,0,0,110, +139,33,145,0,0,0,64,0,0,0,2,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0, +0,0,0,0,0,0,0,2,0,0,0,0,0,0,142,120,110,95,63,126,221,61,247,252,155,252,174, +210,255,143,107,1,0,0,0,192,159,255,234,186,186,93,188,115,159,250,216,214, +222,37,75,94,151,218,42,1,0,0,0,224,182,153,27,216,116,230,79,21,191,41,230, +255,38,117,109,227,255,155,82,0,0,0,0,80,96,126,111,153,169,80,14,0,128,16, +216,35,0,37,16,144,244,235,117,0,0,0,0,208,219,0,160,152,178,123,6,82,32,152, +22,200,61,9,0,0,1,0,0,0,0,0,0,0,4,40,200,34,0,2,0,0,16,32,130,80,64,48,1,0,16, +0,4,0,0,0,0,74,4,1,16,20,0,128,0,4,255,253,36, }; -static const unsigned char big5hkscs_phint_11939[] = { +static const unsigned char big5hkscs_phint_12130[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,128,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0, }; -static const unsigned char big5hkscs_phint_21733[] = { +static const unsigned char big5hkscs_phint_21924[] = { 0,0,0,0,0,26,172,248,250,90,192,250,51,0,0,0,0,0,129,0,160,156,130,144,9,1, 180,192,176,3,86,2,160,66,45,136,1,0,0,0,0,146,119,139,96,5,201,33,6,70,56,96, 72,192,180,36,222,132,224,192,36,0,0,0,0,205,80,197,52,192,40,162,173,124,153, @@ -485,33 +495,33 @@ 5,72,8,22,230,28,165,0,8,0,0,0,192,45,22,20,128,24,58,212,25,136,28,138,4, }; -static const DBCHAR __big5hkscs_bmp_encmap[26537] = { +static const DBCHAR __big5hkscs_bmp_encmap[26401] = { 50904,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34905,34903,N,N,N,N,N,N, -34909,34907,34918,N,N,N,N,N,N,N,34913,34911,N,N,N,N,N,N,N,N,N,N,N,N,34922, -34920,N,N,N,N,N,N,34927,34925,34983,N,34931,34929,N,N,N,N,34935,34933,N,N,N,N, -51451,34939,34937,N,34978,34902,34919,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34906, -34924,N,N,N,N,N,N,34908,34926,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34928,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,51452,34910,34932,N,N,N,N,N, -51450,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34936,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,34904,34921,N,34930,34912,34934,N,34938,N,34940,N,34941,N, -34942,N,34977,51446,34923,N,N,51448,N,N,N,N,N,N,51447,N,N,N,N,N,34984,N,N,N,N, -N,N,N,N,51454,N,N,N,N,N,N,N,N,N,N,51449,N,N,N,N,N,N,N,N,N,N,N,N,N,51445,N,N,N, -N,N,N,51453,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,50905,51193,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,51187,51188,51189,51190,51191,51192,51194,51195,51196,51197, -51198,51264,51265,51266,51267,51268,51269,51270,51271,51272,51273,51274,51275, -51276,51277,51278,51279,51280,51281,51282,51283,51284,51285,51286,51287,51288, -51289,51290,51292,51293,51294,51295,51296,51297,51298,51299,51300,51301,51302, -51303,51304,51305,51306,51307,51308,51309,51310,51311,51312,51313,51314,51315, -51316,51317,N,51291,34915,34980,34917,34982,51410,N,N,N,N,N,N,N,N,N,N,51411,N, +34909,34907,M,N,N,N,N,N,N,N,34913,34911,N,N,N,N,N,N,N,N,N,N,N,N,34922,34920,N, +N,N,N,N,N,34927,34925,M,N,34931,34929,N,N,N,N,34935,34933,N,N,N,N,51451,34939, +34937,N,34978,34902,34919,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34906,34924,N,N,N,N, +N,N,34908,34926,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34928,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,51452,34910,34932,N,N,N,N,N,51450,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34936,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,34904,34921,N,34930,34912,34934,N,34938,N,34940,N,34941,N,34942,N,34977, +51446,34923,N,N,51448,N,N,N,N,N,N,51447,N,N,N,N,N,34984,N,N,N,N,N,N,N,N,51454, +N,N,N,N,N,N,N,N,N,N,51449,N,N,N,N,N,N,N,N,N,N,N,N,N,51445,N,N,N,N,N,N,51453,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,50905,51193,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +51187,51188,51189,51190,51191,51192,51194,51195,51196,51197,51198,51264,51265, +51266,51267,51268,51269,51270,51271,51272,51273,51274,51275,51276,51277,51278, +51279,51280,51281,51282,51283,51284,51285,51286,51287,51288,51289,51290,51292, +51293,51294,51295,51296,51297,51298,51299,51300,51301,51302,51303,51304,51305, +51306,51307,51308,51309,51310,51311,51312,51313,51314,51315,51316,51317,N, +51291,34915,34980,34917,34982,51410,N,N,N,N,N,N,N,N,N,N,51411,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -50869,50870,50871,50872,50873,50874,50875,50876,50877,50878,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,50869,50870, +50871,50872,50873,50874,50875,50876,50877,50878,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,51319,51320,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,51318,50849,50850,50851, +N,N,N,N,N,N,N,N,51319,51320,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,51318,34985,34986,50849,50850,50851, 50852,50853,50854,50855,50856,50857,50858,N,N,N,N,N,N,N,N,N,N,50859,50860, 50861,50862,50863,50864,50865,50866,50867,50868,63993,63992,63974,63983,63965, 63976,63985,63967,63980,63989,63971,63982,63991,63973,63977,63986,63968,63979, @@ -536,231 +546,235 @@ 51153,51154,51155,51156,51157,51158,51159,51160,51161,51162,51163,51164,51165, 51166,51167,51168,51169,51170,51171,51172,51173,51174,51175,51176,51177,51178, 51179,51180,51181,51182,51183,51184,51185,51186,N,N,N,N,N,50915,50906,50907, -51409,37495,N,N,N,N,N,N,N,N,N,N,38623,N,N,N,N,N,N,N,N,N,N,N,35285,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37837,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39903,N,N, -N,N,N,N,64104,N,N,35290,36697,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35291,N, -N,36701,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35292,N,N,N,N,N,N,N,N,N,38647,N,N,N,N,N,N, -N,N,N,N,N,N,35546,N,N,N,N,35804,N,N,N,N,N,N,38875,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,40531,N,N,N,N,40362,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,39914,35438,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35784,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,35304,N,35306,N,N,N,N,N,35915,N,N,N,N,N,N,N,64368,N,N,N,N,N,N,N,N,N, -N,N,35309,N,N,38109,N,35310,N,N,N,N,40628,35539,N,N,N,N,N,N,N,N,N,N,N,37595,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38107,35321,N,N,N,N,N,N,N,N,64378,N,N,N, -35323,N,N,N,N,N,N,N,40700,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35324,N,35263,N,N, -N,35326,N,35302,N,N,40262,N,N,N,40430,N,N,N,41086,N,N,N,41064,N,N,N,N,39145,N, -35688,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36349,35774,40921,N,N,N,N,N,N,N, -35563,N,N,40919,35690,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40028,N,35761,N,N,N,N,N,N,N, -N,64350,N,N,N,N,N,N,N,N,N,40435,N,N,N,N,N,N,N,41168,N,N,N,64614,N,N,N,N,37609, -N,N,N,N,N,N,N,N,39660,36779,64072,N,N,N,N,36421,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,40047,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40670,N,N,N,N,N,N, -35311,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38633,N,N,N,N,N,N,N,N,N, -N,40635,N,N,N,N,38110,N,40632,N,N,N,38842,64357,N,N,N,38358,N,N,N,40123,N,N, -38874,N,N,N,N,36677,N,64381,37208,65124,N,38998,39757,N,N,N,N,N,N,N,N,N,N, -37723,38343,N,38887,N,N,N,N,N,N,37721,N,N,N,37365,38840,N,N,64930,64438,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,37626,37719,N,35750,N,N,N,N,64441,N,38832,N,N,64964,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,40097,N,N,N,N,N,37362,37369,N,36849,N,N,N,N,N,N,38725, -38995,N,N,65144,N,64449,37457,N,N,N,N,N,N,40365,N,N,N,N,N,64876,N,N,64107,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39874,N,N,N,N,N,N,N,N, -N,N,N,N,39547,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,35680,N,N,N,N,N,N,N,N,37707,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,39613,N,N,N,N,37303,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38324,N,N,N,N,N,65221, -N,N,40688,36196,N,N,N,N,N,N,N,N,N,37481,N,N,N,N,N,N,36199,N,N,N,N,N,N,N,N,N,N, -N,N,64490,N,N,N,N,N,N,N,N,64495,N,36200,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37867,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,64578,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,37222,N,N,N,N,N,N,N,N,64205,N,N,N,N,37853,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35788,36205,N,N,N,N,N, -N,N,N,N,N,N,36206,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38568,N,N,N,N,N,N,N,N,N, -N,64678,N,N,N,N,N,N,N,N,N,N,N,N,36207,N,N,N,N,N,N,N,N,N,N,N,N,N,36208,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64612,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,36960,N,N,N,N,N,N,N,N,36212,38851,N,N,N,N,N,N,N,35536,N,N,N, -N,N,N,37492,N,39870,N,N,N,N,N,40136,N,N,40122,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,36216,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,40633,N,N,N,N,N,38234,N,N,37300,N,N,N,N,N,N,35400,N,N,N,N,N,N,N,N,N,N,N, -36221,N,N,35453,N,N,35522,64842,N,36257,N,N,35537,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,64692,35655,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37796,40666,N,N,N,N,N,N,N,N,N, -35409,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36262,N,N,N,N,N,N,40645,N,N, -N,N,64708,N,N,N,N,41080,N,38069,N,N,N,N,N,N,N,64706,35435,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36267,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64232,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,36269,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64585,N,37825,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36975,N,36272,N,N,N,N,N,N,N,N, -38014,37114,N,N,N,N,N,N,N,N,N,N,38009,N,N,N,N,N,N,N,N,36274,N,N,N,N,N,N,N,N, -64750,N,N,N,N,N,N,N,N,N,N,N,N,N,39291,N,N,N,N,N,N,N,N,36276,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,36279,N,N,N,N,N,N,N,37299,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,36283,36282,N,N,N,N,N,N,N,N,36284,36932,N,N,N,64844,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,37860,N,N,37856,N,N,N,N,N,N,N,64851,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36291,N,39864,N,N,N,64496,N,37865,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,37878,N,N,N,N,N,36293,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36298, -N,N,N,N,N,36300,64861,37813,64865,N,N,N,40184,N,N,N,37458,N,N,41192,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40101,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35926,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36310,N,38848,N,N,N,41182,N,N,N,N, -38866,N,N,N,N,N,64165,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64931,N,N,N,36315,36527,N,N, -N,N,N,N,N,N,N,37301,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64841,N,N,N,N,N,N, -N,N,64977,N,N,N,N,N,N,N,N,N,N,36331,N,N,N,N,N,38854,N,64974,N,N,37116,N,N,N,N, -N,N,N,N,N,N,N,N,N,64601,N,N,38614,N,N,N,N,N,N,38853,36335,N,N,N,N,38871,N,N,N, -N,N,36336,N,N,N,N,N,N,N,38566,N,N,N,N,N,N,N,64447,N,N,N,N,36339,N,N,N,N,37961, -N,36341,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39026,N,N,N,N,N,N,N,36459,N,N,N, -N,N,N,64253,N,N,N,N,N,N,N,N,N,N,36688,N,N,N,N,N,N,40396,64613,N,35908,N,N, -39278,38049,N,N,N,N,N,36707,N,N,N,N,N,N,N,41178,N,N,N,N,N,N,N,N,N,N,N,37459, -65001,N,N,40373,N,N,N,N,N,N,N,39033,N,N,N,40285,N,N,N,N,36195,38505,40816,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64618,N,N,35527,N,N,N,N,35287,N,N,N,N,N,N,N,N, -N,N,N,N,65101,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40669,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65275,39100,64204,N,N,38320,N,N,N,37988,N,N,N,N, -N,N,37743,N,N,N,N,N,N,38073,N,N,38380,N,N,N,N,37358,N,N,39107,N,38390,N,N,N, -36861,39109,N,N,N,N,38758,65134,N,N,38877,36010,N,N,37586,N,N,38753,39115,N,N, -N,N,38384,N,38749,N,37347,N,N,N,N,39116,N,N,37993,39117,N,N,N,N,N,39118,N, -38396,N,N,38051,38498,N,N,N,65206,N,37987,N,N,N,N,N,N,N,39120,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39121,N,N,N,N,38005,64224,N,N,N,N,N, -N,N,N,N,38002,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39126,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35568,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39129,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,39131,N,N,N,N,39133,N,N,N,N,N,N,N,N,39080,N,N,N,N,N,N,N, -35437,N,N,N,N,N,N,N,N,N,N,N,35579,35502,64457,N,N,N,N,35933,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,39140,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,39142,N,N,N,N,N,N,N,N,N,N,N,39144,N,N,N,N,N,N,N,N,N,N,N,N,N,35405,N,N,N, -37463,N,N,N,N,N,N,N,N,N,N,38367,N,N,41132,N,N,N,N,39147,N,N,N,N,39148,N,36035, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39156,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35512, -N,N,N,40679,N,N,N,N,N,N,N,N,38076,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64721,N,N,N,N, -N,N,40134,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40574,39166, -65000,N,N,N,N,39232,N,N,N,N,38089,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,38099,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39238,N,N,N,N,37056, -N,38097,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38259,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37826,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39240, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39243,N,N,N,N,N,36437,N,N,N,N,39246,N,N,N,N, -N,N,N,N,N,N,N,36606,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36441,N,N,N,N,N,N,N, -N,N,38124,38127,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35936,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36724,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,39253,N,N,N,N,N,N,N,N,N,38212,N,N,N,N,N,N,N,N,N,N,N, -36043,N,N,N,39254,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39257,N,N,N,N,N,N,N,39259, -N,N,N,N,N,N,N,N,N,N,N,N,N,36036,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64069,N,N, -N,37047,N,N,38723,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38349,N,N,N,N,N,N,38857, -64848,36537,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38342,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39271,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35513,N,N,N,N,N,N,36348,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35446,N, -N,N,N,N,40273,N,N,N,N,N,N,N,N,N,N,N,N,N,39283,N,N,N,N,40271,39290,38244,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,39329,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39333,N,N,N, -N,N,N,N,39335,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +34880,34881,34882,34883,34884,34886,34889,34890,34893,34895,34896,34897,34898, +34900,34901,51321,51409,37495,N,N,N,N,N,N,N,N,N,N,38623,N,N,N,N,N,N,N,N,N, +36084,N,35285,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37837,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,39903,N,N,N,N,N,N,64104,N,N,35290,36697,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,35291,N,N,36701,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35292,N,N,N,N,N, +N,N,N,N,38647,N,N,N,N,N,N,N,N,N,N,N,N,35546,N,N,N,N,35804,N,N,N,N,N,N,38875,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40531,N,N,N,N,40362,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,39914,35438,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35784, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35304,N,35306,N,N,N,N,N,35915,N,N,N,N,N,N, +N,64368,N,N,N,N,N,N,N,N,N,N,N,35309,N,N,38109,N,35310,N,N,N,N,40628,35539,N,N, +N,N,N,N,N,N,N,N,N,37595,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38107,35321,N,N,N, +N,N,N,N,N,64378,N,N,N,35323,N,N,N,N,N,N,N,40700,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,35324,N,35263,N,N,N,35326,N,35302,N,N,40262,N,N,N,40430,N,N,N,41086,N,N,N, +41064,N,N,N,N,39145,N,35688,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36349,35774, +40921,N,N,N,N,N,N,N,35563,N,N,40919,35690,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40028,N, +35761,N,N,N,N,N,N,N,N,64350,N,34672,N,N,N,N,N,N,N,40435,N,N,N,N,N,N,N,41168,N, +N,N,64614,N,N,N,N,37609,N,N,N,N,N,N,N,N,39660,36779,64072,N,N,N,N,36421,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,40047,N,36188,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40670,N,N,N,N,N,N,35311,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,38633,N,N,N,N,N,N,N,N,N,N,40635,N,N,N,N,38110,N,40632,N,N,N,38842,64357,N, +N,N,38358,N,N,N,40123,N,N,38874,N,N,N,N,36677,N,64381,37208,65124,N,38998, +39757,N,N,N,N,N,N,N,N,N,N,37723,38343,N,38887,N,N,N,N,N,N,37721,N,N,N,37365, +38840,N,N,64930,64438,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37626,37719,N,35750,N,N,N,N, +64441,N,38832,N,N,64964,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40097,N,N,N,N,N,37362, +37369,N,36849,N,N,N,N,N,N,38725,38995,N,N,65144,N,64449,37457,N,N,N,N,N,N, +40365,N,N,N,N,N,64876,N,N,64107,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,39874,N,N,N,N,N,N,N,N,N,N,N,N,39547,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35680,N,N,N,N,N,N,N,N,37707, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39613,N,N,N,N,37303,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36171,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,38324,N,N,N,N,N,65221,N,N,40688,36196,N,N,N,N,N,N,N,N,N, +37481,N,N,N,N,N,N,36199,N,N,N,N,N,N,N,N,N,N,N,N,64490,N,N,N,N,N,N,N,N,64495,N, +36200,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,37867,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64578,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37222,N,N,N,N,N,N,N,N, +64205,N,N,N,N,37853,N,N,36178,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,35788,36205,N,N,N,N,N,N,N,N,N,N,N,36206,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,38568,N,N,N,N,N,N,N,N,N,N,64678,N,N,N,N,N,N,N,N,N,N,N, +N,36207,N,N,N,N,N,N,N,N,N,N,N,N,N,36208,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,64612,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36083,N,N,N,N,N,N,N,36960,N, +N,N,N,N,N,N,N,36212,38851,N,N,N,N,N,N,N,35536,N,N,N,N,N,N,37492,N,39870,N,N,N, +N,N,40136,N,N,40122,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36216,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40633,N,N,N,N,N,38234, +N,N,37300,N,N,N,N,N,N,35400,N,N,N,N,N,N,N,N,N,N,N,36221,N,N,35453,N,N,35522, +64842,N,36257,N,N,35537,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64692,35655,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37796,40666,N,N,N,N,N,N,N,N,N,35409,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,36262,N,N,N,N,N,N,40645,N,N,N,N,64708,N,N,N,N,41080,N, +38069,N,N,N,N,N,N,N,64706,35435,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36267,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64232,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36269,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64585,N,37825,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,36975,N,36272,N,N,N,N,N,N,N,N,38014,37114,N,N,N,N,N,N,N,N,N,N, +38009,N,N,N,N,N,N,N,N,36274,N,N,N,N,N,N,N,N,64750,N,N,N,N,N,N,N,N,N,N,N,N,N, +39291,N,N,N,N,N,N,N,N,36276,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36279,N, +N,N,N,N,N,N,37299,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36283,36282,N,N,N,N,N,N,N,N, +36284,36932,N,N,N,64844,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34635,37860,N, +N,37856,N,N,N,N,N,N,N,64851,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,36291,N,39864,N,N,N,64496,N,37865,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37878, +N,N,N,N,N,36293,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36298,N,N,N,N,N,36300,64861,37813, +64865,N,N,N,40184,N,N,N,37458,N,N,41192,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,40101,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35926,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,36310,N,38848,N,N,N,41182,N,N,N,N,38866,N,N,N,N,N,64165,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,64931,N,N,N,36315,36074,36527,N,N,N,N,N,N,N,N,N,37301,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64841,N,N,N,N,N,N,N,N,64977,N,N,N,N,N,N,N, +N,N,N,36331,N,N,N,N,N,38854,N,64974,N,N,37116,N,N,N,N,N,N,N,N,N,N,N,N,N,64601, +N,N,38614,N,N,N,N,N,N,38853,36335,N,N,N,N,38871,N,N,N,N,N,36336,N,N,N,N,N,N,N, +38566,N,N,N,N,N,N,N,64447,N,N,36063,N,36339,N,N,N,N,37961,N,36341,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,39026,N,N,N,N,N,N,N,36459,N,N,N,N,N,N,64253,N,N,N,N, +N,N,N,N,N,N,36688,N,N,N,N,N,N,40396,64613,N,35908,N,N,39278,38049,N,N,N,N,N, +36707,N,N,N,N,N,N,N,41178,N,N,N,N,N,N,N,N,N,N,N,37459,65001,N,N,40373,N,N,N,N, +N,N,N,39033,34666,N,N,40285,N,N,N,N,36195,38505,40816,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,64618,N,N,35527,N,N,N,N,35287,N,N,N,N,N,N,N,N,N,N,N,N,65101,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40669,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,65275,39100,64204,N,N,38320,N,N,N,37988,N,N,N,N,N,N,37743,N,N,N,N,N,N, +38073,N,N,38380,N,N,N,N,37358,N,N,39107,N,38390,N,N,N,36861,39109,N,N,N,N, +38758,65134,N,N,38877,36010,N,N,37586,N,N,38753,39115,N,N,N,N,38384,N,38749,N, +37347,N,N,N,N,39116,N,N,37993,39117,N,N,N,N,N,39118,N,38396,N,N,38051,38498,N, +N,N,65206,N,37987,36167,N,N,N,N,N,N,39120,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,39121,N,N,N,N,38005,64224,N,N,N,N,N,N,N,N,N,38002,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39126,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,35568,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39129,N,N,N,N,N,N,N,36186,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,39131,N,N,N,N,39133,N,N,N,N,N,N,N,N,39080,N,N,N,N,N,N,N,35437,N,N,N,N,N, +N,N,N,N,N,N,35579,35502,64457,N,N,N,N,35933,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,39140,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39142,N,N,N,N, +N,N,N,N,N,N,N,39144,N,N,N,N,N,N,N,N,N,N,N,N,N,35405,N,N,N,37463,N,N,N,N,N,N,N, +N,N,N,38367,N,N,41132,N,N,N,N,39147,N,N,N,N,39148,N,36035,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39156,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35512,N,N,N,40679,N,N,N,N, +N,N,N,N,38076,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64721,N,N,N,N,N,N,40134,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36170,N,40574,36164,39166,65000,N,N,N,N, +39232,N,N,N,N,38089,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,38099,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39238,N,N,N,N,37056,N,38097,N,N,N, +N,N,N,N,N,N,N,N,N,N,36174,N,N,38259,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37826,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39240,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,39243,N,N,N,N,N,36437,N,N,N,N,39246,N,N,N,N,N,N,N,N,N, +N,N,36606,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36191,N,36441,N,N,N,N,N,N,N,N,N, +38124,38127,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35936,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36724,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,39253,N,N,N,N,N,N,N,N,N,38212,N,N,N,N,N,N,N,N,N,N,N,36043, +N,N,N,39254,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39257,N,N,N,N,N,N,N,39259,N,N,N, +N,N,N,N,N,N,N,N,N,N,36036,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64069,N,N,N, +37047,N,N,38723,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38349,N,N,N,N,N,N,38857,64848, +36537,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38342,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39271,N,N, +36067,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35513,N,N, +N,N,N,N,36348,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35446,N,N,N,N,N, +40273,N,N,N,N,N,N,N,N,N,N,N,N,N,39283,N,N,34624,N,40271,39290,38244,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,39329,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39333,N,N,N,N,N, +N,N,39335,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36589,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39341,N,N,N,N,N,N,N,N, +N,N,N,36589,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39341,N,51326,N,N,N,N,N,N, N,N,N,N,N,N,N,37998,36720,N,64208,N,N,N,N,N,N,N,N,N,N,N,N,N,39347,N,N,N,N,N,N, -41043,N,N,N,N,N,N,N,N,38492,N,N,N,N,64890,N,N,N,N,N,N,N,N,38910,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,37565,N,38909,N,N,N,N,36708,N,N,N,N,64759,38242,38861,40548,N,N, -N,N,N,N,N,37452,36553,39356,N,N,N,N,40357,N,36692,N,N,N,N,N,N,N,N,N,N,36732,N, -N,N,N,N,N,36514,N,N,N,N,N,N,N,N,N,36730,N,N,N,N,N,N,38830,N,N,N,N,38600,N,N,N, -N,N,N,N,39363,N,37078,N,40126,N,N,N,36726,N,N,N,N,N,N,N,N,N,N,N,N,N,38000, -64331,N,N,64970,N,N,N,N,N,N,36551,N,N,N,N,N,41209,N,N,N,N,N,N,N,36777,N,N,N,N, -N,N,N,N,N,N,N,N,39367,N,N,N,N,N,N,N,N,N,N,N,N,N,37079,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40671,39374,N,N,N,N,N,N,N,N,36794,N,N,N,N,N,36843,N,39375,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36802,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37577,N,N,N,N,N,38876,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38323,40057,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38322, -36827,N,N,N,N,39907,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40570,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39918,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39390,N,N,N,N,N,N,N,N,N,N,N,N, -N,64250,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40677,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,35410,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39393,N,N,N,N,N,N,35431,35765,N,N,N,N,N,N,N,N,N,N,35500,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39401,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64458,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38878,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38353,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,39413,64586,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,39849,N,N,N,N,N,N,N,N,N,N,N,N,64476,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65110,N, -N,N,N,N,40612,N,N,N,N,N,N,40265,38363,N,N,N,N,N,N,N,N,N,N,35269,N,N,N,N,N,N,N, -N,N,N,N,N,39416,N,N,N,N,N,N,38500,N,N,N,N,36949,N,N,38612,N,N,N,N,N,N,N,38780, -N,N,N,N,N,N,38477,N,38881,N,N,N,N,N,N,39496,N,N,N,N,N,N,N,N,N,N,N,39497,N, -65149,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37034,N,N,N,N,39504,N,N,N,N,N,N,N, -37703,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36568,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,37065,N,N,N,N,N,39509,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37052,N,N,N,N,N,39512,N,35768,37077,N,N,N,N,N,N,N,N,N,N,N,N,N,38465,N,N,N,N,N, -N,39514,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39516,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,38850,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35515,N,N, -N,39850,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37109,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,39520,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37189,35928,N,N,N,N,N,N,N,N,39523,N,N,N,N,N,N,35913,N,N,N,N,N,N,N,N,N,N,N, -35766,N,N,N,N,N,N,N,N,N,N,64719,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38507,39534,N, -37199,N,N,N,N,N,N,N,N,38726,N,N,41190,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37591,N, -38517,N,N,37844,N,N,37307,38521,N,N,N,N,N,39536,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38520,37325,N,40010,41071,N,N,41066,N,N,N,N,N, -N,37215,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40869,N,N,35258,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,40653,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39545,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,40398,N,N,N,36050,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40307,N,N,N,N,N,N,N,N,N,38585,N,38588,N,N,N,N,N,N,40145,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35255,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,40686,N,N,N,N,N,N,N,N,N,N,N,64323,40649,N,N,N,N,N,N,64467,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37294,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,40312,N,N,N,N,N,N,N,N,N,N,40315,40627,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,40626,N,40406,N,N,N,N,39247,N,N,35278,N,N,N,35776,N,40900,N,35796, -N,N,35954,N,N,N,N,N,N,50879,35833,N,N,N,N,N,35142,N,50880,N,N,N,N,N,N,N,N,N, -64229,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,51323,35782,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40023,N,N,N,N,N,N,N,N,N,N,N,N,N,39675,N,N,N,N,N,N,N,35280,35279,N,N,N,50881,N, -35281,N,35298,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37502,N,40378,N,N,N,N,N,50882,N,N, -35951,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64504,N,N,N,35783,37483,N,N,35282, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,40911,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,40361,35283,N,N,39394,N,N,N,N,N,N,N,N,N,37479,37540,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,35955,N,N,35150,N,N,N,N,N,N,N,N,N,N,N,N,N,35151,37496,N, -N,N,N,N,N,N,N,37302,N,N,N,N,35284,N,40914,N,N,N,N,N,N,N,N,37543,N,N,38306,N,N, -N,N,N,37486,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,38634,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37487,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37539,N,N,N,N,N,35152,N,N,64087,N,N,N,N, -39014,N,N,N,N,N,N,N,N,N,N,N,N,35286,N,N,N,N,N,N,N,N,N,N,39090,N,N,N,37547,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38622,37548,N,N,N,N,N,N,N,N,N,N, -35952,N,40814,N,N,N,N,N,N,36594,N,N,N,40812,35288,N,N,N,N,64089,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37544,N,N,N,N,N, -37219,N,N,N,N,N,N,35904,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40819,N,37549,N,N,N,N,N,N,N,N,N,N,N,N,N,39913,N,N,N,N,N,37545,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,37546,N,N,N,N,N,N,35289,N,N,N,N,N,N,N,64854,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40872,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,35953,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37537,N,N,37091,N,N,N,N,N,N,N,N,41126, -N,N,N,N,N,38059,N,64626,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38852,N,N,N,N,N,N, -N,37550,64103,N,N,N,N,N,N,N,N,N,N,N,37538,64105,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,37480,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35153,N,N,N,N,N,N,N,N,N,64111,N,N,N,N,N, -N,N,N,N,64113,N,N,N,N,N,N,N,N,N,35154,N,N,N,N,37978,N,N,N,N,N,N,N,N,50883,N,N, -N,35293,N,51362,N,N,N,N,N,N,N,N,N,N,N,N,N,50884,N,N,N,40530,N,35155,N,N,N,N,N, -N,N,N,N,N,40533,37562,N,N,50885,N,N,35931,N,N,N,64125,64168,39528,64071,N,N, -64126,N,N,N,N,N,N,N,N,N,N,37563,N,N,N,64950,N,64162,N,N,N,N,N,64163,N,64164, -39860,64166,N,N,N,N,N,N,N,35295,N,N,N,64987,N,N,64169,N,35156,N,N,N,N,N,N,N,N, -64171,N,N,N,N,N,N,64634,N,N,N,N,N,N,N,35296,N,40783,51325,N,N,35297,N,N,N,N,N, -64176,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40909,41191,N,N,N,N,N,64177,35238, -N,N,N,N,N,N,N,N,N,N,N,N,40698,N,N,N,N,N,N,N,64178,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,64180,N,37572,N,N,N,N,N,N,40815,N,N,N,N,N,N,N,35760,N, -N,N,N,N,N,N,N,N,N,40876,N,N,N,N,N,35299,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,39891,35300,N,N,N,64181,N,N,N,N,N,40917,N,N,N,N,N,N,35157,N,N,37573,N,N,N, -35158,N,N,N,N,N,N,N,N,N,N,N,N,64179,N,N,N,64182,N,N,N,N,N,N,N,N,N,N,N,64183,N, -N,N,N,N,N,40668,N,N,N,64452,40817,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64186,37575,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,50886,39500,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35944,N,N,35301,N,N,N,N,40829,N,N, -N,N,N,41129,64196,N,N,N,N,50887,N,N,35159,N,N,N,N,N,N,64170,N,N,N,N,N,N,N,N,N, -N,N,35160,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35811,N,35681,N,N,N,N,39665,N,N,40631,N, +41043,N,N,N,N,N,36190,N,N,38492,N,N,36064,N,64890,N,N,N,N,N,N,N,N,38910,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37565,36189,38909,N,N,N,N,36708,N,N,N,N,64759,38242, +38861,40548,N,N,N,N,N,N,N,37452,36553,39356,N,N,N,N,40357,N,36692,N,N,N,N,N,N, +N,N,N,N,36732,N,N,N,N,36181,N,36514,N,N,N,N,N,N,N,N,N,36730,N,N,N,N,N,N,38830, +N,N,N,N,38600,N,N,36068,N,N,N,N,39363,N,37078,N,40126,N,N,N,36726,N,N,N,N,N,N, +N,N,N,N,N,N,N,38000,64331,N,N,64970,N,N,36079,N,N,N,36551,N,N,N,N,36180,41209, +N,N,N,N,N,N,N,36777,N,N,36177,N,N,N,N,N,N,N,N,N,39367,34628,N,N,N,N,N,N,N,N,N, +N,N,N,37079,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +34627,N,N,N,N,N,N,N,N,N,N,N,N,34631,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34648,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40671, +36185,34626,N,N,39374,N,N,N,N,N,N,N,N,36794,N,N,N,N,N,36843,N,39375,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36802,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37577,N,N,N,N,N,38876,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34653,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,36165,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38323,40057,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38322,N, +36172,36827,N,N,N,N,39907,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,34636,N,N,N,N,N,N,N,N,N,N,N,N,N,34637,N,N,N,N,N,N,N,N,N,40570,34647,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,39918,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39390,N,N,N, +N,N,N,N,N,N,N,N,N,N,64250,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35410,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,39393,N,N,N,N,N,N,35431,35765,N,N,N,N,N,N,N,N,N,N,35500,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39401,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,64458,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38878,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38353,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,39413,64586,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,39849,N,N,N,N,N,N,N,N,N,N,N,N,64476,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,65110,N,N,N,N,N,40612,N,N,N,N,N,N,40265,38363,N,N,N,N,N,N,N,N,N,N,35269, +N,N,N,N,N,N,N,N,N,N,N,N,39416,N,N,N,N,N,N,38500,N,N,N,N,36949,N,N,38612,N,N,N, +N,N,N,N,38780,N,N,N,N,N,N,38477,N,38881,N,N,N,N,N,N,39496,N,N,N,N,N,N,N,N,N,N, +N,39497,N,65149,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37034,N,N,N,N,39504,N,N,N,N, +N,N,N,37703,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36568,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37065,N,N,N,N,N,39509,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,37052,N,N,N,N,N,39512,N,35768,37077,N,N,N,N,N,N,N,N,N,N,N,N,N,38465,N,N, +N,N,N,N,39514,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39516,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,38850,N,N,N,N,N,N,N,N,N,N,N,N,N,34652,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35515,N,N,N,39850,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37109,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39520,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,37189,35928,N,N,N,N,N,N,N,N,39523,N,N,N,N,N,N,35913,N,N,N,N,N,N,N,N, +N,N,N,35766,N,N,N,N,N,N,N,N,N,N,64719,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38507, +39534,N,37199,N,N,N,N,N,N,N,N,38726,N,N,41190,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +37591,N,38517,N,N,37844,N,N,37307,38521,N,N,N,N,N,39536,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38520,37325,N,40010,41071,N,N,41066,N, +N,N,N,N,N,37215,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,34625,N,N,N,N,N,N,N,N,40869,N,N,35258,N,34639,N,N,N,N,N,N,34638,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,34645,N,N,N,40653,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39545,N,N,N,N,N,N,N,N,N,36082,N,N,N,36183,N,40398,N,N,N,36050,N,N,N,34649,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40307,N,N,N,N,N,N,N,N, +N,38585,N,38588,N,N,N,N,N,N,40145,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35255,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40686,34633,N,N,N,N,N,N,N,N,N,N, +64323,34651,N,40649,N,N,N,N,N,N,64467,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37294,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,36184,34630,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36182,N,N,N,N,N,N,N, +40312,N,N,N,N,N,N,N,N,N,N,40315,40627,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,40626,N,40406,N,N,N,N,39247,N,N,35278,N,N,N,35776,N,40900,N,35796,N,N,35954, +N,N,N,N,N,N,50879,35833,N,N,N,N,N,35142,N,50880,N,N,N,N,N,N,N,N,N,64229,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,51323,35782,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40023,N,N,N, +N,N,N,N,N,N,N,N,N,N,39675,N,N,N,N,N,N,N,35280,35279,N,N,N,50881,N,35281,N, +35298,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37502,N,40378,N,N,N,N,N,50882,N,N,35951,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64504,N,N,N,35783,37483,N,N,35282,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,40911,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40361,35283,N,N,39394,N,N,N,N,N,N,N,N,N,37479,37540,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,35955,N,N,35150,N,N,N,N,N,N,N,N,N,N,N,N,N,35151,37496,N,N,N,N,N,N, +N,N,37302,N,N,N,N,35284,N,40914,N,N,N,N,N,N,N,N,37543,N,N,38306,N,N,N,N,N, +37486,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,38634,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37487,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37539,N,N,N,N,N,35152,N,N,64087,N,N,N,N,39014,N, +N,N,36088,N,N,N,N,N,N,N,N,35286,N,N,N,N,N,N,N,N,N,N,39090,N,N,N,37547,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38622,37548,N,N,N,N,N,N,N,N,N,N,35952,N, +40814,N,N,N,N,N,N,36594,N,N,N,40812,35288,N,N,N,N,64089,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37544,N,N,N,N,N,37219,N,N, +N,N,N,N,35904,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40819,N, +37549,N,N,N,N,N,N,N,N,N,N,N,N,N,39913,N,N,N,N,N,37545,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,37546,N,N,N,N,N,N,35289,N,N,N,N,N,N,N,64854,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,40872,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35953, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37537,N,N,37091,N,N,N,N,N,N,N,N,41126,N,N,N,N, +N,38059,N,64626,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38852,N,N,N,N,N,N,N,37550, +64103,N,N,N,N,N,N,N,N,N,N,N,37538,64105,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,37480,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35153,N,N,N,N,N,N,N,N,N,64111,N,N,N,N,N,N,N,N,N, +64113,N,N,N,N,N,N,N,N,N,35154,N,N,N,N,37978,N,N,N,N,N,N,N,N,50883,N,N,N,35293, +N,51362,N,N,N,N,N,N,N,N,N,N,N,N,N,50884,N,N,N,40530,N,35155,N,N,N,N,N,N,N,N,N, +N,40533,37562,N,N,50885,N,N,35931,N,N,N,64125,64168,39528,64071,N,N,64126,N,N, +N,N,N,N,N,N,N,N,37563,N,N,N,64950,N,64162,N,N,N,N,N,64163,N,64164,39860,64166, +N,N,N,N,N,N,N,35295,N,N,N,64987,N,N,64169,N,35156,N,N,N,N,N,N,N,N,64171,N,N,N, +N,N,N,64634,N,N,N,N,N,N,N,35296,N,40783,51325,N,N,35297,N,N,N,N,N,64176,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40909,41191,N,N,N,N,N,64177,35238,N,N,N,N,N,N, +N,N,N,N,N,N,40698,N,N,N,N,N,N,N,64178,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,64180,N,37572,N,N,N,N,N,N,40815,N,N,N,N,N,N,N,35760,N,N,N,N,N,N,N, +N,N,N,40876,N,N,N,N,N,35299,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39891, +35300,N,N,N,64181,N,N,N,N,N,40917,N,N,N,N,N,N,35157,N,N,37573,N,N,N,35158,N,N, +N,N,N,N,N,N,N,N,N,N,64179,N,N,N,64182,N,N,N,N,N,N,N,N,N,N,N,64183,N,N,N,N,N,N, +40668,N,N,N,64452,40817,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64186,37575,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,50886,39500,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35944,N,N,35301,N,N,N,N,40829,N,N,N,N,N, +41129,64196,N,N,N,N,50887,N,N,35159,N,N,N,N,N,N,64170,N,N,N,N,N,N,N,N,N,N,N, +35160,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35811,N,35681,N,N,N,N,39665,N,N,40631,N, 50888,N,N,N,64209,N,N,N,N,N,N,64210,N,N,N,N,N,N,N,N,40634,64212,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,64217,N,N,N,N,N,N,N,N,N,N,N,N,64219,N,40160,N,N,N, 64503,N,64506,35303,41082,64220,N,N,64221,N,35305,N,N,N,N,N,50889,N,N,N,N,N,N, @@ -790,17 +804,17 @@ N,N,N,N,N,N,37472,N,N,N,N,N,N,N,N,N,N,N,37470,37313,N,35525,N,N,38819,N,N,N,N, N,N,N,N,N,N,35692,N,36222,N,N,N,N,N,N,N,40020,N,N,N,N,N,40381,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,40133,N,N,N,N,N,N,N,N,N,N,N,35163,N,N,N,N,N,N,N,N, -N,N,64348,N,64347,N,64343,N,N,N,N,N,N,N,N,N,N,N,39111,64346,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,40174,N,N,N,N,N,N,N,37602,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,38055,N,N,N,N,N,N,N,N,N,N,36044,N,39892,N,N,64356,64374,N,N,64352,N, -N,N,N,N,N,N,N,N,N,N,N,N,39397,N,N,39618,N,N,N,37371,N,N,N,41075,N,N,N,N,N,N,N, -40818,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40908,N,N,N,39077,37608,N,N,N,N,N,N, -N,N,39868,N,38643,N,N,37607,N,N,64615,N,N,N,N,N,N,N,N,N,N,N,35709,N,N,N,N, -39924,N,N,N,N,N,40695,N,N,40641,N,N,N,N,N,N,N,N,N,39279,N,N,N,N,N,N,38641,N,N, -36417,N,N,N,N,N,38218,N,N,N,38886,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38645,N,N,N,N,N, -37606,40770,N,N,N,N,N,N,N,64359,N,N,N,N,N,N,N,N,39337,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,64230,64361,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38885,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,38525,N,N,N,64364,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39330,N,N,N,N,N, +N,N,64348,N,64347,N,64343,N,N,N,N,N,N,N,N,N,34661,N,39111,64346,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,40174,N,N,N,N,N,N,N,37602,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,38055,N,N,N,N,N,N,N,N,N,N,36044,N,39892,N,N,64356,64374,N,N, +64352,N,N,N,N,N,N,N,N,N,N,N,N,N,39397,N,N,39618,N,N,N,37371,N,N,N,41075,N,N,N, +N,N,N,N,40818,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40908,N,N,N,39077,37608,N,N, +N,N,N,N,N,N,39868,N,38643,N,N,37607,N,N,64615,N,N,N,N,N,N,N,N,N,N,N,35709,N,N, +N,N,39924,N,N,N,N,N,40695,N,N,40641,N,N,N,N,N,N,N,N,N,39279,N,N,N,N,N,N,38641, +N,N,36417,N,N,N,N,N,38218,N,N,N,38886,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38645,N,N,N, +N,N,37606,40770,N,N,N,N,N,N,N,64359,N,N,N,N,N,N,N,N,39337,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,64230,64361,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38885,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,38525,N,N,N,64364,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39330,N,N,N,N,N, 39611,N,N,N,39525,N,N,37966,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64366,N,N, 39391,N,N,N,N,N,N,N,N,N,39139,N,N,37460,N,N,N,N,N,38523,35503,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35959,N,N,N,N,N,N,35759,40637,N,N, @@ -808,405 +822,407 @@ N,63961,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37610,N,N,N,N,35960,N,N,N,N,N,N,N,N,N,N, N,64370,N,N,N,64369,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35164,N,39152,38642,N,N,N,N, N,N,N,64372,35777,N,35165,35294,N,35166,N,N,50890,N,N,N,N,N,N,65090,N,N,N,N,N, -N,N,N,N,N,N,N,N,64379,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35167,N,35168,N,N,N, +N,N,N,N,N,N,34664,N,64379,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35167,N,35168,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,39885,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40403,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,38988,N,N,N,N,N,N,N,N,N,N,38738,N,N,N,N,N,38339,N,N,N,N,39862,N, -N,N,N,N,N,N,N,N,N,N,N,39609,N,N,N,38835,N,N,N,N,N,N,40820,37617,N,N,N,N,N,N,N, -N,N,N,N,38879,N,N,N,N,64422,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64427,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,39031,N,N,N,38996,38341,N,N,N,N,N,N,N,40277,64434,38270,N, -N,N,N,N,N,N,N,38722,N,38118,N,N,N,N,37621,N,N,N,N,N,N,N,36037,N,N,N,N,N,N, -37629,N,N,64418,N,N,40017,N,N,38121,39004,37616,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,37964,N,N,N,N,N,N,N,37227,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35704,N,N,N,N,38114,N, -N,N,N,N,N,N,38991,N,64437,N,N,N,N,37489,N,N,37733,N,N,39003,N,N,38992,N,N,N,N, -N,N,N,38844,N,N,N,N,37619,N,N,37696,38989,N,N,N,38258,N,65007,N,N,N,N,N,N,N,N, -64961,N,N,N,N,64442,N,N,37611,N,N,N,N,N,N,64627,38839,N,N,N,N,N,N,N,N,N,64436, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37031,N,N,N,N,N,N,N,N,N,N,38721, -37620,N,N,N,64444,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38263,N,N,N,N,N,N,N,N,N,N,N, -40674,N,36728,N,N,N,N,N,N,N,63964,N,N,N,38514,40629,N,N,N,38475,N,N,N,36012,N, -N,N,N,N,N,N,N,N,41210,N,N,N,N,N,N,N,N,N,N,N,38261,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,37082,N,N,37735,N,65188,N,N,N,37087,N,N,N,N,37716,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35169,N,35764,N,N,N,N,40384,N,N,N,N,N,N,36424,N, -64453,N,N,N,N,N,64455,N,N,N,50891,N,64121,N,N,N,N,N,N,N,N,N,N,N,N,N,40551,N,N, -N,N,N,36057,N,N,N,N,N,N,64466,35170,35171,N,N,N,N,N,N,N,N,N,N,64637,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40811,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64460,N,65198,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64465,N,N, -N,N,N,N,N,N,N,N,N,64373,64468,N,N,N,N,N,N,N,N,N,N,N,N,N,64470,64472,N,N,N,N,N, -N,N,35677,N,37708,N,39650,N,N,35785,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64475,40905,N,N,N,N,N,N,N,N,40772,N,N,N,N,N,N, -N,N,N,N,39149,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,64477,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36338,35172,N,65010,N, -37709,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64487,N,N,N,N,N,N, -41202,39016,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40792,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,36211,N,N,N,64478,N,N,N,N,N,64479,N,N,N,N,N,35912,64483,N,N,N,N,36264,N, -N,64484,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40053,N,N,39032,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,36192,N,N,N,N,N,N,N,64485,N,36193,N,N,N,N,N,N,N,N,N,N,N,N,N,36194, -41121,N,N,N,40000,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39085,N,N,N,40682,N, -N,N,N,N,N,36052,N,N,N,N,N,N,N,N,N,40171,N,N,N,N,N,64480,N,N,40785,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36197,N,N,N,N,N,N,40177,N,N,N,N,N,N,N,N,N,N, -64600,N,N,36198,N,N,N,N,N,N,N,38484,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64488,N,N,N,50892,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40910, -64508,N,39652,N,N,N,N,N,N,40821,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,64497,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36201,N,N,N,N,N,37711,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37710,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,64500,N,N,N,N,50894,N,N,N,64451,N,N,35173,N,N,N,N,N,N,N,N, -N,N,N,35962,N,N,N,N,N,N,35963,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,36202,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37715,N,N,40443,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64509,N,N,N, -36953,64576,N,64577,64579,37729,64582,37730,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36203,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64588,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,38328,N,N,50896,35786,N,N,N,N,N,N,N,N,N,N,39034,N,N,N,N, -50897,N,64593,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64596,N,N,N,N,N,N,N,N,64175,N,N,N,N, -N,N,N,36204,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64097,N,N,64599,N,N,N,N,N,N,N,N,N,39792,N,N,N,N,N,N,N,N,41041,N,N,N,N,N,N,N, -35964,N,35787,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37742,N,N,N,64725, -64681,N,N,N,N,N,N,N,N,N,N,N,N,N,64609,N,N,N,N,N,N,N,N,N,35174,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,64203,N,N,N,N,N,N,N,63962,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37754,N,41184,N,N,N,N,N,N,37739,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64619,N,N,N,N,N,41180,N,N,37992,N, -N,N,N,N,N,N,N,N,N,N,64621,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,36209,N,N,N,N,N,N,64868,N,N,N,N,39354,N,N,N,39632,39521, -41189,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41051,38572,N,N,N,N,38720,N,N,N,N, -N,N,N,N,N,N,N,N,40689,N,N,N,N,N,N,N,N,35917,N,N,N,N,N,N,N,N,N,N,N,N,N,40830,N, -N,N,N,N,N,N,N,N,N,N,N,36210,N,N,N,N,64630,N,N,N,N,N,N,N,N,N,N,N,N,N,38569,N,N, -N,N,N,N,N,N,41070,N,N,64682,N,N,N,64461,N,N,N,64628,N,N,N,N,N,N,N,N,N,N,41076, -N,N,N,N,N,N,N,N,N,N,N,N,N,41073,N,N,N,64633,N,N,N,N,N,64636,N,N,N,N,N,N,N,N,N, -N,N,N,N,40016,N,N,37753,37752,N,N,41181,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,36213,N,36214,N,N,N,N,N,N,37748,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36215,64677,N,N,64674,N,N,N,N,N,N,37059,N,N,N,N,N,N,N,41081,36217,N,N,N,N,N,N, -N,N,N,N,35836,N,41078,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35789,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40794,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40948,N,N,40890,N,N,N,N,N,N,N,N,N,N,36218,N,N,N,N,N,N,N,N,N, -N,N,N,40517,N,N,N,N,N,N,37808,N,41077,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,39750,N,64686,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64688,N,N,N,N,N,N, -N,N,N,64081,N,N,N,N,N,36219,36220,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40662,N,N,37804,N,N,N,40795,N,37801,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41084,N,N,N,N,N,N,N,64690,N,N,N, -N,N,N,N,N,N,N,N,N,35521,N,N,N,N,N,40884,N,N,N,N,N,N,N,N,N,N,N,64684,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,40524,N,N,N,N,N,N,N,36805,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37805,N,N,N,N,N,N,N, -N,N,N,N,N,40387,N,N,N,36258,N,N,N,40266,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64694,N,N,36259,40523,N,40525,36260,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35581,N,N,N,N,N,64693,N,64707,37810, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36261,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37793,N,N,N,N,N,N,N,N,N,N,35526,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,35419,N,N,N,35149,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,65236,N,N,N,N,35448,N,37803,N,N,N,N,N,N,N,N,N,36263,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,40773,N,N,N,N,N,N,N,N,N,35414,N,N,N,64703,N,N,N, -64704,N,36582,N,N,35492,35139,N,N,N,N,N,N,37875,N,N,N,N,N,N,N,N,N,N,N,N,64683, -40610,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40391,N,N,N,50898,35790,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64709,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64715,N, -N,N,N,N,N,N,N,N,N,N,37811,N,64714,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,64713,36268,N,64454,35175,N,35966,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64717,N,N,N,N,N,N,N,N,40179,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,64720,N,N,38331,N,N,N,N,N,N,N,N,N,N,N,64723,N,N, -64724,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36270,64727,N,N,N, -N,N,37851,N,N,N,N,65123,N,N,N,N,N,N,N,N,N,N,N,N,37845,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,64730,N,N,N,39793,N,N,64733,N,N,N,N,N,N,N,36271,N,N,N,64242,N,N, -N,N,N,N,N,N,N,N,N,37848,N,N,N,64735,N,N,N,37843,N,N,N,N,N,N,N,64737,N,N,N,N,N, -N,N,N,N,36470,N,N,N,N,N,N,N,64610,N,N,N,N,N,N,N,N,37841,N,N,N,36273,N,N,N,N,N, -N,N,39001,N,N,N,N,N,N,N,N,N,64338,N,N,N,N,N,N,N,N,64339,N,N,N,N,N,64333,N,N, -40127,N,N,N,N,N,N,N,N,39794,N,N,N,N,N,N,N,N,N,N,N,N,N,64336,37822,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40433,64747,N,N,N,N,N, -N,N,N,N,41147,N,39806,N,N,N,N,N,N,N,36275,N,N,35922,N,N,N,N,39656,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,39885,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40403,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,38988,N,N,N,N,N,N,N,N,N,N,38738,N,N,N,N,N,38339,N,N,N,N, +39862,N,N,N,N,N,N,N,N,N,N,N,N,39609,N,N,N,38835,N,N,N,N,N,N,40820,37617,N,N,N, +N,N,N,36090,N,N,N,N,38879,N,N,N,N,64422,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64427,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39031,N,N,N,38996,38341,N,N,N,N,N,N,N,40277, +64434,38270,N,N,N,N,N,N,N,N,38722,N,38118,N,N,N,N,37621,N,N,N,N,N,N,N,36037,N, +N,N,N,N,N,37629,N,N,64418,N,N,40017,N,N,38121,39004,37616,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,37964,N,N,N,N,N,N,N,37227,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35704,N,N,N, +N,38114,N,N,N,N,N,N,N,38991,N,64437,N,N,N,N,37489,N,N,37733,N,N,39003,N,N, +38992,N,N,N,N,N,N,N,38844,N,N,N,N,37619,N,N,37696,38989,N,N,N,38258,N,65007,N, +N,N,N,N,N,N,N,64961,N,N,N,N,64442,N,N,37611,N,N,N,N,N,N,64627,38839,N,N,34671, +N,N,N,N,N,N,64436,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37031,N,N,N,N, +N,N,N,N,N,N,38721,37620,N,34674,N,64444,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38263, +N,N,N,N,N,N,N,N,N,N,N,40674,N,36728,N,N,N,N,N,N,N,63964,N,N,N,38514,40629,N,N, +N,38475,N,N,N,36012,N,N,N,N,N,N,N,N,N,41210,N,N,N,N,N,N,N,N,N,N,N,38261,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37082,N,N,37735,N,65188,N,N,N,37087,N,N,N, +N,37716,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35169,N,35764,N,N,N,N, +40384,N,N,N,N,N,N,36424,N,64453,N,N,N,N,N,64455,N,N,N,50891,N,64121,N,N,N,N,N, +N,N,N,N,N,N,N,N,40551,N,N,N,N,N,36057,N,N,N,N,N,N,64466,35170,35171,N,N,N,N,N, +N,N,N,N,N,64637,N,N,N,N,N,N,N,N,N,N,N,N,34675,N,N,N,N,N,N,N,N,N,N,N,40811,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64460,N,65198,N,N,N,34669,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,64465,N,N,N,N,N,N,N,N,N,N,N,64373,64468,N,N,N,N,N,N,N, +N,N,N,N,N,N,64470,64472,N,N,N,N,N,N,N,35677,N,37708,N,39650,N,N,35785,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64475,40905, +N,N,N,N,N,N,N,N,40772,N,N,N,N,N,N,N,N,N,N,39149,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,36073,N,N,N,N,N,N,N,N,N,N,N,N,64477,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,36338,35172,N,65010,N,37709,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,64487,N,N,N,N,N,N,41202,39016,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40792,N,N,N,36070,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36211,N,N,N,64478,N,N,N,N,N, +64479,N,N,N,N,N,35912,N,N,N,N,N,N,34676,64483,N,N,N,N,36264,N,N,64484,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40053,N,N,39032,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36192,N,N,N,N,N,N,N,64485,N,36193,N,N,N,N,N,N,N,N,N,N,N,N,N,36194,41121,N,N,N, +40000,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39085,N,N,N,40682,N,N,N,36076,N, +N,36052,N,N,N,N,N,N,N,N,N,40171,N,N,N,N,N,64480,N,N,40785,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,36197,N,N,N,N,N,N,40177,N,N,N,N,N,N,N,N,N,N,64600,N,N, +36198,N,N,N,N,N,N,N,38484,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64488,N,N, +N,50892,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40910,64508,N,39652, +N,N,N,N,N,N,40821,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64497, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36201,N,N,N,N,N,37711,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,37710,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,64500,N,N,N,N,50894,N,N,N,64451,N,N,35173,N,N,N,N,N,N,N,N,N,N,N,35962,N, +N,N,N,N,N,35963,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,36202,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37715,N,N,40443,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64509,N,N,N,36953,64576,N, +64577,64579,37729,64582,37730,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36203,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64588,36094,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,38328,N,N,50896,35786,N,N,N,N,N,N,N,N,N,N,39034,N,N,N,N,50897,N, +64593,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64596,N,N,N,N,N,N,N,N,64175,N,N,N,N,N,N,N, +36204,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64097,N, +N,64599,N,N,N,N,N,N,N,N,N,39792,N,N,N,N,N,N,N,N,41041,N,N,N,N,N,N,N,35964,N, +35787,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37742,N,N,N,64725,64681,N,N, +N,N,N,N,N,N,N,N,N,N,N,64609,N,N,N,N,N,N,N,N,N,35174,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,64203,N,N,N,N,N,N,N,63962,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,37754,N,41184,N,N,N,N,N,N,37739,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64619,N,N,N,N,N,41180,N,N,37992,N,N,N,N,N,N, +N,N,N,N,N,64621,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,36209,N,N,N,N,N,N,64868,N,N,N,N,39354,N,N,N,39632,39521,41189,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41051,38572,N,N,N,N,38720,N,N,N,N,N,N,N,N,N,N,N, +N,40689,N,N,N,N,N,N,N,N,35917,N,N,N,N,N,N,N,N,N,N,N,N,N,40830,N,N,N,N,N,N,N,N, +N,N,N,N,36210,N,N,N,N,64630,N,N,N,N,N,N,N,N,N,N,N,N,N,38569,N,N,N,N,N,N,N,N, +41070,N,N,64682,N,N,N,64461,N,N,N,64628,N,N,N,N,N,N,N,N,N,N,41076,N,N,N,N,N,N, +N,N,N,N,N,N,N,41073,N,N,N,64633,N,N,N,N,N,64636,N,N,N,N,N,N,N,N,N,N,N,N,N, +40016,N,N,37753,37752,N,N,41181,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,36213,N,36214,N,N,N,N,N,N,37748,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36215,64677, +N,N,64674,N,N,N,N,N,N,37059,N,N,N,N,N,N,N,41081,36217,N,N,N,N,N,N,N,N,N,N, +35836,N,41078,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35789,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40794,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40948,N,N,40890,N,N,N,N,N,N,N,N,N,N,36218,N,N,N,N,N,N,N,N,N,N,N,N, +40517,N,N,N,N,N,N,37808,N,41077,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39750,N,64686,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64688,N,N,N,N,N,N,N,N,N, +64081,N,N,N,N,N,36219,36220,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40662,N, +N,37804,N,N,N,40795,N,37801,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41084,N,N,N,N,N,N,N,64690,N,N,N,N,N,N,N, +N,N,N,N,N,35521,N,N,N,N,N,40884,N,N,N,N,N,N,N,N,N,N,N,64684,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40524, +N,N,N,N,N,N,N,36805,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37805,N,N,N,N,N,N,N,N,N,N,N, +N,40387,N,N,N,36258,N,N,N,40266,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64694,N,N, +36259,40523,N,40525,36260,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35581,N,N,N,N,N,64693,N,64707,37810,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36261,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37793,N,N,N,N,N,N,N,N,N,N,35526,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,35419,N,N,N,35149,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,65236,N,N,N,N,35448,N,37803,N,N,N,N,N,N,N,N,N,36263,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,40773,N,N,N,N,N,N,N,N,N,35414,N,N,N,64703,N,N,N,64704,N,36582, +N,N,35492,35139,N,N,N,N,N,N,37875,N,N,N,N,N,N,N,N,N,N,N,N,64683,40610,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,40391,N,N,N,50898,35790,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,64709,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64715,N,N,N,N,N,N,N,N, +N,N,N,37811,N,64714,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64713,36268, +N,64454,35175,N,35966,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,64717,N,N,N,N,N,N,N,N,40179,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,64720,N,N,38331,N,N,N,N,N,N,N,N,N,N,N,64723,N,N,64724,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36270,64727,N,N,N,N,N,37851,N,N,N,N, +65123,N,N,N,N,N,N,N,N,N,N,N,N,37845,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64730,N,N,N,39793,N,N,64733,N,34660,N,N,N,N,N,36271,N,N,N,64242,N,N,N,N,N,N,N, +N,N,N,N,37848,N,N,N,64735,N,N,N,37843,N,N,N,N,N,N,N,64737,N,N,N,N,N,N,N,N,N, +36470,N,N,N,N,N,N,N,64610,N,N,N,N,N,N,N,N,37841,N,N,N,36273,N,N,N,N,N,N,N, +39001,N,N,N,N,N,N,N,N,N,64338,N,N,N,N,N,N,N,N,64339,N,N,N,N,N,64333,N,N,40127, +N,N,N,N,N,N,N,N,39794,N,N,N,N,N,N,N,N,N,N,N,N,N,64336,37822,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36059,N,N,N,N,N,N,N,N,N,40433,64747,N,N,N,N,N,N, +N,N,N,41147,N,39806,N,N,N,N,N,N,N,36275,N,N,35922,N,N,N,N,39656,N,N,N,N,N,N, 36572,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40185,N,N,N,N,N,N,N,N,N,N,N,N,N,64080,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39143,64755,N,N,N,N, -64754,N,N,N,36042,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,37861,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39513,N,N,N,36277,N,N,N,N,N,N, -N,64845,N,N,N,N,64862,N,N,N,N,N,N,N,N,N,N,N,N,N,36733,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,38215,64758,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,37456,N,N,N,N,35176,36278,64763,41085,39164,35177,N,N,N,N, -N,N,N,N,65103,N,N,37462,N,N,N,N,N,N,N,N,N,N,64201,N,N,37864,N,N,N,64760,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40163,64937,N,N,N,N,N,N,64580,N,N,N,N,N,N,N,N, -38464,N,N,36280,N,N,N,N,N,N,N,N,N,N,39754,36793,N,N,N,N,N,N,64766,N,N,N,N,N,N, -N,35178,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36281,N,N, -N,37246,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37876,N,N,N,N,N,N,N,N,N,N,N,N,N,64380,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37863,N,N,38895,N,N,N,65098,N,N,N,N,N,64837,N, -38565,N,N,N,N,65248,64840,64839,65266,65130,N,N,N,N,N,36285,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,39841,36002,39607,36604,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40865,N,N,N, -N,N,N,N,N,N,64849,N,N,N,N,N,N,N,64173,N,N,N,N,36286,N,N,35236,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,39641,N,N,N,N,N,N,N,N,N,N,N,64846,N,N,36288,N,N,38896,N,N,N,N,N,N, -N,N,N,N,37812,64836,N,N,N,N,N,N,N,N,N,N,N,N,40871,N,N,N,N,36290,N,N,N,N,39350, -N,N,N,N,N,N,N,N,N,N,N,N,N,64850,N,N,N,N,N,N,36289,N,N,36422,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,41169,N,N,N,N,N,N,N,N,N,N,N,N,N,40906,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,37583,N,N,N,40180,36292,N,N,N,N,N,N,N,N,N,N,64833,N,N,N,N,N,N,N,39756,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,64855,64751,40158,N,N,N,N,N,N,N,64834,39020,N,N,N,N, -N,N,N,N,N,N,N,N,N,38905,N,38232,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39006,65147,38093, -N,N,N,N,N,37870,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36003,N,64858,N,N,N,N,N,N,37877, -N,N,N,N,N,37871,36586,N,N,N,36699,N,N,N,N,N,N,N,N,N,N,N,35934,N,36294,N,N,N,N, -N,N,N,N,N,N,N,36296,N,N,36295,N,N,N,N,N,37879,N,N,N,N,N,N,N,36297,N,N,N,N,N,N, -N,64498,N,N,N,N,38512,N,N,N,N,N,N,N,N,N,36299,N,N,N,64860,N,N,N,N,N,N,N,N,N, -36709,N,N,N,36301,N,N,N,N,N,40360,38137,N,N,36302,N,N,N,N,N,N,N,N,37866,N,N,N, -N,N,N,N,N,N,64863,37872,40886,N,N,N,N,N,N,N,N,N,36303,N,N,N,38755,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36304,37873,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,64866,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64869,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40923,N,N,N,N, -37880,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35831,N,N,N,N,64870,N,N,N, -N,N,35791,N,N,N,N,N,N,36305,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64754,N,N,N,36042,N,N,34677,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,37861,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39513,N,N,N,36277,N,N,N,N, +N,N,N,64845,N,N,N,N,64862,N,N,N,N,N,N,N,N,N,N,N,N,N,36733,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,38215,64758,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,37456,N,N,N,N,35176,36278,64763,41085,39164,35177,N,N, +N,N,N,N,N,N,65103,N,N,37462,N,N,N,N,N,N,N,N,N,N,64201,N,N,37864,N,N,N,64760,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40163,64937,N,N,N,N,N,N,64580,N,N,N,N,N,N, +N,N,38464,N,N,36280,N,N,N,N,N,N,N,N,N,N,39754,36793,N,N,N,N,N,N,64766,N,N,N,N, +N,N,N,35178,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36281, +N,N,N,37246,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37876,N,N,N,N,N,N,N,N,N,N,N,N,N, +64380,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37863,N,N,38895,N,N,N,65098,N,N,N,N,N, +64837,N,38565,N,N,N,N,65248,64840,64839,65266,65130,N,N,N,N,N,36285,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,39841,36002,39607,36604,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40865,N,N,N,N,N,N,N,N,N,64849,N,N,N,N,N,N,N,64173,N,N,N,N,36286,N,N,35236,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,39641,N,N,N,N,N,N,N,N,N,N,N,64846,N,N,36288,N,N,38896, +N,N,N,N,N,N,N,N,N,N,37812,64836,N,N,N,N,N,N,N,N,N,N,N,N,40871,N,N,N,N,36290,N, +N,N,N,39350,N,N,N,N,N,N,N,N,N,N,N,N,N,64850,N,N,N,N,N,N,36289,N,N,36422,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,41169,N,N,N,N,N,N,N,N,N,N,N,N,N,40906,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,37583,N,N,N,40180,36292,N,N,N,N,N,N,N,N,N,N,64833,N,N,N,N,N,N, +N,39756,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64855,64751,40158,N,N,N,N,N,N,N,64834, +39020,N,N,N,N,N,N,N,N,N,N,N,N,N,38905,N,38232,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39006,65147,38093,N,N,N,N,N,37870,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36003,N,64858, +N,N,N,N,N,N,37877,N,N,N,N,N,37871,36586,N,N,N,36699,N,N,N,N,N,N,N,N,N,N,N, +35934,N,36294,N,N,N,N,N,N,N,N,N,N,N,36296,N,N,36295,N,N,N,N,N,37879,N,N,N,N,N, +N,N,36297,N,N,N,N,N,N,N,64498,N,N,N,N,38512,N,N,N,N,N,N,N,N,N,36299,N,N,N, +64860,N,N,N,N,N,N,N,N,N,36709,N,N,N,36301,N,N,N,N,N,40360,38137,N,N,36302,N,N, +N,N,N,N,N,N,37866,N,N,N,N,N,N,N,N,N,64863,37872,40886,N,N,N,N,N,N,N,N,N,36303, +N,N,N,38755,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36304, +37873,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64866,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,64869,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40923,N,N,N,N,37880,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35831,N,N,N,N,64870,N,N,N,N,N,35791,N,N,N,N,N,N,36305,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,36306,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,64881,N,N,N,N,64879,N,N,N,N,N,N,N,N,36307,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40935,37053,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40912,N,N,N,35792,N,64882, +N,40110,35793,N,N,35547,N,N,N,N,N,N,N,N,N,N,N,64228,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,38350,N,64886,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64354,N,N,N,N,N,N,36308, +N,N,N,64888,N,N,N,N,N,36579,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,36982,N,N,39110,N,N,N,N,N,N,N,36309,N,N,N,N,38865,N,N,40630,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64199,N,N,41026,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,39027,N,N,N,N,N,N,N,N,N,N,40956,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,36005,36311,N,N,37627,36312,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,37967,N,36313,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,35179,N,N,N,N,N,N,N,N,38862,N,N,N,64243,64942,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64431,37559,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36314,N,N,N,N,N,N,N,N,N,N,N,N,N,40026,N,N,N,N,N,N,64941,N,N,N,N,N,N,N,N,N,N,N, +N,N,36316,37956,N,N,N,N,N,N,N,N,N,N,N,36317,N,N,N,N,N,N,N,41174,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35905,38869,N,37962,N,N,N,N,N, +37965,N,N,N,N,38859,N,N,N,N,N,36318,N,N,36319,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36320,65273,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,64960,64761,N,N,N,N,N,N,36061,N,64382,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37555,N,N,N,N,N,64943,N,N,N,N,N,N,N,N,N,36321,N,N,N,N, +38355,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35265,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64872,N,N,40119,N,N,36323,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,64192,36325,64100,N,35143,N,N,N,N,36324,N,N,N,N,N,36327, +36328,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64967,64944,N,N,N,N,N,N,37957,38870,N,N, +N,N,N,N,N,N,N,64710,38980,N,N,N,N,N,N,N,N,N,N,N,N,36329,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,36330,N,N,N,N,N,N,N,N,65104,N,N,N,N,N,N,64972,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40359,N,N,N,N,N,64973,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64975,N,N,N,N,38354,N,N,N,N,N,N,N,36333,N,N,N,N,N,N,N,N,64698,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,64965,N,64978,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40156,N,N,N,N,N,38351,N,N,36334,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64980, +N,N,N,N,N,38636,38635,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +37046,N,64963,39083,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38638, +N,N,N,N,N,N,N,N,N,N,N,N,N,36340,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64992,N,35943,N,N,36342,N,N,N,36343,N,N,N,N,N,N,N,36858,N,N,N,N, +N,N,N,N,N,N,38864,N,N,N,N,35794,N,N,36344,N,N,N,N,N,37081,N,35911,N,64240,N,N, +N,N,64993,36345,N,64995,N,N,N,N,N,N,N,36346,N,64355,N,N,N,37030,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,39280,N,N,37355,N,38768,39023,64994,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39154,N,39676,35180,65021,N,N,39262,N,N,N,38333,N,N,N,N,N,N,N,64996, +N,N,N,37350,N,N,N,N,64997,64998,N,N,N,N,N,N,N,N,64999,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,37972,N,N,N,39352,N,N,N,N,N,N,N,N,38889,37702,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,39011,N,N,N,N,N,N,N,N,N,N,N,38332,N,65005,65015,N,N,N, +N,N,N,39024,38646,36521,N,N,N,N,N,37969,N,N,36419,N,35674,N,N,N,N,65006,N,N,N, +N,65008,N,N,N,N,65012,N,39925,N,N,N,N,N,36078,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,38782,N,N,N,N,N,39893,N,39619,N,38856,41179,37328,N,N,40932,N,36829,N, +37353,N,N,N,N,N,N,N,N,N,39136,N,N,N,37578,N,38999,N,N,35921,N,N,N,N,65003,N, +39753,N,N,N,N,N,N,N,N,N,40310,40623,N,N,N,N,N,N,N,N,N,40140,N,N,N,N,N,N,65002, +N,N,36337,N,N,65019,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36435,N,N,N,N, +N,N,N,N,N,N,N,64207,N,N,N,N,N,N,N,N,N,N,N,N,N,38649,N,N,N,N,N,N,N,N,N,39103, +40521,36007,N,N,N,N,N,N,N,N,39882,N,N,N,N,65022,37596,N,N,N,N,N,65089,37324, +37346,N,N,N,N,N,N,N,N,N,N,N,N,65092,34655,N,N,N,N,N,35795,N,N,65095,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,65096,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37973,N,N,N,N, +65099,N,65100,N,N,N,N,36287,N,N,N,N,N,N,N,N,N,40568,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,65105,N,N,N,N,37974,N,N,N,N,N,N,N,40289,N,N,N,N, +37975,N,N,N,N,N,N,N,N,N,N,39270,N,N,N,N,N,N,N,N,N,N,N,N,N,35797,N,N,N,N,41065, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39092,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,41033,41036,N,40549,N,N,N,N,N,N,N,N,N,N,N,39093,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65112,N,39285,65107,41061,N,65113,N,N,N,N, +N,N,N,N,N,39095,39096,N,N,N,N,N,N,N,39098,N,N,N,N,N,N,39099,N,N,N,N,N,N,40892, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41034,N,N, +40647,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36009,N,N,39086,N,N,N,N,N, +N,N,N,37590,N,N,N,64225,N,37332,N,N,N,N,N,N,N,N,64222,N,N,65115,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,35923,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65118,N,N,N,N,64471,65114, +38085,N,N,N,N,64202,N,N,N,N,N,N,N,N,N,N,N,39105,38748,N,65140,N,38771,N,N,N,N, +N,N,N,N,64070,N,N,N,38756,N,N,N,65128,N,38478,N,38757,35930,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,35233,38394,N,37588,65129,N,64325,N,39112,N,N,37103,N,39113,39114,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37997,38071,65132,N,N,37995,N,N,N, +N,N,N,37628,N,38379,N,65139,38766,65119,N,N,N,N,N,N,N,N,N,64957,N,N,37589,N,N, +N,N,N,N,65209,N,N,65137,34680,N,N,N,64443,N,N,38010,N,N,38395,65143,N,N,N,N,N, +N,N,65145,N,65141,N,N,N,37981,N,N,N,N,N,N,N,65148,N,N,N,N,N,N,N,N,N,37700, +36518,N,N,N,N,N,N,N,N,N,N,N,37587,N,38072,N,34681,N,N,N,N,N,N,64625,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,38750,N,N,N,N,36013,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65191,N,N, +N,37994,N,N,N,37859,N,N,39119,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41177,N,N, +N,N,N,N,N,N,41151,41037,41144,N,N,N,N,N,41166,41143,N,N,N,N,N,N,N,N,65193,N,N, +N,N,N,N,N,N,N,N,35267,N,N,N,N,65195,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40436,35181,N,N,N,N,N,40059,N,N,N,N,N,N,39122,N,N,N,40873,N,N,N,65202,N,N, +65201,N,N,N,38873,N,41156,N,38006,N,N,N,N,N,N,N,N,N,N,39288,N,N,N,N,N,N,65203, +N,N,N,N,N,39123,65204,N,N,N,39124,N,N,N,N,N,N,N,40889,N,N,N,N,N,N,N,N,38001,N, +N,N,N,N,N,N,N,N,39125,65208,N,N,N,50900,N,N,N,N,N,N,N,N,N,N,N,65210,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,40540,N,N,65211,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41028,N, +N,N,N,39127,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39128,65212,N,N,N,N,40958,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65213,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,40413,N,N,N,N,40673,N,N,N,N,N,N,N,N,N,N,N,N,39130, +40415,65215,N,65214,N,N,40683,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40537,41052,N, +N,N,N,N,N,N,65216,N,N,N,38007,39132,N,65217,N,N,N,39134,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,65219,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65224,N,N,N,65225,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65226,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +65227,N,N,N,N,N,N,N,N,N,40898,N,N,35947,39108,N,38064,38065,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,65233,N,N,N,N,N,41153,N,65234,N,N,N,N,41165,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,65235,N,N,39141,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65238, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37348,N,N,N,N,36807,38062,N, +35407,38066,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36820,N,N,N,N,39146, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65240,N,N,N,N,N,N,N,N,N,40416,N,N, +N,N,39150,N,N,N,N,38340,N,64744,N,N,N,N,N,39151,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,35950,N,N,N,N,N,N,N,N,64216,N,N,N,N,N,N,N,N,N,N,N,N,N,65244,N,N,N,N,N,N,N, +N,N,41134,40268,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39153,N,N,N,39155,N,38081,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39157,N,N,64079,38626,N,N,N,N, +37968,N,38562,N,N,39158,N,N,N,38629,N,N,N,N,N,39159,N,41030,38627,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,39160,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40676,N,N,N, +N,N,N,63958,N,N,N,N,N,N,38083,N,N,N,N,38082,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65249,N,65257,N,N,N,N,38628,N,35244,38619,N,N, +N,N,N,N,N,N,N,N,N,N,N,65250,N,N,N,N,N,N,N,N,N,N,38084,65251,N,N,N,65255,40955, +N,N,N,N,N,N,N,N,N,N,N,35929,N,N,N,N,N,N,N,N,N,37833,N,38120,64342,N,N,N,37061, +41128,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,65253,N,N,N,39165,39163,65256,N,36543,N,N,N,N,35800,65271,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36712,38086,N,N,N,N,N,N,N,N,40426,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,64617,N,N,N,N,N,N,N,N,N,N,N,N,40154,N,65267,N,N,40050, +N,N,65264,35273,N,N,N,N,N,N,N,N,N,39233,N,N,N,N,N,N,N,39234,N,N,N,65269,N, +37335,N,N,N,N,N,38092,N,N,N,65272,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,38824,N,65276,N,N,N,36062,N,64959,N,N,N,N,N,N,N,65278,N,N,N,N,N,N,N,N, +N,N,N,N,N,38609,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38101,N,N,38096,39236,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35939,N,N,41139,N,N, +N,N,N,N,N,N,N,N,N,N,38095,N,N,N,40954,N,N,N,N,37349,N,40042,N,N,N,36425,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36428,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,36429,N,N,N,N,N,39539,N,N,N,N,N,N,N,N,N,N,N,N,N,39239,N, +36017,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36432,N,N,N,N,N, +N,N,N,N,N,36431,39241,N,N,N,N,N,36433,36434,N,N,N,N,39602,35237,N,N,N,N,N, +39244,N,N,N,40952,N,N,N,N,N,N,36438,39245,37322,36439,N,N,N,N,38113,N,N,N,N, +36935,N,36824,36440,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38123,36444,38227,N, +N,N,N,N,N,N,40933,N,N,N,N,N,N,N,N,N,N,40790,N,N,N,N,N,N,N,38223,N,36446,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,39274,N,N,N,N,N,N,N,N,40036,40153,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,36445,N,N,N,N,N,N,N,N,N,N,N,N,39248,N,N,N,N,N,N,N,N,N,39249,N,N, +36450,N,N,N,N,N,N,N,N,N,N,N,39250,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36456,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36449,40793,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35763,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40797,36454,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36018,N,N,N,N,N,N,N,N,N,N,N, +N,N,36462,N,40804,39251,N,N,64184,N,N,N,N,N,39252,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,36464,N,N,N,N,N,N,N,N,N,N,N,N,40801,N,36466,N,N,N,N,N,N, +N,N,N,N,N,N,41067,N,N,N,N,40768,N,N,N,N,N,N,38125,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,38126,N,N,40893,N,N,N,36475,N,N,N,N,N,N,39255,38135,N,40799,N,N,N,N,36467,N, +N,40802,N,N,N,N,N,N,N,38134,N,N,N,N,N,N,N,N,N,N,N,N,N,39256,N,N,N,N,N,N,N,N,N, +36469,63963,N,N,N,N,36978,N,38136,N,N,N,N,N,N,N,N,N,39258,N,N,N,N,N,N,N,N,N, +41136,36019,N,N,N,36473,N,36472,N,N,N,38131,N,N,N,N,N,39087,N,N,N,N,N,N,41138, +N,N,N,N,N,N,N,N,N,N,N,36474,N,N,N,N,N,N,39260,N,N,N,N,N,36476,N,36477,N,N,N, +35801,N,N,35234,40663,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,41142,N,N,N,N,N,N,N,N,N,N,N,N,40514,N,N,36516,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36306,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64881,N,N,N,N,64879, -N,N,N,N,N,N,N,N,36307,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40935,37053,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,40912,N,N,N,35792,N,64882,N,40110,35793,N,N,35547,N, -N,N,N,N,N,N,N,N,N,N,64228,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38350,N,64886,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,64354,N,N,N,N,N,N,36308,N,N,N,64888,N,N,N,N,N, -36579,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36982,N,N, -39110,N,N,N,N,N,N,N,36309,N,N,N,N,38865,N,N,40630,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,64199,N,N,41026,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39027,N,N, -N,N,N,N,N,N,N,N,40956,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36005,36311,N,N, -37627,36312,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37967,N, -36313,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,35179,N,N,N,N,N,N,N,N,38862,N,N,N,64243,64942,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,64431,37559,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36314,N,N,N,N,N,N,N,N,N, -N,N,N,N,40026,N,N,N,N,N,N,64941,N,N,N,N,N,N,N,N,N,N,N,N,N,36316,37956,N,N,N,N, -N,N,N,N,N,N,N,36317,N,N,N,N,N,N,N,41174,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,35905,38869,N,37962,N,N,N,N,N,37965,N,N,N,N,38859,N,N,N,N, -N,36318,N,N,36319,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36320,65273,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64960,64761,N,N,N,N,N, -N,N,N,64382,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37555,N,N, -N,N,N,64943,N,N,N,N,N,N,N,N,N,36321,N,N,N,N,38355,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35265,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64872,N,N,40119,N,N, -36323,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64192,36325, -64100,N,35143,N,N,N,N,36324,N,N,N,N,N,36327,36328,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,64967,64944,N,N,N,N,N,N,37957,38870,N,N,N,N,N,N,N,N,N,64710,38980,N,N,N,N, -N,N,N,N,N,N,N,N,36329,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36330,N,N,N,N,N,N,N,N, -65104,N,N,N,N,N,N,64972,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40359,N,N,N,N,N, -64973,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64975,N,N,N,N,38354,N,N,N, -N,N,N,N,36333,N,N,N,N,N,N,N,N,64698,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64965, -N,64978,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40156,N,N,N,N,N,38351,N,N, -36334,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64980,N,N,N,N,N,38636,38635,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37046,N,64963,39083,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38638,N,N,N,N,N,N,N,N,N,N,N,N,N, -36340,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64992,N, -35943,N,N,36342,N,N,N,36343,N,N,N,N,N,N,N,36858,N,N,N,N,N,N,N,N,N,N,38864,N,N, -N,N,35794,N,N,36344,N,N,N,N,N,37081,N,35911,N,64240,N,N,N,N,64993,36345,N, -64995,N,N,N,N,N,N,N,36346,N,64355,N,N,N,37030,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39280,N,N,37355,N,38768,39023,64994,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39154,N, -39676,35180,65021,N,N,39262,N,N,N,38333,N,N,N,N,N,N,N,64996,N,N,N,37350,N,N,N, -N,64997,64998,N,N,N,N,N,N,N,N,64999,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37972,N, -N,N,39352,N,N,N,N,N,N,N,N,38889,37702,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,39011,N,N,N,N,N,N,N,N,N,N,N,38332,N,65005,65015,N,N,N,N,N,N,39024,38646, -36521,N,N,N,N,N,37969,N,N,36419,N,35674,N,N,N,N,65006,N,N,N,N,65008,N,N,N,N, -65012,N,39925,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38782,N,N,N,N, -N,39893,N,39619,N,38856,41179,37328,N,N,40932,N,36829,N,37353,N,N,N,N,N,N,N,N, -N,39136,N,N,N,37578,N,38999,N,N,35921,N,N,N,N,65003,N,39753,N,N,N,N,N,N,N,N,N, -40310,40623,N,N,N,N,N,N,N,N,N,40140,N,N,N,N,N,N,65002,N,N,36337,N,N,65019,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36435,N,N,N,N,N,N,N,N,N,N,N,64207,N,N, -N,N,N,N,N,N,N,N,N,N,N,38649,N,N,N,N,N,N,N,N,N,39103,40521,36007,N,N,N,N,N,N,N, -N,39882,N,N,N,N,65022,37596,N,N,N,N,N,65089,37324,37346,N,N,N,N,N,N,N,N,N,N,N, -N,65092,N,N,N,N,N,N,35795,N,N,65095,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65096,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37973,N,N,N,N,65099,N,65100,N,N,N,N,36287,N,N,N,N, -N,N,N,N,N,40568,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65105,N, -N,N,N,37974,N,N,N,N,N,N,N,40289,N,N,N,N,37975,N,N,N,N,N,N,N,N,N,N,39270,N,N,N, -N,N,N,N,N,N,N,N,N,N,35797,N,N,N,N,41065,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,39092,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41033,41036,N, -40549,N,N,N,N,N,N,N,N,N,N,N,39093,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,65112,N,39285,65107,41061,N,65113,N,N,N,N,N,N,N,N,N,39095,39096,N,N,N,N,N,N, -N,39098,N,N,N,N,N,N,39099,N,N,N,N,N,N,40892,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41034,N,N,40647,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,36009,N,N,39086,N,N,N,N,N,N,N,N,37590,N,N,N,64225,N,37332,N,N, -N,N,N,N,N,N,64222,N,N,65115,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35923,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,65118,N,N,N,N,64471,65114,38085,N,N,N,N,64202,N,N,N,N,N,N,N,N,N, -N,N,39105,38748,N,65140,N,38771,N,N,N,N,N,N,N,N,64070,N,N,N,38756,N,N,N,65128, -N,38478,N,38757,35930,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35233,38394,N,37588,65129,N, -64325,N,39112,N,N,37103,N,39113,39114,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,37997,38071,65132,N,N,37995,N,N,N,N,N,N,37628,N,38379,N,65139,38766, -65119,N,N,N,N,N,N,N,N,N,64957,N,N,37589,N,N,N,N,N,N,65209,N,N,65137,N,N,N,N, -64443,N,N,38010,N,N,38395,65143,N,N,N,N,N,N,N,65145,N,65141,N,N,N,37981,N,N,N, -N,N,N,N,65148,N,N,N,N,N,N,N,N,N,37700,36518,N,N,N,N,N,N,N,N,N,N,N,37587,N, -38072,N,N,N,N,N,N,N,N,64625,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38750,N,N,N,N,36013, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,65191,N,N,N,37994,N,N,N,37859,N,N,39119,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,41177,N,N,N,N,N,N,N,N,41151,41037,41144,N,N,N,N,N, -41166,41143,N,N,N,N,N,N,N,N,65193,N,N,N,N,N,N,N,N,N,N,35267,N,N,N,N,65195,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40436,35181,N,N,N,N,N,40059,N,N,N,N,N,N, -39122,N,N,N,40873,N,N,N,65202,N,N,65201,N,N,N,38873,N,41156,N,38006,N,N,N,N,N, -N,N,N,N,N,39288,N,N,N,N,N,N,65203,N,N,N,N,N,39123,65204,N,N,N,39124,N,N,N,N,N, -N,N,40889,N,N,N,N,N,N,N,N,38001,N,N,N,N,N,N,N,N,N,39125,65208,N,N,N,50900,N,N, -N,N,N,N,N,N,N,N,N,65210,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40540,N,N,65211,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,41028,N,N,N,N,39127,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,39128,65212,N,N,N,N,40958,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,65213,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40413,N,N,N,N, -40673,N,N,N,N,N,N,N,N,N,N,N,N,39130,40415,65215,N,65214,N,N,40683,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,40537,41052,N,N,N,N,N,N,N,65216,N,N,N,38007,39132,N, -65217,N,N,N,39134,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65219,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,65224,N,N,N,65225,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65226, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65227,N,N,N,N,N,N,N,N,N,40898,N,N, -35947,39108,N,38064,38065,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65233,N,N,N,N,N,41153,N, -65234,N,N,N,N,41165,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65235,N,N,39141,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65238,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,37348,N,N,N,N,36807,38062,N,35407,38066,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,36820,N,N,N,N,39146,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,65240,N,N,N,N,N,N,N,N,N,40416,N,N,N,N,39150,N,N,N,N,38340,N,64744,N, -N,N,N,N,39151,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35950,N,N,N,N,N,N,N,N,64216,N, -N,N,N,N,N,N,N,N,N,N,N,N,65244,N,N,N,N,N,N,N,N,N,41134,40268,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,39153,N,N,N,39155,N,38081,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,39157,N,N,64079,38626,N,N,N,N,37968,N,38562,N,N,39158,N,N,N,38629, -N,N,N,N,N,39159,N,41030,38627,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39160,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40676,N,N,N,N,N,N,63958,N,N,N,N,N,N,38083,N,N,N, -N,38082,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -65249,N,65257,N,N,N,N,38628,N,35244,38619,N,N,N,N,N,N,N,N,N,N,N,N,N,65250,N,N, -N,N,N,N,N,N,N,N,38084,65251,N,N,N,65255,40955,N,N,N,N,N,N,N,N,N,N,N,35929,N,N, -N,N,N,N,N,N,N,37833,N,38120,64342,N,N,N,37061,41128,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65253,N,N,N,39165,39163, -65256,N,36543,N,N,N,N,35800,65271,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36712,38086,N,N,N,N,N,N,N,N,40426,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64617, -N,N,N,N,N,N,N,N,N,N,N,N,40154,N,65267,N,N,40050,N,N,65264,35273,N,N,N,N,N,N,N, -N,N,39233,N,N,N,N,N,N,N,39234,N,N,N,65269,N,37335,N,N,N,N,N,38092,N,N,N,65272, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38824,N,65276,N,N,N,N,N, -64959,N,N,N,N,N,N,N,65278,N,N,N,N,N,N,N,N,N,N,N,N,N,38609,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,38101,N,N,38096,39236,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,35939,N,N,41139,N,N,N,N,N,N,N,N,N,N,N,N,38095,N,N,N, -40954,N,N,N,N,37349,N,40042,N,N,N,36425,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,36428,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36429,N,N, -N,N,N,39539,N,N,N,N,N,N,N,N,N,N,N,N,N,39239,N,36017,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36432,N,N,N,N,N,N,N,N,N,N,36431,39241,N,N,N,N,N, -36433,36434,N,N,N,N,39602,35237,N,N,N,N,N,39244,N,N,N,40952,N,N,N,N,N,N,36438, -39245,37322,36439,N,N,N,N,38113,N,N,N,N,36935,N,36824,36440,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,38123,36444,38227,N,N,N,N,N,N,N,40933,N,N,N,N,N,N,N,N,N,N, -40790,N,N,N,N,N,N,N,38223,N,36446,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39274,N,N,N,N, -N,N,N,N,40036,40153,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36445,N,N,N,N,N,N,N,N,N, -N,N,N,39248,N,N,N,N,N,N,N,N,N,39249,N,N,36450,N,N,N,N,N,N,N,N,N,N,N,39250,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36456,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36449,40793,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35763,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,40797,36454,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,36018,N,N,N,N,N,N,N,N,N,N,N,N,N,36462,N,40804,39251,N,N,64184,N,N, -N,N,N,39252,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36464,N,N,N,N,N, -N,N,N,N,N,N,N,40801,N,36466,N,N,N,N,N,N,N,N,N,N,N,N,41067,N,N,N,N,40768,N,N,N, -N,N,N,38125,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38126,N,N,40893,N,N,N,36475,N,N,N,N, -N,N,39255,38135,N,40799,N,N,N,N,36467,N,N,40802,N,N,N,N,N,N,N,38134,N,N,N,N,N, -N,N,N,N,N,N,N,N,39256,N,N,N,N,N,N,N,N,N,36469,63963,N,N,N,N,36978,N,38136,N,N, -N,N,N,N,N,N,N,39258,N,N,N,N,N,N,N,N,N,41136,36019,N,N,N,36473,N,36472,N,N,N, -38131,N,N,N,N,N,39087,N,N,N,N,N,N,41138,N,N,N,N,N,N,N,N,N,N,N,36474,N,N,N,N,N, -N,39260,N,N,N,N,N,36476,N,36477,N,N,N,35801,N,N,35234,40663,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41142,N,N,N,N,N,N, -N,N,N,N,N,N,40514,N,N,36516,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36519,N,35958,N,N,N,N,N,N,N,N,N,N,N,38210, -N,N,N,N,N,N,N,N,N,N,N,N,39037,N,N,N,38741,N,N,36520,N,N,N,N,N,N,N,36522,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35235,N,39264,39266,N,N,38140, -39265,N,N,N,N,N,N,N,38138,N,N,N,N,N,N,N,36526,36530,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,36528,N,N,N,N,N,N,N,39267,38826,38139,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,36539,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36060,N,N,N,N,N,N,N,N, -N,39030,N,36513,N,N,N,N,36020,N,36535,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40358,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,40624,N,N,N,36536,N,N,N,N,N,N,N,N,N,N,N,N,40304,N,N, -N,N,35182,N,N,N,N,N,N,N,35183,N,N,N,N,N,N,N,N,N,N,N,N,N,35184,N,N,N,N,N,N,N,N, -N,N,N,N,35185,N,N,N,N,N,N,N,35186,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35187,35188,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,35189,N,N,N,N,N,N,N,N,36540,36541,N,N,N,N,N,36542,N,40401,N,N, -N,N,38141,N,N,N,35799,35802,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,41186,N,N,N,N,N,N,40937,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64936,N,N,N,35559,N,N,N,36546,N,N,N,N,N,N,N,N,N,N,N,36548,N,N,N,N,N,N,N,N,N,N, -39268,N,N,N,N,N,39269,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,38222,N,N,N,N,N,N,N,N,N,39091,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,36555,35807,N,N,N,N,N,36558,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,36559,N,N,39272,N,N,N,N,39273,N,N,N,N,N,N,N,N,39275,36561,N,39276,N,N,N,N,N, -N,N,N,N,36564,36565,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39277,N,N,N, -N,N,N,41150,N,N,N,N,N,36566,41148,41141,N,N,41140,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,35808,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,35253,N,N,N,N,N,N,N,36573,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40541,39281,N, -N,N,N,35246,40424,N,N,N,N,N,N,N,N,38245,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39282,N,N,35676,N,N,N,N,N,N,N,N,N,35249,41152,N, -N,N,36575,N,38246,N,N,39284,N,39286,N,N,N,39287,N,39289,N,N,40410,N,N,36576,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37724,N,N,N,N,N,N,N,40422,N,35679,N,N,38243,N,N,N, -N,N,N,N,N,N,N,38247,N,N,N,N,N,40419,N,N,N,N,N,N,N,N,N,N,N,N,N,39292,N,N,39293, -39294,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35675,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39331,N,N,N,N,N,N,N,39332,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39334,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,39336,N,N,N,N,35518,N,N,N,N,N,N,N,N,N,N,N,40545,N,N,N,N,N,N,N, -N,N,N,39338,N,N,N,N,N,N,41160,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,39339,N,N,N,N,N,N,N,N,N,N,65220,N,N,N,N,N,N,39106,36584,N,41146,N,N,N,N, -N,N,N,N,N,N,N,64887,N,N,36590,N,N,N,40639,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35266,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39340,N,N,N,N,N,N,N,N,N,N,N,N, -N,38251,N,N,38252,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39343,N,N,39242,35190,36680, -N,N,N,N,N,N,N,N,N,N,N,64494,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,39342,N,N,N,36603,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36048,N,N, -N,N,35666,N,N,N,N,N,39344,N,N,N,N,35191,36673,N,N,N,N,N,N,N,39345,N,N,N,N,N,N, -N,N,N,36681,N,N,N,N,N,N,N,N,N,N,N,64077,N,N,N,N,N,N,N,N,40420,36021,N,N,N, -64489,39764,N,39346,40552,N,N,N,N,N,N,N,N,N,N,N,N,36682,N,36674,N,N,36689,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38982,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39348,N,N,N,N,N,N,N,N,N,N,36597,64853,N,N, -40141,N,N,N,N,N,N,N,N,35192,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36691,N, -N,N,N,N,N,N,N,N,N,N,36719,N,N,N,N,N,N,N,N,N,N,36451,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,36694,N,N,N,N,N,N,N,N,N,N,N,N,65142,N,N,N,N,40902,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,64172,N,N,N,N,N,36696,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38984,39351,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38501,N,64108,N,40423,N,N,N,40546,N,N, -N,38604,36455,N,N,64629,N,39038,N,N,N,N,N,N,N,64953,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,38908,N,N,N,N,N,N,N,N,N,39161,N,36710,N,N,N,N,N,N,N,N,38254,N,37445,N,N, -36704,N,N,N,40657,N,N,N,N,N,65229,N,39353,N,N,N,N,N,N,N,N,N,N,N,N,36706,38732, -N,N,N,N,N,N,N,N,N,N,N,N,37319,38239,N,N,N,N,N,N,N,39355,N,N,N,N,N,N,N,N,N, -36461,36721,N,N,38091,N,N,N,N,N,N,N,N,N,N,N,N,38321,N,N,N,N,N,N,N,N,N,39666,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,38595,39357,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,41167,N,N,N,36717,N,N,39358,36596,N,36722,38372,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,39359,37442,N,64421,N,N,N,N,N,N,N,N,N,N,39360,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64948,36727,N,N,N, -39361,N,N,N,N,N,N,N,N,N,64185,N,N,N,N,N,N,N,N,36672,64068,N,N,N,N,N,39362,N,N, -N,N,N,N,N,36700,N,N,N,N,36029,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39364,39365,N,N, -36731,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36022,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36771,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36046,N,N,N,N,N,N,N,N, -N,39366,N,N,N,N,N,N,N,N,N,N,N,N,N,38605,N,N,N,N,N,N,N,N,N,N,N,N,N,38599,36773, -N,N,N,N,N,N,N,N,N,N,64187,N,35937,38256,N,N,N,37736,N,36734,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,36778,N,N,N,N,N,N,41040,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37075,N,N,38230,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,36792,N,N,N,N,N,39368,N,N,N,N,N,N,N,N,N,N,N,36783,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,39369,N,N,N,N,N,N,N,N,N,N,N,N,N,38265,N,N,N,N,N,N,N,N, -N,N,N,N,40777,N,N,N,N,39370,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39371, -40405,36784,N,N,N,N,N,N,N,N,N,N,N,64122,N,N,N,N,N,N,N,N,40543,N,N,N,N,39373, -41161,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39643,N,N,N,41158,N,N,N, -N,N,N,N,36788,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41175,N,N,N,N,N,N,N,N,N,N,N,N, -41159,N,N,N,N,N,N,N,41027,N,N,N,36789,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36786,N,N,N,N,N,N,41057,40542,N,N,N,N,N,N,N,N,N,N,36790,N,N,N,N,N,N,N,N,40936, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,40114,N,N,N,N,N,38268,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,40903,N,N,36795,36796,N,N,N,N,N,N,N,N,36844,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,36800,N,37738,N,N,N,35812,40060,N,N,N,N,N,N,N,N,38305,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,65260,N,N,38307,N,N,N,N,N,N,N,35909,36024,N,N,N,N,N,N, -N,N,N,N,N,36801,N,N,N,41042,N,N,N,N,N,N,N,N,N,N,N,N,N,39376,N,N,N,N,N,36803, -36804,N,N,N,N,N,N,N,N,N,38308,N,N,N,N,N,36806,N,40544,N,N,N,N,N,N,N,63960,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38309,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40115,N,N,N,N,N,N,N,N,N,39377,65265,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,39378,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,40130,N,N,N,39379,N,N,N,N,N,38311,N,N,N,N,N,N,38313,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,38310,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40029,N,N,N,N,N, -N,N,N,39138,N,N,N,N,N,N,36809,N,41154,36810,N,N,N,N,N,N,39380,N,N,41145,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,39768,N,36813,N,41172,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,36814,N,N,N,N,35813,N,N,N,N,35193,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,36816,38326,N,N,N,N,N,N,N,N,N,N,N,N,39382,N,38373,N, -N,N,N,N,N,N,N,N,N,N,N,39383,N,N,N,N,38325,N,N,N,N,N,N,N,N,N,N,N,41162,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40957,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,41048,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36822,N,N,N, -39384,N,N,N,N,N,N,N,36819,N,N,N,N,N,N,N,N,N,N,N,N,36837,N,N,N,N,N,36841,N,N,N, -N,39385,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,37500,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40005,36830,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36831,N,N,N,N,N,N,N,N,N,N,N,N,N,41035,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,36834,N,N,N,41164,N,N,N,N,N,N,N,N,36835,36836,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,39876,N,N,N,39932,N,N,N,N,N,N,38476,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,39670,N,36014,N,N,N,N,N,N,N,N,N,N,N,N,36839,N,N,N,N,N,N,N,N,N,N,36840, -N,N,N,N,35815,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35194, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35195, -39386,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36519,N,35958,N,N,N,N,N,N,N,N,N,34663,N,38210,N,N,N,N,N,N,N,N,N,N,N,N,39037,N, +N,N,38741,N,N,36520,N,N,N,N,N,N,N,36522,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,35235,N,39264,39266,N,N,38140,39265,N,N,N,N,N,N,N,38138,N,N,N,N,N, +N,N,36526,36530,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36528,N,N,N,N,N,N,N,39267,38826, +38139,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36539,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,36060,N,N,N,N,N,N,N,N,N,39030,N,36513,N,N,N,N,36020,N, +36535,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40358,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40624, +N,N,N,36536,N,N,N,N,N,N,N,N,N,N,N,N,40304,N,N,N,N,35182,N,N,N,N,N,N,N,35183,N, +N,N,N,N,N,N,N,N,N,N,N,N,35184,N,N,N,N,N,N,N,N,N,N,N,N,35185,N,N,N,N,N,N,N, +35186,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35187,35188,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35189,N,N,N, +N,N,N,N,N,36540,36541,N,N,N,N,N,36542,N,40401,N,N,N,N,38141,N,N,N,35799,35802, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41186,N,N,N,N,N,N, +40937,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64936,N,N,N,35559,N,N,N, +36546,N,N,N,N,N,N,N,N,N,N,N,36548,N,N,N,N,N,N,N,N,N,N,39268,N,N,N,N,N,39269,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38222,N,N,N,N,N,N,N,N,N,39091,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36555,35807, +N,N,N,N,N,36558,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36559,N,N,39272,N,N,N, +N,39273,N,N,N,N,N,N,N,N,39275,36561,N,39276,N,N,N,N,N,N,N,N,N,36564,36565,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39277,N,N,N,N,N,N,41150,N,N,N,N,N, +36566,41148,41141,N,N,41140,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35808,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35253,N,N,N, +N,N,N,N,36573,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40541,39281,N,N,N,N,35246,40424,N,N, +N,N,N,N,N,N,38245,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,39282,N,N,35676,N,N,N,N,N,N,N,N,N,35249,41152,N,N,N,36575,N,38246,N,N, +39284,N,39286,N,N,N,39287,N,39289,N,N,40410,N,N,36576,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,37724,N,N,N,N,N,N,N,40422,N,35679,N,N,38243,N,N,N,N,N,N,N,N,N,N,38247,N, +N,N,N,N,40419,N,N,N,N,N,N,N,N,N,N,N,N,N,39292,N,N,39293,39294,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,36091,35675,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39331,N,N,N,N,N,N,N, +39332,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39334,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39336,N,N,N,N,35518,N,N,N,N,N,N,N,N,N,N,N,40545,N,N,N,N,N,N,N,N,N,N,39338,N,N, +N,N,N,N,41160,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39339,N,N, +N,N,N,N,N,N,N,N,65220,N,N,N,N,N,N,39106,36584,N,41146,N,N,N,N,N,N,N,N,N,N,N, +64887,N,N,36590,N,N,N,40639,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35266,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39340,N,N,N,N,N,N,N,N,N,N,N,N,N,38251,N,N,38252, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39343,N,N,39242,35190,36680,N,N,N,N,N,N,N,N,N, +N,N,64494,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39342,N, +N,N,36603,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36048,N,N,N,N,35666,N,N,N,N, +N,39344,N,N,N,N,35191,36673,N,N,N,N,N,N,N,39345,N,N,N,N,N,N,N,N,N,36681,N,N,N, +N,N,N,N,N,N,N,N,64077,N,N,N,N,N,N,N,N,40420,36021,N,N,N,64489,39764,N,39346, +40552,N,N,N,N,N,N,N,N,N,N,N,N,36682,N,36674,N,N,36689,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38982,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,39348,N,N,N,N,N,N,N,N,N,N,36597,64853,N,N,40141,N,N,N,N,N,N,N, +N,35192,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36691,N,N,N,N,N,N,N,N,N,N,N, +36719,N,N,N,N,N,N,N,N,N,N,36451,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36694,N,N,N,N,N, +N,N,N,N,N,N,N,65142,N,N,N,N,40902,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64172,N,N,N,N,N, +36696,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38984,39351,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,38501,N,64108,N,40423,N,N,N,40546,N,N,N,38604,36455,N,N, +64629,N,39038,N,N,N,N,N,N,N,64953,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38908,N,N,N,N, +N,N,N,N,N,39161,N,36710,N,N,N,N,N,N,N,N,38254,N,37445,N,N,36704,N,N,N,40657,N, +N,N,N,N,65229,N,39353,N,N,N,N,N,N,N,N,N,N,N,N,36706,38732,N,N,N,N,N,N,N,N,N,N, +N,N,37319,38239,N,N,N,N,N,N,N,39355,N,N,N,N,N,N,N,N,N,36461,36721,N,N,38091,N, +N,N,N,N,N,N,N,N,N,N,N,38321,N,N,N,N,N,N,N,N,N,39666,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,38595,39357,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41167,N, +N,N,36717,N,N,39358,36596,N,36722,38372,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39359,37442,N,64421,N,N,N,N,N,N,N,N,N,N,39360,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64948,36727,N,N,N,39361,N,N,N,N,N,N,N,N,N, +64185,N,N,N,N,N,N,N,N,36672,64068,N,N,N,N,N,39362,N,N,N,N,N,N,N,36700,N,N,N,N, +36029,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39364,39365,N,N,36731,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34678,N,N,N,36022,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36771,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36046,N,N,N,N,N,N,N,N,N,39366,N,N,N,N,N,N,N,N, +N,N,N,N,N,38605,N,N,N,N,N,N,N,N,N,N,N,N,N,38599,36773,N,N,N,N,N,N,N,N,N,N, +64187,N,35937,38256,N,N,N,37736,N,36734,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36778,N,N,N,N,N,N,41040,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37075,N,N,38230,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36845,N,N,N,38336,N,N,N,N,N,N,N,N,N,N,N,N,N,41163,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40520,N,N,N,N,N,N,39387,N,36851,N,N,N,N, -36857,N,N,N,N,N,N,N,N,N,N,N,N,N,38337,N,41038,N,N,N,N,N,N,39388,N,N,N,N,41060, -36855,N,N,N,N,N,N,N,35248,41032,N,N,N,N,36859,36854,N,N,N,N,N,40412,N,N,N, -39389,35816,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37569,N,N,N,N,N,N,N,40918,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41170,N,N,36928,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35524,N,N,39392,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,40944,40947,N,N,N,N,N,N,N,N,N,N,N,N,40383,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,40950,N,38344,N,N,40538,N,N,N,N,N,N,N,N,N,N,N,N,39395, -N,N,N,N,N,N,N,N,N,N,N,35402,N,N,N,N,N,N,N,N,40945,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,35495,N,N,N,N,N,N,N,N,39398,N,N,N,40951,N,40941,N,N,N,N,N, -N,35420,N,40366,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,38345,N,N,N,N,N,36936,N,N,39400,N,N,N,N,N,36937,N,N,36026,N,N, -37041,N,N,N,N,N,N,36938,N,N,N,N,N,N,N,N,N,N,39402,N,N,N,N,N,N,N,N,N,N,N,39889, -N,N,N,N,N,N,N,39403,N,39404,N,N,N,N,N,N,N,N,39405,N,N,N,N,39406,36940,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36941,N,N,38347,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38882,N,N,N,N,N,N,N,N,38348,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40824,N,N,N,N,N, -N,N,N,N,35196,35197,N,N,N,N,N,N,35198,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39261,N,N,N,N,N,N,N,N,N,N,N,N,39770,N,N,N,N, -36944,N,35919,N,N,N,N,N,N,N,N,N,N,N,36948,N,50902,39592,39407,65259,40355, +36792,N,N,N,N,N,39368,N,N,N,N,N,N,N,N,N,N,N,36783,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39369,N,N,N,N,N,N,N,N,N,N,N,N,N,38265,N,N,N,N,N,N,N,N,N,N,N,N,40777, +N,N,N,N,39370,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39371,40405,36784,N,N, +N,N,N,N,N,N,N,N,N,64122,N,N,N,N,N,N,N,N,40543,N,N,N,N,39373,41161,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39643,N,N,N,41158,N,N,N,N,N,N,N,36788,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,41175,N,N,N,N,N,N,N,N,N,N,N,N,41159,N,N,N,N,N,N,N, +41027,N,N,N,36789,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36786,N,N,N,N,N,N, +41057,40542,N,N,N,N,N,N,N,N,N,N,36790,N,N,N,N,N,N,N,N,40936,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40114,N,N,N,N,N,38268,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40903, +N,N,36795,36796,N,N,N,N,N,N,N,N,36844,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36800,N, +37738,N,N,N,35812,40060,N,N,N,N,N,N,N,N,38305,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,65260,N,N,38307,N,N,N,N,N,N,N,35909,36024,N,N,N,N,N,N,N,N,N,N,N, +36801,N,N,N,41042,N,N,N,N,N,N,N,N,N,N,N,N,N,39376,N,N,N,N,N,36803,36804,N,N,N, +N,N,N,N,N,N,38308,N,N,N,N,N,36806,N,40544,N,N,N,N,N,N,N,63960,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,38309,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40115,N,N,N,N,N, +N,N,N,N,39377,65265,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,39378,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40130,N,N,N,39379,N,N,N,N,N,38311,N,N,N,N,N,N,38313,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,38310,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40029,N,N,N,N,N,N,N,N,39138,N,N, +N,N,N,N,36809,N,41154,36810,N,N,N,N,N,N,39380,N,N,41145,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39768,N,36813,N,41172,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36814,N,N, +N,N,35813,N,N,N,N,35193,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,36816,38326,N,N,N,N,N,N,N,N,N,N,N,N,39382,N,38373,N,N,N,N,N,N,N,N,N, +N,N,N,39383,N,N,N,N,38325,N,N,N,N,N,N,N,N,N,N,N,41162,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40957,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,41048,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36822,N,N,N,39384,N,N,N,N,N,N,N, +36819,N,N,N,N,N,N,N,N,N,N,N,N,36837,N,N,N,N,N,36841,N,N,N,N,39385,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36087,N,N,N,N,N,N,N,N,N,N,N,N,N,37500,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,40005,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36072,36830,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,36831,N,N,N,N,N,N,N,N,N,N,N,N,N,41035,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,36834,N,N,N,41164,N,N,N,N,N,N,N,N,36835,36836,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,39876,N,N,N,39932,N,N,N,N,N,N,38476,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,39670,N,36014,N,N,N,N,N,N,N,N,N,N,N,N,36839,N,N,N,N, +N,N,N,N,N,N,36840,N,N,N,N,35815,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,35194,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,35195,39386,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,36845,N,N,N,38336,N,N,N,N,N,N,N,N,N,N,N,N,N,41163,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40520,N,N,N,N,N,N,39387,N,36851, +N,N,N,N,36857,N,N,N,N,N,N,N,N,N,N,N,N,N,38337,N,41038,N,N,N,N,N,N,39388,N,N,N, +N,41060,36855,N,N,N,N,N,N,N,35248,41032,N,N,N,N,36859,36854,N,N,N,N,N,40412,N, +N,N,39389,35816,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37569,N,N,N,N,N,N,N,40918,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41170,N,N,36928, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35524,N,N,39392,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,40944,40947,N,N,N,N,N,N,N,N,N,N,N,N,40383,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,40950,N,38344,N,N,40538,N,N,N,N,N,N,N,N,N,N,N,N, +39395,N,N,N,N,N,N,N,N,N,N,N,35402,N,N,N,N,N,N,N,N,40945,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,35495,N,N,N,N,N,N,N,N,39398,N,N,N,40951,N,40941,N,N, +N,N,N,N,35420,N,40366,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,38345,N,N,N,N,N,36936,N,N,39400,N,N,N,N,N,36937,N,N,36026, +N,N,37041,N,N,N,N,N,N,36938,N,N,N,N,N,N,N,N,N,N,39402,N,N,N,N,N,N,N,N,N,N,N, +39889,N,N,N,N,N,N,N,39403,N,39404,N,N,N,N,N,N,N,N,39405,N,N,N,N,39406,36940,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36941,N,N,38347,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,38882,N,N,N,N,N,N,N,N,38348,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40824,N,N, +N,N,N,N,N,N,N,35196,35197,N,N,N,N,N,N,35198,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39261,N,N,N,N,N,N,N,N,N,N,N,N,39770,N,N, +N,N,36944,N,35919,N,N,N,N,N,N,N,N,N,N,N,36948,N,50902,39592,39407,65259,40355, 40353,39235,39237,N,40317,N,N,39408,N,N,N,N,N,N,N,N,39409,N,39410,N,N,36028, 40288,N,N,N,N,N,N,N,N,N,41123,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,36955,40667,N,N,N,N,N,N,N,N,N,40313,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, @@ -1259,82 +1275,76 @@ N,N,N,N,37063,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37604,40786,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,37083,N,N,N,N,N,41062,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37074,N,N,N,N,37076,N,N,N,N,N,N,N,N,N,39515,38397,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,35780,N,N,N,35942,N,37086,N,N,N,N,N,40164,N,37089,N,N,N,N,N,N,N,N,N,N,N,N,N, -40518,N,N,N,38481,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64344,N,37094,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38480,N,N,N,37095,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,37096,39517,N,40826,N,N,N,39772,N,40828,N,N,64594,37097,N,37098,N,39518,N, -N,N,N,N,40822,N,N,N,N,N,N,N,N,N,37099,N,N,N,N,N,N,N,N,N,N,N,N,N,37100,N,N,N,N, -N,35822,N,N,N,N,N,N,N,37102,N,N,N,37318,N,N,37106,64700,35444,N,N,N,N,N,N,N,N, -N,38487,N,N,N,40175,N,N,N,N,N,N,N,N,N,N,40927,N,N,N,N,37111,37110,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,39774,N,N,N,37112,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,37113,N,36041,N,N,N,64106,N,N,N,N,N,N,N,N,35823,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40928,N,N,37186,N,39522,N,N,N,N,N,N,N,N,N, -38249,N,N,N,37188,37187,N,37185,N,N,N,35824,N,N,N,N,N,N,N,N,N,N,N,N,N,38496,N, -35825,N,39414,37193,N,N,N,N,37194,N,N,N,N,N,37195,N,N,N,N,39524,N,N,N,35519, -39526,N,N,N,N,N,N,N,N,N,N,39527,N,N,39529,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,39530,38482,37197,N,38502,N,N,N,N,40827,N,39531,N,N,N,N,N,N,N, -41068,N,N,38503,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39532,N,N,N,N,39533,35826,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,38506,N,N,N,N,N,N,N,N,64746,N,N,N,N,N,38508,N,N,N,N, -N,N,N,N,N,N,N,N,N,37316,N,N,N,38519,N,N,N,N,N,N,N,39412,39535,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,40875,N,N,N,N,N,36030,36545,N,N,N,N,38229,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,37202,37203,N,N,N,37205,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38237,N, -38513,N,N,N,N,40045,N,N,N,N,N,N,N,N,38515,N,N,N,N,N,N,N,N,N,N,N,37204,39537,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37206,N,N,N,38509,N,N,N,N, -N,N,38231,N,N,N,N,N,N,N,N,35270,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,35271,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,35434,N,N,N,35671,N,N,N,40929,N,N,39775,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41053,N,N,N,N,N,N,N,N,37211,N,37212,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,37214,N,N,N,N,N,N,N,N,N,N,40796,40791,N,N,N,N,N,N,40805, -N,N,N,N,N,39538,N,N,N,N,37216,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40798, -N,N,37217,N,N,N,N,N,N,37220,N,N,N,N,40769,N,N,N,N,N,N,37225,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,37224,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39540,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38578,N,39541,N,64933,N,N,N,N,N,N,N,40681, -N,35770,37229,41056,N,N,N,N,N,N,N,40926,N,N,N,N,N,40899,N,38581,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,41063,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,38579,N,N,N,N,N,N,N,N,N,N,N,N,N,39542,N,N,N,N,N,N,N,N,N,N,N,38357,N,N,N, -40650,N,N,N,39543,N,N,39544,N,N,N,N,N,N,N,N,N,N,37232,37231,N,N,N,N,N,N,N, -40867,N,37233,N,N,N,38577,N,N,N,N,40803,N,N,N,N,N,40807,N,N,N,35769,39546,N,N, -N,N,N,35670,N,N,N,N,N,N,N,N,39642,N,N,N,N,N,38576,N,N,N,N,39550,N,N,N,N,N,N,N, -N,N,N,40414,N,N,N,N,N,N,N,N,N,38573,N,N,N,38574,N,N,N,N,N,N,N,N,N,40609,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40528,N,N,N,N,N,N,N,N,38575,35828,40868,N,N, -N,N,N,N,N,N,N,38589,N,N,N,N,N,N,N,N,N,38644,N,N,N,N,N,N,N,N,N,N,38584,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,64161,N,N,N,N,37287,N,N,N,N,N,N,N,N,N,N,41054,N,N, -N,N,39549,N,N,N,N,35144,N,40625,N,N,N,N,N,N,N,N,N,N,N,N,N,40411,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,38335,35443,N,N,N,N,N,N,N,N,N,N,N,N,N,40702,N,37242,N,N,N,N, -37243,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39587,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38594,N,N,N,N,N,40823,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39588,N,N,39589,N,N,N, -37281,N,N,N,N,35256,N,N,N,N,N,N,N,N,N,N,37235,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39590,35261,N,35257,N,37245,N,N, -N,N,N,N,N,N,N,38587,N,N,N,40946,N,N,35829,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39593,N,N, -N,N,N,40788,N,N,40931,40685,N,N,N,N,N,N,N,N,N,N,37290,N,N,N,N,37291,41072,N, -40813,N,N,N,N,N,37292,N,N,N,37293,N,N,N,41213,N,40930,N,37295,40513,39594,N,N, -37296,N,39595,N,N,N,N,N,N,N,N,N,N,N,39596,N,39498,N,37298,N,N,35830,N,39597, -35254,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39599,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,39600,N,N,N,N,N,N,39601,N,N,N,N,N,39585,37305,N,N,N,N,N,37306,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,37310,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41025,35767,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37312,N,N,N,N,N,N,N,N,N,N,39603,37315,N,N,N,N,N,N, -N,N,N,N,41212,N,N,40942,N,N,N,N,N,N,40809,N,N,N,N,N,N,N,37320,N,N,N,N,N,N, -37321,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36326,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,37323,N,N,N,N,N,N,N,N,N,N,35272,N,N,N,N,N,36266,N,N,N,N,N,40925,34880, -34881,34882,34883,34884,N,34886,N,N,34889,34890,N,N,34893,N,34895,34896,34897, -34898,N,34900,34901,N,N,N,N,N,N,N,N,N,N,N,N,34914,N,34916,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34979,N,34981,N,N,N,34985,34986,35907,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35949,N,N,N,N,N,N,35956,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36023,N,36025,N,36027,N,N,N,N,36032,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,36055,36056,N,36058,51321,N,N,N,N,51326,51361,N,51363,35832,51408, -N,N,N,N,51407,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,50916,N,50917,N,N,N,N,N,N,N,N,N,N,N,N,N, +37074,N,N,34667,N,37076,N,N,N,N,N,N,N,N,N,39515,38397,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,35780,N,N,N,35942,N,37086,N,N,N,N,N,40164,N,37089,N,N,N,N,N,N,N,N,N,N,N, +N,N,40518,N,N,N,38481,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64344,N,37094, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38480,N,N,N,37095,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,37096,39517,N,40826,N,N,N,39772,N,40828,N,N,64594,37097,N,37098,N, +39518,N,N,N,N,N,40822,N,N,N,N,N,N,N,N,N,37099,N,N,N,N,N,N,N,N,N,N,N,N,N,37100, +N,N,N,N,N,35822,N,N,N,N,N,N,N,37102,N,N,N,37318,N,N,37106,64700,35444,N,N,N,N, +N,N,N,N,N,38487,N,N,N,40175,N,N,N,N,N,N,N,N,N,N,40927,N,N,N,N,37111,37110,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39774,N,N,N,37112,N,N,N,N,N,N,N,N,N,N,36092,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,37113,N,36041,N,N,N,64106,N,N,N,N,N,N,N,N,35823,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40928,N,N,37186,N,39522,N,N,N,N,N, +N,N,N,N,38249,N,N,N,37188,37187,N,37185,N,N,N,35824,N,N,N,N,N,N,N,N,N,N,N,N,N, +38496,N,35825,N,39414,37193,N,N,N,N,37194,N,N,N,N,N,37195,N,N,N,N,39524,N,N,N, +35519,39526,N,N,N,N,N,N,N,N,N,N,39527,N,N,39529,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,39530,38482,37197,N,38502,N,N,N,N,40827,N,39531,N,N,N,N, +N,N,N,41068,N,N,38503,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39532,N,N,N,N,39533,35826, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38506,N,N,N,N,N,N,N,N,64746,N,N,N,N,N,38508,N, +N,N,N,N,N,N,N,N,N,N,N,N,37316,N,N,N,38519,N,N,N,N,N,N,N,39412,39535,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40875,N,N,N,N,N,36030,36545,N,N,N,N,38229,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37202,37203,N,N,N,37205,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38237,N,38513,N,N,N,N,40045,N,N,N,N,N,N,N,N,38515,N,N,N,N,N,N,N,N,N,N,N,37204, +39537,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37206,N,N,N,38509, +N,N,N,N,N,N,38231,N,N,N,N,N,N,N,N,35270,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35271,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,35434,N,N,N,35671,N,N,N,40929,N,N,39775,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41053,N,N,N,N,N,N,N,N,37211,N,37212,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37214,N,N,N,N,N,N,N,N,N,N,40796,40791,N,N,N,N,N, +N,40805,N,N,N,N,N,39538,N,N,N,N,37216,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,40798,N,N,37217,N,N,N,N,N,N,37220,N,N,N,N,40769,N,N,N,N,N,N,37225,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,37224,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39540,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38578,N,39541,N,64933,N,N,N,N, +N,N,N,40681,N,35770,37229,41056,N,N,N,N,N,N,N,40926,N,N,N,N,N,40899,N,38581,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41063,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,38579,N,N,N,N,N,N,N,N,N,N,N,N,N,39542,N,N,N,N,N,N,N,N,N,N,N, +38357,N,N,N,40650,N,N,N,39543,N,N,39544,N,N,N,N,N,N,N,N,N,N,37232,37231,N,N,N, +N,N,N,N,40867,N,37233,N,N,N,38577,N,N,N,N,40803,N,N,N,N,N,40807,N,N,N,35769, +39546,N,N,N,N,N,35670,N,N,N,N,N,N,N,N,39642,N,N,N,N,N,38576,N,N,N,N,39550,N,N, +N,N,N,N,N,N,N,N,40414,N,N,N,N,N,N,N,N,N,38573,N,N,N,38574,N,N,N,N,N,N,N,N,N, +40609,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40528,N,N,N,N,N,N,N,N,38575, +35828,40868,N,N,N,N,N,N,N,N,N,38589,N,N,N,N,N,N,N,N,N,38644,N,N,N,N,N,N,N,N,N, +N,38584,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64161,N,N,N,N,37287,N,N,N,N,N,N,N, +N,N,N,41054,N,N,N,N,39549,N,N,N,N,35144,N,40625,N,N,N,N,N,N,N,N,N,N,N,N,N, +40411,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38335,35443,N,N,N,N,N,N,N,N,N,N,N,N,N,40702, +N,37242,N,N,N,N,37243,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39587,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,38594,N,N,N,N,N,40823,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39588,N, +N,39589,N,N,N,37281,N,N,N,N,35256,N,N,N,N,N,N,N,N,N,N,37235,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39590,35261,N, +35257,N,37245,N,N,N,N,N,N,N,N,N,38587,N,N,N,40946,N,N,35829,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,39593,N,N,N,N,N,40788,N,N,40931,40685,N,N,N,N,N,N,N,N,N,N,37290,N,N,N, +N,37291,41072,N,40813,N,N,N,N,N,37292,N,N,N,37293,N,N,N,41213,N,40930,N,37295, +40513,39594,N,N,37296,N,39595,N,N,N,N,N,N,N,N,N,N,N,39596,N,39498,N,37298,N,N, +35830,N,39597,35254,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39599, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,39600,N,N,N,N,N,N,39601,N,N,N,N,N,39585,37305,N,N, +N,N,N,37306,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37310,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +41025,35767,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37312,N,N,N,N,N,N,N,N,N,N,39603, +37315,N,N,N,N,N,N,N,N,N,N,41212,N,N,40942,N,N,N,N,N,N,40809,N,N,N,N,N,N,N, +37320,N,N,N,N,N,N,37321,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36326,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37323,N,N,N,N,N,N,N,N,N,N,35272,N,N,N,N,N,36266,N,N,N,N, +N,40925,35907,35949,35956,36023,36025,36027,36032,36055,36056,36058,51361, +51363,36077,36168,35832,51408,N,N,N,N,51407,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,50916,N, +50917,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,51405,N, -51406,N,N,N,N,N,N,N,N,63998, +N,N,N,N,N,N,N,N,N,N,N,51405,N,51406,N,N,N,N,N,N,N,N,63998, }; static const struct unim_index big5hkscs_bmp_encmap[256] = { @@ -1343,65 +1353,66 @@ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__big5hkscs_bmp_encmap+506,190, -193},{0,0,0},{0,0,0},{__big5hkscs_bmp_encmap+510,22,231},{0,0,0},{0,0,0},{ -__big5hkscs_bmp_encmap+720,96,125},{__big5hkscs_bmp_encmap+750,80,112},{0,0,0 -},{__big5hkscs_bmp_encmap+783,61,61},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ -0,0,0},{__big5hkscs_bmp_encmap+784,128,227},{__big5hkscs_bmp_encmap+884,51,51 -},{__big5hkscs_bmp_encmap+885,5,254},{0,0,0},{__big5hkscs_bmp_encmap+1135,49, -49},{0,0,0},{__big5hkscs_bmp_encmap+1136,53,251},{__big5hkscs_bmp_encmap+1335, -6,254},{__big5hkscs_bmp_encmap+1584,9,245},{__big5hkscs_bmp_encmap+1821,1,251 -},{__big5hkscs_bmp_encmap+2072,15,250},{__big5hkscs_bmp_encmap+2308,8,254},{ -__big5hkscs_bmp_encmap+2555,1,251},{__big5hkscs_bmp_encmap+2806,14,244},{ -__big5hkscs_bmp_encmap+3037,13,239},{__big5hkscs_bmp_encmap+3264,19,253},{ -__big5hkscs_bmp_encmap+3499,6,255},{__big5hkscs_bmp_encmap+3749,0,250},{ -__big5hkscs_bmp_encmap+4000,4,250},{__big5hkscs_bmp_encmap+4247,3,249},{ -__big5hkscs_bmp_encmap+4494,17,252},{__big5hkscs_bmp_encmap+4730,43,242},{ -__big5hkscs_bmp_encmap+4930,1,244},{__big5hkscs_bmp_encmap+5174,3,233},{ -__big5hkscs_bmp_encmap+5405,6,245},{__big5hkscs_bmp_encmap+5645,19,244},{ -__big5hkscs_bmp_encmap+5871,0,250},{__big5hkscs_bmp_encmap+6122,6,231},{ -__big5hkscs_bmp_encmap+6348,15,255},{__big5hkscs_bmp_encmap+6589,16,192},{ -__big5hkscs_bmp_encmap+6766,4,237},{__big5hkscs_bmp_encmap+7000,9,156},{ -__big5hkscs_bmp_encmap+7148,4,248},{__big5hkscs_bmp_encmap+7393,3,253},{ -__big5hkscs_bmp_encmap+7644,3,252},{__big5hkscs_bmp_encmap+7894,1,254},{ -__big5hkscs_bmp_encmap+8148,2,249},{__big5hkscs_bmp_encmap+8396,1,254},{ -__big5hkscs_bmp_encmap+8650,19,239},{__big5hkscs_bmp_encmap+8871,2,251},{ -__big5hkscs_bmp_encmap+9121,5,253},{__big5hkscs_bmp_encmap+9370,0,254},{ -__big5hkscs_bmp_encmap+9625,3,251},{__big5hkscs_bmp_encmap+9874,2,249},{ -__big5hkscs_bmp_encmap+10122,2,254},{__big5hkscs_bmp_encmap+10375,13,255},{ -__big5hkscs_bmp_encmap+10618,5,245},{__big5hkscs_bmp_encmap+10859,16,245},{ -__big5hkscs_bmp_encmap+11089,9,252},{__big5hkscs_bmp_encmap+11333,12,223},{ -__big5hkscs_bmp_encmap+11545,35,253},{__big5hkscs_bmp_encmap+11764,7,226},{ -__big5hkscs_bmp_encmap+11984,44,229},{__big5hkscs_bmp_encmap+12170,24,254},{ -__big5hkscs_bmp_encmap+12401,7,234},{__big5hkscs_bmp_encmap+12629,10,255},{ -__big5hkscs_bmp_encmap+12875,24,241},{__big5hkscs_bmp_encmap+13093,2,254},{ -__big5hkscs_bmp_encmap+13346,0,202},{__big5hkscs_bmp_encmap+13549,0,250},{ -__big5hkscs_bmp_encmap+13800,3,246},{__big5hkscs_bmp_encmap+14044,5,250},{ -__big5hkscs_bmp_encmap+14290,28,255},{__big5hkscs_bmp_encmap+14518,2,254},{ -__big5hkscs_bmp_encmap+14771,2,250},{__big5hkscs_bmp_encmap+15020,4,248},{ -__big5hkscs_bmp_encmap+15265,3,254},{__big5hkscs_bmp_encmap+15517,5,246},{ -__big5hkscs_bmp_encmap+15759,0,226},{__big5hkscs_bmp_encmap+15986,2,251},{ -__big5hkscs_bmp_encmap+16236,2,248},{__big5hkscs_bmp_encmap+16483,5,220},{ -__big5hkscs_bmp_encmap+16699,2,217},{__big5hkscs_bmp_encmap+16915,12,254},{ -__big5hkscs_bmp_encmap+17158,8,245},{__big5hkscs_bmp_encmap+17396,6,244},{ -__big5hkscs_bmp_encmap+17635,6,254},{__big5hkscs_bmp_encmap+17884,11,252},{ -__big5hkscs_bmp_encmap+18126,18,252},{__big5hkscs_bmp_encmap+18361,37,254},{ -__big5hkscs_bmp_encmap+18579,7,223},{__big5hkscs_bmp_encmap+18796,6,250},{ -__big5hkscs_bmp_encmap+19041,2,246},{__big5hkscs_bmp_encmap+19286,3,246},{ -__big5hkscs_bmp_encmap+19530,24,255},{__big5hkscs_bmp_encmap+19762,11,237},{ -__big5hkscs_bmp_encmap+19989,5,248},{__big5hkscs_bmp_encmap+20233,3,252},{ -__big5hkscs_bmp_encmap+20483,2,239},{__big5hkscs_bmp_encmap+20721,112,245},{ -__big5hkscs_bmp_encmap+20855,4,255},{__big5hkscs_bmp_encmap+21107,0,231},{ -__big5hkscs_bmp_encmap+21339,28,234},{__big5hkscs_bmp_encmap+21546,12,226},{ -__big5hkscs_bmp_encmap+21761,81,247},{__big5hkscs_bmp_encmap+21928,3,212},{ -__big5hkscs_bmp_encmap+22138,1,242},{__big5hkscs_bmp_encmap+22380,25,249},{ -__big5hkscs_bmp_encmap+22605,8,196},{__big5hkscs_bmp_encmap+22794,81,254},{ -__big5hkscs_bmp_encmap+22968,8,253},{__big5hkscs_bmp_encmap+23214,3,244},{ -__big5hkscs_bmp_encmap+23456,1,246},{__big5hkscs_bmp_encmap+23702,45,244},{ -__big5hkscs_bmp_encmap+23902,29,244},{__big5hkscs_bmp_encmap+24118,3,245},{ -__big5hkscs_bmp_encmap+24361,20,245},{__big5hkscs_bmp_encmap+24587,14,245},{ -__big5hkscs_bmp_encmap+24819,12,255},{__big5hkscs_bmp_encmap+25063,2,255},{ -__big5hkscs_bmp_encmap+25317,2,124},{__big5hkscs_bmp_encmap+25440,2,252},{ -__big5hkscs_bmp_encmap+25691,10,254},{__big5hkscs_bmp_encmap+25936,2,165},{0, +193},{0,0,0},{0,0,0},{__big5hkscs_bmp_encmap+510,22,231},{0,0,0},{ +__big5hkscs_bmp_encmap+720,218,219},{__big5hkscs_bmp_encmap+722,96,125},{ +__big5hkscs_bmp_encmap+752,80,112},{0,0,0},{__big5hkscs_bmp_encmap+785,61,61}, +{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__big5hkscs_bmp_encmap+786, +128,227},{__big5hkscs_bmp_encmap+886,51,51},{__big5hkscs_bmp_encmap+887,5,254 +},{__big5hkscs_bmp_encmap+1137,192,207},{__big5hkscs_bmp_encmap+1153,49,49},{ +0,0,0},{__big5hkscs_bmp_encmap+1154,53,251},{__big5hkscs_bmp_encmap+1353,6,254 +},{__big5hkscs_bmp_encmap+1602,9,245},{__big5hkscs_bmp_encmap+1839,1,251},{ +__big5hkscs_bmp_encmap+2090,15,250},{__big5hkscs_bmp_encmap+2326,8,254},{ +__big5hkscs_bmp_encmap+2573,1,251},{__big5hkscs_bmp_encmap+2824,14,244},{ +__big5hkscs_bmp_encmap+3055,13,239},{__big5hkscs_bmp_encmap+3282,18,253},{ +__big5hkscs_bmp_encmap+3518,6,255},{__big5hkscs_bmp_encmap+3768,0,250},{ +__big5hkscs_bmp_encmap+4019,4,250},{__big5hkscs_bmp_encmap+4266,2,249},{ +__big5hkscs_bmp_encmap+4514,17,252},{__big5hkscs_bmp_encmap+4750,43,242},{ +__big5hkscs_bmp_encmap+4950,1,244},{__big5hkscs_bmp_encmap+5194,3,234},{ +__big5hkscs_bmp_encmap+5426,3,247},{__big5hkscs_bmp_encmap+5671,19,244},{ +__big5hkscs_bmp_encmap+5897,0,250},{__big5hkscs_bmp_encmap+6148,6,231},{ +__big5hkscs_bmp_encmap+6374,15,255},{__big5hkscs_bmp_encmap+6615,16,192},{ +__big5hkscs_bmp_encmap+6792,4,237},{__big5hkscs_bmp_encmap+7026,7,156},{ +__big5hkscs_bmp_encmap+7176,4,248},{__big5hkscs_bmp_encmap+7421,3,253},{ +__big5hkscs_bmp_encmap+7672,3,252},{__big5hkscs_bmp_encmap+7922,1,254},{ +__big5hkscs_bmp_encmap+8176,2,249},{__big5hkscs_bmp_encmap+8424,1,254},{ +__big5hkscs_bmp_encmap+8678,19,239},{__big5hkscs_bmp_encmap+8899,2,251},{ +__big5hkscs_bmp_encmap+9149,5,253},{__big5hkscs_bmp_encmap+9398,0,254},{ +__big5hkscs_bmp_encmap+9653,3,251},{__big5hkscs_bmp_encmap+9902,2,249},{ +__big5hkscs_bmp_encmap+10150,2,254},{__big5hkscs_bmp_encmap+10403,13,255},{ +__big5hkscs_bmp_encmap+10646,5,252},{__big5hkscs_bmp_encmap+10894,16,245},{ +__big5hkscs_bmp_encmap+11124,9,252},{__big5hkscs_bmp_encmap+11368,12,223},{ +__big5hkscs_bmp_encmap+11580,35,253},{__big5hkscs_bmp_encmap+11799,7,226},{ +__big5hkscs_bmp_encmap+12019,44,229},{__big5hkscs_bmp_encmap+12205,24,254},{ +__big5hkscs_bmp_encmap+12436,7,234},{__big5hkscs_bmp_encmap+12664,10,255},{ +__big5hkscs_bmp_encmap+12910,24,241},{__big5hkscs_bmp_encmap+13128,2,254},{ +__big5hkscs_bmp_encmap+13381,0,202},{__big5hkscs_bmp_encmap+13584,0,250},{ +__big5hkscs_bmp_encmap+13835,3,246},{__big5hkscs_bmp_encmap+14079,5,250},{ +__big5hkscs_bmp_encmap+14325,28,255},{__big5hkscs_bmp_encmap+14553,2,254},{ +__big5hkscs_bmp_encmap+14806,2,250},{__big5hkscs_bmp_encmap+15055,4,248},{ +__big5hkscs_bmp_encmap+15300,3,254},{__big5hkscs_bmp_encmap+15552,5,246},{ +__big5hkscs_bmp_encmap+15794,0,226},{__big5hkscs_bmp_encmap+16021,2,251},{ +__big5hkscs_bmp_encmap+16271,2,248},{__big5hkscs_bmp_encmap+16518,5,220},{ +__big5hkscs_bmp_encmap+16734,2,217},{__big5hkscs_bmp_encmap+16950,12,254},{ +__big5hkscs_bmp_encmap+17193,8,245},{__big5hkscs_bmp_encmap+17431,6,244},{ +__big5hkscs_bmp_encmap+17670,6,254},{__big5hkscs_bmp_encmap+17919,11,252},{ +__big5hkscs_bmp_encmap+18161,18,252},{__big5hkscs_bmp_encmap+18396,37,254},{ +__big5hkscs_bmp_encmap+18614,7,223},{__big5hkscs_bmp_encmap+18831,6,250},{ +__big5hkscs_bmp_encmap+19076,2,246},{__big5hkscs_bmp_encmap+19321,3,246},{ +__big5hkscs_bmp_encmap+19565,24,255},{__big5hkscs_bmp_encmap+19797,11,237},{ +__big5hkscs_bmp_encmap+20024,5,248},{__big5hkscs_bmp_encmap+20268,3,252},{ +__big5hkscs_bmp_encmap+20518,2,239},{__big5hkscs_bmp_encmap+20756,112,245},{ +__big5hkscs_bmp_encmap+20890,4,255},{__big5hkscs_bmp_encmap+21142,0,231},{ +__big5hkscs_bmp_encmap+21374,28,249},{__big5hkscs_bmp_encmap+21596,12,226},{ +__big5hkscs_bmp_encmap+21811,81,247},{__big5hkscs_bmp_encmap+21978,3,212},{ +__big5hkscs_bmp_encmap+22188,1,242},{__big5hkscs_bmp_encmap+22430,25,249},{ +__big5hkscs_bmp_encmap+22655,8,196},{__big5hkscs_bmp_encmap+22844,81,254},{ +__big5hkscs_bmp_encmap+23018,8,253},{__big5hkscs_bmp_encmap+23264,3,244},{ +__big5hkscs_bmp_encmap+23506,1,246},{__big5hkscs_bmp_encmap+23752,45,244},{ +__big5hkscs_bmp_encmap+23952,29,244},{__big5hkscs_bmp_encmap+24168,3,245},{ +__big5hkscs_bmp_encmap+24411,20,245},{__big5hkscs_bmp_encmap+24637,14,245},{ +__big5hkscs_bmp_encmap+24869,12,255},{__big5hkscs_bmp_encmap+25113,2,255},{ +__big5hkscs_bmp_encmap+25367,2,124},{__big5hkscs_bmp_encmap+25490,2,252},{ +__big5hkscs_bmp_encmap+25741,10,254},{__big5hkscs_bmp_encmap+25986,2,179},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, @@ -1410,13 +1421,12 @@ },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 -},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__big5hkscs_bmp_encmap+26100,3,75}, -{0,0,0},{__big5hkscs_bmp_encmap+26173,122,239},{0,0,0},{__big5hkscs_bmp_encmap -+26291,229,237},{0,0,0},{__big5hkscs_bmp_encmap+26300,7,7},{0,0,0},{0,0,0},{0, -0,0},{0,0,0},{0,0,0},{__big5hkscs_bmp_encmap+26301,2,237}, +},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, +0,0},{0,0,0},{__big5hkscs_bmp_encmap+26164,7,7},{0,0,0},{0,0,0},{0,0,0},{0,0,0 +},{0,0,0},{__big5hkscs_bmp_encmap+26165,2,237}, }; -static const DBCHAR __big5hkscs_nonbmp_encmap[28325] = { +static const DBCHAR __big5hkscs_nonbmp_encmap[29306] = { 40049,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37749,N,N,N,N,N, N,N,37750,N,N,N,N,N,N,N,38216,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,36550,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35781,35834, @@ -1427,34 +1437,34 @@ N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,35501,N,37490,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64583,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38111,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,40913,64459,N,N,N,N,N,N,N,37501,N,N,N,N,N,N,N, +N,N,N,N,N,N,36085,N,N,N,N,35501,N,37490,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,64583,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38111,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40913,64459,N,N,N,N,N,N,N,37501,N,N,N,N,N,N,N, 39076,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38119,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37067,37499,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38104,N,N,N,N,64607,N,64084,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39605,N,N,N,N,N,N,N,38618,37497,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64116, -37493,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36347,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35401,N,N,N,37599,39804,64099,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,64096,37485,64098,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,39606,N,N,N,N,N,N,38763,N,N,N,N,N,N,N,N,N,N,N,N,N, -64874,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64852,N,37491,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38872,N,N,N,N,N, -N,40891,37698,37494,N,N,N,N,N,N,N,N,N,N,64101,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37484,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,64110,N,N,N,N,N,N,40672,N,N,37568,37567,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,37566,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39610,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35507,N,38773,64064,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64118,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,64464,N,N,N,N,N,N,N,N,N,N,N,N,N,64123,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,65133,N,N,N,N,N,N,39859,N,N,N,N,N,35276,N,N,N,N,39614,N,N,N,N,N,N, -N,N,N,64066,37564,N,N,N,N,N,N,N,N,N,N,37980,39861,N,N,N,39615,N,N,N,39079, +36089,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38119, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37067,37499,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38104,N,N,N,N,64607,N, +64084,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39605,N,N,N,N,N,N,N,38618, +37497,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64116,37493,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36347,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35401,N,N,N,37599,39804,64099,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,64096,37485,64098,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39606,N,N,N,N,N,N,38763,N,N,N,N,N,N,N,N,N,N,N,N, +N,64874,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64852,N,37491,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38872,N,N,N,N, +N,N,40891,37698,37494,N,N,N,N,N,N,N,N,N,N,64101,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37484,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,64110,N,N,N,N,N,N,40672,N,N,37568,37567,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,37566,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39610,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35507,N,38773,64064,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64118,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,64464,N,N,N,N,N,N,N,N,N,N,N,N,N,64123,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,65133,N,N,N,N,N,N,39859,N,N,N,N,N,35276,N,N,N,N,39614,N,N,N,N,N, +N,N,N,N,64066,37564,N,N,N,N,N,N,N,N,N,N,37980,39861,N,N,N,39615,N,N,N,39079, 38820,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37117,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64635,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39616,37571,N,N,N,N,N,N,N,N,N,N,N,N,N, @@ -1473,38 +1483,38 @@ N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35250,40038,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36947,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,35938,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,38849,N,N,N,N,N,N,N,N,N,N,N,N,N,39620,N,N,N,N,N,N,N,N,N,N,39621,36591,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38849,N,N,N,N,N,N,N,N,N,N,N,N,N,39620,N,N,N,N,N,N,N,N,N,N,39621,36591,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,64233,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37474, -35575,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39622,N,N,N,N,N,N,37601,N,N,N, -N,39625,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64198,N,N,N,N,N,N,N,N, -38821,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39627,N,N,N,64114,35422,N,38112,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,37580,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35557,N, -N,N,N,N,65116,39628,N,N,N,N,N,40441,35395,35494,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39629,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39630,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,64238,39884,N,N,N,39631,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39633,N,N,N,N,N,N,N, -N,40442,N,N,N,N,N,40316,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39635, -N,N,38822,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39263,N,N,N,64502,40901, -35417,35691,N,N,N,N,N,N,39636,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39637,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,38818,35396,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40778,N, -N,N,N,N,N,N,N,37025,64932,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35428,35570, -35576,40408,N,N,38102,64254,64423,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,39638,N,40781,N,N,64246,N,N,N,N,N,N,N,35415,N,35651,35652, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35510,N,N,N,N,N,35520,N,N,N,N,N,N, -N,N,N,N,40532,N,N,N,N,N,N,N,N,N,N,39639,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,39640,39644,N,N,N,N,35530,40616,N,N,37475,39645,35685,35695,35710,N,N,N,N, -36675,N,N,N,N,N,N,37584,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35572,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40382,N,N,N,N,N,39649,N,64734,40445,35686,35696, -35701,35556,35748,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35565,N,N,N,N,N,N,N,N,N, -35421,N,35656,N,N,N,N,40429,N,N,N,N,40512,N,N,N,N,N,N,N,35567,35574,40566,N,N, -N,N,N,N,N,N,N,40675,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,39646,36350,N,N,N,N,64252,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,40113,40567,35684,35687,38731,N,N,N,N,N,N,N,N,38483,N,N,N,N,N,N,39648, +N,N,N,N,N,N,N,N,N,N,64233,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36160,N,N,N,N,N,N,N,N, +37474,35575,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39622,N,N,N,N,N,N,37601, +N,N,N,N,39625,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64198,N,N,N,N,N,N,N, +N,38821,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39627,N,N,N,64114,35422,N,38112,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,37580,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35557, +N,N,N,N,N,65116,39628,N,N,N,N,N,40441,35395,35494,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,39629,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39630,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,64238,39884,N,N,N,39631,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39633,N,N,N,N,N,N, +N,N,40442,N,N,N,N,N,40316,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39635,N,N,38822,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39263,N,N,N,64502, +40901,35417,35691,N,N,N,N,N,N,39636,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39637,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,38818,35396,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40778,N,N,N,N,N,N,N,N,37025,64932,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35428, +35570,35576,40408,N,N,38102,64254,64423,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,39638,N,40781,N,N,64246,N,N,N,N,N,N,N,35415,N,35651, +35652,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35510,N,N,N,N,N,35520,N,N,N, +N,N,N,N,N,N,N,40532,N,N,N,N,N,N,N,N,N,N,39639,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39640,39644,N,N,N,N,35530,40616,N,N,37475,39645,35685,35695,35710,N, +N,N,N,36675,N,N,N,N,N,N,37584,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35572,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40382,N,N,N,N,N,39649,N,64734,40445,35686, +35696,35701,35556,35748,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35565,N,N,N,N,N,N,N,N, +N,35421,N,35656,N,N,N,N,40429,N,N,N,N,40512,N,N,N,N,N,N,N,35567,35574,40566,N, +N,N,N,N,N,N,N,N,40675,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,39646,36350,N,N,N,N,64252,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,40113,40567,35684,35687,38731,N,N,N,N,N,N,N,N,38483,N,N,N,N,N,N,39648, 35658,N,35569,35543,N,N,N,N,N,N,N,N,N,41131,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, 35509,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35423,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35566,N,N,39647,N, @@ -1574,151 +1584,152 @@ N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64076,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37623,39744,N,N,N,N,N,N,64462,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,39745,N,N,N,N,N,65197,64469,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,39745,N,N,N,N,N,65197,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,34657,64469,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35778,39548,39746,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39747,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35778,39548,39746,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,40569,N,N,64473,N,N,N,N,N,N,39748,41127,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39747,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40569,N,N,64473,N,N, +N,N,N,N,39748,41127,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34670,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39923,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35961,N,N,N,37726,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,35275,N,N,N,N,N,N,40787,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,37847,N,N,N,N,N,N,N,N,N,N,N,N,N,64481,65232,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,64482,N,N,N,N,N,64739,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,39923,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,35961,N,N,N,37726,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35275,N,N,N,N, +N,N,40787,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37847,N,N,N,N,N,N, +N,N,N,N,N,N,N,64481,65232,N,N,N,N,N,N,36081,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,64482,N,N,N,N,N,64739,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36980,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,64486,N,N,N,39863,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,39749,N,N,N,N,N,N,N,N,N,N,N,N,39751,40784,N,N,N,N,N,39752, +N,N,N,N,N,N,N,N,N,N,36980,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64486,N,N,N,39863,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,39749,N,N,N,N,N,N,N,N,N,N,N,N,39751,40784,N,N,N,N,N,39752,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64603, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,64603,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39081,N,N,40189,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,39081,N,N,40189,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34892,39755,N,N,N,64492,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,35945,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39848,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,35541,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64115,64857,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37282,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64493,N,N,N,N,N,N,40105,N, +N,N,N,N,N,N,N,N,N,N,N,N,34892,39755,N,N,N,64492,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35496,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39875, -35553,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35945,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39848,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35541,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64115,64857,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37282,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64493,N,N,N,N,N,N,40105,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35496,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36162,N,39875,35553,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,39758,38352,N,N,N,36959,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39758,38352,N, +N,N,36959,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,38894,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64590,N,N,N,N,N,N, -39759,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39760,40646,N,N,N,N,N,N,N,N,N,N,N,64592,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,64883,N,N,N,N,N,64935,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,40354,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64088,64094,N, -N,N,N,N,N,N,41049,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64117,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64446,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40098,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,37744,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37745,37751,65263,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,37741,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64605,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,37048,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,35580,N,64321,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40555,38115,36578,35965,N,36567, -N,N,N,N,N,N,40013,N,N,N,38563,N,N,N,N,N,N,N,N,N,N,39761,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35523,N,N,N,N,N,N,N,N,N,N,N, -38570,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,64616,35693,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,64871,35561,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64673,37740,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,39762,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65136,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,64680,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64745,40116,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,35562,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39763,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39765,N,N,N,38571,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64679,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39766,35516,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35531,N,N,N,N, -N,39767,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35277,N,39769,39771,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,37797,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,39773,N,N,N,40527,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,37795,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35451,N,N,N,35650, -38736,36787,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35408,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,39776,N,N,N,N,35653,N,N,N,35654,N,N,N,N,N,N,N,N,N,N,N,N,40446,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39778,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37755,N,N,N,N,N,37809,N,N,N,N,N,N,N,35424,N,N, -N,N,N,N,N,N,35544,N,N,N,N,39779,N,N,N,N,N,N,N,N,N,N,35433,N,N,N,35399,N,N, -35532,37756,39781,N,N,N,N,N,N,N,N,N,39782,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35442,N,N,N,N,N, -N,N,35450,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37807,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35504,N,N,N,N, -N,N,N,39784,N,N,N,N,N,N,N,N,N,N,40611,N,N,64236,35703,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,39783,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35673,64689,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64699,N,N,N,N,N, -N,N,N,N,N,N,39785,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37800,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,35552,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,40529,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36703,39786,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,39787,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38892,39788,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65102,N,N,N,N,N,N,64962,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,39789,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37223,64716,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37814,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37092,N,N,N,N,37093,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40690,37834,N,N,N,N,N,N,N,N, +38894,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64590,N,N,N,N,N,N,39759,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39760,40646,N,N,N,N,N, +N,N,N,N,N,N,64592,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64883,N,N, +N,N,N,64935,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40354, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,35772,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64088,64094,N,N,N,N,N,N,N,41049,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64117,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64446,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36678,N,N,N,N,37839,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,64731,64732,N,N,N,N,N,N,N,N,N,N,N,N,N,37824,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,64742,38631,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64728,64729,64934,37838,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,38385,N,N,N,N,N,N,N,N,N,40169,N,64740,38063,64119, -37836,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,36954,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,35924,N,N,N,N,N,N,N,37823,64337,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,37817,65239,37815,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37849,N,N,N,N,N,N,N,N,N,N,N,N,N,37819, -37850,39075,N,N,N,N,N,N,N,N,N,37073,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39790,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64112,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39915,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,39791,N,N,N,N,N,N,N,64764,N,N,N,N,N,N,N,N,N,N,N,N,N,35648,41083,N,N,N, -36001,38903,N,N,N,37858,64726,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38233,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37798,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,64832,N,N,37727,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38898,40054,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,36600,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,36679,N,N,N,N,N,N,N,N,N,N,N,N,39796,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37556, -N,N,N,37357,N,N,38610,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64838,36687,38217,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39797,64092,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39801,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,64843,N,N,N,38611,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,64856,N,N,N,N,N,37983,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,41205,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,37443,N,N,N,N,N,N,38906,N,N,N,N,N,N,N,N,N,N,N,N, +40098,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37744, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,37745,37751,65263,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +37741,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64605,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,37048,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35580,N, +64321,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40555,38115,36578,35965,N,36567,N,N,N,N,N,N, +40013,N,N,N,38563,N,N,N,N,N,N,N,N,N,N,39761,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35523,N,N,N,N,N,N,N,N,N,N,N,38570,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36066,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,64616,35693,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64871,35561,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64673,37740,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,39762,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65136,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,64680,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64745,40116,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,35562,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39763,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39765,N,N,N,38571,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,64679,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39766,35516,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35531,N,N,N,N,N,39767,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,35277,N,39769,39771,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,37797,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39773,N,N, +N,40527,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,37795,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35451,N,N,N,35650,38736,36787,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35408,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39776,N,N,N,N,35653,N,N,N,35654,N,N,N,N,N,N,N,N,N,N,N,N,40446,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39778,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37755,N,N,N,N,N,37809,N,N,N,N,N,N,N,35424,N,N,N,N,N,N,N, +N,35544,N,N,N,N,39779,N,N,N,N,N,N,N,N,N,N,35433,N,N,N,35399,N,N,35532,37756, +39781,N,N,N,N,N,N,N,N,N,39782,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35442,N,N,N,N,N,N,N,35450,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37807,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35504,N,N,N,N,N,N,N,39784, +N,N,N,N,N,N,N,N,N,N,40611,N,N,64236,35703,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39783,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35673,64689,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64699,N,N,N,N,N,N,N,N,N,N,N, +39785,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37800,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35552,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,40529,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36703,39786,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,39787,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38892,39788,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,65102,N,N,N,N,N,N,64962,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,39789,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37223, +64716,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37814,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37092,N,N,N,N,37093,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40690,37834,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,35772,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36678,N,N, +N,N,37839,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64731,64732,N,N,N,N,N,N,N,N,N,N,N,N,N,37824,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,64742,38631,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64728,64729,64934,37838,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,38385,N,N,N,N,N,N,N,N,N,40169,N,64740,38063,64119,37836,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36065,N,N,N,N,N, +N,N,N,N,N,N,36954,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35924,N,N,N,N,N,N,N,37823,64337,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,37817,65239,37815,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37849,N,N,N,N,N,N,N,N,N,N,N,N,N,37819,37850, +39075,N,N,N,N,N,N,N,N,N,37073,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39790,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64112,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39915,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39791,N,N,N,N,N,N,N,64764,N,N,N,N,N,N,N,N,N,N,N,N,N,35648,41083,N,N,N,36001, +38903,N,N,N,37858,64726,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38233,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37798,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,64832,N,N,37727,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,38898,40054,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,36600,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36075,N,N,N,N,N,N,N,N,36679,N,N,N,N,N,N,N,N,N,N,N,N,39796,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37556,N, +N,N,37357,N,N,38610,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64838,36687,38217,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39797,64092,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,34641,N,N,39801,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64843,N,N,N,38611,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,64856,N,N,N,N,N,37983,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,41205,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,37443,N,N,N,N,N,N,38906,N,N,N,N,N,N,N,N,N,N,N,N, 40409,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, 38900,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37453,64859,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,39802,N,N,N,N,N,N,N,N,N,40661,N,N,N,N,N,N,N,N,N,N,N,N,64174,N,40137,N,N,N, @@ -1729,418 +1740,442 @@ N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37868,38902,38607,37854,35535,39842,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,64873,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37714,N,N,N,N,N,N, -N,N,N,N,N,39074,64878,36004,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64124,37882,36988,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36711,N,40375,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,41193,64078,64929,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40564,40895,40651,39865, -40404,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38841,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36593,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,38267,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40658,38739,38564,36798,38105,36952,64889,64891,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36570,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36602,39845,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,40665,38868,37051,64956,64966,37448,N,N,N,N,N,N,N,37557,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40385, -37561,37542,36683,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39846,N,N,N,N,N,37558,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,36416,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,40664,37982,39007,38094,37450,64880,37991,N,N,N,N,N,N,N,N,N,N,N, -36332,N,N,N,N,N,N,N,N,39896,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37960,64193,40183,64958, -N,N,N,N,N,N,N,N,N,N,N,N,36826,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,64985,N,N,64638,N,N,N,N,N,N,N,N,37881,N,N,N,N,64067,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64235, -64195,38867,38393,40008,64984,41176,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64983,64330,39855,37963,64969,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36524,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64946,N,N,N,N,N,37466, -64701,37593,N,N,N,64981,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37597,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37465,38586,N,N,N,N,N,N,N,N,N,N,37467,N,N,N,N,N, -N,N,N,N,39851,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,64986,64990,N,N,N,64979,N,N,N,N,N,N,N,N,N,35910,N,N,N,N,N,N,64982, -64988,64989,N,N,N,N,37118,N,N,65185,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,35757,N,N,40152,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,40557,64892,64353,N,N,N,N,N,N,38648,N,N,N,N,N,N,N,N, -38640,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64756,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,65120,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38994,38479,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37230,N,N,N,N,N,N,N,N,N,N,39021,N,N,39012,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37971,65004,64376,N,N,N,N,N,N, -N,N,N,N,N,38330,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39005,N,37625,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,39002,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65014,N, -N,N,N,N,N,N,37840,39010,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,39853,N,N,N,N,N,N,N,N,N,N,N,38735,39854,N,N,N,N,N,N,N,N,N,N,N, -N,37970,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39856,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,37330,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,38890,64363,37297,65011,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,37579,N,N,N,N,N,N,N,N,N,39857,N,N,N,N,N,64748,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39019,N,N,N,38737,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -39025,38383,N,N,N,N,N,N,N,40691,N,N,N,N,N,37352,39866,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64332, -37482,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -65016,39009,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37351,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,37869,38724,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37345,N,N,64501,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,39017,N,N,N,N,35426,N,N,39867,36008,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40021,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36471,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35506, -40636,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37862,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39074,36071,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64878, +36004,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64124,37882,36988,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,36711,N,40375,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41193, +64078,64929,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40564,40895,40651,39865,40404,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38841,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36593,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38267, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40658,38739,38564,36798,38105,36952,64889,64891,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36570,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,36602,34658,N,N,N,N,N,N,N,N,N,N,39845,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,40665,38868,37051,64956,64966,37448,N,N,N,N,N,N,N, +37557,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,40385,37561,37542,36683,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39846,N,N,N,N,N,37558,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36416,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,40664,37982,39007,38094,37450,64880,37991,N,N,N,N,N,N,N, +N,N,N,N,36332,N,N,N,N,N,N,N,N,39896,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,34659,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37960,64193, +40183,64958,N,N,N,N,N,N,N,N,N,N,N,N,36826,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64985,N,N,64638,N,N,N,N,N,N,N,N,37881,N,N, +N,N,64067,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,64235,64195,38867,38393,40008,64984,41176,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64983,64330,39855,37963,64969, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36524,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64946,N,N, +N,N,N,37466,64701,37593,N,N,N,64981,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37597,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37465,N,N,N,N,N,N,N,N,N,N,36080, +38586,N,N,N,N,N,N,N,N,N,N,37467,N,N,N,N,N,N,N,N,N,39851,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64986,64990,N,N,N,64979,N, +N,N,N,N,N,N,N,N,35910,N,N,N,N,N,N,64982,64988,64989,N,N,N,N,37118,N,N,65185,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35757,N,N,40152,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40557,64892, +64353,N,N,N,N,N,N,38648,N,N,N,N,N,N,N,N,38640,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64756,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65120,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38994,38479,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37230,N,N,N, +N,N,N,N,N,N,N,39021,N,N,39012,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,37971,65004,64376,N,N,N,N,N,N,N,N,N,N,N,38330,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,39005,N,37625,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39002,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,34640,N,65014,N,N,N,N,N,N,N,37840,39010,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39853,N,N,N,N,N,N,N, +N,N,N,N,38735,39854,N,N,N,N,N,N,N,N,N,N,N,N,37970,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,39856,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37330,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38890,64363,37297,65011,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37579,N,N,N, +N,N,N,N,N,N,39857,N,N,N,N,N,64748,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,39019,N,N,N,38737,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39025,38383,N,N,N,N,N,N,N,40691,N,N,N,N, +N,37352,39866,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64332,37482,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65016,39009,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,37351,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37869,38724,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,37345,N,N,64501,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39017,N,N,N,N, +35426,N,N,39867,36008,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40021,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,36471,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35506,40636,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +37862,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37794,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39869,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38067,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37757,40550,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37977,N,N,N,N,N,N,N,N,N,39871,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,37976,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40613,39879,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,65108,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36468,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,35798,N,N,N,N,N,N,38070,64884,39104,38053,N,N,N,N,N,N,N, +39880,N,N,N,38381,64894,64491,N,N,N,N,N,N,N,N,N,N,64893,N,N,N,N,N,N,N,N,N, +38767,37985,N,40897,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38359,N,N,N, +64082,40024,N,N,N,N,N,N,N,N,N,40808,39911,64718,38632,64073,38817,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38221,40696,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,65097,37326,38769,N,N,N,N,36047,N,N,N,64945,N,N,64622,N,N,N,N,N, +40178,37816,36931,38745,38103,65126,38013,64623,N,N,N,N,37446,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64109,N,N,36599,N,64439,N,38012,37581,38834,N,N,N,N,N,N,N,N,N, +65125,38526,38744,39799,37327,N,N,N,N,N,N,N,N,N,38052,N,N,N,N,N,N,N,N,N,N, +40109,N,N,N,N,N,N,N,N,N,35755,N,N,N,38613,64691,N,N,N,37806,N,38765,N,N,N,N,N, +N,37958,38391,N,N,N,N,N,N,N,N,40006,38235,37329,38132,N,65127,37541,N,N,N, +65247,36011,N,39881,N,N,N,N,N,N,N,N,N,N,N,64749,65018,64712,65122,37372,65131, +65017,64711,37198,40120,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38759,N,N,N, +38382,N,N,39858,N,N,N,N,37984,N,N,N,38050,39029,38828,37331,N,N,N,N,N,N,N,N,N, +N,N,39035,N,N,N,N,N,N,N,36587,38762,38494,N,N,N,N,N,N,N,N,N,38891,N,N,N,N,N, +40953,38392,65186,36838,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65150,N,N,N,N,N,N, +40356,38760,36588,38077,N,N,N,N,N,N,N,N,N,N,N,N,N,37979,40182,64167,39897,N,N, +N,N,N,N,N,N,N,64093,38486,38754,N,N,N,N,N,N,38074,41039,37592,N,N,N,39883,N,N, +N,N,N,N,38075,N,N,40287,N,N,N,N,N,N,37071,N,N,N,N,N,N,N,N,N,N,N,N,N,37989,N,N, +40780,N,N,N,N,N,N,37080,36187,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40638,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,64365,38346,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,40386,38904,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36860,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38003, +38004,N,N,N,N,N,N,N,N,N,N,N,N,65207,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,37794,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39869,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38067,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,37757,40550,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37977,N,N,N,N,N,N,N,N,N,39871,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35403,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37976,N,N,N,N, +35413,35689,35548,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35702,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39886,N,35432,41208,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,39135,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,65205,N,N,N,39887,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38651,N, +N,39931,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40654,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36581,N, +N,N,N,N,N,N,N,N,40571,39890,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,35493,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,65230,35397,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,40444,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65231,35749,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35914,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,35564,N,N,64736,38061,65237,38060,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40613,39879,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65108,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +64602,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39894, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,35439,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35753,36447,N,N,40395,N, +64743,39895,N,N,N,N,N,N,N,N,N,N,N,37832,N,N,N,N,N,N,N,N,N,37360,36832,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39899,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37101,N,39900,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36179,41196,N,N,N, +39162,N,N,N,N,N,N,N,N,N,39904,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,37831,37449,38625,39906,N,N,N,39908,N,N,36833,39909,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38080,N,N,37827,N,N,N,N,N,N,N,N,N,N,37829,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36985,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38779,N,N,N,N,N, +36990,N,N,N,N,65254,65094,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40376,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,37488,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38312,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,36016,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,38088,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39097,37184,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64702,N,N,N,N,N,N,N,37207,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35762,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64223,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,36468,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35798,N,N,N,N,N,N, -38070,64884,39104,38053,N,N,N,N,N,N,N,39880,N,N,N,38381,64894,64491,N,N,N,N,N, -N,N,N,N,N,64893,N,N,N,N,N,N,N,N,N,38767,37985,N,40897,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,38359,N,N,N,64082,40024,N,N,N,N,N,N,N,N,N,40808,39911,64718, -38632,64073,38817,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38221,40696,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65097,37326,38769,N,N,N,N,36047,N, -N,N,64945,N,N,64622,N,N,N,N,N,40178,37816,36931,38745,38103,65126,38013,64623, -N,N,N,N,37446,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64109,N,N,36599,N,64439,N,38012, -37581,38834,N,N,N,N,N,N,N,N,N,65125,38526,38744,39799,37327,N,N,N,N,N,N,N,N,N, -38052,N,N,N,N,N,N,N,N,N,N,40109,N,N,N,N,N,N,N,N,N,35755,N,N,N,38613,64691,N,N, -N,37806,N,38765,N,N,N,N,N,N,37958,38391,N,N,N,N,N,N,N,N,40006,38235,37329, -38132,N,65127,37541,N,N,N,65247,36011,N,39881,N,N,N,N,N,N,N,N,N,N,N,64749, -65018,64712,65122,37372,65131,65017,64711,37198,40120,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,38759,N,N,N,38382,N,N,39858,N,N,N,N,37984,N,N,N,38050,39029, -38828,37331,N,N,N,N,N,N,N,N,N,N,N,39035,N,N,N,N,N,N,N,36587,38762,38494,N,N,N, -N,N,N,N,N,N,38891,N,N,N,N,N,40953,38392,65186,36838,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,65150,N,N,N,N,N,N,40356,38760,36588,38077,N,N,N,N,N,N,N,N,N,N,N,N,N, -37979,40182,64167,39897,N,N,N,N,N,N,N,N,N,64093,38486,38754,N,N,N,N,N,N,38074, -41039,37592,N,N,N,39883,N,N,N,N,N,N,38075,N,N,40287,N,N,N,N,N,N,37071,N,N,N,N, -N,N,N,N,N,N,N,N,N,37989,N,N,40780,N,N,N,N,N,N,37080,40638,N,N,N,N,N,N,N,N,N,N, +N,39910,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38467,36420,40015,65268, +N,N,N,N,N,39912,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37852,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38511,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36426,39917,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37622,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40377,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,64365,38346,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,36430,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,64463,34656,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40642, +N,N,N,N,N,N,38117,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39920,38116,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,38225,35771,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39921,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,38128,36452,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38122,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36705,N,N,N,39780,36443,N,N,N,N, +39922,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40894,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40393,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36460,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36723,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,36015,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,36725,36465,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36448,36458,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,35916,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38226,38228, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35540,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40379,38211,37630,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,38130,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38129,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41194,40402,41137,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37368, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,40386,38904,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,36860,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38003,38004,N,N, -N,N,N,N,N,N,N,N,N,N,65207,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37986,39844, +36525,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40621,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38608,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65262,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,35508,N,N,N,N,N,N,N,N,N,N,N,N,38743,35447,39927,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36533,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41069, +36534,38742,38208,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,41203,38078,N,N,N,39930,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64991,40380,N,N,N,N,N,N,N, +N,38142,N,N,N,N,N,N,N,N,35803,41214,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,36544,40775,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35806,41211,N,N,N,N, +36547,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38473,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,65218,N,N,38220,39933,N,N,N,N,N,N,N,N,N,N,N,N,N,37068, +40032,38219,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39934,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40048,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,40003,N,N,N,40007,36556,N,N,N,36436,N,N,N,N,N,N,N,N,N,N,36580, +40009,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35678,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38238,N,N,N,N,N,N,N, +N,N,N,N,N,38236,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40011,35809,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,36569,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40372,N, +37471,N,N,N,40012,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,35489,N,N,N,N,N,N,N,N,N,N,N,N,N,36571,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40022,35490,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,38740,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40030,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40660,38248,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,41155,35558,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,41207,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40033,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40031,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64589,N,40539,N,N,N,N,N,N,N,N,40553,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40035,65223,N,N,65222,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40039,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,40041,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35810,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,37221,N,N,N,N,N,N,N,N,N,N,N,N,40167,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,35412,N,N,N,N,N,N,N,40044,40046,65117,N,N,N,N,N,40051,N, +N,N,N,N,N,N,N,N,N,N,N,N,38250,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38253,36592,36685,N, +N,N,N,36598,N,N,N,N,N,N,N,N,64188,N,36053,N,N,N,N,N,N,N,N,N,N,N,N,N,34654,N,N, +N,N,64474,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,35660,64885,39901,64245,N,N,N,N,N,N,N,40052,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,38213,N,N,N,N,N,N,N,N,N,N,N,N,38598,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,36714,36686,N,N,N,N,N,40056,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64085,N,N,N,N,N,N,N,N,N,N,N,N,38884,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,40001,37468,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38650,36086,N,N,N,N,36173,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64358,36453,38985, +64424,38978,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40058,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38907,37066,N,N,N,N,40027,N,N,38733, +N,N,36563,N,N,N,N,N,N,N,N,N,N,N,N,N,38241,40779,40885,37842,64938,38976,37190, +39015,64090,64425,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,38977,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,36051,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,64765,64939,37309,36684,38601,36693,64430,38255,N,N, +N,N,N,N,40061,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,41200,N,N,N,N,N,N,N,N,N,N,N,N,N,37999,64940,N,N,N,N, +38603,38606,N,N,N,N,41046,N,40161,N,N,N,N,N,N,N,N,N,N,38596,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +36702,36716,36515,64435,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,64595,N,N,N,64947,N,N,N,N,36715,N,N,N,N,N,N,N,N,N,N, +N,N,38602,N,N,N,N,N,N,34643,N,N,N,N,N,N,N,N,N,N,N,N,N,36729,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,40559,41157,64632,36418,36698,37058,36517,36961,37455,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35403,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35413, -35689,35548,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35702,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37747,64949,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39886,N, -35432,41208,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,65228,N,64445,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36054, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38979,38597, +35260,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40099,N,N,N,N,N,N,37451,38986, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,39135,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,65205,N,N,N,39887,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38651,N,N,39931, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,40654,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36581,N,N,N,N,N, -N,N,N,N,40571,39890,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,35493,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,36772,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,41201,40699,40146,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,36775,N,N,N,N,34644,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64604,38981,N,N,36934,36049,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65274,38240,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,65230,35397,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,40444,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65231,35749,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,40776,37447,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37115,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35914,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,35564,N,N,64736,38061,65237,38060,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64602,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39894,N,N,N,N,N,N, +N,40100,38257,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35439,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35753,36447,N,N,40395,N,64743,39895,N,N, -N,N,N,N,N,N,N,N,N,37832,N,N,N,N,N,N,N,N,N,37360,36832,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,39899,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,37101,N,39900,41196,N,N,N,39162,N,N,N,N,N,N,N,N,N,39904,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37831,37449,38625,39906,N, -N,N,39908,N,N,36833,39909,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38080,N,N,37827,N,N,N,N,N,N,N,N,N,N,37829,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36985,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,38779,N,N,N,N,N,36990,N,N,N,N,65254,65094,N,N,N,N, +N,N,N,N,34629,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40102,N,N,N,N, +40103,N,N,N,N,N,40106,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,40659,N,N,N,40560,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40108,34642,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,40376,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37488,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36782,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,38312,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36016,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38088,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,39097,37184,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,64702,N,N,N,N,N,N,N,37207,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35762,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64223,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,36176,38269,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40112,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39910,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,38467,36420,40015,65268,N,N,N,N,N,39912,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,37852,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38838,N,41149,35551,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40618,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38511,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,36426,39917,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,36797,N,N,N,36799,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37737, +39847,51364,N,N,N,N,65258,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,39905,N,N,N,N,N,N,35649,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,40374,41195,39843,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,37622,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40377,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,35745,36808,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,35148,39008,N,N,N,N,N,N,N,N,N,N,38087,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,35672,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38315,38314,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36430,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64463,40642,N,N,N,N,N, -N,38117,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39920,38116,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,40131,40132,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,37846,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,40364,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35814,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35441,36817,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,38225,35771,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39921,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38128,36452,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38122,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36705,N,N,N,39780,36443,N,N,N,N,39922,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40894,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40393,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36460,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36723,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36015,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36725, -36465,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36448,36458,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,35916,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38226,38228,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,35540,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40379,38211, -37630,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -38130,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38129,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,41194,40402,41137,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37368,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37986,39844,36525,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40621,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38608,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,65262,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35508,N, -N,N,N,N,N,N,N,N,N,N,N,38743,35447,39927,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,36533,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41069,36534,38742, -38208,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,41203,38078,N,N,N,39930,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64991,40380,N,N,N,N,N,N,N,N,38142,N,N, -N,N,N,N,N,N,35803,41214,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36544, -40775,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35806,41211,N,N,N,N,36547,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38473,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,65218,N,N,38220,39933,N,N,N,N,N,N,N,N,N,N,N,N,N,37068,40032, -38219,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39934,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,40048,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,40003,N,N,N,40007,36556,N,N,N,36436,N,N,N,N,N,N,N,N,N,N,36580,40009,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35678,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38238,N,N,N,N,N,N,N,N,N,N,N,N, -38236,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40011,35809,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,36569,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40372,N,37471,N,N,N, -40012,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35489,N,N,N,N,N,N,N,N,N,N,N,N,N,36571,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40022,35490,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,38740,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40030,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,40660,38248,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -41155,35558,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,41207,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40033,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,40031,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,64589,N,40539,N,N,N,N,N,N,N,N,40553,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40035,65223,N, -N,65222,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40039,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,40041,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35810,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,37221,N,N,N,N,N,N,N,N,N,N,N,N,40167,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,35412,N,N,N,N,N,N,N,40044,40046,65117,N,N,N,N,N,40051,N,N,N,N,N,N,N,N, -N,N,N,N,N,38250,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38253,36592,36685,N,N,N,N,36598,N, -N,N,N,N,N,N,N,64188,N,36053,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64474,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35660, -64885,39901,64245,N,N,N,N,N,N,N,40052,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,38213,N,N,N,N,N,N,N,N,N,N,N,N,38598,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,36714,36686,N,N,N,N,N,40056,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64085,N,N,N,N,N,N,N,N,N,N,N,N,38884,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40001,37468, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38650,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64358,36453,38985,64424,38978,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40058,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,38907,37066,N,N,N,N,40027,N,N,38733,N,N,36563,N,N,N,N,N,N,N,N,N, -N,N,N,N,38241,40779,40885,37842,64938,38976,37190,39015,64090,64425,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38977,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36051,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64765,64939,37309,36684,38601,36693,64430,38255,N,N,N,N,N,N,40061,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,39381,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37108,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35491,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -41200,N,N,N,N,N,N,N,N,N,N,N,N,N,37999,64940,N,N,N,N,38603,38606,N,N,N,N,41046, -N,40161,N,N,N,N,N,N,N,N,N,N,38596,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36702,36716,36515,64435,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64595,N,N,N,64947,N,N,N,N,36715,N,N,N,N,N,N,N,N,N,N,N,N,38602,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,36729,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40559,41157,64632, -36418,36698,37058,36517,36961,37455,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37747,64949,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65228,N,64445,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36054,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38979,38597,35260,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,40099,N,N,N,N,N,N,37451,38986,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36772,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41201, -40699,40146,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36775,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,64604,38981,N,N,36934,36049,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,65274,38240,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40776,37447,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,37115,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40100,38257,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,40102,N,N,N,N,40103,N,N,N,N,N,40106,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40659,N,N,N,40560,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,40108,36782,38269,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40112,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38838, -N,41149,35551,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,40618,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36797,N,N,N,36799,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37737,39847, -51364,N,N,N,N,65258,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,39905,N,N,N,N,N,N,35649,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,40374,41195,39843,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35745,36808,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,35148,39008,N,N,N,N,N,N,N,N,N,N,38087,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,35672,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,38315,38314,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,40131,40132,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,37846,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40364,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35814,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35441,36817,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,39381,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37108,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35491,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40142,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,40148,40149,N,N,N,64456,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40371,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64624,N,N,N,N,N,36823,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39795,N,N,N,N,N,N,N,N,N,N,64091,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40142,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40148,40149,N,N,N,64456,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40371,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64624,N,N,N,N,N,36823,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39795,N,N,N,N,N,N,N,N,N,N,64091,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,36818,36964,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39094, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36818,36964,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39094, 38504,N,N,N,N,40150,N,N,N,N,N,N,N,N,N,N,N,N,39101,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36828,65270,36825,N,N,N,N,N,N,N,N,N,N,N,N,N, 38209,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38899,39928,40556,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36850,36846,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,40151,N,N,N,N,N,N,N,N,N,N,N,N,40558,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,35392,N,N,N,N,N,N,N,N,N,N,36847,N,N,N,N,N,N,N,N,36852,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36853,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38338,39018,N,38863,40572,36929,N,N,N, -N,N,N,40155,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37953,N,N,N,N,40166,40368, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40170,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40173,N,N,N,N,N,N,N,N,N,N,N,N,40186,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,35682,35406,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,40138,35430,N,N,N,N,N,N,N,N,N,N,40187,40188,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40190,N,N,N,N,N,N,N,N,N,N,N, -N,N,35411,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40165,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,40256,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,40257,N,N,N,N,N,N,N,N,N,N,N,N,36933,35699,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,38858,N,40258,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35425,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,35758,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35538,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,35746,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40434,40259,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40159,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,40260,N,N,N,N,N,N,N,N,N,N,36554,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36942,N,N,N,N,N,N,N,36531,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40949,N,N,N,N,N,N,N,N,N,N,N,N,40261,36943,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,34668,N,N,N,N,38899,39928,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40263,N,N,N,35274,N,N,N,N,N,N,40117,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64510,36958,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36963,36951,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36966,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,39872,N,N,N,N,N,N,N,N,N,N,N,64741,37218,N,N,N,N,N,N,N,N,N,N,36967,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36769,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,36770,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,40264,64211,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36957,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,37049,N,N,N,N,N,N,N,N,N,N,N,N,N,36971,35932,N,N,N, -36969,65111,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,65109,36979,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39919,40176,N,N, -N,N,N,N,N,N,N,N,N,N,40267,N,N,N,N,N,N,N,N,N,N,N,N,N,65241,N,N,N,65242,N,N,N, -37344,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37336,N,N,N,N,N,N,N,N,N,N,38470,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37728,N,64083,40147,N,N, -N,N,N,N,N,N,N,N,N,N,40270,N,N,N,64320,N,N,N,36322,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,37954,N,36950,N,N,39013,N,35948,64074,N,N,40272, -40274,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38319,38746,37705,38727,41204,N,N,N,N,N, -N,38776,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36815,N,N,N,64608,N,N,N,N,N,N,N,N,35918,N, -N,N,64598,N,N,N,N,N,N,N,N,N,N,N,N,N,37340,38497,37612,37725,36574,38654,64847, -38366,N,N,N,N,N,N,N,N,N,N,N,N,N,39088,41024,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38845,38781,38901,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,39852,64218,37570,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38833,N,N,N,N,N,36987,N,N,N,N,37886,38011, -N,38775,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64190,64835,37062,37028,37032,38057,N, -37033,N,N,N,N,35941,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38368,36989,N,N,N,N,N,N, -37477,N,N,N,N,N,N,N,N,N,N,N,N,N,64954,37828,N,N,N,N,N,N,N,N,65261,40363,41187, -N,38472,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40275,N,N,N,N,N,35497,N, -39877,N,38493,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38751,38495,38510,64349,N,N, -N,N,N,40369,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,65187,N,N,N,N,N,N,N,N,N,40370,N,N,38318,64675,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41122,N,N,38485,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,40276,N,N,37697,N,38317,37333,N,N,N,N,N,N,N,N,N,N,N,N,38778,65020, -36423,37885,37029,37036,N,N,N,N,N,N,N,N,38316,N,N,N,N,N,N,N,N,N,37038,65189,N, -N,N,N,N,40278,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38883,38370,N,N,N,N,N,37990, -N,N,38471,N,N,N,N,37304,N,N,N,N,40172,N,N,N,N,N,N,N,N,37037,N,38371,N,N,N,N,N, +34650,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34632,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34634,40556,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36850,36846,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,40151,N,N,N,N,N,N,N,N,N,N,N,N,40558,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35392,N, +N,N,N,N,N,N,N,N,N,36847,N,N,N,N,N,N,N,N,36852,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36853,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,38338,39018,N,38863,40677,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40572, +36929,N,N,N,N,N,N,40155,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37953,N,N,N,N, +40166,40368,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,40170,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40173,N,N,N,N,N,N,N,N,N,N,N,N, +40186,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,35682,35406,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40138,35430,N,N,N,N,N,N,N,N,N,N,40187,40188,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40190,N,N,N,N,N, +N,N,N,N,N,N,N,N,35411,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40165,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40256,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40257,N,N,N,N,N,N,N,N,N,N,N,N,36933,35699, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38858,N,40258,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,35425,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,35758,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35538,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,35746,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40434, +40259,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40159,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,40260,N,N,N,N,N,N,N,N,N,N,36554,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36942,N,N,N,N,N,N,N,36531,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,40949,N,N,N,N,N,N,N,N,N,N,N,N,40261,36943,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,40263,N,N,N,35274,N,N,N,N,N,N,40117,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64510, +36958,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36963,36951,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36966,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,39872,N,N,N,N,N,N,N,N,N,N,N,64741,37218,N,N,N,N,N,N,N,N,N,N,36967,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36769,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,36770,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40264,64211,N,N,N,N,N,N,36175,N,N,N,N,N,N,N,N,N,36957,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37049,N,N,N,N,N,N,N,N,N,N,N,N,N,36971, +35932,N,N,N,36969,65111,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,65109,36979,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +39919,40176,N,N,N,N,N,N,N,N,N,N,N,N,40267,N,N,N,N,N,N,N,N,N,N,N,N,N,65241,N,N, +N,65242,N,N,N,37344,36163,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37336,N,N,N,N,N,N,N, +N,N,N,38470,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37728, +N,64083,40147,N,N,N,N,N,N,N,N,N,N,N,N,40270,N,N,N,64320,N,N,N,36322,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37954,N,36950,N,N,39013,N,35948, +64074,N,N,40272,40274,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38319,38746,37705,38727, +41204,N,N,N,N,N,N,38776,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36815,N,N,N,64608,N,N,N,N, +N,N,N,N,35918,N,N,N,64598,N,N,N,N,N,N,N,N,N,N,N,N,N,37340,38497,37612,37725, +36574,38654,64847,38366,N,N,N,N,N,N,N,N,N,N,N,N,N,39088,41024,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38845,38781,38901, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39852,64218,37570,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38833,N,N,N,N,N,36987,N, +N,N,N,37886,38011,N,38775,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64190,64835,37062, +37028,37032,38057,N,37033,N,N,N,N,35941,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38368,36989,N,N,N,N,N,N,37477,N,N,N,N,N,N,N,N,N,N,N,N,N,64954,37828,N,N,N,N,N, +N,N,N,65261,40363,41187,N,38472,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40275,N,N,N,N,N,35497,N,39877,N,38493,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +38751,38495,38510,64349,N,N,N,N,N,40369,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65187,N,N,N,N,N,N,N,N,N,40370,N,N,38318,64675,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34665,N,N,N,N,N,N,N,N, +41122,N,N,38485,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40276,N,N,37697,N,38317,37333,N,N, +N,N,N,N,N,N,N,N,N,N,38778,65020,36423,37885,37029,37036,N,N,N,N,N,N,N,N,38316, +N,N,N,N,N,N,N,N,N,37038,65189,N,N,N,N,N,40278,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,38883,38370,N,N,N,N,N,37990,N,N,38471,N,N,N,N,37304,N,N,N,N,40172,N,N,N,N, +N,N,N,N,37037,N,38371,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35663, +N,N,35555,N,N,N,N,35661,38378,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35663,N,N,35555,N,N,N,N,35661,38378,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35662,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36033,35821,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37337,N,N,41124,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38389,38388, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,40883,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65199,N,N,N,N, -N,65138,37498,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,65196,N,N,N,N,N,N,N,N,N,N,N,N,N,38387,40280,37746,N,N,37317,N,N,N,N, -N,N,N,38466,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37069,38398, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35662,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36033, +35821,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,37337,N,N,41124,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,38389,38388,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40883,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,65199,N,N,N,N,N,65138,37498,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,65196,N,N,N,N,N,N,N,N,N,N,N, +N,N,38387,40280,36166,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37746,N,N,37317,N,N,N,N,N,N, +N,38466,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37069,38398, 37209,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40037,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38860,37070,N,N,N,N,N,N,40281,64757,65277,N,N, 40283,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, @@ -2168,70 +2203,72 @@ N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,40129,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,40296,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -37799,N,N,N,N,N,N,38516,41199,N,37201,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38593,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,35940,38518,40297,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64676, -N,N,N,N,N,N,N,N,N,N,N,N,40298,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37454,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40299,N,N,N,N,N,39873, -40300,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -35429,37213,N,N,N,N,N,N,N,N,40301,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +37799,N,N,N,N,N,N,38516,N,N,N,N,N,N,N,N,36093,41199,N,37201,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38593,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,34679,N,35940,38518,40297,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,64676,N,N,N,N,N,N,N,N,N,N,N,N,40298,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +37454,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,40299,N,N,N,N,N,39873,40300,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,35429,37213,N,N,N,N,N,N,N,N,40301,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37210,35906,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37210,35906,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40128,37226,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,40302,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,40614,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +40397,N,N,40303,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,40128,37226,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -40302,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40614, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40397,N,N,40303,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35259,40697,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38580,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,37234,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,35259,40697,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,38580,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37234,N, +40648,N,N,N,34673,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35669,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40648,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,35669,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40305,40306,N,N,N,N, -N,N,N,N,N,N,N,N,40652,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,40305,40306,N,N,N,N,N,N,N,N,N,N,N,N,40652,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37236,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40656,36956,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,37236,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,40656,36956,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36562,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,37288,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,37239,N,N,N,N,N,N,N,N,N,N,N,38591,N,N,N,N,N,38592,N,N,N,N, -36785,N,N,N,N,N,38583,35925,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,37240,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35262,37244,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,64375,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,36562,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37288,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37239,N,N,N,N,N,N,N,N,N,N,N, +38591,N,N,N,N,N,38592,N,N,N,N,36785,N,N,N,N,N,38583,35925,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37240,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35262, +37244,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64375,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,37237,37283,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37238,N,N,N, -N,N,N,N,N,38590,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,37241,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,38582, -37284,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37286,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37237,37283,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,37238,N,N,N,N,N,N,N,N,38590,36169,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37241,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,38582,37284,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +37286,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40309,N,N,N,N,N,N,N,N,N,N,N,36946,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,41029,N,37289,N,39082,N,N,N,35935,N,N,35754,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40157,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40311,34646,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,40309,N,N,N,N,N,N,N,N,N,N,N,36946,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -41029,N,37289,N,39082,N,N,N,35935,N,N,35754,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40157,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,40311,35136,40684,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,37802,38008,N,N,N,N,40314,35529,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,35659,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40940,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,35554,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,35136,40684,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,37802,38008,N,N,N,N,40314,35529,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35659,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40940,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +35554,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,40565,39028,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,39624,N,N,N,N,41031,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35779,N,N,N,N,N,N,N,N,N, -N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64584,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -64631,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -N,N,40018,36605,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36776,N,N,N,N,N,N,N,N,N,38266,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, -36848, +N,N,40565,39028,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,39624,N,N,N,N,41031, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,35779,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,64584,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,64631,N,N,N,N,N,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,40018,36605,N,N,N,N, +N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36776,N,N,N,N,N,N,N,N,N, +38266,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,36848, }; static const struct unim_index big5hkscs_nonbmp_encmap[256] = { @@ -2249,84 +2286,84 @@ 253},{__big5hkscs_nonbmp_encmap+4292,119,150},{__big5hkscs_nonbmp_encmap+4324, 10,254},{__big5hkscs_nonbmp_encmap+4569,13,252},{__big5hkscs_nonbmp_encmap+ 4809,32,250},{__big5hkscs_nonbmp_encmap+5028,3,243},{__big5hkscs_nonbmp_encmap -+5269,45,75},{__big5hkscs_nonbmp_encmap+5300,68,194},{ -__big5hkscs_nonbmp_encmap+5427,42,172},{__big5hkscs_nonbmp_encmap+5558,70,249 -},{__big5hkscs_nonbmp_encmap+5738,28,213},{__big5hkscs_nonbmp_encmap+5924,15, -232},{__big5hkscs_nonbmp_encmap+6142,69,252},{__big5hkscs_nonbmp_encmap+6326, -42,195},{__big5hkscs_nonbmp_encmap+6480,8,124},{__big5hkscs_nonbmp_encmap+6597 -,33,250},{__big5hkscs_nonbmp_encmap+6815,101,237},{__big5hkscs_nonbmp_encmap+ -6952,19,190},{__big5hkscs_nonbmp_encmap+7124,27,246},{ -__big5hkscs_nonbmp_encmap+7344,18,205},{__big5hkscs_nonbmp_encmap+7532,3,247}, -{__big5hkscs_nonbmp_encmap+7777,38,147},{__big5hkscs_nonbmp_encmap+7887,102, -232},{__big5hkscs_nonbmp_encmap+8018,14,206},{__big5hkscs_nonbmp_encmap+8211, -38,201},{__big5hkscs_nonbmp_encmap+8375,7,238},{__big5hkscs_nonbmp_encmap+8607 -,13,239},{__big5hkscs_nonbmp_encmap+8834,116,227},{__big5hkscs_nonbmp_encmap+ -8946,51,218},{__big5hkscs_nonbmp_encmap+9114,3,249},{__big5hkscs_nonbmp_encmap -+9361,15,225},{__big5hkscs_nonbmp_encmap+9572,0,254},{ -__big5hkscs_nonbmp_encmap+9827,0,229},{__big5hkscs_nonbmp_encmap+10057,25,243 -},{__big5hkscs_nonbmp_encmap+10276,0,238},{__big5hkscs_nonbmp_encmap+10515,3, -215},{__big5hkscs_nonbmp_encmap+10728,58,58},{__big5hkscs_nonbmp_encmap+10729, -194,194},{__big5hkscs_nonbmp_encmap+10730,167,250},{__big5hkscs_nonbmp_encmap+ -10814,90,90},{__big5hkscs_nonbmp_encmap+10815,99,255},{ -__big5hkscs_nonbmp_encmap+10972,64,248},{__big5hkscs_nonbmp_encmap+11157,17, -252},{__big5hkscs_nonbmp_encmap+11393,53,240},{__big5hkscs_nonbmp_encmap+11581 -,17,225},{__big5hkscs_nonbmp_encmap+11790,4,252},{__big5hkscs_nonbmp_encmap+ -12039,27,250},{__big5hkscs_nonbmp_encmap+12263,13,248},{ -__big5hkscs_nonbmp_encmap+12499,4,214},{__big5hkscs_nonbmp_encmap+12710,5,200 -},{__big5hkscs_nonbmp_encmap+12906,24,212},{__big5hkscs_nonbmp_encmap+13095,6, -224},{__big5hkscs_nonbmp_encmap+13314,18,255},{__big5hkscs_nonbmp_encmap+13552 -,0,251},{__big5hkscs_nonbmp_encmap+13804,14,233},{__big5hkscs_nonbmp_encmap+ -14024,110,245},{__big5hkscs_nonbmp_encmap+14160,9,217},{ -__big5hkscs_nonbmp_encmap+14369,6,235},{__big5hkscs_nonbmp_encmap+14599,59,167 -},{__big5hkscs_nonbmp_encmap+14708,14,194},{__big5hkscs_nonbmp_encmap+14889, -44,157},{__big5hkscs_nonbmp_encmap+15003,43,231},{__big5hkscs_nonbmp_encmap+ -15192,32,216},{__big5hkscs_nonbmp_encmap+15377,14,19},{ -__big5hkscs_nonbmp_encmap+15383,25,110},{__big5hkscs_nonbmp_encmap+15469,49, -224},{__big5hkscs_nonbmp_encmap+15645,5,246},{__big5hkscs_nonbmp_encmap+15887, -6,225},{__big5hkscs_nonbmp_encmap+16107,87,225},{__big5hkscs_nonbmp_encmap+ -16246,3,204},{__big5hkscs_nonbmp_encmap+16448,149,233},{ -__big5hkscs_nonbmp_encmap+16533,116,232},{__big5hkscs_nonbmp_encmap+16650,1, -254},{__big5hkscs_nonbmp_encmap+16904,32,67},{__big5hkscs_nonbmp_encmap+16940, -14,216},{__big5hkscs_nonbmp_encmap+17143,26,226},{__big5hkscs_nonbmp_encmap+ -17344,41,165},{__big5hkscs_nonbmp_encmap+17469,2,221},{ -__big5hkscs_nonbmp_encmap+17689,88,208},{__big5hkscs_nonbmp_encmap+17810,53, -248},{__big5hkscs_nonbmp_encmap+18006,2,152},{__big5hkscs_nonbmp_encmap+18157, -18,191},{__big5hkscs_nonbmp_encmap+18331,18,252},{__big5hkscs_nonbmp_encmap+ -18566,22,204},{__big5hkscs_nonbmp_encmap+18749,28,199},{ -__big5hkscs_nonbmp_encmap+18921,14,250},{__big5hkscs_nonbmp_encmap+19158,45,82 -},{__big5hkscs_nonbmp_encmap+19196,5,247},{__big5hkscs_nonbmp_encmap+19439,33, -209},{__big5hkscs_nonbmp_encmap+19616,34,240},{__big5hkscs_nonbmp_encmap+19823 -,0,215},{__big5hkscs_nonbmp_encmap+20039,38,223},{__big5hkscs_nonbmp_encmap+ -20225,14,248},{__big5hkscs_nonbmp_encmap+20460,9,205},{ -__big5hkscs_nonbmp_encmap+20657,27,230},{__big5hkscs_nonbmp_encmap+20861,154, -154},{__big5hkscs_nonbmp_encmap+20862,34,134},{__big5hkscs_nonbmp_encmap+20963 -,116,254},{__big5hkscs_nonbmp_encmap+21102,7,148},{__big5hkscs_nonbmp_encmap+ -21244,15,204},{__big5hkscs_nonbmp_encmap+21434,88,200},{ -__big5hkscs_nonbmp_encmap+21547,36,253},{__big5hkscs_nonbmp_encmap+21765,10, -244},{__big5hkscs_nonbmp_encmap+22000,6,244},{__big5hkscs_nonbmp_encmap+22239, -18,18},{__big5hkscs_nonbmp_encmap+22240,47,220},{__big5hkscs_nonbmp_encmap+ -22414,77,79},{__big5hkscs_nonbmp_encmap+22417,249,249},{ -__big5hkscs_nonbmp_encmap+22418,2,244},{__big5hkscs_nonbmp_encmap+22661,46,188 -},{__big5hkscs_nonbmp_encmap+22804,7,226},{__big5hkscs_nonbmp_encmap+23024,6, -138},{__big5hkscs_nonbmp_encmap+23157,18,130},{__big5hkscs_nonbmp_encmap+23270 -,1,244},{__big5hkscs_nonbmp_encmap+23514,0,230},{__big5hkscs_nonbmp_encmap+ -23745,15,19},{__big5hkscs_nonbmp_encmap+23750,4,43},{__big5hkscs_nonbmp_encmap -+23790,51,252},{__big5hkscs_nonbmp_encmap+23992,15,252},{ -__big5hkscs_nonbmp_encmap+24230,12,255},{__big5hkscs_nonbmp_encmap+24474,3,210 -},{__big5hkscs_nonbmp_encmap+24682,52,185},{__big5hkscs_nonbmp_encmap+24816, -15,231},{__big5hkscs_nonbmp_encmap+25033,197,197},{__big5hkscs_nonbmp_encmap+ -25034,136,237},{__big5hkscs_nonbmp_encmap+25136,13,235},{0,0,0},{0,0,0},{ -__big5hkscs_nonbmp_encmap+25359,29,231},{__big5hkscs_nonbmp_encmap+25562,158, -244},{0,0,0},{__big5hkscs_nonbmp_encmap+25649,32,212},{ -__big5hkscs_nonbmp_encmap+25830,16,241},{__big5hkscs_nonbmp_encmap+26056,3,201 -},{__big5hkscs_nonbmp_encmap+26255,40,77},{__big5hkscs_nonbmp_encmap+26293,5, -213},{__big5hkscs_nonbmp_encmap+26502,115,173},{__big5hkscs_nonbmp_encmap+ -26561,62,246},{__big5hkscs_nonbmp_encmap+26746,6,248},{ -__big5hkscs_nonbmp_encmap+26989,35,222},{__big5hkscs_nonbmp_encmap+27177,20, -254},{__big5hkscs_nonbmp_encmap+27412,7,245},{__big5hkscs_nonbmp_encmap+27651, -32,255},{__big5hkscs_nonbmp_encmap+27875,169,169},{__big5hkscs_nonbmp_encmap+ -27876,52,91},{__big5hkscs_nonbmp_encmap+27916,198,203},{ -__big5hkscs_nonbmp_encmap+27922,1,169},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 ++5269,45,99},{__big5hkscs_nonbmp_encmap+5324,68,194},{ +__big5hkscs_nonbmp_encmap+5451,42,172},{__big5hkscs_nonbmp_encmap+5582,70,249 +},{__big5hkscs_nonbmp_encmap+5762,28,213},{__big5hkscs_nonbmp_encmap+5948,15, +232},{__big5hkscs_nonbmp_encmap+6166,69,252},{__big5hkscs_nonbmp_encmap+6350, +42,195},{__big5hkscs_nonbmp_encmap+6504,8,124},{__big5hkscs_nonbmp_encmap+6621 +,33,250},{__big5hkscs_nonbmp_encmap+6839,101,237},{__big5hkscs_nonbmp_encmap+ +6976,19,190},{__big5hkscs_nonbmp_encmap+7148,27,246},{ +__big5hkscs_nonbmp_encmap+7368,18,205},{__big5hkscs_nonbmp_encmap+7556,3,247}, +{__big5hkscs_nonbmp_encmap+7801,38,147},{__big5hkscs_nonbmp_encmap+7911,102, +232},{__big5hkscs_nonbmp_encmap+8042,14,206},{__big5hkscs_nonbmp_encmap+8235, +38,201},{__big5hkscs_nonbmp_encmap+8399,7,238},{__big5hkscs_nonbmp_encmap+8631 +,13,239},{__big5hkscs_nonbmp_encmap+8858,116,227},{__big5hkscs_nonbmp_encmap+ +8970,51,218},{__big5hkscs_nonbmp_encmap+9138,3,249},{__big5hkscs_nonbmp_encmap ++9385,15,225},{__big5hkscs_nonbmp_encmap+9596,0,254},{ +__big5hkscs_nonbmp_encmap+9851,0,229},{__big5hkscs_nonbmp_encmap+10081,25,243 +},{__big5hkscs_nonbmp_encmap+10300,0,238},{__big5hkscs_nonbmp_encmap+10539,3, +215},{__big5hkscs_nonbmp_encmap+10752,58,58},{__big5hkscs_nonbmp_encmap+10753, +194,194},{__big5hkscs_nonbmp_encmap+10754,167,250},{__big5hkscs_nonbmp_encmap+ +10838,26,90},{__big5hkscs_nonbmp_encmap+10903,99,255},{ +__big5hkscs_nonbmp_encmap+11060,64,248},{__big5hkscs_nonbmp_encmap+11245,6,252 +},{__big5hkscs_nonbmp_encmap+11492,53,240},{__big5hkscs_nonbmp_encmap+11680, +17,236},{__big5hkscs_nonbmp_encmap+11900,4,252},{__big5hkscs_nonbmp_encmap+ +12149,27,250},{__big5hkscs_nonbmp_encmap+12373,13,248},{ +__big5hkscs_nonbmp_encmap+12609,4,214},{__big5hkscs_nonbmp_encmap+12820,5,200 +},{__big5hkscs_nonbmp_encmap+13016,24,212},{__big5hkscs_nonbmp_encmap+13205,6, +224},{__big5hkscs_nonbmp_encmap+13424,18,255},{__big5hkscs_nonbmp_encmap+13662 +,0,251},{__big5hkscs_nonbmp_encmap+13914,14,233},{__big5hkscs_nonbmp_encmap+ +14134,15,245},{__big5hkscs_nonbmp_encmap+14365,9,217},{ +__big5hkscs_nonbmp_encmap+14574,6,235},{__big5hkscs_nonbmp_encmap+14804,59,167 +},{__big5hkscs_nonbmp_encmap+14913,14,194},{__big5hkscs_nonbmp_encmap+15094, +44,157},{__big5hkscs_nonbmp_encmap+15208,43,231},{__big5hkscs_nonbmp_encmap+ +15397,32,216},{__big5hkscs_nonbmp_encmap+15582,14,19},{ +__big5hkscs_nonbmp_encmap+15588,25,154},{__big5hkscs_nonbmp_encmap+15718,49, +224},{__big5hkscs_nonbmp_encmap+15894,5,246},{__big5hkscs_nonbmp_encmap+16136, +6,225},{__big5hkscs_nonbmp_encmap+16356,87,225},{__big5hkscs_nonbmp_encmap+ +16495,3,204},{__big5hkscs_nonbmp_encmap+16697,84,233},{ +__big5hkscs_nonbmp_encmap+16847,116,232},{__big5hkscs_nonbmp_encmap+16964,1, +254},{__big5hkscs_nonbmp_encmap+17218,32,67},{__big5hkscs_nonbmp_encmap+17254, +14,216},{__big5hkscs_nonbmp_encmap+17457,26,226},{__big5hkscs_nonbmp_encmap+ +17658,41,165},{__big5hkscs_nonbmp_encmap+17783,2,221},{ +__big5hkscs_nonbmp_encmap+18003,88,208},{__big5hkscs_nonbmp_encmap+18124,53, +248},{__big5hkscs_nonbmp_encmap+18320,2,152},{__big5hkscs_nonbmp_encmap+18471, +18,191},{__big5hkscs_nonbmp_encmap+18645,18,252},{__big5hkscs_nonbmp_encmap+ +18880,22,204},{__big5hkscs_nonbmp_encmap+19063,28,199},{ +__big5hkscs_nonbmp_encmap+19235,14,250},{__big5hkscs_nonbmp_encmap+19472,45,82 +},{__big5hkscs_nonbmp_encmap+19510,5,247},{__big5hkscs_nonbmp_encmap+19753,33, +209},{__big5hkscs_nonbmp_encmap+19930,34,240},{__big5hkscs_nonbmp_encmap+20137 +,0,215},{__big5hkscs_nonbmp_encmap+20353,38,223},{__big5hkscs_nonbmp_encmap+ +20539,14,248},{__big5hkscs_nonbmp_encmap+20774,9,205},{ +__big5hkscs_nonbmp_encmap+20971,27,230},{__big5hkscs_nonbmp_encmap+21175,82, +255},{__big5hkscs_nonbmp_encmap+21349,34,134},{__big5hkscs_nonbmp_encmap+21450 +,116,254},{__big5hkscs_nonbmp_encmap+21589,7,148},{__big5hkscs_nonbmp_encmap+ +21731,15,204},{__big5hkscs_nonbmp_encmap+21921,88,200},{ +__big5hkscs_nonbmp_encmap+22034,36,253},{__big5hkscs_nonbmp_encmap+22252,10, +244},{__big5hkscs_nonbmp_encmap+22487,6,244},{__big5hkscs_nonbmp_encmap+22726, +18,197},{__big5hkscs_nonbmp_encmap+22906,47,220},{__big5hkscs_nonbmp_encmap+ +23080,77,79},{__big5hkscs_nonbmp_encmap+23083,46,249},{ +__big5hkscs_nonbmp_encmap+23287,2,244},{__big5hkscs_nonbmp_encmap+23530,46,188 +},{__big5hkscs_nonbmp_encmap+23673,7,226},{__big5hkscs_nonbmp_encmap+23893,6, +138},{__big5hkscs_nonbmp_encmap+24026,18,130},{__big5hkscs_nonbmp_encmap+24139 +,1,244},{__big5hkscs_nonbmp_encmap+24383,0,230},{__big5hkscs_nonbmp_encmap+ +24614,15,19},{__big5hkscs_nonbmp_encmap+24619,4,43},{__big5hkscs_nonbmp_encmap ++24659,51,252},{__big5hkscs_nonbmp_encmap+24861,15,252},{ +__big5hkscs_nonbmp_encmap+25099,12,255},{__big5hkscs_nonbmp_encmap+25343,3,210 +},{__big5hkscs_nonbmp_encmap+25551,52,185},{__big5hkscs_nonbmp_encmap+25685, +15,231},{__big5hkscs_nonbmp_encmap+25902,197,197},{__big5hkscs_nonbmp_encmap+ +25903,121,237},{__big5hkscs_nonbmp_encmap+26020,13,235},{0,0,0},{0,0,0},{ +__big5hkscs_nonbmp_encmap+26243,29,231},{__big5hkscs_nonbmp_encmap+26446,158, +244},{0,0,0},{__big5hkscs_nonbmp_encmap+26533,32,212},{ +__big5hkscs_nonbmp_encmap+26714,16,250},{__big5hkscs_nonbmp_encmap+26949,3,201 +},{__big5hkscs_nonbmp_encmap+27148,40,77},{__big5hkscs_nonbmp_encmap+27186,5, +213},{__big5hkscs_nonbmp_encmap+27395,115,173},{__big5hkscs_nonbmp_encmap+ +27454,62,246},{__big5hkscs_nonbmp_encmap+27639,6,248},{ +__big5hkscs_nonbmp_encmap+27882,35,222},{__big5hkscs_nonbmp_encmap+28070,20, +254},{__big5hkscs_nonbmp_encmap+28305,7,245},{__big5hkscs_nonbmp_encmap+28544, +32,255},{__big5hkscs_nonbmp_encmap+28768,81,169},{__big5hkscs_nonbmp_encmap+ +28857,52,91},{__big5hkscs_nonbmp_encmap+28897,198,203},{ +__big5hkscs_nonbmp_encmap+28903,1,169},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 @@ -2335,6 +2372,7 @@ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ -__big5hkscs_nonbmp_encmap+28091,37,205},{__big5hkscs_nonbmp_encmap+28260,148, +__big5hkscs_nonbmp_encmap+29072,37,205},{__big5hkscs_nonbmp_encmap+29241,148, 212},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, }; + Modified: python/branches/py3k/Objects/dictobject.c ============================================================================== --- python/branches/py3k/Objects/dictobject.c (original) +++ python/branches/py3k/Objects/dictobject.c Sat Feb 9 03:18:51 2008 @@ -163,6 +163,22 @@ } #endif +/* Debug statistic to compare allocations with reuse through the free list */ +#undef SHOW_ALLOC_COUNT +#ifdef SHOW_ALLOC_COUNT +static size_t count_alloc = 0; +static size_t count_reuse = 0; + +static void +show_alloc(void) +{ + fprintf(stderr, "Dict allocations: %zd\n", count_alloc); + fprintf(stderr, "Dict reuse through freelist: %zd\n", count_reuse); + fprintf(stderr, "%.2f%% reuse rate\n\n", + (100.0*count_reuse/(count_alloc+count_reuse))); +} +#endif + /* Initialization macros. There are two ways to create a dict: PyDict_New() is the main C API function, and the tp_new slot maps to dict_new(). In the latter case we @@ -190,6 +206,18 @@ static PyDictObject *free_list[PyDict_MAXFREELIST]; static int numfree = 0; +void +PyDict_Fini(void) +{ + PyDictObject *op; + + while (numfree) { + op = free_list[--numfree]; + assert(PyDict_CheckExact(op)); + PyObject_GC_Del(op); + } +} + PyObject * PyDict_New(void) { @@ -201,6 +229,9 @@ #ifdef SHOW_CONVERSION_COUNTS Py_AtExit(show_counts); #endif +#ifdef SHOW_ALLOC_COUNT + Py_AtExit(show_alloc); +#endif } if (numfree) { mp = free_list[--numfree]; @@ -213,11 +244,17 @@ assert (mp->ma_used == 0); assert (mp->ma_table == mp->ma_smalltable); assert (mp->ma_mask == PyDict_MINSIZE - 1); +#ifdef SHOW_ALLOC_COUNT + count_reuse++; +#endif } else { mp = PyObject_GC_New(PyDictObject, &PyDict_Type); if (mp == NULL) return NULL; EMPTY_TO_MINSIZE(mp); +#ifdef SHOW_ALLOC_COUNT + count_alloc++; +#endif } mp->ma_lookup = lookdict_unicode; #ifdef SHOW_CONVERSION_COUNTS Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Sat Feb 9 03:18:51 2008 @@ -63,6 +63,22 @@ return 0; } +/* Debug statistic to compare allocations with reuse through the free list */ +#undef SHOW_ALLOC_COUNT +#ifdef SHOW_ALLOC_COUNT +static size_t count_alloc = 0; +static size_t count_reuse = 0; + +static void +show_alloc(void) +{ + fprintf(stderr, "List allocations: %zd\n", count_alloc); + fprintf(stderr, "List reuse through freelist: %zd\n", count_reuse); + fprintf(stderr, "%.2f%% reuse rate\n\n", + (100.0*count_reuse/(count_alloc+count_reuse))); +} +#endif + /* Empty list reuse scheme to save calls to malloc and free */ #ifndef PyList_MAXFREELIST #define PyList_MAXFREELIST 80 @@ -76,8 +92,7 @@ PyListObject *op; while (numfree) { - numfree--; - op = free_list[numfree]; + op = free_list[--numfree]; assert(PyList_CheckExact(op)); PyObject_GC_Del(op); } @@ -88,6 +103,13 @@ { PyListObject *op; size_t nbytes; +#ifdef SHOW_ALLOC_COUNT + static int initialized = 0; + if (!initialized) { + Py_AtExit(show_alloc); + initialized = 1; + } +#endif if (size < 0) { PyErr_BadInternalCall(); @@ -101,10 +123,16 @@ numfree--; op = free_list[numfree]; _Py_NewReference((PyObject *)op); +#ifdef SHOW_ALLOC_COUNT + count_reuse++; +#endif } else { op = PyObject_GC_New(PyListObject, &PyList_Type); if (op == NULL) return NULL; +#ifdef SHOW_ALLOC_COUNT + count_alloc++; +#endif } if (size <= 0) op->ob_item = NULL; Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Sat Feb 9 03:18:51 2008 @@ -405,9 +405,9 @@ { basicblock *block; for (block = u->u_blocks; block != NULL; block = block->b_list) { - assert(block != (void *)0xcbcbcbcb); - assert(block != (void *)0xfbfbfbfb); - assert(block != (void *)0xdbdbdbdb); + assert((void *)block != (void *)0xcbcbcbcb); + assert((void *)block != (void *)0xfbfbfbfb); + assert((void *)block != (void *)0xdbdbdbdb); if (block->b_instr != NULL) { assert(block->b_ialloc > 0); assert(block->b_iused > 0); Modified: python/branches/py3k/Python/pythonrun.c ============================================================================== --- python/branches/py3k/Python/pythonrun.c (original) +++ python/branches/py3k/Python/pythonrun.c Sat Feb 9 03:18:51 2008 @@ -504,6 +504,7 @@ PyBytes_Fini(); PyLong_Fini(); PyFloat_Fini(); + PyDict_Fini(); /* Cleanup Unicode implementation */ _PyUnicode_Fini(); Modified: python/branches/py3k/Python/strtod.c ============================================================================== --- python/branches/py3k/Python/strtod.c (original) +++ python/branches/py3k/Python/strtod.c Sat Feb 9 03:18:51 2008 @@ -44,11 +44,11 @@ I do know about , but the whole point of this file is that we can't always trust that stuff to be there or to be correct. */ -static int MDMINEXPT = {-323}; +static int MDMINEXPT = -323; static char MDMINFRAC[] = "494065645841246544"; static double ZERO = 0.0; -static int MDMAXEXPT = { 309}; +static int MDMAXEXPT = 309; static char MDMAXFRAC[] = "17976931348623157"; static double HUGE = 1.7976931348623157e308; From python-3000-checkins at python.org Sat Feb 9 03:53:49 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 03:53:49 +0100 (CET) Subject: [Python-3000-checkins] r60682 - python/branches/py3k/Lib/_abcoll.py Message-ID: <20080209025349.03DCD1E4009@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 03:53:48 2008 New Revision: 60682 Modified: python/branches/py3k/Lib/_abcoll.py Log: Merge r60679 Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Sat Feb 9 03:53:48 2008 @@ -82,7 +82,7 @@ return NotImplemented -class Iterator(metaclass=ABCMeta): +class Iterator(Iterable): @abstractmethod def __next__(self): @@ -157,7 +157,7 @@ ### SETS ### -class Set(metaclass=ABCMeta): +class Set(Sized, Iterable, Container): """A set is a finite, iterable container. @@ -169,19 +169,6 @@ then the other operations will automatically follow suit. """ - @abstractmethod - def __contains__(self, value): - return False - - @abstractmethod - def __iter__(self): - while False: - yield None - - @abstractmethod - def __len__(self): - return 0 - def __le__(self, other): if not isinstance(other, Set): return NotImplemented @@ -358,7 +345,7 @@ ### MAPPINGS ### -class Mapping(metaclass=ABCMeta): +class Mapping(Sized, Iterable, Container): @abstractmethod def __getitem__(self, key): @@ -378,15 +365,6 @@ else: return True - @abstractmethod - def __len__(self): - return 0 - - @abstractmethod - def __iter__(self): - while False: - yield None - def keys(self): return KeysView(self) @@ -523,7 +501,7 @@ ### SEQUENCES ### -class Sequence(metaclass=ABCMeta): +class Sequence(Sized, Iterable, Container): """All the operations on a read-only sequence. @@ -535,10 +513,6 @@ def __getitem__(self, index): raise IndexError - @abstractmethod - def __len__(self): - return 0 - def __iter__(self): i = 0 try: From python-3000-checkins at python.org Sat Feb 9 04:25:08 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 04:25:08 +0100 (CET) Subject: [Python-3000-checkins] r60683 - in python/branches/py3k: Doc/library/collections.rst Lib/_abcoll.py Message-ID: <20080209032508.73D961E4009@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 04:25:08 2008 New Revision: 60683 Modified: python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Lib/_abcoll.py Log: Document how to use Set and MutableSet as a mixin. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Sat Feb 9 04:25:08 2008 @@ -58,7 +58,7 @@ ``insert``, ``remove``, and ``__iadd__`` and ``__len__`` -:class:`Set` :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, +:class:`Set` \(1) \(2) :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, :class:`Iterable`, ``__iter__``, and ``__gt__``, ``__ge__``, ``__and__``, ``__or__`` :class:`Container` ``__contains__`` ``__sub__``, ``__xor__``, and ``isdisjoint`` @@ -100,6 +100,23 @@ s2 = ListBasedSet('defghi') overlap = s1 & s2 # The __and__() method is supported automatically +Notes on using :class:`Set` and :class:`MutableSet` as a mixin: + +(1) + Since some set operations create new sets, the default mixin methods need + a way to create new instances from an iterable. The class constructor is + assumed to have a signature in the form ``ClassName(iterable)``. + That assumption is factored-out to a singleinternal classmethod called + :meth:`_from_iterable` which calls ``cls(iterable)`` to produce a new set. + If the :class:`Set` mixin is being used in a class with a different + constructor signature, you will need to override :meth:`from_iterable` + with a classmethod that can construct new instances from + an iterable argument. + +(2) + To override the comparisons (presumably for speed, as the + semantics are fixed), redefine :meth:`__le__` and + then the other operations will automatically follow suit. (For more about ABCs, see the :mod:`abc` module and :pep:`3119`.) Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Sat Feb 9 04:25:08 2008 @@ -207,9 +207,9 @@ '''Construct an instance of the class from any iterable input. Must override this method if the class constructor signature - will not accept a frozenset for an input. + does not accept an iterable for an input. ''' - return cls(frozenset(it)) + return cls(it) def __and__(self, other): if not isinstance(other, Iterable): From python-3000-checkins at python.org Sat Feb 9 04:48:16 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 04:48:16 +0100 (CET) Subject: [Python-3000-checkins] r60685 - python/branches/py3k/Doc/library/collections.rst Message-ID: <20080209034816.A507A1E4009@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 04:48:16 2008 New Revision: 60685 Modified: python/branches/py3k/Doc/library/collections.rst Log: Add another usage note for collections.Set Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Sat Feb 9 04:48:16 2008 @@ -58,7 +58,7 @@ ``insert``, ``remove``, and ``__iadd__`` and ``__len__`` -:class:`Set` \(1) \(2) :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, +:class:`Set` :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, :class:`Iterable`, ``__iter__``, and ``__gt__``, ``__ge__``, ``__and__``, ``__or__`` :class:`Container` ``__contains__`` ``__sub__``, ``__xor__``, and ``isdisjoint`` @@ -118,6 +118,13 @@ semantics are fixed), redefine :meth:`__le__` and then the other operations will automatically follow suit. +(3) + The :class:`Set` mixin provides a :meth:`_hash` method to compute a hash value + for the set; however, :meth:`__hash__` is not defined because not all sets + are hashable or immutable. To add set hashabilty using mixins, + inherit from both :meth:`Set` and :meth:`Hashable`, then define + ``__hash__ = Set._hash``. + (For more about ABCs, see the :mod:`abc` module and :pep:`3119`.) From python-3000-checkins at python.org Sat Feb 9 05:13:49 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 05:13:49 +0100 (CET) Subject: [Python-3000-checkins] r60686 - python/branches/py3k/Objects/rangeobject.c Message-ID: <20080209041349.9E9BF1E4009@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 05:13:49 2008 New Revision: 60686 Modified: python/branches/py3k/Objects/rangeobject.c Log: Merge r60673 Modified: python/branches/py3k/Objects/rangeobject.c ============================================================================== --- python/branches/py3k/Objects/rangeobject.c (original) +++ python/branches/py3k/Objects/rangeobject.c Sat Feb 9 05:13:49 2008 @@ -220,7 +220,7 @@ } /* XXX(nnorwitz): optimize for short ints. */ - rem = PyLong_FromSsize_t(i % len); + rem = PyLong_FromSsize_t(i); if (!rem) return NULL; incr = PyNumber_Multiply(rem, r->step); From python-3000-checkins at python.org Sat Feb 9 11:04:32 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sat, 9 Feb 2008 11:04:32 +0100 (CET) Subject: [Python-3000-checkins] r60690 - python/branches/py3k/Lib/_abcoll.py Message-ID: <20080209100432.437051E4004@bag.python.org> Author: raymond.hettinger Date: Sat Feb 9 11:04:32 2008 New Revision: 60690 Modified: python/branches/py3k/Lib/_abcoll.py Log: MappingView is Sized. Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Sat Feb 9 11:04:32 2008 @@ -382,7 +382,7 @@ return not (self == other) -class MappingView(metaclass=ABCMeta): +class MappingView(Sized): def __init__(self, mapping): self._mapping = mapping From python-3000-checkins at python.org Sat Feb 9 21:51:35 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 9 Feb 2008 21:51:35 +0100 (CET) Subject: [Python-3000-checkins] r60698 - in python/branches/py3k: Doc/library/tempfile.rst Lib/io.py Lib/tempfile.py Lib/test/test_sys.py Lib/test/test_tempfile.py Modules/_collectionsmodule.c Message-ID: <20080209205135.559551E400D@bag.python.org> Author: christian.heimes Date: Sat Feb 9 21:51:34 2008 New Revision: 60698 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/tempfile.rst python/branches/py3k/Lib/io.py python/branches/py3k/Lib/tempfile.py python/branches/py3k/Lib/test/test_sys.py python/branches/py3k/Lib/test/test_tempfile.py python/branches/py3k/Modules/_collectionsmodule.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678-60695 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60679 | raymond.hettinger | 2008-02-09 02:18:42 +0100 (Sat, 09 Feb 2008) | 1 line Make ABC containers inherit as documented. ........ r60684 | raymond.hettinger | 2008-02-09 04:34:52 +0100 (Sat, 09 Feb 2008) | 1 line Merge with r60683. ........ r60687 | raymond.hettinger | 2008-02-09 05:37:49 +0100 (Sat, 09 Feb 2008) | 1 line Add -3 warnings that set.copy(), dict.copy(), and defaultdict.copy() will go away in Py3.x ........ r60689 | raymond.hettinger | 2008-02-09 11:04:19 +0100 (Sat, 09 Feb 2008) | 1 line Metaclass declaration is inherited ........ r60691 | raymond.hettinger | 2008-02-09 11:06:20 +0100 (Sat, 09 Feb 2008) | 1 line Temporarily disable this test. It's been broken for a week. ........ r60695 | nick.coghlan | 2008-02-09 16:28:09 +0100 (Sat, 09 Feb 2008) | 1 line Issue 2021: Allow NamedTemporaryFile and SpooledTemporaryFile to be used as context managers. (The NamedTemporaryFile fix should be considered for backporting to 2.5) ........ Modified: python/branches/py3k/Doc/library/tempfile.rst ============================================================================== --- python/branches/py3k/Doc/library/tempfile.rst (original) +++ python/branches/py3k/Doc/library/tempfile.rst Sat Feb 9 21:51:34 2008 @@ -51,7 +51,8 @@ The returned object is a true file object on POSIX platforms. On other platforms, it is a file-like object whose :attr:`file` attribute is the - underlying true file object. + underlying true file object. This file-like object can be used in a :keyword:`with` + statement, just like a normal file. .. function:: NamedTemporaryFile([mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir[, delete]]]]]]) @@ -64,7 +65,8 @@ across platforms (it can be so used on Unix; it cannot on Windows NT or later). If *delete* is true (the default), the file is deleted as soon as it is closed. The returned object is always a file-like object whose :attr:`file` attribute - is the underlying true file object. + is the underlying true file object. This file-like object can be used in a :keyword:`with` + statement, just like a normal file. .. function:: SpooledTemporaryFile([max_size=0, [mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir]]]]]]) @@ -79,7 +81,8 @@ The returned object is a file-like object whose :attr:`_file` attribute is either a :class:`StringIO` object or a true file object, depending on - whether :func:`rollover` has been called. + whether :func:`rollover` has been called. This file-like object can be used in a + :keyword:`with` statement, just like a normal file. .. function:: mkstemp([suffix[, prefix[, dir[, text]]]]) Modified: python/branches/py3k/Lib/io.py ============================================================================== --- python/branches/py3k/Lib/io.py (original) +++ python/branches/py3k/Lib/io.py Sat Feb 9 21:51:34 2008 @@ -365,6 +365,7 @@ def __enter__(self) -> "IOBase": # That's a forward reference """Context management protocol. Returns self.""" + self._checkClosed() return self def __exit__(self, *args) -> None: Modified: python/branches/py3k/Lib/tempfile.py ============================================================================== --- python/branches/py3k/Lib/tempfile.py (original) +++ python/branches/py3k/Lib/tempfile.py Sat Feb 9 21:51:34 2008 @@ -363,6 +363,7 @@ raise IOError(_errno.EEXIST, "No usable temporary filename found") + class _TemporaryFileWrapper: """Temporary file wrapper @@ -378,17 +379,25 @@ self.delete = delete def __getattr__(self, name): + # Attribute lookups are delegated to the underlying file + # and cached for non-numeric results + # (i.e. methods are cached, closed and friends are not) file = self.__dict__['file'] a = getattr(file, name) - if type(a) != type(0): + if not isinstance(a, int): setattr(self, name, a) return a + # The underlying __enter__ method returns the wrong object + # (self.file) so override it to return the wrapper + def __enter__(self): + self.file.__enter__() + return self + # NT provides delete-on-close as a primitive, so we don't need # the wrapper to do anything special. We still use it so that # file.name is useful (i.e. not "(fdopen)") with NamedTemporaryFile. if _os.name != 'nt': - # Cache the unlinker so we don't get spurious errors at # shutdown when the module-level "os" is None'd out. Note # that this must be referenced as self.unlink, because the @@ -406,6 +415,14 @@ def __del__(self): self.close() + # Need to trap __exit__ as well to ensure the file gets + # deleted when used in a with statement + def __exit__(self, exc, value, tb): + result = self.file.__exit__(exc, value, tb) + self.close() + return result + + def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix="", prefix=template, dir=None, delete=True): @@ -523,6 +540,20 @@ self._rolled = True + # The method caching trick from NamedTemporaryFile + # won't work here, because _file may change from a + # _StringIO instance to a real file. So we list + # all the methods directly. + + # Context management protocol + def __enter__(self): + if self._file.closed: + raise ValueError("Cannot enter context with closed file") + return self + + def __exit__(self, exc, value, tb): + self._file.close() + # file protocol def __iter__(self): return self._file.__iter__() Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Sat Feb 9 21:51:34 2008 @@ -336,17 +336,17 @@ def test_compact_freelists(self): sys._compact_freelists() r = sys._compact_freelists() - # freed blocks shouldn't change - self.assertEqual(r[0][2], 0) - # fill freelists - ints = list(range(10000)) - floats = [float(i) for i in ints] - del ints - del floats - # should free more than 100 blocks - r = sys._compact_freelists() - self.assert_(r[0][1] > 100, r[0][1]) - self.assert_(r[0][2] > 100, r[0][2]) + ## freed blocks shouldn't change + #self.assertEqual(r[0][2], 0) + ## fill freelists + #ints = list(range(10000)) + #floats = [float(i) for i in ints] + #del ints + #del floats + ## should free more than 100 blocks + #r = sys._compact_freelists() + #self.assert_(r[0][1] > 100, r[0][1]) + #self.assert_(r[0][2] > 100, r[0][2]) def test_main(): test.test_support.run_unittest(SysModuleTest) Modified: python/branches/py3k/Lib/test/test_tempfile.py ============================================================================== --- python/branches/py3k/Lib/test/test_tempfile.py (original) +++ python/branches/py3k/Lib/test/test_tempfile.py Sat Feb 9 21:51:34 2008 @@ -1,5 +1,4 @@ # tempfile.py unit tests. - import tempfile import os import sys @@ -619,7 +618,6 @@ def test_multiple_close(self): # A NamedTemporaryFile can be closed many times without error - f = tempfile.NamedTemporaryFile() f.write(b'abc\n') f.close() @@ -629,6 +627,16 @@ except: self.failOnException("close") + def test_context_manager(self): + # A NamedTemporaryFile can be used as a context manager + with tempfile.NamedTemporaryFile() as f: + self.failUnless(os.path.exists(f.name)) + self.failIf(os.path.exists(f.name)) + def use_closed(): + with f: + pass + self.failUnlessRaises(ValueError, use_closed) + # How to test the mode and bufsize parameters? test_classes.append(test_NamedTemporaryFile) @@ -707,10 +715,23 @@ self.failUnless(f.fileno() > 0) self.failUnless(f._rolled) - def test_multiple_close(self): + def test_multiple_close_before_rollover(self): # A SpooledTemporaryFile can be closed many times without error f = tempfile.SpooledTemporaryFile() f.write(b'abc\n') + self.failIf(f._rolled) + f.close() + try: + f.close() + f.close() + except: + self.failOnException("close") + + def test_multiple_close_after_rollover(self): + # A SpooledTemporaryFile can be closed many times without error + f = tempfile.SpooledTemporaryFile(max_size=1) + f.write(b'abc\n') + self.failUnless(f._rolled) f.close() try: f.close() @@ -759,6 +780,46 @@ self.assertEqual(f.read(), "\u039B\r\n" + ("\u039B" * 20) + "\r\n") self.failUnless(f._rolled) + def test_context_manager_before_rollover(self): + # A SpooledTemporaryFile can be used as a context manager + with tempfile.SpooledTemporaryFile(max_size=1) as f: + self.failIf(f._rolled) + self.failIf(f.closed) + self.failUnless(f.closed) + def use_closed(): + with f: + pass + self.failUnlessRaises(ValueError, use_closed) + + def test_context_manager_during_rollover(self): + # A SpooledTemporaryFile can be used as a context manager + with tempfile.SpooledTemporaryFile(max_size=1) as f: + self.failIf(f._rolled) + f.write(b'abc\n') + f.flush() + self.failUnless(f._rolled) + self.failIf(f.closed) + self.failUnless(f.closed) + def use_closed(): + with f: + pass + self.failUnlessRaises(ValueError, use_closed) + + def test_context_manager_after_rollover(self): + # A SpooledTemporaryFile can be used as a context manager + f = tempfile.SpooledTemporaryFile(max_size=1) + f.write(b'abc\n') + f.flush() + self.failUnless(f._rolled) + with f: + self.failIf(f.closed) + self.failUnless(f.closed) + def use_closed(): + with f: + pass + self.failUnlessRaises(ValueError, use_closed) + + test_classes.append(test_SpooledTemporaryFile) Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Sat Feb 9 21:51:34 2008 @@ -1127,7 +1127,7 @@ { /* This calls the object's class. That only works for subclasses whose class constructor has the same signature. Subclasses that - define a different constructor signature must override copy(). + define a different constructor signature must override __copy__(). */ return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd), dd->default_factory, dd, NULL); @@ -1182,8 +1182,6 @@ static PyMethodDef defdict_methods[] = { {"__missing__", (PyCFunction)defdict_missing, METH_O, defdict_missing_doc}, - {"copy", (PyCFunction)defdict_copy, METH_NOARGS, - defdict_copy_doc}, {"__copy__", (PyCFunction)defdict_copy, METH_NOARGS, defdict_copy_doc}, {"__reduce__", (PyCFunction)defdict_reduce, METH_NOARGS, From python-3000-checkins at python.org Sat Feb 9 21:58:00 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 9 Feb 2008 21:58:00 +0100 (CET) Subject: [Python-3000-checkins] r60699 - in python/branches/py3k: PC/pyconfig.h PC/readme.txt PCbuild/build.bat PCbuild/pyd.vsprops PCbuild/pyd_d.vsprops PCbuild/readme.txt Message-ID: <20080209205800.C45291E400D@bag.python.org> Author: christian.heimes Date: Sat Feb 9 21:58:00 2008 New Revision: 60699 Modified: python/branches/py3k/ (props changed) python/branches/py3k/PC/pyconfig.h python/branches/py3k/PC/readme.txt python/branches/py3k/PCbuild/build.bat python/branches/py3k/PCbuild/pyd.vsprops python/branches/py3k/PCbuild/pyd_d.vsprops python/branches/py3k/PCbuild/readme.txt Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60696-60698 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60696 | christian.heimes | 2008-02-09 20:55:22 +0100 (Sat, 09 Feb 2008) | 5 lines Issue #1706: Require Windows 2000+ Added Py_BUILD_CORE_MODULES macro to set WINVER and NTDDI_VERSION to Windows 2000 for core modules, too Added -d option to build.bat (same as -c Debug) and fixed warning about /build option Updated Windows related readme.txt files ........ Modified: python/branches/py3k/PC/pyconfig.h ============================================================================== --- python/branches/py3k/PC/pyconfig.h (original) +++ python/branches/py3k/PC/pyconfig.h Sat Feb 9 21:58:00 2008 @@ -158,10 +158,12 @@ /* set the version macros for the windows headers */ #ifdef MS_WINX64 /* 64 bit only runs on XP or greater */ -#define Py_WINVER 0x0501 +#define Py_WINVER _WIN32_WINNT_WINXP +#define Py_NTDDI NTDDI_WINXP #else -/* NT 4.0 or greater required otherwise */ -#define Py_WINVER 0x0400 +/* Python 2.6+ requires Windows 2000 or greater */ +#define Py_WINVER _WIN32_WINNT_WIN2K +#define Py_NTDDI NTDDI_WIN2KSP4 #endif /* We only set these values when building Python - we don't want to force @@ -171,7 +173,10 @@ structures etc so it can optionally use new Windows features if it determines at runtime they are available. */ -#ifdef Py_BUILD_CORE +#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE) +#ifndef NTDDI_VERSION +#define NTDDI_VERSION Py_NTDDI +#endif #ifndef WINVER #define WINVER Py_WINVER #endif Modified: python/branches/py3k/PC/readme.txt ============================================================================== --- python/branches/py3k/PC/readme.txt (original) +++ python/branches/py3k/PC/readme.txt Sat Feb 9 21:58:00 2008 @@ -1,11 +1,6 @@ Welcome to the "PC" subdirectory of the Python distribution *********************************************************** -*** Note: the project files for MS VC++ 7.1 are now in the -*** PCbuild directory. See the file readme.txt there for build -*** instructions. There is some information below that might -*** still be relevant. - This "PC" subdirectory contains complete project files to make several older PC ports of Python, as well as all the PC-specific Python source files. It should be located in the root of the @@ -79,18 +74,23 @@ example_nt A subdirectory showing how to build an extension as a DLL. -Visual Studio 6.0 -================= -The subdirectory VC6 contains Visual Studio 6 project files. These -were originally located in the PCBuild directory, but are no longer -maintained. +Legacy support for older versions of Visual Studio +================================================== +The subdirectories VC6, VS7.1 and VS8.0 contain legacy support older +versions of Microsoft Visual Studio. See PCbuild/readme.txt. + +EMX development tools for OS/2 +============================== +See os2emx/readme.txt. This platform is maintained by Andrew MacIntyre. IBM VisualAge C/C++ for OS/2 ============================ See os2vacpp/readme.txt. This platform is supported by Jeff Rush. +NOTE: Support for os2vacpp may be dropped in the near future. Please move + to EMX. Note for Windows 3.x and DOS users ================================== Modified: python/branches/py3k/PCbuild/build.bat ============================================================================== --- python/branches/py3k/PCbuild/build.bat (original) +++ python/branches/py3k/PCbuild/build.bat Sat Feb 9 21:58:00 2008 @@ -5,12 +5,13 @@ setlocal set platf=Win32 set conf=Release -set build=/build +set build= :CheckOpts -if "%1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts +if "%1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts -if "%1"=="-r" (set build=/rebuild) & shift & goto CheckOpts +if "%1"=="-r" (set build=/rebuild) & shift & goto CheckOpts +if "%1"=="-d" (set conf=Debug) & shift & goto CheckOpts set cmd=vcbuild /useenv pcbuild.sln %build% "%conf%|%platf%" echo %cmd% Modified: python/branches/py3k/PCbuild/pyd.vsprops ============================================================================== --- python/branches/py3k/PCbuild/pyd.vsprops (original) +++ python/branches/py3k/PCbuild/pyd.vsprops Sat Feb 9 21:58:00 2008 @@ -7,6 +7,7 @@ > All Programs -> Microsoft Visual Studio 2008 @@ -285,7 +288,7 @@ NOTE: Official support for Itanium builds have been dropped from the build. Please -contact as and provide patches if you are interested in Itanium builds. +contact us and provide patches if you are interested in Itanium builds. The project files support a ReleaseItanium configuration which creates Win64/Itanium binaries. For this to work, you need to install the Platform From python-3000-checkins at python.org Sun Feb 10 02:44:44 2008 From: python-3000-checkins at python.org (eric.smith) Date: Sun, 10 Feb 2008 02:44:44 +0100 (CET) Subject: [Python-3000-checkins] r60708 - python/branches/py3k Message-ID: <20080210014444.621281E400D@bag.python.org> Author: eric.smith Date: Sun Feb 10 02:44:44 2008 New Revision: 60708 Modified: python/branches/py3k/ (props changed) Log: r60707 does not need porting to py3k from trunk. From python-3000-checkins at python.org Sun Feb 10 16:09:40 2008 From: python-3000-checkins at python.org (eric.smith) Date: Sun, 10 Feb 2008 16:09:40 +0100 (CET) Subject: [Python-3000-checkins] r60714 - python/branches/py3k Message-ID: <20080210150940.C8DC81E4006@bag.python.org> Author: eric.smith Date: Sun Feb 10 16:09:40 2008 New Revision: 60714 Modified: python/branches/py3k/ (props changed) Log: Block r60713 with svnmerge. From python-3000-checkins at python.org Sun Feb 10 21:41:56 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Sun, 10 Feb 2008 21:41:56 +0100 (CET) Subject: [Python-3000-checkins] r60720 - python/branches/py3k/Lib/shelve.py Message-ID: <20080210204156.6B9391E4028@bag.python.org> Author: raymond.hettinger Date: Sun Feb 10 21:41:56 2008 New Revision: 60720 Modified: python/branches/py3k/Lib/shelve.py Log: The new default protocol is two. Modified: python/branches/py3k/Lib/shelve.py ============================================================================== --- python/branches/py3k/Lib/shelve.py (original) +++ python/branches/py3k/Lib/shelve.py Sun Feb 10 21:41:56 2008 @@ -75,7 +75,7 @@ keyencoding="utf-8"): self.dict = dict if protocol is None: - protocol = 0 + protocol = 2 self._protocol = protocol self.writeback = writeback self.cache = {} From python-3000-checkins at python.org Mon Feb 11 07:19:19 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 11 Feb 2008 07:19:19 +0100 (CET) Subject: [Python-3000-checkins] r60725 - in python/branches/py3k: Demo/classes/README Doc/README.txt Doc/conf.py Doc/extending/windows.rst Doc/library/decimal.rst Doc/library/fractions.rst Doc/library/numbers.rst Doc/library/pickletools.rst Doc/library/rational.rst Doc/whatsnew/2.6.rst Lib/decimal.py Lib/fractions.py Lib/pickletools.py Lib/rational.py Lib/test/test_builtin.py Lib/test/test_fractions.py Lib/test/test_rational.py Modules/_collectionsmodule.c Message-ID: <20080211061919.5D97E1E400F@bag.python.org> Author: christian.heimes Date: Mon Feb 11 07:19:17 2008 New Revision: 60725 Added: python/branches/py3k/Doc/library/fractions.rst - copied, changed from r60724, python/branches/py3k/Doc/library/rational.rst python/branches/py3k/Lib/fractions.py - copied, changed from r60724, python/branches/py3k/Lib/rational.py python/branches/py3k/Lib/test/test_fractions.py - copied, changed from r60724, python/branches/py3k/Lib/test/test_rational.py Removed: python/branches/py3k/Doc/library/rational.rst python/branches/py3k/Lib/rational.py python/branches/py3k/Lib/test/test_rational.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/classes/README python/branches/py3k/Doc/README.txt python/branches/py3k/Doc/conf.py python/branches/py3k/Doc/extending/windows.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/numbers.rst python/branches/py3k/Doc/library/pickletools.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/pickletools.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Modules/_collectionsmodule.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60706,60708-60712,60714-60724 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60701 | georg.brandl | 2008-02-09 22:36:15 +0100 (Sat, 09 Feb 2008) | 2 lines Needs only 2.4 now. ........ r60702 | georg.brandl | 2008-02-09 22:38:54 +0100 (Sat, 09 Feb 2008) | 2 lines Docs are rst now. ........ r60703 | georg.brandl | 2008-02-09 23:00:00 +0100 (Sat, 09 Feb 2008) | 2 lines Fix link. ........ r60704 | georg.brandl | 2008-02-10 00:09:25 +0100 (Sun, 10 Feb 2008) | 2 lines Fix for newest doctools. ........ r60709 | raymond.hettinger | 2008-02-10 08:21:09 +0100 (Sun, 10 Feb 2008) | 1 line Clarify that decimal also supports fixed-point arithmetic. ........ r60710 | nick.coghlan | 2008-02-10 08:32:52 +0100 (Sun, 10 Feb 2008) | 1 line Add missing NEWS entry for r60695 ........ r60712 | mark.dickinson | 2008-02-10 15:58:38 +0100 (Sun, 10 Feb 2008) | 3 lines Turn classmethods into staticmethods, and avoid calling the constructor of subclasses of Rational. (See discussion in issue #1682.) ........ r60715 | mark.dickinson | 2008-02-10 16:19:58 +0100 (Sun, 10 Feb 2008) | 2 lines Typos in decimal comment and documentation ........ r60716 | skip.montanaro | 2008-02-10 16:31:54 +0100 (Sun, 10 Feb 2008) | 2 lines Get the saying right. ;-) ........ r60717 | skip.montanaro | 2008-02-10 16:32:16 +0100 (Sun, 10 Feb 2008) | 2 lines whoops - revert ........ r60718 | mark.dickinson | 2008-02-10 20:23:36 +0100 (Sun, 10 Feb 2008) | 2 lines Remove reference to Rational ........ r60719 | raymond.hettinger | 2008-02-10 21:35:16 +0100 (Sun, 10 Feb 2008) | 1 line Complete an open todo on pickletools -- add a pickle optimizer. ........ r60721 | mark.dickinson | 2008-02-10 22:29:51 +0100 (Sun, 10 Feb 2008) | 3 lines Rename rational.Rational to fractions.Fraction, to avoid name clash with numbers.Rational. See issue #1682 for related discussion. ........ r60722 | christian.heimes | 2008-02-11 03:26:22 +0100 (Mon, 11 Feb 2008) | 1 line The test requires the network resource ........ r60723 | mark.dickinson | 2008-02-11 04:11:55 +0100 (Mon, 11 Feb 2008) | 3 lines Put an extra space into the repr of a Fraction: Fraction(1, 2) instead of Fraction(1,2). ........ Modified: python/branches/py3k/Demo/classes/README ============================================================================== --- python/branches/py3k/Demo/classes/README (original) +++ python/branches/py3k/Demo/classes/README Mon Feb 11 07:19:17 2008 @@ -4,7 +4,6 @@ Dates.py Date manipulation package by Tim Peters Dbm.py Wrapper around built-in dbm, supporting arbitrary values Range.py Example of a generator: re-implement built-in range() -Rat.py Rational numbers Rev.py Yield the reverse of a sequence Vec.py A simple vector class bitvec.py A bit-vector class by Jan-Hein B\"uhrman Modified: python/branches/py3k/Doc/README.txt ============================================================================== --- python/branches/py3k/Doc/README.txt (original) +++ python/branches/py3k/Doc/README.txt Mon Feb 11 07:19:17 2008 @@ -14,7 +14,7 @@ Building the docs ================= -You need to install Python 2.5.1 or higher (but Python 3.0 is not supported yet); +You need to install Python 2.4 or higher (but Python 3.0 is not supported yet); the toolset used to build the docs are written in Python. The toolset used to build the documentation is called *Sphinx*, it is not included in this tree, but maintained separately in the Python Subversion repository. Also @@ -55,7 +55,7 @@ * "latex", which builds LaTeX source files that can be run with "pdflatex" to produce PDF documents. - + * "linkcheck", which checks all external references to see whether they are broken, redirected or malformed, and outputs this information to stdout as well as a plain-text (.txt) file. Modified: python/branches/py3k/Doc/conf.py ============================================================================== --- python/branches/py3k/Doc/conf.py (original) +++ python/branches/py3k/Doc/conf.py Mon Feb 11 07:19:17 2008 @@ -38,17 +38,17 @@ today_fmt = '%B %d, %Y' # List of files that shouldn't be included in the build. -unused_files = [ - 'whatsnew/2.0.rst', - 'whatsnew/2.1.rst', - 'whatsnew/2.2.rst', - 'whatsnew/2.3.rst', - 'whatsnew/2.4.rst', - 'whatsnew/2.5.rst', - 'whatsnew/2.6.rst', - 'maclib/scrap.rst', - 'library/xmllib.rst', - 'library/xml.etree.rst', +unused_docs = [ + 'whatsnew/2.0', + 'whatsnew/2.1', + 'whatsnew/2.2', + 'whatsnew/2.3', + 'whatsnew/2.4', + 'whatsnew/2.5', + 'whatsnew/2.6', + 'maclib/scrap', + 'library/xmllib', + 'library/xml.etree', ] # Relative filename of the reference count data file. Modified: python/branches/py3k/Doc/extending/windows.rst ============================================================================== --- python/branches/py3k/Doc/extending/windows.rst (original) +++ python/branches/py3k/Doc/extending/windows.rst Mon Feb 11 07:19:17 2008 @@ -179,7 +179,7 @@ MyObject_Type.ob_type = &PyType_Type; -Refer to section 3 of the `Python FAQ `_ for +Refer to section 3 of the `Python FAQ `_ for details on why you must do this. Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Mon Feb 11 07:19:17 2008 @@ -1,6 +1,6 @@ -:mod:`decimal` --- Decimal floating point arithmetic -==================================================== +:mod:`decimal` --- Decimal fixed point and floating point arithmetic +==================================================================== .. module:: decimal :synopsis: Implementation of the General Decimal Arithmetic Specification. @@ -16,6 +16,11 @@ The :mod:`decimal` module provides support for decimal floating point arithmetic. It offers several advantages over the :class:`float` datatype: +* Decimal "is based on a floating-point model which was designed with people + in mind, and necessarily has a paramount guiding principle -- computers must + provide an arithmetic that works in the same way as the arithmetic that + people learn at school." -- excerpt from the decimal arithmetic specification. + * Decimal numbers can be represented exactly. In contrast, numbers like :const:`1.1` do not have an exact representation in binary floating point. End users typically would not expect :const:`1.1` to display as @@ -25,7 +30,7 @@ + 0.1 + 0.1 - 0.3`` is exactly equal to zero. In binary floating point, the result is :const:`5.5511151231257827e-017`. While near to zero, the differences prevent reliable equality testing and differences can accumulate. For this - reason, decimal would be preferred in accounting applications which have strict + reason, decimal is preferred in accounting applications which have strict equality invariants. * The decimal module incorporates a notion of significant places so that ``1.30 @@ -50,6 +55,13 @@ standards. While the built-in float type exposes only a modest portion of its capabilities, the decimal module exposes all required parts of the standard. When needed, the programmer has full control over rounding and signal handling. + This includes an option to enforce exact arithmetic by using exceptions + to block any inexact operations. + +* The decimal module was designed to support "without prejudice, both exact + unrounded decimal arithmetic (sometimes called fixed-point arithmetic) + and rounded floating-point arithmetic." -- excerpt from the decimal + arithmetic specification. The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals. @@ -832,7 +844,7 @@ :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). - Because the trapped are disabled, this context is useful for applications that + Because the traps are disabled, this context is useful for applications that prefer to have result value of :const:`NaN` or :const:`Infinity` instead of raising exceptions. This allows an application to complete a run in the presence of conditions that would otherwise halt the program. @@ -1245,7 +1257,7 @@ :const:`True`. An attempt to compare two Decimals using any of the ``<``, ``<=``, ``>`` or ``>=`` operators will raise the :exc:`InvalidOperation` signal if either operand is a :const:`NaN`, and return :const:`False` if this signal is -trapped. Note that the General Decimal Arithmetic specification does not +not trapped. Note that the General Decimal Arithmetic specification does not specify the behavior of direct comparisons; these rules for comparisons involving a :const:`NaN` were taken from the IEEE 854 standard (see Table 3 in section 5.7). To ensure strict standards-compliance, use the :meth:`compare` Copied: python/branches/py3k/Doc/library/fractions.rst (from r60724, python/branches/py3k/Doc/library/rational.rst) ============================================================================== --- python/branches/py3k/Doc/library/rational.rst (original) +++ python/branches/py3k/Doc/library/fractions.rst Mon Feb 11 07:19:17 2008 @@ -1,28 +1,28 @@ -:mod:`rational` --- Rational numbers +:mod:`fractions` --- Rational numbers ==================================== -.. module:: rational +.. module:: fractions :synopsis: Rational numbers. .. moduleauthor:: Jeffrey Yasskin .. sectionauthor:: Jeffrey Yasskin .. versionadded:: 2.6 -The :mod:`rational` module defines an immutable, infinite-precision +The :mod:`fractions` module defines an immutable, infinite-precision Rational number class. -.. class:: Rational(numerator=0, denominator=1) - Rational(other_rational) - Rational(string) +.. class:: Fraction(numerator=0, denominator=1) + Fraction(other_fraction) + Fraction(string) The first version requires that *numerator* and *denominator* are instances of :class:`numbers.Integral` and returns a new - ``Rational`` representing ``numerator/denominator``. If + ``Fraction`` representing ``numerator/denominator``. If *denominator* is :const:`0`, raises a :exc:`ZeroDivisionError`. The - second version requires that *other_rational* is an instance of - :class:`numbers.Rational` and returns an instance of + second version requires that *other_fraction* is an instance of + :class:`numbers.Fraction` and returns an instance of :class:`Rational` with the same value. The third version expects a string of the form ``[-+]?[0-9]+(/[0-9]+)?``, optionally surrounded by spaces. @@ -31,39 +31,39 @@ :class:`numbers.Rational` and is immutable and hashable. -.. method:: Rational.from_float(flt) +.. method:: Fraction.from_float(flt) - This classmethod constructs a :class:`Rational` representing the + This classmethod constructs a :class:`Fraction` representing the exact value of *flt*, which must be a :class:`float`. Beware that - ``Rational.from_float(0.3)`` is not the same value as ``Rational(3, + ``Fraction.from_float(0.3)`` is not the same value as ``Rational(3, 10)`` -.. method:: Rational.from_decimal(dec) +.. method:: Fraction.from_decimal(dec) - This classmethod constructs a :class:`Rational` representing the + This classmethod constructs a :class:`Fraction` representing the exact value of *dec*, which must be a :class:`decimal.Decimal`. -.. method:: Rational.__floor__() +.. method:: Fraction.__floor__() Returns the greatest :class:`int` ``<= self``. Will be accessible through :func:`math.floor` in Py3k. -.. method:: Rational.__ceil__() +.. method:: Fraction.__ceil__() Returns the least :class:`int` ``>= self``. Will be accessible through :func:`math.ceil` in Py3k. -.. method:: Rational.__round__() - Rational.__round__(ndigits) +.. method:: Fraction.__round__() + Fraction.__round__(ndigits) The first version returns the nearest :class:`int` to ``self``, rounding half to even. The second version rounds ``self`` to the - nearest multiple of ``Rational(1, 10**ndigits)`` (logically, if + nearest multiple of ``Fraction(1, 10**ndigits)`` (logically, if ``ndigits`` is negative), again rounding half toward even. Will be accessible through :func:`round` in Py3k. Modified: python/branches/py3k/Doc/library/numbers.rst ============================================================================== --- python/branches/py3k/Doc/library/numbers.rst (original) +++ python/branches/py3k/Doc/library/numbers.rst Mon Feb 11 07:19:17 2008 @@ -104,7 +104,7 @@ Implementors should be careful to make equal numbers equal and hash them to the same values. This may be subtle if there are two different -extensions of the real numbers. For example, :class:`rational.Rational` +extensions of the real numbers. For example, :class:`fractions.Fraction` implements :func:`hash` as follows:: def __hash__(self): @@ -199,11 +199,11 @@ Because most of the operations on any given type will be very similar, it can be useful to define a helper function which generates the forward and reverse instances of any given operator. For example, -:class:`rational.Rational` uses:: +:class:`fractions.Fraction` uses:: def _operator_fallbacks(monomorphic_operator, fallback_operator): def forward(a, b): - if isinstance(b, (int, long, Rational)): + if isinstance(b, (int, long, Fraction)): return monomorphic_operator(a, b) elif isinstance(b, float): return fallback_operator(float(a), b) @@ -215,7 +215,7 @@ forward.__doc__ = monomorphic_operator.__doc__ def reverse(b, a): - if isinstance(a, RationalAbc): + if isinstance(a, Rational): # Includes ints. return monomorphic_operator(a, b) elif isinstance(a, numbers.Real): @@ -231,7 +231,7 @@ def _add(a, b): """a + b""" - return Rational(a.numerator * b.denominator + + return Fraction(a.numerator * b.denominator + b.numerator * a.denominator, a.denominator * b.denominator) Modified: python/branches/py3k/Doc/library/pickletools.rst ============================================================================== --- python/branches/py3k/Doc/library/pickletools.rst (original) +++ python/branches/py3k/Doc/library/pickletools.rst Mon Feb 11 07:19:17 2008 @@ -33,3 +33,10 @@ the opcode's argument; *pos* is the position at which this opcode is located. *pickle* can be a string or a file-like object. +.. function:: optimize(picklestring) + + Returns a new equivalent pickle string after eliminating unused ``PUT`` + opcodes. The optimized pickle is shorter, takes less transmission time, + requires less storage space, and unpickles more efficiently. + + .. versionadded:: 2.6 Deleted: /python/branches/py3k/Doc/library/rational.rst ============================================================================== --- /python/branches/py3k/Doc/library/rational.rst Mon Feb 11 07:19:17 2008 +++ (empty file) @@ -1,75 +0,0 @@ - -:mod:`rational` --- Rational numbers -==================================== - -.. module:: rational - :synopsis: Rational numbers. -.. moduleauthor:: Jeffrey Yasskin -.. sectionauthor:: Jeffrey Yasskin -.. versionadded:: 2.6 - - -The :mod:`rational` module defines an immutable, infinite-precision -Rational number class. - - -.. class:: Rational(numerator=0, denominator=1) - Rational(other_rational) - Rational(string) - - The first version requires that *numerator* and *denominator* are - instances of :class:`numbers.Integral` and returns a new - ``Rational`` representing ``numerator/denominator``. If - *denominator* is :const:`0`, raises a :exc:`ZeroDivisionError`. The - second version requires that *other_rational* is an instance of - :class:`numbers.Rational` and returns an instance of - :class:`Rational` with the same value. The third version expects a - string of the form ``[-+]?[0-9]+(/[0-9]+)?``, optionally surrounded - by spaces. - - Implements all of the methods and operations from - :class:`numbers.Rational` and is immutable and hashable. - - -.. method:: Rational.from_float(flt) - - This classmethod constructs a :class:`Rational` representing the - exact value of *flt*, which must be a :class:`float`. Beware that - ``Rational.from_float(0.3)`` is not the same value as ``Rational(3, - 10)`` - - -.. method:: Rational.from_decimal(dec) - - This classmethod constructs a :class:`Rational` representing the - exact value of *dec*, which must be a - :class:`decimal.Decimal`. - - -.. method:: Rational.__floor__() - - Returns the greatest :class:`int` ``<= self``. Will be accessible - through :func:`math.floor` in Py3k. - - -.. method:: Rational.__ceil__() - - Returns the least :class:`int` ``>= self``. Will be accessible - through :func:`math.ceil` in Py3k. - - -.. method:: Rational.__round__() - Rational.__round__(ndigits) - - The first version returns the nearest :class:`int` to ``self``, - rounding half to even. The second version rounds ``self`` to the - nearest multiple of ``Rational(1, 10**ndigits)`` (logically, if - ``ndigits`` is negative), again rounding half toward even. Will be - accessible through :func:`round` in Py3k. - - -.. seealso:: - - Module :mod:`numbers` - The abstract base classes making up the numeric tower. - Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Mon Feb 11 07:19:17 2008 @@ -578,8 +578,8 @@ :class:`Rational` numbers derive from :class:`Real`, have :attr:`numerator` and :attr:`denominator` properties, and can be -converted to floats. Python 2.6 adds a simple rational-number class -in the :mod:`rational` module. +converted to floats. Python 2.6 adds a simple rational-number class, +:class:`Fraction`, in the :mod:`fractions` module. :class:`Integral` numbers derive from :class:`Rational`, and can be shifted left and right with ``<<`` and ``>>``, @@ -598,29 +598,29 @@ -The Rational Module +The Fraction Module -------------------------------------------------- To fill out the hierarchy of numeric types, a rational-number class -has been added as the :mod:`rational` module. Rational numbers are +has been added as the :mod:`fractions` module. Rational numbers are represented as a fraction; rational numbers can exactly represent numbers such as two-thirds that floating-point numbers can only approximate. -The :class:`Rational` constructor takes two :class:`Integral` values +The :class:`Fraction` constructor takes two :class:`Integral` values that will be the numerator and denominator of the resulting fraction. :: - >>> from rational import Rational - >>> a = Rational(2, 3) - >>> b = Rational(2, 5) + >>> from fractions import Fraction + >>> a = Fraction(2, 3) + >>> b = Fraction(2, 5) >>> float(a), float(b) (0.66666666666666663, 0.40000000000000002) >>> a+b - rational.Rational(16,15) + Fraction(16, 15) >>> a/b - rational.Rational(5,3) + Fraction(5, 3) -The :mod:`rational` module is based upon an implementation by Sjoerd +The :mod:`fractions` module is based upon an implementation by Sjoerd Mullender that was in Python's :file:`Demo/classes/` directory for a long time. This implementation was significantly updated by Jeffrey Yaskin. Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Mon Feb 11 07:19:17 2008 @@ -802,7 +802,7 @@ # != comparisons involving a NaN always return True # <, >, <= and >= comparisons involving a (quiet or signaling) # NaN signal InvalidOperation, and return False if the - # InvalidOperation is trapped. + # InvalidOperation is not trapped. # # This behavior is designed to conform as closely as possible to # that specified by IEEE 754. Copied: python/branches/py3k/Lib/fractions.py (from r60724, python/branches/py3k/Lib/rational.py) ============================================================================== --- python/branches/py3k/Lib/rational.py (original) +++ python/branches/py3k/Lib/fractions.py Mon Feb 11 07:19:17 2008 @@ -1,16 +1,15 @@ # Originally contributed by Sjoerd Mullender. # Significantly modified by Jeffrey Yasskin . -"""Rational, infinite-precision, real numbers.""" +"""Fraction, infinite-precision, real numbers.""" import math import numbers import operator import re -__all__ = ["Rational"] +__all__ = ["Fraction"] -RationalAbc = numbers.Rational def gcd(a, b): @@ -38,15 +37,15 @@ """, re.VERBOSE) -class Rational(RationalAbc): +class Fraction(numbers.Rational): """This class implements rational numbers. - Rational(8, 6) will produce a rational number equivalent to + Fraction(8, 6) will produce a rational number equivalent to 4/3. Both arguments must be Integral. The numerator defaults to 0 - and the denominator defaults to 1 so that Rational(3) == 3 and - Rational() == 0. + and the denominator defaults to 1 so that Fraction(3) == 3 and + Fraction() == 0. - Rationals can also be constructed from strings of the form + Fraction can also be constructed from strings of the form '[-+]?[0-9]+((/|.)[0-9]+)?', optionally surrounded by spaces. """ @@ -61,7 +60,7 @@ numerator/denominator pair. """ - self = super(Rational, cls).__new__(cls) + self = super(Fraction, cls).__new__(cls) if denominator == 1: if isinstance(numerator, str): @@ -69,7 +68,7 @@ input = numerator m = _RATIONAL_FORMAT.match(input) if m is None: - raise ValueError('Invalid literal for Rational: ' + input) + raise ValueError('Invalid literal for Fraction: ' + input) numerator = m.group('num') decimal = m.group('decimal') if decimal: @@ -86,7 +85,7 @@ numerator = -numerator elif (not isinstance(numerator, numbers.Integral) and - isinstance(numerator, RationalAbc)): + isinstance(numerator, numbers.Rational)): # Handle copies from other rationals. other_rational = numerator numerator = other_rational.numerator @@ -94,11 +93,11 @@ if (not isinstance(numerator, numbers.Integral) or not isinstance(denominator, numbers.Integral)): - raise TypeError("Rational(%(numerator)s, %(denominator)s):" + raise TypeError("Fraction(%(numerator)s, %(denominator)s):" " Both arguments must be integral." % locals()) if denominator == 0: - raise ZeroDivisionError('Rational(%s, 0)' % numerator) + raise ZeroDivisionError('Fraction(%s, 0)' % numerator) g = gcd(numerator, denominator) self._numerator = int(numerator // g) @@ -109,7 +108,7 @@ def from_float(cls, f): """Converts a finite float to a rational number, exactly. - Beware that Rational.from_float(0.3) != Rational(3, 10). + Beware that Fraction.from_float(0.3) != Fraction(3, 10). """ if not isinstance(f, float): @@ -141,7 +140,7 @@ @classmethod def from_continued_fraction(cls, seq): - 'Build a Rational from a continued fraction expessed as a sequence' + 'Build a Fraction from a continued fraction expessed as a sequence' n, d = 1, 0 for e in reversed(seq): n, d = d, n @@ -168,7 +167,7 @@ if self.denominator <= max_denominator: return self cf = self.as_continued_fraction() - result = Rational(0) + result = Fraction(0) for i in range(1, len(cf)): new = self.from_continued_fraction(cf[:i]) if new.denominator > max_denominator: @@ -186,7 +185,7 @@ def __repr__(self): """repr(self)""" - return ('Rational(%r,%r)' % (self.numerator, self.denominator)) + return ('Fraction(%r,%r)' % (self.numerator, self.denominator)) def __str__(self): """str(self)""" @@ -206,13 +205,13 @@ that mixed-mode operations either call an implementation whose author knew about the types of both arguments, or convert both to the nearest built in type and do the operation there. In - Rational, that means that we define __add__ and __radd__ as: + Fraction, that means that we define __add__ and __radd__ as: def __add__(self, other): # Both types have numerators/denominator attributes, # so do the operation directly - if isinstance(other, (int, Rational)): - return Rational(self.numerator * other.denominator + + if isinstance(other, (int, Fraction)): + return Fraction(self.numerator * other.denominator + other.numerator * self.denominator, self.denominator * other.denominator) # float and complex don't have those operations, but we @@ -227,8 +226,8 @@ def __radd__(self, other): # radd handles more types than add because there's # nothing left to fall back to. - if isinstance(other, RationalAbc): - return Rational(self.numerator * other.denominator + + if isinstance(other, numbers.Rational): + return Fraction(self.numerator * other.denominator + other.numerator * self.denominator, self.denominator * other.denominator) elif isinstance(other, Real): @@ -239,32 +238,32 @@ There are 5 different cases for a mixed-type addition on - Rational. I'll refer to all of the above code that doesn't - refer to Rational, float, or complex as "boilerplate". 'r' - will be an instance of Rational, which is a subtype of - RationalAbc (r : Rational <: RationalAbc), and b : B <: + Fraction. I'll refer to all of the above code that doesn't + refer to Fraction, float, or complex as "boilerplate". 'r' + will be an instance of Fraction, which is a subtype of + Rational (r : Fraction <: Rational), and b : B <: Complex. The first three involve 'r + b': - 1. If B <: Rational, int, float, or complex, we handle + 1. If B <: Fraction, int, float, or complex, we handle that specially, and all is well. - 2. If Rational falls back to the boilerplate code, and it + 2. If Fraction falls back to the boilerplate code, and it were to return a value from __add__, we'd miss the possibility that B defines a more intelligent __radd__, so the boilerplate should return NotImplemented from - __add__. In particular, we don't handle RationalAbc + __add__. In particular, we don't handle Rational here, even though we could get an exact answer, in case the other type wants to do something special. - 3. If B <: Rational, Python tries B.__radd__ before - Rational.__add__. This is ok, because it was - implemented with knowledge of Rational, so it can + 3. If B <: Fraction, Python tries B.__radd__ before + Fraction.__add__. This is ok, because it was + implemented with knowledge of Fraction, so it can handle those instances before delegating to Real or Complex. The next two situations describe 'b + r'. We assume that b - didn't know about Rational in its implementation, and that it + didn't know about Fraction in its implementation, and that it uses similar boilerplate code: - 4. If B <: RationalAbc, then __radd_ converts both to the + 4. If B <: Rational, then __radd_ converts both to the builtin rational type (hey look, that's us) and proceeds. 5. Otherwise, __radd__ tries to find the nearest common @@ -276,7 +275,7 @@ """ def forward(a, b): - if isinstance(b, (int, Rational)): + if isinstance(b, (int, Fraction)): return monomorphic_operator(a, b) elif isinstance(b, float): return fallback_operator(float(a), b) @@ -288,7 +287,7 @@ forward.__doc__ = monomorphic_operator.__doc__ def reverse(b, a): - if isinstance(a, RationalAbc): + if isinstance(a, numbers.Rational): # Includes ints. return monomorphic_operator(a, b) elif isinstance(a, numbers.Real): @@ -304,7 +303,7 @@ def _add(a, b): """a + b""" - return Rational(a.numerator * b.denominator + + return Fraction(a.numerator * b.denominator + b.numerator * a.denominator, a.denominator * b.denominator) @@ -312,7 +311,7 @@ def _sub(a, b): """a - b""" - return Rational(a.numerator * b.denominator - + return Fraction(a.numerator * b.denominator - b.numerator * a.denominator, a.denominator * b.denominator) @@ -320,13 +319,13 @@ def _mul(a, b): """a * b""" - return Rational(a.numerator * b.numerator, a.denominator * b.denominator) + return Fraction(a.numerator * b.numerator, a.denominator * b.denominator) __mul__, __rmul__ = _operator_fallbacks(_mul, operator.mul) def _div(a, b): """a / b""" - return Rational(a.numerator * b.denominator, + return Fraction(a.numerator * b.denominator, a.denominator * b.numerator) __truediv__, __rtruediv__ = _operator_fallbacks(_div, operator.truediv) @@ -357,14 +356,14 @@ result will be rational. """ - if isinstance(b, RationalAbc): + if isinstance(b, numbers.Rational): if b.denominator == 1: power = b.numerator if power >= 0: - return Rational(a.numerator ** power, + return Fraction(a.numerator ** power, a.denominator ** power) else: - return Rational(a.denominator ** -power, + return Fraction(a.denominator ** -power, a.numerator ** -power) else: # A fractional power will generally produce an @@ -379,8 +378,8 @@ # If a is an int, keep it that way if possible. return a ** b.numerator - if isinstance(a, RationalAbc): - return Rational(a.numerator, a.denominator) ** b + if isinstance(a, numbers.Rational): + return Fraction(a.numerator, a.denominator) ** b if b.denominator == 1: return a ** b.numerator @@ -388,16 +387,16 @@ return a ** float(b) def __pos__(a): - """+a: Coerces a subclass instance to Rational""" - return Rational(a.numerator, a.denominator) + """+a: Coerces a subclass instance to Fraction""" + return Fraction(a.numerator, a.denominator) def __neg__(a): """-a""" - return Rational(-a.numerator, a.denominator) + return Fraction(-a.numerator, a.denominator) def __abs__(a): """abs(a)""" - return Rational(abs(a.numerator), a.denominator) + return Fraction(abs(a.numerator), a.denominator) def __trunc__(a): """trunc(a)""" @@ -433,12 +432,12 @@ return floor + 1 shift = 10**abs(ndigits) # See _operator_fallbacks.forward to check that the results of - # these operations will always be Rational and therefore have + # these operations will always be Fraction and therefore have # round(). if ndigits > 0: - return Rational(round(self * shift), shift) + return Fraction(round(self * shift), shift) else: - return Rational(round(self / shift) * shift) + return Fraction(round(self / shift) * shift) def __hash__(self): """hash(self) @@ -461,7 +460,7 @@ def __eq__(a, b): """a == b""" - if isinstance(b, RationalAbc): + if isinstance(b, numbers.Rational): return (a.numerator == b.numerator and a.denominator == b.denominator) if isinstance(b, numbers.Complex) and b.imag == 0: @@ -488,7 +487,7 @@ if isinstance(b, float): b = a.from_float(b) try: - # XXX: If b <: Real but not <: RationalAbc, this is likely + # XXX: If b <: Real but not <: Rational, this is likely # to fall back to a float. If the actual values differ by # less than MIN_FLOAT, this could falsely call them equal, # which would make <= inconsistent with ==. Better ways of @@ -496,7 +495,7 @@ diff = a - b except TypeError: return NotImplemented - if isinstance(diff, RationalAbc): + if isinstance(diff, numbers.Rational): return op(diff.numerator, 0) return op(diff, 0) @@ -526,11 +525,11 @@ return (self.__class__, (str(self),)) def __copy__(self): - if type(self) == Rational: + if type(self) == Fraction: return self # I'm immutable; therefore I am my own clone return self.__class__(self.numerator, self.denominator) def __deepcopy__(self, memo): - if type(self) == Rational: + if type(self) == Fraction: return self # My components are also immutable return self.__class__(self.numerator, self.denominator) Modified: python/branches/py3k/Lib/pickletools.py ============================================================================== --- python/branches/py3k/Lib/pickletools.py (original) +++ python/branches/py3k/Lib/pickletools.py Mon Feb 11 07:19:17 2008 @@ -14,9 +14,7 @@ import pickle import re -__all__ = ['dis', - 'genops', - ] +__all__ = ['dis', 'genops', 'optimize'] bytes_types = pickle.bytes_types @@ -1836,6 +1834,33 @@ break ############################################################################## +# A pickle optimizer. + +def optimize(p): + 'Optimize a pickle string by removing unused PUT opcodes' + gets = set() # set of args used by a GET opcode + puts = [] # (arg, startpos, stoppos) for the PUT opcodes + prevpos = None # set to pos if previous opcode was a PUT + for opcode, arg, pos in genops(p): + if prevpos is not None: + puts.append((prevarg, prevpos, pos)) + prevpos = None + if 'PUT' in opcode.name: + prevarg, prevpos = arg, pos + elif 'GET' in opcode.name: + gets.add(arg) + + # Copy the pickle string except for PUTS without a corresponding GET + s = [] + i = 0 + for arg, start, stop in puts: + j = stop if (arg in gets) else start + s.append(p[i:j]) + i = stop + s.append(p[i:]) + return ''.join(s) + +############################################################################## # A symbolic pickle disassembler. def dis(pickle, out=None, memo=None, indentlevel=4): Deleted: /python/branches/py3k/Lib/rational.py ============================================================================== --- /python/branches/py3k/Lib/rational.py Mon Feb 11 07:19:17 2008 +++ (empty file) @@ -1,536 +0,0 @@ -# Originally contributed by Sjoerd Mullender. -# Significantly modified by Jeffrey Yasskin . - -"""Rational, infinite-precision, real numbers.""" - -import math -import numbers -import operator -import re - -__all__ = ["Rational"] - -RationalAbc = numbers.Rational - - -def gcd(a, b): - """Calculate the Greatest Common Divisor of a and b. - - Unless b==0, the result will have the same sign as b (so that when - b is divided by it, the result comes out positive). - """ - while b: - a, b = b, a%b - return a - - -_RATIONAL_FORMAT = re.compile(r""" - \A\s* # optional whitespace at the start, then - (?P[-+]?) # an optional sign, then - (?=\d|\.\d) # lookahead for digit or .digit - (?P\d*) # numerator (possibly empty) - (?: # followed by an optional - /(?P\d+) # / and denominator - | # or - \.(?P\d*) # decimal point and fractional part - )? - \s*\Z # and optional whitespace to finish -""", re.VERBOSE) - - -class Rational(RationalAbc): - """This class implements rational numbers. - - Rational(8, 6) will produce a rational number equivalent to - 4/3. Both arguments must be Integral. The numerator defaults to 0 - and the denominator defaults to 1 so that Rational(3) == 3 and - Rational() == 0. - - Rationals can also be constructed from strings of the form - '[-+]?[0-9]+((/|.)[0-9]+)?', optionally surrounded by spaces. - - """ - - __slots__ = ('_numerator', '_denominator') - - # We're immutable, so use __new__ not __init__ - def __new__(cls, numerator=0, denominator=1): - """Constructs a Rational. - - Takes a string like '3/2' or '1.5', another Rational, or a - numerator/denominator pair. - - """ - self = super(Rational, cls).__new__(cls) - - if denominator == 1: - if isinstance(numerator, str): - # Handle construction from strings. - input = numerator - m = _RATIONAL_FORMAT.match(input) - if m is None: - raise ValueError('Invalid literal for Rational: ' + input) - numerator = m.group('num') - decimal = m.group('decimal') - if decimal: - # The literal is a decimal number. - numerator = int(numerator + decimal) - denominator = 10**len(decimal) - else: - # The literal is an integer or fraction. - numerator = int(numerator) - # Default denominator to 1. - denominator = int(m.group('denom') or 1) - - if m.group('sign') == '-': - numerator = -numerator - - elif (not isinstance(numerator, numbers.Integral) and - isinstance(numerator, RationalAbc)): - # Handle copies from other rationals. - other_rational = numerator - numerator = other_rational.numerator - denominator = other_rational.denominator - - if (not isinstance(numerator, numbers.Integral) or - not isinstance(denominator, numbers.Integral)): - raise TypeError("Rational(%(numerator)s, %(denominator)s):" - " Both arguments must be integral." % locals()) - - if denominator == 0: - raise ZeroDivisionError('Rational(%s, 0)' % numerator) - - g = gcd(numerator, denominator) - self._numerator = int(numerator // g) - self._denominator = int(denominator // g) - return self - - @classmethod - def from_float(cls, f): - """Converts a finite float to a rational number, exactly. - - Beware that Rational.from_float(0.3) != Rational(3, 10). - - """ - if not isinstance(f, float): - raise TypeError("%s.from_float() only takes floats, not %r (%s)" % - (cls.__name__, f, type(f).__name__)) - if math.isnan(f) or math.isinf(f): - raise TypeError("Cannot convert %r to %s." % (f, cls.__name__)) - return cls(*f.as_integer_ratio()) - - @classmethod - def from_decimal(cls, dec): - """Converts a finite Decimal instance to a rational number, exactly.""" - from decimal import Decimal - if not isinstance(dec, Decimal): - raise TypeError( - "%s.from_decimal() only takes Decimals, not %r (%s)" % - (cls.__name__, dec, type(dec).__name__)) - if not dec.is_finite(): - # Catches infinities and nans. - raise TypeError("Cannot convert %s to %s." % (dec, cls.__name__)) - sign, digits, exp = dec.as_tuple() - digits = int(''.join(map(str, digits))) - if sign: - digits = -digits - if exp >= 0: - return cls(digits * 10 ** exp) - else: - return cls(digits, 10 ** -exp) - - @classmethod - def from_continued_fraction(cls, seq): - 'Build a Rational from a continued fraction expessed as a sequence' - n, d = 1, 0 - for e in reversed(seq): - n, d = d, n - n += e * d - return cls(n, d) if seq else cls(0) - - def as_continued_fraction(self): - 'Return continued fraction expressed as a list' - n = self.numerator - d = self.denominator - cf = [] - while d: - e = int(n // d) - cf.append(e) - n -= e * d - n, d = d, n - return cf - - def approximate(self, max_denominator): - 'Best rational approximation with a denominator <= max_denominator' - # XXX First cut at algorithm - # Still needs rounding rules as specified at - # http://en.wikipedia.org/wiki/Continued_fraction - if self.denominator <= max_denominator: - return self - cf = self.as_continued_fraction() - result = Rational(0) - for i in range(1, len(cf)): - new = self.from_continued_fraction(cf[:i]) - if new.denominator > max_denominator: - break - result = new - return result - - @property - def numerator(a): - return a._numerator - - @property - def denominator(a): - return a._denominator - - def __repr__(self): - """repr(self)""" - return ('Rational(%r,%r)' % (self.numerator, self.denominator)) - - def __str__(self): - """str(self)""" - if self.denominator == 1: - return str(self.numerator) - else: - return '%s/%s' % (self.numerator, self.denominator) - - def _operator_fallbacks(monomorphic_operator, fallback_operator): - """Generates forward and reverse operators given a purely-rational - operator and a function from the operator module. - - Use this like: - __op__, __rop__ = _operator_fallbacks(just_rational_op, operator.op) - - In general, we want to implement the arithmetic operations so - that mixed-mode operations either call an implementation whose - author knew about the types of both arguments, or convert both - to the nearest built in type and do the operation there. In - Rational, that means that we define __add__ and __radd__ as: - - def __add__(self, other): - # Both types have numerators/denominator attributes, - # so do the operation directly - if isinstance(other, (int, Rational)): - return Rational(self.numerator * other.denominator + - other.numerator * self.denominator, - self.denominator * other.denominator) - # float and complex don't have those operations, but we - # know about those types, so special case them. - elif isinstance(other, float): - return float(self) + other - elif isinstance(other, complex): - return complex(self) + other - # Let the other type take over. - return NotImplemented - - def __radd__(self, other): - # radd handles more types than add because there's - # nothing left to fall back to. - if isinstance(other, RationalAbc): - return Rational(self.numerator * other.denominator + - other.numerator * self.denominator, - self.denominator * other.denominator) - elif isinstance(other, Real): - return float(other) + float(self) - elif isinstance(other, Complex): - return complex(other) + complex(self) - return NotImplemented - - - There are 5 different cases for a mixed-type addition on - Rational. I'll refer to all of the above code that doesn't - refer to Rational, float, or complex as "boilerplate". 'r' - will be an instance of Rational, which is a subtype of - RationalAbc (r : Rational <: RationalAbc), and b : B <: - Complex. The first three involve 'r + b': - - 1. If B <: Rational, int, float, or complex, we handle - that specially, and all is well. - 2. If Rational falls back to the boilerplate code, and it - were to return a value from __add__, we'd miss the - possibility that B defines a more intelligent __radd__, - so the boilerplate should return NotImplemented from - __add__. In particular, we don't handle RationalAbc - here, even though we could get an exact answer, in case - the other type wants to do something special. - 3. If B <: Rational, Python tries B.__radd__ before - Rational.__add__. This is ok, because it was - implemented with knowledge of Rational, so it can - handle those instances before delegating to Real or - Complex. - - The next two situations describe 'b + r'. We assume that b - didn't know about Rational in its implementation, and that it - uses similar boilerplate code: - - 4. If B <: RationalAbc, then __radd_ converts both to the - builtin rational type (hey look, that's us) and - proceeds. - 5. Otherwise, __radd__ tries to find the nearest common - base ABC, and fall back to its builtin type. Since this - class doesn't subclass a concrete type, there's no - implementation to fall back to, so we need to try as - hard as possible to return an actual value, or the user - will get a TypeError. - - """ - def forward(a, b): - if isinstance(b, (int, Rational)): - return monomorphic_operator(a, b) - elif isinstance(b, float): - return fallback_operator(float(a), b) - elif isinstance(b, complex): - return fallback_operator(complex(a), b) - else: - return NotImplemented - forward.__name__ = '__' + fallback_operator.__name__ + '__' - forward.__doc__ = monomorphic_operator.__doc__ - - def reverse(b, a): - if isinstance(a, RationalAbc): - # Includes ints. - return monomorphic_operator(a, b) - elif isinstance(a, numbers.Real): - return fallback_operator(float(a), float(b)) - elif isinstance(a, numbers.Complex): - return fallback_operator(complex(a), complex(b)) - else: - return NotImplemented - reverse.__name__ = '__r' + fallback_operator.__name__ + '__' - reverse.__doc__ = monomorphic_operator.__doc__ - - return forward, reverse - - def _add(a, b): - """a + b""" - return Rational(a.numerator * b.denominator + - b.numerator * a.denominator, - a.denominator * b.denominator) - - __add__, __radd__ = _operator_fallbacks(_add, operator.add) - - def _sub(a, b): - """a - b""" - return Rational(a.numerator * b.denominator - - b.numerator * a.denominator, - a.denominator * b.denominator) - - __sub__, __rsub__ = _operator_fallbacks(_sub, operator.sub) - - def _mul(a, b): - """a * b""" - return Rational(a.numerator * b.numerator, a.denominator * b.denominator) - - __mul__, __rmul__ = _operator_fallbacks(_mul, operator.mul) - - def _div(a, b): - """a / b""" - return Rational(a.numerator * b.denominator, - a.denominator * b.numerator) - - __truediv__, __rtruediv__ = _operator_fallbacks(_div, operator.truediv) - - def __floordiv__(a, b): - """a // b""" - return math.floor(a / b) - - def __rfloordiv__(b, a): - """a // b""" - return math.floor(a / b) - - def __mod__(a, b): - """a % b""" - div = a // b - return a - b * div - - def __rmod__(b, a): - """a % b""" - div = a // b - return a - b * div - - def __pow__(a, b): - """a ** b - - If b is not an integer, the result will be a float or complex - since roots are generally irrational. If b is an integer, the - result will be rational. - - """ - if isinstance(b, RationalAbc): - if b.denominator == 1: - power = b.numerator - if power >= 0: - return Rational(a.numerator ** power, - a.denominator ** power) - else: - return Rational(a.denominator ** -power, - a.numerator ** -power) - else: - # A fractional power will generally produce an - # irrational number. - return float(a) ** float(b) - else: - return float(a) ** b - - def __rpow__(b, a): - """a ** b""" - if b.denominator == 1 and b.numerator >= 0: - # If a is an int, keep it that way if possible. - return a ** b.numerator - - if isinstance(a, RationalAbc): - return Rational(a.numerator, a.denominator) ** b - - if b.denominator == 1: - return a ** b.numerator - - return a ** float(b) - - def __pos__(a): - """+a: Coerces a subclass instance to Rational""" - return Rational(a.numerator, a.denominator) - - def __neg__(a): - """-a""" - return Rational(-a.numerator, a.denominator) - - def __abs__(a): - """abs(a)""" - return Rational(abs(a.numerator), a.denominator) - - def __trunc__(a): - """trunc(a)""" - if a.numerator < 0: - return -(-a.numerator // a.denominator) - else: - return a.numerator // a.denominator - - def __floor__(a): - """Will be math.floor(a) in 3.0.""" - return a.numerator // a.denominator - - def __ceil__(a): - """Will be math.ceil(a) in 3.0.""" - # The negations cleverly convince floordiv to return the ceiling. - return -(-a.numerator // a.denominator) - - def __round__(self, ndigits=None): - """Will be round(self, ndigits) in 3.0. - - Rounds half toward even. - """ - if ndigits is None: - floor, remainder = divmod(self.numerator, self.denominator) - if remainder * 2 < self.denominator: - return floor - elif remainder * 2 > self.denominator: - return floor + 1 - # Deal with the half case: - elif floor % 2 == 0: - return floor - else: - return floor + 1 - shift = 10**abs(ndigits) - # See _operator_fallbacks.forward to check that the results of - # these operations will always be Rational and therefore have - # round(). - if ndigits > 0: - return Rational(round(self * shift), shift) - else: - return Rational(round(self / shift) * shift) - - def __hash__(self): - """hash(self) - - Tricky because values that are exactly representable as a - float must have the same hash as that float. - - """ - # XXX since this method is expensive, consider caching the result - if self.denominator == 1: - # Get integers right. - return hash(self.numerator) - # Expensive check, but definitely correct. - if self == float(self): - return hash(float(self)) - else: - # Use tuple's hash to avoid a high collision rate on - # simple fractions. - return hash((self.numerator, self.denominator)) - - def __eq__(a, b): - """a == b""" - if isinstance(b, RationalAbc): - return (a.numerator == b.numerator and - a.denominator == b.denominator) - if isinstance(b, numbers.Complex) and b.imag == 0: - b = b.real - if isinstance(b, float): - return a == a.from_float(b) - else: - # XXX: If b.__eq__ is implemented like this method, it may - # give the wrong answer after float(a) changes a's - # value. Better ways of doing this are welcome. - return float(a) == b - - def _subtractAndCompareToZero(a, b, op): - """Helper function for comparison operators. - - Subtracts b from a, exactly if possible, and compares the - result with 0 using op, in such a way that the comparison - won't recurse. If the difference raises a TypeError, returns - NotImplemented instead. - - """ - if isinstance(b, numbers.Complex) and b.imag == 0: - b = b.real - if isinstance(b, float): - b = a.from_float(b) - try: - # XXX: If b <: Real but not <: RationalAbc, this is likely - # to fall back to a float. If the actual values differ by - # less than MIN_FLOAT, this could falsely call them equal, - # which would make <= inconsistent with ==. Better ways of - # doing this are welcome. - diff = a - b - except TypeError: - return NotImplemented - if isinstance(diff, RationalAbc): - return op(diff.numerator, 0) - return op(diff, 0) - - def __lt__(a, b): - """a < b""" - return a._subtractAndCompareToZero(b, operator.lt) - - def __gt__(a, b): - """a > b""" - return a._subtractAndCompareToZero(b, operator.gt) - - def __le__(a, b): - """a <= b""" - return a._subtractAndCompareToZero(b, operator.le) - - def __ge__(a, b): - """a >= b""" - return a._subtractAndCompareToZero(b, operator.ge) - - def __bool__(a): - """a != 0""" - return a.numerator != 0 - - # support for pickling, copy, and deepcopy - - def __reduce__(self): - return (self.__class__, (str(self),)) - - def __copy__(self): - if type(self) == Rational: - return self # I'm immutable; therefore I am my own clone - return self.__class__(self.numerator, self.denominator) - - def __deepcopy__(self, memo): - if type(self) == Rational: - return self # My components are also immutable - return self.__class__(self.numerator, self.denominator) Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Mon Feb 11 07:19:17 2008 @@ -5,7 +5,7 @@ run_with_locale from operator import neg -import sys, warnings, random, collections, io, rational +import sys, warnings, random, collections, io, rational, fractions warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) warnings.filterwarnings("ignore", "integer argument expected", @@ -607,7 +607,7 @@ n, d = f.as_integer_ratio() self.assertEqual(float(n).__truediv__(d), f) - R = rational.Rational + R = fractions.Fraction self.assertEqual(R(0, 1), R(*float(0.0).as_integer_ratio())) self.assertEqual(R(5, 2), Copied: python/branches/py3k/Lib/test/test_fractions.py (from r60724, python/branches/py3k/Lib/test/test_rational.py) ============================================================================== --- python/branches/py3k/Lib/test/test_rational.py (original) +++ python/branches/py3k/Lib/test/test_fractions.py Mon Feb 11 07:19:17 2008 @@ -1,15 +1,15 @@ -"""Tests for Lib/rational.py.""" +"""Tests for Lib/fractions.py.""" from decimal import Decimal from test.test_support import run_unittest, verbose import math import operator -import rational +import fractions import unittest from copy import copy, deepcopy from pickle import dumps, loads -R = rational.Rational -gcd = rational.gcd +R = fractions.Fraction +gcd = fractions.gcd class GcdTest(unittest.TestCase): @@ -31,7 +31,7 @@ return (r.numerator, r.denominator) -class RationalTest(unittest.TestCase): +class FractionTest(unittest.TestCase): def assertTypedEquals(self, expected, actual): """Asserts that both the types and values are the same.""" @@ -60,7 +60,7 @@ self.assertEquals((7, 15), _components(R(7, 15))) self.assertEquals((10**23, 1), _components(R(10**23))) - self.assertRaisesMessage(ZeroDivisionError, "Rational(12, 0)", + self.assertRaisesMessage(ZeroDivisionError, "Fraction(12, 0)", R, 12, 0) self.assertRaises(TypeError, R, 1.5) self.assertRaises(TypeError, R, 1.5 + 3j) @@ -81,41 +81,41 @@ self.assertEquals((3, 5), _components(R(" .6 "))) self.assertRaisesMessage( - ZeroDivisionError, "Rational(3, 0)", + ZeroDivisionError, "Fraction(3, 0)", R, "3/0") self.assertRaisesMessage( - ValueError, "Invalid literal for Rational: 3/", + ValueError, "Invalid literal for Fraction: 3/", R, "3/") self.assertRaisesMessage( - ValueError, "Invalid literal for Rational: 3 /2", + ValueError, "Invalid literal for Fraction: 3 /2", R, "3 /2") self.assertRaisesMessage( # Denominators don't need a sign. - ValueError, "Invalid literal for Rational: 3/+2", + ValueError, "Invalid literal for Fraction: 3/+2", R, "3/+2") self.assertRaisesMessage( # Imitate float's parsing. - ValueError, "Invalid literal for Rational: + 3/2", + ValueError, "Invalid literal for Fraction: + 3/2", R, "+ 3/2") self.assertRaisesMessage( # Avoid treating '.' as a regex special character. - ValueError, "Invalid literal for Rational: 3a2", + ValueError, "Invalid literal for Fraction: 3a2", R, "3a2") self.assertRaisesMessage( # Only parse ordinary decimals, not scientific form. - ValueError, "Invalid literal for Rational: 3.2e4", + ValueError, "Invalid literal for Fraction: 3.2e4", R, "3.2e4") self.assertRaisesMessage( # Don't accept combinations of decimals and rationals. - ValueError, "Invalid literal for Rational: 3/7.2", + ValueError, "Invalid literal for Fraction: 3/7.2", R, "3/7.2") self.assertRaisesMessage( # Don't accept combinations of decimals and rationals. - ValueError, "Invalid literal for Rational: 3.2/7", + ValueError, "Invalid literal for Fraction: 3.2/7", R, "3.2/7") self.assertRaisesMessage( # Allow 3. and .3, but not . - ValueError, "Invalid literal for Rational: .", + ValueError, "Invalid literal for Fraction: .", R, ".") def testImmutable(self): @@ -136,7 +136,7 @@ def testFromFloat(self): self.assertRaisesMessage( - TypeError, "Rational.from_float() only takes floats, not 3 (int)", + TypeError, "Fraction.from_float() only takes floats, not 3 (int)", R.from_float, 3) self.assertEquals((0, 1), _components(R.from_float(-0.0))) @@ -152,19 +152,19 @@ inf = 1e1000 nan = inf - inf self.assertRaisesMessage( - TypeError, "Cannot convert inf to Rational.", + TypeError, "Cannot convert inf to Fraction.", R.from_float, inf) self.assertRaisesMessage( - TypeError, "Cannot convert -inf to Rational.", + TypeError, "Cannot convert -inf to Fraction.", R.from_float, -inf) self.assertRaisesMessage( - TypeError, "Cannot convert nan to Rational.", + TypeError, "Cannot convert nan to Fraction.", R.from_float, nan) def testFromDecimal(self): self.assertRaisesMessage( TypeError, - "Rational.from_decimal() only takes Decimals, not 3 (int)", + "Fraction.from_decimal() only takes Decimals, not 3 (int)", R.from_decimal, 3) self.assertEquals(R(0), R.from_decimal(Decimal("-0"))) self.assertEquals(R(5, 10), R.from_decimal(Decimal("0.5"))) @@ -174,16 +174,16 @@ R.from_decimal(Decimal("0." + "9" * 30))) self.assertRaisesMessage( - TypeError, "Cannot convert Infinity to Rational.", + TypeError, "Cannot convert Infinity to Fraction.", R.from_decimal, Decimal("inf")) self.assertRaisesMessage( - TypeError, "Cannot convert -Infinity to Rational.", + TypeError, "Cannot convert -Infinity to Fraction.", R.from_decimal, Decimal("-inf")) self.assertRaisesMessage( - TypeError, "Cannot convert NaN to Rational.", + TypeError, "Cannot convert NaN to Fraction.", R.from_decimal, Decimal("nan")) self.assertRaisesMessage( - TypeError, "Cannot convert sNaN to Rational.", + TypeError, "Cannot convert sNaN to Fraction.", R.from_decimal, Decimal("snan")) def testFromContinuedFraction(self): @@ -316,7 +316,7 @@ # Decimal refuses mixed comparisons. self.assertRaisesMessage( TypeError, - "unsupported operand type(s) for +: 'Rational' and 'Decimal'", + "unsupported operand type(s) for +: 'Fraction' and 'Decimal'", operator.add, R(3,11), Decimal('3.1415926')) self.assertNotEquals(R(5, 2), Decimal('2.5')) @@ -378,7 +378,7 @@ self.assertFalse(R(5, 2) == 2) def testStringification(self): - self.assertEquals("Rational(7,3)", repr(R(7, 3))) + self.assertEquals("Fraction(7,3)", repr(R(7, 3))) self.assertEquals("7/3", str(R(7, 3))) self.assertEquals("7", str(R(7, 1))) @@ -421,7 +421,7 @@ self.assertEqual(id(r), id(deepcopy(r))) def test_main(): - run_unittest(RationalTest, GcdTest) + run_unittest(FractionTest, GcdTest) if __name__ == '__main__': test_main() Deleted: /python/branches/py3k/Lib/test/test_rational.py ============================================================================== --- /python/branches/py3k/Lib/test/test_rational.py Mon Feb 11 07:19:17 2008 +++ (empty file) @@ -1,427 +0,0 @@ -"""Tests for Lib/rational.py.""" - -from decimal import Decimal -from test.test_support import run_unittest, verbose -import math -import operator -import rational -import unittest -from copy import copy, deepcopy -from pickle import dumps, loads -R = rational.Rational -gcd = rational.gcd - - -class GcdTest(unittest.TestCase): - - def testMisc(self): - self.assertEquals(0, gcd(0, 0)) - self.assertEquals(1, gcd(1, 0)) - self.assertEquals(-1, gcd(-1, 0)) - self.assertEquals(1, gcd(0, 1)) - self.assertEquals(-1, gcd(0, -1)) - self.assertEquals(1, gcd(7, 1)) - self.assertEquals(-1, gcd(7, -1)) - self.assertEquals(1, gcd(-23, 15)) - self.assertEquals(12, gcd(120, 84)) - self.assertEquals(-12, gcd(84, -120)) - - -def _components(r): - return (r.numerator, r.denominator) - - -class RationalTest(unittest.TestCase): - - def assertTypedEquals(self, expected, actual): - """Asserts that both the types and values are the same.""" - self.assertEquals(type(expected), type(actual)) - self.assertEquals(expected, actual) - - def assertRaisesMessage(self, exc_type, message, - callable, *args, **kwargs): - """Asserts that callable(*args, **kwargs) raises exc_type(message).""" - try: - callable(*args, **kwargs) - except exc_type as e: - self.assertEquals(message, str(e)) - else: - self.fail("%s not raised" % exc_type.__name__) - - def testInit(self): - self.assertEquals((0, 1), _components(R())) - self.assertEquals((7, 1), _components(R(7))) - self.assertEquals((7, 3), _components(R(R(7, 3)))) - - self.assertEquals((-1, 1), _components(R(-1, 1))) - self.assertEquals((-1, 1), _components(R(1, -1))) - self.assertEquals((1, 1), _components(R(-2, -2))) - self.assertEquals((1, 2), _components(R(5, 10))) - self.assertEquals((7, 15), _components(R(7, 15))) - self.assertEquals((10**23, 1), _components(R(10**23))) - - self.assertRaisesMessage(ZeroDivisionError, "Rational(12, 0)", - R, 12, 0) - self.assertRaises(TypeError, R, 1.5) - self.assertRaises(TypeError, R, 1.5 + 3j) - - self.assertRaises(TypeError, R, R(1, 2), 3) - self.assertRaises(TypeError, R, "3/2", 3) - - def testFromString(self): - self.assertEquals((5, 1), _components(R("5"))) - self.assertEquals((3, 2), _components(R("3/2"))) - self.assertEquals((3, 2), _components(R(" \n +3/2"))) - self.assertEquals((-3, 2), _components(R("-3/2 "))) - self.assertEquals((3, 2), _components(R(" 03/02 \n "))) - self.assertEquals((3, 2), _components(R(" 03/02 \n "))) - self.assertEquals((16, 5), _components(R(" 3.2 "))) - self.assertEquals((-16, 5), _components(R(" -3.2 "))) - self.assertEquals((-3, 1), _components(R(" -3. "))) - self.assertEquals((3, 5), _components(R(" .6 "))) - - self.assertRaisesMessage( - ZeroDivisionError, "Rational(3, 0)", - R, "3/0") - self.assertRaisesMessage( - ValueError, "Invalid literal for Rational: 3/", - R, "3/") - self.assertRaisesMessage( - ValueError, "Invalid literal for Rational: 3 /2", - R, "3 /2") - self.assertRaisesMessage( - # Denominators don't need a sign. - ValueError, "Invalid literal for Rational: 3/+2", - R, "3/+2") - self.assertRaisesMessage( - # Imitate float's parsing. - ValueError, "Invalid literal for Rational: + 3/2", - R, "+ 3/2") - self.assertRaisesMessage( - # Avoid treating '.' as a regex special character. - ValueError, "Invalid literal for Rational: 3a2", - R, "3a2") - self.assertRaisesMessage( - # Only parse ordinary decimals, not scientific form. - ValueError, "Invalid literal for Rational: 3.2e4", - R, "3.2e4") - self.assertRaisesMessage( - # Don't accept combinations of decimals and rationals. - ValueError, "Invalid literal for Rational: 3/7.2", - R, "3/7.2") - self.assertRaisesMessage( - # Don't accept combinations of decimals and rationals. - ValueError, "Invalid literal for Rational: 3.2/7", - R, "3.2/7") - self.assertRaisesMessage( - # Allow 3. and .3, but not . - ValueError, "Invalid literal for Rational: .", - R, ".") - - def testImmutable(self): - r = R(7, 3) - r.__init__(2, 15) - self.assertEquals((7, 3), _components(r)) - - self.assertRaises(AttributeError, setattr, r, 'numerator', 12) - self.assertRaises(AttributeError, setattr, r, 'denominator', 6) - self.assertEquals((7, 3), _components(r)) - - # But if you _really_ need to: - r._numerator = 4 - r._denominator = 2 - self.assertEquals((4, 2), _components(r)) - # Which breaks some important operations: - self.assertNotEquals(R(4, 2), r) - - def testFromFloat(self): - self.assertRaisesMessage( - TypeError, "Rational.from_float() only takes floats, not 3 (int)", - R.from_float, 3) - - self.assertEquals((0, 1), _components(R.from_float(-0.0))) - self.assertEquals((10, 1), _components(R.from_float(10.0))) - self.assertEquals((-5, 2), _components(R.from_float(-2.5))) - self.assertEquals((99999999999999991611392, 1), - _components(R.from_float(1e23))) - self.assertEquals(float(10**23), float(R.from_float(1e23))) - self.assertEquals((3602879701896397, 1125899906842624), - _components(R.from_float(3.2))) - self.assertEquals(3.2, float(R.from_float(3.2))) - - inf = 1e1000 - nan = inf - inf - self.assertRaisesMessage( - TypeError, "Cannot convert inf to Rational.", - R.from_float, inf) - self.assertRaisesMessage( - TypeError, "Cannot convert -inf to Rational.", - R.from_float, -inf) - self.assertRaisesMessage( - TypeError, "Cannot convert nan to Rational.", - R.from_float, nan) - - def testFromDecimal(self): - self.assertRaisesMessage( - TypeError, - "Rational.from_decimal() only takes Decimals, not 3 (int)", - R.from_decimal, 3) - self.assertEquals(R(0), R.from_decimal(Decimal("-0"))) - self.assertEquals(R(5, 10), R.from_decimal(Decimal("0.5"))) - self.assertEquals(R(5, 1000), R.from_decimal(Decimal("5e-3"))) - self.assertEquals(R(5000), R.from_decimal(Decimal("5e3"))) - self.assertEquals(1 - R(1, 10**30), - R.from_decimal(Decimal("0." + "9" * 30))) - - self.assertRaisesMessage( - TypeError, "Cannot convert Infinity to Rational.", - R.from_decimal, Decimal("inf")) - self.assertRaisesMessage( - TypeError, "Cannot convert -Infinity to Rational.", - R.from_decimal, Decimal("-inf")) - self.assertRaisesMessage( - TypeError, "Cannot convert NaN to Rational.", - R.from_decimal, Decimal("nan")) - self.assertRaisesMessage( - TypeError, "Cannot convert sNaN to Rational.", - R.from_decimal, Decimal("snan")) - - def testFromContinuedFraction(self): - self.assertRaises(TypeError, R.from_continued_fraction, None) - phi = R.from_continued_fraction([1]*100) - self.assertEquals(round(phi - (1 + 5 ** 0.5) / 2, 10), 0.0) - - minusphi = R.from_continued_fraction([-1]*100) - self.assertEquals(round(minusphi + (1 + 5 ** 0.5) / 2, 10), 0.0) - - self.assertEquals(R.from_continued_fraction([0]), R(0)) - self.assertEquals(R.from_continued_fraction([]), R(0)) - - def testAsContinuedFraction(self): - self.assertEqual(R.from_float(math.pi).as_continued_fraction()[:15], - [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3, 3]) - self.assertEqual(R.from_float(-math.pi).as_continued_fraction()[:16], - [-4, 1, 6, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3, 3]) - self.assertEqual(R(0).as_continued_fraction(), [0]) - - def testApproximateFrom(self): - self.assertEqual(R.from_float(math.pi).approximate(10000), R(355, 113)) - self.assertEqual(R.from_float(-math.pi).approximate(10000), R(-355, 113)) - self.assertEqual(R.from_float(0.0).approximate(10000), R(0)) - - def testConversions(self): - self.assertTypedEquals(-1, math.trunc(R(-11, 10))) - self.assertTypedEquals(-2, math.floor(R(-11, 10))) - self.assertTypedEquals(-1, math.ceil(R(-11, 10))) - self.assertTypedEquals(-1, math.ceil(R(-10, 10))) - self.assertTypedEquals(-1, int(R(-11, 10))) - - self.assertTypedEquals(0, round(R(-1, 10))) - self.assertTypedEquals(0, round(R(-5, 10))) - self.assertTypedEquals(-2, round(R(-15, 10))) - self.assertTypedEquals(-1, round(R(-7, 10))) - - self.assertEquals(False, bool(R(0, 1))) - self.assertEquals(True, bool(R(3, 2))) - self.assertTypedEquals(0.1, float(R(1, 10))) - - # Check that __float__ isn't implemented by converting the - # numerator and denominator to float before dividing. - self.assertRaises(OverflowError, float, int('2'*400+'7')) - self.assertAlmostEquals(2.0/3, - float(R(int('2'*400+'7'), int('3'*400+'1')))) - - self.assertTypedEquals(0.1+0j, complex(R(1,10))) - - def testRound(self): - self.assertTypedEquals(R(-200), round(R(-150), -2)) - self.assertTypedEquals(R(-200), round(R(-250), -2)) - self.assertTypedEquals(R(30), round(R(26), -1)) - self.assertTypedEquals(R(-2, 10), round(R(-15, 100), 1)) - self.assertTypedEquals(R(-2, 10), round(R(-25, 100), 1)) - - - def testArithmetic(self): - self.assertEquals(R(1, 2), R(1, 10) + R(2, 5)) - self.assertEquals(R(-3, 10), R(1, 10) - R(2, 5)) - self.assertEquals(R(1, 25), R(1, 10) * R(2, 5)) - self.assertEquals(R(1, 4), R(1, 10) / R(2, 5)) - self.assertTypedEquals(2, R(9, 10) // R(2, 5)) - self.assertTypedEquals(10**23, R(10**23, 1) // R(1)) - self.assertEquals(R(2, 3), R(-7, 3) % R(3, 2)) - self.assertEquals(R(8, 27), R(2, 3) ** R(3)) - self.assertEquals(R(27, 8), R(2, 3) ** R(-3)) - self.assertTypedEquals(2.0, R(4) ** R(1, 2)) - z = pow(R(-1), R(1, 2)) - self.assertAlmostEquals(z.real, 0) - self.assertEquals(z.imag, 1) - - def testMixedArithmetic(self): - self.assertTypedEquals(R(11, 10), R(1, 10) + 1) - self.assertTypedEquals(1.1, R(1, 10) + 1.0) - self.assertTypedEquals(1.1 + 0j, R(1, 10) + (1.0 + 0j)) - self.assertTypedEquals(R(11, 10), 1 + R(1, 10)) - self.assertTypedEquals(1.1, 1.0 + R(1, 10)) - self.assertTypedEquals(1.1 + 0j, (1.0 + 0j) + R(1, 10)) - - self.assertTypedEquals(R(-9, 10), R(1, 10) - 1) - self.assertTypedEquals(-0.9, R(1, 10) - 1.0) - self.assertTypedEquals(-0.9 + 0j, R(1, 10) - (1.0 + 0j)) - self.assertTypedEquals(R(9, 10), 1 - R(1, 10)) - self.assertTypedEquals(0.9, 1.0 - R(1, 10)) - self.assertTypedEquals(0.9 + 0j, (1.0 + 0j) - R(1, 10)) - - self.assertTypedEquals(R(1, 10), R(1, 10) * 1) - self.assertTypedEquals(0.1, R(1, 10) * 1.0) - self.assertTypedEquals(0.1 + 0j, R(1, 10) * (1.0 + 0j)) - self.assertTypedEquals(R(1, 10), 1 * R(1, 10)) - self.assertTypedEquals(0.1, 1.0 * R(1, 10)) - self.assertTypedEquals(0.1 + 0j, (1.0 + 0j) * R(1, 10)) - - self.assertTypedEquals(R(1, 10), R(1, 10) / 1) - self.assertTypedEquals(0.1, R(1, 10) / 1.0) - self.assertTypedEquals(0.1 + 0j, R(1, 10) / (1.0 + 0j)) - self.assertTypedEquals(R(10, 1), 1 / R(1, 10)) - self.assertTypedEquals(10.0, 1.0 / R(1, 10)) - self.assertTypedEquals(10.0 + 0j, (1.0 + 0j) / R(1, 10)) - - self.assertTypedEquals(0, R(1, 10) // 1) - self.assertTypedEquals(0, R(1, 10) // 1.0) - self.assertTypedEquals(10, 1 // R(1, 10)) - self.assertTypedEquals(10**23, 10**22 // R(1, 10)) - self.assertTypedEquals(10, 1.0 // R(1, 10)) - - self.assertTypedEquals(R(1, 10), R(1, 10) % 1) - self.assertTypedEquals(0.1, R(1, 10) % 1.0) - self.assertTypedEquals(R(0, 1), 1 % R(1, 10)) - self.assertTypedEquals(0.0, 1.0 % R(1, 10)) - - # No need for divmod since we don't override it. - - # ** has more interesting conversion rules. - self.assertTypedEquals(R(100, 1), R(1, 10) ** -2) - self.assertTypedEquals(R(100, 1), R(10, 1) ** 2) - self.assertTypedEquals(0.1, R(1, 10) ** 1.0) - self.assertTypedEquals(0.1 + 0j, R(1, 10) ** (1.0 + 0j)) - self.assertTypedEquals(4 , 2 ** R(2, 1)) - z = pow(-1, R(1, 2)) - self.assertAlmostEquals(0, z.real) - self.assertEquals(1, z.imag) - self.assertTypedEquals(R(1, 4) , 2 ** R(-2, 1)) - self.assertTypedEquals(2.0 , 4 ** R(1, 2)) - self.assertTypedEquals(0.25, 2.0 ** R(-2, 1)) - self.assertTypedEquals(1.0 + 0j, (1.0 + 0j) ** R(1, 10)) - - def testMixingWithDecimal(self): - # Decimal refuses mixed comparisons. - self.assertRaisesMessage( - TypeError, - "unsupported operand type(s) for +: 'Rational' and 'Decimal'", - operator.add, R(3,11), Decimal('3.1415926')) - self.assertNotEquals(R(5, 2), Decimal('2.5')) - - def testComparisons(self): - self.assertTrue(R(1, 2) < R(2, 3)) - self.assertFalse(R(1, 2) < R(1, 2)) - self.assertTrue(R(1, 2) <= R(2, 3)) - self.assertTrue(R(1, 2) <= R(1, 2)) - self.assertFalse(R(2, 3) <= R(1, 2)) - self.assertTrue(R(1, 2) == R(1, 2)) - self.assertFalse(R(1, 2) == R(1, 3)) - self.assertFalse(R(1, 2) != R(1, 2)) - self.assertTrue(R(1, 2) != R(1, 3)) - - def testMixedLess(self): - self.assertTrue(2 < R(5, 2)) - self.assertFalse(2 < R(4, 2)) - self.assertTrue(R(5, 2) < 3) - self.assertFalse(R(4, 2) < 2) - - self.assertTrue(R(1, 2) < 0.6) - self.assertFalse(R(1, 2) < 0.4) - self.assertTrue(0.4 < R(1, 2)) - self.assertFalse(0.5 < R(1, 2)) - - def testMixedLessEqual(self): - self.assertTrue(0.5 <= R(1, 2)) - self.assertFalse(0.6 <= R(1, 2)) - self.assertTrue(R(1, 2) <= 0.5) - self.assertFalse(R(1, 2) <= 0.4) - self.assertTrue(2 <= R(4, 2)) - self.assertFalse(2 <= R(3, 2)) - self.assertTrue(R(4, 2) <= 2) - self.assertFalse(R(5, 2) <= 2) - - def testBigFloatComparisons(self): - # Because 10**23 can't be represented exactly as a float: - self.assertFalse(R(10**23) == float(10**23)) - # The first test demonstrates why these are important. - self.assertFalse(1e23 < float(R(math.trunc(1e23) + 1))) - self.assertTrue(1e23 < R(math.trunc(1e23) + 1)) - self.assertFalse(1e23 <= R(math.trunc(1e23) - 1)) - self.assertTrue(1e23 > R(math.trunc(1e23) - 1)) - self.assertFalse(1e23 >= R(math.trunc(1e23) + 1)) - - def testBigComplexComparisons(self): - self.assertFalse(R(10**23) == complex(10**23)) - self.assertTrue(R(10**23) > complex(10**23)) - self.assertFalse(R(10**23) <= complex(10**23)) - - def testMixedEqual(self): - self.assertTrue(0.5 == R(1, 2)) - self.assertFalse(0.6 == R(1, 2)) - self.assertTrue(R(1, 2) == 0.5) - self.assertFalse(R(1, 2) == 0.4) - self.assertTrue(2 == R(4, 2)) - self.assertFalse(2 == R(3, 2)) - self.assertTrue(R(4, 2) == 2) - self.assertFalse(R(5, 2) == 2) - - def testStringification(self): - self.assertEquals("Rational(7,3)", repr(R(7, 3))) - self.assertEquals("7/3", str(R(7, 3))) - self.assertEquals("7", str(R(7, 1))) - - def testHash(self): - self.assertEquals(hash(2.5), hash(R(5, 2))) - self.assertEquals(hash(10**50), hash(R(10**50))) - self.assertNotEquals(hash(float(10**23)), hash(R(10**23))) - - def testApproximatePi(self): - # Algorithm borrowed from - # http://docs.python.org/lib/decimal-recipes.html - three = R(3) - lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24 - while abs(s - lasts) > R(1, 10**9): - lasts = s - n, na = n+na, na+8 - d, da = d+da, da+32 - t = (t * n) / d - s += t - self.assertAlmostEquals(math.pi, s) - - def testApproximateCos1(self): - # Algorithm borrowed from - # http://docs.python.org/lib/decimal-recipes.html - x = R(1) - i, lasts, s, fact, num, sign = 0, 0, R(1), 1, 1, 1 - while abs(s - lasts) > R(1, 10**9): - lasts = s - i += 2 - fact *= i * (i-1) - num *= x * x - sign *= -1 - s += num / fact * sign - self.assertAlmostEquals(math.cos(1), s) - - def test_copy_deepcopy_pickle(self): - r = R(13, 7) - self.assertEqual(r, loads(dumps(r))) - self.assertEqual(id(r), id(copy(r))) - self.assertEqual(id(r), id(deepcopy(r))) - -def test_main(): - run_unittest(RationalTest, GcdTest) - -if __name__ == '__main__': - test_main() Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Mon Feb 11 07:19:17 2008 @@ -1182,6 +1182,8 @@ static PyMethodDef defdict_methods[] = { {"__missing__", (PyCFunction)defdict_missing, METH_O, defdict_missing_doc}, + {"copy", (PyCFunction)defdict_copy, METH_NOARGS, + defdict_copy_doc}, {"__copy__", (PyCFunction)defdict_copy, METH_NOARGS, defdict_copy_doc}, {"__reduce__", (PyCFunction)defdict_reduce, METH_NOARGS, From python-3000-checkins at python.org Mon Feb 11 18:55:02 2008 From: python-3000-checkins at python.org (eric.smith) Date: Mon, 11 Feb 2008 18:55:02 +0100 (CET) Subject: [Python-3000-checkins] r60729 - python/branches/py3k/Lib/test/test_long.py Message-ID: <20080211175502.378561E4022@bag.python.org> Author: eric.smith Date: Mon Feb 11 18:55:01 2008 New Revision: 60729 Modified: python/branches/py3k/Lib/test/test_long.py Log: Renamed test_format to test__format__, since it really tests the __format__ method. It was hiding another method of the same name. Modified: python/branches/py3k/Lib/test/test_long.py ============================================================================== --- python/branches/py3k/Lib/test/test_long.py (original) +++ python/branches/py3k/Lib/test/test_long.py Mon Feb 11 18:55:01 2008 @@ -482,7 +482,7 @@ eq(x > y, Rcmp > 0, Frm("%r > %r %d", x, y, Rcmp)) eq(x >= y, Rcmp >= 0, Frm("%r >= %r %d", x, y, Rcmp)) - def test_format(self): + def test__format__(self): self.assertEqual(format(123456789, 'd'), '123456789') self.assertEqual(format(123456789, 'd'), '123456789') From python-3000-checkins at python.org Mon Feb 11 20:00:13 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Mon, 11 Feb 2008 20:00:13 +0100 (CET) Subject: [Python-3000-checkins] r60732 - python/branches/py3k/Lib/UserList.py python/branches/py3k/Lib/UserString.py python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/weakref.py Message-ID: <20080211190013.92E0A1E400E@bag.python.org> Author: raymond.hettinger Date: Mon Feb 11 20:00:13 2008 New Revision: 60732 Modified: python/branches/py3k/Lib/UserList.py python/branches/py3k/Lib/UserString.py python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/weakref.py Log: No need to register classes that already inherit from ABCs. Modified: python/branches/py3k/Lib/UserList.py ============================================================================== --- python/branches/py3k/Lib/UserList.py (original) +++ python/branches/py3k/Lib/UserList.py Mon Feb 11 20:00:13 2008 @@ -71,5 +71,3 @@ self.data.extend(other.data) else: self.data.extend(other) - -collections.MutableSequence.register(UserList) Modified: python/branches/py3k/Lib/UserString.py ============================================================================== --- python/branches/py3k/Lib/UserString.py (original) +++ python/branches/py3k/Lib/UserString.py Mon Feb 11 20:00:13 2008 @@ -235,8 +235,6 @@ def insert(self, index, value): self[index:index] = value -collections.MutableSequence.register(MutableString) - if __name__ == "__main__": # execute the regression test to stdout, if called as a script: import os Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Mon Feb 11 20:00:13 2008 @@ -160,8 +160,6 @@ d[key] = value return d -MutableMapping.register(UserDict) - ################################################################################ Modified: python/branches/py3k/Lib/weakref.py ============================================================================== --- python/branches/py3k/Lib/weakref.py (original) +++ python/branches/py3k/Lib/weakref.py Mon Feb 11 20:00:13 2008 @@ -194,7 +194,6 @@ L.append(o) return L -collections.MutableMapping.register(WeakValueDictionary) class KeyedRef(ref): """Specialized reference that includes a key corresponding to the value. @@ -350,5 +349,3 @@ d[ref(key, self._remove)] = value if len(kwargs): self.update(kwargs) - -collections.MutableMapping.register(WeakKeyDictionary) From python-3000-checkins at python.org Mon Feb 11 23:57:17 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 11 Feb 2008 23:57:17 +0100 (CET) Subject: [Python-3000-checkins] r60736 - in python/branches/py3k: Lib/pickletools.py Lib/test/test_pickletools.py Lib/test/test_tarfile.py Lib/test/testtar.tar Message-ID: <20080211225717.A8D3C1E4025@bag.python.org> Author: christian.heimes Date: Mon Feb 11 23:57:17 2008 New Revision: 60736 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/pickletools.py python/branches/py3k/Lib/test/test_pickletools.py python/branches/py3k/Lib/test/test_tarfile.py python/branches/py3k/Lib/test/testtar.tar Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60734 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60731 | raymond.hettinger | 2008-02-11 19:51:08 +0100 (Mon, 11 Feb 2008) | 1 line No need to register classes that already inherit from ABCs. ........ r60733 | lars.gustaebel | 2008-02-11 20:17:10 +0100 (Mon, 11 Feb 2008) | 2 lines Make sure that xstar headers are read correctly. ........ r60734 | raymond.hettinger | 2008-02-11 21:05:53 +0100 (Mon, 11 Feb 2008) | 1 line Add tests for pickletools.optimize(). ........ Modified: python/branches/py3k/Lib/pickletools.py ============================================================================== --- python/branches/py3k/Lib/pickletools.py (original) +++ python/branches/py3k/Lib/pickletools.py Mon Feb 11 23:57:17 2008 @@ -1858,7 +1858,7 @@ s.append(p[i:j]) i = stop s.append(p[i:]) - return ''.join(s) + return b''.join(s) ############################################################################## # A symbolic pickle disassembler. Modified: python/branches/py3k/Lib/test/test_pickletools.py ============================================================================== --- python/branches/py3k/Lib/test/test_pickletools.py (original) +++ python/branches/py3k/Lib/test/test_pickletools.py Mon Feb 11 23:57:17 2008 @@ -1,3 +1,24 @@ +import pickle import pickletools from test import test_support -test_support.run_doctest(pickletools) +from test.pickletester import AbstractPickleTests +from test.pickletester import AbstractPickleModuleTests + +class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests): + + def dumps(self, arg, proto=0, fast=0): + return pickletools.optimize(pickle.dumps(arg, proto)) + + def loads(self, buf): + return pickle.loads(buf) + + module = pickle + error = KeyError + +def test_main(): + test_support.run_unittest(OptimizedPickleTests) + test_support.run_doctest(pickletools) + + +if __name__ == "__main__": + test_main() Modified: python/branches/py3k/Lib/test/test_tarfile.py ============================================================================== --- python/branches/py3k/Lib/test/test_tarfile.py (original) +++ python/branches/py3k/Lib/test/test_tarfile.py Mon Feb 11 23:57:17 2008 @@ -207,6 +207,15 @@ self.assert_(tarinfo.type == tarfile.DIRTYPE, "v7 dirtype failed") + def test_xstar_type(self): + # The xstar format stores extra atime and ctime fields inside the + # space reserved for the prefix field. The prefix field must be + # ignored in this case, otherwise it will mess up the name. + try: + self.tar.getmember("misc/regtype-xstar") + except KeyError: + self.fail("failed to find misc/regtype-xstar (mangled prefix?)") + def test_check_members(self): for tarinfo in self.tar: self.assert_(int(tarinfo.mtime) == 0o7606136617, Modified: python/branches/py3k/Lib/test/testtar.tar ============================================================================== Binary files. No diff available. From python-3000-checkins at python.org Tue Feb 12 18:44:23 2008 From: python-3000-checkins at python.org (thomas.heller) Date: Tue, 12 Feb 2008 18:44:23 +0100 (CET) Subject: [Python-3000-checkins] r60746 - python/branches/py3k/Modules/_ctypes/_ctypes.c Message-ID: <20080212174423.804FE1E4011@bag.python.org> Author: thomas.heller Date: Tue Feb 12 18:44:23 2008 New Revision: 60746 Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c Log: Revert the last svnmerge (r60681) from trunk to _ctypes.c, it should not have been merged as was noticed in the commit message. Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Tue Feb 12 18:44:23 2008 @@ -4814,48 +4814,11 @@ static int create_comerror(void) { - PyObject *dict = PyDict_New(); - PyMethodDef *methods = comerror_methods; - PyObject *s; - int status; - - if (dict == NULL) + PyComError_Type.tp_base = (PyTypeObject*)PyExc_Exception; + if (PyType_Ready(&PyComError_Type) < 0) return -1; - - while (methods->ml_name) { - /* get a wrapper for the built-in function */ - PyObject *func = PyCFunction_New(methods, NULL); - PyObject *meth; - if (func == NULL) - goto error; - meth = PyMethod_New(func, NULL, ComError); - Py_DECREF(func); - if (meth == NULL) - goto error; - PyDict_SetItemString(dict, methods->ml_name, meth); - Py_DECREF(meth); - ++methods; - } - - s = PyString_FromString(comerror_doc); - if (s == NULL) - goto error; ComError = (PyObject*)&PyComError_Type; - status = PyDict_SetItemString(dict, "__doc__", s); - Py_DECREF(s); - if (status == -1) - goto error; - - ComError = PyErr_NewException("_ctypes.COMError", - NULL, - dict); - if (ComError == NULL) - goto error; - return 0; - error: - Py_DECREF(dict); - return -1; } #endif From python-3000-checkins at python.org Tue Feb 12 20:30:36 2008 From: python-3000-checkins at python.org (martin.v.loewis) Date: Tue, 12 Feb 2008 20:30:36 +0100 (CET) Subject: [Python-3000-checkins] r60750 - python/branches/py3k/Include/ceval.h Message-ID: <20080212193036.094C01E4011@bag.python.org> Author: martin.v.loewis Date: Tue Feb 12 20:30:35 2008 New Revision: 60750 Modified: python/branches/py3k/Include/ceval.h Log: Bug #1595: Remove extra semicolon. Modified: python/branches/py3k/Include/ceval.h ============================================================================== --- python/branches/py3k/Include/ceval.h (original) +++ python/branches/py3k/Include/ceval.h Tue Feb 12 20:30:35 2008 @@ -51,7 +51,7 @@ _Py_CheckRecursiveCall(where)) #define Py_LeaveRecursiveCall() \ do{ if((--PyThreadState_GET()->recursion_depth) < \ - _Py_CheckRecursionLimit - 50); \ + _Py_CheckRecursionLimit - 50) \ PyThreadState_GET()->overflowed = 0; \ } while(0) PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); From python-3000-checkins at python.org Tue Feb 12 21:03:10 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Tue, 12 Feb 2008 21:03:10 +0100 (CET) Subject: [Python-3000-checkins] r60751 - in python/branches/py3k: Doc/library/collections.rst Doc/library/numeric.rst Doc/library/userdict.rst Lib/UserList.py Lib/collections.py Lib/test/string_tests.py Lib/test/test_bisect.py Lib/test/test_builtin.py Lib/test/test_extcall.py Lib/test/test_file.py Lib/test/test_fileio.py Lib/test/test_richcmp.py Lib/test/test_userlist.py Lib/test/test_weakref.py Message-ID: <20080212200310.22BA31E4012@bag.python.org> Author: raymond.hettinger Date: Tue Feb 12 21:03:09 2008 New Revision: 60751 Removed: python/branches/py3k/Lib/UserList.py Modified: python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/numeric.rst python/branches/py3k/Doc/library/userdict.rst python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/test/string_tests.py python/branches/py3k/Lib/test/test_bisect.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_extcall.py python/branches/py3k/Lib/test/test_file.py python/branches/py3k/Lib/test/test_fileio.py python/branches/py3k/Lib/test/test_richcmp.py python/branches/py3k/Lib/test/test_userlist.py python/branches/py3k/Lib/test/test_weakref.py Log: Move UserList to collections. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Tue Feb 12 21:03:09 2008 @@ -1,9 +1,9 @@ -:mod:`collections` --- High-performance container datatypes -=========================================================== +:mod:`collections` --- Container datatypes +========================================== .. module:: collections - :synopsis: High-performance datatypes + :synopsis: Container datatypes .. moduleauthor:: Raymond Hettinger .. sectionauthor:: Raymond Hettinger @@ -663,3 +663,45 @@ .. attribute:: UserDict.data A real dictionary used to store the contents of the :class:`UserDict` class. + + + +:class:`UserList` objects +------------------------- + +This class acts as a wrapper around list objects. It is a useful base class +for your own list-like classes which can inherit from them and override +existing methods or add new ones. In this way, one can add new behaviors to +lists. + +The need for this class has been partially supplanted by the ability to +subclass directly from :class:`list`; however, this class can be easier +to work with because the underlying list is accessible as an attribute. + +.. class:: UserList([list]) + + Class that simulates a list. The instance's contents are kept in a regular + list, which is accessible via the :attr:`data` attribute of :class:`UserList` + instances. The instance's contents are initially set to a copy of *list*, + defaulting to the empty list ``[]``. *list* can be any iterable, for + example a real Python list or a :class:`UserList` object. + +In addition to supporting the methods and operations of mutable sequences, +:class:`UserList` instances provide the following attribute: + +.. attribute:: UserList.data + + A real :class:`list` object used to store the contents of the + :class:`UserList` class. + +**Subclassing requirements:** Subclasses of :class:`UserList` are expect to +offer a constructor which can be called with either no arguments or one +argument. List operations which return a new sequence attempt to create an +instance of the actual implementation class. To do so, it assumes that the +constructor can be called with a single parameter, which is a sequence object +used as a data source. + +If a derived class does not wish to comply with this requirement, all of the +special methods supported by this class will need to be overridden; please +consult the sources for information about the methods which need to be provided +in that case. Modified: python/branches/py3k/Doc/library/numeric.rst ============================================================================== --- python/branches/py3k/Doc/library/numeric.rst (original) +++ python/branches/py3k/Doc/library/numeric.rst Tue Feb 12 21:03:09 2008 @@ -21,7 +21,7 @@ math.rst cmath.rst decimal.rst - rational.rst + fractions.rst random.rst itertools.rst functools.rst Modified: python/branches/py3k/Doc/library/userdict.rst ============================================================================== --- python/branches/py3k/Doc/library/userdict.rst (original) +++ python/branches/py3k/Doc/library/userdict.rst Tue Feb 12 21:03:09 2008 @@ -1,55 +1,3 @@ -:mod:`UserList` --- Class wrapper for list objects -================================================== - -.. module:: UserList - :synopsis: Class wrapper for list objects. - - -.. note:: - - This module is available for backward compatibility only. If you are writing - code that does not need to work with versions of Python earlier than Python 2.2, - please consider subclassing directly from the built-in :class:`list` type. - -This module defines a class that acts as a wrapper around list objects. It is a -useful base class for your own list-like classes, which can inherit from them -and override existing methods or add new ones. In this way one can add new -behaviors to lists. - -The :mod:`UserList` module defines the :class:`UserList` class: - - -.. class:: UserList([list]) - - Class that simulates a list. The instance's contents are kept in a regular - list, which is accessible via the :attr:`data` attribute of - :class:`UserList` - instances. The instance's contents are initially set to a copy of *list*, - defaulting to the empty list ``[]``. *list* can be any iterable, for - example a real Python list or a :class:`UserList` object. - -In addition to supporting the methods and operations of mutable sequences (see -section :ref:`typesseq`), :class:`UserList` instances provide the following -attribute: - - -.. attribute:: UserList.data - - A real Python list object used to store the contents of the :class:`UserList` - class. - -**Subclassing requirements:** Subclasses of :class:`UserList` are expect to -offer a constructor which can be called with either no arguments or one -argument. List operations which return a new sequence attempt to create an -instance of the actual implementation class. To do so, it assumes that the -constructor can be called with a single parameter, which is a sequence object -used as a data source. - -If a derived class does not wish to comply with this requirement, all of the -special methods supported by this class will need to be overridden; please -consult the sources for information about the methods which need to be provided -in that case. - :mod:`UserString` --- Class wrapper for string objects ====================================================== Deleted: /python/branches/py3k/Lib/UserList.py ============================================================================== --- /python/branches/py3k/Lib/UserList.py Tue Feb 12 21:03:09 2008 +++ (empty file) @@ -1,73 +0,0 @@ -"""A more or less complete user-defined wrapper around list objects.""" - -import collections - -class UserList(collections.MutableSequence): - def __init__(self, initlist=None): - self.data = [] - if initlist is not None: - # XXX should this accept an arbitrary sequence? - if type(initlist) == type(self.data): - self.data[:] = initlist - elif isinstance(initlist, UserList): - self.data[:] = initlist.data[:] - else: - self.data = list(initlist) - def __repr__(self): return repr(self.data) - def __lt__(self, other): return self.data < self.__cast(other) - def __le__(self, other): return self.data <= self.__cast(other) - def __eq__(self, other): return self.data == self.__cast(other) - def __ne__(self, other): return self.data != self.__cast(other) - def __gt__(self, other): return self.data > self.__cast(other) - def __ge__(self, other): return self.data >= self.__cast(other) - def __cast(self, other): - if isinstance(other, UserList): return other.data - else: return other - def __cmp__(self, other): - return cmp(self.data, self.__cast(other)) - def __contains__(self, item): return item in self.data - def __len__(self): return len(self.data) - def __getitem__(self, i): return self.data[i] - def __setitem__(self, i, item): self.data[i] = item - def __delitem__(self, i): del self.data[i] - def __add__(self, other): - if isinstance(other, UserList): - return self.__class__(self.data + other.data) - elif isinstance(other, type(self.data)): - return self.__class__(self.data + other) - else: - return self.__class__(self.data + list(other)) - def __radd__(self, other): - if isinstance(other, UserList): - return self.__class__(other.data + self.data) - elif isinstance(other, type(self.data)): - return self.__class__(other + self.data) - else: - return self.__class__(list(other) + self.data) - def __iadd__(self, other): - if isinstance(other, UserList): - self.data += other.data - elif isinstance(other, type(self.data)): - self.data += other - else: - self.data += list(other) - return self - def __mul__(self, n): - return self.__class__(self.data*n) - __rmul__ = __mul__ - def __imul__(self, n): - self.data *= n - return self - def append(self, item): self.data.append(item) - def insert(self, i, item): self.data.insert(i, item) - def pop(self, i=-1): return self.data.pop(i) - def remove(self, item): self.data.remove(item) - def count(self, item): return self.data.count(item) - def index(self, item, *args): return self.data.index(item, *args) - def reverse(self): self.data.reverse() - def sort(self, *args, **kwds): self.data.sort(*args, **kwds) - def extend(self, other): - if isinstance(other, UserList): - self.data.extend(other.data) - else: - self.data.extend(other) Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Tue Feb 12 21:03:09 2008 @@ -163,6 +163,80 @@ ################################################################################ +### UserList +################################################################################ + +class UserList(MutableSequence): + """A more or less complete user-defined wrapper around list objects.""" + def __init__(self, initlist=None): + self.data = [] + if initlist is not None: + # XXX should this accept an arbitrary sequence? + if type(initlist) == type(self.data): + self.data[:] = initlist + elif isinstance(initlist, UserList): + self.data[:] = initlist.data[:] + else: + self.data = list(initlist) + def __repr__(self): return repr(self.data) + def __lt__(self, other): return self.data < self.__cast(other) + def __le__(self, other): return self.data <= self.__cast(other) + def __eq__(self, other): return self.data == self.__cast(other) + def __ne__(self, other): return self.data != self.__cast(other) + def __gt__(self, other): return self.data > self.__cast(other) + def __ge__(self, other): return self.data >= self.__cast(other) + def __cast(self, other): + return other.data if isinstance(other, UserList) else other + def __cmp__(self, other): + return cmp(self.data, self.__cast(other)) + def __contains__(self, item): return item in self.data + def __len__(self): return len(self.data) + def __getitem__(self, i): return self.data[i] + def __setitem__(self, i, item): self.data[i] = item + def __delitem__(self, i): del self.data[i] + def __add__(self, other): + if isinstance(other, UserList): + return self.__class__(self.data + other.data) + elif isinstance(other, type(self.data)): + return self.__class__(self.data + other) + return self.__class__(self.data + list(other)) + def __radd__(self, other): + if isinstance(other, UserList): + return self.__class__(other.data + self.data) + elif isinstance(other, type(self.data)): + return self.__class__(other + self.data) + return self.__class__(list(other) + self.data) + def __iadd__(self, other): + if isinstance(other, UserList): + self.data += other.data + elif isinstance(other, type(self.data)): + self.data += other + else: + self.data += list(other) + return self + def __mul__(self, n): + return self.__class__(self.data*n) + __rmul__ = __mul__ + def __imul__(self, n): + self.data *= n + return self + def append(self, item): self.data.append(item) + def insert(self, i, item): self.data.insert(i, item) + def pop(self, i=-1): return self.data.pop(i) + def remove(self, item): self.data.remove(item) + def count(self, item): return self.data.count(item) + def index(self, item, *args): return self.data.index(item, *args) + def reverse(self): self.data.reverse() + def sort(self, *args, **kwds): self.data.sort(*args, **kwds) + def extend(self, other): + if isinstance(other, UserList): + self.data.extend(other.data) + else: + self.data.extend(other) + + + +################################################################################ ### Simple tests ################################################################################ Modified: python/branches/py3k/Lib/test/string_tests.py ============================================================================== --- python/branches/py3k/Lib/test/string_tests.py (original) +++ python/branches/py3k/Lib/test/string_tests.py Tue Feb 12 21:03:09 2008 @@ -4,7 +4,7 @@ import unittest, string, sys, struct from test import test_support -from UserList import UserList +from collections import UserList class Sequence: def __init__(self, seq='wxyz'): self.seq = seq Modified: python/branches/py3k/Lib/test/test_bisect.py ============================================================================== --- python/branches/py3k/Lib/test/test_bisect.py (original) +++ python/branches/py3k/Lib/test/test_bisect.py Tue Feb 12 21:03:09 2008 @@ -1,7 +1,7 @@ import unittest from test import test_support from bisect import bisect_right, bisect_left, insort_left, insort_right, insort, bisect -from UserList import UserList +from collections import UserList class TestBisect(unittest.TestCase): Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Tue Feb 12 21:03:09 2008 @@ -5,7 +5,7 @@ run_with_locale from operator import neg -import sys, warnings, random, collections, io, rational, fractions +import sys, warnings, random, collections, io, fractions warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) warnings.filterwarnings("ignore", "integer argument expected", @@ -210,7 +210,7 @@ # verify that circular objects are not handled a = []; a.append(a) b = []; b.append(b) - from UserList import UserList + from collections import UserList c = UserList(); c.append(c) self.assertRaises(RuntimeError, cmp, a, b) self.assertRaises(RuntimeError, cmp, b, c) Modified: python/branches/py3k/Lib/test/test_extcall.py ============================================================================== --- python/branches/py3k/Lib/test/test_extcall.py (original) +++ python/branches/py3k/Lib/test/test_extcall.py Tue Feb 12 21:03:09 2008 @@ -1,6 +1,5 @@ from test.test_support import verify, verbose, TestFailed, sortdict -from UserList import UserList -from collections import UserDict +from collections import UserDict, UserList def e(a, b): print(a, b) Modified: python/branches/py3k/Lib/test/test_file.py ============================================================================== --- python/branches/py3k/Lib/test/test_file.py (original) +++ python/branches/py3k/Lib/test/test_file.py Tue Feb 12 21:03:09 2008 @@ -5,7 +5,7 @@ from weakref import proxy from test.test_support import TESTFN, findfile, run_unittest -from UserList import UserList +from collections import UserList class AutoFileTests(unittest.TestCase): # file tests for which a test file is automatically set up Modified: python/branches/py3k/Lib/test/test_fileio.py ============================================================================== --- python/branches/py3k/Lib/test/test_fileio.py (original) +++ python/branches/py3k/Lib/test/test_fileio.py Tue Feb 12 21:03:09 2008 @@ -7,7 +7,7 @@ from weakref import proxy from test.test_support import TESTFN, findfile, run_unittest -from UserList import UserList +from collections import UserList import _fileio Modified: python/branches/py3k/Lib/test/test_richcmp.py ============================================================================== --- python/branches/py3k/Lib/test/test_richcmp.py (original) +++ python/branches/py3k/Lib/test/test_richcmp.py Tue Feb 12 21:03:09 2008 @@ -254,7 +254,7 @@ def test_recursion(self): # Check that comparison for recursive objects fails gracefully - from UserList import UserList + from collections import UserList a = UserList() b = UserList() a.append(b) Modified: python/branches/py3k/Lib/test/test_userlist.py ============================================================================== --- python/branches/py3k/Lib/test/test_userlist.py (original) +++ python/branches/py3k/Lib/test/test_userlist.py Tue Feb 12 21:03:09 2008 @@ -1,6 +1,6 @@ # Check every path through every method of UserList -from UserList import UserList +from collections import UserList import unittest from test import test_support, list_tests Modified: python/branches/py3k/Lib/test/test_weakref.py ============================================================================== --- python/branches/py3k/Lib/test/test_weakref.py (original) +++ python/branches/py3k/Lib/test/test_weakref.py Tue Feb 12 21:03:09 2008 @@ -1,7 +1,7 @@ import gc import sys import unittest -import UserList +import collections import weakref from test import test_support @@ -157,7 +157,7 @@ o = C() self.check_proxy(o, weakref.proxy(o)) - L = UserList.UserList() + L = collections.UserList() p = weakref.proxy(L) self.failIf(p, "proxy for empty UserList should be false") p.append(12) @@ -171,11 +171,11 @@ p[1] = 5 self.assertEqual(L[1], 5) self.assertEqual(p[1], 5) - L2 = UserList.UserList(L) + L2 = collections.UserList(L) p2 = weakref.proxy(L2) self.assertEqual(p, p2) ## self.assertEqual(repr(L2), repr(p2)) - L3 = UserList.UserList(range(10)) + L3 = collections.UserList(range(10)) p3 = weakref.proxy(L3) self.assertEqual(L3[:], p3[:]) self.assertEqual(L3[5:], p3[5:]) From python-3000-checkins at python.org Tue Feb 12 22:34:12 2008 From: python-3000-checkins at python.org (kurt.kaiser) Date: Tue, 12 Feb 2008 22:34:12 +0100 (CET) Subject: [Python-3000-checkins] r60753 - python/branches/py3k/Lib/idlelib/configDialog.py python/branches/py3k/Lib/idlelib/configHandler.py Message-ID: <20080212213412.F2BC61E4029@bag.python.org> Author: kurt.kaiser Date: Tue Feb 12 22:34:12 2008 New Revision: 60753 Modified: python/branches/py3k/Lib/idlelib/configDialog.py python/branches/py3k/Lib/idlelib/configHandler.py Log: Convert some custom sort comparison functions to equivalent key functions. Modified: python/branches/py3k/Lib/idlelib/configDialog.py ============================================================================== --- python/branches/py3k/Lib/idlelib/configDialog.py (original) +++ python/branches/py3k/Lib/idlelib/configDialog.py Tue Feb 12 22:34:12 2008 @@ -980,16 +980,11 @@ self.SetThemeType() ##load theme element option menu themeNames = list(self.themeElements.keys()) - themeNames.sort(self.__ThemeNameIndexCompare) + themeNames.sort(key=lambda x: self.themeElements[x][1]) self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0]) self.PaintThemeSample() self.SetHighlightTarget() - def __ThemeNameIndexCompare(self,a,b): - if self.themeElements[a][1] int(h2[2]): - return 1 - else: - return 0 - def GetAllExtraHelpSourcesList(self): """ Returns a list of tuples containing the details of all additional help From python-3000-checkins at python.org Tue Feb 12 23:59:26 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 12 Feb 2008 23:59:26 +0100 (CET) Subject: [Python-3000-checkins] r60756 - in python/branches/py3k: Doc/library/collections.rst Doc/library/fractions.rst Lib/decimal.py Lib/httplib.py Lib/idlelib/configHandler.py Lib/numbers.py Modules/_collectionsmodule.c PC/_msi.c Message-ID: <20080212225926.48EEE1E4020@bag.python.org> Author: christian.heimes Date: Tue Feb 12 23:59:25 2008 New Revision: 60756 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/fractions.rst python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/httplib.py python/branches/py3k/Lib/idlelib/configHandler.py python/branches/py3k/Lib/numbers.py python/branches/py3k/Modules/_collectionsmodule.c python/branches/py3k/PC/_msi.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60735-60751 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60735 | raymond.hettinger | 2008-02-11 23:53:01 +0100 (Mon, 11 Feb 2008) | 1 line Add notes on how decimal fits into the model. ........ r60737 | raymond.hettinger | 2008-02-12 00:34:56 +0100 (Tue, 12 Feb 2008) | 1 line Fix markup ........ r60738 | raymond.hettinger | 2008-02-12 00:38:00 +0100 (Tue, 12 Feb 2008) | 1 line Backport ABC docs ........ r60739 | raymond.hettinger | 2008-02-12 01:15:32 +0100 (Tue, 12 Feb 2008) | 1 line Restore fractions.rst to the document tree. ........ r60740 | raymond.hettinger | 2008-02-12 01:48:20 +0100 (Tue, 12 Feb 2008) | 1 line Fix typo in comments ........ r60741 | raymond.hettinger | 2008-02-12 02:18:03 +0100 (Tue, 12 Feb 2008) | 1 line Bring decimal a bit closer to the spec for Reals. ........ r60743 | martin.v.loewis | 2008-02-12 14:47:26 +0100 (Tue, 12 Feb 2008) | 2 lines Patch #1736: Fix file name handling of _msi.FCICreate. ........ r60745 | kurt.kaiser | 2008-02-12 16:45:50 +0100 (Tue, 12 Feb 2008) | 2 lines what??! Correct r60225. ........ r60747 | martin.v.loewis | 2008-02-12 19:47:34 +0100 (Tue, 12 Feb 2008) | 4 lines Patch #1966: Break infinite loop in httplib when the servers implements the chunked encoding incorrectly. Will backport to 2.5. ........ r60749 | raymond.hettinger | 2008-02-12 20:05:36 +0100 (Tue, 12 Feb 2008) | 1 line dict.copy() rises from the ashes. Revert r60687. ........ Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Tue Feb 12 23:59:25 2008 @@ -12,10 +12,18 @@ there are two datatypes, :class:`deque` and :class:`defaultdict`, and one datatype factory function, :func:`namedtuple`. +Besides the containers provided here, the optional :mod:`bsddb` +module offers the ability to create in-memory or file based ordered +dictionaries with string keys using the :meth:`bsddb.btopen` method. + +In addition to containers, the collections module provides some ABCs +(abstract base classes) that can be used to test whether a class +provides a particular interface, for example, is it hashable or +a mapping. + The specialized containers provided in this module provide alternatives to Python's general purpose built-in containers, :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple`. - Besides the containers provided here, the optional :mod:`bsddb` module offers the ability to create in-memory or file based ordered dictionaries with string keys using the :meth:`bsddb.btopen` method. @@ -128,7 +136,6 @@ (For more about ABCs, see the :mod:`abc` module and :pep:`3119`.) - .. _deque-objects: :class:`deque` objects Modified: python/branches/py3k/Doc/library/fractions.rst ============================================================================== --- python/branches/py3k/Doc/library/fractions.rst (original) +++ python/branches/py3k/Doc/library/fractions.rst Tue Feb 12 23:59:25 2008 @@ -1,6 +1,6 @@ :mod:`fractions` --- Rational numbers -==================================== +===================================== .. module:: fractions :synopsis: Rational numbers. Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Tue Feb 12 23:59:25 2008 @@ -1518,6 +1518,20 @@ __trunc__ = __int__ + @property + def real(self): + return self + + @property + def imag(self): + return Decimal(0) + + def conjugate(self): + return self + + def __complex__(self): + return complex(float(self)) + def _fix_nan(self, context): """Decapitate the payload of a NaN to fit the context""" payload = self._int Modified: python/branches/py3k/Lib/httplib.py ============================================================================== --- python/branches/py3k/Lib/httplib.py (original) +++ python/branches/py3k/Lib/httplib.py Tue Feb 12 23:59:25 2008 @@ -596,6 +596,10 @@ ### note: we shouldn't have any trailers! while True: line = self.fp.readline() + if not line: + # a vanishingly small number of sites EOF without + # sending the trailer + break if line == b"\r\n": break Modified: python/branches/py3k/Lib/idlelib/configHandler.py ============================================================================== --- python/branches/py3k/Lib/idlelib/configHandler.py (original) +++ python/branches/py3k/Lib/idlelib/configHandler.py Tue Feb 12 23:59:25 2008 @@ -143,7 +143,7 @@ try: cfgFile = open(fname, 'w') except IOError: - fname.unlink() + os.unlink(fname) cfgFile = open(fname, 'w') self.write(cfgFile) else: Modified: python/branches/py3k/Lib/numbers.py ============================================================================== --- python/branches/py3k/Lib/numbers.py (original) +++ python/branches/py3k/Lib/numbers.py Tue Feb 12 23:59:25 2008 @@ -46,6 +46,32 @@ # Inexact.register(decimal.Decimal) +## Notes on Decimal and it how relates to the numeric tower +## -------------------------------------------------------- +## Decimal is Real except that it does not support rich comparisons. +## +## Decimal has some of the characteristics of Integrals. It provides +## logical operations but not as operators. The logical operations only apply +## to a subset of decimals (those that are non-negative, have a zero exponent, +## and have digits that are only 0 or 1). It does provide __long__() and +## a three argument form of __pow__ that includes exactness guarantees. +## It does not provide an __index__() method. +## +## Depending on context, decimal operations may be exact or inexact. +## +## When decimal is run in a context with small precision and automatic rounding, +## it is Inexact. See the "Floating point notes" section of the decimal docs +## for an example of losing the associative and distributive properties of +## addition. +## +## When decimal is used for high precision integer arithmetic, it is Exact. +## When the decimal used as fixed-point, it is Exact. +## When it is run with sufficient precision, it is Exact. +## When the decimal.Inexact trap is set, decimal operations are Exact. +## For an example, see the float_to_decimal() recipe in the "Decimal FAQ" +## section of the docs -- it shows an how traps are used in conjunction +## with variable precision to reliably achieve exact results. + class Complex(Number): """Complex defines the operations that work on the builtin complex type. Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Tue Feb 12 23:59:25 2008 @@ -1127,7 +1127,7 @@ { /* This calls the object's class. That only works for subclasses whose class constructor has the same signature. Subclasses that - define a different constructor signature must override __copy__(). + define a different constructor signature must override copy(). */ return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd), dd->default_factory, dd, NULL); Modified: python/branches/py3k/PC/_msi.c ============================================================================== --- python/branches/py3k/PC/_msi.c (original) +++ python/branches/py3k/PC/_msi.c Tue Feb 12 23:59:25 2008 @@ -180,12 +180,12 @@ static PyObject* fcicreate(PyObject* obj, PyObject* args) { - char *cabname; + char *cabname, *p; PyObject *files; CCAB ccab; HFCI hfci; ERF erf; - int i; + Py_ssize_t i; if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files)) @@ -208,22 +208,22 @@ ccab.setID = 0; ccab.szDisk[0] = '\0'; - for (i=0; cabname[i]; i++) - if (cabname[i] == '\\' || cabname[i] == '/') - break; + for (i = 0, p = cabname; *p; p = CharNext(p)) + if (*p == '\\' || *p == '/') + i = p - cabname + 1; - if (i > sizeof(ccab.szCabPath) || - strlen(cabname+i) > sizeof(ccab.szCab)) { + if (i >= sizeof(ccab.szCabPath) || + strlen(cabname+i) >= sizeof(ccab.szCab)) { PyErr_SetString(PyExc_ValueError, "path name too long"); return 0; } - if (cabname[i]) { + if (i > 0) { memcpy(ccab.szCabPath, cabname, i); ccab.szCabPath[i] = '\0'; strcpy(ccab.szCab, cabname+i); } else { - strcpy(ccab.szCabPath, "."); + strcpy(ccab.szCabPath, ".\\"); strcpy(ccab.szCab, cabname); } From python-3000-checkins at python.org Wed Feb 13 17:09:27 2008 From: python-3000-checkins at python.org (kurt.kaiser) Date: Wed, 13 Feb 2008 17:09:27 +0100 (CET) Subject: [Python-3000-checkins] r60761 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: <20080213160927.6EF701E4014@bag.python.org> Author: kurt.kaiser Date: Wed Feb 13 17:09:27 2008 New Revision: 60761 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Log: list.sort() and builtin.sorted() no longer accept 'cmp' argument. Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Wed Feb 13 17:09:27 2008 @@ -141,6 +141,10 @@ :meth:`dict.values` return views instead of lists. For example, this no longer works: ``k = d.keys(); k.sort()``. Use ``k = sorted(d)`` instead. +* :meth:`builtin.sorted` and :meth:`list.sort` no longer accept the `cmp` + argument providing a comparision function. Use the `key` argument + instead. N.B. the `key` and `reverse` arguments are now "keyword-only". + * ``1/2`` returns a float. Use ``1//2`` to get the truncating behavior. * The :func:`repr` of a long integer doesn't include the trailing ``L`` From python-3000-checkins at python.org Wed Feb 13 19:03:12 2008 From: python-3000-checkins at python.org (kurt.kaiser) Date: Wed, 13 Feb 2008 19:03:12 +0100 (CET) Subject: [Python-3000-checkins] r60763 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: <20080213180312.438411E4015@bag.python.org> Author: kurt.kaiser Date: Wed Feb 13 19:03:11 2008 New Revision: 60763 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Log: Improve formatting for arg names in previous checkin. Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Wed Feb 13 19:03:11 2008 @@ -141,9 +141,9 @@ :meth:`dict.values` return views instead of lists. For example, this no longer works: ``k = d.keys(); k.sort()``. Use ``k = sorted(d)`` instead. -* :meth:`builtin.sorted` and :meth:`list.sort` no longer accept the `cmp` - argument providing a comparision function. Use the `key` argument - instead. N.B. the `key` and `reverse` arguments are now "keyword-only". +* :meth:`builtin.sorted` and :meth:`list.sort` no longer accept the *cmp* + argument providing a comparision function. Use the *key* argument + instead. N.B. the *key* and *reverse* arguments are now "keyword-only". * ``1/2`` returns a float. Use ``1//2`` to get the truncating behavior. From python-3000-checkins at python.org Wed Feb 13 21:40:44 2008 From: python-3000-checkins at python.org (thomas.heller) Date: Wed, 13 Feb 2008 21:40:44 +0100 (CET) Subject: [Python-3000-checkins] r60769 - in python/branches/py3k: Doc/library/ctypes.rst Lib/ctypes/test/test_pickling.py Modules/_ctypes/_ctypes.c Modules/_ctypes/callproc.c Modules/_ctypes/ctypes.h Modules/_ctypes/stgdict.c Message-ID: <20080213204044.A61AE1E4011@bag.python.org> Author: thomas.heller Date: Wed Feb 13 21:40:44 2008 New Revision: 60769 Added: python/branches/py3k/Lib/ctypes/test/test_pickling.py - copied, changed from r60767, python/trunk/Lib/ctypes/test/test_pickling.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/ctypes.rst python/branches/py3k/Modules/_ctypes/_ctypes.c python/branches/py3k/Modules/_ctypes/callproc.c python/branches/py3k/Modules/_ctypes/ctypes.h python/branches/py3k/Modules/_ctypes/stgdict.c Log: Merged revisions 60767,60768 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60767 | thomas.heller | 2008-02-13 21:21:53 +0100 (Mi, 13 Feb 2008) | 1 line Add pickle support to ctypes types. ........ r60768 | thomas.heller | 2008-02-13 21:36:51 +0100 (Mi, 13 Feb 2008) | 1 line Make the test somewhat clearer (I hope). ........ Modified: python/branches/py3k/Doc/library/ctypes.rst ============================================================================== --- python/branches/py3k/Doc/library/ctypes.rst (original) +++ python/branches/py3k/Doc/library/ctypes.rst Wed Feb 13 21:40:44 2008 @@ -2009,6 +2009,11 @@ ctypes data types. ``_SimpleCData`` is a subclass of ``_CData``, so it inherits their methods and attributes. + .. versionchanged:: 2.6 + + ctypes data types that are not and do not contain pointers can + now be pickled. + Instances have a single attribute: Copied: python/branches/py3k/Lib/ctypes/test/test_pickling.py (from r60767, python/trunk/Lib/ctypes/test/test_pickling.py) ============================================================================== --- python/trunk/Lib/ctypes/test/test_pickling.py (original) +++ python/branches/py3k/Lib/ctypes/test/test_pickling.py Wed Feb 13 21:40:44 2008 @@ -28,8 +28,8 @@ ]: dst = self.loads(self.dumps(src)) self.failUnlessEqual(src.__dict__, dst.__dict__) - self.failUnlessEqual(buffer(src), - buffer(dst)) + self.failUnlessEqual(memoryview(src).tobytes(), + memoryview(dst).tobytes()) def test_struct(self): X.init_called = 0 @@ -46,8 +46,8 @@ # ctypes instances are identical when the instance __dict__ # and the memory buffer are identical self.failUnlessEqual(y.__dict__, x.__dict__) - self.failUnlessEqual(buffer(y), - buffer(x)) + self.failUnlessEqual(memoryview(y).tobytes(), + memoryview(x).tobytes()) def test_unpickable(self): # ctypes objects that are pointers or contain pointers are Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Wed Feb 13 21:40:44 2008 @@ -123,6 +123,9 @@ PyObject *PyExc_ArgError; static PyTypeObject Simple_Type; +/* a callable object used for unpickling */ +static PyObject *_unpickle; + char *conversion_mode_encoding = NULL; char *conversion_mode_errors = NULL; @@ -710,6 +713,7 @@ stgdict->length = 1; stgdict->ffi_type_pointer = ffi_type_pointer; stgdict->paramfunc = PointerType_paramfunc; + stgdict->flags |= TYPEFLAG_ISPOINTER; proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */ if (proto && -1 == PointerType_SetProto(stgdict, proto)) { @@ -1139,6 +1143,9 @@ itemalign = itemdict->align; + if (itemdict->flags & (TYPEFLAG_ISPOINTER | TYPEFLAG_HASPOINTER)) + stgdict->flags |= TYPEFLAG_HASPOINTER; + stgdict->size = itemsize * length; stgdict->align = itemalign; stgdict->length = length; @@ -1706,12 +1713,21 @@ switch (*proto_str) { case 'z': /* c_char_p */ ml = &c_char_p_method; + stgdict->flags |= TYPEFLAG_ISPOINTER; break; case 'Z': /* c_wchar_p */ ml = &c_wchar_p_method; + stgdict->flags |= TYPEFLAG_ISPOINTER; break; case 'P': /* c_void_p */ ml = &c_void_p_method; + stgdict->flags |= TYPEFLAG_ISPOINTER; + break; + case 'u': + case 'X': + case 'O': + ml = NULL; + stgdict->flags |= TYPEFLAG_ISPOINTER; break; default: ml = NULL; @@ -1928,7 +1944,7 @@ "class must define _flags_ which must be an integer"); return -1; } - stgdict->flags = PyLong_AS_LONG(ob); + stgdict->flags = PyLong_AS_LONG(ob) | TYPEFLAG_ISPOINTER; /* _argtypes_ is optional... */ ob = PyDict_GetItemString((PyObject *)stgdict, "_argtypes_"); @@ -2003,6 +2019,7 @@ return NULL; stgdict->paramfunc = CFuncPtrType_paramfunc; + stgdict->flags |= TYPEFLAG_ISPOINTER; /* create the new instance (which is a class, since we are a metatype!) */ @@ -2235,6 +2252,45 @@ return -1; } +static PyObject * +CData_reduce(PyObject *_self, PyObject *args) +{ + CDataObject *self = (CDataObject *)_self; + + if (PyObject_stgdict(_self)->flags & (TYPEFLAG_ISPOINTER|TYPEFLAG_HASPOINTER)) { + PyErr_SetString(PyExc_ValueError, + "ctypes objects containing pointers cannot be pickled"); + return NULL; + } + return Py_BuildValue("O(O(NN))", + _unpickle, + Py_TYPE(_self), + PyObject_GetAttrString(_self, "__dict__"), + PyString_FromStringAndSize(self->b_ptr, self->b_size)); +} + +static PyObject * +CData_setstate(PyObject *_self, PyObject *args) +{ + void *data; + int len; + int res; + PyObject *dict, *mydict; + CDataObject *self = (CDataObject *)_self; + if (!PyArg_ParseTuple(args, "Os#", &dict, &data, &len)) + return NULL; + if (len > self->b_size) + len = self->b_size; + memmove(self->b_ptr, data, len); + mydict = PyObject_GetAttrString(_self, "__dict__"); + res = PyDict_Update(mydict, dict); + Py_DECREF(mydict); + if (res == -1) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + /* * default __ctypes_from_outparam__ method returns self. */ @@ -2247,6 +2303,8 @@ static PyMethodDef CData_methods[] = { { "__ctypes_from_outparam__", CData_from_outparam, METH_NOARGS, }, + { "__reduce__", CData_reduce, METH_NOARGS, }, + { "__setstate__", CData_setstate, METH_VARARGS, }, { NULL, NULL }, }; @@ -4934,6 +4992,10 @@ if (!m) return; + _unpickle = PyObject_GetAttrString(m, "_unpickle"); + if (_unpickle == NULL) + return; + if (PyType_Ready(&PyCArg_Type) < 0) return; Modified: python/branches/py3k/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/callproc.c (original) +++ python/branches/py3k/Modules/_ctypes/callproc.c Wed Feb 13 21:40:44 2008 @@ -1543,7 +1543,30 @@ return Py_None; } +static PyObject * +unpickle(PyObject *self, PyObject *args) +{ + PyObject *typ; + PyObject *state; + PyObject *result; + PyObject *tmp; + + if (!PyArg_ParseTuple(args, "OO", &typ, &state)) + return NULL; + result = PyObject_CallMethod(typ, "__new__", "O", typ); + if (result == NULL) + return NULL; + tmp = PyObject_CallMethod(result, "__setstate__", "O", state); + if (tmp == NULL) { + Py_DECREF(result); + return NULL; + } + Py_DECREF(tmp); + return result; +} + PyMethodDef module_methods[] = { + {"_unpickle", unpickle, METH_VARARGS }, {"resize", resize, METH_VARARGS, "Resize the memory buffer of a ctypes instance"}, #ifdef CTYPES_UNICODE {"set_conversion_mode", set_conversion_mode, METH_VARARGS, set_conversion_mode_doc}, Modified: python/branches/py3k/Modules/_ctypes/ctypes.h ============================================================================== --- python/branches/py3k/Modules/_ctypes/ctypes.h (original) +++ python/branches/py3k/Modules/_ctypes/ctypes.h Wed Feb 13 21:40:44 2008 @@ -269,6 +269,9 @@ #define FUNCFLAG_HRESULT 0x2 #define FUNCFLAG_PYTHONAPI 0x4 +#define TYPEFLAG_ISPOINTER 0x100 +#define TYPEFLAG_HASPOINTER 0x200 + #define DICTFLAG_FINAL 0x1000 struct tagPyCArgObject { Modified: python/branches/py3k/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/stgdict.c (original) +++ python/branches/py3k/Modules/_ctypes/stgdict.c Wed Feb 13 21:40:44 2008 @@ -402,6 +402,8 @@ return -1; } stgdict->ffi_type_pointer.elements[ffi_ofs + i] = &dict->ffi_type_pointer; + if (dict->flags & (TYPEFLAG_ISPOINTER | TYPEFLAG_HASPOINTER)) + stgdict->flags |= TYPEFLAG_HASPOINTER; dict->flags |= DICTFLAG_FINAL; /* mark field type final */ if (PyTuple_Size(pair) == 3) { /* bits specified */ switch(dict->ffi_type_pointer.type) { From python-3000-checkins at python.org Thu Feb 14 03:47:51 2008 From: python-3000-checkins at python.org (kurt.kaiser) Date: Thu, 14 Feb 2008 03:47:51 +0100 (CET) Subject: [Python-3000-checkins] r60774 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: <20080214024751.14EB91E4003@bag.python.org> Author: kurt.kaiser Date: Thu Feb 14 03:47:50 2008 New Revision: 60774 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Log: typo Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Thu Feb 14 03:47:50 2008 @@ -142,7 +142,7 @@ longer works: ``k = d.keys(); k.sort()``. Use ``k = sorted(d)`` instead. * :meth:`builtin.sorted` and :meth:`list.sort` no longer accept the *cmp* - argument providing a comparision function. Use the *key* argument + argument providing a comparison function. Use the *key* argument instead. N.B. the *key* and *reverse* arguments are now "keyword-only". * ``1/2`` returns a float. Use ``1//2`` to get the truncating behavior. From python-3000-checkins at python.org Thu Feb 14 09:27:39 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 14 Feb 2008 09:27:39 +0100 (CET) Subject: [Python-3000-checkins] r60787 - in python/branches/py3k: Doc/library/decimal.rst Doc/library/fractions.rst Doc/library/os.rst Lib/abc.py Lib/decimal.py Lib/fractions.py Lib/idlelib/NEWS.txt Lib/numbers.py Lib/test/test_abc.py Lib/test/test_decimal.py Lib/test/test_fractions.py Modules/posixmodule.c configure configure.in Message-ID: <20080214082739.596631E4025@bag.python.org> Author: christian.heimes Date: Thu Feb 14 09:27:37 2008 New Revision: 60787 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/fractions.rst python/branches/py3k/Doc/library/os.rst python/branches/py3k/Lib/abc.py python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/fractions.py python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/numbers.py python/branches/py3k/Lib/test/test_abc.py python/branches/py3k/Lib/test/test_decimal.py python/branches/py3k/Lib/test/test_fractions.py python/branches/py3k/Modules/posixmodule.c python/branches/py3k/configure python/branches/py3k/configure.in Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60766,60769-60786 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60752 | mark.dickinson | 2008-02-12 22:31:59 +0100 (Tue, 12 Feb 2008) | 5 lines Implementation of Fraction.limit_denominator. Remove Fraction.to_continued_fraction and Fraction.from_continued_fraction ........ r60754 | mark.dickinson | 2008-02-12 22:40:53 +0100 (Tue, 12 Feb 2008) | 3 lines Revert change in r60712: turn alternate constructors back into classmethods instead of staticmethods. ........ r60755 | mark.dickinson | 2008-02-12 22:46:54 +0100 (Tue, 12 Feb 2008) | 4 lines Replace R=fractions.Fraction with F=fractions.Fraction in test_fractions.py. This should have been part of the name change from Rational to Fraction. ........ r60758 | georg.brandl | 2008-02-13 08:20:22 +0100 (Wed, 13 Feb 2008) | 3 lines #2063: correct order of utime and stime in os.times() result on Windows. ........ r60762 | jeffrey.yasskin | 2008-02-13 18:58:04 +0100 (Wed, 13 Feb 2008) | 7 lines Working on issue #1762: Brought ./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'isinstance(3, Fraction); isinstance(f, Fraction)' from 12.3 usec/loop to 3.44 usec/loop and ./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)' from 48.8 usec to 23.6 usec by avoiding genexps and sets in __instancecheck__ and inlining the common case from __subclasscheck__. ........ r60765 | brett.cannon | 2008-02-13 20:15:44 +0100 (Wed, 13 Feb 2008) | 5 lines Fix --enable-universalsdk and its comment line so that zsh's flag completion works. Thanks to Jeroen Ruigrok van der Werven for the fix. ........ r60771 | kurt.kaiser | 2008-02-14 01:08:55 +0100 (Thu, 14 Feb 2008) | 2 lines Bring NEWS.txt up to date from check-in msgs. ........ r60772 | raymond.hettinger | 2008-02-14 02:08:02 +0100 (Thu, 14 Feb 2008) | 3 lines Update notes on Decimal. ........ r60773 | raymond.hettinger | 2008-02-14 03:41:22 +0100 (Thu, 14 Feb 2008) | 1 line Fix decimal repr which should have used single quotes like other reprs. ........ r60785 | jeffrey.yasskin | 2008-02-14 07:12:24 +0100 (Thu, 14 Feb 2008) | 11 lines Performance optimizations on Fraction's constructor. ./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3)` 31.7 usec/loop -> 9.2 usec/loop ./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)'` 27.7 usec/loop -> 9.32 usec/loop ./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'Fraction(f)' 31.9 usec/loop -> 14.3 usec/loop ........ r60786 | jeffrey.yasskin | 2008-02-14 08:49:25 +0100 (Thu, 14 Feb 2008) | 5 lines Change simple instances (in Fraction) of self.numerator and self.denominator to self._numerator and self._denominator. This speeds abs() up from 12.2us to 10.8us and trunc() from 2.07us to 1.11us. This doesn't change _add and friends because they're more complicated. ........ Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Thu Feb 14 09:27:37 2008 @@ -46,10 +46,10 @@ >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) - Decimal("0.142857") + Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) - Decimal("0.1428571428571428571428571429") + Decimal('0.1428571428571428571428571429') * Both binary and decimal floating point are implemented in terms of published standards. While the built-in float type exposes only a modest portion of its @@ -128,19 +128,19 @@ :const:`Infinity`, and :const:`-0`. :: >>> Decimal(10) - Decimal("10") - >>> Decimal("3.14") - Decimal("3.14") + Decimal('10') + >>> Decimal('3.14') + Decimal('3.14') >>> Decimal((0, (3, 1, 4), -2)) - Decimal("3.14") + Decimal('3.14') >>> Decimal(str(2.0 ** 0.5)) - Decimal("1.41421356237") - >>> Decimal(2) ** Decimal("0.5") - Decimal("1.414213562373095048801688724") - >>> Decimal("NaN") - Decimal("NaN") - >>> Decimal("-Infinity") - Decimal("-Infinity") + Decimal('1.41421356237') + >>> Decimal(2) ** Decimal('0.5') + Decimal('1.414213562373095048801688724') + >>> Decimal('NaN') + Decimal('NaN') + >>> Decimal('-Infinity') + Decimal('-Infinity') The significance of a new Decimal is determined solely by the number of digits input. Context precision and rounding only come into play during arithmetic @@ -148,28 +148,28 @@ >>> getcontext().prec = 6 >>> Decimal('3.0') - Decimal("3.0") + Decimal('3.0') >>> Decimal('3.1415926535') - Decimal("3.1415926535") + Decimal('3.1415926535') >>> Decimal('3.1415926535') + Decimal('2.7182818285') - Decimal("5.85987") + Decimal('5.85987') >>> getcontext().rounding = ROUND_UP >>> Decimal('3.1415926535') + Decimal('2.7182818285') - Decimal("5.85988") + Decimal('5.85988') Decimals interact well with much of the rest of Python. Here is a small decimal floating point flying circus:: >>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()) >>> max(data) - Decimal("9.25") + Decimal('9.25') >>> min(data) - Decimal("0.03") + Decimal('0.03') >>> sorted(data) - [Decimal("0.03"), Decimal("1.00"), Decimal("1.34"), Decimal("1.87"), - Decimal("2.35"), Decimal("3.45"), Decimal("9.25")] + [Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'), + Decimal('2.35'), Decimal('3.45'), Decimal('9.25')] >>> sum(data) - Decimal("19.29") + Decimal('19.29') >>> a,b,c = data[:3] >>> str(a) '1.34' @@ -180,31 +180,31 @@ >>> int(a) 1 >>> a * 5 - Decimal("6.70") + Decimal('6.70') >>> a * b - Decimal("2.5058") + Decimal('2.5058') >>> c % a - Decimal("0.77") + Decimal('0.77') And some mathematical functions are also available to Decimal:: >>> Decimal(2).sqrt() - Decimal("1.414213562373095048801688724") + Decimal('1.414213562373095048801688724') >>> Decimal(1).exp() - Decimal("2.718281828459045235360287471") - >>> Decimal("10").ln() - Decimal("2.302585092994045684017991455") - >>> Decimal("10").log10() - Decimal("1") + Decimal('2.718281828459045235360287471') + >>> Decimal('10').ln() + Decimal('2.302585092994045684017991455') + >>> Decimal('10').log10() + Decimal('1') The :meth:`quantize` method rounds a number to a fixed exponent. This method is useful for monetary applications that often round results to a fixed number of places:: >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) - Decimal("7.32") + Decimal('7.32') >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) - Decimal("8") + Decimal('8') As shown above, the :func:`getcontext` function accesses the current context and allows the settings to be changed. This approach meets the needs of most @@ -222,16 +222,16 @@ >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) - Decimal("0.142857142857142857142857142857142857142857142857142857142857") + Decimal('0.142857142857142857142857142857142857142857142857142857142857') >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, capitals=1, flags=[], traps=[]) >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) - Decimal("0.142857143") + Decimal('0.142857143') >>> Decimal(42) / Decimal(0) - Decimal("Infinity") + Decimal('Infinity') >>> setcontext(BasicContext) >>> Decimal(42) / Decimal(0) @@ -248,7 +248,7 @@ >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) - Decimal("3.14159292") + Decimal('3.14159292') >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, capitals=1, flags=[Inexact, Rounded], traps=[]) @@ -261,7 +261,7 @@ context:: >>> Decimal(1) / Decimal(0) - Decimal("Infinity") + Decimal('Infinity') >>> getcontext().traps[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) Traceback (most recent call last): @@ -289,7 +289,7 @@ Construct a new :class:`Decimal` object based from *value*. *value* can be an integer, string, tuple, or another :class:`Decimal` - object. If no *value* is given, returns ``Decimal("0")``. If *value* is a + object. If no *value* is given, returns ``Decimal('0')``. If *value* is a string, it should conform to the decimal numeric string syntax after leading and trailing whitespace characters are removed:: @@ -307,11 +307,11 @@ If *value* is a :class:`tuple`, it should have three components, a sign (:const:`0` for positive or :const:`1` for negative), a :class:`tuple` of digits, and an integer exponent. For example, ``Decimal((0, (1, 4, 1, 4), -3))`` - returns ``Decimal("1.414")``. + returns ``Decimal('1.414')``. The *context* precision does not affect how many digits are stored. That is determined exclusively by the number of digits in *value*. For example, - ``Decimal("3.00000")`` records all five zeros even if the context precision is + ``Decimal('3.00000')`` records all five zeros even if the context precision is only three. The purpose of the *context* argument is determining what to do if *value* is a @@ -338,7 +338,7 @@ .. method:: Decimal.adjusted() Return the adjusted exponent after shifting out the coefficient's rightmost - digits until only the lead digit remains: ``Decimal("321e+5").adjusted()`` + digits until only the lead digit remains: ``Decimal('321e+5').adjusted()`` returns seven. Used for determining the position of the most significant digit with respect to the decimal point. @@ -367,10 +367,10 @@ instance rather than an integer, and if either operand is a NaN then the result is a NaN:: - a or b is a NaN ==> Decimal("NaN") - a < b ==> Decimal("-1") - a == b ==> Decimal("0") - a > b ==> Decimal("1") + a or b is a NaN ==> Decimal('NaN') + a < b ==> Decimal('-1') + a == b ==> Decimal('0') + a > b ==> Decimal('1') .. method:: Decimal.compare_signal(other[, context]) @@ -389,14 +389,14 @@ value but different representations compare unequal in this ordering:: - >>> Decimal("12.0").compare_total(Decimal("12")) - Decimal("-1") + >>> Decimal('12.0').compare_total(Decimal('12')) + Decimal('-1') Quiet and signaling NaNs are also included in the total ordering. - The result of this function is ``Decimal("0")`` if both operands - have the same representation, ``Decimal("-1")`` if the first + The result of this function is ``Decimal('0')`` if both operands + have the same representation, ``Decimal('-1')`` if the first operand is lower in the total order than the second, and - ``Decimal("1")`` if the first operand is higher in the total order + ``Decimal('1')`` if the first operand is higher in the total order than the second operand. See the specification for details of the total order. @@ -428,8 +428,8 @@ Return a copy of the first operand with the sign set to be the same as the sign of the second operand. For example:: - >>> Decimal("2.3").copy_sign(Decimal("-1.5")) - Decimal("-2.3") + >>> Decimal('2.3').copy_sign(Decimal('-1.5')) + Decimal('-2.3') This operation is unaffected by the context and is quiet: no flags are changed and no rounding is performed. @@ -442,9 +442,9 @@ :const:`ROUND_HALF_EVEN` rounding mode. >>> Decimal(1).exp() - Decimal("2.718281828459045235360287471") + Decimal('2.718281828459045235360287471') >>> Decimal(321).exp() - Decimal("2.561702493119680037517373933E+139") + Decimal('2.561702493119680037517373933E+139') .. method:: Decimal.fma(other, third[, context]) @@ -453,7 +453,7 @@ the intermediate product self*other. >>> Decimal(2).fma(3, 5) - Decimal("11") + Decimal('11') .. method:: Decimal.is_canonical() @@ -537,9 +537,9 @@ For a nonzero number, return the adjusted exponent of its operand as a :class:`Decimal` instance. If the operand is a zero then - ``Decimal("-Infinity")`` is returned and the + ``Decimal('-Infinity')`` is returned and the :const:`DivisionByZero` flag is raised. If the operand is an - infinity then ``Decimal("Infinity")`` is returned. + infinity then ``Decimal('Infinity')`` is returned. .. method:: Decimal.logical_and(other[, context]) @@ -620,10 +620,10 @@ .. method:: Decimal.normalize([context]) Normalize the number by stripping the rightmost trailing zeros and converting - any result equal to :const:`Decimal("0")` to :const:`Decimal("0e0")`. Used for + any result equal to :const:`Decimal('0')` to :const:`Decimal('0e0')`. Used for producing canonical values for members of an equivalence class. For example, - ``Decimal("32.100")`` and ``Decimal("0.321000e+2")`` both normalize to the - equivalent value ``Decimal("32.1")``. + ``Decimal('32.100')`` and ``Decimal('0.321000e+2')`` both normalize to the + equivalent value ``Decimal('32.1')``. .. method:: Decimal.number_class([context]) @@ -648,8 +648,8 @@ Return a value equal to the first operand after rounding and having the exponent of the second operand. - >>> Decimal("1.41421356").quantize(Decimal("1.000")) - Decimal("1.414") + >>> Decimal('1.41421356').quantize(Decimal('1.000')) + Decimal('1.414') Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision, then an @@ -680,7 +680,7 @@ Compute the modulo as either a positive or negative value depending on which is closest to zero. For instance, ``Decimal(10).remainder_near(6)`` returns - ``Decimal("-2")`` which is closer to zero than ``Decimal("4")``. + ``Decimal('-2')`` which is closer to zero than ``Decimal('4')``. If both are equally close, the one chosen will have the same sign as *self*. @@ -732,7 +732,7 @@ Engineering notation has an exponent which is a multiple of 3, so there are up to 3 digits left of the decimal place. For example, converts - ``Decimal('123E+1')`` to ``Decimal("1.23E+3")`` + ``Decimal('123E+1')`` to ``Decimal('1.23E+3')`` .. method:: Decimal.to_integral([rounding[, context]]) @@ -937,10 +937,10 @@ change the result:: >>> getcontext().prec = 3 - >>> Decimal("3.4445") + Decimal("1.0023") - Decimal("4.45") - >>> Decimal("3.4445") + Decimal(0) + Decimal("1.0023") - Decimal("4.44") + >>> Decimal('3.4445') + Decimal('1.0023') + Decimal('4.45') + >>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023') + Decimal('4.44') This method implements the to-number operation of the IBM specification. If the argument is a string, no leading or trailing @@ -1195,15 +1195,15 @@ >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w - Decimal("9.5111111") + Decimal('9.5111111') >>> u + (v + w) - Decimal("10") + Decimal('10') >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) - Decimal("0.01") + Decimal('0.01') >>> u * (v+w) - Decimal("0.0060000") + Decimal('0.0060000') The :mod:`decimal` module makes it possible to restore the identities by expanding the precision sufficiently to avoid loss of significance:: @@ -1211,15 +1211,15 @@ >>> getcontext().prec = 20 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w - Decimal("9.51111111") + Decimal('9.51111111') >>> u + (v + w) - Decimal("9.51111111") + Decimal('9.51111111') >>> >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) - Decimal("0.0060000") + Decimal('0.0060000') >>> u * (v+w) - Decimal("0.0060000") + Decimal('0.0060000') Special values @@ -1275,7 +1275,7 @@ the following calculation returns a value equal to zero:: >>> 1 / Decimal('Infinity') - Decimal("0E-1000000026") + Decimal('0E-1000000026') .. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1486,7 +1486,7 @@ >>> D = decimal.Decimal >>> D('1.23') + D('3.45') - Decimal("4.68") + Decimal('4.68') Q. In a fixed-point application with two decimal places, some inputs have many places and need to be rounded. Others are not supposed to have excess digits @@ -1498,14 +1498,14 @@ >>> TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01') >>> # Round to two places - >>> Decimal("3.214").quantize(TWOPLACES) - Decimal("3.21") + >>> Decimal('3.214').quantize(TWOPLACES) + Decimal('3.21') >>> # Validate that a number does not exceed two places - >>> Decimal("3.21").quantize(TWOPLACES, context=Context(traps=[Inexact])) - Decimal("3.21") + >>> Decimal('3.21').quantize(TWOPLACES, context=Context(traps=[Inexact])) + Decimal('3.21') - >>> Decimal("3.214").quantize(TWOPLACES, context=Context(traps=[Inexact])) + >>> Decimal('3.214').quantize(TWOPLACES, context=Context(traps=[Inexact])) Traceback (most recent call last): ... Inexact: Changed in rounding @@ -1527,7 +1527,7 @@ >>> values = map(Decimal, '200 200.000 2E2 .02E+4'.split()) >>> [v.normalize() for v in values] - [Decimal("2E+2"), Decimal("2E+2"), Decimal("2E+2"), Decimal("2E+2")] + [Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2')] Q. Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation? @@ -1555,7 +1555,7 @@ ctx.prec += 1 >>> float_to_decimal(math.pi) - Decimal("3.141592653589793115997963468544185161590576171875") + Decimal('3.141592653589793115997963468544185161590576171875') Q. Why isn't the :func:`float_to_decimal` routine included in the module? @@ -1564,7 +1564,7 @@ representation issues associated with binary floating point:: >>> float_to_decimal(1.1) - Decimal("1.100000000000000088817841970012523233890533447265625") + Decimal('1.100000000000000088817841970012523233890533447265625') Q. Within a complex calculation, how can I make sure that I haven't gotten a spurious result because of insufficient precision or rounding anomalies. @@ -1585,20 +1585,20 @@ >>> getcontext().prec = 3 >>> Decimal('3.104') + D('2.104') - Decimal("5.21") + Decimal('5.21') >>> Decimal('3.104') + D('0.000') + D('2.104') - Decimal("5.20") + Decimal('5.20') The solution is either to increase precision or to force rounding of inputs using the unary plus operation:: >>> getcontext().prec = 3 >>> +Decimal('1.23456789') # unary plus triggers rounding - Decimal("1.23") + Decimal('1.23') Alternatively, inputs can be rounded upon creation using the :meth:`Context.create_decimal` method:: >>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678') - Decimal("1.2345") + Decimal('1.2345') Modified: python/branches/py3k/Doc/library/fractions.rst ============================================================================== --- python/branches/py3k/Doc/library/fractions.rst (original) +++ python/branches/py3k/Doc/library/fractions.rst Thu Feb 14 09:27:37 2008 @@ -46,6 +46,24 @@ :class:`decimal.Decimal`. +.. method:: Fraction.limit_denominator(max_denominator=1000000) + + Finds and returns the closest :class:`Fraction` to ``self`` that + has denominator at most max_denominator. This method is useful for + finding rational approximations to a given floating-point number:: + + >>> Fraction('3.1415926535897932').limit_denominator(1000) + Fraction(355, 113) + + or for recovering a rational number that's represented as a float:: + + >>> from math import pi, cos + >>> Fraction.from_float(cos(pi/3)) + Fraction(4503599627370497L, 9007199254740992L) + >>> Fraction.from_float(cos(pi/3)).limit_denominator() + Fraction(1, 2) + + .. method:: Fraction.__floor__() Returns the greatest :class:`int` ``<= self``. Will be accessible Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Thu Feb 14 09:27:37 2008 @@ -1584,7 +1584,7 @@ user time, children's system time, and elapsed real time since a fixed point in the past, in that order. See the Unix manual page :manpage:`times(2)` or the corresponding Windows Platform API documentation. Availability: Macintosh, Unix, - Windows. + Windows. On Windows, only the first two items are filled, the others are zero. .. function:: wait() Modified: python/branches/py3k/Lib/abc.py ============================================================================== --- python/branches/py3k/Lib/abc.py (original) +++ python/branches/py3k/Lib/abc.py Thu Feb 14 09:27:37 2008 @@ -162,8 +162,19 @@ def __instancecheck__(cls, instance): """Override for isinstance(instance, cls).""" - return any(cls.__subclasscheck__(c) - for c in {instance.__class__, type(instance)}) + # Inline the cache checking + subclass = instance.__class__ + if subclass in cls._abc_cache: + return True + subtype = type(instance) + if subtype is subclass: + if (cls._abc_negative_cache_version == + ABCMeta._abc_invalidation_counter and + subclass in cls._abc_negative_cache): + return False + # Fall back to the subclass check. + return cls.__subclasscheck__(subclass) + return any(cls.__subclasscheck__(c) for c in {subclass, subtype}) def __subclasscheck__(cls, subclass): """Override for issubclass(subclass, cls).""" Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Thu Feb 14 09:27:37 2008 @@ -35,26 +35,26 @@ useful for financial applications or for contexts where users have expectations that are at odds with binary floating point (for instance, in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead -of the expected Decimal("0.00") returned by decimal floating point). +of the expected Decimal('0.00') returned by decimal floating point). Here are some examples of using the decimal module: >>> from decimal import * >>> setcontext(ExtendedContext) >>> Decimal(0) -Decimal("0") ->>> Decimal("1") -Decimal("1") ->>> Decimal("-.0123") -Decimal("-0.0123") +Decimal('0') +>>> Decimal('1') +Decimal('1') +>>> Decimal('-.0123') +Decimal('-0.0123') >>> Decimal(123456) -Decimal("123456") ->>> Decimal("123.45e12345678901234567890") -Decimal("1.2345E+12345678901234567892") ->>> Decimal("1.33") + Decimal("1.27") -Decimal("2.60") ->>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41") -Decimal("-2.20") +Decimal('123456') +>>> Decimal('123.45e12345678901234567890') +Decimal('1.2345E+12345678901234567892') +>>> Decimal('1.33') + Decimal('1.27') +Decimal('2.60') +>>> Decimal('12.34') + Decimal('3.87') - Decimal('18.41') +Decimal('-2.20') >>> dig = Decimal(1) >>> print(dig / Decimal(3)) 0.333333333 @@ -91,7 +91,7 @@ >>> print(c.flags[InvalidOperation]) 0 >>> c.divide(Decimal(0), Decimal(0)) -Decimal("NaN") +Decimal('NaN') >>> c.traps[InvalidOperation] = 1 >>> print(c.flags[InvalidOperation]) 1 @@ -517,15 +517,15 @@ """Create a decimal point instance. >>> Decimal('3.14') # string input - Decimal("3.14") + Decimal('3.14') >>> Decimal((0, (3, 1, 4), -2)) # tuple (sign, digit_tuple, exponent) - Decimal("3.14") + Decimal('3.14') >>> Decimal(314) # int - Decimal("314") + Decimal('314') >>> Decimal(Decimal(314)) # another decimal instance - Decimal("314") + Decimal('314') >>> Decimal(' 3.14 \\n') # leading and trailing whitespace okay - Decimal("3.14") + Decimal('3.14') """ # Note that the coefficient, self._int, is actually stored as @@ -885,7 +885,7 @@ # # The hash of a nonspecial noninteger Decimal must depend only # on the value of that Decimal, and not on its representation. - # For example: hash(Decimal("100E-1")) == hash(Decimal("10")). + # For example: hash(Decimal('100E-1')) == hash(Decimal('10')). if self._is_special: if self._isnan(): raise TypeError('Cannot hash a NaN value.') @@ -919,7 +919,7 @@ def __repr__(self): """Represents the number as an instance of Decimal.""" # Invariant: eval(repr(d)) == d - return 'Decimal("%s")' % str(self) + return "Decimal('%s')" % str(self) def __str__(self, eng=False, context=None): """Return string representation of the number in scientific notation. @@ -3637,13 +3637,13 @@ the plus operation on the operand. >>> ExtendedContext.abs(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.abs(Decimal('-100')) - Decimal("100") + Decimal('100') >>> ExtendedContext.abs(Decimal('101.5')) - Decimal("101.5") + Decimal('101.5') >>> ExtendedContext.abs(Decimal('-101.5')) - Decimal("101.5") + Decimal('101.5') """ return a.__abs__(context=self) @@ -3651,9 +3651,9 @@ """Return the sum of the two operands. >>> ExtendedContext.add(Decimal('12'), Decimal('7.00')) - Decimal("19.00") + Decimal('19.00') >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4')) - Decimal("1.02E+4") + Decimal('1.02E+4') """ return a.__add__(b, context=self) @@ -3667,7 +3667,7 @@ received object already is in its canonical form. >>> ExtendedContext.canonical(Decimal('2.50')) - Decimal("2.50") + Decimal('2.50') """ return a.canonical(context=self) @@ -3686,17 +3686,17 @@ zero or negative zero, or '1' if the result is greater than zero. >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1')) - Decimal("0") + Decimal('0') >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10')) - Decimal("0") + Decimal('0') >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3')) - Decimal("1") + Decimal('1') >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1')) - Decimal("-1") + Decimal('-1') """ return a.compare(b, context=self) @@ -3708,21 +3708,21 @@ >>> c = ExtendedContext >>> c.compare_signal(Decimal('2.1'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> c.compare_signal(Decimal('2.1'), Decimal('2.1')) - Decimal("0") + Decimal('0') >>> c.flags[InvalidOperation] = 0 >>> print(c.flags[InvalidOperation]) 0 >>> c.compare_signal(Decimal('NaN'), Decimal('2.1')) - Decimal("NaN") + Decimal('NaN') >>> print(c.flags[InvalidOperation]) 1 >>> c.flags[InvalidOperation] = 0 >>> print(c.flags[InvalidOperation]) 0 >>> c.compare_signal(Decimal('sNaN'), Decimal('2.1')) - Decimal("NaN") + Decimal('NaN') >>> print(c.flags[InvalidOperation]) 1 """ @@ -3736,17 +3736,17 @@ representations. >>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare_total(Decimal('-127'), Decimal('12')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.30')) - Decimal("0") + Decimal('0') >>> ExtendedContext.compare_total(Decimal('12.3'), Decimal('12.300')) - Decimal("1") + Decimal('1') >>> ExtendedContext.compare_total(Decimal('12.3'), Decimal('NaN')) - Decimal("-1") + Decimal('-1') """ return a.compare_total(b) @@ -3761,9 +3761,9 @@ """Returns a copy of the operand with the sign set to 0. >>> ExtendedContext.copy_abs(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.copy_abs(Decimal('-100')) - Decimal("100") + Decimal('100') """ return a.copy_abs() @@ -3771,9 +3771,9 @@ """Returns a copy of the decimal objet. >>> ExtendedContext.copy_decimal(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.copy_decimal(Decimal('-1.00')) - Decimal("-1.00") + Decimal('-1.00') """ return Decimal(a) @@ -3781,9 +3781,9 @@ """Returns a copy of the operand with the sign inverted. >>> ExtendedContext.copy_negate(Decimal('101.5')) - Decimal("-101.5") + Decimal('-101.5') >>> ExtendedContext.copy_negate(Decimal('-101.5')) - Decimal("101.5") + Decimal('101.5') """ return a.copy_negate() @@ -3794,13 +3794,13 @@ equal to the sign of the second operand. >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('7.33')) - Decimal("1.50") + Decimal('1.50') >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('7.33')) - Decimal("1.50") + Decimal('1.50') >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('-7.33')) - Decimal("-1.50") + Decimal('-1.50') >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33')) - Decimal("-1.50") + Decimal('-1.50') """ return a.copy_sign(b) @@ -3808,25 +3808,25 @@ """Decimal division in a specified context. >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) - Decimal("0.333333333") + Decimal('0.333333333') >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) - Decimal("0.666666667") + Decimal('0.666666667') >>> ExtendedContext.divide(Decimal('5'), Decimal('2')) - Decimal("2.5") + Decimal('2.5') >>> ExtendedContext.divide(Decimal('1'), Decimal('10')) - Decimal("0.1") + Decimal('0.1') >>> ExtendedContext.divide(Decimal('12'), Decimal('12')) - Decimal("1") + Decimal('1') >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2')) - Decimal("4.00") + Decimal('4.00') >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0')) - Decimal("1.20") + Decimal('1.20') >>> ExtendedContext.divide(Decimal('1000'), Decimal('100')) - Decimal("10") + Decimal('10') >>> ExtendedContext.divide(Decimal('1000'), Decimal('1')) - Decimal("1000") + Decimal('1000') >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2')) - Decimal("1.20E+6") + Decimal('1.20E+6') """ return a.__truediv__(b, context=self) @@ -3834,11 +3834,11 @@ """Divides two numbers and returns the integer part of the result. >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3')) - Decimal("0") + Decimal('0') >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3')) - Decimal("3") + Decimal('3') >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3')) - Decimal("3") + Decimal('3') """ return a.__floordiv__(b, context=self) @@ -3852,17 +3852,17 @@ >>> c.Emin = -999 >>> c.Emax = 999 >>> c.exp(Decimal('-Infinity')) - Decimal("0") + Decimal('0') >>> c.exp(Decimal('-1')) - Decimal("0.367879441") + Decimal('0.367879441') >>> c.exp(Decimal('0')) - Decimal("1") + Decimal('1') >>> c.exp(Decimal('1')) - Decimal("2.71828183") + Decimal('2.71828183') >>> c.exp(Decimal('0.693147181')) - Decimal("2.00000000") + Decimal('2.00000000') >>> c.exp(Decimal('+Infinity')) - Decimal("Infinity") + Decimal('Infinity') """ return a.exp(context=self) @@ -3874,11 +3874,11 @@ multiplication, using add, all with only one final rounding. >>> ExtendedContext.fma(Decimal('3'), Decimal('5'), Decimal('7')) - Decimal("22") + Decimal('22') >>> ExtendedContext.fma(Decimal('3'), Decimal('-5'), Decimal('7')) - Decimal("-8") + Decimal('-8') >>> ExtendedContext.fma(Decimal('888565290'), Decimal('1557.96930'), Decimal('-86087.7578')) - Decimal("1.38435736E+12") + Decimal('1.38435736E+12') """ return a.fma(b, c, context=self) @@ -4032,15 +4032,15 @@ >>> c.Emin = -999 >>> c.Emax = 999 >>> c.ln(Decimal('0')) - Decimal("-Infinity") + Decimal('-Infinity') >>> c.ln(Decimal('1.000')) - Decimal("0") + Decimal('0') >>> c.ln(Decimal('2.71828183')) - Decimal("1.00000000") + Decimal('1.00000000') >>> c.ln(Decimal('10')) - Decimal("2.30258509") + Decimal('2.30258509') >>> c.ln(Decimal('+Infinity')) - Decimal("Infinity") + Decimal('Infinity') """ return a.ln(context=self) @@ -4051,19 +4051,19 @@ >>> c.Emin = -999 >>> c.Emax = 999 >>> c.log10(Decimal('0')) - Decimal("-Infinity") + Decimal('-Infinity') >>> c.log10(Decimal('0.001')) - Decimal("-3") + Decimal('-3') >>> c.log10(Decimal('1.000')) - Decimal("0") + Decimal('0') >>> c.log10(Decimal('2')) - Decimal("0.301029996") + Decimal('0.301029996') >>> c.log10(Decimal('10')) - Decimal("1") + Decimal('1') >>> c.log10(Decimal('70')) - Decimal("1.84509804") + Decimal('1.84509804') >>> c.log10(Decimal('+Infinity')) - Decimal("Infinity") + Decimal('Infinity') """ return a.log10(context=self) @@ -4076,13 +4076,13 @@ value of that digit and without limiting the resulting exponent). >>> ExtendedContext.logb(Decimal('250')) - Decimal("2") + Decimal('2') >>> ExtendedContext.logb(Decimal('2.50')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logb(Decimal('0.03')) - Decimal("-2") + Decimal('-2') >>> ExtendedContext.logb(Decimal('0')) - Decimal("-Infinity") + Decimal('-Infinity') """ return a.logb(context=self) @@ -4092,17 +4092,17 @@ The operands must be both logical numbers. >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_and(Decimal('0'), Decimal('1')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_and(Decimal('1'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_and(Decimal('1'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_and(Decimal('1100'), Decimal('1010')) - Decimal("1000") + Decimal('1000') >>> ExtendedContext.logical_and(Decimal('1111'), Decimal('10')) - Decimal("10") + Decimal('10') """ return a.logical_and(b, context=self) @@ -4112,13 +4112,13 @@ The operand must be a logical number. >>> ExtendedContext.logical_invert(Decimal('0')) - Decimal("111111111") + Decimal('111111111') >>> ExtendedContext.logical_invert(Decimal('1')) - Decimal("111111110") + Decimal('111111110') >>> ExtendedContext.logical_invert(Decimal('111111111')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_invert(Decimal('101010101')) - Decimal("10101010") + Decimal('10101010') """ return a.logical_invert(context=self) @@ -4128,17 +4128,17 @@ The operands must be both logical numbers. >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_or(Decimal('0'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_or(Decimal('1'), Decimal('0')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_or(Decimal('1'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_or(Decimal('1100'), Decimal('1010')) - Decimal("1110") + Decimal('1110') >>> ExtendedContext.logical_or(Decimal('1110'), Decimal('10')) - Decimal("1110") + Decimal('1110') """ return a.logical_or(b, context=self) @@ -4148,17 +4148,17 @@ The operands must be both logical numbers. >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('0')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('1')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_xor(Decimal('1100'), Decimal('1010')) - Decimal("110") + Decimal('110') >>> ExtendedContext.logical_xor(Decimal('1111'), Decimal('10')) - Decimal("1101") + Decimal('1101') """ return a.logical_xor(b, context=self) @@ -4172,13 +4172,13 @@ infinity) of the two operands is chosen as the result. >>> ExtendedContext.max(Decimal('3'), Decimal('2')) - Decimal("3") + Decimal('3') >>> ExtendedContext.max(Decimal('-10'), Decimal('3')) - Decimal("3") + Decimal('3') >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.max(Decimal('7'), Decimal('NaN')) - Decimal("7") + Decimal('7') """ return a.max(b, context=self) @@ -4196,13 +4196,13 @@ infinity) of the two operands is chosen as the result. >>> ExtendedContext.min(Decimal('3'), Decimal('2')) - Decimal("2") + Decimal('2') >>> ExtendedContext.min(Decimal('-10'), Decimal('3')) - Decimal("-10") + Decimal('-10') >>> ExtendedContext.min(Decimal('1.0'), Decimal('1')) - Decimal("1.0") + Decimal('1.0') >>> ExtendedContext.min(Decimal('7'), Decimal('NaN')) - Decimal("7") + Decimal('7') """ return a.min(b, context=self) @@ -4218,9 +4218,9 @@ has the same exponent as the operand. >>> ExtendedContext.minus(Decimal('1.3')) - Decimal("-1.3") + Decimal('-1.3') >>> ExtendedContext.minus(Decimal('-1.3')) - Decimal("1.3") + Decimal('1.3') """ return a.__neg__(context=self) @@ -4233,15 +4233,15 @@ of the two operands. >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3')) - Decimal("3.60") + Decimal('3.60') >>> ExtendedContext.multiply(Decimal('7'), Decimal('3')) - Decimal("21") + Decimal('21') >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8')) - Decimal("0.72") + Decimal('0.72') >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0')) - Decimal("-0.0") + Decimal('-0.0') >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321')) - Decimal("4.28135971E+11") + Decimal('4.28135971E+11') """ return a.__mul__(b, context=self) @@ -4252,13 +4252,13 @@ >>> c.Emin = -999 >>> c.Emax = 999 >>> ExtendedContext.next_minus(Decimal('1')) - Decimal("0.999999999") + Decimal('0.999999999') >>> c.next_minus(Decimal('1E-1007')) - Decimal("0E-1007") + Decimal('0E-1007') >>> ExtendedContext.next_minus(Decimal('-1.00000003')) - Decimal("-1.00000004") + Decimal('-1.00000004') >>> c.next_minus(Decimal('Infinity')) - Decimal("9.99999999E+999") + Decimal('9.99999999E+999') """ return a.next_minus(context=self) @@ -4269,13 +4269,13 @@ >>> c.Emin = -999 >>> c.Emax = 999 >>> ExtendedContext.next_plus(Decimal('1')) - Decimal("1.00000001") + Decimal('1.00000001') >>> c.next_plus(Decimal('-1E-1007')) - Decimal("-0E-1007") + Decimal('-0E-1007') >>> ExtendedContext.next_plus(Decimal('-1.00000003')) - Decimal("-1.00000002") + Decimal('-1.00000002') >>> c.next_plus(Decimal('-Infinity')) - Decimal("-9.99999999E+999") + Decimal('-9.99999999E+999') """ return a.next_plus(context=self) @@ -4291,19 +4291,19 @@ >>> c.Emin = -999 >>> c.Emax = 999 >>> c.next_toward(Decimal('1'), Decimal('2')) - Decimal("1.00000001") + Decimal('1.00000001') >>> c.next_toward(Decimal('-1E-1007'), Decimal('1')) - Decimal("-0E-1007") + Decimal('-0E-1007') >>> c.next_toward(Decimal('-1.00000003'), Decimal('0')) - Decimal("-1.00000002") + Decimal('-1.00000002') >>> c.next_toward(Decimal('1'), Decimal('0')) - Decimal("0.999999999") + Decimal('0.999999999') >>> c.next_toward(Decimal('1E-1007'), Decimal('-100')) - Decimal("0E-1007") + Decimal('0E-1007') >>> c.next_toward(Decimal('-1.00000003'), Decimal('-10')) - Decimal("-1.00000004") + Decimal('-1.00000004') >>> c.next_toward(Decimal('0.00'), Decimal('-0.0000')) - Decimal("-0.00") + Decimal('-0.00') """ return a.next_toward(b, context=self) @@ -4314,17 +4314,17 @@ result. >>> ExtendedContext.normalize(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.normalize(Decimal('-2.0')) - Decimal("-2") + Decimal('-2') >>> ExtendedContext.normalize(Decimal('1.200')) - Decimal("1.2") + Decimal('1.2') >>> ExtendedContext.normalize(Decimal('-120')) - Decimal("-1.2E+2") + Decimal('-1.2E+2') >>> ExtendedContext.normalize(Decimal('120.00')) - Decimal("1.2E+2") + Decimal('1.2E+2') >>> ExtendedContext.normalize(Decimal('0.00')) - Decimal("0") + Decimal('0') """ return a.normalize(context=self) @@ -4383,9 +4383,9 @@ has the same exponent as the operand. >>> ExtendedContext.plus(Decimal('1.3')) - Decimal("1.3") + Decimal('1.3') >>> ExtendedContext.plus(Decimal('-1.3')) - Decimal("-1.3") + Decimal('-1.3') """ return a.__pos__(context=self) @@ -4415,46 +4415,46 @@ >>> c.Emin = -999 >>> c.Emax = 999 >>> c.power(Decimal('2'), Decimal('3')) - Decimal("8") + Decimal('8') >>> c.power(Decimal('-2'), Decimal('3')) - Decimal("-8") + Decimal('-8') >>> c.power(Decimal('2'), Decimal('-3')) - Decimal("0.125") + Decimal('0.125') >>> c.power(Decimal('1.7'), Decimal('8')) - Decimal("69.7575744") + Decimal('69.7575744') >>> c.power(Decimal('10'), Decimal('0.301029996')) - Decimal("2.00000000") + Decimal('2.00000000') >>> c.power(Decimal('Infinity'), Decimal('-1')) - Decimal("0") + Decimal('0') >>> c.power(Decimal('Infinity'), Decimal('0')) - Decimal("1") + Decimal('1') >>> c.power(Decimal('Infinity'), Decimal('1')) - Decimal("Infinity") + Decimal('Infinity') >>> c.power(Decimal('-Infinity'), Decimal('-1')) - Decimal("-0") + Decimal('-0') >>> c.power(Decimal('-Infinity'), Decimal('0')) - Decimal("1") + Decimal('1') >>> c.power(Decimal('-Infinity'), Decimal('1')) - Decimal("-Infinity") + Decimal('-Infinity') >>> c.power(Decimal('-Infinity'), Decimal('2')) - Decimal("Infinity") + Decimal('Infinity') >>> c.power(Decimal('0'), Decimal('0')) - Decimal("NaN") + Decimal('NaN') >>> c.power(Decimal('3'), Decimal('7'), Decimal('16')) - Decimal("11") + Decimal('11') >>> c.power(Decimal('-3'), Decimal('7'), Decimal('16')) - Decimal("-11") + Decimal('-11') >>> c.power(Decimal('-3'), Decimal('8'), Decimal('16')) - Decimal("1") + Decimal('1') >>> c.power(Decimal('3'), Decimal('7'), Decimal('-16')) - Decimal("11") + Decimal('11') >>> c.power(Decimal('23E12345'), Decimal('67E189'), Decimal('123456789')) - Decimal("11729830") + Decimal('11729830') >>> c.power(Decimal('-0'), Decimal('17'), Decimal('1729')) - Decimal("-0") + Decimal('-0') >>> c.power(Decimal('-23'), Decimal('0'), Decimal('65537')) - Decimal("1") + Decimal('1') """ return a.__pow__(b, modulo, context=self) @@ -4477,35 +4477,35 @@ if the result is subnormal and inexact. >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001')) - Decimal("2.170") + Decimal('2.170') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01')) - Decimal("2.17") + Decimal('2.17') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1')) - Decimal("2.2") + Decimal('2.2') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0')) - Decimal("2") + Decimal('2') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1')) - Decimal("0E+1") + Decimal('0E+1') >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity')) - Decimal("-Infinity") + Decimal('-Infinity') >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity')) - Decimal("NaN") + Decimal('NaN') >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1')) - Decimal("-0") + Decimal('-0') >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5')) - Decimal("-0E+5") + Decimal('-0E+5') >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) - Decimal("NaN") + Decimal('NaN') >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) - Decimal("NaN") + Decimal('NaN') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1')) - Decimal("217.0") + Decimal('217.0') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0')) - Decimal("217") + Decimal('217') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1')) - Decimal("2.2E+2") + Decimal('2.2E+2') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2')) - Decimal("2E+2") + Decimal('2E+2') """ return a.quantize(b, context=self) @@ -4513,7 +4513,7 @@ """Just returns 10, as this is Decimal, :) >>> ExtendedContext.radix() - Decimal("10") + Decimal('10') """ return Decimal(10) @@ -4530,17 +4530,17 @@ remainder cannot be calculated). >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.remainder(Decimal('10'), Decimal('3')) - Decimal("1") + Decimal('1') >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1')) - Decimal("0.2") + Decimal('0.2') >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3')) - Decimal("0.1") + Decimal('0.1') >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3')) - Decimal("1.0") + Decimal('1.0') """ return a.__mod__(b, context=self) @@ -4555,19 +4555,19 @@ remainder cannot be calculated). >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) - Decimal("-0.9") + Decimal('-0.9') >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6')) - Decimal("-2") + Decimal('-2') >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3')) - Decimal("1") + Decimal('1') >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1')) - Decimal("0.2") + Decimal('0.2') >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3')) - Decimal("0.1") + Decimal('0.1') >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3')) - Decimal("-0.3") + Decimal('-0.3') """ return a.remainder_near(b, context=self) @@ -4581,15 +4581,15 @@ positive or to the right otherwise. >>> ExtendedContext.rotate(Decimal('34'), Decimal('8')) - Decimal("400000003") + Decimal('400000003') >>> ExtendedContext.rotate(Decimal('12'), Decimal('9')) - Decimal("12") + Decimal('12') >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('-2')) - Decimal("891234567") + Decimal('891234567') >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('0')) - Decimal("123456789") + Decimal('123456789') >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('+2')) - Decimal("345678912") + Decimal('345678912') """ return a.rotate(b, context=self) @@ -4614,11 +4614,11 @@ """Returns the first operand after adding the second value its exp. >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2')) - Decimal("0.0750") + Decimal('0.0750') >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0')) - Decimal("7.50") + Decimal('7.50') >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3')) - Decimal("7.50E+3") + Decimal('7.50E+3') """ return a.scaleb (b, context=self) @@ -4633,15 +4633,15 @@ coefficient are zeros. >>> ExtendedContext.shift(Decimal('34'), Decimal('8')) - Decimal("400000000") + Decimal('400000000') >>> ExtendedContext.shift(Decimal('12'), Decimal('9')) - Decimal("0") + Decimal('0') >>> ExtendedContext.shift(Decimal('123456789'), Decimal('-2')) - Decimal("1234567") + Decimal('1234567') >>> ExtendedContext.shift(Decimal('123456789'), Decimal('0')) - Decimal("123456789") + Decimal('123456789') >>> ExtendedContext.shift(Decimal('123456789'), Decimal('+2')) - Decimal("345678900") + Decimal('345678900') """ return a.shift(b, context=self) @@ -4652,23 +4652,23 @@ algorithm. >>> ExtendedContext.sqrt(Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.sqrt(Decimal('-0')) - Decimal("-0") + Decimal('-0') >>> ExtendedContext.sqrt(Decimal('0.39')) - Decimal("0.624499800") + Decimal('0.624499800') >>> ExtendedContext.sqrt(Decimal('100')) - Decimal("10") + Decimal('10') >>> ExtendedContext.sqrt(Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.sqrt(Decimal('1.0')) - Decimal("1.0") + Decimal('1.0') >>> ExtendedContext.sqrt(Decimal('1.00')) - Decimal("1.0") + Decimal('1.0') >>> ExtendedContext.sqrt(Decimal('7')) - Decimal("2.64575131") + Decimal('2.64575131') >>> ExtendedContext.sqrt(Decimal('10')) - Decimal("3.16227766") + Decimal('3.16227766') >>> ExtendedContext.prec 9 """ @@ -4678,11 +4678,11 @@ """Return the difference between the two operands. >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07')) - Decimal("0.23") + Decimal('0.23') >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30')) - Decimal("0.00") + Decimal('0.00') >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07')) - Decimal("-0.77") + Decimal('-0.77') """ return a.__sub__(b, context=self) @@ -4711,21 +4711,21 @@ context. >>> ExtendedContext.to_integral_exact(Decimal('2.1')) - Decimal("2") + Decimal('2') >>> ExtendedContext.to_integral_exact(Decimal('100')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_exact(Decimal('100.0')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_exact(Decimal('101.5')) - Decimal("102") + Decimal('102') >>> ExtendedContext.to_integral_exact(Decimal('-101.5')) - Decimal("-102") + Decimal('-102') >>> ExtendedContext.to_integral_exact(Decimal('10E+5')) - Decimal("1.0E+6") + Decimal('1.0E+6') >>> ExtendedContext.to_integral_exact(Decimal('7.89E+77')) - Decimal("7.89E+77") + Decimal('7.89E+77') >>> ExtendedContext.to_integral_exact(Decimal('-Inf')) - Decimal("-Infinity") + Decimal('-Infinity') """ return a.to_integral_exact(context=self) @@ -4739,21 +4739,21 @@ be set. The rounding mode is taken from the context. >>> ExtendedContext.to_integral_value(Decimal('2.1')) - Decimal("2") + Decimal('2') >>> ExtendedContext.to_integral_value(Decimal('100')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_value(Decimal('100.0')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_value(Decimal('101.5')) - Decimal("102") + Decimal('102') >>> ExtendedContext.to_integral_value(Decimal('-101.5')) - Decimal("-102") + Decimal('-102') >>> ExtendedContext.to_integral_value(Decimal('10E+5')) - Decimal("1.0E+6") + Decimal('1.0E+6') >>> ExtendedContext.to_integral_value(Decimal('7.89E+77')) - Decimal("7.89E+77") + Decimal('7.89E+77') >>> ExtendedContext.to_integral_value(Decimal('-Inf')) - Decimal("-Infinity") + Decimal('-Infinity') """ return a.to_integral_value(context=self) Modified: python/branches/py3k/Lib/fractions.py ============================================================================== --- python/branches/py3k/Lib/fractions.py (original) +++ python/branches/py3k/Lib/fractions.py Thu Feb 14 09:27:37 2008 @@ -62,7 +62,7 @@ """ self = super(Fraction, cls).__new__(cls) - if denominator == 1: + if not isinstance(numerator, int) and denominator == 1: if isinstance(numerator, str): # Handle construction from strings. input = numerator @@ -84,24 +84,22 @@ if m.group('sign') == '-': numerator = -numerator - elif (not isinstance(numerator, numbers.Integral) and - isinstance(numerator, numbers.Rational)): - # Handle copies from other rationals. + elif isinstance(numerator, numbers.Rational): + # Handle copies from other rationals. Integrals get + # caught here too, but it doesn't matter because + # denominator is already 1. other_rational = numerator numerator = other_rational.numerator denominator = other_rational.denominator - if (not isinstance(numerator, numbers.Integral) or - not isinstance(denominator, numbers.Integral)): - raise TypeError("Fraction(%(numerator)s, %(denominator)s):" - " Both arguments must be integral." % locals()) - if denominator == 0: raise ZeroDivisionError('Fraction(%s, 0)' % numerator) + numerator = numerator.__index__() + denominator = denominator.__index__() g = gcd(numerator, denominator) - self._numerator = int(numerator // g) - self._denominator = int(denominator // g) + self._numerator = numerator // g + self._denominator = denominator // g return self @classmethod @@ -138,42 +136,60 @@ else: return cls(digits, 10 ** -exp) - @classmethod - def from_continued_fraction(cls, seq): - 'Build a Fraction from a continued fraction expessed as a sequence' - n, d = 1, 0 - for e in reversed(seq): - n, d = d, n - n += e * d - return cls(n, d) if seq else cls(0) - - def as_continued_fraction(self): - 'Return continued fraction expressed as a list' - n = self.numerator - d = self.denominator - cf = [] - while d: - e = int(n // d) - cf.append(e) - n -= e * d - n, d = d, n - return cf - - def approximate(self, max_denominator): - 'Best rational approximation with a denominator <= max_denominator' - # XXX First cut at algorithm - # Still needs rounding rules as specified at - # http://en.wikipedia.org/wiki/Continued_fraction - if self.denominator <= max_denominator: - return self - cf = self.as_continued_fraction() - result = Fraction(0) - for i in range(1, len(cf)): - new = self.from_continued_fraction(cf[:i]) - if new.denominator > max_denominator: + def limit_denominator(self, max_denominator=1000000): + """Closest Fraction to self with denominator at most max_denominator. + + >>> Fraction('3.141592653589793').limit_denominator(10) + Fraction(22, 7) + >>> Fraction('3.141592653589793').limit_denominator(100) + Fraction(311, 99) + >>> Fraction(1234, 5678).limit_denominator(10000) + Fraction(1234, 5678) + + """ + # Algorithm notes: For any real number x, define a *best upper + # approximation* to x to be a rational number p/q such that: + # + # (1) p/q >= x, and + # (2) if p/q > r/s >= x then s > q, for any rational r/s. + # + # Define *best lower approximation* similarly. Then it can be + # proved that a rational number is a best upper or lower + # approximation to x if, and only if, it is a convergent or + # semiconvergent of the (unique shortest) continued fraction + # associated to x. + # + # To find a best rational approximation with denominator <= M, + # we find the best upper and lower approximations with + # denominator <= M and take whichever of these is closer to x. + # In the event of a tie, the bound with smaller denominator is + # chosen. If both denominators are equal (which can happen + # only when max_denominator == 1 and self is midway between + # two integers) the lower bound---i.e., the floor of self, is + # taken. + + if max_denominator < 1: + raise ValueError("max_denominator should be at least 1") + if self._denominator <= max_denominator: + return Fraction(self) + + p0, q0, p1, q1 = 0, 1, 1, 0 + n, d = self._numerator, self._denominator + while True: + a = n//d + q2 = q0+a*q1 + if q2 > max_denominator: break - result = new - return result + p0, q0, p1, q1 = p1, q1, p0+a*p1, q2 + n, d = d, n-a*d + + k = (max_denominator-q0)//q1 + bound1 = Fraction(p0+k*p1, q0+k*q1) + bound2 = Fraction(p1, q1) + if abs(bound2 - self) <= abs(bound1-self): + return bound2 + else: + return bound1 @property def numerator(a): @@ -185,14 +201,14 @@ def __repr__(self): """repr(self)""" - return ('Fraction(%r,%r)' % (self.numerator, self.denominator)) + return ('Fraction(%r, %r)' % (self._numerator, self._denominator)) def __str__(self): """str(self)""" - if self.denominator == 1: - return str(self.numerator) + if self._denominator == 1: + return str(self._numerator) else: - return '%s/%s' % (self.numerator, self.denominator) + return '%s/%s' % (self._numerator, self._denominator) def _operator_fallbacks(monomorphic_operator, fallback_operator): """Generates forward and reverse operators given a purely-rational @@ -360,11 +376,11 @@ if b.denominator == 1: power = b.numerator if power >= 0: - return Fraction(a.numerator ** power, - a.denominator ** power) + return Fraction(a._numerator ** power, + a._denominator ** power) else: - return Fraction(a.denominator ** -power, - a.numerator ** -power) + return Fraction(a._denominator ** -power, + a._numerator ** -power) else: # A fractional power will generally produce an # irrational number. @@ -374,36 +390,36 @@ def __rpow__(b, a): """a ** b""" - if b.denominator == 1 and b.numerator >= 0: + if b._denominator == 1 and b._numerator >= 0: # If a is an int, keep it that way if possible. - return a ** b.numerator + return a ** b._numerator if isinstance(a, numbers.Rational): return Fraction(a.numerator, a.denominator) ** b - if b.denominator == 1: - return a ** b.numerator + if b._denominator == 1: + return a ** b._numerator return a ** float(b) def __pos__(a): """+a: Coerces a subclass instance to Fraction""" - return Fraction(a.numerator, a.denominator) + return Fraction(a._numerator, a._denominator) def __neg__(a): """-a""" - return Fraction(-a.numerator, a.denominator) + return Fraction(-a._numerator, a._denominator) def __abs__(a): """abs(a)""" - return Fraction(abs(a.numerator), a.denominator) + return Fraction(abs(a._numerator), a._denominator) def __trunc__(a): """trunc(a)""" - if a.numerator < 0: - return -(-a.numerator // a.denominator) + if a._numerator < 0: + return -(-a._numerator // a._denominator) else: - return a.numerator // a.denominator + return a._numerator // a._denominator def __floor__(a): """Will be math.floor(a) in 3.0.""" @@ -447,22 +463,22 @@ """ # XXX since this method is expensive, consider caching the result - if self.denominator == 1: + if self._denominator == 1: # Get integers right. - return hash(self.numerator) + return hash(self._numerator) # Expensive check, but definitely correct. if self == float(self): return hash(float(self)) else: # Use tuple's hash to avoid a high collision rate on # simple fractions. - return hash((self.numerator, self.denominator)) + return hash((self._numerator, self._denominator)) def __eq__(a, b): """a == b""" if isinstance(b, numbers.Rational): - return (a.numerator == b.numerator and - a.denominator == b.denominator) + return (a._numerator == b.numerator and + a._denominator == b.denominator) if isinstance(b, numbers.Complex) and b.imag == 0: b = b.real if isinstance(b, float): @@ -517,7 +533,7 @@ def __bool__(a): """a != 0""" - return a.numerator != 0 + return a._numerator != 0 # support for pickling, copy, and deepcopy @@ -527,9 +543,9 @@ def __copy__(self): if type(self) == Fraction: return self # I'm immutable; therefore I am my own clone - return self.__class__(self.numerator, self.denominator) + return self.__class__(self._numerator, self._denominator) def __deepcopy__(self, memo): if type(self) == Fraction: return self # My components are also immutable - return self.__class__(self.numerator, self.denominator) + return self.__class__(self._numerator, self._denominator) Modified: python/branches/py3k/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/py3k/Lib/idlelib/NEWS.txt (original) +++ python/branches/py3k/Lib/idlelib/NEWS.txt Thu Feb 14 09:27:37 2008 @@ -70,6 +70,13 @@ - Clean up EditorWindow close. +- Patch 1693258: Fix for duplicate "preferences" menu-OS X. Backport of r56204. + +- OSX: Avoid crash for those versions of Tcl/Tk which don't have a console + +- Bug in idlelib.MultiCall: Options dialog was crashing IDLE if there was an + option in config-extensions w/o a value. Patch #1672481, Tal Einat + - Corrected some bugs in AutoComplete. Also, Page Up/Down in ACW implemented; mouse and cursor selection in ACWindow implemented; double Tab inserts current selection and closes ACW (similar to double-click and Return); scroll Modified: python/branches/py3k/Lib/numbers.py ============================================================================== --- python/branches/py3k/Lib/numbers.py (original) +++ python/branches/py3k/Lib/numbers.py Thu Feb 14 09:27:37 2008 @@ -46,9 +46,11 @@ # Inexact.register(decimal.Decimal) -## Notes on Decimal and it how relates to the numeric tower -## -------------------------------------------------------- -## Decimal is Real except that it does not support rich comparisons. +## Notes on Decimal +## ---------------- +## Decimal has all of the methods specified by the Real abc, but it should +## not be registered as a Real because decimals do not interoperate with +## binary floats. ## ## Decimal has some of the characteristics of Integrals. It provides ## logical operations but not as operators. The logical operations only apply @@ -304,7 +306,6 @@ return +self Real.register(float) -# Real.register(decimal.Decimal) class Rational(Real, Exact): Modified: python/branches/py3k/Lib/test/test_abc.py ============================================================================== --- python/branches/py3k/Lib/test/test_abc.py (original) +++ python/branches/py3k/Lib/test/test_abc.py Thu Feb 14 09:27:37 2008 @@ -81,6 +81,16 @@ self.assertEqual(issubclass(C, A), True) self.assertEqual(isinstance(c, A), True) + def test_isinstance_invalidation(self): + class A(metaclass=abc.ABCMeta): + pass + class B: + pass + b = B() + self.assertEqual(isinstance(b, A), False) + A.register(B) + self.assertEqual(isinstance(b, A), True) + def test_registration_builtins(self): class A(metaclass=abc.ABCMeta): pass Modified: python/branches/py3k/Lib/test/test_decimal.py ============================================================================== --- python/branches/py3k/Lib/test/test_decimal.py (original) +++ python/branches/py3k/Lib/test/test_decimal.py Thu Feb 14 09:27:37 2008 @@ -1040,7 +1040,7 @@ d = Decimal('15.32') self.assertEqual(str(d), '15.32') # str - self.assertEqual(repr(d), 'Decimal("15.32")') # repr + self.assertEqual(repr(d), "Decimal('15.32')") # repr def test_tonum_methods(self): #Test float, int and long methods. Modified: python/branches/py3k/Lib/test/test_fractions.py ============================================================================== --- python/branches/py3k/Lib/test/test_fractions.py (original) +++ python/branches/py3k/Lib/test/test_fractions.py Thu Feb 14 09:27:37 2008 @@ -8,7 +8,7 @@ import unittest from copy import copy, deepcopy from pickle import dumps, loads -R = fractions.Fraction +F = fractions.Fraction gcd = fractions.gcd @@ -49,77 +49,76 @@ self.fail("%s not raised" % exc_type.__name__) def testInit(self): - self.assertEquals((0, 1), _components(R())) - self.assertEquals((7, 1), _components(R(7))) - self.assertEquals((7, 3), _components(R(R(7, 3)))) - - self.assertEquals((-1, 1), _components(R(-1, 1))) - self.assertEquals((-1, 1), _components(R(1, -1))) - self.assertEquals((1, 1), _components(R(-2, -2))) - self.assertEquals((1, 2), _components(R(5, 10))) - self.assertEquals((7, 15), _components(R(7, 15))) - self.assertEquals((10**23, 1), _components(R(10**23))) + self.assertEquals((0, 1), _components(F())) + self.assertEquals((7, 1), _components(F(7))) + self.assertEquals((7, 3), _components(F(F(7, 3)))) + + self.assertEquals((-1, 1), _components(F(-1, 1))) + self.assertEquals((-1, 1), _components(F(1, -1))) + self.assertEquals((1, 1), _components(F(-2, -2))) + self.assertEquals((1, 2), _components(F(5, 10))) + self.assertEquals((7, 15), _components(F(7, 15))) + self.assertEquals((10**23, 1), _components(F(10**23))) self.assertRaisesMessage(ZeroDivisionError, "Fraction(12, 0)", - R, 12, 0) - self.assertRaises(TypeError, R, 1.5) - self.assertRaises(TypeError, R, 1.5 + 3j) + F, 12, 0) + self.assertRaises(AttributeError, F, 1.5) + self.assertRaises(AttributeError, F, 1.5 + 3j) - self.assertRaises(TypeError, R, R(1, 2), 3) - self.assertRaises(TypeError, R, "3/2", 3) + self.assertRaises(AttributeError, F, F(1, 2), 3) + self.assertRaises(AttributeError, F, "3/2", 3) def testFromString(self): - self.assertEquals((5, 1), _components(R("5"))) - self.assertEquals((3, 2), _components(R("3/2"))) - self.assertEquals((3, 2), _components(R(" \n +3/2"))) - self.assertEquals((-3, 2), _components(R("-3/2 "))) - self.assertEquals((3, 2), _components(R(" 03/02 \n "))) - self.assertEquals((3, 2), _components(R(" 03/02 \n "))) - self.assertEquals((16, 5), _components(R(" 3.2 "))) - self.assertEquals((-16, 5), _components(R(" -3.2 "))) - self.assertEquals((-3, 1), _components(R(" -3. "))) - self.assertEquals((3, 5), _components(R(" .6 "))) + self.assertEquals((5, 1), _components(F("5"))) + self.assertEquals((3, 2), _components(F("3/2"))) + self.assertEquals((3, 2), _components(F(" \n +3/2"))) + self.assertEquals((-3, 2), _components(F("-3/2 "))) + self.assertEquals((13, 2), _components(F(" 013/02 \n "))) + self.assertEquals((16, 5), _components(F(" 3.2 "))) + self.assertEquals((-16, 5), _components(F(" -3.2 "))) + self.assertEquals((-3, 1), _components(F(" -3. "))) + self.assertEquals((3, 5), _components(F(" .6 "))) self.assertRaisesMessage( ZeroDivisionError, "Fraction(3, 0)", - R, "3/0") + F, "3/0") self.assertRaisesMessage( ValueError, "Invalid literal for Fraction: 3/", - R, "3/") + F, "3/") self.assertRaisesMessage( ValueError, "Invalid literal for Fraction: 3 /2", - R, "3 /2") + F, "3 /2") self.assertRaisesMessage( # Denominators don't need a sign. ValueError, "Invalid literal for Fraction: 3/+2", - R, "3/+2") + F, "3/+2") self.assertRaisesMessage( # Imitate float's parsing. ValueError, "Invalid literal for Fraction: + 3/2", - R, "+ 3/2") + F, "+ 3/2") self.assertRaisesMessage( # Avoid treating '.' as a regex special character. ValueError, "Invalid literal for Fraction: 3a2", - R, "3a2") + F, "3a2") self.assertRaisesMessage( # Only parse ordinary decimals, not scientific form. ValueError, "Invalid literal for Fraction: 3.2e4", - R, "3.2e4") + F, "3.2e4") self.assertRaisesMessage( # Don't accept combinations of decimals and rationals. ValueError, "Invalid literal for Fraction: 3/7.2", - R, "3/7.2") + F, "3/7.2") self.assertRaisesMessage( # Don't accept combinations of decimals and rationals. ValueError, "Invalid literal for Fraction: 3.2/7", - R, "3.2/7") + F, "3.2/7") self.assertRaisesMessage( # Allow 3. and .3, but not . ValueError, "Invalid literal for Fraction: .", - R, ".") + F, ".") def testImmutable(self): - r = R(7, 3) + r = F(7, 3) r.__init__(2, 15) self.assertEquals((7, 3), _components(r)) @@ -132,267 +131,253 @@ r._denominator = 2 self.assertEquals((4, 2), _components(r)) # Which breaks some important operations: - self.assertNotEquals(R(4, 2), r) + self.assertNotEquals(F(4, 2), r) def testFromFloat(self): self.assertRaisesMessage( TypeError, "Fraction.from_float() only takes floats, not 3 (int)", - R.from_float, 3) + F.from_float, 3) - self.assertEquals((0, 1), _components(R.from_float(-0.0))) - self.assertEquals((10, 1), _components(R.from_float(10.0))) - self.assertEquals((-5, 2), _components(R.from_float(-2.5))) + self.assertEquals((0, 1), _components(F.from_float(-0.0))) + self.assertEquals((10, 1), _components(F.from_float(10.0))) + self.assertEquals((-5, 2), _components(F.from_float(-2.5))) self.assertEquals((99999999999999991611392, 1), - _components(R.from_float(1e23))) - self.assertEquals(float(10**23), float(R.from_float(1e23))) + _components(F.from_float(1e23))) + self.assertEquals(float(10**23), float(F.from_float(1e23))) self.assertEquals((3602879701896397, 1125899906842624), - _components(R.from_float(3.2))) - self.assertEquals(3.2, float(R.from_float(3.2))) + _components(F.from_float(3.2))) + self.assertEquals(3.2, float(F.from_float(3.2))) inf = 1e1000 nan = inf - inf self.assertRaisesMessage( TypeError, "Cannot convert inf to Fraction.", - R.from_float, inf) + F.from_float, inf) self.assertRaisesMessage( TypeError, "Cannot convert -inf to Fraction.", - R.from_float, -inf) + F.from_float, -inf) self.assertRaisesMessage( TypeError, "Cannot convert nan to Fraction.", - R.from_float, nan) + F.from_float, nan) def testFromDecimal(self): self.assertRaisesMessage( TypeError, "Fraction.from_decimal() only takes Decimals, not 3 (int)", - R.from_decimal, 3) - self.assertEquals(R(0), R.from_decimal(Decimal("-0"))) - self.assertEquals(R(5, 10), R.from_decimal(Decimal("0.5"))) - self.assertEquals(R(5, 1000), R.from_decimal(Decimal("5e-3"))) - self.assertEquals(R(5000), R.from_decimal(Decimal("5e3"))) - self.assertEquals(1 - R(1, 10**30), - R.from_decimal(Decimal("0." + "9" * 30))) + F.from_decimal, 3) + self.assertEquals(F(0), F.from_decimal(Decimal("-0"))) + self.assertEquals(F(5, 10), F.from_decimal(Decimal("0.5"))) + self.assertEquals(F(5, 1000), F.from_decimal(Decimal("5e-3"))) + self.assertEquals(F(5000), F.from_decimal(Decimal("5e3"))) + self.assertEquals(1 - F(1, 10**30), + F.from_decimal(Decimal("0." + "9" * 30))) self.assertRaisesMessage( TypeError, "Cannot convert Infinity to Fraction.", - R.from_decimal, Decimal("inf")) + F.from_decimal, Decimal("inf")) self.assertRaisesMessage( TypeError, "Cannot convert -Infinity to Fraction.", - R.from_decimal, Decimal("-inf")) + F.from_decimal, Decimal("-inf")) self.assertRaisesMessage( TypeError, "Cannot convert NaN to Fraction.", - R.from_decimal, Decimal("nan")) + F.from_decimal, Decimal("nan")) self.assertRaisesMessage( TypeError, "Cannot convert sNaN to Fraction.", - R.from_decimal, Decimal("snan")) + F.from_decimal, Decimal("snan")) - def testFromContinuedFraction(self): - self.assertRaises(TypeError, R.from_continued_fraction, None) - phi = R.from_continued_fraction([1]*100) - self.assertEquals(round(phi - (1 + 5 ** 0.5) / 2, 10), 0.0) - - minusphi = R.from_continued_fraction([-1]*100) - self.assertEquals(round(minusphi + (1 + 5 ** 0.5) / 2, 10), 0.0) - - self.assertEquals(R.from_continued_fraction([0]), R(0)) - self.assertEquals(R.from_continued_fraction([]), R(0)) - - def testAsContinuedFraction(self): - self.assertEqual(R.from_float(math.pi).as_continued_fraction()[:15], - [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3, 3]) - self.assertEqual(R.from_float(-math.pi).as_continued_fraction()[:16], - [-4, 1, 6, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3, 3]) - self.assertEqual(R(0).as_continued_fraction(), [0]) - - def testApproximateFrom(self): - self.assertEqual(R.from_float(math.pi).approximate(10000), R(355, 113)) - self.assertEqual(R.from_float(-math.pi).approximate(10000), R(-355, 113)) - self.assertEqual(R.from_float(0.0).approximate(10000), R(0)) + def testLimitDenominator(self): + rpi = F('3.1415926535897932') + self.assertEqual(rpi.limit_denominator(10000), F(355, 113)) + self.assertEqual(-rpi.limit_denominator(10000), F(-355, 113)) + self.assertEqual(rpi.limit_denominator(113), F(355, 113)) + self.assertEqual(rpi.limit_denominator(112), F(333, 106)) + self.assertEqual(F(201, 200).limit_denominator(100), F(1)) + self.assertEqual(F(201, 200).limit_denominator(101), F(102, 101)) + self.assertEqual(F(0).limit_denominator(10000), F(0)) def testConversions(self): - self.assertTypedEquals(-1, math.trunc(R(-11, 10))) - self.assertTypedEquals(-2, math.floor(R(-11, 10))) - self.assertTypedEquals(-1, math.ceil(R(-11, 10))) - self.assertTypedEquals(-1, math.ceil(R(-10, 10))) - self.assertTypedEquals(-1, int(R(-11, 10))) - - self.assertTypedEquals(0, round(R(-1, 10))) - self.assertTypedEquals(0, round(R(-5, 10))) - self.assertTypedEquals(-2, round(R(-15, 10))) - self.assertTypedEquals(-1, round(R(-7, 10))) - - self.assertEquals(False, bool(R(0, 1))) - self.assertEquals(True, bool(R(3, 2))) - self.assertTypedEquals(0.1, float(R(1, 10))) + self.assertTypedEquals(-1, math.trunc(F(-11, 10))) + self.assertTypedEquals(-2, math.floor(F(-11, 10))) + self.assertTypedEquals(-1, math.ceil(F(-11, 10))) + self.assertTypedEquals(-1, math.ceil(F(-10, 10))) + self.assertTypedEquals(-1, int(F(-11, 10))) + self.assertTypedEquals(0, round(F(-1, 10))) + self.assertTypedEquals(0, round(F(-5, 10))) + self.assertTypedEquals(-2, round(F(-15, 10))) + self.assertTypedEquals(-1, round(F(-7, 10))) + + self.assertEquals(False, bool(F(0, 1))) + self.assertEquals(True, bool(F(3, 2))) + self.assertTypedEquals(0.1, float(F(1, 10))) # Check that __float__ isn't implemented by converting the # numerator and denominator to float before dividing. self.assertRaises(OverflowError, float, int('2'*400+'7')) self.assertAlmostEquals(2.0/3, - float(R(int('2'*400+'7'), int('3'*400+'1')))) + float(F(int('2'*400+'7'), int('3'*400+'1')))) - self.assertTypedEquals(0.1+0j, complex(R(1,10))) + self.assertTypedEquals(0.1+0j, complex(F(1,10))) def testRound(self): - self.assertTypedEquals(R(-200), round(R(-150), -2)) - self.assertTypedEquals(R(-200), round(R(-250), -2)) - self.assertTypedEquals(R(30), round(R(26), -1)) - self.assertTypedEquals(R(-2, 10), round(R(-15, 100), 1)) - self.assertTypedEquals(R(-2, 10), round(R(-25, 100), 1)) + self.assertTypedEquals(F(-200), round(F(-150), -2)) + self.assertTypedEquals(F(-200), round(F(-250), -2)) + self.assertTypedEquals(F(30), round(F(26), -1)) + self.assertTypedEquals(F(-2, 10), round(F(-15, 100), 1)) + self.assertTypedEquals(F(-2, 10), round(F(-25, 100), 1)) def testArithmetic(self): - self.assertEquals(R(1, 2), R(1, 10) + R(2, 5)) - self.assertEquals(R(-3, 10), R(1, 10) - R(2, 5)) - self.assertEquals(R(1, 25), R(1, 10) * R(2, 5)) - self.assertEquals(R(1, 4), R(1, 10) / R(2, 5)) - self.assertTypedEquals(2, R(9, 10) // R(2, 5)) - self.assertTypedEquals(10**23, R(10**23, 1) // R(1)) - self.assertEquals(R(2, 3), R(-7, 3) % R(3, 2)) - self.assertEquals(R(8, 27), R(2, 3) ** R(3)) - self.assertEquals(R(27, 8), R(2, 3) ** R(-3)) - self.assertTypedEquals(2.0, R(4) ** R(1, 2)) - z = pow(R(-1), R(1, 2)) + self.assertEquals(F(1, 2), F(1, 10) + F(2, 5)) + self.assertEquals(F(-3, 10), F(1, 10) - F(2, 5)) + self.assertEquals(F(1, 25), F(1, 10) * F(2, 5)) + self.assertEquals(F(1, 4), F(1, 10) / F(2, 5)) + self.assertTypedEquals(2, F(9, 10) // F(2, 5)) + self.assertTypedEquals(10**23, F(10**23, 1) // F(1)) + self.assertEquals(F(2, 3), F(-7, 3) % F(3, 2)) + self.assertEquals(F(8, 27), F(2, 3) ** F(3)) + self.assertEquals(F(27, 8), F(2, 3) ** F(-3)) + self.assertTypedEquals(2.0, F(4) ** F(1, 2)) + z = pow(F(-1), F(1, 2)) self.assertAlmostEquals(z.real, 0) self.assertEquals(z.imag, 1) def testMixedArithmetic(self): - self.assertTypedEquals(R(11, 10), R(1, 10) + 1) - self.assertTypedEquals(1.1, R(1, 10) + 1.0) - self.assertTypedEquals(1.1 + 0j, R(1, 10) + (1.0 + 0j)) - self.assertTypedEquals(R(11, 10), 1 + R(1, 10)) - self.assertTypedEquals(1.1, 1.0 + R(1, 10)) - self.assertTypedEquals(1.1 + 0j, (1.0 + 0j) + R(1, 10)) - - self.assertTypedEquals(R(-9, 10), R(1, 10) - 1) - self.assertTypedEquals(-0.9, R(1, 10) - 1.0) - self.assertTypedEquals(-0.9 + 0j, R(1, 10) - (1.0 + 0j)) - self.assertTypedEquals(R(9, 10), 1 - R(1, 10)) - self.assertTypedEquals(0.9, 1.0 - R(1, 10)) - self.assertTypedEquals(0.9 + 0j, (1.0 + 0j) - R(1, 10)) - - self.assertTypedEquals(R(1, 10), R(1, 10) * 1) - self.assertTypedEquals(0.1, R(1, 10) * 1.0) - self.assertTypedEquals(0.1 + 0j, R(1, 10) * (1.0 + 0j)) - self.assertTypedEquals(R(1, 10), 1 * R(1, 10)) - self.assertTypedEquals(0.1, 1.0 * R(1, 10)) - self.assertTypedEquals(0.1 + 0j, (1.0 + 0j) * R(1, 10)) - - self.assertTypedEquals(R(1, 10), R(1, 10) / 1) - self.assertTypedEquals(0.1, R(1, 10) / 1.0) - self.assertTypedEquals(0.1 + 0j, R(1, 10) / (1.0 + 0j)) - self.assertTypedEquals(R(10, 1), 1 / R(1, 10)) - self.assertTypedEquals(10.0, 1.0 / R(1, 10)) - self.assertTypedEquals(10.0 + 0j, (1.0 + 0j) / R(1, 10)) - - self.assertTypedEquals(0, R(1, 10) // 1) - self.assertTypedEquals(0, R(1, 10) // 1.0) - self.assertTypedEquals(10, 1 // R(1, 10)) - self.assertTypedEquals(10**23, 10**22 // R(1, 10)) - self.assertTypedEquals(10, 1.0 // R(1, 10)) - - self.assertTypedEquals(R(1, 10), R(1, 10) % 1) - self.assertTypedEquals(0.1, R(1, 10) % 1.0) - self.assertTypedEquals(R(0, 1), 1 % R(1, 10)) - self.assertTypedEquals(0.0, 1.0 % R(1, 10)) + self.assertTypedEquals(F(11, 10), F(1, 10) + 1) + self.assertTypedEquals(1.1, F(1, 10) + 1.0) + self.assertTypedEquals(1.1 + 0j, F(1, 10) + (1.0 + 0j)) + self.assertTypedEquals(F(11, 10), 1 + F(1, 10)) + self.assertTypedEquals(1.1, 1.0 + F(1, 10)) + self.assertTypedEquals(1.1 + 0j, (1.0 + 0j) + F(1, 10)) + + self.assertTypedEquals(F(-9, 10), F(1, 10) - 1) + self.assertTypedEquals(-0.9, F(1, 10) - 1.0) + self.assertTypedEquals(-0.9 + 0j, F(1, 10) - (1.0 + 0j)) + self.assertTypedEquals(F(9, 10), 1 - F(1, 10)) + self.assertTypedEquals(0.9, 1.0 - F(1, 10)) + self.assertTypedEquals(0.9 + 0j, (1.0 + 0j) - F(1, 10)) + + self.assertTypedEquals(F(1, 10), F(1, 10) * 1) + self.assertTypedEquals(0.1, F(1, 10) * 1.0) + self.assertTypedEquals(0.1 + 0j, F(1, 10) * (1.0 + 0j)) + self.assertTypedEquals(F(1, 10), 1 * F(1, 10)) + self.assertTypedEquals(0.1, 1.0 * F(1, 10)) + self.assertTypedEquals(0.1 + 0j, (1.0 + 0j) * F(1, 10)) + + self.assertTypedEquals(F(1, 10), F(1, 10) / 1) + self.assertTypedEquals(0.1, F(1, 10) / 1.0) + self.assertTypedEquals(0.1 + 0j, F(1, 10) / (1.0 + 0j)) + self.assertTypedEquals(F(10, 1), 1 / F(1, 10)) + self.assertTypedEquals(10.0, 1.0 / F(1, 10)) + self.assertTypedEquals(10.0 + 0j, (1.0 + 0j) / F(1, 10)) + + self.assertTypedEquals(0, F(1, 10) // 1) + self.assertTypedEquals(0, F(1, 10) // 1.0) + self.assertTypedEquals(10, 1 // F(1, 10)) + self.assertTypedEquals(10**23, 10**22 // F(1, 10)) + self.assertTypedEquals(10, 1.0 // F(1, 10)) + + self.assertTypedEquals(F(1, 10), F(1, 10) % 1) + self.assertTypedEquals(0.1, F(1, 10) % 1.0) + self.assertTypedEquals(F(0, 1), 1 % F(1, 10)) + self.assertTypedEquals(0.0, 1.0 % F(1, 10)) # No need for divmod since we don't override it. # ** has more interesting conversion rules. - self.assertTypedEquals(R(100, 1), R(1, 10) ** -2) - self.assertTypedEquals(R(100, 1), R(10, 1) ** 2) - self.assertTypedEquals(0.1, R(1, 10) ** 1.0) - self.assertTypedEquals(0.1 + 0j, R(1, 10) ** (1.0 + 0j)) - self.assertTypedEquals(4 , 2 ** R(2, 1)) - z = pow(-1, R(1, 2)) + self.assertTypedEquals(F(100, 1), F(1, 10) ** -2) + self.assertTypedEquals(F(100, 1), F(10, 1) ** 2) + self.assertTypedEquals(0.1, F(1, 10) ** 1.0) + self.assertTypedEquals(0.1 + 0j, F(1, 10) ** (1.0 + 0j)) + self.assertTypedEquals(4 , 2 ** F(2, 1)) + z = pow(-1, F(1, 2)) self.assertAlmostEquals(0, z.real) self.assertEquals(1, z.imag) - self.assertTypedEquals(R(1, 4) , 2 ** R(-2, 1)) - self.assertTypedEquals(2.0 , 4 ** R(1, 2)) - self.assertTypedEquals(0.25, 2.0 ** R(-2, 1)) - self.assertTypedEquals(1.0 + 0j, (1.0 + 0j) ** R(1, 10)) + self.assertTypedEquals(F(1, 4) , 2 ** F(-2, 1)) + self.assertTypedEquals(2.0 , 4 ** F(1, 2)) + self.assertTypedEquals(0.25, 2.0 ** F(-2, 1)) + self.assertTypedEquals(1.0 + 0j, (1.0 + 0j) ** F(1, 10)) def testMixingWithDecimal(self): # Decimal refuses mixed comparisons. self.assertRaisesMessage( TypeError, "unsupported operand type(s) for +: 'Fraction' and 'Decimal'", - operator.add, R(3,11), Decimal('3.1415926')) - self.assertNotEquals(R(5, 2), Decimal('2.5')) + operator.add, F(3,11), Decimal('3.1415926')) + self.assertNotEquals(F(5, 2), Decimal('2.5')) def testComparisons(self): - self.assertTrue(R(1, 2) < R(2, 3)) - self.assertFalse(R(1, 2) < R(1, 2)) - self.assertTrue(R(1, 2) <= R(2, 3)) - self.assertTrue(R(1, 2) <= R(1, 2)) - self.assertFalse(R(2, 3) <= R(1, 2)) - self.assertTrue(R(1, 2) == R(1, 2)) - self.assertFalse(R(1, 2) == R(1, 3)) - self.assertFalse(R(1, 2) != R(1, 2)) - self.assertTrue(R(1, 2) != R(1, 3)) + self.assertTrue(F(1, 2) < F(2, 3)) + self.assertFalse(F(1, 2) < F(1, 2)) + self.assertTrue(F(1, 2) <= F(2, 3)) + self.assertTrue(F(1, 2) <= F(1, 2)) + self.assertFalse(F(2, 3) <= F(1, 2)) + self.assertTrue(F(1, 2) == F(1, 2)) + self.assertFalse(F(1, 2) == F(1, 3)) + self.assertFalse(F(1, 2) != F(1, 2)) + self.assertTrue(F(1, 2) != F(1, 3)) def testMixedLess(self): - self.assertTrue(2 < R(5, 2)) - self.assertFalse(2 < R(4, 2)) - self.assertTrue(R(5, 2) < 3) - self.assertFalse(R(4, 2) < 2) - - self.assertTrue(R(1, 2) < 0.6) - self.assertFalse(R(1, 2) < 0.4) - self.assertTrue(0.4 < R(1, 2)) - self.assertFalse(0.5 < R(1, 2)) + self.assertTrue(2 < F(5, 2)) + self.assertFalse(2 < F(4, 2)) + self.assertTrue(F(5, 2) < 3) + self.assertFalse(F(4, 2) < 2) + + self.assertTrue(F(1, 2) < 0.6) + self.assertFalse(F(1, 2) < 0.4) + self.assertTrue(0.4 < F(1, 2)) + self.assertFalse(0.5 < F(1, 2)) def testMixedLessEqual(self): - self.assertTrue(0.5 <= R(1, 2)) - self.assertFalse(0.6 <= R(1, 2)) - self.assertTrue(R(1, 2) <= 0.5) - self.assertFalse(R(1, 2) <= 0.4) - self.assertTrue(2 <= R(4, 2)) - self.assertFalse(2 <= R(3, 2)) - self.assertTrue(R(4, 2) <= 2) - self.assertFalse(R(5, 2) <= 2) + self.assertTrue(0.5 <= F(1, 2)) + self.assertFalse(0.6 <= F(1, 2)) + self.assertTrue(F(1, 2) <= 0.5) + self.assertFalse(F(1, 2) <= 0.4) + self.assertTrue(2 <= F(4, 2)) + self.assertFalse(2 <= F(3, 2)) + self.assertTrue(F(4, 2) <= 2) + self.assertFalse(F(5, 2) <= 2) def testBigFloatComparisons(self): # Because 10**23 can't be represented exactly as a float: - self.assertFalse(R(10**23) == float(10**23)) + self.assertFalse(F(10**23) == float(10**23)) # The first test demonstrates why these are important. - self.assertFalse(1e23 < float(R(math.trunc(1e23) + 1))) - self.assertTrue(1e23 < R(math.trunc(1e23) + 1)) - self.assertFalse(1e23 <= R(math.trunc(1e23) - 1)) - self.assertTrue(1e23 > R(math.trunc(1e23) - 1)) - self.assertFalse(1e23 >= R(math.trunc(1e23) + 1)) + self.assertFalse(1e23 < float(F(math.trunc(1e23) + 1))) + self.assertTrue(1e23 < F(math.trunc(1e23) + 1)) + self.assertFalse(1e23 <= F(math.trunc(1e23) - 1)) + self.assertTrue(1e23 > F(math.trunc(1e23) - 1)) + self.assertFalse(1e23 >= F(math.trunc(1e23) + 1)) def testBigComplexComparisons(self): - self.assertFalse(R(10**23) == complex(10**23)) - self.assertTrue(R(10**23) > complex(10**23)) - self.assertFalse(R(10**23) <= complex(10**23)) + self.assertFalse(F(10**23) == complex(10**23)) + self.assertTrue(F(10**23) > complex(10**23)) + self.assertFalse(F(10**23) <= complex(10**23)) def testMixedEqual(self): - self.assertTrue(0.5 == R(1, 2)) - self.assertFalse(0.6 == R(1, 2)) - self.assertTrue(R(1, 2) == 0.5) - self.assertFalse(R(1, 2) == 0.4) - self.assertTrue(2 == R(4, 2)) - self.assertFalse(2 == R(3, 2)) - self.assertTrue(R(4, 2) == 2) - self.assertFalse(R(5, 2) == 2) + self.assertTrue(0.5 == F(1, 2)) + self.assertFalse(0.6 == F(1, 2)) + self.assertTrue(F(1, 2) == 0.5) + self.assertFalse(F(1, 2) == 0.4) + self.assertTrue(2 == F(4, 2)) + self.assertFalse(2 == F(3, 2)) + self.assertTrue(F(4, 2) == 2) + self.assertFalse(F(5, 2) == 2) def testStringification(self): - self.assertEquals("Fraction(7,3)", repr(R(7, 3))) - self.assertEquals("7/3", str(R(7, 3))) - self.assertEquals("7", str(R(7, 1))) + self.assertEquals("Fraction(7, 3)", repr(F(7, 3))) + self.assertEquals("7/3", str(F(7, 3))) + self.assertEquals("7", str(F(7, 1))) def testHash(self): - self.assertEquals(hash(2.5), hash(R(5, 2))) - self.assertEquals(hash(10**50), hash(R(10**50))) - self.assertNotEquals(hash(float(10**23)), hash(R(10**23))) + self.assertEquals(hash(2.5), hash(F(5, 2))) + self.assertEquals(hash(10**50), hash(F(10**50))) + self.assertNotEquals(hash(float(10**23)), hash(F(10**23))) def testApproximatePi(self): # Algorithm borrowed from # http://docs.python.org/lib/decimal-recipes.html - three = R(3) + three = F(3) lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24 - while abs(s - lasts) > R(1, 10**9): + while abs(s - lasts) > F(1, 10**9): lasts = s n, na = n+na, na+8 d, da = d+da, da+32 @@ -403,9 +388,9 @@ def testApproximateCos1(self): # Algorithm borrowed from # http://docs.python.org/lib/decimal-recipes.html - x = R(1) - i, lasts, s, fact, num, sign = 0, 0, R(1), 1, 1, 1 - while abs(s - lasts) > R(1, 10**9): + x = F(1) + i, lasts, s, fact, num, sign = 0, 0, F(1), 1, 1, 1 + while abs(s - lasts) > F(1, 10**9): lasts = s i += 2 fact *= i * (i-1) @@ -415,7 +400,7 @@ self.assertAlmostEquals(math.cos(1), s) def test_copy_deepcopy_pickle(self): - r = R(13, 7) + r = F(13, 7) self.assertEqual(r, loads(dumps(r))) self.assertEqual(id(r), id(copy(r))) self.assertEqual(id(r), id(deepcopy(r))) Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Thu Feb 14 09:27:37 2008 @@ -4546,10 +4546,10 @@ */ return Py_BuildValue( "ddddd", - (double)(kernel.dwHighDateTime*429.4967296 + - kernel.dwLowDateTime*1e-7), (double)(user.dwHighDateTime*429.4967296 + user.dwLowDateTime*1e-7), + (double)(kernel.dwHighDateTime*429.4967296 + + kernel.dwLowDateTime*1e-7), (double)0, (double)0, (double)0); Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Thu Feb 14 09:27:37 2008 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 60489 . +# From configure.in Revision: 60552 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -1311,7 +1311,7 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-universalsdk[SDKDIR] + --enable-universalsdk[=SDKDIR] Build against Mac OS X 10.4u SDK (ppc/i386) --enable-framework[=INSTALLDIR] Build (MacOSX|Darwin) framework Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Thu Feb 14 09:27:37 2008 @@ -61,7 +61,7 @@ CONFIG_ARGS="$ac_configure_args" AC_ARG_ENABLE(universalsdk, - AC_HELP_STRING(--enable-universalsdk@<:@SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)), + AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)), [ case $enableval in yes) From python-3000-checkins at python.org Thu Feb 14 14:32:19 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Thu, 14 Feb 2008 14:32:19 +0100 (CET) Subject: [Python-3000-checkins] r60802 - python/branches/py3k/Doc/library/stdtypes.rst Message-ID: <20080214133219.3A8841E401D@bag.python.org> Author: raymond.hettinger Date: Thu Feb 14 14:32:18 2008 New Revision: 60802 Modified: python/branches/py3k/Doc/library/stdtypes.rst Log: Documentation nit. Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Thu Feb 14 14:32:18 2008 @@ -1326,13 +1326,13 @@ *reverse* is a boolean value. If set to ``True``, then the list elements are sorted as if each comparison were reversed. - Starting with Python 2.3, the :meth:`sort` method is guaranteed to be stable. A + The :meth:`sort` method is guaranteed to be stable. A sort is stable if it guarantees not to change the relative order of elements that compare equal --- this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade). While a list is being sorted, the effect of attempting to mutate, or even - inspect, the list is undefined. The C implementation of Python 2.3 and newer + inspect, the list is undefined. The C implementation makes the list appear empty for the duration, and raises :exc:`ValueError` if it can detect that the list has been mutated during a sort. From python-3000-checkins at python.org Thu Feb 14 14:34:38 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Thu, 14 Feb 2008 14:34:38 +0100 (CET) Subject: [Python-3000-checkins] r60803 - python/branches/py3k/Doc/library/stdtypes.rst Message-ID: <20080214133438.7ADD81E4011@bag.python.org> Author: raymond.hettinger Date: Thu Feb 14 14:34:38 2008 New Revision: 60803 Modified: python/branches/py3k/Doc/library/stdtypes.rst Log: Note the the sort arguments are required to be keywords. Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Thu Feb 14 14:34:38 2008 @@ -1266,7 +1266,7 @@ | ``s.reverse()`` | reverses the items of *s* in | \(6) | | | place | | +------------------------------+--------------------------------+---------------------+ -| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7) | +| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7), (8) | +------------------------------+--------------------------------+---------------------+ .. index:: @@ -1315,10 +1315,8 @@ sequence. (7) - :meth:`sort` is not supported by :class:`bytearray` objects. - The :meth:`sort` method takes optional arguments for controlling the - comparisons. + comparisons. Each must be specified as a keyword argument. *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``. @@ -1336,6 +1334,8 @@ makes the list appear empty for the duration, and raises :exc:`ValueError` if it can detect that the list has been mutated during a sort. +(8) + :meth:`sort` is not supported by :class:`bytearray` objects. .. _bytes-methods: From python-3000-checkins at python.org Thu Feb 14 14:52:25 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Thu, 14 Feb 2008 14:52:25 +0100 (CET) Subject: [Python-3000-checkins] r60804 - python/branches/py3k/Doc/library/functions.rst Message-ID: <20080214135225.1DC341E400C@bag.python.org> Author: raymond.hettinger Date: Thu Feb 14 14:52:24 2008 New Revision: 60804 Modified: python/branches/py3k/Doc/library/functions.rst Log: Note that the key and reverse arguments must be specified as keywords Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Thu Feb 14 14:52:24 2008 @@ -979,9 +979,7 @@ Return a new sorted list from the items in *iterable*. - The optional arguments *key* and *reverse* have the same meaning as - those for the :meth:`list.sort` method (described in section - :ref:`typesseq-mutable`). + 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``. From python-3000-checkins at python.org Thu Feb 14 15:08:04 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Thu, 14 Feb 2008 15:08:04 +0100 (CET) Subject: [Python-3000-checkins] r60806 - python/branches/py3k/Doc/library/functions.rst Message-ID: <20080214140804.8A18A1E4019@bag.python.org> Author: raymond.hettinger Date: Thu Feb 14 15:08:04 2008 New Revision: 60806 Modified: python/branches/py3k/Doc/library/functions.rst Log: Minor doc updates for Py3.0 Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Thu Feb 14 15:08:04 2008 @@ -92,14 +92,6 @@ return False -.. function:: basestring() - - This abstract type is the superclass for :class:`str`. It - cannot be called or instantiated, but it can be used to test whether an object - is an instance of :class:`str` (or a user-defined type inherited from - :class:`basestring`). - - .. function:: bin(x) Convert an integer number to a binary string. The result is a valid Python @@ -296,20 +288,7 @@ class's attributes, and recursively of the attributes of its class's base classes. - The resulting list is sorted alphabetically. For example:: - - >>> import struct - >>> dir() - ['__builtins__', '__doc__', '__name__', 'struct'] - >>> dir(struct) - ['__doc__', '__name__', 'calcsize', 'error', 'pack', 'unpack'] - >>> class Foo(object): - ... def __dir__(self): - ... return ["kan", "ga", "roo"] - ... - >>> f = Foo() - >>> dir(f) - ['ga', 'kan', 'roo'] + The resulting list is sorted alphabetically. .. note:: @@ -623,10 +602,7 @@ returns ``['a', 'b', 'c']`` and ``list( (1, 2, 3) )`` returns ``[1, 2, 3]``. If no argument is given, returns a new empty list, ``[]``. - :class:`list` is a mutable sequence type, as documented in - :ref:`typesseq`. For other containers see the built in :class:`dict`, - :class:`set`, and :class:`tuple` classes, and the :mod:`collections` module. - + :class:`list` is a mutable sequence type, as documented in :ref:`typesseq`. .. function:: locals() @@ -948,9 +924,6 @@ Return a new set, optionally with elements are taken from *iterable*. The set type is described in :ref:`types-set`. - For other containers see the built in :class:`dict`, :class:`list`, and - :class:`tuple` classes, and the :mod:`collections` module. - .. function:: setattr(object, name, value) @@ -1082,9 +1055,7 @@ 3])`` returns ``(1, 2, 3)``. If no argument is given, returns a new empty tuple, ``()``. - :class:`tuple` is an immutable sequence type, as documented in - :ref:`typesseq`. For other containers see the built in :class:`dict`, - :class:`list`, and :class:`set` classes, and the :mod:`collections` module. + :class:`tuple` is an immutable sequence type, as documented in :ref:`typesseq`. .. function:: type(object) From python-3000-checkins at python.org Thu Feb 14 17:28:00 2008 From: python-3000-checkins at python.org (mark.summerfield) Date: Thu, 14 Feb 2008 17:28:00 +0100 (CET) Subject: [Python-3000-checkins] r60809 - python/branches/py3k/Doc/library/collections.rst Message-ID: <20080214162800.53CB51E4005@bag.python.org> Author: mark.summerfield Date: Thu Feb 14 17:28:00 2008 New Revision: 60809 Modified: python/branches/py3k/Doc/library/collections.rst Log: Deleted two duplicated paragraphs in the intro. Added mention of UserDict and UserList and mixins in the intro. Fixed a typo. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Thu Feb 14 17:28:00 2008 @@ -10,16 +10,10 @@ This module implements high-performance container datatypes. Currently, there are two datatypes, :class:`deque` and :class:`defaultdict`, and -one datatype factory function, :func:`namedtuple`. - -Besides the containers provided here, the optional :mod:`bsddb` -module offers the ability to create in-memory or file based ordered -dictionaries with string keys using the :meth:`bsddb.btopen` method. - -In addition to containers, the collections module provides some ABCs -(abstract base classes) that can be used to test whether a class -provides a particular interface, for example, is it hashable or -a mapping. +one datatype factory function, :func:`namedtuple`. This module also +provides the :class:`UserDict` and :class:`UserList` classes which may +be useful when inheriting directly from :class:`dict` or +:class:`list` isn't convenient. The specialized containers provided in this module provide alternatives to Python's general purpose built-in containers, :class:`dict`, @@ -29,9 +23,9 @@ dictionaries with string keys using the :meth:`bsddb.btopen` method. In addition to containers, the collections module provides some ABCs -(abstract base classes) that can be used to test whether a class +(abstract base classes). These can be used to test whether a class provides a particular interface, for example, is it hashable or -a mapping. +a mapping, and some of them can also be used as mixin classes. ABCs - abstract base classes ---------------------------- @@ -114,7 +108,7 @@ Since some set operations create new sets, the default mixin methods need a way to create new instances from an iterable. The class constructor is assumed to have a signature in the form ``ClassName(iterable)``. - That assumption is factored-out to a singleinternal classmethod called + That assumption is factored-out to a single internal classmethod called :meth:`_from_iterable` which calls ``cls(iterable)`` to produce a new set. If the :class:`Set` mixin is being used in a class with a different constructor signature, you will need to override :meth:`from_iterable` From python-3000-checkins at python.org Sat Feb 16 08:38:33 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 16 Feb 2008 08:38:33 +0100 (CET) Subject: [Python-3000-checkins] r60853 - in python/branches/py3k: Doc/c-api/method.rst Doc/c-api/set.rst Doc/c-api/tuple.rst Doc/c-api/type.rst Doc/c-api/unicode.rst Doc/library/ctypes.rst Doc/library/decimal.rst Doc/whatsnew/2.6.rst Include/classobject.h Include/frameobject.h Include/methodobject.h Include/tupleobject.h Include/unicodeobject.h Lib/SocketServer.py Lib/UserString.py Lib/idlelib/EditorWindow.py Lib/idlelib/NEWS.txt Lib/idlelib/ScriptBinding.py Lib/idlelib/configDialog.py Lib/test/test_complex.py Lib/test/test_descr.py Lib/test/test_gc.py Lib/test/test_mmap.py Misc/NEWS Misc/build.sh Modules/gcmodule.c Modules/mmapmodule.c Objects/abstract.c Objects/classobject.c Objects/complexobject.c Objects/descrobject.c Objects/frameobject.c Objects/methodobject.c Objects/tupleobject.c Objects/unicodeobject.c Message-ID: <20080216073833.5E85D1E401A@bag.python.org> Author: christian.heimes Date: Sat Feb 16 08:38:31 2008 New Revision: 60853 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/method.rst python/branches/py3k/Doc/c-api/set.rst python/branches/py3k/Doc/c-api/tuple.rst python/branches/py3k/Doc/c-api/type.rst python/branches/py3k/Doc/c-api/unicode.rst python/branches/py3k/Doc/library/ctypes.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Include/classobject.h python/branches/py3k/Include/frameobject.h python/branches/py3k/Include/methodobject.h python/branches/py3k/Include/tupleobject.h python/branches/py3k/Include/unicodeobject.h python/branches/py3k/Lib/SocketServer.py python/branches/py3k/Lib/UserString.py python/branches/py3k/Lib/idlelib/EditorWindow.py python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/idlelib/ScriptBinding.py python/branches/py3k/Lib/idlelib/configDialog.py python/branches/py3k/Lib/test/test_complex.py python/branches/py3k/Lib/test/test_descr.py python/branches/py3k/Lib/test/test_gc.py python/branches/py3k/Lib/test/test_mmap.py python/branches/py3k/Misc/NEWS python/branches/py3k/Misc/build.sh python/branches/py3k/Modules/gcmodule.c python/branches/py3k/Modules/mmapmodule.c python/branches/py3k/Objects/abstract.c python/branches/py3k/Objects/classobject.c python/branches/py3k/Objects/complexobject.c python/branches/py3k/Objects/descrobject.c python/branches/py3k/Objects/frameobject.c python/branches/py3k/Objects/methodobject.c python/branches/py3k/Objects/tupleobject.c python/branches/py3k/Objects/unicodeobject.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines Add diagnostic message to help figure-out why SocketServer tests occasionally crash when trying to remove a pid that in not in the activechildren list. ........ r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line Add fixed-point examples to the decimal FAQ ........ r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Improve rst markup ........ r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line Show how to remove exponents. ........ r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup. ........ r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. ........ r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line Simplify moneyfmt() recipe. ........ r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup ........ r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line No need to register subclass of ABCs. ........ r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line Try to correct a markup error that does hide the following paragraph. ........ r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 ........ r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. ........ r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ Thanks to Thomas Herve for the fix. ........ r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. ........ r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines Two new functions: * place_summary_first copies the regrtest summary to the front of the file making it easier to scan quickly for problems. * count_failures gets the actual count of the number of failing tests, not just a 1 (some failures) or 0 (no failures). ........ r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line Update example to match the current syntax. ........ r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines Issue #2115: __slot__ attributes setting was 10x slower. Also correct a possible crash using ABCs. This change is exactly the same as an optimisation done 5 years ago, but on slot *access*: http://svn.python.org/view?view=rev&rev=28297 ........ r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines Temporarily let these tests pass ........ r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. ........ r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines Configured selection highlighting colors were ignored; updating highlighting in the config dialog would cause non-Python files to be colored as if they were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. ........ r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. ........ Modified: python/branches/py3k/Doc/c-api/method.rst ============================================================================== --- python/branches/py3k/Doc/c-api/method.rst (original) +++ python/branches/py3k/Doc/c-api/method.rst Sat Feb 16 08:38:31 2008 @@ -92,3 +92,9 @@ .. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth) Macro version of :cfunc:`PyMethod_Self` which avoids error checking. + + +.. cfunction:: int PyMethod_ClearFreeList(void) + + Clear the free list. Return the total number of freed items. + Modified: python/branches/py3k/Doc/c-api/set.rst ============================================================================== --- python/branches/py3k/Doc/c-api/set.rst (original) +++ python/branches/py3k/Doc/c-api/set.rst Sat Feb 16 08:38:31 2008 @@ -54,15 +54,11 @@ Return true if *p* is a :class:`set` object or an instance of a subtype. - .. versionadded:: 2.6 - .. cfunction:: int PyFrozenSet_Check(PyObject *p) Return true if *p* is a :class:`frozenset` object or an instance of a subtype. - .. versionadded:: 2.6 - .. cfunction:: int PyAnySet_Check(PyObject *p) Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or an Modified: python/branches/py3k/Doc/c-api/tuple.rst ============================================================================== --- python/branches/py3k/Doc/c-api/tuple.rst (original) +++ python/branches/py3k/Doc/c-api/tuple.rst Sat Feb 16 08:38:31 2008 @@ -105,3 +105,7 @@ this function. If the object referenced by ``*p`` is replaced, the original ``*p`` is destroyed. On failure, returns ``-1`` and sets ``*p`` to *NULL*, and raises :exc:`MemoryError` or :exc:`SystemError`. + +.. cfunction:: int PyMethod_ClearFreeList(void) + + Clear the free list. Return the total number of freed items. Modified: python/branches/py3k/Doc/c-api/type.rst ============================================================================== --- python/branches/py3k/Doc/c-api/type.rst (original) +++ python/branches/py3k/Doc/c-api/type.rst Sat Feb 16 08:38:31 2008 @@ -37,8 +37,6 @@ Clears the internal lookup cache. Return the current version tag. - .. versionadded:: 2.6 - .. cfunction:: int PyType_HasFeature(PyObject *o, int feature) Modified: python/branches/py3k/Doc/c-api/unicode.rst ============================================================================== --- python/branches/py3k/Doc/c-api/unicode.rst (original) +++ python/branches/py3k/Doc/c-api/unicode.rst Sat Feb 16 08:38:31 2008 @@ -83,6 +83,11 @@ Return a pointer to the internal buffer of the object. *o* has to be a :ctype:`PyUnicodeObject` (not checked). + +.. cfunction:: int PyUnicode_ClearFreeList(void) + + Clear the free list. Return the total number of freed items. + Unicode provides many different character properties. The most often needed ones are available through these macros which are mapped to C functions depending on the Python configuration. Modified: python/branches/py3k/Doc/library/ctypes.rst ============================================================================== --- python/branches/py3k/Doc/library/ctypes.rst (original) +++ python/branches/py3k/Doc/library/ctypes.rst Sat Feb 16 08:38:31 2008 @@ -2010,7 +2010,6 @@ their methods and attributes. .. versionchanged:: 2.6 - ctypes data types that are not and do not contain pointers can now be pickled. Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Sat Feb 16 08:38:31 2008 @@ -1352,19 +1352,15 @@ '<.02>' """ - q = Decimal((0, (1,), -places)) # 2 places --> '0.01' - sign, digits, exp = value.quantize(q).as_tuple() - assert exp == -places + q = Decimal(10) ** -places # 2 places --> '0.01' + sign, digits, exp = value.quantize(q).as_tuple() result = [] digits = map(str, digits) build, next = result.append, digits.pop if sign: build(trailneg) for i in range(places): - if digits: - build(next()) - else: - build('0') + build(next() if digits else '0') build(dp) i = 0 while digits: @@ -1374,12 +1370,8 @@ i = 0 build(sep) build(curr) - if sign: - build(neg) - else: - build(pos) - result.reverse() - return ''.join(result) + build(neg if sign else pos) + return ''.join(reversed(result)) def pi(): """Compute Pi to the current precision. @@ -1482,7 +1474,7 @@ Q. It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way to minimize typing when using the interactive interpreter? -\A. Some users abbreviate the constructor to just a single letter:: +A. Some users abbreviate the constructor to just a single letter:: >>> D = decimal.Decimal >>> D('1.23') + D('3.45') @@ -1513,9 +1505,36 @@ Q. Once I have valid two place inputs, how do I maintain that invariant throughout an application? -A. Some operations like addition and subtraction automatically preserve fixed -point. Others, like multiplication and division, change the number of decimal -places and need to be followed-up with a :meth:`quantize` step. +A. Some operations like addition, subtraction, and multiplication by an integer +will automatically preserve fixed point. Others operations, like division and +non-integer multiplication, will change the number of decimal places and need to +be followed-up with a :meth:`quantize` step:: + + >>> a = Decimal('102.72') # Initial fixed-point values + >>> b = Decimal('3.17') + >>> a + b # Addition preserves fixed-point + Decimal('105.89') + >>> a - b + Decimal('99.55') + >>> a * 42 # So does integer multiplication + Decimal('4314.24') + >>> (a * b).quantize(TWOPLACES) # Must quantize non-integer multiplication + Decimal('325.62') + >>> (b / a).quantize(TWOPLACES) # And quantize division + Decimal('0.03') + +In developing fixed-point applications, it is convenient to define functions +to handle the :meth:`quantize` step:: + + >>> def mul(x, y, fp=TWOPLACES): + ... return (x * y).quantize(fp) + >>> def div(x, y, fp=TWOPLACES): + ... return (x / y).quantize(fp) + + >>> mul(a, b) # Automatically preserve fixed-point + Decimal('325.62') + >>> div(b, a) + Decimal('0.03') Q. There are many ways to express the same value. The numbers :const:`200`, :const:`200.000`, :const:`2E2`, and :const:`.02E+4` all have the same value at @@ -1537,6 +1556,16 @@ :const:`5.0E+3` as :const:`5000` keeps the value constant but cannot show the original's two-place significance. +If an application does not care about tracking significance, it is easy to +remove the exponent and trailing zeroes, losing signficance, but keeping the +value unchanged:: + + >>> def remove_exponent(d): + ... return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize() + + >>> remove_exponent(Decimal('5E+3')) + Decimal('5000') + Q. Is there a way to convert a regular float to a :class:`Decimal`? A. Yes, all binary floating point numbers can be exactly expressed as a Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Sat Feb 16 08:38:31 2008 @@ -825,7 +825,7 @@ int int >>> var._asdict() {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'} - >>> v2 = var._replace('name', 'amplitude') + >>> v2 = var._replace(name='amplitude') >>> v2 variable(id=1, name='amplitude', type='int', size=4) Modified: python/branches/py3k/Include/classobject.h ============================================================================== --- python/branches/py3k/Include/classobject.h (original) +++ python/branches/py3k/Include/classobject.h Sat Feb 16 08:38:31 2008 @@ -31,6 +31,7 @@ #define PyMethod_GET_SELF(meth) \ (((PyMethodObject *)meth) -> im_self) +PyAPI_FUNC(int) PyMethod_ClearFreeList(void); typedef struct { PyObject_HEAD Modified: python/branches/py3k/Include/frameobject.h ============================================================================== --- python/branches/py3k/Include/frameobject.h (original) +++ python/branches/py3k/Include/frameobject.h Sat Feb 16 08:38:31 2008 @@ -73,6 +73,8 @@ PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); +PyAPI_FUNC(int) PyFrame_ClearFreeList(void); + #ifdef __cplusplus } #endif Modified: python/branches/py3k/Include/methodobject.h ============================================================================== --- python/branches/py3k/Include/methodobject.h (original) +++ python/branches/py3k/Include/methodobject.h Sat Feb 16 08:38:31 2008 @@ -85,6 +85,8 @@ PyObject *m_module; /* The __module__ attribute, can be anything */ } PyCFunctionObject; +PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); + #ifdef __cplusplus } #endif Modified: python/branches/py3k/Include/tupleobject.h ============================================================================== --- python/branches/py3k/Include/tupleobject.h (original) +++ python/branches/py3k/Include/tupleobject.h Sat Feb 16 08:38:31 2008 @@ -53,6 +53,8 @@ /* Macro, *only* to be used to fill in brand new tuples */ #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) +PyAPI_FUNC(int) PyTuple_ClearFreeList(void); + #ifdef __cplusplus } #endif Modified: python/branches/py3k/Include/unicodeobject.h ============================================================================== --- python/branches/py3k/Include/unicodeobject.h (original) +++ python/branches/py3k/Include/unicodeobject.h Sat Feb 16 08:38:31 2008 @@ -210,6 +210,7 @@ # define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString # define _PyUnicode_Fini _PyUnicodeUCS2_Fini # define _PyUnicode_Init _PyUnicodeUCS2_Init +# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist # define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha # define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit # define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit @@ -303,6 +304,7 @@ # define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString # define _PyUnicode_Fini _PyUnicodeUCS4_Fini # define _PyUnicode_Init _PyUnicodeUCS4_Init +# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist # define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha # define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit # define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit @@ -413,6 +415,8 @@ extern "C" { #endif +PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); + /* --- Unicode Type ------------------------------------------------------- */ typedef struct { Modified: python/branches/py3k/Lib/SocketServer.py ============================================================================== --- python/branches/py3k/Lib/SocketServer.py (original) +++ python/branches/py3k/Lib/SocketServer.py Sat Feb 16 08:38:31 2008 @@ -452,7 +452,11 @@ except os.error: pid = None if not pid: break - self.active_children.remove(pid) + try: + self.active_children.remove(pid) + except ValueError as e: + raise ValueError('%s. x=%d and list=%r' % (e.message, pid, + self.active_children)) def handle_timeout(self): """Wait for zombies after self.timeout seconds of inactivity. Modified: python/branches/py3k/Lib/UserString.py ============================================================================== --- python/branches/py3k/Lib/UserString.py (original) +++ python/branches/py3k/Lib/UserString.py Sat Feb 16 08:38:31 2008 @@ -162,8 +162,6 @@ def upper(self): return self.__class__(self.data.upper()) def zfill(self, width): return self.__class__(self.data.zfill(width)) -collections.Sequence.register(UserString) - class MutableString(UserString, collections.MutableSequence): """mutable string objects Modified: python/branches/py3k/Lib/idlelib/EditorWindow.py ============================================================================== --- python/branches/py3k/Lib/idlelib/EditorWindow.py (original) +++ python/branches/py3k/Lib/idlelib/EditorWindow.py Sat Feb 16 08:38:31 2008 @@ -109,16 +109,6 @@ self.width = idleConf.GetOption('main','EditorWindow','width') self.text = text = MultiCallCreator(Text)( text_frame, name='text', padx=5, wrap='none', - foreground=idleConf.GetHighlight(currentTheme, - 'normal',fgBg='fg'), - background=idleConf.GetHighlight(currentTheme, - 'normal',fgBg='bg'), - highlightcolor=idleConf.GetHighlight(currentTheme, - 'hilite',fgBg='fg'), - highlightbackground=idleConf.GetHighlight(currentTheme, - 'hilite',fgBg='bg'), - insertbackground=idleConf.GetHighlight(currentTheme, - 'cursor',fgBg='fg'), width=self.width, height=idleConf.GetOption('main','EditorWindow','height') ) self.top.focused_widget = self.text @@ -225,7 +215,6 @@ # Making the initial values larger slows things down more often. self.num_context_lines = 50, 500, 5000000 self.per = per = self.Percolator(text) - self.color = None self.undo = undo = self.UndoDelegator() per.insertfilter(undo) text.undo_block_start = undo.undo_block_start @@ -236,6 +225,7 @@ io.set_filename_change_hook(self.filename_change_hook) self.good_load = False self.set_indentation_params(False) + self.color = None # initialized below in self.ResetColorizer if filename: if os.path.exists(filename) and not os.path.isdir(filename): if io.loadfile(filename): @@ -247,6 +237,7 @@ per.insertfilter(color) else: io.set_filename(filename) + self.ResetColorizer() self.saved_change_hook() self.update_recent_files_list() self.load_extensions() @@ -561,36 +552,42 @@ self.flist.filename_changed_edit(self) self.saved_change_hook() self.top.update_windowlist_registry(self) - if self.ispythonsource(self.io.filename): - self.addcolorizer() - else: - self.rmcolorizer() + self.ResetColorizer() - def addcolorizer(self): + def _addcolorizer(self): if self.color: return - self.per.removefilter(self.undo) - self.color = self.ColorDelegator() - self.per.insertfilter(self.color) - self.per.insertfilter(self.undo) + if self.ispythonsource(self.io.filename): + self.color = self.ColorDelegator() + # can add more colorizers here... + if self.color: + self.per.removefilter(self.undo) + self.per.insertfilter(self.color) + self.per.insertfilter(self.undo) - def rmcolorizer(self): + def _rmcolorizer(self): if not self.color: return self.color.removecolors() - self.per.removefilter(self.undo) self.per.removefilter(self.color) self.color = None - self.per.insertfilter(self.undo) def ResetColorizer(self): - "Update the colour theme if it is changed" - # Called from configDialog.py - if self.color: - self.color = self.ColorDelegator() - self.per.insertfilter(self.color) + "Update the colour theme" + # Called from self.filename_change_hook and from configDialog.py + self._rmcolorizer() + self._addcolorizer() theme = idleConf.GetOption('main','Theme','name') - self.text.config(idleConf.GetHighlight(theme, "normal")) + normal_colors = idleConf.GetHighlight(theme, 'normal') + cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg') + select_colors = idleConf.GetHighlight(theme, 'hilite') + self.text.config( + foreground=normal_colors['foreground'], + background=normal_colors['background'], + insertbackground=cursor_color, + selectforeground=select_colors['foreground'], + selectbackground=select_colors['background'], + ) IDENTCHARS = string.ascii_letters + string.digits + "_" Modified: python/branches/py3k/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/py3k/Lib/idlelib/NEWS.txt (original) +++ python/branches/py3k/Lib/idlelib/NEWS.txt Sat Feb 16 08:38:31 2008 @@ -45,6 +45,12 @@ *Release date: XX-XXX-200X* UNRELEASED, but merged into 3.0 +- Configured selection highlighting colors were ignored; updating highlighting + in the config dialog would cause non-Python files to be colored as if they + were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. + +- ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. + - There was an error on exit if no sys.exitfunc was defined. Issue 1647. - Could not open files in .idlerc directory if latter was hidden on Windows. Modified: python/branches/py3k/Lib/idlelib/ScriptBinding.py ============================================================================== --- python/branches/py3k/Lib/idlelib/ScriptBinding.py (original) +++ python/branches/py3k/Lib/idlelib/ScriptBinding.py Sat Feb 16 08:38:31 2008 @@ -55,11 +55,11 @@ def check_module_event(self, event): filename = self.getfilename() if not filename: - return + return 'break' if not self.checksyntax(filename): - return + return 'break' if not self.tabnanny(filename): - return + return 'break' def tabnanny(self, filename): f = open(filename, 'r') @@ -120,12 +120,12 @@ """ filename = self.getfilename() if not filename: - return + return 'break' code = self.checksyntax(filename) if not code: - return + return 'break' if not self.tabnanny(filename): - return + return 'break' shell = self.shell interp = shell.interp if PyShell.use_subprocess: @@ -148,6 +148,7 @@ # go to __stderr__. With subprocess, they go to the shell. # Need to change streams in PyShell.ModifiedInterpreter. interp.runcode(code) + return 'break' def getfilename(self): """Get source filename. If not saved, offer to save (or create) file Modified: python/branches/py3k/Lib/idlelib/configDialog.py ============================================================================== --- python/branches/py3k/Lib/idlelib/configDialog.py (original) +++ python/branches/py3k/Lib/idlelib/configDialog.py Sat Feb 16 08:38:31 2008 @@ -1114,15 +1114,12 @@ def ActivateConfigChanges(self): "Dynamically apply configuration changes" winInstances = self.parent.instance_dict.keys() - theme = idleConf.CurrentTheme() - cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg') for instance in winInstances: instance.ResetColorizer() instance.ResetFont() instance.set_notabs_indentwidth() instance.ApplyKeybindings() instance.reset_help_menu_entries() - instance.text.configure(insertbackground=cursor_color) def Cancel(self): self.destroy() Modified: python/branches/py3k/Lib/test/test_complex.py ============================================================================== --- python/branches/py3k/Lib/test/test_complex.py (original) +++ python/branches/py3k/Lib/test/test_complex.py Sat Feb 16 08:38:31 2008 @@ -4,6 +4,8 @@ from random import random from math import atan2 +INF = float("inf") +NAN = float("nan") # These tests ensure that complex math does the right thing class ComplexTest(unittest.TestCase): @@ -316,6 +318,18 @@ self.assertEqual(-6j,complex(repr(-6j))) self.assertEqual(6j,complex(repr(6j))) + self.assertEqual(repr(complex(1., INF)), "(1+inf*j)") + self.assertEqual(repr(complex(1., -INF)), "(1-inf*j)") + self.assertEqual(repr(complex(INF, 1)), "(inf+1j)") + self.assertEqual(repr(complex(-INF, INF)), "(-inf+inf*j)") + self.assertEqual(repr(complex(NAN, 1)), "(nan+1j)") + self.assertEqual(repr(complex(1, NAN)), "(1+nan*j)") + self.assertEqual(repr(complex(NAN, NAN)), "(nan+nan*j)") + + self.assertEqual(repr(complex(0, INF)), "inf*j") + self.assertEqual(repr(complex(0, -INF)), "-inf*j") + self.assertEqual(repr(complex(0, NAN)), "nan*j") + def test_neg(self): self.assertEqual(-(1+6j), -1-6j) Modified: python/branches/py3k/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k/Lib/test/test_descr.py (original) +++ python/branches/py3k/Lib/test/test_descr.py Sat Feb 16 08:38:31 2008 @@ -1067,6 +1067,23 @@ a.foo = 42 self.assertEqual(a.__dict__, {"foo": 42}) + def test_slots_descriptor(self): + # Issue2115: slot descriptors did not correctly check + # the type of the given object + import abc + class MyABC(metaclass=abc.ABCMeta): + __slots__ = "a" + + class Unrelated(object): + pass + MyABC.register(Unrelated) + + u = Unrelated() + self.assert_(isinstance(u, MyABC)) + + # This used to crash + self.assertRaises(TypeError, MyABC.a.__set__, u, 3) + def test_dynamics(self): # Testing class attribute propagation... class D(object): Modified: python/branches/py3k/Lib/test/test_gc.py ============================================================================== --- python/branches/py3k/Lib/test/test_gc.py (original) +++ python/branches/py3k/Lib/test/test_gc.py Sat Feb 16 08:38:31 2008 @@ -236,21 +236,33 @@ gc.disable() gc.set_threshold(*thresholds) + # The following two tests are fragile: + # They precisely count the number of allocations, + # which is highly implementation-dependent. + # For example: + # - disposed tuples are not freed, but reused + # - the call to assertEqual somehow avoids building its args tuple def test_get_count(self): + # Avoid future allocation of method object + assertEqual = self.assertEqual gc.collect() - self.assertEqual(gc.get_count(), (0, 0, 0)) + assertEqual(gc.get_count(), (0, 0, 0)) a = dict() - self.assertEqual(gc.get_count(), (1, 0, 0)) + # since gc.collect(), we created two objects: + # the dict, and the tuple returned by get_count() + assertEqual(gc.get_count(), (2, 0, 0)) def test_collect_generations(self): + # Avoid future allocation of method object + assertEqual = self.assertEqual gc.collect() a = dict() gc.collect(0) - self.assertEqual(gc.get_count(), (0, 1, 0)) + assertEqual(gc.get_count(), (0, 1, 0)) gc.collect(1) - self.assertEqual(gc.get_count(), (0, 0, 1)) + assertEqual(gc.get_count(), (0, 0, 1)) gc.collect(2) - self.assertEqual(gc.get_count(), (0, 0, 0)) + assertEqual(gc.get_count(), (0, 0, 0)) def test_trashcan(self): class Ouch: Modified: python/branches/py3k/Lib/test/test_mmap.py ============================================================================== --- python/branches/py3k/Lib/test/test_mmap.py (original) +++ python/branches/py3k/Lib/test/test_mmap.py Sat Feb 16 08:38:31 2008 @@ -425,6 +425,13 @@ return mmap.mmap.__new__(klass, -1, *args, **kwargs) anon_mmap(PAGESIZE) + def test_prot_readonly(self): + mapsize = 10 + open(TESTFN, "wb").write(b"a"*mapsize) + f = open(TESTFN, "rb") + m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ) + self.assertRaises(TypeError, m.write, "foo") + def test_main(): run_unittest(MmapTests) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Feb 16 08:38:31 2008 @@ -12,6 +12,39 @@ Core and Builtins ----------------- +<<<<<<< .working +======= +- Issue #2115: Important speedup in setting __slot__ attributes. Also + prevent a possible crash: an Abstract Base Class would try to access a slot + on a registered virtual subclass. + +- Fixed repr() and str() of complex numbers with infinity or nan as real or + imaginary part. + +- Clear all free list during a gc.collect() of the highest generation in order + to allow pymalloc to free more arenas. Python may give back memory to the + OS earlier. + +- Issue #2045: Fix an infinite recursion triggered when printing a subclass of + collections.defaultdict, if its default_factory is set to a bound method. + +- Fixed a minor memory leak in dictobject.c. The content of the free + list was not freed on interpreter shutdown. + +- Limit free list of method and builtin function objects to 256 entries + each. + +- Patch #1953: Added ``sys._compact_freelists()`` and the C API functions + ``PyInt_CompactFreeList`` and ``PyFloat_CompactFreeList`` + to compact the internal free lists of pre-allocted ints and floats. + +- Bug #1983: Fixed return type of fork(), fork1() and forkpty() calls. + Python expected the return type int but the fork familie returns pi_t. + +- Issue #1678380: Fix a bug that identifies 0j and -0j when they appear + in the same code unit. + +>>>>>>> .merge-right.r60845 - Issue #2025 : Add tuple.count() and tuple.index() methods to comply with the collections.Sequence API. @@ -67,7 +100,13 @@ Extension Modules ----------------- +<<<<<<< .working - Issue #1762972: Readded the reload() function as imp.reload() +======= +- Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ + +- #2063: correct order of utime and stime in os.times() result on Windows. +>>>>>>> .merge-right.r60845 Library Modified: python/branches/py3k/Misc/build.sh ============================================================================== --- python/branches/py3k/Misc/build.sh (original) +++ python/branches/py3k/Misc/build.sh Sat Feb 16 08:38:31 2008 @@ -92,6 +92,24 @@ echo "
  • $1 ($time seconds)
  • " >> $RESULT_FILE } +place_summary_first() { + testf=$1 + sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \ + | egrep -v '\[[0-9]+ refs\]' > $testf.tmp + echo "" >> $testf.tmp + cat $testf >> $testf.tmp + mv $testf.tmp $testf +} + +count_failures () { + testf=$1 + n=`grep -ic " failed:" $testf` + if [ $n -eq 1 ] ; then + n=`grep " failed:" $testf | sed -e 's/ .*//'` + fi + echo $n +} + mail_on_failure() { if [ "$NUM_FAILURES" != "0" ]; then dest=$FAILURE_MAILTO @@ -187,14 +205,16 @@ F=make-test.out start=`current_time` $PYTHON $REGRTEST_ARGS $ALWAYS_SKIP >& build/$F - NUM_FAILURES=`grep -ic " failed:" build/$F` + NUM_FAILURES=`count_failures build/$F` + place_summary_first build/$F update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start mail_on_failure "basics" build/$F F=make-test-opt.out start=`current_time` $PYTHON -O $REGRTEST_ARGS $ALWAYS_SKIP >& build/$F - NUM_FAILURES=`grep -ic " failed:" build/$F` + NUM_FAILURES=`count_failures build/$F` + place_summary_first build/$F update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start mail_on_failure "opt" build/$F @@ -206,6 +226,7 @@ $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F LEAK_PAT="($LEAKY_TESTS|sum=0)" NUM_FAILURES=`egrep -vc "$LEAK_PAT" $REFLOG` + place_summary_first build/$F update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start mail_on_failure "refleak" $REFLOG "$LEAK_PAT" @@ -215,7 +236,8 @@ ## skip curses when running from cron since there's no terminal ## skip sound since it's not setup on the PSF box (/dev/dsp) $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev $_ALWAYS_SKIP >& build/$F - NUM_FAILURES=`grep -ic " failed:" build/$F` + NUM_FAILURES=`count_failures build/$F` + place_summary_first build/$F update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start mail_on_failure "all" build/$F fi Modified: python/branches/py3k/Modules/gcmodule.c ============================================================================== --- python/branches/py3k/Modules/gcmodule.c (original) +++ python/branches/py3k/Modules/gcmodule.c Sat Feb 16 08:38:31 2008 @@ -19,6 +19,7 @@ */ #include "Python.h" +#include "frameobject.h" /* for PyFrame_ClearFreeList */ /* Get an object's GC head */ #define AS_GC(o) ((PyGC_Head *)(o)-1) @@ -687,6 +688,21 @@ } } +/* Clear all free lists + * All free lists are cleared during the collection of the highest generation. + * Allocated items in the free list may keep a pymalloc arena occupied. + * Clearing the free lists may give back memory to the OS earlier. + */ +static void +clear_freelists(void) +{ + (void)PyMethod_ClearFreeList(); + (void)PyFrame_ClearFreeList(); + (void)PyCFunction_ClearFreeList(); + (void)PyTuple_ClearFreeList(); + (void)PyUnicode_ClearFreeList(); +} + /* This is the main function. Read this to understand how the * collection process works. */ static Py_ssize_t @@ -839,6 +855,12 @@ */ (void)handle_finalizers(&finalizers, old); + /* Clear free list only during the collection of the higest + * generation */ + if (generation == NUM_GENERATIONS-1) { + clear_freelists(); + } + if (PyErr_Occurred()) { if (gc_str == NULL) gc_str = PyUnicode_FromString("garbage collection"); Modified: python/branches/py3k/Modules/mmapmodule.c ============================================================================== --- python/branches/py3k/Modules/mmapmodule.c (original) +++ python/branches/py3k/Modules/mmapmodule.c Sat Feb 16 08:38:31 2008 @@ -1043,6 +1043,10 @@ "mmap invalid access parameter."); } + if (prot == PROT_READ) { + access = ACCESS_READ; + } + #ifdef HAVE_FSTAT # ifdef __VMS /* on OpenVMS we must ensure that all bytes are written to the file */ Modified: python/branches/py3k/Objects/abstract.c ============================================================================== --- python/branches/py3k/Objects/abstract.c (original) +++ python/branches/py3k/Objects/abstract.c Sat Feb 16 08:38:31 2008 @@ -1405,13 +1405,19 @@ PyObject * PyNumber_ToBase(PyObject *n, int base) { - PyObject *res; + PyObject *res = NULL; PyObject *index = PyNumber_Index(n); if (!index) return NULL; - assert(PyLong_Check(index)); - res = _PyLong_Format(index, base); + if (PyLong_Check(index)) + res = _PyLong_Format(index, base); + else + /* It should not be possible to get here, as + PyNumber_Index already has a check for the same + condition */ + PyErr_SetString(PyExc_ValueError, "PyNumber_ToBase: index not " + "int or long"); Py_DECREF(index); return res; } @@ -2540,10 +2546,17 @@ int PyObject_IsInstance(PyObject *inst, PyObject *cls) { + static PyObject *name = NULL; PyObject *t, *v, *tb; PyObject *checker; PyErr_Fetch(&t, &v, &tb); - checker = PyObject_GetAttrString(cls, "__instancecheck__"); + + if (name == NULL) { + name = PyUnicode_InternFromString("__instancecheck__"); + if (name == NULL) + return -1; + } + checker = PyObject_GetAttr(cls, name); PyErr_Restore(t, v, tb); if (checker != NULL) { PyObject *res; @@ -2611,10 +2624,17 @@ int PyObject_IsSubclass(PyObject *derived, PyObject *cls) { + static PyObject *name = NULL; PyObject *t, *v, *tb; PyObject *checker; PyErr_Fetch(&t, &v, &tb); - checker = PyObject_GetAttrString(cls, "__subclasscheck__"); + + if (name == NULL) { + name = PyUnicode_InternFromString("__subclasscheck__"); + if (name == NULL) + return -1; + } + checker = PyObject_GetAttr(cls, name); PyErr_Restore(t, v, tb); if (checker != NULL) { PyObject *res; Modified: python/branches/py3k/Objects/classobject.c ============================================================================== --- python/branches/py3k/Objects/classobject.c (original) +++ python/branches/py3k/Objects/classobject.c Sat Feb 16 08:38:31 2008 @@ -382,9 +382,11 @@ /* Clear out the free list */ -void -PyMethod_Fini(void) +int +PyMethod_ClearFreeList(void) { + int freelist_size = numfree; + while (free_list) { PyMethodObject *im = free_list; free_list = (PyMethodObject *)(im->im_self); @@ -392,6 +394,13 @@ numfree--; } assert(numfree == 0); + return freelist_size; +} + +void +PyMethod_Fini(void) +{ + (void)PyMethod_ClearFreeList(); } /* ------------------------------------------------------------------------ Modified: python/branches/py3k/Objects/complexobject.c ============================================================================== --- python/branches/py3k/Objects/complexobject.c (original) +++ python/branches/py3k/Objects/complexobject.c Sat Feb 16 08:38:31 2008 @@ -314,16 +314,49 @@ { char format[32]; if (v->cval.real == 0.) { - PyOS_snprintf(format, sizeof(format), "%%.%ig", precision); - PyOS_ascii_formatd(buf, bufsz - 1, format, v->cval.imag); - strncat(buf, "j", 1); + if (!Py_IS_FINITE(v->cval.imag)) { + if (Py_IS_NAN(v->cval.imag)) + strncpy(buf, "nan*j", 6); + /* else if (copysign(1, v->cval.imag) == 1) */ + else if (v->cval.imag > 0) + strncpy(buf, "inf*j", 6); + else + strncpy(buf, "-inf*j", 7); + } + else { + PyOS_snprintf(format, sizeof(format), "%%.%ig", precision); + PyOS_ascii_formatd(buf, bufsz - 1, format, v->cval.imag); + strncat(buf, "j", 1); + } } else { char re[64], im[64]; /* Format imaginary part with sign, real part without */ - PyOS_snprintf(format, sizeof(format), "%%.%ig", precision); - PyOS_ascii_formatd(re, sizeof(re), format, v->cval.real); - PyOS_snprintf(format, sizeof(format), "%%+.%ig", precision); - PyOS_ascii_formatd(im, sizeof(im), format, v->cval.imag); + if (!Py_IS_FINITE(v->cval.real)) { + if (Py_IS_NAN(v->cval.real)) + strncpy(re, "nan", 4); + /* else if (copysign(1, v->cval.real) == 1) */ + else if (v->cval.real > 0) + strncpy(re, "inf", 4); + else + strncpy(re, "-inf", 5); + } + else { + PyOS_snprintf(format, sizeof(format), "%%.%ig", precision); + PyOS_ascii_formatd(re, sizeof(re), format, v->cval.real); + } + if (!Py_IS_FINITE(v->cval.imag)) { + if (Py_IS_NAN(v->cval.imag)) + strncpy(im, "+nan*", 6); + /* else if (copysign(1, v->cval.imag) == 1) */ + else if (v->cval.imag > 0) + strncpy(im, "+inf*", 6); + else + strncpy(im, "-inf*", 6); + } + else { + PyOS_snprintf(format, sizeof(format), "%%+.%ig", precision); + PyOS_ascii_formatd(im, sizeof(im), format, v->cval.imag); + } PyOS_snprintf(buf, bufsz, "(%s%sj)", re, im); } } Modified: python/branches/py3k/Objects/descrobject.c ============================================================================== --- python/branches/py3k/Objects/descrobject.c (original) +++ python/branches/py3k/Objects/descrobject.c Sat Feb 16 08:38:31 2008 @@ -168,7 +168,7 @@ int *pres) { assert(obj != NULL); - if (!PyObject_IsInstance(obj, (PyObject *)(descr->d_type))) { + if (!PyObject_TypeCheck(obj, descr->d_type)) { PyErr_Format(PyExc_TypeError, "descriptor '%V' for '%.100s' objects " "doesn't apply to '%.100s' object", Modified: python/branches/py3k/Objects/frameobject.c ============================================================================== --- python/branches/py3k/Objects/frameobject.c (original) +++ python/branches/py3k/Objects/frameobject.c Sat Feb 16 08:38:31 2008 @@ -897,10 +897,11 @@ } /* Clear out the free list */ - -void -PyFrame_Fini(void) +int +PyFrame_ClearFreeList(void) { + int freelist_size = numfree; + while (free_list != NULL) { PyFrameObject *f = free_list; free_list = free_list->f_back; @@ -908,6 +909,13 @@ --numfree; } assert(numfree == 0); + return freelist_size; +} + +void +PyFrame_Fini(void) +{ + (void)PyFrame_ClearFreeList(); Py_XDECREF(builtin_object); builtin_object = NULL; } Modified: python/branches/py3k/Objects/methodobject.c ============================================================================== --- python/branches/py3k/Objects/methodobject.c (original) +++ python/branches/py3k/Objects/methodobject.c Sat Feb 16 08:38:31 2008 @@ -319,9 +319,11 @@ /* Clear out the free list */ -void -PyCFunction_Fini(void) +int +PyCFunction_ClearFreeList(void) { + int freelist_size = numfree; + while (free_list) { PyCFunctionObject *v = free_list; free_list = (PyCFunctionObject *)(v->m_self); @@ -329,6 +331,13 @@ numfree--; } assert(numfree == 0); + return freelist_size; +} + +void +PyCFunction_Fini(void) +{ + (void)PyCFunction_ClearFreeList(); } /* PyCFunction_New() is now just a macro that calls PyCFunction_NewEx(), Modified: python/branches/py3k/Objects/tupleobject.c ============================================================================== --- python/branches/py3k/Objects/tupleobject.c (original) +++ python/branches/py3k/Objects/tupleobject.c Sat Feb 16 08:38:31 2008 @@ -807,19 +807,18 @@ return 0; } -void -PyTuple_Fini(void) +int +PyTuple_ClearFreeList(void) { + int freelist_size = 0; #if PyTuple_MAXSAVESIZE > 0 int i; - - Py_XDECREF(free_list[0]); - free_list[0] = NULL; - for (i = 1; i < PyTuple_MAXSAVESIZE; i++) { PyTupleObject *p, *q; p = free_list[i]; + freelist_size += numfree[i]; free_list[i] = NULL; + numfree[i] = 0; while (p) { q = p; p = (PyTupleObject *)(p->ob_item[0]); @@ -827,6 +826,20 @@ } } #endif + return freelist_size; +} + +void +PyTuple_Fini(void) +{ +#if PyTuple_MAXSAVESIZE > 0 + /* empty tuples are used all over the place and applications may + * rely on the fact that an empty tuple is a singleton. */ + Py_XDECREF(free_list[0]); + free_list[0] = NULL; + + (void)PyTuple_ClearFreeList(); +#endif } /*********************** Tuple Iterator **************************/ Modified: python/branches/py3k/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k/Objects/unicodeobject.c (original) +++ python/branches/py3k/Objects/unicodeobject.c Sat Feb 16 08:38:31 2008 @@ -9111,10 +9111,29 @@ /* Finalize the Unicode implementation */ +int +PyUnicode_ClearFreeList(void) +{ + int freelist_size = numfree; + PyUnicodeObject *u; + + for (u = free_list; u != NULL;) { + PyUnicodeObject *v = u; + u = *(PyUnicodeObject **)u; + if (v->str) + PyMem_DEL(v->str); + Py_XDECREF(v->defenc); + PyObject_Del(v); + numfree--; + } + free_list = NULL; + assert(numfree == 0); + return freelist_size; +} + void _PyUnicode_Fini(void) { - PyUnicodeObject *u; int i; Py_XDECREF(unicode_empty); @@ -9126,17 +9145,7 @@ unicode_latin1[i] = NULL; } } - - for (u = free_list; u != NULL;) { - PyUnicodeObject *v = u; - u = *(PyUnicodeObject **)u; - if (v->str) - PyMem_DEL(v->str); - Py_XDECREF(v->defenc); - PyObject_Del(v); - } - free_list = NULL; - numfree = 0; + (void)PyUnicode_ClearFreeList(); } void From python-3000-checkins at python.org Sun Feb 17 14:31:40 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 17 Feb 2008 14:31:40 +0100 (CET) Subject: [Python-3000-checkins] r60874 - in python/branches/py3k: Doc/howto/advocacy.rst Doc/library/codecs.rst Lib/logging/__init__.py Lib/test/output/test_logging Lib/test/test_logging.py Lib/test/test_mmap.py Lib/test/test_scope.py Misc/ACKS Modules/_struct.c Modules/cStringIO.c Objects/cellobject.c Message-ID: <20080217133140.363441E401C@bag.python.org> Author: christian.heimes Date: Sun Feb 17 14:31:39 2008 New Revision: 60874 Removed: python/branches/py3k/Lib/test/output/test_logging Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/howto/advocacy.rst python/branches/py3k/Doc/library/codecs.rst python/branches/py3k/Lib/logging/__init__.py python/branches/py3k/Lib/test/test_logging.py python/branches/py3k/Lib/test/test_mmap.py python/branches/py3k/Lib/test/test_scope.py python/branches/py3k/Misc/ACKS python/branches/py3k/Modules/_struct.c python/branches/py3k/Modules/cStringIO.c python/branches/py3k/Objects/cellobject.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines mmap.PROT_READ does not exists on win32; Skip this test created by r60830. ........ r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line Add __all__ to logging module. ........ r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines #2120: broken links in advocacy document. ........ r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines Crashers of the day: Py_CLEAR must be used when there is a chance that the function can be called recursively. This was discussed in issue1020188. In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect, except when they appear in tp_new or tp_dealloc functions, or when the member cannot be of a user-defined class. Note that tp_init is not safe. I do have a (crashing) example for every changed line. Is it worth adding them to the test suite? Example: class SpecialStr(str): def __del__(self): s.close() import cStringIO s = cStringIO.StringIO(SpecialStr("text")) s.close() # Segfault ........ r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer is still present in the containing structure. ........ r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines Move test_logging over to doctest. Thanks to Christopher White from GHOP. ........ r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines #2131: note that codecs.open() always opens files in binary mode. ........ Modified: python/branches/py3k/Doc/howto/advocacy.rst ============================================================================== --- python/branches/py3k/Doc/howto/advocacy.rst (original) +++ python/branches/py3k/Doc/howto/advocacy.rst Sun Feb 17 14:31:39 2008 @@ -160,7 +160,7 @@ don't merge cleanly into the overall design scheme (thus, some fans of Classic C maintain that ANSI C is no longer compact). - (From http://www.catb.org/ esr/jargon/html/C/compact.html) + (From http://www.catb.org/~esr/jargon/html/C/compact.html) In this sense of the word, Python is quite compact, because the language has just a few ideas, which are used in lots of places. Take namespaces, for @@ -174,14 +174,14 @@ This simplicity arises from Python's development history. The language syntax derives from different sources; ABC, a relatively obscure teaching language, is one primary influence, and Modula-3 is another. (For more information about ABC -and Modula-3, consult their respective Web sites at http://www.cwi.nl/ -steven/abc/ and http://www.m3.org.) Other features have come from C, Icon, +and Modula-3, consult their respective Web sites at http://www.cwi.nl/~steven/abc/ +and http://www.m3.org.) Other features have come from C, Icon, Algol-68, and even Perl. Python hasn't really innovated very much, but instead has tried to keep the language small and easy to learn, building on ideas that have been tried in other languages and found useful. Simplicity is a virtue that should not be underestimated. It lets you learn the -language more quickly, and then rapidly write code, code that often works the +language more quickly, and then rapidly write code -- code that often works the first time you run it. @@ -266,7 +266,7 @@ They're practically nonexistent. Consult the :file:`Misc/COPYRIGHT` file in the source distribution, or the section :ref:`history-and-license` for the full -language, but it boils down to three conditions. +language, but it boils down to three conditions: * You have to leave the copyright notice on the software; if you don't include the source code in a product, you have to put the copyright notice in the Modified: python/branches/py3k/Doc/library/codecs.rst ============================================================================== --- python/branches/py3k/Doc/library/codecs.rst (original) +++ python/branches/py3k/Doc/library/codecs.rst Sun Feb 17 14:31:39 2008 @@ -202,7 +202,8 @@ .. function:: open(filename, mode[, encoding[, errors[, buffering]]]) Open an encoded file using the given *mode* and return a wrapped version - providing transparent encoding/decoding. + providing transparent encoding/decoding. The default file mode is ``'r'`` + meaning to open the file in read mode. .. note:: @@ -210,6 +211,13 @@ i.e. Unicode objects for most built-in codecs. Output is also codec-dependent and will usually be Unicode as well. + .. note:: + + Files are always opened in binary mode, even if no binary mode was + specified. This is done to avoid data loss due to encodings using 8-bit + values. This means that no automatic conversion of ``'\n'`` is done + on reading and writing. + *encoding* specifies the encoding which is to be used for the file. *errors* may be given to define the error handling. It defaults to ``'strict'`` Modified: python/branches/py3k/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k/Lib/logging/__init__.py (original) +++ python/branches/py3k/Lib/logging/__init__.py Sun Feb 17 14:31:39 2008 @@ -24,6 +24,10 @@ """ import sys, os, time, io, traceback +__all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR', + 'FATAL', 'FileHandler', 'Filter', 'Filterer', 'Formatter', 'Handler', + 'INFO', 'LogRecord', 'Logger', 'Manager', 'NOTSET', 'PlaceHolder', + 'RootLogger', 'StreamHandler', 'WARN', 'WARNING'] try: import codecs Deleted: /python/branches/py3k/Lib/test/output/test_logging ============================================================================== --- /python/branches/py3k/Lib/test/output/test_logging Sun Feb 17 14:31:39 2008 +++ (empty file) @@ -1,525 +0,0 @@ -test_logging --- log_test0 begin --------------------------------------------------- -CRITICAL:ERR:Message 0 -ERROR:ERR:Message 1 -CRITICAL:INF:Message 2 -ERROR:INF:Message 3 -WARNING:INF:Message 4 -INFO:INF:Message 5 -CRITICAL:INF.UNDEF:Message 6 -ERROR:INF.UNDEF:Message 7 -WARNING:INF.UNDEF:Message 8 -INFO:INF.UNDEF:Message 9 -CRITICAL:INF.ERR:Message 10 -ERROR:INF.ERR:Message 11 -CRITICAL:INF.ERR.UNDEF:Message 12 -ERROR:INF.ERR.UNDEF:Message 13 -CRITICAL:DEB:Message 14 -ERROR:DEB:Message 15 -WARNING:DEB:Message 16 -INFO:DEB:Message 17 -DEBUG:DEB:Message 18 -CRITICAL:UNDEF:Message 19 -ERROR:UNDEF:Message 20 -WARNING:UNDEF:Message 21 -INFO:UNDEF:Message 22 -CRITICAL:INF.BADPARENT.UNDEF:Message 23 -CRITICAL:INF.BADPARENT:Message 24 -INFO:INF:Finish up, it's closing time. Messages should bear numbers 0 through 24. --- log_test0 end --------------------------------------------------- --- log_test1 begin --------------------------------------------------- --- setting logging level to 'Boring' ----- -Boring:root:This should only be seen at the 'Boring' logging level (or lower) -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- Filtering at handler level to SOCIABLE -- --- setting logging level to 'Boring' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- Filtering using GARRULOUS filter -- --- setting logging level to 'Boring' ----- -Boring:root:This should only be seen at the 'Boring' logging level (or lower) -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- Filtering using specific filter for SOCIABLE, TACITURN -- --- setting logging level to 'Boring' ----- -Boring:root:This should only be seen at the 'Boring' logging level (or lower) -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- log_test1 end --------------------------------------------------- --- log_test2 begin --------------------------------------------------- --- logging at DEBUG, nothing should be seen yet -- --- logging at INFO, nothing should be seen yet -- --- logging at WARNING, 3 messages should be seen -- -DEBUG:root:Debug message -INFO:root:Info message -WARNING:root:Warn message --- logging 0 at INFO, messages should be seen every 10 events -- --- logging 1 at INFO, messages should be seen every 10 events -- --- logging 2 at INFO, messages should be seen every 10 events -- --- logging 3 at INFO, messages should be seen every 10 events -- --- logging 4 at INFO, messages should be seen every 10 events -- --- logging 5 at INFO, messages should be seen every 10 events -- --- logging 6 at INFO, messages should be seen every 10 events -- --- logging 7 at INFO, messages should be seen every 10 events -- --- logging 8 at INFO, messages should be seen every 10 events -- --- logging 9 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 0 -INFO:root:Info index = 1 -INFO:root:Info index = 2 -INFO:root:Info index = 3 -INFO:root:Info index = 4 -INFO:root:Info index = 5 -INFO:root:Info index = 6 -INFO:root:Info index = 7 -INFO:root:Info index = 8 -INFO:root:Info index = 9 --- logging 10 at INFO, messages should be seen every 10 events -- --- logging 11 at INFO, messages should be seen every 10 events -- --- logging 12 at INFO, messages should be seen every 10 events -- --- logging 13 at INFO, messages should be seen every 10 events -- --- logging 14 at INFO, messages should be seen every 10 events -- --- logging 15 at INFO, messages should be seen every 10 events -- --- logging 16 at INFO, messages should be seen every 10 events -- --- logging 17 at INFO, messages should be seen every 10 events -- --- logging 18 at INFO, messages should be seen every 10 events -- --- logging 19 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 10 -INFO:root:Info index = 11 -INFO:root:Info index = 12 -INFO:root:Info index = 13 -INFO:root:Info index = 14 -INFO:root:Info index = 15 -INFO:root:Info index = 16 -INFO:root:Info index = 17 -INFO:root:Info index = 18 -INFO:root:Info index = 19 --- logging 20 at INFO, messages should be seen every 10 events -- --- logging 21 at INFO, messages should be seen every 10 events -- --- logging 22 at INFO, messages should be seen every 10 events -- --- logging 23 at INFO, messages should be seen every 10 events -- --- logging 24 at INFO, messages should be seen every 10 events -- --- logging 25 at INFO, messages should be seen every 10 events -- --- logging 26 at INFO, messages should be seen every 10 events -- --- logging 27 at INFO, messages should be seen every 10 events -- --- logging 28 at INFO, messages should be seen every 10 events -- --- logging 29 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 20 -INFO:root:Info index = 21 -INFO:root:Info index = 22 -INFO:root:Info index = 23 -INFO:root:Info index = 24 -INFO:root:Info index = 25 -INFO:root:Info index = 26 -INFO:root:Info index = 27 -INFO:root:Info index = 28 -INFO:root:Info index = 29 --- logging 30 at INFO, messages should be seen every 10 events -- --- logging 31 at INFO, messages should be seen every 10 events -- --- logging 32 at INFO, messages should be seen every 10 events -- --- logging 33 at INFO, messages should be seen every 10 events -- --- logging 34 at INFO, messages should be seen every 10 events -- --- logging 35 at INFO, messages should be seen every 10 events -- --- logging 36 at INFO, messages should be seen every 10 events -- --- logging 37 at INFO, messages should be seen every 10 events -- --- logging 38 at INFO, messages should be seen every 10 events -- --- logging 39 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 30 -INFO:root:Info index = 31 -INFO:root:Info index = 32 -INFO:root:Info index = 33 -INFO:root:Info index = 34 -INFO:root:Info index = 35 -INFO:root:Info index = 36 -INFO:root:Info index = 37 -INFO:root:Info index = 38 -INFO:root:Info index = 39 --- logging 40 at INFO, messages should be seen every 10 events -- --- logging 41 at INFO, messages should be seen every 10 events -- --- logging 42 at INFO, messages should be seen every 10 events -- --- logging 43 at INFO, messages should be seen every 10 events -- --- logging 44 at INFO, messages should be seen every 10 events -- --- logging 45 at INFO, messages should be seen every 10 events -- --- logging 46 at INFO, messages should be seen every 10 events -- --- logging 47 at INFO, messages should be seen every 10 events -- --- logging 48 at INFO, messages should be seen every 10 events -- --- logging 49 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 40 -INFO:root:Info index = 41 -INFO:root:Info index = 42 -INFO:root:Info index = 43 -INFO:root:Info index = 44 -INFO:root:Info index = 45 -INFO:root:Info index = 46 -INFO:root:Info index = 47 -INFO:root:Info index = 48 -INFO:root:Info index = 49 --- logging 50 at INFO, messages should be seen every 10 events -- --- logging 51 at INFO, messages should be seen every 10 events -- --- logging 52 at INFO, messages should be seen every 10 events -- --- logging 53 at INFO, messages should be seen every 10 events -- --- logging 54 at INFO, messages should be seen every 10 events -- --- logging 55 at INFO, messages should be seen every 10 events -- --- logging 56 at INFO, messages should be seen every 10 events -- --- logging 57 at INFO, messages should be seen every 10 events -- --- logging 58 at INFO, messages should be seen every 10 events -- --- logging 59 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 50 -INFO:root:Info index = 51 -INFO:root:Info index = 52 -INFO:root:Info index = 53 -INFO:root:Info index = 54 -INFO:root:Info index = 55 -INFO:root:Info index = 56 -INFO:root:Info index = 57 -INFO:root:Info index = 58 -INFO:root:Info index = 59 --- logging 60 at INFO, messages should be seen every 10 events -- --- logging 61 at INFO, messages should be seen every 10 events -- --- logging 62 at INFO, messages should be seen every 10 events -- --- logging 63 at INFO, messages should be seen every 10 events -- --- logging 64 at INFO, messages should be seen every 10 events -- --- logging 65 at INFO, messages should be seen every 10 events -- --- logging 66 at INFO, messages should be seen every 10 events -- --- logging 67 at INFO, messages should be seen every 10 events -- --- logging 68 at INFO, messages should be seen every 10 events -- --- logging 69 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 60 -INFO:root:Info index = 61 -INFO:root:Info index = 62 -INFO:root:Info index = 63 -INFO:root:Info index = 64 -INFO:root:Info index = 65 -INFO:root:Info index = 66 -INFO:root:Info index = 67 -INFO:root:Info index = 68 -INFO:root:Info index = 69 --- logging 70 at INFO, messages should be seen every 10 events -- --- logging 71 at INFO, messages should be seen every 10 events -- --- logging 72 at INFO, messages should be seen every 10 events -- --- logging 73 at INFO, messages should be seen every 10 events -- --- logging 74 at INFO, messages should be seen every 10 events -- --- logging 75 at INFO, messages should be seen every 10 events -- --- logging 76 at INFO, messages should be seen every 10 events -- --- logging 77 at INFO, messages should be seen every 10 events -- --- logging 78 at INFO, messages should be seen every 10 events -- --- logging 79 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 70 -INFO:root:Info index = 71 -INFO:root:Info index = 72 -INFO:root:Info index = 73 -INFO:root:Info index = 74 -INFO:root:Info index = 75 -INFO:root:Info index = 76 -INFO:root:Info index = 77 -INFO:root:Info index = 78 -INFO:root:Info index = 79 --- logging 80 at INFO, messages should be seen every 10 events -- --- logging 81 at INFO, messages should be seen every 10 events -- --- logging 82 at INFO, messages should be seen every 10 events -- --- logging 83 at INFO, messages should be seen every 10 events -- --- logging 84 at INFO, messages should be seen every 10 events -- --- logging 85 at INFO, messages should be seen every 10 events -- --- logging 86 at INFO, messages should be seen every 10 events -- --- logging 87 at INFO, messages should be seen every 10 events -- --- logging 88 at INFO, messages should be seen every 10 events -- --- logging 89 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 80 -INFO:root:Info index = 81 -INFO:root:Info index = 82 -INFO:root:Info index = 83 -INFO:root:Info index = 84 -INFO:root:Info index = 85 -INFO:root:Info index = 86 -INFO:root:Info index = 87 -INFO:root:Info index = 88 -INFO:root:Info index = 89 --- logging 90 at INFO, messages should be seen every 10 events -- --- logging 91 at INFO, messages should be seen every 10 events -- --- logging 92 at INFO, messages should be seen every 10 events -- --- logging 93 at INFO, messages should be seen every 10 events -- --- logging 94 at INFO, messages should be seen every 10 events -- --- logging 95 at INFO, messages should be seen every 10 events -- --- logging 96 at INFO, messages should be seen every 10 events -- --- logging 97 at INFO, messages should be seen every 10 events -- --- logging 98 at INFO, messages should be seen every 10 events -- --- logging 99 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 90 -INFO:root:Info index = 91 -INFO:root:Info index = 92 -INFO:root:Info index = 93 -INFO:root:Info index = 94 -INFO:root:Info index = 95 -INFO:root:Info index = 96 -INFO:root:Info index = 97 -INFO:root:Info index = 98 -INFO:root:Info index = 99 --- logging 100 at INFO, messages should be seen every 10 events -- --- logging 101 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 100 -INFO:root:Info index = 101 --- log_test2 end --------------------------------------------------- --- log_test3 begin --------------------------------------------------- -Unfiltered... -INFO:a:Info 1 -INFO:a.b:Info 2 -INFO:a.c:Info 3 -INFO:a.b.c:Info 4 -INFO:a.b.c.d:Info 5 -INFO:a.bb.c:Info 6 -INFO:b:Info 7 -INFO:b.a:Info 8 -INFO:c.a.b:Info 9 -INFO:a.bb:Info 10 -Filtered with 'a.b'... -INFO:a.b:Info 2 -INFO:a.b.c:Info 4 -INFO:a.b.c.d:Info 5 --- log_test3 end --------------------------------------------------- --- log_test4 begin --------------------------------------------------- -config0: ok. -config1: ok. -config2: -config3: --- log_test4 end --------------------------------------------------- --- log_test5 begin --------------------------------------------------- -ERROR:root:just testing -... Don't panic! --- log_test5 end --------------------------------------------------- --- logrecv output begin --------------------------------------------------- -ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) -ERR -> ERROR: Message 1 (via logrecv.tcp.ERR) -INF -> CRITICAL: Message 2 (via logrecv.tcp.INF) -INF -> ERROR: Message 3 (via logrecv.tcp.INF) -INF -> WARNING: Message 4 (via logrecv.tcp.INF) -INF -> INFO: Message 5 (via logrecv.tcp.INF) -INF.UNDEF -> CRITICAL: Message 6 (via logrecv.tcp.INF.UNDEF) -INF.UNDEF -> ERROR: Message 7 (via logrecv.tcp.INF.UNDEF) -INF.UNDEF -> WARNING: Message 8 (via logrecv.tcp.INF.UNDEF) -INF.UNDEF -> INFO: Message 9 (via logrecv.tcp.INF.UNDEF) -INF.ERR -> CRITICAL: Message 10 (via logrecv.tcp.INF.ERR) -INF.ERR -> ERROR: Message 11 (via logrecv.tcp.INF.ERR) -INF.ERR.UNDEF -> CRITICAL: Message 12 (via logrecv.tcp.INF.ERR.UNDEF) -INF.ERR.UNDEF -> ERROR: Message 13 (via logrecv.tcp.INF.ERR.UNDEF) -DEB -> CRITICAL: Message 14 (via logrecv.tcp.DEB) -DEB -> ERROR: Message 15 (via logrecv.tcp.DEB) -DEB -> WARNING: Message 16 (via logrecv.tcp.DEB) -DEB -> INFO: Message 17 (via logrecv.tcp.DEB) -DEB -> DEBUG: Message 18 (via logrecv.tcp.DEB) -UNDEF -> CRITICAL: Message 19 (via logrecv.tcp.UNDEF) -UNDEF -> ERROR: Message 20 (via logrecv.tcp.UNDEF) -UNDEF -> WARNING: Message 21 (via logrecv.tcp.UNDEF) -UNDEF -> INFO: Message 22 (via logrecv.tcp.UNDEF) -INF.BADPARENT.UNDEF -> CRITICAL: Message 23 (via logrecv.tcp.INF.BADPARENT.UNDEF) -INF.BADPARENT -> CRITICAL: Message 24 (via logrecv.tcp.INF.BADPARENT) -INF -> INFO: Finish up, it's closing time. Messages should bear numbers 0 through 24. (via logrecv.tcp.INF) --- logrecv output end --------------------------------------------------- Modified: python/branches/py3k/Lib/test/test_logging.py ============================================================================== --- python/branches/py3k/Lib/test/test_logging.py (original) +++ python/branches/py3k/Lib/test/test_logging.py Sun Feb 17 14:31:39 2008 @@ -1,38 +1,1883 @@ #!/usr/bin/env python -# -# Copyright 2001-2004 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, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of Vinay Sajip -# not be used in advertising or publicity pertaining to distribution -# of the software without specific, written prior permission. -# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL -# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# -# This file is part of the Python logging distribution. See -# http://www.red-dove.com/python_logging.html -# -"""Test harness for the logging module. Run all tests. +""" +Test 0 +====== + +Some preliminaries: +>>> import sys +>>> import logging +>>> def nextmessage(): +... global msgcount +... rv = "Message %d" % msgcount +... msgcount = msgcount + 1 +... return rv + +Set a few variables, then go through the logger autoconfig and set the default threshold. +>>> msgcount = 0 +>>> FINISH_UP = "Finish up, it's closing time. Messages should bear numbers 0 through 24." +>>> logging.basicConfig(stream=sys.stdout) +>>> rootLogger = logging.getLogger("") +>>> rootLogger.setLevel(logging.DEBUG) + +Now, create a bunch of loggers, and set their thresholds. +>>> ERR = logging.getLogger("ERR0") +>>> ERR.setLevel(logging.ERROR) +>>> INF = logging.getLogger("INFO0") +>>> INF.setLevel(logging.INFO) +>>> INF_ERR = logging.getLogger("INFO0.ERR") +>>> INF_ERR.setLevel(logging.ERROR) +>>> DEB = logging.getLogger("DEB0") +>>> DEB.setLevel(logging.DEBUG) +>>> INF_UNDEF = logging.getLogger("INFO0.UNDEF") +>>> INF_ERR_UNDEF = logging.getLogger("INFO0.ERR.UNDEF") +>>> UNDEF = logging.getLogger("UNDEF0") +>>> GRANDCHILD = logging.getLogger("INFO0.BADPARENT.UNDEF") +>>> CHILD = logging.getLogger("INFO0.BADPARENT") + + +And finally, run all the tests. + +>>> ERR.log(logging.FATAL, nextmessage()) +CRITICAL:ERR0:Message 0 + +>>> ERR.error(nextmessage()) +ERROR:ERR0:Message 1 + +>>> INF.log(logging.FATAL, nextmessage()) +CRITICAL:INFO0:Message 2 + +>>> INF.error(nextmessage()) +ERROR:INFO0:Message 3 + +>>> INF.warn(nextmessage()) +WARNING:INFO0:Message 4 + +>>> INF.info(nextmessage()) +INFO:INFO0:Message 5 + +>>> INF_UNDEF.log(logging.FATAL, nextmessage()) +CRITICAL:INFO0.UNDEF:Message 6 + +>>> INF_UNDEF.error(nextmessage()) +ERROR:INFO0.UNDEF:Message 7 + +>>> INF_UNDEF.warn (nextmessage()) +WARNING:INFO0.UNDEF:Message 8 + +>>> INF_UNDEF.info (nextmessage()) +INFO:INFO0.UNDEF:Message 9 + +>>> INF_ERR.log(logging.FATAL, nextmessage()) +CRITICAL:INFO0.ERR:Message 10 + +>>> INF_ERR.error(nextmessage()) +ERROR:INFO0.ERR:Message 11 + +>>> INF_ERR_UNDEF.log(logging.FATAL, nextmessage()) +CRITICAL:INFO0.ERR.UNDEF:Message 12 + +>>> INF_ERR_UNDEF.error(nextmessage()) +ERROR:INFO0.ERR.UNDEF:Message 13 + +>>> DEB.log(logging.FATAL, nextmessage()) +CRITICAL:DEB0:Message 14 + +>>> DEB.error(nextmessage()) +ERROR:DEB0:Message 15 + +>>> DEB.warn (nextmessage()) +WARNING:DEB0:Message 16 + +>>> DEB.info (nextmessage()) +INFO:DEB0:Message 17 + +>>> DEB.debug(nextmessage()) +DEBUG:DEB0:Message 18 + +>>> UNDEF.log(logging.FATAL, nextmessage()) +CRITICAL:UNDEF0:Message 19 + +>>> UNDEF.error(nextmessage()) +ERROR:UNDEF0:Message 20 + +>>> UNDEF.warn (nextmessage()) +WARNING:UNDEF0:Message 21 + +>>> UNDEF.info (nextmessage()) +INFO:UNDEF0:Message 22 + +>>> GRANDCHILD.log(logging.FATAL, nextmessage()) +CRITICAL:INFO0.BADPARENT.UNDEF:Message 23 + +>>> CHILD.log(logging.FATAL, nextmessage()) +CRITICAL:INFO0.BADPARENT:Message 24 + +These should not log: + +>>> ERR.warn(nextmessage()) + +>>> ERR.info(nextmessage()) + +>>> ERR.debug(nextmessage()) + +>>> INF.debug(nextmessage()) + +>>> INF_UNDEF.debug(nextmessage()) + +>>> INF_ERR.warn(nextmessage()) + +>>> INF_ERR.info(nextmessage()) + +>>> INF_ERR.debug(nextmessage()) + +>>> INF_ERR_UNDEF.warn(nextmessage()) + +>>> INF_ERR_UNDEF.info(nextmessage()) + +>>> INF_ERR_UNDEF.debug(nextmessage()) + +>>> INF.info(FINISH_UP) +INFO:INFO0:Finish up, it's closing time. Messages should bear numbers 0 through 24. + +Test 1 +====== + +>>> import sys, logging +>>> logging.basicConfig(stream=sys.stdout) + +First, we define our levels. There can be as many as you want - the only +limitations are that they should be integers, the lowest should be > 0 and +larger values mean less information being logged. If you need specific +level values which do not fit into these limitations, you can use a +mapping dictionary to convert between your application levels and the +logging system. + +>>> SILENT = 10 +>>> TACITURN = 9 +>>> TERSE = 8 +>>> EFFUSIVE = 7 +>>> SOCIABLE = 6 +>>> VERBOSE = 5 +>>> TALKATIVE = 4 +>>> GARRULOUS = 3 +>>> CHATTERBOX = 2 +>>> BORING = 1 +>>> LEVEL_RANGE = range(BORING, SILENT + 1) + + +Next, we define names for our levels. You don't need to do this - in which + case the system will use "Level n" to denote the text for the level. +' + + +>>> my_logging_levels = { +... SILENT : 'SILENT', +... TACITURN : 'TACITURN', +... TERSE : 'TERSE', +... EFFUSIVE : 'EFFUSIVE', +... SOCIABLE : 'SOCIABLE', +... VERBOSE : 'VERBOSE', +... TALKATIVE : 'TALKATIVE', +... GARRULOUS : 'GARRULOUS', +... CHATTERBOX : 'CHATTERBOX', +... BORING : 'BORING', +... } + + +Now, to demonstrate filtering: suppose for some perverse reason we only +want to print out all except GARRULOUS messages. We create a filter for +this purpose... + +>>> class SpecificLevelFilter(logging.Filter): +... def __init__(self, lvl): +... self.level = lvl +... +... def filter(self, record): +... return self.level != record.levelno + +>>> class GarrulousFilter(SpecificLevelFilter): +... def __init__(self): +... SpecificLevelFilter.__init__(self, GARRULOUS) + + +Now, demonstrate filtering at the logger. This time, use a filter +which excludes SOCIABLE and TACITURN messages. Note that GARRULOUS events +are still excluded. + + +>>> class VerySpecificFilter(logging.Filter): +... def filter(self, record): +... return record.levelno not in [SOCIABLE, TACITURN] + +>>> SHOULD1 = "This should only be seen at the '%s' logging level (or lower)" + +Configure the logger, and tell the logging system to associate names with our levels. +>>> logging.basicConfig(stream=sys.stdout) +>>> rootLogger = logging.getLogger("") +>>> rootLogger.setLevel(logging.DEBUG) +>>> for lvl in my_logging_levels.keys(): +... logging.addLevelName(lvl, my_logging_levels[lvl]) +>>> log = logging.getLogger("") +>>> hdlr = log.handlers[0] +>>> from test.test_logging import message + +Set the logging level to each different value and call the utility +function to log events. In the output, you should see that each time +round the loop, the number of logging events which are actually output +decreases. + +>>> log.setLevel(1) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) +BORING:root:This should only be seen at the '1' logging level (or lower) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) +CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) +GARRULOUS:root:This should only be seen at the '3' logging level (or lower) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(2) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) +CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) +GARRULOUS:root:This should only be seen at the '3' logging level (or lower) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(3) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) +GARRULOUS:root:This should only be seen at the '3' logging level (or lower) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(4) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(5) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + + +>>> log.setLevel(6) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(7) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(8) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(9) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(10) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> hdlr.setLevel(SOCIABLE) + +>>> log.setLevel(1) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(2) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(3) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(4) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(5) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(6) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(7) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(8) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(9) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(10) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> + +>>> hdlr.setLevel(0) + +>>> garr = GarrulousFilter() + +>>> hdlr.addFilter(garr) + +>>> log.setLevel(1) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) +BORING:root:This should only be seen at the '1' logging level (or lower) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) +CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(2) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) +CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(3) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(4) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(5) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.setLevel(6) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) +SOCIABLE:root:This should only be seen at the '6' logging level (or lower) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(7) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(8) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(9) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) +TACITURN:root:This should only be seen at the '9' logging level (or lower) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(10) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> spec = VerySpecificFilter() + +>>> log.addFilter(spec) + +>>> log.setLevel(1) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) +BORING:root:This should only be seen at the '1' logging level (or lower) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) +CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(2) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) +CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(3) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(4) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) +TALKATIVE:root:This should only be seen at the '4' logging level (or lower) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(5) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) +VERBOSE:root:This should only be seen at the '5' logging level (or lower) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(6) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(7) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) +EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) -Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved. -""" +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(8) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) +TERSE:root:This should only be seen at the '8' logging level (or lower) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(9) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(10) + +>>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) + +>>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) + +>>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) + +>>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) + +>>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) + +>>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) + +>>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) + +>>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) + +>>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) + +>>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) +SILENT:root:This should only be seen at the '10' logging level (or lower) + +>>> log.setLevel(0) + +>>> log.removeFilter(spec) + +>>> hdlr.removeFilter(garr) + +>>> logging.addLevelName(logging.DEBUG, "DEBUG") + + +Test 2 +====== +Test memory handlers. These are basically buffers for log messages: they take so many messages, and then print them all. + +>>> import logging.handlers + +>>> sys.stderr = sys.stdout +>>> logger = logging.getLogger("") +>>> sh = logger.handlers[0] +>>> sh.close() +>>> logger.removeHandler(sh) +>>> mh = logging.handlers.MemoryHandler(10,logging.WARNING, sh) +>>> logger.setLevel(logging.DEBUG) +>>> logger.addHandler(mh) + +>>> logger.debug("Debug message") + +-- logging at INFO, nothing should be seen yet -- + +>>> logger.info("Info message") + +-- logging at WARNING, 3 messages should be seen -- + +>>> logger.warn("Warn message") +DEBUG:root:Debug message +INFO:root:Info message +WARNING:root:Warn message + +>>> logger.info("Info index = 0") + +>>> logger.info("Info index = 1") + +>>> logger.info("Info index = 2") + +>>> logger.info("Info index = 3") + +>>> logger.info("Info index = 4") + +>>> logger.info("Info index = 5") + +>>> logger.info("Info index = 6") + +>>> logger.info("Info index = 7") + +>>> logger.info("Info index = 8") + +>>> logger.info("Info index = 9") +INFO:root:Info index = 0 +INFO:root:Info index = 1 +INFO:root:Info index = 2 +INFO:root:Info index = 3 +INFO:root:Info index = 4 +INFO:root:Info index = 5 +INFO:root:Info index = 6 +INFO:root:Info index = 7 +INFO:root:Info index = 8 +INFO:root:Info index = 9 + +>>> logger.info("Info index = 10") + +>>> logger.info("Info index = 11") + +>>> logger.info("Info index = 12") + +>>> logger.info("Info index = 13") + +>>> logger.info("Info index = 14") + +>>> logger.info("Info index = 15") + +>>> logger.info("Info index = 16") + +>>> logger.info("Info index = 17") + +>>> logger.info("Info index = 18") + +>>> logger.info("Info index = 19") +INFO:root:Info index = 10 +INFO:root:Info index = 11 +INFO:root:Info index = 12 +INFO:root:Info index = 13 +INFO:root:Info index = 14 +INFO:root:Info index = 15 +INFO:root:Info index = 16 +INFO:root:Info index = 17 +INFO:root:Info index = 18 +INFO:root:Info index = 19 + +>>> logger.info("Info index = 20") + +>>> logger.info("Info index = 21") + +>>> logger.info("Info index = 22") + +>>> logger.info("Info index = 23") + +>>> logger.info("Info index = 24") + +>>> logger.info("Info index = 25") + +>>> logger.info("Info index = 26") + +>>> logger.info("Info index = 27") + +>>> logger.info("Info index = 28") + +>>> logger.info("Info index = 29") +INFO:root:Info index = 20 +INFO:root:Info index = 21 +INFO:root:Info index = 22 +INFO:root:Info index = 23 +INFO:root:Info index = 24 +INFO:root:Info index = 25 +INFO:root:Info index = 26 +INFO:root:Info index = 27 +INFO:root:Info index = 28 +INFO:root:Info index = 29 + +>>> logger.info("Info index = 30") + +>>> logger.info("Info index = 31") + +>>> logger.info("Info index = 32") + +>>> logger.info("Info index = 33") + +>>> logger.info("Info index = 34") + +>>> logger.info("Info index = 35") + +>>> logger.info("Info index = 36") + +>>> logger.info("Info index = 37") + +>>> logger.info("Info index = 38") + +>>> logger.info("Info index = 39") +INFO:root:Info index = 30 +INFO:root:Info index = 31 +INFO:root:Info index = 32 +INFO:root:Info index = 33 +INFO:root:Info index = 34 +INFO:root:Info index = 35 +INFO:root:Info index = 36 +INFO:root:Info index = 37 +INFO:root:Info index = 38 +INFO:root:Info index = 39 + +>>> logger.info("Info index = 40") + +>>> logger.info("Info index = 41") + +>>> logger.info("Info index = 42") + +>>> logger.info("Info index = 43") + +>>> logger.info("Info index = 44") + +>>> logger.info("Info index = 45") + +>>> logger.info("Info index = 46") + +>>> logger.info("Info index = 47") + +>>> logger.info("Info index = 48") + +>>> logger.info("Info index = 49") +INFO:root:Info index = 40 +INFO:root:Info index = 41 +INFO:root:Info index = 42 +INFO:root:Info index = 43 +INFO:root:Info index = 44 +INFO:root:Info index = 45 +INFO:root:Info index = 46 +INFO:root:Info index = 47 +INFO:root:Info index = 48 +INFO:root:Info index = 49 + +>>> logger.info("Info index = 50") + +>>> logger.info("Info index = 51") + +>>> logger.info("Info index = 52") + +>>> logger.info("Info index = 53") + +>>> logger.info("Info index = 54") + +>>> logger.info("Info index = 55") + +>>> logger.info("Info index = 56") + +>>> logger.info("Info index = 57") + +>>> logger.info("Info index = 58") + +>>> logger.info("Info index = 59") +INFO:root:Info index = 50 +INFO:root:Info index = 51 +INFO:root:Info index = 52 +INFO:root:Info index = 53 +INFO:root:Info index = 54 +INFO:root:Info index = 55 +INFO:root:Info index = 56 +INFO:root:Info index = 57 +INFO:root:Info index = 58 +INFO:root:Info index = 59 + +>>> logger.info("Info index = 60") + +>>> logger.info("Info index = 61") + +>>> logger.info("Info index = 62") + +>>> logger.info("Info index = 63") + +>>> logger.info("Info index = 64") + +>>> logger.info("Info index = 65") + +>>> logger.info("Info index = 66") + +>>> logger.info("Info index = 67") + +>>> logger.info("Info index = 68") + +>>> logger.info("Info index = 69") +INFO:root:Info index = 60 +INFO:root:Info index = 61 +INFO:root:Info index = 62 +INFO:root:Info index = 63 +INFO:root:Info index = 64 +INFO:root:Info index = 65 +INFO:root:Info index = 66 +INFO:root:Info index = 67 +INFO:root:Info index = 68 +INFO:root:Info index = 69 + +>>> logger.info("Info index = 70") + +>>> logger.info("Info index = 71") + +>>> logger.info("Info index = 72") + +>>> logger.info("Info index = 73") + +>>> logger.info("Info index = 74") + +>>> logger.info("Info index = 75") + +>>> logger.info("Info index = 76") + +>>> logger.info("Info index = 77") + +>>> logger.info("Info index = 78") +>>> logger.info("Info index = 79") +INFO:root:Info index = 70 +INFO:root:Info index = 71 +INFO:root:Info index = 72 +INFO:root:Info index = 73 +INFO:root:Info index = 74 +INFO:root:Info index = 75 +INFO:root:Info index = 76 +INFO:root:Info index = 77 +INFO:root:Info index = 78 +INFO:root:Info index = 79 + +>>> logger.info("Info index = 80") + +>>> logger.info("Info index = 81") + +>>> logger.info("Info index = 82") + +>>> logger.info("Info index = 83") + +>>> logger.info("Info index = 84") + +>>> logger.info("Info index = 85") + +>>> logger.info("Info index = 86") + +>>> logger.info("Info index = 87") + +>>> logger.info("Info index = 88") + +>>> logger.info("Info index = 89") +INFO:root:Info index = 80 +INFO:root:Info index = 81 +INFO:root:Info index = 82 +INFO:root:Info index = 83 +INFO:root:Info index = 84 +INFO:root:Info index = 85 +INFO:root:Info index = 86 +INFO:root:Info index = 87 +INFO:root:Info index = 88 +INFO:root:Info index = 89 + +>>> logger.info("Info index = 90") + +>>> logger.info("Info index = 91") + +>>> logger.info("Info index = 92") + +>>> logger.info("Info index = 93") + +>>> logger.info("Info index = 94") + +>>> logger.info("Info index = 95") + +>>> logger.info("Info index = 96") + +>>> logger.info("Info index = 97") + +>>> logger.info("Info index = 98") + +>>> logger.info("Info index = 99") +INFO:root:Info index = 90 +INFO:root:Info index = 91 +INFO:root:Info index = 92 +INFO:root:Info index = 93 +INFO:root:Info index = 94 +INFO:root:Info index = 95 +INFO:root:Info index = 96 +INFO:root:Info index = 97 +INFO:root:Info index = 98 +INFO:root:Info index = 99 + +>>> logger.info("Info index = 100") + +>>> logger.info("Info index = 101") + +>>> mh.close() +INFO:root:Info index = 100 +INFO:root:Info index = 101 + +>>> logger.removeHandler(mh) +>>> logger.addHandler(sh) + + + +Test 3 +====== + +>>> import sys, logging +>>> sys.stderr = sys +>>> logging.basicConfig() +>>> FILTER = "a.b" +>>> root = logging.getLogger() +>>> root.setLevel(logging.DEBUG) +>>> hand = root.handlers[0] + +>>> logging.getLogger("a").info("Info 1") +INFO:a:Info 1 + +>>> logging.getLogger("a.b").info("Info 2") +INFO:a.b:Info 2 + +>>> logging.getLogger("a.c").info("Info 3") +INFO:a.c:Info 3 + +>>> logging.getLogger("a.b.c").info("Info 4") +INFO:a.b.c:Info 4 + +>>> logging.getLogger("a.b.c.d").info("Info 5") +INFO:a.b.c.d:Info 5 + +>>> logging.getLogger("a.bb.c").info("Info 6") +INFO:a.bb.c:Info 6 + +>>> logging.getLogger("b").info("Info 7") +INFO:b:Info 7 + +>>> logging.getLogger("b.a").info("Info 8") +INFO:b.a:Info 8 + +>>> logging.getLogger("c.a.b").info("Info 9") +INFO:c.a.b:Info 9 + +>>> logging.getLogger("a.bb").info("Info 10") +INFO:a.bb:Info 10 + +Filtered with 'a.b'... + +>>> filt = logging.Filter(FILTER) + +>>> hand.addFilter(filt) + +>>> logging.getLogger("a").info("Info 1") + +>>> logging.getLogger("a.b").info("Info 2") +INFO:a.b:Info 2 + +>>> logging.getLogger("a.c").info("Info 3") + +>>> logging.getLogger("a.b.c").info("Info 4") +INFO:a.b.c:Info 4 + +>>> logging.getLogger("a.b.c.d").info("Info 5") +INFO:a.b.c.d:Info 5 + +>>> logging.getLogger("a.bb.c").info("Info 6") + +>>> logging.getLogger("b").info("Info 7") + +>>> logging.getLogger("b.a").info("Info 8") + +>>> logging.getLogger("c.a.b").info("Info 9") + +>>> logging.getLogger("a.bb").info("Info 10") + +>>> hand.removeFilter(filt) + + +Test 4 +====== +>>> import sys, logging, logging.handlers, string +>>> import tempfile, logging.config, os, test.test_support +>>> sys.stderr = sys.stdout + +>>> from test.test_logging import config0, config1 + +config2 has a subtle configuration error that should be reported +>>> config2 = config1.replace("sys.stdout", "sys.stbout") + +config3 has a less subtle configuration error +>>> config3 = config1.replace("formatter=form1", "formatter=misspelled_name") + +>>> def test4(conf): +... loggerDict = logging.getLogger().manager.loggerDict +... logging._acquireLock() +... try: +... saved_handlers = logging._handlers.copy() +... saved_handler_list = logging._handlerList[:] +... saved_loggers = loggerDict.copy() +... finally: +... logging._releaseLock() +... try: +... fn = test.test_support.TESTFN +... f = open(fn, "w") +... f.write(conf) +... f.close() +... try: +... logging.config.fileConfig(fn) +... #call again to make sure cleanup is correct +... logging.config.fileConfig(fn) +... except: +... t = sys.exc_info()[0] +... message(str(t)) +... else: +... message('ok.') +... os.remove(fn) +... finally: +... logging._acquireLock() +... try: +... logging._handlers.clear() +... logging._handlers.update(saved_handlers) +... logging._handlerList[:] = saved_handler_list +... loggerDict = logging.getLogger().manager.loggerDict +... loggerDict.clear() +... loggerDict.update(saved_loggers) +... finally: +... logging._releaseLock() + +>>> test4(config0) +ok. + +>>> test4(config1) +ok. + +>>> test4(config2) + + +>>> test4(config3) + + +>>> from test import test_logging +>>> test_logging.test5() +ERROR:root:just testing +... Don't panic! + + +Test Main +========= +>>> import select +>>> import os, sys, string, struct, types, pickle, io +>>> import socket, tempfile, threading, time +>>> import logging, logging.handlers, logging.config +>>> from test import test_logging + +XXX: The test is unstable! +#>>> test_logging.test_main_inner() +ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) +ERR -> ERROR: Message 1 (via logrecv.tcp.ERR) +INF -> CRITICAL: Message 2 (via logrecv.tcp.INF) +INF -> ERROR: Message 3 (via logrecv.tcp.INF) +INF -> WARNING: Message 4 (via logrecv.tcp.INF) +INF -> INFO: Message 5 (via logrecv.tcp.INF) +INF.UNDEF -> CRITICAL: Message 6 (via logrecv.tcp.INF.UNDEF) +INF.UNDEF -> ERROR: Message 7 (via logrecv.tcp.INF.UNDEF) +INF.UNDEF -> WARNING: Message 8 (via logrecv.tcp.INF.UNDEF) +INF.UNDEF -> INFO: Message 9 (via logrecv.tcp.INF.UNDEF) +INF.ERR -> CRITICAL: Message 10 (via logrecv.tcp.INF.ERR) +INF.ERR -> ERROR: Message 11 (via logrecv.tcp.INF.ERR) +INF.ERR.UNDEF -> CRITICAL: Message 12 (via logrecv.tcp.INF.ERR.UNDEF) +INF.ERR.UNDEF -> ERROR: Message 13 (via logrecv.tcp.INF.ERR.UNDEF) +DEB -> CRITICAL: Message 14 (via logrecv.tcp.DEB) +DEB -> ERROR: Message 15 (via logrecv.tcp.DEB) +DEB -> WARNING: Message 16 (via logrecv.tcp.DEB) +DEB -> INFO: Message 17 (via logrecv.tcp.DEB) +DEB -> DEBUG: Message 18 (via logrecv.tcp.DEB) +UNDEF -> CRITICAL: Message 19 (via logrecv.tcp.UNDEF) +UNDEF -> ERROR: Message 20 (via logrecv.tcp.UNDEF) +UNDEF -> WARNING: Message 21 (via logrecv.tcp.UNDEF) +UNDEF -> INFO: Message 22 (via logrecv.tcp.UNDEF) +INF.BADPARENT.UNDEF -> CRITICAL: Message 23 (via logrecv.tcp.INF.BADPARENT.UNDEF) +INF.BADPARENT -> CRITICAL: Message 24 (via logrecv.tcp.INF.BADPARENT) +INF -> INFO: Finish up, it's closing time. Messages should bear numbers 0 through 24. (via logrecv.tcp.INF) + +""" import select import os, sys, struct, pickle, io import socket, tempfile, threading, time -import logging, logging.handlers, logging.config -from test.test_support import run_with_locale +import logging, logging.handlers, logging.config, test.test_support + BANNER = "-- %-10s %-6s ---------------------------------------------------\n" FINISH_UP = "Finish up, it's closing time. Messages should bear numbers 0 through 24." +#---------------------------------------------------------------------------- +# Test 0 +#---------------------------------------------------------------------------- + +msgcount = 0 + +def nextmessage(): + global msgcount + rv = "Message %d" % msgcount + msgcount = msgcount + 1 + return rv #---------------------------------------------------------------------------- # Log receiver @@ -78,11 +1923,80 @@ if record.msg == FINISH_UP: self.server.abort = 1 record.msg = record.msg + " (via " + logname + ")" - logger = logging.getLogger(logname) + logger = logging.getLogger("logrecv") logger.handle(record) -# The server sets socketDataProcessed when it's done. -socketDataProcessed = threading.Event() +# The server sets socketDataProcessed when it's done. +socketDataProcessed = threading.Event() +#---------------------------------------------------------------------------- +# Test 5 +#---------------------------------------------------------------------------- + +test5_config = """ +[loggers] +keys=root + +[handlers] +keys=hand1 + +[formatters] +keys=form1 + +[logger_root] +level=NOTSET +handlers=hand1 + +[handler_hand1] +class=StreamHandler +level=NOTSET +formatter=form1 +args=(sys.stdout,) + +[formatter_form1] +class=test.test_logging.FriendlyFormatter +format=%(levelname)s:%(name)s:%(message)s +datefmt= +""" + +class FriendlyFormatter (logging.Formatter): + def formatException(self, ei): + return "%s... Don't panic!" % str(ei[0]) + + +def test5(): + loggerDict = logging.getLogger().manager.loggerDict + logging._acquireLock() + try: + saved_handlers = logging._handlers.copy() + saved_handler_list = logging._handlerList[:] + saved_loggers = loggerDict.copy() + finally: + logging._releaseLock() + try: + fn = test.test_support.TESTFN + f = open(fn, "w") + f.write(test5_config) + f.close() + logging.config.fileConfig(fn) + try: + raise KeyError + except KeyError: + logging.exception("just testing") + os.remove(fn) + hdlr = logging.getLogger().handlers[0] + logging.getLogger().handlers.remove(hdlr) + finally: + logging._acquireLock() + try: + logging._handlers.clear() + logging._handlers.update(saved_handlers) + logging._handlerList[:] = saved_handler_list + loggerDict = logging.getLogger().manager.loggerDict + loggerDict.clear() + loggerDict.update(saved_loggers) + finally: + logging._releaseLock() + class LogRecordSocketReceiver(ThreadingTCPServer): """ @@ -105,8 +2019,6 @@ self.timeout) if rd: self.handle_request() - #notify the main thread that we're about to exit - socketDataProcessed.set() # close the listen socket self.server_close() @@ -119,17 +2031,10 @@ def runTCP(tcpserver): tcpserver.serve_until_stopped() -#---------------------------------------------------------------------------- -# Test 0 -#---------------------------------------------------------------------------- - -msgcount = 0 - -def nextmessage(): - global msgcount - rv = "Message %d" % msgcount - msgcount = msgcount + 1 - return rv +def banner(nm, typ): + sep = BANNER % (nm, typ) + sys.stdout.write(sep) + sys.stdout.flush() def test0(): ERR = logging.getLogger("ERR") @@ -199,202 +2104,70 @@ INF.info(FINISH_UP) -#---------------------------------------------------------------------------- -# Test 1 -#---------------------------------------------------------------------------- - -# -# First, we define our levels. There can be as many as you want - the only -# limitations are that they should be integers, the lowest should be > 0 and -# larger values mean less information being logged. If you need specific -# level values which do not fit into these limitations, you can use a -# mapping dictionary to convert between your application levels and the -# logging system. -# -SILENT = 10 -TACITURN = 9 -TERSE = 8 -EFFUSIVE = 7 -SOCIABLE = 6 -VERBOSE = 5 -TALKATIVE = 4 -GARRULOUS = 3 -CHATTERBOX = 2 -BORING = 1 - -LEVEL_RANGE = range(BORING, SILENT + 1) - -# -# Next, we define names for our levels. You don't need to do this - in which -# case the system will use "Level n" to denote the text for the level. -# -my_logging_levels = { - SILENT : 'Silent', - TACITURN : 'Taciturn', - TERSE : 'Terse', - EFFUSIVE : 'Effusive', - SOCIABLE : 'Sociable', - VERBOSE : 'Verbose', - TALKATIVE : 'Talkative', - GARRULOUS : 'Garrulous', - CHATTERBOX : 'Chatterbox', - BORING : 'Boring', -} - -# -# Now, to demonstrate filtering: suppose for some perverse reason we only -# want to print out all except GARRULOUS messages. Let's create a filter for -# this purpose... -# -class SpecificLevelFilter(logging.Filter): - def __init__(self, lvl): - self.level = lvl - - def filter(self, record): - return self.level != record.levelno - -class GarrulousFilter(SpecificLevelFilter): - def __init__(self): - SpecificLevelFilter.__init__(self, GARRULOUS) - -# -# Now, let's demonstrate filtering at the logger. This time, use a filter -# which excludes SOCIABLE and TACITURN messages. Note that GARRULOUS events -# are still excluded. -# -class VerySpecificFilter(logging.Filter): - def filter(self, record): - return record.levelno not in [SOCIABLE, TACITURN] - -def message(s): - sys.stdout.write("%s\n" % s) +def test_main_inner(): + rootLogger = logging.getLogger("") + rootLogger.setLevel(logging.DEBUG) -SHOULD1 = "This should only be seen at the '%s' logging level (or lower)" + # Find an unused port number + port = logging.handlers.DEFAULT_TCP_LOGGING_PORT + while port < logging.handlers.DEFAULT_TCP_LOGGING_PORT+100: + try: + tcpserver = LogRecordSocketReceiver(port=port) + except socket.error: + port += 1 + else: + break + else: + raise ImportError("Could not find unused port") -def test1(): -# -# Now, tell the logging system to associate names with our levels. -# - for lvl in my_logging_levels.keys(): - logging.addLevelName(lvl, my_logging_levels[lvl]) - -# -# Now, define a test function which logs an event at each of our levels. -# - - def doLog(log): - for lvl in LEVEL_RANGE: - log.log(lvl, SHOULD1, logging.getLevelName(lvl)) - - log = logging.getLogger("") - hdlr = log.handlers[0] -# -# Set the logging level to each different value and call the utility -# function to log events. -# In the output, you should see that each time round the loop, the number of -# logging events which are actually output decreases. -# - for lvl in LEVEL_RANGE: - message("-- setting logging level to '%s' -----" % - logging.getLevelName(lvl)) - log.setLevel(lvl) - doLog(log) - # - # Now, we demonstrate level filtering at the handler level. Tell the - # handler defined above to filter at level 'SOCIABLE', and repeat the - # above loop. Compare the output from the two runs. - # - hdlr.setLevel(SOCIABLE) - message("-- Filtering at handler level to SOCIABLE --") - for lvl in LEVEL_RANGE: - message("-- setting logging level to '%s' -----" % - logging.getLevelName(lvl)) - log.setLevel(lvl) - doLog(log) - - hdlr.setLevel(0) #turn off level filtering at the handler - - garr = GarrulousFilter() - hdlr.addFilter(garr) - message("-- Filtering using GARRULOUS filter --") - for lvl in LEVEL_RANGE: - message("-- setting logging level to '%s' -----" % - logging.getLevelName(lvl)) - log.setLevel(lvl) - doLog(log) - spec = VerySpecificFilter() - log.addFilter(spec) - message("-- Filtering using specific filter for SOCIABLE, TACITURN --") - for lvl in LEVEL_RANGE: - message("-- setting logging level to '%s' -----" % - logging.getLevelName(lvl)) - log.setLevel(lvl) - doLog(log) - - log.removeFilter(spec) - hdlr.removeFilter(garr) - #Undo the one level which clashes...for regression tests - logging.addLevelName(logging.DEBUG, "DEBUG") -#---------------------------------------------------------------------------- -# Test 2 -#---------------------------------------------------------------------------- + #Set up a handler such that all events are sent via a socket to the log + #receiver (logrecv). + #The handler will only be added to the rootLogger for some of the tests + shdlr = logging.handlers.SocketHandler('localhost', port) + rootLogger.addHandler(shdlr) -MSG = "-- logging %d at INFO, messages should be seen every 10 events --" -def test2(): - logger = logging.getLogger("") - sh = logger.handlers[0] - sh.close() - logger.removeHandler(sh) - mh = logging.handlers.MemoryHandler(10,logging.WARNING, sh) - logger.setLevel(logging.DEBUG) - logger.addHandler(mh) - message("-- logging at DEBUG, nothing should be seen yet --") - logger.debug("Debug message") - message("-- logging at INFO, nothing should be seen yet --") - logger.info("Info message") - message("-- logging at WARNING, 3 messages should be seen --") - logger.warn("Warn message") - for i in range(102): - message(MSG % i) - logger.info("Info index = %d", i) - mh.close() - logger.removeHandler(mh) - logger.addHandler(sh) + #Configure the logger for logrecv so events do not propagate beyond it. + #The sockLogger output is buffered in memory until the end of the test, + #and printed at the end. + sockOut = io.StringIO() + sockLogger = logging.getLogger("logrecv") + sockLogger.setLevel(logging.DEBUG) + sockhdlr = logging.StreamHandler(sockOut) + sockhdlr.setFormatter(logging.Formatter( + "%(name)s -> %(levelname)s: %(message)s")) + sockLogger.addHandler(sockhdlr) + sockLogger.propagate = 0 -#---------------------------------------------------------------------------- -# Test 3 -#---------------------------------------------------------------------------- + #Set up servers + threads = [] + #sys.stdout.write("About to start TCP server...\n") + threads.append(threading.Thread(target=runTCP, args=(tcpserver,))) -FILTER = "a.b" + for thread in threads: + thread.start() + try: + test0() -def doLog3(): - logging.getLogger("a").info("Info 1") - logging.getLogger("a.b").info("Info 2") - logging.getLogger("a.c").info("Info 3") - logging.getLogger("a.b.c").info("Info 4") - logging.getLogger("a.b.c.d").info("Info 5") - logging.getLogger("a.bb.c").info("Info 6") - logging.getLogger("b").info("Info 7") - logging.getLogger("b.a").info("Info 8") - logging.getLogger("c.a.b").info("Info 9") - logging.getLogger("a.bb").info("Info 10") - -def test3(): - root = logging.getLogger() - root.setLevel(logging.DEBUG) - hand = root.handlers[0] - message("Unfiltered...") - doLog3() - message("Filtered with '%s'..." % FILTER) - filt = logging.Filter(FILTER) - hand.addFilter(filt) - doLog3() - hand.removeFilter(filt) + # XXX(nnorwitz): Try to fix timing related test failures. + # This sleep gives us some extra time to read messages. + # The test generally only fails on Solaris without this sleep. + #time.sleep(2.0) + shdlr.close() + rootLogger.removeHandler(shdlr) -#---------------------------------------------------------------------------- -# Test 4 -#---------------------------------------------------------------------------- + finally: + #wait for TCP receiver to terminate +# socketDataProcessed.wait() + # ensure the server dies + tcpserver.abort = 1 + for thread in threads: + thread.join(2.0) + print(sockOut.getvalue()) + sockOut.close() + sockLogger.removeHandler(sockhdlr) + sockhdlr.close() + sys.stdout.flush() # config0 is a standard configuration. config0 = """ @@ -454,231 +2227,18 @@ datefmt= """ +def message(s): + sys.stdout.write("%s\n" % s) + # config2 has a subtle configuration error that should be reported config2 = config1.replace("sys.stdout", "sys.stbout") # config3 has a less subtle configuration error config3 = config1.replace("formatter=form1", "formatter=misspelled_name") -def test4(): - for i in range(4): - conf = globals()['config%d' % i] - sys.stdout.write('config%d: ' % i) - loggerDict = logging.getLogger().manager.loggerDict - logging._acquireLock() - try: - saved_handlers = logging._handlers.copy() - saved_handler_list = logging._handlerList[:] - saved_loggers = loggerDict.copy() - finally: - logging._releaseLock() - try: - fn = tempfile.mktemp(".ini") - f = open(fn, "w") - f.write(conf) - f.close() - try: - logging.config.fileConfig(fn) - #call again to make sure cleanup is correct - logging.config.fileConfig(fn) - except: - t = sys.exc_info()[0] - message(str(t)) - else: - message('ok.') - os.remove(fn) - finally: - logging._acquireLock() - try: - logging._handlers.clear() - logging._handlers.update(saved_handlers) - logging._handlerList[:] = saved_handler_list - loggerDict = logging.getLogger().manager.loggerDict - loggerDict.clear() - loggerDict.update(saved_loggers) - finally: - logging._releaseLock() - -#---------------------------------------------------------------------------- -# Test 5 -#---------------------------------------------------------------------------- - -test5_config = """ -[loggers] -keys=root - -[handlers] -keys=hand1 - -[formatters] -keys=form1 - -[logger_root] -level=NOTSET -handlers=hand1 - -[handler_hand1] -class=StreamHandler -level=NOTSET -formatter=form1 -args=(sys.stdout,) - -[formatter_form1] -class=test.test_logging.FriendlyFormatter -format=%(levelname)s:%(name)s:%(message)s -datefmt= -""" - -class FriendlyFormatter (logging.Formatter): - def formatException(self, ei): - return "%s... Don't panic!" % str(ei[0]) - - -def test5(): - loggerDict = logging.getLogger().manager.loggerDict - logging._acquireLock() - try: - saved_handlers = logging._handlers.copy() - saved_handler_list = logging._handlerList[:] - saved_loggers = loggerDict.copy() - finally: - logging._releaseLock() - try: - fn = tempfile.mktemp(".ini") - f = open(fn, "w") - f.write(test5_config) - f.close() - logging.config.fileConfig(fn) - try: - raise KeyError - except KeyError: - logging.exception("just testing") - os.remove(fn) - hdlr = logging.getLogger().handlers[0] - logging.getLogger().handlers.remove(hdlr) - finally: - logging._acquireLock() - try: - logging._handlers.clear() - logging._handlers.update(saved_handlers) - logging._handlerList[:] = saved_handler_list - loggerDict = logging.getLogger().manager.loggerDict - loggerDict.clear() - loggerDict.update(saved_loggers) - finally: - logging._releaseLock() - - -#---------------------------------------------------------------------------- -# Test Harness -#---------------------------------------------------------------------------- -def banner(nm, typ): - sep = BANNER % (nm, typ) - sys.stdout.write(sep) - sys.stdout.flush() - -def test_main_inner(): - rootLogger = logging.getLogger("") - rootLogger.setLevel(logging.DEBUG) - hdlr = logging.StreamHandler(sys.stdout) - fmt = logging.Formatter(logging.BASIC_FORMAT) - hdlr.setFormatter(fmt) - rootLogger.addHandler(hdlr) - - # Find an unused port number - port = logging.handlers.DEFAULT_TCP_LOGGING_PORT - while port < logging.handlers.DEFAULT_TCP_LOGGING_PORT+100: - try: - tcpserver = LogRecordSocketReceiver(port=port) - except socket.error: - port += 1 - else: - break - else: - raise ImportError("Could not find unused port") - - - #Set up a handler such that all events are sent via a socket to the log - #receiver (logrecv). - #The handler will only be added to the rootLogger for some of the tests - shdlr = logging.handlers.SocketHandler('localhost', port) - - #Configure the logger for logrecv so events do not propagate beyond it. - #The sockLogger output is buffered in memory until the end of the test, - #and printed at the end. - sockOut = io.StringIO() - sockLogger = logging.getLogger("logrecv") - sockLogger.setLevel(logging.DEBUG) - sockhdlr = logging.StreamHandler(sockOut) - sockhdlr.setFormatter(logging.Formatter( - "%(name)s -> %(levelname)s: %(message)s")) - sockLogger.addHandler(sockhdlr) - sockLogger.propagate = 0 - - #Set up servers - threads = [] - #sys.stdout.write("About to start TCP server...\n") - threads.append(threading.Thread(target=runTCP, args=(tcpserver,))) - - for thread in threads: - thread.start() - try: - banner("log_test0", "begin") - - rootLogger.addHandler(shdlr) - test0() - # XXX(nnorwitz): Try to fix timing related test failures. - # This sleep gives us some extra time to read messages. - # The test generally only fails on Solaris without this sleep. - time.sleep(2.0) - shdlr.close() - rootLogger.removeHandler(shdlr) - - banner("log_test0", "end") - - for t in range(1,6): - banner("log_test%d" % t, "begin") - globals()['test%d' % t]() - banner("log_test%d" % t, "end") - - finally: - #wait for TCP receiver to terminate - socketDataProcessed.wait() - # ensure the server dies - tcpserver.abort = 1 - for thread in threads: - thread.join(2.0) - banner("logrecv output", "begin") - sys.stdout.write(sockOut.getvalue()) - sockOut.close() - sockLogger.removeHandler(sockhdlr) - sockhdlr.close() - banner("logrecv output", "end") - sys.stdout.flush() - try: - hdlr.close() - except: - pass - rootLogger.removeHandler(hdlr) - -# 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. - at run_with_locale('LC_ALL', '') def test_main(): - # Save and restore the original root logger level across the tests. - # Otherwise, e.g., if any test using cookielib runs after test_logging, - # cookielib's debug-level logger tries to log messages, leading to - # confusing: - # No handlers could be found for logger "cookielib" - # output while the tests are running. - root_logger = logging.getLogger("") - original_logging_level = root_logger.getEffectiveLevel() - try: - test_main_inner() - finally: - root_logger.setLevel(original_logging_level) + from test import test_support, test_logging + test_support.run_doctest(test_logging) -if __name__ == "__main__": - sys.stdout.write("test_logging\n") +if __name__=="__main__": test_main() Modified: python/branches/py3k/Lib/test/test_mmap.py ============================================================================== --- python/branches/py3k/Lib/test/test_mmap.py (original) +++ python/branches/py3k/Lib/test/test_mmap.py Sun Feb 17 14:31:39 2008 @@ -426,6 +426,8 @@ anon_mmap(PAGESIZE) def test_prot_readonly(self): + if not hasattr(mmap, 'PROT_READ'): + return mapsize = 10 open(TESTFN, "wb").write(b"a"*mapsize) f = open(TESTFN, "rb") Modified: python/branches/py3k/Lib/test/test_scope.py ============================================================================== --- python/branches/py3k/Lib/test/test_scope.py (original) +++ python/branches/py3k/Lib/test/test_scope.py Sun Feb 17 14:31:39 2008 @@ -573,6 +573,13 @@ f(4)() + def testFreeingCell(self): + # Test what happens when a finalizer accesses + # the cell where the object was stored. + class Special: + def __del__(self): + nestedcell_get() + def testNonLocalFunction(self): def f(x): Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Sun Feb 17 14:31:39 2008 @@ -709,6 +709,7 @@ Cliff Wells Rickard Westman Jeff Wheeler +Christopher White Mats Wichmann Truida Wiedijk Felix Wiemann Modified: python/branches/py3k/Modules/_struct.c ============================================================================== --- python/branches/py3k/Modules/_struct.c (original) +++ python/branches/py3k/Modules/_struct.c Sun Feb 17 14:31:39 2008 @@ -1486,7 +1486,7 @@ return -1; } - Py_XDECREF(soself->s_format); + Py_CLEAR(soself->s_format); soself->s_format = o_format; ret = prepare_s(soself); Modified: python/branches/py3k/Modules/cStringIO.c ============================================================================== --- python/branches/py3k/Modules/cStringIO.c (original) +++ python/branches/py3k/Modules/cStringIO.c Sun Feb 17 14:31:39 2008 @@ -566,8 +566,7 @@ static PyObject * I_close(Iobject *self, PyObject *unused) { - Py_XDECREF(self->pbuf); - self->pbuf = NULL; + Py_CLEAR(self->pbuf); self->buf = NULL; self->pos = self->string_size = 0; Modified: python/branches/py3k/Objects/cellobject.c ============================================================================== --- python/branches/py3k/Objects/cellobject.c (original) +++ python/branches/py3k/Objects/cellobject.c Sun Feb 17 14:31:39 2008 @@ -31,13 +31,15 @@ int PyCell_Set(PyObject *op, PyObject *obj) { + PyObject* oldobj; if (!PyCell_Check(op)) { PyErr_BadInternalCall(); return -1; } - Py_XDECREF(((PyCellObject*)op)->ob_ref); + oldobj = PyCell_GET(op); Py_XINCREF(obj); PyCell_SET(op, obj); + Py_XDECREF(oldobj); return 0; } From python-3000-checkins at python.org Sun Feb 17 20:48:01 2008 From: python-3000-checkins at python.org (eric.smith) Date: Sun, 17 Feb 2008 20:48:01 +0100 (CET) Subject: [Python-3000-checkins] r60880 - in python/branches/py3k: Include/abstract.h Lib/test/test_builtin.py Lib/test/test_datetime.py Modules/datetimemodule.c Objects/abstract.c Objects/stringlib/formatter.h Objects/stringlib/string_format.h Objects/stringlib/stringdefs.h Objects/stringlib/unicodedefs.h Python/bltinmodule.c Message-ID: <20080217194801.06A421E400A@bag.python.org> Author: eric.smith Date: Sun Feb 17 20:48:00 2008 New Revision: 60880 Modified: python/branches/py3k/Include/abstract.h python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_datetime.py python/branches/py3k/Modules/datetimemodule.c python/branches/py3k/Objects/abstract.c python/branches/py3k/Objects/stringlib/formatter.h python/branches/py3k/Objects/stringlib/string_format.h python/branches/py3k/Objects/stringlib/stringdefs.h python/branches/py3k/Objects/stringlib/unicodedefs.h python/branches/py3k/Python/bltinmodule.c Log: Fixes for shared 2.6 code that implements PEP 3101, advanced string formatting. Includes: - Modifying tests for basic types to use __format__ methods, instead of builtin "format". - Adding PyObject_Format. - General str/unicode cleanup discovered when backporting to 2.6. - Removing datetimemodule.c's time_format, since it was identical to date_format. The files in Objects/stringlib that implement PEP 3101 (stringdefs.h, unicodedefs.h, formatter.h, string_format.h) are identical in trunk and py3k. Any changes from here on should be made to trunk, and changes will propogate to py3k). Modified: python/branches/py3k/Include/abstract.h ============================================================================== --- python/branches/py3k/Include/abstract.h (original) +++ python/branches/py3k/Include/abstract.h Sun Feb 17 20:48:00 2008 @@ -611,6 +611,13 @@ */ + PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj, + PyObject *format_spec); + /* + Takes an arbitrary object and returns the result of + calling obj.__format__(format_spec). + */ + /* Iterators */ PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Sun Feb 17 20:48:00 2008 @@ -541,24 +541,58 @@ self.assertRaises(TypeError, float, Foo4(42)) def test_format(self): - class A: - def __init__(self, x): - self.x = x - def __format__(self, format_spec): - return str(self.x) + format_spec + # Test the basic machinery of the format() builtin. Don't test + # the specifics of the various formatters + self.assertEqual(format(3, ''), '3') - # class that returns a bad type from __format__ - class B: - def __format__(self, format_spec): - return 1.0 + # Returns some classes to use for various tests. There's + # an old-style version, and a new-style version + def classes_new(): + class A(object): + def __init__(self, x): + self.x = x + def __format__(self, format_spec): + return str(self.x) + format_spec + class DerivedFromA(A): + pass - # class that is derived from string, used - # as a format spec - class C(str): - pass + class Simple(object): pass + class DerivedFromSimple(Simple): + def __init__(self, x): + self.x = x + def __format__(self, format_spec): + return str(self.x) + format_spec + class DerivedFromSimple2(DerivedFromSimple): pass + return A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2 + + # In 3.0, classes_classic has the same meaning as classes_new + def classes_classic(): + class A: + def __init__(self, x): + self.x = x + def __format__(self, format_spec): + return str(self.x) + format_spec + class DerivedFromA(A): + pass - self.assertEqual(format(3, ''), '3') - self.assertEqual(format(A(3), 'spec'), '3spec') + class Simple: pass + class DerivedFromSimple(Simple): + def __init__(self, x): + self.x = x + def __format__(self, format_spec): + return str(self.x) + format_spec + class DerivedFromSimple2(DerivedFromSimple): pass + return A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2 + + def class_test(A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2): + self.assertEqual(format(A(3), 'spec'), '3spec') + self.assertEqual(format(DerivedFromA(4), 'spec'), '4spec') + self.assertEqual(format(DerivedFromSimple(5), 'abc'), '5abc') + self.assertEqual(format(DerivedFromSimple2(10), 'abcdef'), + '10abcdef') + + class_test(*classes_new()) + class_test(*classes_classic()) def empty_format_spec(value): # test that: @@ -578,19 +612,28 @@ empty_format_spec(None) # TypeError because self.__format__ returns the wrong type - self.assertRaises(TypeError, format, B(), "") + class BadFormatResult: + def __format__(self, format_spec): + return 1.0 + self.assertRaises(TypeError, format, BadFormatResult(), "") - # TypeError because format_spec is not unicode + # TypeError because format_spec is not unicode or str self.assertRaises(TypeError, format, object(), 4) self.assertRaises(TypeError, format, object(), object()) + # tests for object.__format__ really belong elsewhere, but + # there's no good place to put them + x = object().__format__('') + self.assert_(x.startswith(' strftime() style string.")}, - {"__format__", (PyCFunction)time_format, METH_VARARGS, + {"__format__", (PyCFunction)date_format, METH_VARARGS, PyDoc_STR("Formats self with strftime.")}, {"utcoffset", (PyCFunction)time_utcoffset, METH_NOARGS, Modified: python/branches/py3k/Objects/abstract.c ============================================================================== --- python/branches/py3k/Objects/abstract.c (original) +++ python/branches/py3k/Objects/abstract.c Sun Feb 17 20:48:00 2008 @@ -704,6 +704,57 @@ return 0; } +PyObject * +PyObject_Format(PyObject *obj, PyObject *format_spec) +{ + static PyObject * str__format__ = NULL; + PyObject *meth; + PyObject *empty = NULL; + PyObject *result = NULL; + + /* Initialize cached value */ + if (str__format__ == NULL) { + /* Initialize static variable needed by _PyType_Lookup */ + str__format__ = PyUnicode_FromString("__format__"); + if (str__format__ == NULL) + goto done; + } + + /* If no format_spec is provided, use an empty string */ + if (format_spec == NULL) { + empty = PyUnicode_FromUnicode(NULL, 0); + format_spec = empty; + } + + /* Make sure the type is initialized. float gets initialized late */ + if (Py_TYPE(obj)->tp_dict == NULL) + if (PyType_Ready(Py_TYPE(obj)) < 0) + goto done; + + /* Find the (unbound!) __format__ method (a borrowed reference) */ + meth = _PyType_Lookup(Py_TYPE(obj), str__format__); + if (meth == NULL) { + PyErr_Format(PyExc_TypeError, + "Type %.100s doesn't define __format__", + Py_TYPE(obj)->tp_name); + goto done; + } + + /* And call it, binding it to the value */ + result = PyObject_CallFunctionObjArgs(meth, obj, format_spec, NULL); + + if (result && !PyUnicode_Check(result)) { + PyErr_SetString(PyExc_TypeError, + "__format__ method did not return string"); + Py_DECREF(result); + result = NULL; + goto done; + } + +done: + Py_XDECREF(empty); + return result; +} /* Operations on numbers */ int Modified: python/branches/py3k/Objects/stringlib/formatter.h ============================================================================== --- python/branches/py3k/Objects/stringlib/formatter.h (original) +++ python/branches/py3k/Objects/stringlib/formatter.h Sun Feb 17 20:48:00 2008 @@ -195,7 +195,7 @@ return 1; } - +#if defined FORMAT_FLOAT || defined FORMAT_LONG /************************************************************************/ /*********** common routines for numeric formatting *********************/ /************************************************************************/ @@ -288,7 +288,8 @@ else { /* determine which of left, space, or right padding is needed */ - Py_ssize_t padding = format->width - (r->n_lsign + n_digits + r->n_rsign); + Py_ssize_t padding = format->width - + (r->n_lsign + n_digits + r->n_rsign); if (format->align == '<') r->n_rpadding = padding; else if (format->align == '>') @@ -338,6 +339,7 @@ } return p_digits; } +#endif /* FORMAT_FLOAT || FORMAT_LONG */ /************************************************************************/ /*********** string formatting ******************************************/ @@ -434,18 +436,23 @@ /*********** long formatting ********************************************/ /************************************************************************/ +#if defined FORMAT_LONG || defined FORMAT_INT +typedef PyObject* +(*IntOrLongToString)(PyObject *value, int base); + static PyObject * -format_long_internal(PyObject *value, const InternalFormatSpec *format) +format_int_or_long_internal(PyObject *value, const InternalFormatSpec *format, + IntOrLongToString tostring) { PyObject *result = NULL; - int total_leading_chars_to_skip = 0; /* also includes sign, if - present */ + PyObject *tmp = NULL; + STRINGLIB_CHAR *pnumeric_chars; + STRINGLIB_CHAR numeric_char; STRINGLIB_CHAR sign = '\0'; STRINGLIB_CHAR *p; Py_ssize_t n_digits; /* count of digits need from the computed string */ - Py_ssize_t len; - Py_ssize_t tmp; + Py_ssize_t n_leading_chars; NumberFieldWidths spec; long x; @@ -469,6 +476,7 @@ /* taken from unicodeobject.c formatchar() */ /* Integer input truncated to a character */ +/* XXX: won't work for int */ x = PyLong_AsLong(value); if (x == -1 && PyErr_Occurred()) goto done; @@ -487,115 +495,101 @@ goto done; } #endif - result = STRINGLIB_NEW(NULL, 1); - if (result == NULL) - goto done; - p = STRINGLIB_STR(result); - p[0] = (Py_UNICODE) x; - n_digits = len = 1; + numeric_char = (STRINGLIB_CHAR)x; + pnumeric_chars = &numeric_char; + n_digits = 1; } else { int base; - int format_leading_chars_to_skip; /* characters added by - PyNumber_ToBase that we - want to skip over. - instead of using them, - we'll compute our - own. */ - /* compute the base and how many characters will be added by + int leading_chars_to_skip; /* Number of characters added by + PyNumber_ToBase that we want to + skip over. */ + + /* Compute the base and how many characters will be added by PyNumber_ToBase */ switch (format->type) { case 'b': base = 2; - format_leading_chars_to_skip = 2; /* 0b */ + leading_chars_to_skip = 2; /* 0b */ break; case 'o': base = 8; - format_leading_chars_to_skip = 2; /* 0o */ + leading_chars_to_skip = 2; /* 0o */ break; case 'x': case 'X': base = 16; - format_leading_chars_to_skip = 2; /* 0x */ + leading_chars_to_skip = 2; /* 0x */ break; default: /* shouldn't be needed, but stops a compiler warning */ case 'd': base = 10; - format_leading_chars_to_skip = 0; + leading_chars_to_skip = 0; break; } - /* do the hard part, converting to a string in a given base */ - result = PyNumber_ToBase(value, base); - if (result == NULL) + /* Do the hard part, converting to a string in a given base */ + tmp = tostring(value, base); + if (tmp == NULL) goto done; - n_digits = STRINGLIB_LEN(result); - len = n_digits; - p = STRINGLIB_STR(result); - - /* if X, convert to uppercase */ - if (format->type == 'X') - for (tmp = 0; tmp < len; tmp++) - p[tmp] = STRINGLIB_TOUPPER(p[tmp]); + pnumeric_chars = STRINGLIB_STR(tmp); + n_digits = STRINGLIB_LEN(tmp); + + /* Remember not to modify what pnumeric_chars points to. it + might be interned. Only modify it after we copy it into a + newly allocated output buffer. */ - /* is a sign character present in the output? if so, remember it + /* Is a sign character present in the output? If so, remember it and skip it */ - sign = p[0]; + sign = pnumeric_chars[0]; if (sign == '-') { - total_leading_chars_to_skip += 1; - n_digits--; + ++leading_chars_to_skip; } - /* skip over the leading digits (0x, 0b, etc.) */ - assert(n_digits >= format_leading_chars_to_skip + 1); - n_digits -= format_leading_chars_to_skip; - total_leading_chars_to_skip += format_leading_chars_to_skip; + /* Skip over the leading chars (0x, 0b, etc.) */ + n_digits -= leading_chars_to_skip; + pnumeric_chars += leading_chars_to_skip; } + /* Calculate the widths of the various leading and trailing parts */ calc_number_widths(&spec, sign, n_digits, format); - /* if the buffer is getting bigger, realloc it. if it's getting - smaller, don't realloc because we need to move the results - around first. realloc after we've done that */ - - if (spec.n_total > len) { - if (STRINGLIB_RESIZE(&result, spec.n_total) < 0) - goto done; - /* recalc, because string might have moved */ - p = STRINGLIB_STR(result); - } - - /* copy the characters into position first, since we're going to - overwrite some of that space */ - /* we need to move if the number of left padding in the output is - different from the number of characters we need to skip */ - if ((spec.n_lpadding + spec.n_lsign + spec.n_spadding) != - total_leading_chars_to_skip) { - memmove(p + (spec.n_lpadding + spec.n_lsign + spec.n_spadding), - p + total_leading_chars_to_skip, - n_digits * sizeof(STRINGLIB_CHAR)); + /* Allocate a new string to hold the result */ + result = STRINGLIB_NEW(NULL, spec.n_total); + if (!result) + goto done; + p = STRINGLIB_STR(result); + + /* Fill in the digit parts */ + n_leading_chars = spec.n_lpadding + spec.n_lsign + spec.n_spadding; + memmove(p + n_leading_chars, + pnumeric_chars, + n_digits * sizeof(STRINGLIB_CHAR)); + + /* if X, convert to uppercase */ + if (format->type == 'X') { + Py_ssize_t t; + for (t = 0; t < n_digits; t++) + p[t + n_leading_chars] = STRINGLIB_TOUPPER(p[t + n_leading_chars]); } - /* now fill in the non-digit parts */ + /* Fill in the non-digit parts */ fill_number(p, &spec, n_digits, format->fill_char == '\0' ? ' ' : format->fill_char); - /* if we're getting smaller, realloc now */ - if (spec.n_total < len) { - if (STRINGLIB_RESIZE(&result, spec.n_total) < 0) - goto done; - } - done: + Py_XDECREF(tmp); return result; } - +#endif /* defined FORMAT_LONG || defined FORMAT_INT */ /************************************************************************/ /*********** float formatting *******************************************/ /************************************************************************/ +#ifdef FORMAT_FLOAT +#if STRINGLIB_IS_UNICODE /* taken from unicodeobject.c */ static Py_ssize_t strtounicode(Py_UNICODE *buffer, const char *charbuffer) @@ -607,6 +601,7 @@ return len; } +#endif /* the callback function to call to do the actual float formatting. it matches the definition of PyOS_ascii_formatd */ @@ -694,7 +689,8 @@ /* cast "type", because if we're in unicode we need to pass a 8-bit char. this is safe, because we've restricted what "type" can be */ - PyOS_snprintf(fmt, sizeof(fmt), "%%.%" PY_FORMAT_SIZE_T "d%c", precision, (char)type); + PyOS_snprintf(fmt, sizeof(fmt), "%%.%" PY_FORMAT_SIZE_T "d%c", precision, + (char)type); /* call the passed in function to do the actual formatting */ snprintf(charbuf, sizeof(charbuf), fmt, x); @@ -739,7 +735,8 @@ format->fill_char == '\0' ? ' ' : format->fill_char); /* fill in the digit parts */ - memmove(STRINGLIB_STR(result) + (spec.n_lpadding + spec.n_lsign + spec.n_spadding), + memmove(STRINGLIB_STR(result) + + (spec.n_lpadding + spec.n_lsign + spec.n_spadding), p, n_digits * sizeof(STRINGLIB_CHAR)); @@ -755,20 +752,43 @@ else return _format_float(format->type, value, format, PyOS_ascii_formatd); } +#endif /* FORMAT_FLOAT */ /************************************************************************/ /*********** built in formatters ****************************************/ /************************************************************************/ - +#ifdef FORMAT_STRING PyObject * FORMAT_STRING(PyObject* value, PyObject* args) { PyObject *format_spec; PyObject *result = NULL; +#if PY_VERSION_HEX < 0x03000000 + PyObject *tmp = NULL; +#endif InternalFormatSpec format; - if (!PyArg_ParseTuple(args, STRINGLIB_PARSE_CODE ":__format__", &format_spec)) + /* If 2.x, we accept either str or unicode, and try to convert it + to the right type. In 3.x, we insist on only unicode */ +#if PY_VERSION_HEX >= 0x03000000 + if (!PyArg_ParseTuple(args, STRINGLIB_PARSE_CODE ":__format__", + &format_spec)) goto done; +#else + /* If 2.x, convert format_spec to the same type as value */ + /* This is to allow things like u''.format('') */ + if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) + goto done; + if (!(PyString_Check(format_spec) || PyUnicode_Check(format_spec))) { + PyErr_Format(PyExc_TypeError, "__format__ arg must be str " + "or unicode, not %s", Py_TYPE(format_spec)->tp_name); + goto done; + } + tmp = STRINGLIB_TOSTR(format_spec); + if (tmp == NULL) + goto done; + format_spec = tmp; +#endif /* check for the special case of zero length format spec, make it equivalent to str(value) */ @@ -777,6 +797,7 @@ goto done; } + /* parse the format_spec */ if (!parse_internal_render_format_spec(format_spec, &format, 's')) goto done; @@ -795,18 +816,24 @@ } done: +#if PY_VERSION_HEX < 0x03000000 + Py_XDECREF(tmp); +#endif return result; } +#endif /* FORMAT_STRING */ -PyObject * -FORMAT_LONG(PyObject* value, PyObject* args) +#if defined FORMAT_LONG || defined FORMAT_INT +static PyObject* +format_int_or_long(PyObject* value, PyObject* args, IntOrLongToString tostring) { PyObject *format_spec; PyObject *result = NULL; PyObject *tmp = NULL; InternalFormatSpec format; - if (!PyArg_ParseTuple(args, STRINGLIB_PARSE_CODE ":__format__", &format_spec)) + if (!PyArg_ParseTuple(args, STRINGLIB_PARSE_CODE ":__format__", + &format_spec)) goto done; /* check for the special case of zero length format spec, make @@ -828,8 +855,9 @@ case 'o': case 'x': case 'X': - /* no type conversion needed, already an int. do the formatting */ - result = format_long_internal(value, &format); + /* no type conversion needed, already an int (or long). do + the formatting */ + result = format_int_or_long_internal(value, &format, tostring); break; case 'e': @@ -858,7 +886,52 @@ Py_XDECREF(tmp); return result; } +#endif /* FORMAT_LONG || defined FORMAT_INT */ + +#ifdef FORMAT_LONG +/* Need to define long_format as a function that will convert a long + to a string. In 3.0, _PyLong_Format has the correct signature. In + 2.x, we need to fudge a few parameters */ +#if PY_VERSION_HEX >= 0x03000000 +#define long_format _PyLong_Format +#else +static PyObject* +long_format(PyObject* value, int base) +{ + /* Convert to base, don't add trailing 'L', and use the new octal + format. We already know this is a long object */ + assert(PyLong_Check(value)); + /* convert to base, don't add 'L', and use the new octal format */ + return _PyLong_Format(value, base, 0, 1); +} +#endif + +PyObject * +FORMAT_LONG(PyObject* value, PyObject* args) +{ + return format_int_or_long(value, args, long_format); +} +#endif /* FORMAT_LONG */ + +#ifdef FORMAT_INT +/* this is only used for 2.x, not 3.0 */ +static PyObject* +int_format(PyObject* value, int base) +{ + /* Convert to base, and use the new octal format. We already + know this is an int object */ + assert(PyInt_Check(value)); + return _PyInt_Format((PyIntObject*)value, base, 1); +} + +PyObject * +FORMAT_INT(PyObject* value, PyObject* args) +{ + return format_int_or_long(value, args, int_format); +} +#endif /* FORMAT_INT */ +#ifdef FORMAT_FLOAT PyObject * FORMAT_FLOAT(PyObject *value, PyObject *args) { @@ -904,3 +977,4 @@ done: return result; } +#endif /* FORMAT_FLOAT */ Modified: python/branches/py3k/Objects/stringlib/string_format.h ============================================================================== --- python/branches/py3k/Objects/stringlib/string_format.h (original) +++ python/branches/py3k/Objects/stringlib/string_format.h Sun Feb 17 20:48:00 2008 @@ -6,6 +6,11 @@ */ +/* Defines for Python 2.6 compatability */ +#if PY_VERSION_HEX < 0x03000000 +#define PyLong_FromSsize_t _PyLong_FromSsize_t +#endif + /* Defines for more efficiently reallocating the string buffer */ #define INITIAL_SIZE_INCREMENT 100 #define SIZE_MULTIPLIER 2 @@ -470,66 +475,6 @@ field object and field specification string generated by get_field_and_spec, and renders the field into the output string. - format() does the actual calling of the objects __format__ method. -*/ - - -/* returns fieldobj.__format__(format_spec) */ -static PyObject * -format(PyObject *fieldobj, SubString *format_spec) -{ - static PyObject *format_str = NULL; - PyObject *meth; - PyObject *spec = NULL; - PyObject *result = NULL; - - /* Initialize cached value */ - if (format_str == NULL) { - /* Initialize static variable needed by _PyType_Lookup */ - format_str = PyUnicode_FromString("__format__"); - if (format_str == NULL) - return NULL; - } - - /* Make sure the type is initialized. float gets initialized late */ - if (Py_TYPE(fieldobj)->tp_dict == NULL) - if (PyType_Ready(Py_TYPE(fieldobj)) < 0) - return NULL; - - /* we need to create an object out of the pointers we have */ - spec = SubString_new_object_or_empty(format_spec); - if (spec == NULL) - goto done; - - /* Find the (unbound!) __format__ method (a borrowed reference) */ - meth = _PyType_Lookup(Py_TYPE(fieldobj), format_str); - if (meth == NULL) { - PyErr_Format(PyExc_TypeError, - "Type %.100s doesn't define __format__", - Py_TYPE(fieldobj)->tp_name); - goto done; - } - - /* And call it, binding it to the value */ - result = PyObject_CallFunctionObjArgs(meth, fieldobj, spec, NULL); - if (result == NULL) - goto done; - - if (!STRINGLIB_CHECK(result)) { - PyErr_SetString(PyExc_TypeError, - "__format__ method did not return " - STRINGLIB_TYPE_NAME); - Py_DECREF(result); - result = NULL; - goto done; - } - -done: - Py_XDECREF(spec); - return result; -} - -/* render_field calls fieldobj.__format__(format_spec) method, and appends to the output. */ @@ -537,14 +482,21 @@ render_field(PyObject *fieldobj, SubString *format_spec, OutputString *output) { int ok = 0; - PyObject *result = format(fieldobj, format_spec); + PyObject *result = NULL; + /* we need to create an object out of the pointers we have */ + PyObject *format_spec_object = SubString_new_object_or_empty(format_spec); + if (format_spec_object == NULL) + goto done; + + result = PyObject_Format(fieldobj, format_spec_object); if (result == NULL) goto done; ok = output_data(output, STRINGLIB_STR(result), STRINGLIB_LEN(result)); done: + Py_DECREF(format_spec_object); Py_XDECREF(result); return ok; } @@ -770,7 +722,7 @@ case 'r': return PyObject_Repr(obj); case 's': - return PyObject_Str(obj); + return STRINGLIB_TOSTR(obj); default: PyErr_Format(PyExc_ValueError, "Unknown converion specifier %c", @@ -845,7 +797,7 @@ } /* - do_markup is the top-level loop for the format() function. It + do_markup is the top-level loop for the format() method. It searches through the format string for escapes to markup codes, and calls other functions to move non-markup text to the output, and to perform the markup to the output. @@ -958,7 +910,7 @@ typedef struct { PyObject_HEAD - PyUnicodeObject *str; + STRINGLIB_OBJECT *str; MarkupIterator it_markup; } formatteriterobject; @@ -984,7 +936,7 @@ SubString literal; SubString field_name; SubString format_spec; - Py_UNICODE conversion; + STRINGLIB_CHAR conversion; int format_spec_needs_expanding; int result = MarkupIterator_next(&it->it_markup, &literal, &field_name, &format_spec, &conversion, @@ -1028,7 +980,7 @@ Py_INCREF(conversion_str); } else - conversion_str = PyUnicode_FromUnicode(&conversion, 1); + conversion_str = STRINGLIB_NEW(&conversion, 1); if (conversion_str == NULL) goto done; @@ -1047,7 +999,7 @@ {NULL, NULL} /* sentinel */ }; -PyTypeObject PyFormatterIter_Type = { +static PyTypeObject PyFormatterIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "formatteriterator", /* tp_name */ sizeof(formatteriterobject), /* tp_basicsize */ @@ -1085,7 +1037,7 @@ describing the parsed elements. It's a wrapper around stringlib/string_format.h's MarkupIterator */ static PyObject * -formatter_parser(PyUnicodeObject *self) +formatter_parser(STRINGLIB_OBJECT *self) { formatteriterobject *it; @@ -1099,8 +1051,8 @@ /* initialize the contained MarkupIterator */ MarkupIterator_init(&it->it_markup, - PyUnicode_AS_UNICODE(self), - PyUnicode_GET_SIZE(self)); + STRINGLIB_STR(self), + STRINGLIB_LEN(self)); return (PyObject *)it; } @@ -1118,7 +1070,7 @@ typedef struct { PyObject_HEAD - PyUnicodeObject *str; + STRINGLIB_OBJECT *str; FieldNameIterator it_field; } fieldnameiterobject; @@ -1220,7 +1172,7 @@ field_name_split. The iterator it returns is a FieldNameIterator */ static PyObject * -formatter_field_name_split(PyUnicodeObject *self) +formatter_field_name_split(STRINGLIB_OBJECT *self) { SubString first; Py_ssize_t first_idx; Modified: python/branches/py3k/Objects/stringlib/stringdefs.h ============================================================================== --- python/branches/py3k/Objects/stringlib/stringdefs.h (original) +++ python/branches/py3k/Objects/stringlib/stringdefs.h Sun Feb 17 20:48:00 2008 @@ -6,12 +6,15 @@ compiled as unicode. */ #define STRINGLIB_IS_UNICODE 0 +#define STRINGLIB_OBJECT PyStringObject #define STRINGLIB_CHAR char #define STRINGLIB_TYPE_NAME "string" #define STRINGLIB_PARSE_CODE "S" -#define STRINGLIB_EMPTY string_empty +#define STRINGLIB_EMPTY nullstring #define STRINGLIB_ISDECIMAL(x) ((x >= '0') && (x <= '9')) #define STRINGLIB_TODECIMAL(x) (STRINGLIB_ISDECIMAL(x) ? (x - '0') : -1) +#define STRINGLIB_TOUPPER toupper +#define STRINGLIB_TOLOWER tolower #define STRINGLIB_FILL memset #define STRINGLIB_STR PyString_AS_STRING #define STRINGLIB_LEN PyString_GET_SIZE Modified: python/branches/py3k/Objects/stringlib/unicodedefs.h ============================================================================== --- python/branches/py3k/Objects/stringlib/unicodedefs.h (original) +++ python/branches/py3k/Objects/stringlib/unicodedefs.h Sun Feb 17 20:48:00 2008 @@ -6,6 +6,7 @@ compiled as unicode. */ #define STRINGLIB_IS_UNICODE 1 +#define STRINGLIB_OBJECT PyUnicodeObject #define STRINGLIB_CHAR Py_UNICODE #define STRINGLIB_TYPE_NAME "unicode" #define STRINGLIB_PARSE_CODE "U" @@ -20,7 +21,12 @@ #define STRINGLIB_NEW PyUnicode_FromUnicode #define STRINGLIB_RESIZE PyUnicode_Resize #define STRINGLIB_CHECK PyUnicode_Check + +#if PY_VERSION_HEX < 0x03000000 +#define STRINGLIB_TOSTR PyObject_Unicode +#else #define STRINGLIB_TOSTR PyObject_Str +#endif #define STRINGLIB_WANT_CONTAINS_OBJ 1 Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Sun Feb 17 20:48:00 2008 @@ -304,58 +304,13 @@ static PyObject * builtin_format(PyObject *self, PyObject *args) { - static PyObject * format_str = NULL; PyObject *value; - PyObject *spec = NULL; - PyObject *meth; - PyObject *empty = NULL; - PyObject *result = NULL; - - /* Initialize cached value */ - if (format_str == NULL) { - /* Initialize static variable needed by _PyType_Lookup */ - format_str = PyUnicode_FromString("__format__"); - if (format_str == NULL) - goto done; - } - - if (!PyArg_ParseTuple(args, "O|U:format", &value, &spec)) - goto done; - - /* initialize the default value */ - if (spec == NULL) { - empty = PyUnicode_FromUnicode(NULL, 0); - spec = empty; - } - - /* Make sure the type is initialized. float gets initialized late */ - if (Py_TYPE(value)->tp_dict == NULL) - if (PyType_Ready(Py_TYPE(value)) < 0) - goto done; - - /* Find the (unbound!) __format__ method (a borrowed reference) */ - meth = _PyType_Lookup(Py_TYPE(value), format_str); - if (meth == NULL) { - PyErr_Format(PyExc_TypeError, - "Type %.100s doesn't define __format__", - Py_TYPE(value)->tp_name); - goto done; - } - - /* And call it, binding it to the value */ - result = PyObject_CallFunctionObjArgs(meth, value, spec, NULL); - - if (result && !PyUnicode_Check(result)) { - PyErr_SetString(PyExc_TypeError, - "__format__ method did not return string"); - Py_DECREF(result); - result = NULL; - goto done; - } - -done: - Py_XDECREF(empty); - return result; + PyObject *format_spec = NULL; + + if (!PyArg_ParseTuple(args, "O|U:format", &value, &format_spec)) + return NULL; + + return PyObject_Format(value, format_spec); } PyDoc_STRVAR(format_doc, From python-3000-checkins at python.org Sun Feb 17 20:48:58 2008 From: python-3000-checkins at python.org (eric.smith) Date: Sun, 17 Feb 2008 20:48:58 +0100 (CET) Subject: [Python-3000-checkins] r60881 - python/branches/py3k Message-ID: <20080217194858.16DBA1E400A@bag.python.org> Author: eric.smith Date: Sun Feb 17 20:48:57 2008 New Revision: 60881 Modified: python/branches/py3k/ (props changed) Log: Blocked 60879 (backport of PEP 3101). From python-3000-checkins at python.org Mon Feb 18 19:07:48 2008 From: python-3000-checkins at python.org (eric.smith) Date: Mon, 18 Feb 2008 19:07:48 +0100 (CET) Subject: [Python-3000-checkins] r60894 - python/branches/py3k/Objects/stringlib/string_format.h Message-ID: <20080218180748.30EFE1E4012@bag.python.org> Author: eric.smith Date: Mon Feb 18 19:07:47 2008 New Revision: 60894 Modified: python/branches/py3k/Objects/stringlib/string_format.h Log: Port 60893 to py3k, without unicode test. Modified: python/branches/py3k/Objects/stringlib/string_format.h ============================================================================== --- python/branches/py3k/Objects/stringlib/string_format.h (original) +++ python/branches/py3k/Objects/stringlib/string_format.h Mon Feb 18 19:07:47 2008 @@ -493,6 +493,22 @@ if (result == NULL) goto done; +#if PY_VERSION_HEX >= 0x03000000 + assert(PyString_Check(result)); +#else + assert(PyString_Check(result) || PyUnicode_Check(result)); + + /* Convert result to our type. We could be str, and result could + be unicode */ + { + PyObject *tmp = STRINGLIB_TOSTR(result); + if (tmp == NULL) + goto done; + Py_DECREF(result); + result = tmp; + } +#endif + ok = output_data(output, STRINGLIB_STR(result), STRINGLIB_LEN(result)); done: From python-3000-checkins at python.org Mon Feb 18 19:09:30 2008 From: python-3000-checkins at python.org (eric.smith) Date: Mon, 18 Feb 2008 19:09:30 +0100 (CET) Subject: [Python-3000-checkins] r60895 - python/branches/py3k Message-ID: <20080218180930.9FD341E4012@bag.python.org> Author: eric.smith Date: Mon Feb 18 19:09:30 2008 New Revision: 60895 Modified: python/branches/py3k/ (props changed) Log: block r60893 From python-3000-checkins at python.org Mon Feb 18 23:20:55 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 18 Feb 2008 23:20:55 +0100 (CET) Subject: [Python-3000-checkins] r60897 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: <20080218222055.A45CC1E4012@bag.python.org> Author: georg.brandl Date: Mon Feb 18 23:20:55 2008 New Revision: 60897 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Log: Clarification. Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Mon Feb 18 23:20:55 2008 @@ -331,7 +331,7 @@ * Removed: :func:`apply`, :func:`callable`, :func:`coerce`, :func:`execfile`, :func:`file`, :func:`reduce`, :func:`reload`. -* Removed: :meth:`dict.has_key`. +* Removed: :meth:`dict.has_key` -- use the ``in`` operator instead. * :func:`exec` is now a function. From python-3000-checkins at python.org Tue Feb 19 13:29:58 2008 From: python-3000-checkins at python.org (eric.smith) Date: Tue, 19 Feb 2008 13:29:58 +0100 (CET) Subject: [Python-3000-checkins] r60900 - python/branches/py3k Message-ID: <20080219122958.E2C611E4009@bag.python.org> Author: eric.smith Date: Tue Feb 19 13:29:58 2008 New Revision: 60900 Modified: python/branches/py3k/ (props changed) Log: block r60899 From python-3000-checkins at python.org Tue Feb 19 15:21:47 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 19 Feb 2008 15:21:47 +0100 (CET) Subject: [Python-3000-checkins] r60902 - in python/branches/py3k: Doc/c-api/tuple.rst Doc/library/inspect.rst Lib/SimpleHTTPServer.py Lib/inspect.py Lib/pydoc.py Lib/test/test_SimpleHTTPServer.py Lib/test/test_inspect.py Lib/test/test_mmap.py Lib/test/test_types.py Misc/NEWS Modules/mmapmodule.c PC/VC6/pythoncore.dsp PC/VS7.1/pythoncore.vcproj Python/pythonrun.c Tools/scripts/reindent.py Message-ID: <20080219142147.D9D041E4009@bag.python.org> Author: christian.heimes Date: Tue Feb 19 15:21:46 2008 New Revision: 60902 Added: python/branches/py3k/Lib/test/test_SimpleHTTPServer.py - copied unchanged from r60891, python/trunk/Lib/test/test_SimpleHTTPServer.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/tuple.rst python/branches/py3k/Doc/library/inspect.rst python/branches/py3k/Lib/SimpleHTTPServer.py python/branches/py3k/Lib/inspect.py python/branches/py3k/Lib/pydoc.py python/branches/py3k/Lib/test/test_inspect.py python/branches/py3k/Lib/test/test_mmap.py python/branches/py3k/Lib/test/test_types.py python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/mmapmodule.c python/branches/py3k/PC/VC6/pythoncore.dsp python/branches/py3k/PC/VS7.1/pythoncore.vcproj python/branches/py3k/Python/pythonrun.c python/branches/py3k/Tools/scripts/reindent.py Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60876 | georg.brandl | 2008-02-17 16:14:10 +0100 (Sun, 17 Feb 2008) | 2 lines Fix function name. ........ r60877 | facundo.batista | 2008-02-17 17:21:13 +0100 (Sun, 17 Feb 2008) | 4 lines Now we handle different the backup copy, because of security issues regarding user/group and permissions. Fixes 1050828. ........ r60878 | facundo.batista | 2008-02-17 19:59:29 +0100 (Sun, 17 Feb 2008) | 4 lines Issue 2112. mmap does not raises EnvironmentError no more, but a subclass of it. Thanks John Lenton. ........ r60882 | amaury.forgeotdarc | 2008-02-17 21:56:31 +0100 (Sun, 17 Feb 2008) | 5 lines Compilation was broken on Windows since the introduction of Advanced String Formatting. Only PCBuild (vs9) was really tested. Changes for older compilers were done manually. ........ r60883 | georg.brandl | 2008-02-17 22:18:55 +0100 (Sun, 17 Feb 2008) | 2 lines #2133: fix HTML color spec. ........ r60884 | facundo.batista | 2008-02-18 04:43:43 +0100 (Mon, 18 Feb 2008) | 5 lines Issue #1916. Added isgenerator() and isgeneratorfunction() to inspect.py. Thanks Javi Mansilla for patch review and corrections. ........ r60885 | facundo.batista | 2008-02-18 13:48:43 +0100 (Mon, 18 Feb 2008) | 4 lines Issue 1224. Now we support again the double slash in the URL. Thanks Anthony Lenton. ........ r60887 | eric.smith | 2008-02-18 15:25:02 +0100 (Mon, 18 Feb 2008) | 1 line Temporarily removed float tests. See issue 1600. ........ r60891 | kristjan.jonsson | 2008-02-18 18:40:47 +0100 (Mon, 18 Feb 2008) | 1 line Perform correct handling of stack overflow for windows: Catch the correct exception code and reset the overflow condition when handled. ........ Modified: python/branches/py3k/Doc/c-api/tuple.rst ============================================================================== --- python/branches/py3k/Doc/c-api/tuple.rst (original) +++ python/branches/py3k/Doc/c-api/tuple.rst Tue Feb 19 15:21:46 2008 @@ -106,6 +106,6 @@ ``*p`` is destroyed. On failure, returns ``-1`` and sets ``*p`` to *NULL*, and raises :exc:`MemoryError` or :exc:`SystemError`. -.. cfunction:: int PyMethod_ClearFreeList(void) +.. cfunction:: int PyTuple_ClearFreeList(void) Clear the free list. Return the total number of freed items. Modified: python/branches/py3k/Doc/library/inspect.rst ============================================================================== --- python/branches/py3k/Doc/library/inspect.rst (original) +++ python/branches/py3k/Doc/library/inspect.rst Tue Feb 19 15:21:46 2008 @@ -26,7 +26,7 @@ ----------------- The :func:`getmembers` function retrieves the members of an object such as a -class or module. The eleven functions whose names begin with "is" are mainly +class or module. The fifteen functions whose names begin with "is" are mainly provided as convenient choices for the second argument to :func:`getmembers`. They also help you determine when you can expect to find the following special attributes: @@ -229,6 +229,16 @@ Return true if the object is a Python function or unnamed (:term:`lambda`) function. +.. function:: isgeneratorfunction(object) + + Return true if the object is a Python generator function. + + +.. function:: isgenerator(object) + + Return true if the object is a generator. + + .. function:: istraceback(object) Return true if the object is a traceback. Modified: python/branches/py3k/Lib/SimpleHTTPServer.py ============================================================================== --- python/branches/py3k/Lib/SimpleHTTPServer.py (original) +++ python/branches/py3k/Lib/SimpleHTTPServer.py Tue Feb 19 15:21:46 2008 @@ -143,7 +143,8 @@ """ # abandon query parameters - path = urlparse.urlparse(path)[2] + path = path.split('?',1)[0] + path = path.split('#',1)[0] path = posixpath.normpath(urllib.unquote(path)) words = path.split('/') words = filter(None, words) Modified: python/branches/py3k/Lib/inspect.py ============================================================================== --- python/branches/py3k/Lib/inspect.py (original) +++ python/branches/py3k/Lib/inspect.py Tue Feb 19 15:21:46 2008 @@ -7,8 +7,9 @@ Here are some of the useful functions provided by this module: - ismodule(), isclass(), ismethod(), isfunction(), istraceback(), - isframe(), iscode(), isbuiltin(), isroutine() - check object types + ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(), + isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(), + isroutine() - check object types getmembers() - get members of an object that satisfy a given condition getfile(), getsourcefile(), getsource() - find an object's source code @@ -29,9 +30,20 @@ __author__ = 'Ka-Ping Yee ' __date__ = '1 Jan 2001' -import sys, os, types, re, dis, imp, tokenize, linecache +import sys +import os +import types +import string +import re +import dis +import imp +import tokenize +import linecache from operator import attrgetter from collections import namedtuple +# These constants are from Include/code.h. +CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 0x1, 0x2, 0x4, 0x8 +CO_NESTED, CO_GENERATOR, CO_NOFREE = 0x10, 0x20, 0x40 # ----------------------------------------------------------- type-checking def ismodule(object): @@ -137,6 +149,33 @@ __kwdefaults__ dict of keyword only parameters with defaults""" return isinstance(object, types.FunctionType) +def isgeneratorfunction(object): + """Return true if the object is a user-defined generator function. + + Generator function objects provides same attributes as functions. + + See isfunction.__doc__ for attributes listing.""" + if (isfunction(object) or ismethod(object)) and \ + object.__code__.co_flags & CO_GENERATOR: + return True + +def isgenerator(object): + """Return true if the object is a generator. + + Generator objects provide these attributes: + __iter__ defined to support interation over container + close raises a new GeneratorExit exception inside the + generator to terminate the iteration + gi_code code object + gi_frame frame object or possibly None once the generator has + been exhausted + gi_running set to 1 when generator is executing, 0 otherwise + next return the next item from the container + send resumes the generator and "sends" a value that becomes + the result of the current yield-expression + throw used to raise an exception inside the generator""" + return isinstance(object, types.GeneratorType) + def istraceback(object): """Return true if the object is a traceback. @@ -198,6 +237,10 @@ or ismethod(object) or ismethoddescriptor(object)) +def isgenerator(object): + """Return true if the object is a generator object.""" + return isinstance(object, types.GeneratorType) + def getmembers(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate.""" @@ -670,9 +713,6 @@ return walktree(roots, children, None) # ------------------------------------------------ argument list extraction -# These constants are from Python's compile.h. -CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 1, 2, 4, 8 - Arguments = namedtuple('Arguments', 'args, varargs, varkw') def getargs(co): Modified: python/branches/py3k/Lib/pydoc.py ============================================================================== --- python/branches/py3k/Lib/pydoc.py (original) +++ python/branches/py3k/Lib/pydoc.py Tue Feb 19 15:21:46 2008 @@ -660,7 +660,7 @@ contents = self.multicolumn( modules, lambda t: self.modulelink(t[1])) result = result + self.bigsection( - 'Modules', '#fffff', '#aa55cc', contents) + 'Modules', '#ffffff', '#aa55cc', contents) if classes: classlist = [value for (key, value) in classes] Modified: python/branches/py3k/Lib/test/test_inspect.py ============================================================================== --- python/branches/py3k/Lib/test/test_inspect.py (original) +++ python/branches/py3k/Lib/test/test_inspect.py Tue Feb 19 15:21:46 2008 @@ -13,10 +13,10 @@ # Functions tested in this suite: # ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode, -# isbuiltin, isroutine, getmembers, getdoc, getfile, getmodule, -# getsourcefile, getcomments, getsource, getclasstree, getargspec, -# getargvalues, formatargspec, formatargvalues, currentframe, stack, trace -# isdatadescriptor +# isbuiltin, isroutine, isgenerator, isgeneratorfunction, getmembers, +# getdoc, getfile, getmodule, getsourcefile, getcomments, getsource, +# getclasstree, getargspec, getargvalues, formatargspec, formatargvalues, +# currentframe, stack, trace, isdatadescriptor modfile = mod.__file__ if modfile.endswith(('c', 'o')): @@ -41,23 +41,33 @@ class IsTestBase(unittest.TestCase): predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode, inspect.isframe, inspect.isfunction, inspect.ismethod, - inspect.ismodule, inspect.istraceback]) + inspect.ismodule, inspect.istraceback, + inspect.isgenerator, inspect.isgeneratorfunction]) def istest(self, predicate, exp): obj = eval(exp) self.failUnless(predicate(obj), '%s(%s)' % (predicate.__name__, exp)) for other in self.predicates - set([predicate]): + if predicate == inspect.isgeneratorfunction and\ + other == inspect.isfunction: + continue self.failIf(other(obj), 'not %s(%s)' % (other.__name__, exp)) +def generator_function_example(self): + for i in range(2): + yield i + class TestPredicates(IsTestBase): - def test_thirteen(self): + def test_fifteen(self): count = len([x for x in dir(inspect) if x.startswith('is')]) - # Doc/lib/libinspect.tex claims there are 13 such functions - expected = 13 + # This test is here for remember you to update Doc/library/inspect.rst + # which claims there are 15 such functions + expected = 15 err_msg = "There are %d (not %d) is* functions" % (count, expected) self.assertEqual(count, expected, err_msg) + def test_excluding_predicates(self): self.istest(inspect.isbuiltin, 'sys.exit') self.istest(inspect.isbuiltin, '[].append') @@ -70,6 +80,8 @@ self.istest(inspect.ismodule, 'mod') self.istest(inspect.istraceback, 'tb') self.istest(inspect.isdatadescriptor, 'collections.defaultdict.default_factory') + self.istest(inspect.isgenerator, '(x for x in range(2))') + self.istest(inspect.isgeneratorfunction, 'generator_function_example') if hasattr(types, 'GetSetDescriptorType'): self.istest(inspect.isgetsetdescriptor, 'type(tb.tb_frame).f_locals') Modified: python/branches/py3k/Lib/test/test_mmap.py ============================================================================== --- python/branches/py3k/Lib/test/test_mmap.py (original) +++ python/branches/py3k/Lib/test/test_mmap.py Tue Feb 19 15:21:46 2008 @@ -435,6 +435,11 @@ self.assertRaises(TypeError, m.write, "foo") + def test_error(self): + self.assert_(issubclass(mmap.error, EnvironmentError)) + self.assert_("mmap.error" in str(mmap.error)) + + def test_main(): run_unittest(MmapTests) Modified: python/branches/py3k/Lib/test/test_types.py ============================================================================== --- python/branches/py3k/Lib/test/test_types.py (original) +++ python/branches/py3k/Lib/test/test_types.py Tue Feb 19 15:21:46 2008 @@ -63,15 +63,15 @@ try: 5 / 0 except ZeroDivisionError: pass - else: self.fail("5 / 0L didn't raise ZeroDivisionError") + else: self.fail("5 / 0 didn't raise ZeroDivisionError") try: 5 // 0 except ZeroDivisionError: pass - else: self.fail("5 // 0L didn't raise ZeroDivisionError") + else: self.fail("5 // 0 didn't raise ZeroDivisionError") try: 5 % 0 except ZeroDivisionError: pass - else: self.fail("5 % 0L didn't raise ZeroDivisionError") + else: self.fail("5 % 0 didn't raise ZeroDivisionError") def test_numeric_types(self): if 0 != 0 or 0 != 0.0 or 0 != 0.0: self.fail('mixed comparisons') @@ -80,7 +80,7 @@ self.fail('int/long/float value not equal') # calling built-in types without argument must return 0 if int() != 0: self.fail('int() does not return 0') - if int() != 0: self.fail('long() does not return 0L') + if int() != 0: self.fail('long() does not return 0') if float() != 0.0: self.fail('float() does not return 0.0') if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass else: self.fail('int() does not round properly') @@ -203,6 +203,251 @@ self.assertRaises(TypeError, type, 1, 2) self.assertRaises(TypeError, type, 1, 2, 3, 4) + def test_int__format__(self): + def test(i, format_spec, result): + # just make sure I'm not accidentally checking longs + assert type(i) == int + assert type(format_spec) == str + self.assertEqual(i.__format__(format_spec), result) + + test(123456789, 'd', '123456789') + test(123456789, 'd', '123456789') + + test(1, 'c', '\01') + + # sign and aligning are interdependent + test(1, "-", '1') + test(-1, "-", '-1') + test(1, "-3", ' 1') + test(-1, "-3", ' -1') + test(1, "+3", ' +1') + test(-1, "+3", ' -1') + test(1, " 3", ' 1') + test(-1, " 3", ' -1') + test(1, " ", ' 1') + test(-1, " ", '-1') + + # hex + test(3, "x", "3") + test(3, "X", "3") + test(1234, "x", "4d2") + test(-1234, "x", "-4d2") + test(1234, "8x", " 4d2") + test(-1234, "8x", " -4d2") + test(1234, "x", "4d2") + test(-1234, "x", "-4d2") + test(-3, "x", "-3") + test(-3, "X", "-3") + test(int('be', 16), "x", "be") + test(int('be', 16), "X", "BE") + test(-int('be', 16), "x", "-be") + test(-int('be', 16), "X", "-BE") + + # octal + test(3, "o", "3") + test(-3, "o", "-3") + test(65, "o", "101") + test(-65, "o", "-101") + test(1234, "o", "2322") + test(-1234, "o", "-2322") + test(1234, "-o", "2322") + test(-1234, "-o", "-2322") + test(1234, " o", " 2322") + test(-1234, " o", "-2322") + test(1234, "+o", "+2322") + test(-1234, "+o", "-2322") + + # binary + test(3, "b", "11") + test(-3, "b", "-11") + test(1234, "b", "10011010010") + test(-1234, "b", "-10011010010") + test(1234, "-b", "10011010010") + test(-1234, "-b", "-10011010010") + test(1234, " b", " 10011010010") + test(-1234, " b", "-10011010010") + test(1234, "+b", "+10011010010") + test(-1234, "+b", "-10011010010") + + # make sure these are errors + + # precision disallowed + self.assertRaises(ValueError, 3 .__format__, "1.3") + # sign not allowed with 'c' + self.assertRaises(ValueError, 3 .__format__, "+c") + # format spec must be string + self.assertRaises(TypeError, 3 .__format__, None) + self.assertRaises(TypeError, 3 .__format__, 0) + + # ensure that only int and float type specifiers work + for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + + [chr(x) for x in range(ord('A'), ord('Z')+1)]): + if not format_spec in 'bcdoxXeEfFgGn%': + self.assertRaises(ValueError, 0 .__format__, format_spec) + self.assertRaises(ValueError, 1 .__format__, format_spec) + self.assertRaises(ValueError, (-1) .__format__, format_spec) + + # ensure that float type specifiers work; format converts + # the int to a float + for format_spec in 'eEfFgGn%': + for value in [0, 1, -1, 100, -100, 1234567890, -1234567890]: + self.assertEqual(value.__format__(format_spec), + float(value).__format__(format_spec)) + + def test_long__format__(self): + def test(i, format_spec, result): + # make sure we're not accidentally checking ints + assert type(i) == int + assert type(format_spec) == str + self.assertEqual(i.__format__(format_spec), result) + + test(10**100, 'd', '1' + '0' * 100) + test(10**100+100, 'd', '1' + '0' * 97 + '100') + + test(123456789, 'd', '123456789') + test(123456789, 'd', '123456789') + + # sign and aligning are interdependent + test(1, "-", '1') + test(-1, "-", '-1') + test(1, "-3", ' 1') + test(-1, "-3", ' -1') + test(1, "+3", ' +1') + test(-1, "+3", ' -1') + test(1, " 3", ' 1') + test(-1, " 3", ' -1') + test(1, " ", ' 1') + test(-1, " ", '-1') + + test(1, 'c', '\01') + + # hex + test(3, "x", "3") + test(3, "X", "3") + test(1234, "x", "4d2") + test(-1234, "x", "-4d2") + test(1234, "8x", " 4d2") + test(-1234, "8x", " -4d2") + test(1234, "x", "4d2") + test(-1234, "x", "-4d2") + test(-3, "x", "-3") + test(-3, "X", "-3") + + # octal + test(3, "o", "3") + test(-3, "o", "-3") + test(65, "o", "101") + test(-65, "o", "-101") + test(1234, "o", "2322") + test(-1234, "o", "-2322") + test(1234, "-o", "2322") + test(-1234, "-o", "-2322") + test(1234, " o", " 2322") + test(-1234, " o", "-2322") + test(1234, "+o", "+2322") + test(-1234, "+o", "-2322") + + # binary + test(3, "b", "11") + test(-3, "b", "-11") + test(1234, "b", "10011010010") + test(-1234, "b", "-10011010010") + test(1234, "-b", "10011010010") + test(-1234, "-b", "-10011010010") + test(1234, " b", " 10011010010") + test(-1234, " b", "-10011010010") + test(1234, "+b", "+10011010010") + test(-1234, "+b", "-10011010010") + + # make sure these are errors + + # precision disallowed + self.assertRaises(ValueError, 3 .__format__, "1.3") + # sign not allowed with 'c' + self.assertRaises(ValueError, 3 .__format__, "+c") + # format spec must be string + self.assertRaises(TypeError, 3 .__format__, None) + self.assertRaises(TypeError, 3 .__format__, 0) + + # ensure that only int and float type specifiers work + for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + + [chr(x) for x in range(ord('A'), ord('Z')+1)]): + if not format_spec in 'bcdoxXeEfFgGn%': + self.assertRaises(ValueError, 0 .__format__, format_spec) + self.assertRaises(ValueError, 1 .__format__, format_spec) + self.assertRaises(ValueError, (-1) .__format__, format_spec) + + # ensure that float type specifiers work; format converts + # the long to a float + for format_spec in 'eEfFgGn%': + for value in [0, 1, -1, 100, -100, 1234567890, -1234567890]: + self.assertEqual(value.__format__(format_spec), + float(value).__format__(format_spec)) + + def test_float__format__(self): + # these should be rewritten to use both format(x, spec) and + # x.__format__(spec) + + def test(f, format_spec, result): + assert type(f) == float + assert type(format_spec) == str + self.assertEqual(f.__format__(format_spec), result) + + test(0.0, 'f', '0.000000') + + # the default is 'g', except for empty format spec + test(0.0, '', '0.0') + test(0.01, '', '0.01') + test(0.01, 'g', '0.01') + + test( 1.0, ' g', ' 1') + test(-1.0, ' g', '-1') + test( 1.0, '+g', '+1') + test(-1.0, '+g', '-1') + test(1.1234e200, 'g', '1.1234e+200') + test(1.1234e200, 'G', '1.1234E+200') + + + test(1.0, 'f', '1.000000') + + test(-1.0, 'f', '-1.000000') + + test( 1.0, ' f', ' 1.000000') + test(-1.0, ' f', '-1.000000') + test( 1.0, '+f', '+1.000000') + test(-1.0, '+f', '-1.000000') + test(1.1234e200, 'f', '1.1234e+200') + test(1.1234e200, 'F', '1.1234e+200') + + # temporarily removed. see issue 1600 + # test( 1.0, 'e', '1.000000e+00') + # test(-1.0, 'e', '-1.000000e+00') + # test( 1.0, 'E', '1.000000E+00') + # test(-1.0, 'E', '-1.000000E+00') + # test(1.1234e20, 'e', '1.123400e+20') + # test(1.1234e20, 'E', '1.123400E+20') + + # % formatting + test(-1.0, '%', '-100.000000%') + + # format spec must be string + self.assertRaises(TypeError, 3.0.__format__, None) + self.assertRaises(TypeError, 3.0.__format__, 0) + + # other format specifiers shouldn't work on floats, + # in particular int specifiers + for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + + [chr(x) for x in range(ord('A'), ord('Z')+1)]): + if not format_spec in 'eEfFgGn%': + self.assertRaises(ValueError, format, 0.0, format_spec) + self.assertRaises(ValueError, format, 1.0, format_spec) + self.assertRaises(ValueError, format, -1.0, format_spec) + self.assertRaises(ValueError, format, 1e100, format_spec) + self.assertRaises(ValueError, format, -1e100, format_spec) + self.assertRaises(ValueError, format, 1e-100, format_spec) + self.assertRaises(ValueError, format, -1e-100, format_spec) + + def test_main(): run_unittest(TypesTests) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Feb 19 15:21:46 2008 @@ -97,18 +97,1570 @@ of PyString. +<<<<<<< .working +======= +- Issue #1402: Fix a crash on exit, when another thread is still running, and + if the deallocation of its frames somehow calls the PyGILState_Ensure() / + PyGILState_Release() functions. + +- Expose the Py_Py3kWarningFlag as sys.py3kwarning. + +- Issue #1445: Fix a SystemError when accessing the ``cell_contents`` + attribute of an empty cell object. + +- Issue #1460: The utf-7 incremental decoder did not accept truncated input. + It now correctly saves its state between chunks of data. + +- Patch #1739468: Directories and zipfiles containing a __main__.py file can + now be directly executed by passing their name to the interpreter. The + directory/zipfile is automatically inserted as the first entry in sys.path. + +- Issue #1265: Fix a problem with sys.settrace, if the tracing function uses a + generator expression when at the same time the executed code is closing a + paused generator. + +- sets and frozensets now have an isdisjoint() method. + +- optimize the performance of builtin.sum(). + +- Fix warnings found by the new version of the Coverity checker. + +- The enumerate() builtin function is no longer bounded to sequences smaller + than LONG_MAX. Formerly, it raised an OverflowError. Now, automatically + shifts from ints to longs. + +- Issue #1686386: Tuple's tp_repr did not take into account the possibility of + having a self-referential tuple, which is possible from C code. Nor did + object's tp_str consider that a type's tp_str could do something that could + lead to an inifinite recursion. Py_ReprEnter() and Py_EnterRecursiveCall(), + respectively, fixed the issues. + +- Issue #1164: It was possible to trigger deadlock when using the 'print' + statement to write to a file since the GIL was not released as needed. Now + PyObject_Print() does the right thing along with various tp_print + implementations of the built-in types and those in the collections module. + +- Issue #1147: Exceptions were directly allowing string exceptions in their + throw() method even though string exceptions no longer allowed. + +- Issue #1096: Prevent a segfault from getting the repr of a very deeply nested + list by using the recursion counter. + +- Issue #1202533: Fix infinite recursion calls triggered by calls to + PyObject_Call() never calling back out to Python code to trigger recursion + depth updates/checks. Required the creation of a static RuntimeError + instance in case normalizing an exception put the recursion check value past + its limit. Fixes crashers infinite_rec_(1|2|4|5).py. + +- Patch #1031213: Decode source line in SyntaxErrors back to its original source + encoding. + +- Patch #1673759: add a missing overflow check when formatting floats + with %G. + +- Prevent expandtabs() on string and unicode objects from causing a segfault + when a large width is passed on 32-bit platforms. + +- Bug #1733488: Fix compilation of bufferobject.c on AIX. + +- Bug #1722485: remove docstrings again when running with -OO. + +- Add new attribute names for function objects. All the func_* become + __*__ attributes. (Some already existed, e.g., __doc__ and __name__.) + +- Add -3 option to the interpreter to warn about features that are + deprecated and will be changed/removed in Python 3.0. + +- Patch #1686487: you can now pass any mapping after '**' in function + calls. + +- except clauses may now be spelled either "except E, target:" or + "except E as target:". This is to provide forwards compatibility with + Python 3.0. + +- Deprecate BaseException.message as per PEP 352. + +- Bug #1303614: don't expose object's __dict__ when the dict is + inherited from a builtin base. + +- When __slots__ are set to a unicode string, make it work the same as + setting a plain string, ie don't expand to single letter identifiers. + +- Request #1191699: Slices can now be pickled. + +- Request #1193128: str.translate() now allows a None argument for + translations that only remove characters without re-mapping the + remaining characters. + +- Patch #1682205: a TypeError while unpacking an iterable is no longer + masked by a generic one with the message "unpack non-sequence". + +- Remove unused file Python/fmod.c. + +- Bug #1683368: The object.__init__() and object.__new__() methods are + now stricter in rejecting excess arguments. The only time when + either allows excess arguments is when it is not overridden and the + other one is. For backwards compatibility, when both are + overridden, it is a deprecation warning (for now; maybe a Py3k + warning later). Also, type.__init__() insists on the same signature + as supported by type.__new__(). + +- Patch #1675423: PyComplex_AsCComplex() now tries to convert an object + to complex using its __complex__() method before falling back to the + __float__() method. Therefore, the functions in the cmath module now + can operate on objects that define a __complex__() method. + +- Patch #1623563: allow __class__ assignment for classes with __slots__. + The old and the new class are still required to have the same slot names. + +- Patch #1642547: Fix an error/crash when encountering syntax errors in + complex if statements. + +- Patch #1462488: Python no longer segfaults when ``object.__reduce_ex__()`` + is called with an object that is faking its type. + +- Patch #1680015: Don't modify __slots__ tuple if it contains an unicode + name. + +- Patch #1444529: the builtin compile() now accepts keyword arguments. + +- Bug #1678647: write a newline after printing an exception in any + case, even when converting the value to a string failed. + +- The dir() function has been extended to call the __dir__() method on + its argument, if it exists. If not, it will work like before. This allows + customizing the output of dir() in the presence of a __getattr__(). + +- Patch #922167: Python no longer segfaults when faced with infinitely + self-recursive reload() calls (as reported by bug #742342). + +- Patch #1675981: remove unreachable code from ``type.__new__()`` method. + +- Patch #1491866: change the complex() constructor to allow parthensized + forms. This means complex(repr(x)) now works instead of raising a + ValueError. + +- Patch #703779: unset __file__ in __main__ after running a file. This + makes the filenames the warning module prints much more sensible when + a PYTHONSTARTUP file is used. + +- Variant of patch #697613: don't exit the interpreter on a SystemExit + exception if the -i command line option or PYTHONINSPECT environment + variable is given, but break into the interactive interpreter just like + on other exceptions or normal program exit. + +- Patch #1638879: don't accept strings with embedded NUL bytes in long(). + +- Bug #1674503: close the file opened by execfile() in an error condition. + +- Patch #1674228: when assigning a slice (old-style), check for the + sq_ass_slice instead of the sq_slice slot. + +- When printing an unraisable error, don't print exceptions. before the name. + This duplicates the behavior whening normally printing exceptions. + +- Bug #1653736: Properly discard third argument to slot_nb_inplace_power. + +- PEP 352: Raising a string exception now triggers a TypeError. Attempting to + catch a string exception raises DeprecationWarning. + +- Bug #1377858: Fix the segfaulting of the interpreter when an object created + a weakref on itself during a __del__ call for new-style classes (classic + classes still have the bug). + +- Bug #1579370: Make PyTraceBack_Here use the current thread, not the + frame's thread state. + +- patch #1630975: Fix crash when replacing sys.stdout in sitecustomize.py + +- Prevent seg fault on shutdown which could occur if an object + raised a warning. + +- Bug #1566280: Explicitly invoke threading._shutdown from Py_Main, + to avoid relying on atexit. + +- Bug #1590891: random.randrange don't return correct value for big number + +- Patch #1586791: Better exception messages for some operations on strings, + tuples and lists. + +- Bug #1067760: Deprecate passing floats to file.seek. + +- Bug #1591996: Correctly forward exception in instance_contains(). + +- Bug #1588287: fix invalid assertion for `1,2` in debug builds. + +- Bug #1576657: when setting a KeyError for a tuple key, make sure that + the tuple isn't used as the "exception arguments tuple". + +- Bug #1565514, SystemError not raised on too many nested blocks. + +- Bug #1576174: WindowsError now displays the windows error code + again, no longer the posix error code. + +- Patch #1549049: Support long values in structmember, issue warnings + if the assigned value for structmember fields gets truncated. + +- Update the peephole optimizer to remove more dead code (jumps after returns) + and inline unconditional jumps to returns. + +- Bug #1545497: when given an explicit base, int() did ignore NULs + embedded in the string to convert. + +- Bug #1569998: break inside a try statement (outside a loop) is now + recognized and rejected. + +- list.pop(x) accepts any object x following the __index__ protocol. + +- A number of places, including integer negation and absolute value, + were fixed to not rely on undefined behaviour of the C compiler + anymore. + +- Bug #1566800: make sure that EnvironmentError can be called with any + number of arguments, as was the case in Python 2.4. + +- Patch #1567691: super() and new.instancemethod() now don't accept + keyword arguments any more (previously they accepted them, but didn't + use them). + +- Fix a bug in the parser's future statement handling that led to "with" + not being recognized as a keyword after, e.g., this statement: + from __future__ import division, with_statement + +- Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). + +- Fix %zd string formatting on Mac OS X so it prints negative numbers. + +- Allow exception instances to be directly sliced again. + +- Bug #1551432: Exceptions do not define an explicit __unicode__ method. This + allows calling unicode() on exceptions classes directly to succeed. + +- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. + Also make sure that every exception class has __module__ set to + 'exceptions'. + +- Bug #1550983: emit better error messages for erroneous relative + imports (if not in package and if beyond toplevel package). + +- Overflow checking code in integer division ran afoul of new gcc + optimizations. Changed to be more standard-conforming. + +- Patch #1542451: disallow continue anywhere under a finally. + +- Patch #1546288: fix seg fault in dict_equal due to ref counting bug. + +- The return tuple from str.rpartition(sep) is (tail, sep, head) where + head is the original string if sep was not found. + +- Bug #1520864: unpacking singleton tuples in list comprehensions and + generator expressions (x for x, in ... ) works again. Fixing this problem + required changing the .pyc magic number. This means that .pyc files + generated before 2.5c2 will be regenerated. + +- ``with`` and ``as`` are now keywords. + +- Bug #1664966: Fix crash in exec if Unicode filename can't be decoded. + +- Issue #1537: Changed GeneratorExit's base class from Exception to + BaseException. + +- Fix Issue #1703448: A joined thread could show up in the + threading.enumerate() list after the join() for a brief period until + it actually exited. + + +Library +------- + +- Issue #1916. Added isgenerator() and isgeneratorfunction() to inspect.py. + +- #1224: Fixed bad url parsing when path begins with double slash. + +- ctypes instances that are not or do not contain pointers can now be + pickled. + +- Patch #1966: Break infinite loop in httplib when the servers + implements the chunked encoding incorrectly. + +- Rename rational.py to fractions.py and the rational.Rational class + to fractions.Fraction, to avoid the name clash with the abstract + base class numbers.Rational. See discussion in issue #1682. + +- The pickletools module now provides an optimize() function + that eliminates unused PUT opcodes from a pickle string. + +- #2021: Allow tempfile.NamedTemporaryFile and SpooledTemporaryFile + to be used in with statements by correctly supporting the context + management protocol. + +- #1979: Add rich comparisons to Decimal, and make Decimal comparisons + involving a NaN follow the IEEE 754 standard. + +- #2004: tarfile.py: Use mode 0700 for temporary directories and default + permissions for missing directories. + +- #175006: The debugger used to skip the condition of a "while" statement + after the first iteration. Now it correctly steps on the expression, and + breakpoints on the "while" statement are honored on each loop. + +- #1765140: add an optional delay argument to FileHandler and its + subclasses. Defaults to false (existing behaviour), but if true, + defers opening the file until the first call to emit(). + +- The pprint module now supports sets and frozensets. + +- #1221598: add optional callbacks to ftplib.FTP's storbinary() and + storlines() methods. (Contributed by Phil Schwartz) + +- #1715: include sub-extension modules in pydoc's text output. + +- #1836: fix an off-by-one bug in TimedRotatingHandler's rollover + time calculation. + +- #1021: fix a bug to allow basicConfig to accept NOTSET as a level. + +- #932563: add LoggerAdapter convenience class to make it easier to add + contextual information in logging output. + +- #1760556: fix a bug to avoid FileHandler throwing an exception in + flush(). + +- Bug #1530959: distutils' build command now uses different build directory + when building extension modules against versions of Python compiled + with ``--with-pydebug``. + +- #1555501: move plistlib from plat-mac directory to general library. + +- #1269: fix a bug in pstats.add_callers() and add a unit test file for + pstats. + +- #1669: don't allow shutil.rmtree() to be called on a symlink to a + directory. + +- #1664522: in urllib, don't read non-existing directories in ftp mode, + returning a 0-byte file -- raise an IOError instead. + +- #856047: respect the ``no_proxy`` environment variable when using the + ``http_proxy`` etc. environment variables in urllib. + +- #1178141: add a getcode() method to the addinfourls that urllib.open() + returns so that you can retrieve the HTTP status code. + +- Issue #1003: Fix zipfile decryption check, it would fail zip files + with extended local headers. + +- #1189216: Fix the zipfile module to work on archives with headers + past the 2**31 byte boundary. + +- #1336: fix a race condition in subprocess.Popen if the garbage + collector kicked in at the wrong time that would cause the process + to hang when the child wrote to stderr. + +- #1146: fix how textwrap breaks a long word that would start in the + last column of a line. + +- #1693149: trace.py --ignore-module - accept multiple comma-separated + modules to be given. + +- #1822: MIMEMultipart.is_multipart() behaves correctly for a just-created + (and empty) instance. Thanks Jonathan Share. + +- #1861: Added an attribute to the sched module which returns an ordered + list of upcoming events (displayed as named tuples). + +- #1837: The queue module now also supports a LIFO queue and a priority queue. + +- Patch #1048820: Add insert-mode editing to curses.textpad.Textbox + (patch by Stefan Wehr). Also, fix an off-by-one bug in + Textbox.gather(). + +- Issue #1831: ctypes now raises a TypeError if conflicting positional + and named arguments are passed to a Structure or Union initializer. + When too many positional arguments are passed, also a TypeError is + raised instead of a ValueError. + +- Convert the internal ctypes array type cache to a WeakValueDict so + that array types do not live longer than needed. + +- Issue #1786: pdb should use its own stdin/stdout around an exec call + and when creating a recursive instance. + +- Issue #1698398 Zipfile.printdir() crashed because the format string + expected a tuple type of length six instead of time.struct_time object. + +- Issue #1780: The Decimal constructor now accepts arbitrary leading + and trailing whitespace when constructing from a string. + Context.create_decimal no longer accepts trailing newlines. + +- Decimal.as_tuple(), difflib.find_longest_match() and inspect functions + that returned a tuple now return a named tuple. + +- Doctest now returns results as a named tuple for readability: + (0, 7) --> TestResults(failed=0, attempted=7) + +- Issue #846388. re.match is interruptible now, which is particularly + good for long regular expression matches. + +- pyexpat, patch #1137: allow setting buffer_size attribute + on Parser objects to set the character data buffer size. + +- Issue #1757: The hash of a Decimal instance is no longer affected by + the current context. + +- Patch #467924: add ZipFile.extract() and ZipFile.extractall() in the + zipfile module. + +- Issue #1646: Make socket support the TIPC protocol. + +- Bug #1742: return os.curdir from os.path.relpath() if both arguments are + equal instead of raising an exception. + +- Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'. + +- Patch #1698: allow '@' in username parsed by urlparse.py. + +- Issue #1735: TarFile.extractall() now correctly sets directory permissions + and times. + +- Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint. + +- Bug #1687: Fxed plistlib.py restricts to Python int when writing + +- Issue #1700: Regular expression inline flags incorrectly handle certain + unicode characters. + +- Issue #1689: PEP 3141, numeric abstract base classes. + +- Tk issue #1851526: Return results from Python callbacks to Tcl as + Tcl objects. + +- Issue #1642: Fix segfault in ctypes when trying to delete attributes. + +- Issue #1727780: Support loading pickles of random.Random objects created + on 32-bit systems on 64-bit systems, and vice versa. As a consequence + of the change, Random pickles created by Python 2.6 cannot be loaded + in Python 2.5. + +- Issue #1455: The distutils package now supports VS 2005 and VS 2008 for + both the msvccompiler and cygwincompiler. + +- Issue #1531: tarfile.py: Read fileobj from the current offset, do not + seek to the start. + +- Issue #1534: Added a dictionary sys.float_info with information about the + internal floating point type to the sys module. + +- Issue 1429818: patch for trace and doctest modules so they play nicely + together. + +- doctest made a bad assumption that a package's __loader__.get_data() + method used universal newlines. + +- Issue #1705170: contextlib.contextmanager was still swallowing + StopIteration in some cases. This should no longer happen. + +- Issue #1292: On alpha, arm, ppc, and s390 linux systems the + --with-system-ffi configure option defaults to "yes". + +- IN module for FreeBSD 8 is added and preexisting FreeBSD 6 and 7 + files are updated. + +- Issues #1181, #1287: unsetenv() is now called when the os.environ.pop() + and os.environ.clear() methods are used. + +- ctypes will now work correctly on 32-bit systems when Python is + configured with --with-system-ffi. + +- Patch #1203: ctypes now does work on OS X when Python is built with + --disable-toolbox-glue. + +- collections.deque() now supports a "maxlen" argument. + +- itertools.count() is no longer bounded to LONG_MAX. Formerly, it raised + an OverflowError. Now, automatically shifts from ints to longs. + +- Patch #1541463: optimize performance of cgi.FieldStorage operations. + +- Decimal is fully updated to the latest Decimal Specification (v1.66). + +- Bug #1153: repr.repr() now doesn't require set and dictionary items + to be orderable to properly represent them. + +- A 'c_longdouble' type was added to the ctypes module. + +- Bug #1709599: Run test_1565150 only if the file system is NTFS. + +- When encountering a password-protected robots.txt file the RobotFileParser + no longer prompts interactively for a username and password (bug 813986). + +- TarFile.__init__() no longer fails if no name argument is passed and + the fileobj argument has no usable name attribute (e.g. StringIO). + +- The functools module now provides 'reduce', for forward compatibility + with Python 3000. + +- Server-side SSL support and cert verification added, by Bill Janssen. + +- socket.ssl deprecated; use new ssl module instead. + +- uuid creation is now threadsafe. + +- EUC-KR codec now handles the cheot-ga-keut composed make-up hangul + syllables. + +- GB18030 codec now can encode additional two-byte characters that + are missing in GBK. + +- Add new codecs for UTF-32, UTF-32-LE and UTF-32-BE. + +- Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot + represent the result in a single character. + +- Bug #978833: Close https sockets by releasing the _ssl object. + +- Change location of the package index to pypi.python.org/pypi + +- Bug #1701409: Fix a segfault in printing ctypes.c_char_p and + ctypes.c_wchar_p when they point to an invalid location. As a + sideeffect the representation of these instances has changed. + +- tarfile.py: Added "exclude" keyword argument to TarFile.add(). + +- Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute. + +- The urlopen function of urllib2 now has an optional timeout parameter (note + that it actually works with HTTP, HTTPS, FTP and FTPS connections). + +- In ftplib, the FTP.ntransfercmd method, when in passive mode, now uses + the socket.create_connection function, using the timeout specified at + connection time. + +- Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it + reads a file that ends with incomplete sequence and sizehint argument + for .read() is specified. + +- Bug #1730389: Change time.strptime() to use ``\s+`` instead of ``\s*`` when + matching spaces in the specified format argument. + +- SF 1668596/1720897: distutils now copies data files + even if package_dir is empty. + +- sha now raises a DeprecationWarning upon import. + +- md5 now raises a DeprecationWarning upon import. + +- Issue1385: The hmac module now computes the correct hmac when using hashes + with a block size other than 64 bytes (such as sha384 and sha512). + +- mimify now raises a DeprecationWarning upon import. + +- MimeWriter now raises a DeprecationWarning upon import. + +- tarfile.py: Improved unicode support. Unicode input names are now + officially supported. Added "errors" argument to the TarFile class. + +- urllib.ftpwrapper class now accepts an optional timeout. + +- shlex.split() now has an optional "posix" parameter. + +- The posixfile module now raises a DeprecationWarning. + +- Remove the gopherlib module. This also leads to the removal of gopher + support in urllib/urllib2. + +- Fix bug in marshal where bad data would cause a segfault due to + lack of an infinite recursion check. + +- Removed plat-freebsd2 and plat-freebsd3 directories (and IN.py in + the directories). + +- HTML-escape the plain traceback in cgitb's HTML output, to prevent + the traceback inadvertently or maliciously closing the comment and + injecting HTML into the error page. + +- The popen2 module and os.popen* are deprecated. Use the subprocess module. + +- Added an optional credentials argument to SMTPHandler, for use with SMTP + servers which require authentication. + +- Patch #1695948: Added optional timeout parameter to SocketHandler. + +- Bug #1652788: Minor fix for currentframe. + +- Patch #1598415: Added WatchedFileHandler to better support external + log file rotation using e.g. newsyslog or logrotate. This handler is + only useful in Unix/Linux environments. + +- Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file + (as opposed to the command line) will now write file names ending in + ".cpp" too. + +- As specified in RFC 2616, an HTTP response like 2xx indicates that + the client's request was successfully received, understood, and accepted. + Now in these cases no error is raised in urllib (issue #1177) and urllib2. + +- Bug #1290505: time.strptime's internal cache of locale information is now + properly recreated when the locale is changed. + +- Patch #1685563: remove (don't add) duplicate paths in distutils.MSVCCompiler. + +- Added a timeout parameter to the constructor of other protocols + (telnetlib, ftplib, smtplib and poplib). This is second part of the + work started with create_connection() and timeout in httplib, and + closes patch #723312. + +- Patch #1676823: Added create_connection() to socket.py, which may be + called with a timeout, and use it from httplib (whose HTTPConnection + and HTTPSConnection now accept an optional timeout). + +- Bug #978833: Revert r50844, as it broke _socketobject.dup. + +- Bug #1675967: re patterns pickled with Python 2.4 and earlier can + now be unpickled with Python 2.5 and newer. + +- Patch #1630118: add a SpooledTemporaryFile class to tempfile.py. + +- Patch #1273829: os.walk() now has a "followlinks" parameter. If set to + True (which is not the default), it visits symlinks pointing to + directories. + +- Bug #1681228: the webbrowser module now correctly uses the default + GNOME or KDE browser, depending on whether there is a session of one + of those present. Also, it tries the Windows default browser before + trying Mozilla variants. + +- Patch #1339796: add a relpath() function to os.path. + +- Patch #1681153: the wave module now closes a file object it opened if + initialization failed. + +- Bug #767111: fix long-standing bug in urllib which caused an + AttributeError instead of an IOError when the server's response didn't + contain a valid HTTP status line. + +- Patch #957650: "%var%" environment variable references are now properly + expanded in ntpath.expandvars(), also "~user" home directory references + are recognized and handled on Windows. + +- Patch #1429539: pdb now correctly initializes the __main__ module for + the debugged script, which means that imports from __main__ work + correctly now. + +- The nonobvious commands.getstatus() function is now deprecated. + +- Patch #1393667: pdb now has a "run" command which restarts the debugged + Python program, optionally with different arguments. + +- Patch #1649190: Adding support for _Bool to ctypes as c_bool. + +- Patch #1530482: add pydoc.render_doc() which returns the documentation + for a thing instead of paging it to stdout, which pydoc.doc() does. + +- Patch #1533909: the timeit module now accepts callables in addition to + strings for the code to time and the setup code. Also added two + convenience functions for instantiating a Timer and calling its methods. + +- Patch #1537850: tempfile.NamedTemporaryFile now has a "delete" parameter + which can be set to False to prevent the default delete-on-close + behavior. + +- Patch #1581073: add a flag to textwrap that prevents the dropping of + whitespace while wrapping. + +- Patch #1603688: ConfigParser.SafeConfigParser now checks values that + are set for invalid interpolation sequences that would lead to errors + on reading back those values. + +- Added support for the POSIX.1-2001 (pax) format to tarfile.py. Extended + and cleaned up the test suite. Added a new testtar.tar. + +- Patch #1449244: Support Unicode strings in + email.message.Message.{set_charset,get_content_charset}. + +- Patch #1542681: add entries for "with", "as" and "CONTEXTMANAGERS" to + pydoc's help keywords. + +- Patch #1555098: use str.join() instead of repeated string + concatenation in robotparser. + +- Patch #1635454: the csv.DictWriter class now includes the offending + field names in its exception message if you try to write a record with + a dictionary containing fields not in the CSV field names list. + +- Patch #1668100: urllib2 now correctly raises URLError instead of + OSError if accessing a local file via the file:// protocol fails. + +- Patch #1677862: Require a space or tab after import in .pth files. + +- Patch #1192590: Fix pdb's "ignore" and "condition" commands so they trap + the IndexError caused by passing in an invalid breakpoint number. + +- Patch #1599845: Add an option to disable the implicit calls to server_bind() + and server_activate() in the constructors for TCPServer, SimpleXMLRPCServer + and DocXMLRPCServer. + +- Bug #1531963: Make SocketServer.TCPServer's server_address always + be equal to calling getsockname() on the server's socket. Fixed by + patch #1545011. + +- Patch #742598: Add .timeout attribute to SocketServer that calls + .handle_timeout() when no requests are received. + +- Bug #1651235: When a tuple was passed to a ctypes function call, + Python would crash instead of raising an error. + +- Bug #1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0) + returned string up to the first NUL character. + +- Patch #957003: Implement smtplib.LMTP. + +- Patch #1481079: add support for HTTP_REFERER to CGIHTTPServer. + +- Patch #1675424: Added tests for uncovered code in the zipfile module. + The KeyError raised by Zipfile.getinfo for nonexistent names now has + a descriptive message. + +- Bug #1115886: os.path.splitext('.cshrc') gives now ('.cshrc', ''). + +- unittest now verifies more of its assumptions. In particular, TestCase + and TestSuite subclasses (not instances) are no longer accepted in + TestSuite.addTest(). This should cause no incompatibility since it + never made sense with ordinary subclasses -- the failure just occurred + later, with a more cumbersome exception. + +- Patch #787789: allow to pass custom TestRunner instances to unittest's + main() function. + +- Patches #1550273, #1550272: fix a few bugs in unittest and add a + comprehensive test suite for the module. + +- Patch #1001604: glob.glob() now returns unicode filenames if it was + given a unicode argument and os.listdir() returns unicode filenames. + +- Patch #1673619: setup.py identifies extension modules it doesn't know how + to build and those it knows how to build but that fail to build. + +- Patch #912410: Replace HTML entity references for attribute values + in HTMLParser. + +- Patch #1663234: you can now run doctest on test files and modules + using "python -m doctest [-v] filename ...". + +- Patch #1121142: Implement ZipFile.open. + +- Taught setup.py how to locate Berkeley DB on Macs using MacPorts. + +- Added heapq.merge() for merging sorted input streams. + +- Added collections.namedtuple() for assigning field names to tuples. + +- Added itertools.izip_longest(). + +- Have the encoding package's search function dynamically import using absolute + import semantics. + +- Patch #1647484: Renamed GzipFile's filename attribute to name. + +- Patch #1517891: Mode 'a' for ZipFile now creates the file if it + doesn't exist. + +- Patch #698833: Support file decryption in zipfile. + +- Patch #685268: Consider a package's __path__ in imputil. + +- Patch 1463026: Support default namespace in XMLGenerator. + +- Patch 1571379: Make trace's --ignore-dir facility work in the face of + relative directory names. + +- Bug #1600860: Search for shared python library in LIBDIR, + not lib/python/config, on "linux" and "gnu" systems. + +- Patch #1652681: tarfile.py: create nonexistent files in append mode and + allow appending to empty files. + +- Bug #1124861: Automatically create pipes if GetStdHandle fails in + subprocess. + +- Patch #1634778: add missing encoding aliases for iso8859_15 and + iso8859_16. + +- Patch #1638243: the compiler package is now able to correctly compile + a with statement; previously, executing code containing a with statement + compiled by the compiler package crashed the interpreter. + +- Bug #1643943: Fix time.strptime's support for the %U directive. + +- Patch #1507247: tarfile.py: use current umask for intermediate + directories. + +- Patch #1627441: close sockets properly in urllib2. + +- Bug #494589: make ntpath.expandvars behave according to its docstring. + +- Changed platform module API python_version_tuple() to actually + return a tuple (it used to return a list). + +- Added new platform module APIs python_branch(), python_revision(), + python_implementation() and linux_distribution(). + +- Added support for IronPython and Jython to the platform module. + +- The sets module has been deprecated. Use the built-in set/frozenset types + instead. + +- Bug #1610795: make ctypes.util.find_library work on BSD systems. + +- Fixes for 64-bit Windows: In ctypes.wintypes, correct the + definitions of HANDLE, WPARAM, LPARAM data types. Make + parameterless foreign function calls work. + +- The version number of the ctypes package changed to "1.1.0". + +- Bug #1627575: logging: Added _open() method to FileHandler which can + be used to reopen files. The FileHandler instance now saves the + encoding (which can be None) in an attribute called "encoding". + +- Bug #411881: logging.handlers: bare except clause removed from + SMTPHandler.emit. Now, only ImportError is trapped. + +- Bug #411881: logging.handlers: bare except clause removed from + SocketHandler.createSocket. Now, only socket.error is trapped. + +- Bug #411881: logging: bare except clause removed from LogRecord.__init__. + Now, only ValueError, TypeError and AttributeError are trapped. + +- Patch #1504073: Fix tarfile.open() for mode "r" with a fileobj argument. + +- Patch #1182394 from Shane Holloway: speed up HMAC.hexdigest. + +- Patch #1262036: Prevent TarFiles from being added to themselves under + certain conditions. + +- Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() + work correctly together with readline(). + +- Patch #1484695: The tarfile module now raises a HeaderError exception + if a buffer given to frombuf() is invalid. + +- Bug #1503765: Fix a problem in logging.config with spaces in comma- + separated lists read from logging config files. + +- Patch #1604907: Fix problems in logging.handlers caused at logging shutdown + when syslog handlers fail to initialize because of syslogd problems. + +- Patch #1608267: fix a race condition in os.makedirs() if the directory + to be created is already there. + +- Patch #1610437: fix a tarfile bug with long filename headers. + +- Patch #1371075: Make ConfigParser accept optional dict type + for ordering, sorting, etc. + +- Bug #1563807: _ctypes built on AIX fails with ld ffi error. + +- Bug #1598620: A ctypes Structure cannot contain itself. + +- Patch #1070046: Marshal new-style objects like InstanceType + in xmlrpclib. + +- cStringIO.truncate(-1) now raises an IOError, like StringIO and + regular files. + +- Patch #1472877: Fix Tix subwidget name resolution. + +- Patch #1594554: Always close a tkSimpleDialog on ok(), even + if an exception occurs. + +- Patch #1538878: Don't make tkSimpleDialog dialogs transient if + the parent window is withdrawn. + +- Bug #1597824: return the registered function from atexit.register() + to facilitate usage as a decorator. + +- Patch #1360200: Use unmangled_version RPM spec field to deal with + file name mangling. + +- Patch #1359217: Process 2xx response in an ftplib transfer + that precedes an 1xx response. + +- Patch #1355023: support whence argument for GzipFile.seek. + +- Patch #1065257: Support passing open files as body in + HTTPConnection.request(). + +- Bug #1569790: mailbox.py: Maildir.get_folder() and MH.get_folder() + weren't passing the message factory on to newly created Maildir/MH + objects. + +- Patch #1514543: mailbox.py: In the Maildir class, report errors if there's + a filename clash instead of possibly losing a message. (Patch by David + Watson.) + +- Patch #1514544: Try to ensure that messages/indexes have been physically + written to disk after calling .flush() or .close(). (Patch by David + Watson.) + +- Patch #1592250: Add elidge argument to Tkinter.Text.search. + +- Patch #838546: Make terminal become controlling in pty.fork() + +- Patch #1351744: Add askyesnocancel helper for tkMessageBox. + +- Patch #1060577: Extract list of RPM files from spec file in + bdist_rpm + +- Bug #1586613: fix zlib and bz2 codecs' incremental en/decoders. + +- Patch #1583880: fix tarfile's problems with long names and posix/ + GNU modes. + +- Bug #1586448: the compiler module now emits the same bytecode for + list comprehensions as the builtin compiler, using the LIST_APPEND + opcode. + +- Fix codecs.EncodedFile which did not use file_encoding in 2.5.0, and + fix all codecs file wrappers to work correctly with the "with" + statement (bug #1586513). + +- Lib/modulefinder.py now handles absolute and relative imports + correctly. + +- Patch #1567274: Support SMTP over TLS. + +- Patch #1560695: Add .note.GNU-stack to ctypes' sysv.S so that + ctypes isn't considered as requiring executable stacks. + +- ctypes callback functions only support 'fundamental' data types as + result type. Raise an error when something else is used. This is a + partial fix for Bug #1574584. + +- Fix turtle so that time.sleep is imported for the entire library. Allows + the demo2 function to be executed on its own instead of only when the + module is run as a script. + +- Bug #813342: Start the IDLE subprocess with -Qnew if the parent + is started with that option. + +- Bug #1565150: Fix subsecond processing for os.utime on Windows. + +- Support for MSVC 8 was added to bdist_wininst. + +- Bug #1446043: correctly raise a LookupError if an encoding name given + to encodings.search_function() contains a dot. + +- Bug #1560617: in pyclbr, return full module name not only for classes, + but also for functions. + +- Bug #1457823: cgi.(Sv)FormContentDict's constructor now takes + keep_blank_values and strict_parsing keyword arguments. + +- Bug #1566602: correct failure of posixpath unittest when $HOME ends + with a slash. + +- Bug #1565661: in webbrowser, split() the command for the default + GNOME browser in case it is a command with args. + +- Made the error message for time.strptime when the data data and format do + match be more clear. + +- Fix a bug in traceback.format_exception_only() that led to an error + being raised when print_exc() was called without an exception set. + In version 2.4, this printed "None", restored that behavior. + +- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because + the close_fds arg to subprocess.Popen is not supported). + +- Reverted patch #1504333 to sgmllib because it introduced an infinite loop. + +- Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE + by adding smarter caching in inspect.getmodule() + +- Fix missing import of the types module in logging.config. + +- Patch #1550886: Fix decimal module context management implementation + to match the localcontext() example from PEP 343. + +- Bug #1545341: The 'classifier' keyword argument to the Distutils setup() + function now accepts tuples as well as lists. + +- Bug #1541863: uuid.uuid1 failed to generate unique identifiers + on systems with low clock resolution. + +- Bug #1531862: Do not close standard file descriptors in subprocess. + +- idle: Honor the "Cancel" action in the save dialog (Debian bug #299092). + +- Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the + first chunk fed to the decoder started with a BOM, but was longer than 3 bytes. + +- The implementation of UnicodeError objects has been simplified (start and end + attributes are now stored directly as Py_ssize_t members). + +- Issue829951: In the smtplib module, SMTP.starttls() now complies with + RFC 3207 and forgets any knowledge obtained from the server not obtained + from the TLS negotiation itself. Patch contributed by Bill Fenner. + +- Issue1339: The smtplib.SMTP class has been refactored a bit such + that the SMTP.starttls() caller no longer needs to call ehlo() + beforehand. SMTP.starttls() now raises an exception of the server + does not claim to support starttls. Adds the SMTP.ehlo_or_helo_if_needed() + method. Patch contributed by Bill Fenner. + + +>>>>>>> .merge-right.r60891 Extension Modules ----------------- <<<<<<< .working +<<<<<<< .working - Issue #1762972: Readded the reload() function as imp.reload() ======= +======= +- #2112: mmap.error is now a subclass of EnvironmentError and not a + direct EnvironmentError + +>>>>>>> .merge-right.r60878 - Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ - #2063: correct order of utime and stime in os.times() result on Windows. >>>>>>> .merge-right.r60845 +<<<<<<< .working +======= +- Updated ``big5hkscs`` codec to the HKSCS revision of 2004. + +- #1940: make it possible to use curses.filter() before curses.initscr() + as the documentation says. + +- Backport of _fileio module from Python 3.0. + +- #1087741: mmap.mmap is now a class, not a factory function. It is also + subclassable now. + +- Patch #1648: added ``sys.getprofile()`` and ``sys.gettrace()``. + +- Patch #1663329: added ``os.closerange()`` function to quickly close a range + of file descriptors without considering errors. + +- Patch 976880: ``mmap`` objects now have an ``rfind`` method that + works as expected. ``mmap.find`` also takes an optional ``end`` + parameter. + +- _winreg's HKEY object has gained __enter__ and __exit__ methods to support + the context manager protocol. The _winreg module also gained a new function + ``ExpandEnvironmentStrings`` to expand REG_EXPAND_SZ keys. + +- itertools.starmap() now accepts any iterable input. Previously, it required + the function inputs to be tuples. + +- Issue #1646: Make socket support TIPC. The socket module now has support + for TIPC under Linux, see http://tipc.sf.net/ for more information. + +- Added interface for Windows' WSAIoctl to socket object and added an example + for a simple network sniffer. + +- Bug #1301: Bad assert in _tkinter fixed. + +- Added bdist_wininst executable for VS 2008. + +- Bug #1604: collections.deque.__init__(iterable) now clears any prior contents + before adding elements from the iterable. This fix brings the behavior into + line with that for list.__init__(). + +- Added wide char functions to msvcrt module: getwch, getwche, putwch and + ungetwch. The functions accept or return unicode. + +- os.access now returns True on Windows for any existing directory. + +- Added warnpy3k function to the warnings module. + +- Marshal.dumps() now expects exact type matches for int, long, float, complex, + tuple, list, dict, set, and frozenset. Formerly, it would silently miscode + subclasses of those types. Now, it raises a ValueError instead. + +- Patch #1388440: Add set_completion_display_matches_hook and + get_completion_type to readline. + +- Bug #1649098: Avoid declaration of zero-sized array declaration in + structure. + +- Removed the rgbimg module; been deprecated since Python 2.5. + +- Bug #1721309: prevent bsddb module from freeing random memory. + +- Bug #1233: fix bsddb.dbshelve.DBShelf append method to work as + intended for RECNO databases. + +- pybsddb.sf.net Bug #477182: Load the database flags at database open + time so that opening a database previously created with the DB_DUP or + DB_DUPSORT flag set will keep the proper behavior on subsequent opens. + Specifically: dictionary assignment to a DB object will replace all + values for a given key when the database allows duplicate values. + DB users should use DB.put(k, v) when they want to store duplicates; not + DB[k] = v. + +- Add the bsddb.db.DBEnv.lock_id_free method. + +- Bug #1686475: Support stat'ing open files on Windows again. + +- Patch #1185447: binascii.b2a_qp() now correctly quotes binary characters + with ASCII value less than 32. Also, it correctly quotes dots only if + they occur on a single line, as opposed to the previous behavior of + quoting dots if they are the second character of any line. + +- Bug #1622896: fix a rare corner case where the bz2 module raised an + error in spite of a succesful compression. + +- Patch #1654417: make operator.{get,set,del}slice use the full range + of Py_ssize_t. + +- Patch #1646728: datetime.fromtimestamp fails with negative + fractional times. With unittest. + +- Patch #1490190: posixmodule now includes os.chflags() and os.lchflags() + functions on platforms where the underlying system calls are available. + +- Patch #1494140: Add documentation for the new struct.Struct object. + +- Patch #1432399: Support the HCI protocol for bluetooth sockets + +- Patch #1657276: Make NETLINK_DNRTMSG conditional. + +- Bug #1653736: Complain about keyword arguments to time.isoformat. + +- Bug #1486663: don't reject keyword arguments for subclasses of builtin + types. + +- Patch #1610575: The struct module now supports the 't' code, for + C99 _Bool. + +- Patch #1635058: ensure that htonl and friends never accept or + return negative numbers, per the underlying C implementation. + +- Patch #1544279: Improve thread-safety of the socket module by moving + the sock_addr_t storage out of the socket object. + +- Patch #1019808: fix bug that causes an incorrect error to be returned + when a socket timeout is set and a connection attempt fails. + +- Speed up function calls into the math module. + +- Bug #1588217: don't parse "= " as a soft line break in binascii's + a2b_qp() function, instead leave it in the string as quopri.decode() + does. + +- Bug #1599782: Fix segfault on bsddb.db.DB().type(). + +- Bug #1567666: Emulate GetFileAttributesExA for Win95. + +- Patch #1576166: Support os.utime for directories on Windows NT+. + +- Patch #1572724: fix typo ('=' instead of '==') in _msi.c. + +- Bug #1572832: fix a bug in ISO-2022 codecs which may cause segfault + when encoding non-BMP unicode characters. + +- Bug #1556784: allow format strings longer than 127 characters in + datetime's strftime function. + +- Fix itertools.count(n) to work with negative numbers again. + +- RLIMIT_SBSIZE was added to the resource module where available. + +- Bug #1551427: fix a wrong NULL pointer check in the win32 version + of os.urandom(). + +- Bug #1548092: fix curses.tparm seg fault on invalid input. + +- Patch #1114: fix curses module compilation on 64-bit AIX, & possibly + other 64-bit LP64 platforms where attr_t is not the same size as a long. + (Contributed by Luke Mewburn.) + +- Bug #1550714: fix SystemError from itertools.tee on negative value for n. + +- Fixed a few bugs on cjkcodecs: + - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. + - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 + codepoints to conform the standard. + - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2 + codepoints now. + +- Bug #1552726: in readline.c, avoid repeatedly polling in interactive + mode by only placing a timeout on the select() if an input hook has + been defined. This prevents an interactive Python from waking up 10 + times per second. Patch by Richard Boulton. + +- fixed a bug with bsddb.DB.stat: the flags and txn keyword arguments + were transposed. + +- Added support for linking the bsddb module against BerkeleyDB 4.5.x + and 4.6.x. + +- Bug #1633621: if curses.resizeterm() or curses.resize_term() is called, + update _curses.LINES, _curses.COLS, curses.LINES and curses.COLS. + +- Fix an off-by-one bug in locale.strxfrm(). + +- Fix libffi configure for hppa*-*-linux* | parisc*-*-linux*. + +- Build using system ffi library on arm*-linux*. + +- Bug #1372: zlibmodule.c: int overflow in PyZlib_decompress + +- bsddb module: Fix memory leak when using database cursors on + databases without a DBEnv. + +Tests +----- + +- Refactor test_logging to use doctest. + +- Refactor test_profile and test_cprofile to use the same code to profile. + +- Make test_runpy reentrant by fixing _check_module to clear out any module + being tested. Was causing an error by __import__ doing a reload on the + second run and thus suppressing bytecode recreation. + +- Capture socket connection resets and timeouts in test_socket_ssl and + test_urllib2net and raise test.test_support.ResourceDenied. + +- Patch #1559413: Fix test_cmd_line if sys.executable contains a space. + +- Added test.test_support.TransientResource which is a context manager to + surround calls to resources that are not guaranteed to work even if + test.test_support.requires says that the resource should exist. + +- Added a test for slicing of an exception. + +- Added test.test_support.EnvironmentVarGuard. It's a class that provides a + context manager so that one can temporarily set or unset environment + variables. + +- Added some tests for modulefinder. + +- Converted test_imp to use unittest. + +- Fix bsddb test_basics.test06_Transactions to check the version + number properly. + +- test.test_support.catch_warning is a new context manager that can be used + to catch the warnings issued by the warning framework. + + +Tools +----- + +- Tools/scripts/reindent.py now creates the backup file using shutil.copy + to preserve user/group and permissions. Added also a --nobackup option + to not create the backup if the user is concerned regarding this. Check + issue 1050828 for more details. + +- Tools/scripts/win_add2path.py was added. The simple script modifes the + PATH environment var of the HKCU tree and adds the python bin and script + directory. + +- Tools/18n/pygettext.py was added to the list of scripts installed by + Tools/scripts/setup.py (tracker item 642309). + +- Added IronPython and Jython support to pybench (part of which + was patch #1563844) + +- Made some minor changes to pybench output to allow the user + to see which Python version is running pybench + +- Added support for the new platform module feature + platform.python_implementation(); this will now be saved + in the benchmark pickle + + +Documentation +------------- + +- RFE #1765140: Updated documentation on FileHandler and subclasses to + include new optional delay argument. + +- Bug #932563: Added section on getting contextual information into logging + output, and added documentation for the new LoggerAdapter class. + +- Bug #1295: Added information about caching of formatted exception + information in the LogRecord by Formatter.format(). + +- Bug #1637365: add subsection about "__name__ == __main__" to the + Python tutorial. + +- Patch #1698768: updated the "using Python on the Mac" intro. + +- Bug #1569057: Document that calling file.next() when the file is open for + writing is undefined. + +- Patch #1489771: the syntax rules in Python Reference Manual were + updated to reflect the current Python syntax. + +- Patch #1686451: Fix return type for + PySequence_{Count,Index,Fast_GET_SIZE}. + +- Patch #1679379: add documentation for fnmatch.translate(). + +- Bug #1629566: clarify the docs on the return values of parsedate() + and parsedate_tz() in email.utils and rfc822. + +- Patch #1671450: add a section about subclassing builtin types to the + "extending and embedding" tutorial. + +- Bug #1629125: fix wrong data type (int -> Py_ssize_t) in PyDict_Next + docs. + +- Bug #1565919: document set types in the Language Reference. + +- Bug #1546052: clarify that PyString_FromString(AndSize) copies the + string pointed to by its parameter. + +- Bug #1566663: remove obsolete example from datetime docs. + +- Bug #1541682: Fix example in the "Refcount details" API docs. + Additionally, remove a faulty example showing PySequence_SetItem applied + to a newly created list object and add notes that this isn't a good idea. + + +Tools/Demos +----------- + +- Patch #1552024: add decorator support to unparse.py demo script. + +- Make auto-generated python.vim file list built-ins and exceptions in + alphatbetical order. Makes output more deterministic and easier to tell if + the file is stale or not. + +- Bug #1546372: Fixed small bugglet in pybench that caused a missing + file not to get reported properly. + + +Build +----- + +- Have the search path for building extensions follow the declared order in + $CPPFLAGS and $LDFLAGS when adding directories from those environment + variables. + +- Bug #1983: Added a check to pyport to verify that sizeof(pid_t) is + smaller or equal sizeof(long). + +- Bug #1234: Fixed semaphore errors on AIX 5.2 + +- Issue #1726: Remove Python/atof.c from PCBuild/pythoncore.vcproj + +- Removed PCbuild8/ directory and added a new build directory for VS 2005 + based on the VS 2008 build directory to PC/VS8.0. The script + PCbuild/vs8to9.py was added to sync changes from PCbuild to PC/VS8.0. + +- Moved PCbuild/ directory for VS 2003 to PC/VS7.1 and renamed PCBuild9/ + directory to PCBuild/. + +- Bug #1699: Define _BSD_SOURCE only on OpenBSD. + +- Bug #1608: use -fwrapv when GCC supports it. This is important, + newer GCC versions may optimize away overflow buffer overflow checks + without this option! + +- Patch #1418: Make the AC_REPLACE_FUNCS object files actually work. + +- Add a FAST_LOOPS build option that speeds-up looping by trading away + periodic threadstate and signal checking in tight loops. By default, + this option is turned-off. It should only be enabled in debugged, + performance critical applications. + +- Patch #786737: Allow building in a tree of symlinks pointing to + a readonly source. + +- Bug #1737210: Change Manufacturer of Windows installer to PSF. + +- Bug #1746880: Correctly install DLLs into system32 folder on Win64. + +- Define _BSD_SOURCE, to get access to POSIX extensions on OpenBSD 4.1+. + +- Stop supporting AtheOS and cause a build error in configure for the platform. + +- Bug #1655392: don't add -L/usr/lib/pythonX.Y/config to the LDFLAGS + returned by python-config if Python was built with --enable-shared + because that prevented the shared library from being used. + +- Patch #1569798: fix a bug in distutils when building Python from a + directory within sys.exec_prefix. + +- Bug #1675511: Use -Kpic instead of -xcode=pic32 on Solaris/x86. + +- Disable _XOPEN_SOURCE on NetBSD 1.x. + +- configure now checks whether gcc supports the PyArg_ParseTuple format + attribute. + +- Bug #1578513: Cross compilation was broken by a change to configure. + Repair so that it's back to how it was in 2.4.3. + +- Patch #1576954: Update VC6 build directory; remove redundant + files in VC7. + +- Bug #1568842: Fix test for uintptr_t. + +- Patch #1540470, for OpenBSD 4.0. + +- Fix build failure on kfreebsd and on the hurd. + +- Fix the build of the library reference in info format. + +- Allow Emacs 22 for building the documentation in info format. + +- Makefile.pre.in(buildbottest): Run an optional script pybuildbot.identify + to include some information about the build environment. + + +C API +----- + +- Unified naming convention for free lists and their limits. All free lists + in Object/ are named ``free_list``, the counter ``numfree`` and the upper + limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. + +- ``PySet_Add()`` can now modify a newly created frozenset. Similarly to + ``PyTuple_SetItem``, it can be used to populate a brand new frozenset; but + it does not steal a reference to the added item. + +- Added ``PySet_Check()`` and ``PyFrozenSet_Check()`` to the set API. + +- Backport of PyUnicode_FromString(), _FromStringAndSize(), _Format and + _FormatV from Python 3.0. Made PyLong_AsSsize_t and PyLong_FromSsize_t + public functions. + +- Patch #1720595: add T_BOOL to the range of structmember types. + +- Issue #1534: Added ``PyFloat_GetMax()``, ``PyFloat_GetMin()`` and + ``PyFloat_GetInfo()`` to the float API. + +- Issue #1521: On 64bit platforms, using PyArgs_ParseTuple with the t# of w# + format code incorrectly truncated the length to an int, even when + PY_SSIZE_T_CLEAN is set. The str.decode method used to return incorrect + results with huge strings. + +- Issue #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE + and Py_REFCNT. + +- PEP 3123: Provide forward compatibility with Python 3.0, while keeping + backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and + PyVarObject_HEAD_INIT. + +- Py_ssize_t fields work in structmember when HAVE_LONG_LONG is not defined. + +- Patch #1733960: Allow T_LONGLONG to accept ints. + +- T_PYSSIZET can now be used in PyMemberDef lists for Py_ssize_t members. + +- Added a new API function ``PyImport_ImportModuleNoBlock``. + +- Bug #1637022: Prefix AST symbols with _Py_. + +- Fix some leftovers from the conversion from int to Py_ssize_t + (relevant to strings and sequences of more than 2**31 items). + +- Make _PyGILState_NoteThreadState() static, it was not used anywhere + outside of pystate.c and should not be necessary. + +- ``PyImport_Import`` and ``PyImport_ImportModule`` now always do absolute + imports. In earlier versions they might have used relative imports under + some conditions. + +- Added case insensitive comparison methods ``PyOS_stricmp(char*, char*)`` + and ``PyOS_strnicmp(char*, char*, Py_ssize_t)``. + +- Bug #1542693: remove semi-colon at end of PyImport_ImportModuleEx macro + so it can be used as an expression. + + +Windows +------- + +- Patch #1706: Drop support for Win9x, WinME and NT4. Python now requires + Windows 2000 or greater. The _WINVER and NTDDI_VERSION macros are set to + Win2k for x86/32bit builds and WinXP for AMD64 builds. + +- Conditionalize definition of _CRT_SECURE_NO_DEPRECATE + and _CRT_NONSTDC_NO_DEPRECATE. + +- Bug #1216: Restore support for Visual Studio 2002. + + +Mac +--- + +- cfmfile now raises a DeprecationWarning. + +- buildtools now raises a DeprecationWarning. + +- Removed the macfs module. It had been deprecated since Python 2.5. This + lead to the deprecation of macostools.touched() as it relied solely on macfs + and was a no-op under OS X. + + +What's New in Python 2.5 release candidate 1? +============================================= + +*Release date: 17-AUG-2006* + +Core and builtins +----------------- + +- Unicode objects will no longer raise an exception when being + compared equal or unequal to a string and a UnicodeDecodeError + exception occurs, e.g. as result of a decoding failure. + + Instead, the equal (==) and unequal (!=) comparison operators will + now issue a UnicodeWarning and interpret the two objects as + unequal. The UnicodeWarning can be filtered as desired using + the warning framework, e.g. silenced completely, turned into an + exception, logged, etc. + + Note that compare operators other than equal and unequal will still + raise UnicodeDecodeError exceptions as they've always done. + +- Fix segfault when doing string formatting on subclasses of long. + +- Fix bug related to __len__ functions using values > 2**32 on 64-bit machines + with new-style classes. + +- Fix bug related to __len__ functions returning negative values with + classic classes. + +- Patch #1538606, Fix __index__() clipping. There were some problems + discovered with the API and how integers that didn't fit into Py_ssize_t + were handled. This patch attempts to provide enough alternatives + to effectively use __index__. + +- Bug #1536021: __hash__ may now return long int; the final hash + value is obtained by invoking hash on the long int. + +- Bug #1536786: buffer comparison could emit a RuntimeWarning. + +- Bug #1535165: fixed a segfault in input() and raw_input() when + sys.stdin is closed. + +- On Windows, the PyErr_Warn function is now exported from + the Python dll again. + +- Bug #1191458: tracing over for loops now produces a line event + on each iteration. Fixing this problem required changing the .pyc + magic number. This means that .pyc files generated before 2.5c1 + will be regenerated. + +- Bug #1333982: string/number constants were inappropriately stored + in the byte code and co_consts even if they were not used, ie + immediately popped off the stack. + +- Fixed a reference-counting problem in property(). + + +>>>>>>> .merge-right.r60878 Library ------- Modified: python/branches/py3k/Modules/mmapmodule.c ============================================================================== --- python/branches/py3k/Modules/mmapmodule.c (original) +++ python/branches/py3k/Modules/mmapmodule.c Tue Feb 19 15:21:46 2008 @@ -1326,7 +1326,10 @@ dict = PyModule_GetDict(module); if (!dict) return; - mmap_module_error = PyExc_EnvironmentError; + mmap_module_error = PyErr_NewException("mmap.error", + PyExc_EnvironmentError , NULL); + if (mmap_module_error == NULL) + return; PyDict_SetItemString(dict, "error", mmap_module_error); PyDict_SetItemString(dict, "mmap", (PyObject*) &mmap_object_type); #ifdef PROT_EXEC Modified: python/branches/py3k/PC/VC6/pythoncore.dsp ============================================================================== --- python/branches/py3k/PC/VC6/pythoncore.dsp (original) +++ python/branches/py3k/PC/VC6/pythoncore.dsp Tue Feb 19 15:21:46 2008 @@ -125,6 +125,10 @@ # End Source File # Begin Source File +SOURCE=..\..\Modules\_collectionsmodule.c +# End Source File +# Begin Source File + SOURCE=..\..\Modules\_csv.c # End Source File # Begin Source File @@ -349,6 +353,14 @@ # End Source File # Begin Source File +SOURCE=..\..\Python\formatter_string.c +# End Source File +# Begin Source File + +SOURCE=..\..\Python\formatter_unicode.c +# End Source File +# Begin Source File + SOURCE=..\..\Objects\frameobject.c # End Source File # Begin Source File Modified: python/branches/py3k/PC/VS7.1/pythoncore.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/pythoncore.vcproj (original) +++ python/branches/py3k/PC/VS7.1/pythoncore.vcproj Tue Feb 19 15:21:46 2008 @@ -515,6 +515,9 @@ RelativePath="..\..\Objects\floatobject.c"> + + Author: travis.oliphant Date: Tue Feb 19 19:03:53 2008 New Revision: 60906 Modified: python/branches/py3k/Include/object.h Log: Remove unused and non-PEP-related entry from PyBufferProcs Modified: python/branches/py3k/Include/object.h ============================================================================== --- python/branches/py3k/Include/object.h (original) +++ python/branches/py3k/Include/object.h Tue Feb 19 19:03:53 2008 @@ -277,7 +277,6 @@ typedef struct { getbufferproc bf_getbuffer; releasebufferproc bf_releasebuffer; - inquiry bf_multisegment; } PyBufferProcs; typedef void (*freefunc)(void *); From python-3000-checkins at python.org Thu Feb 21 21:16:31 2008 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 21 Feb 2008 21:16:31 +0100 (CET) Subject: [Python-3000-checkins] r60931 - python/branches/py3k/Misc/NEWS Message-ID: <20080221201631.CB5BC1E4022@bag.python.org> Author: guido.van.rossum Date: Thu Feb 21 21:16:31 2008 New Revision: 60931 Modified: python/branches/py3k/Misc/NEWS Log: Remove merge turds. Break long lines. Remove item that was rolled back (float formatting). Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Feb 21 21:16:31 2008 @@ -12,8 +12,6 @@ Core and Builtins ----------------- -<<<<<<< .working -======= - Issue #2115: Important speedup in setting __slot__ attributes. Also prevent a possible crash: an Abstract Base Class would try to access a slot on a registered virtual subclass. @@ -44,7 +42,6 @@ - Issue #1678380: Fix a bug that identifies 0j and -0j when they appear in the same code unit. ->>>>>>> .merge-right.r60845 - Issue #2025 : Add tuple.count() and tuple.index() methods to comply with the collections.Sequence API. @@ -87,18 +84,11 @@ gc module; gc.DEBUG_COLLECTABLE or gc.DEBUG_UNCOLLECTABLE are now enough to print the corresponding list of objects considered by the garbage collector. -- Issue #1580: New free format floating point representation based on - "Floating-Point Printer Sample Code", by Robert G. Burger. For example - repr(11./5) now returns '2.2' instead of '2.2000000000000002'. - - Issue #1573: Improper use of the keyword-only syntax makes the parser crash. - Issue #1564: The set implementation should special-case PyUnicode instead of PyString. - -<<<<<<< .working -======= - Issue #1402: Fix a crash on exit, when another thread is still running, and if the deallocation of its frames somehow calls the PyGILState_Ensure() / PyGILState_Release() functions. @@ -152,8 +142,8 @@ instance in case normalizing an exception put the recursion check value past its limit. Fixes crashers infinite_rec_(1|2|4|5).py. -- Patch #1031213: Decode source line in SyntaxErrors back to its original source - encoding. +- Patch #1031213: Decode source line in SyntaxErrors back to its + original source encoding. - Patch #1673759: add a missing overflow check when formatting floats with %G. @@ -523,7 +513,8 @@ - Issue #1735: TarFile.extractall() now correctly sets directory permissions and times. -- Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint. +- Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a + mountpoint. - Bug #1687: Fxed plistlib.py restricts to Python int when writing @@ -1093,7 +1084,8 @@ - idle: Honor the "Cancel" action in the save dialog (Debian bug #299092). - Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the - first chunk fed to the decoder started with a BOM, but was longer than 3 bytes. + first chunk fed to the decoder started with a BOM, but was longer than 3 + bytes. - The implementation of UnicodeError objects has been simplified (start and end attributes are now stored directly as Py_ssize_t members). @@ -1109,27 +1101,18 @@ method. Patch contributed by Bill Fenner. ->>>>>>> .merge-right.r60891 Extension Modules ----------------- -<<<<<<< .working -<<<<<<< .working - Issue #1762972: Readded the reload() function as imp.reload() -======= -======= + - #2112: mmap.error is now a subclass of EnvironmentError and not a direct EnvironmentError ->>>>>>> .merge-right.r60878 - Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ - #2063: correct order of utime and stime in os.times() result on Windows. ->>>>>>> .merge-right.r60845 - -<<<<<<< .working -======= - Updated ``big5hkscs`` codec to the HKSCS revision of 2004. - #1940: make it possible to use curses.filter() before curses.initscr() @@ -1660,7 +1643,6 @@ - Fixed a reference-counting problem in property(). ->>>>>>> .merge-right.r60878 Library ------- @@ -1670,7 +1652,8 @@ - Created new UserDict class in collections module. This one inherits from and complies with the MutableMapping ABC. -- Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. +- Removed UserDict.DictMixin. Replaced all its uses with + collections.MutableMapping. - Issue #1703: getpass() should flush after writing prompt. From python-3000-checkins at python.org Thu Feb 21 21:18:45 2008 From: python-3000-checkins at python.org (eric.smith) Date: Thu, 21 Feb 2008 21:18:45 +0100 (CET) Subject: [Python-3000-checkins] r60934 - python/branches/py3k Message-ID: <20080221201845.372681E402E@bag.python.org> Author: eric.smith Date: Thu Feb 21 21:18:44 2008 New Revision: 60934 Modified: python/branches/py3k/ (props changed) Log: Block r60932 with svnmerge. From python-3000-checkins at python.org Thu Feb 21 23:11:38 2008 From: python-3000-checkins at python.org (raymond.hettinger) Date: Thu, 21 Feb 2008 23:11:38 +0100 (CET) Subject: [Python-3000-checkins] r60941 - in python/branches/py3k: Doc/library/collections.rst Doc/library/datatypes.rst Doc/library/userdict.rst Lib/UserString.py Lib/collections.py Lib/test/test___all__.py Lib/test/test_userstring.py Misc/NEWS Message-ID: <20080221221138.20FB21E4017@bag.python.org> Author: raymond.hettinger Date: Thu Feb 21 23:11:37 2008 New Revision: 60941 Removed: python/branches/py3k/Doc/library/userdict.rst python/branches/py3k/Lib/UserString.py Modified: python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/datatypes.rst python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/test/test___all__.py python/branches/py3k/Lib/test/test_userstring.py python/branches/py3k/Misc/NEWS Log: Move UserString to collections. Removed decode() method. Added isidentifier() and format() methods. Drop MutableUserString class. Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Thu Feb 21 23:11:37 2008 @@ -706,3 +706,22 @@ special methods supported by this class will need to be overridden; please consult the sources for information about the methods which need to be provided in that case. + +:class:`UserString` objects +------------------------- + +The class, :class:`UserString` acts as a wrapper around string objects. +The need for this class has been partially supplanted by the ability to +subclass directly from :class:`str`; however, this class can be easier +to work with because the underlying string is accessible as an +attribute. + +.. class:: UserString([sequence]) + + Class that simulates a string or a Unicode string object. The instance's + content is kept in a regular string object, which is accessible via the + :attr:`data` attribute of :class:`UserString` instances. The instance's + contents are initially set to a copy of *sequence*. The *sequence* can + be an instance of :class:`bytes`, :class:`str`, :class:`UserString` (or a + subclass) or an arbitrary sequence which can be converted into a string using + the built-in :func:`str` function. Modified: python/branches/py3k/Doc/library/datatypes.rst ============================================================================== --- python/branches/py3k/Doc/library/datatypes.rst (original) +++ python/branches/py3k/Doc/library/datatypes.rst Thu Feb 21 23:11:37 2008 @@ -29,7 +29,6 @@ mutex.rst queue.rst weakref.rst - userdict.rst types.rst copy.rst pprint.rst Deleted: /python/branches/py3k/Doc/library/userdict.rst ============================================================================== --- /python/branches/py3k/Doc/library/userdict.rst Thu Feb 21 23:11:37 2008 +++ (empty file) @@ -1,61 +0,0 @@ - -:mod:`UserString` --- Class wrapper for string objects -====================================================== - -.. module:: UserString - :synopsis: Class wrapper for string objects. -.. moduleauthor:: Peter Funk -.. sectionauthor:: Peter Funk - - -.. note:: - - This :class:`UserString` class from this module is available for backward - compatibility only. If you are writing code that does not need to work with - versions of Python earlier than Python 2.2, please consider subclassing directly - from the built-in :class:`str` type instead of using :class:`UserString` (there - is no built-in equivalent to :class:`MutableString`). - -This module defines a class that acts as a wrapper around string objects. It is -a useful base class for your own string-like classes, which can inherit from -them and override existing methods or add new ones. In this way one can add new -behaviors to strings. - -It should be noted that these classes are highly inefficient compared to real -string or bytes objects; this is especially the case for -:class:`MutableString`. - -The :mod:`UserString` module defines the following classes: - - -.. class:: UserString([sequence]) - - Class that simulates a string or a Unicode string object. The instance's - content is kept in a regular string or Unicode string object, which is - accessible via the :attr:`data` attribute of :class:`UserString` instances. The - instance's contents are initially set to a copy of *sequence*. *sequence* can - be an instance of :class:`bytes`, :class:`str`, :class:`UserString` (or a - subclass) or an arbitrary sequence which can be converted into a string using - the built-in :func:`str` function. - - -.. class:: MutableString([sequence]) - - This class is derived from the :class:`UserString` above and redefines strings - to be *mutable*. Mutable strings can't be used as dictionary keys, because - dictionaries require *immutable* objects as keys. The main intention of this - class is to serve as an educational example for inheritance and necessity to - remove (override) the :meth:`__hash__` method in order to trap attempts to use a - mutable object as dictionary key, which would be otherwise very error prone and - hard to track down. - -In addition to supporting the methods and operations of bytes and string -objects (see section :ref:`string-methods`), :class:`UserString` instances -provide the following attribute: - - -.. attribute:: MutableString.data - - A real Python string or bytes object used to store the content of the - :class:`UserString` class. - Deleted: /python/branches/py3k/Lib/UserString.py ============================================================================== --- /python/branches/py3k/Lib/UserString.py Thu Feb 21 23:11:37 2008 +++ (empty file) @@ -1,244 +0,0 @@ -#!/usr/bin/env python -## vim:ts=4:et:nowrap -"""A user-defined wrapper around string objects - -Note: string objects have grown methods in Python 1.6 -This module requires Python 1.6 or later. -""" -import sys -import collections - -__all__ = ["UserString","MutableString"] - -class UserString(collections.Sequence): - def __init__(self, seq): - if isinstance(seq, str): - self.data = seq - elif isinstance(seq, UserString): - self.data = seq.data[:] - else: - self.data = str(seq) - def __str__(self): return str(self.data) - def __repr__(self): return repr(self.data) - def __int__(self): return int(self.data) - def __long__(self): return int(self.data) - def __float__(self): return float(self.data) - def __complex__(self): return complex(self.data) - def __hash__(self): return hash(self.data) - - def __eq__(self, string): - if isinstance(string, UserString): - return self.data == string.data - else: - return self.data == string - def __ne__(self, string): - if isinstance(string, UserString): - return self.data != string.data - else: - return self.data != string - def __lt__(self, string): - if isinstance(string, UserString): - return self.data < string.data - else: - return self.data < string - def __le__(self, string): - if isinstance(string, UserString): - return self.data <= string.data - else: - return self.data <= string - def __gt__(self, string): - if isinstance(string, UserString): - return self.data > string.data - else: - return self.data > string - def __ge__(self, string): - if isinstance(string, UserString): - return self.data >= string.data - else: - return self.data >= string - - def __contains__(self, char): - if isinstance(char, UserString): - char = char.data - return char in self.data - - def __len__(self): return len(self.data) - def __getitem__(self, index): return self.__class__(self.data[index]) - def __add__(self, other): - if isinstance(other, UserString): - return self.__class__(self.data + other.data) - elif isinstance(other, str): - return self.__class__(self.data + other) - else: - return self.__class__(self.data + str(other)) - def __radd__(self, other): - if isinstance(other, str): - return self.__class__(other + self.data) - else: - return self.__class__(str(other) + self.data) - def __mul__(self, n): - return self.__class__(self.data*n) - __rmul__ = __mul__ - def __mod__(self, args): - return self.__class__(self.data % args) - - # the following methods are defined in alphabetical order: - def capitalize(self): return self.__class__(self.data.capitalize()) - def center(self, width, *args): - return self.__class__(self.data.center(width, *args)) - def count(self, sub, start=0, end=sys.maxsize): - if isinstance(sub, UserString): - sub = sub.data - return self.data.count(sub, start, end) - def decode(self, encoding=None, errors=None): # XXX improve this? - if encoding: - if errors: - return self.__class__(self.data.decode(encoding, errors)) - else: - return self.__class__(self.data.decode(encoding)) - else: - return self.__class__(self.data.decode()) - def encode(self, encoding=None, errors=None): # XXX improve this? - if encoding: - if errors: - return self.__class__(self.data.encode(encoding, errors)) - else: - return self.__class__(self.data.encode(encoding)) - else: - return self.__class__(self.data.encode()) - def endswith(self, suffix, start=0, end=sys.maxsize): - return self.data.endswith(suffix, start, end) - def expandtabs(self, tabsize=8): - return self.__class__(self.data.expandtabs(tabsize)) - def find(self, sub, start=0, end=sys.maxsize): - if isinstance(sub, UserString): - sub = sub.data - return self.data.find(sub, start, end) - def index(self, sub, start=0, end=sys.maxsize): - return self.data.index(sub, start, end) - def isalpha(self): return self.data.isalpha() - def isalnum(self): return self.data.isalnum() - def isdecimal(self): return self.data.isdecimal() - def isdigit(self): return self.data.isdigit() - def islower(self): return self.data.islower() - def isnumeric(self): return self.data.isnumeric() - def isspace(self): return self.data.isspace() - def istitle(self): return self.data.istitle() - def isupper(self): return self.data.isupper() - def join(self, seq): return self.data.join(seq) - def ljust(self, width, *args): - return self.__class__(self.data.ljust(width, *args)) - def lower(self): return self.__class__(self.data.lower()) - def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) - def partition(self, sep): - return self.data.partition(sep) - def replace(self, old, new, maxsplit=-1): - if isinstance(old, UserString): - old = old.data - if isinstance(new, UserString): - new = new.data - return self.__class__(self.data.replace(old, new, maxsplit)) - def rfind(self, sub, start=0, end=sys.maxsize): - return self.data.rfind(sub, start, end) - def rindex(self, sub, start=0, end=sys.maxsize): - return self.data.rindex(sub, start, end) - def rjust(self, width, *args): - return self.__class__(self.data.rjust(width, *args)) - def rpartition(self, sep): - return self.data.rpartition(sep) - def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars)) - def split(self, sep=None, maxsplit=-1): - return self.data.split(sep, maxsplit) - def rsplit(self, sep=None, maxsplit=-1): - return self.data.rsplit(sep, maxsplit) - def splitlines(self, keepends=0): return self.data.splitlines(keepends) - def startswith(self, prefix, start=0, end=sys.maxsize): - return self.data.startswith(prefix, start, end) - def strip(self, chars=None): return self.__class__(self.data.strip(chars)) - def swapcase(self): return self.__class__(self.data.swapcase()) - def title(self): return self.__class__(self.data.title()) - def translate(self, *args): - return self.__class__(self.data.translate(*args)) - def upper(self): return self.__class__(self.data.upper()) - def zfill(self, width): return self.__class__(self.data.zfill(width)) - -class MutableString(UserString, collections.MutableSequence): - """mutable string objects - - Python strings are immutable objects. This has the advantage, that - strings may be used as dictionary keys. If this property isn't needed - and you insist on changing string values in place instead, you may cheat - and use MutableString. - - But the purpose of this class is an educational one: to prevent - people from inventing their own mutable string class derived - from UserString and than forget thereby to remove (override) the - __hash__ method inherited from UserString. This would lead to - errors that would be very hard to track down. - - A faster and better solution is to rewrite your program using lists.""" - def __init__(self, string=""): - self.data = string - def __hash__(self): - raise TypeError("unhashable type (it is mutable)") - def __setitem__(self, index, sub): - if isinstance(index, slice): - if isinstance(sub, UserString): - sub = sub.data - elif not isinstance(sub, str): - sub = str(sub) - start, stop, step = index.indices(len(self.data)) - if step == -1: - start, stop = stop+1, start+1 - sub = sub[::-1] - elif step != 1: - # XXX(twouters): I guess we should be reimplementing - # the extended slice assignment/deletion algorithm here... - raise TypeError("invalid step in slicing assignment") - start = min(start, stop) - self.data = self.data[:start] + sub + self.data[stop:] - else: - if index < 0: - index += len(self.data) - if index < 0 or index >= len(self.data): raise IndexError - self.data = self.data[:index] + sub + self.data[index+1:] - def __delitem__(self, index): - if isinstance(index, slice): - start, stop, step = index.indices(len(self.data)) - if step == -1: - start, stop = stop+1, start+1 - elif step != 1: - # XXX(twouters): see same block in __setitem__ - raise TypeError("invalid step in slicing deletion") - start = min(start, stop) - self.data = self.data[:start] + self.data[stop:] - else: - if index < 0: - index += len(self.data) - if index < 0 or index >= len(self.data): raise IndexError - self.data = self.data[:index] + self.data[index+1:] - def immutable(self): - return UserString(self.data) - def __iadd__(self, other): - if isinstance(other, UserString): - self.data += other.data - elif isinstance(other, str): - self.data += other - else: - self.data += str(other) - return self - def __imul__(self, n): - self.data *= n - return self - def insert(self, index, value): - self[index:index] = value - -if __name__ == "__main__": - # execute the regression test to stdout, if called as a script: - import os - called_in_dir, called_as = os.path.split(sys.argv[0]) - called_as, py = os.path.splitext(called_as) - if '-q' in sys.argv: - from test import test_support - test_support.verbose = 0 - __import__('test.test_' + called_as.lower()) Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Thu Feb 21 23:11:37 2008 @@ -237,6 +237,150 @@ ################################################################################ +### UserString +################################################################################ + +class UserString(Sequence): + def __init__(self, seq): + if isinstance(seq, str): + self.data = seq + elif isinstance(seq, UserString): + self.data = seq.data[:] + else: + self.data = str(seq) + def __str__(self): return str(self.data) + def __repr__(self): return repr(self.data) + def __int__(self): return int(self.data) + def __long__(self): return int(self.data) + def __float__(self): return float(self.data) + def __complex__(self): return complex(self.data) + def __hash__(self): return hash(self.data) + + def __eq__(self, string): + if isinstance(string, UserString): + return self.data == string.data + return self.data == string + def __ne__(self, string): + if isinstance(string, UserString): + return self.data != string.data + return self.data != string + def __lt__(self, string): + if isinstance(string, UserString): + return self.data < string.data + return self.data < string + def __le__(self, string): + if isinstance(string, UserString): + return self.data <= string.data + return self.data <= string + def __gt__(self, string): + if isinstance(string, UserString): + return self.data > string.data + return self.data > string + def __ge__(self, string): + if isinstance(string, UserString): + return self.data >= string.data + return self.data >= string + + def __contains__(self, char): + if isinstance(char, UserString): + char = char.data + return char in self.data + + def __len__(self): return len(self.data) + def __getitem__(self, index): return self.__class__(self.data[index]) + def __add__(self, other): + if isinstance(other, UserString): + return self.__class__(self.data + other.data) + elif isinstance(other, str): + return self.__class__(self.data + other) + return self.__class__(self.data + str(other)) + def __radd__(self, other): + if isinstance(other, str): + return self.__class__(other + self.data) + return self.__class__(str(other) + self.data) + def __mul__(self, n): + return self.__class__(self.data*n) + __rmul__ = __mul__ + def __mod__(self, args): + return self.__class__(self.data % args) + + # the following methods are defined in alphabetical order: + def capitalize(self): return self.__class__(self.data.capitalize()) + def center(self, width, *args): + return self.__class__(self.data.center(width, *args)) + def count(self, sub, start=0, end=_sys.maxsize): + if isinstance(sub, UserString): + sub = sub.data + return self.data.count(sub, start, end) + def encode(self, encoding=None, errors=None): # XXX improve this? + if encoding: + if errors: + return self.__class__(self.data.encode(encoding, errors)) + return self.__class__(self.data.encode(encoding)) + return self.__class__(self.data.encode()) + def endswith(self, suffix, start=0, end=_sys.maxsize): + return self.data.endswith(suffix, start, end) + def expandtabs(self, tabsize=8): + return self.__class__(self.data.expandtabs(tabsize)) + def find(self, sub, start=0, end=_sys.maxsize): + if isinstance(sub, UserString): + sub = sub.data + return self.data.find(sub, start, end) + def format(self, *args, **kwds): + return self.data.format(*args, **kwds) + def index(self, sub, start=0, end=_sys.maxsize): + return self.data.index(sub, start, end) + def isalpha(self): return self.data.isalpha() + def isalnum(self): return self.data.isalnum() + def isdecimal(self): return self.data.isdecimal() + def isdigit(self): return self.data.isdigit() + def isidentifier(self): return self.data.isidentifier() + def islower(self): return self.data.islower() + def isnumeric(self): return self.data.isnumeric() + def isspace(self): return self.data.isspace() + def istitle(self): return self.data.istitle() + def isupper(self): return self.data.isupper() + def join(self, seq): return self.data.join(seq) + def ljust(self, width, *args): + return self.__class__(self.data.ljust(width, *args)) + def lower(self): return self.__class__(self.data.lower()) + def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) + def partition(self, sep): + return self.data.partition(sep) + def replace(self, old, new, maxsplit=-1): + if isinstance(old, UserString): + old = old.data + if isinstance(new, UserString): + new = new.data + return self.__class__(self.data.replace(old, new, maxsplit)) + def rfind(self, sub, start=0, end=_sys.maxsize): + return self.data.rfind(sub, start, end) + def rindex(self, sub, start=0, end=_sys.maxsize): + return self.data.rindex(sub, start, end) + def rjust(self, width, *args): + return self.__class__(self.data.rjust(width, *args)) + def rpartition(self, sep): + return self.data.rpartition(sep) + def rstrip(self, chars=None): + return self.__class__(self.data.rstrip(chars)) + def split(self, sep=None, maxsplit=-1): + return self.data.split(sep, maxsplit) + def rsplit(self, sep=None, maxsplit=-1): + return self.data.rsplit(sep, maxsplit) + def splitlines(self, keepends=0): return self.data.splitlines(keepends) + def startswith(self, prefix, start=0, end=_sys.maxsize): + return self.data.startswith(prefix, start, end) + def strip(self, chars=None): return self.__class__(self.data.strip(chars)) + def swapcase(self): return self.__class__(self.data.swapcase()) + def title(self): return self.__class__(self.data.title()) + def translate(self, *args): + return self.__class__(self.data.translate(*args)) + def upper(self): return self.__class__(self.data.upper()) + def zfill(self, width): return self.__class__(self.data.zfill(width)) + + + +################################################################################ ### Simple tests ################################################################################ Modified: python/branches/py3k/Lib/test/test___all__.py ============================================================================== --- python/branches/py3k/Lib/test/test___all__.py (original) +++ python/branches/py3k/Lib/test/test___all__.py Thu Feb 21 23:11:37 2008 @@ -36,7 +36,6 @@ self.check_all("Queue") self.check_all("SimpleHTTPServer") self.check_all("SocketServer") - self.check_all("UserString") self.check_all("aifc") self.check_all("base64") self.check_all("bdb") Modified: python/branches/py3k/Lib/test/test_userstring.py ============================================================================== --- python/branches/py3k/Lib/test/test_userstring.py (original) +++ python/branches/py3k/Lib/test/test_userstring.py Thu Feb 21 23:11:37 2008 @@ -6,7 +6,7 @@ import string from test import test_support, string_tests -from UserString import UserString, MutableString +from collections import UserString class UserStringTest( string_tests.CommonTest, @@ -42,99 +42,9 @@ # we don't fix the arguments, because UserString can't cope with it getattr(object, methodname)(*args) -class MutableStringTest(UserStringTest): - type2test = MutableString - - # MutableStrings can be hashed => deactivate test - def test_hash(self): - pass - - def test_setitem(self): - s = self.type2test("foo") - self.assertRaises(IndexError, s.__setitem__, -4, "bar") - self.assertRaises(IndexError, s.__setitem__, 3, "bar") - s[-1] = "bar" - self.assertEqual(s, "fobar") - s[0] = "bar" - self.assertEqual(s, "barobar") - - def test_delitem(self): - s = self.type2test("foo") - self.assertRaises(IndexError, s.__delitem__, -4) - self.assertRaises(IndexError, s.__delitem__, 3) - del s[-1] - self.assertEqual(s, "fo") - del s[0] - self.assertEqual(s, "o") - del s[0] - self.assertEqual(s, "") - - def test_setslice(self): - s = self.type2test("foo") - s[:] = "bar" - self.assertEqual(s, "bar") - s[1:2] = "foo" - self.assertEqual(s, "bfoor") - s[1:-1] = UserString("a") - self.assertEqual(s, "bar") - s[0:10] = 42 - self.assertEqual(s, "42") - - def test_delslice(self): - s = self.type2test("foobar") - del s[3:10] - self.assertEqual(s, "foo") - del s[-1:10] - self.assertEqual(s, "fo") - - def test_extended_set_del_slice(self): - indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100) - orig = string.ascii_letters + string.digits - for start in indices: - for stop in indices: - # Use indices[1:] when MutableString can handle real - # extended slices - for step in (None, 1, -1): - s = self.type2test(orig) - L = list(orig) - # Make sure we have a slice of exactly the right length, - # but with (hopefully) different data. - data = L[start:stop:step] - data.reverse() - L[start:stop:step] = data - s[start:stop:step] = "".join(data) - self.assertEquals(s, "".join(L)) - - del L[start:stop:step] - del s[start:stop:step] - self.assertEquals(s, "".join(L)) - - def test_immutable(self): - s = self.type2test("foobar") - s2 = s.immutable() - self.assertEqual(s, s2) - self.assert_(isinstance(s2, UserString)) - - def test_iadd(self): - s = self.type2test("foo") - s += "bar" - self.assertEqual(s, "foobar") - s += UserString("baz") - self.assertEqual(s, "foobarbaz") - s += 42 - self.assertEqual(s, "foobarbaz42") - - def test_imul(self): - s = self.type2test("foo") - s *= 1 - self.assertEqual(s, "foo") - s *= 2 - self.assertEqual(s, "foofoo") - s *= -1 - self.assertEqual(s, "") def test_main(): - test_support.run_unittest(UserStringTest, MutableStringTest) + test_support.run_unittest(UserStringTest) if __name__ == "__main__": test_main() Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Feb 21 23:11:37 2008 @@ -1650,7 +1650,8 @@ XXX their API still needs to be modernized (i.e. eliminate the iter methods). - Created new UserDict class in collections module. This one inherits from and - complies with the MutableMapping ABC. + complies with the MutableMapping ABC. Also, moved UserString and UserList + to the collections module. The MutableUserString class was removed. - Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. From python-3000-checkins at python.org Fri Feb 22 15:22:52 2008 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 22 Feb 2008 15:22:52 +0100 (CET) Subject: [Python-3000-checkins] r60959 - python/branches/py3k/README Message-ID: <20080222142252.4D2801E4018@bag.python.org> Author: georg.brandl Date: Fri Feb 22 15:22:51 2008 New Revision: 60959 Modified: python/branches/py3k/README Log: Link to whatsnew document. Modified: python/branches/py3k/README ============================================================================== --- python/branches/py3k/README (original) +++ python/branches/py3k/README Fri Feb 22 15:22:51 2008 @@ -51,8 +51,12 @@ http://www.artima.com/weblogs/index.jsp?blogger=guido -We'll eventually have a comprehensive overview of the changes in a -"What's New in Python 3.0" document. Please help write it! +We try to eventually have a comprehensive overview of the changes in +the "What's New in Python 3.0" document, found at + + http://docs.python.org/dev/3.0/whatsnew/3.0 + +Please help write it! What's New Since 3.0a1 From python-3000-checkins at python.org Fri Feb 22 17:31:16 2008 From: python-3000-checkins at python.org (eric.smith) Date: Fri, 22 Feb 2008 17:31:16 +0100 (CET) Subject: [Python-3000-checkins] r60963 - python/branches/py3k Message-ID: <20080222163116.0406D1E4018@bag.python.org> Author: eric.smith Date: Fri Feb 22 17:31:15 2008 New Revision: 60963 Modified: python/branches/py3k/ (props changed) Log: Block r60962 with svnmerge. From python-3000-checkins at python.org Fri Feb 22 17:37:43 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Fri, 22 Feb 2008 17:37:43 +0100 (CET) Subject: [Python-3000-checkins] r60964 - in python/branches/py3k: Doc/c-api/long.rst Doc/c-api/objbuffer.rst Doc/c-api/typeobj.rst Doc/distutils/builtdist.rst Doc/distutils/packageindex.rst Doc/distutils/setupscript.rst Doc/howto/advocacy.rst Doc/howto/doanddont.rst Doc/howto/functional.rst Doc/howto/sockets.rst Doc/library/codecs.rst Doc/library/collections.rst Doc/library/decimal.rst Doc/library/logging.rst Doc/library/mailbox.rst Doc/library/optparse.rst Doc/library/platform.rst Doc/library/profile.rst Doc/library/random.rst Doc/library/re.rst Doc/library/socket.rst Doc/library/tokenize.rst Doc/library/weakref.rst Doc/library/xml.etree.elementtree.rst Doc/reference/compound_stmts.rst Doc/reference/expressions.rst Doc/reference/index.rst Doc/tutorial/stdlib2.rst Doc/whatsnew/2.6.rst Lib/distutils/ccompiler.py Lib/distutils/command/sdist.py Lib/runpy.py Lib/test/test_itertools.py Lib/test/test_types.py Misc/HISTORY Modules/_ctypes/libffi/configure Modules/_ctypes/libffi/configure.ac Modules/_ctypes/libffi/fficonfig.h.in Modules/itertoolsmodule.c Objects/stringlib/formatter.h Python/pystrtod.c Message-ID: <20080222163743.C05E31E4018@bag.python.org> Author: christian.heimes Date: Fri Feb 22 17:37:40 2008 New Revision: 60964 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/long.rst python/branches/py3k/Doc/c-api/objbuffer.rst python/branches/py3k/Doc/c-api/typeobj.rst python/branches/py3k/Doc/distutils/builtdist.rst python/branches/py3k/Doc/distutils/packageindex.rst python/branches/py3k/Doc/distutils/setupscript.rst python/branches/py3k/Doc/howto/advocacy.rst python/branches/py3k/Doc/howto/doanddont.rst python/branches/py3k/Doc/howto/functional.rst python/branches/py3k/Doc/howto/sockets.rst python/branches/py3k/Doc/library/codecs.rst python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/logging.rst python/branches/py3k/Doc/library/mailbox.rst python/branches/py3k/Doc/library/optparse.rst python/branches/py3k/Doc/library/platform.rst python/branches/py3k/Doc/library/profile.rst python/branches/py3k/Doc/library/random.rst python/branches/py3k/Doc/library/re.rst python/branches/py3k/Doc/library/socket.rst python/branches/py3k/Doc/library/tokenize.rst python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Doc/library/xml.etree.elementtree.rst python/branches/py3k/Doc/reference/compound_stmts.rst python/branches/py3k/Doc/reference/expressions.rst python/branches/py3k/Doc/reference/index.rst python/branches/py3k/Doc/tutorial/stdlib2.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/distutils/ccompiler.py python/branches/py3k/Lib/distutils/command/sdist.py python/branches/py3k/Lib/runpy.py python/branches/py3k/Lib/test/test_itertools.py python/branches/py3k/Lib/test/test_types.py python/branches/py3k/Misc/HISTORY python/branches/py3k/Modules/_ctypes/libffi/configure python/branches/py3k/Modules/_ctypes/libffi/configure.ac python/branches/py3k/Modules/_ctypes/libffi/fficonfig.h.in python/branches/py3k/Modules/itertoolsmodule.c python/branches/py3k/Objects/stringlib/formatter.h python/branches/py3k/Python/pystrtod.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60901 | eric.smith | 2008-02-19 14:21:56 +0100 (Tue, 19 Feb 2008) | 1 line Added PEP 3101. ........ r60907 | georg.brandl | 2008-02-20 20:12:36 +0100 (Wed, 20 Feb 2008) | 2 lines Fixes contributed by Ori Avtalion. ........ r60909 | eric.smith | 2008-02-21 00:34:22 +0100 (Thu, 21 Feb 2008) | 1 line Trim leading zeros from a floating point exponent, per C99. See issue 1600. As far as I know, this only affects Windows. Add float type 'n' to PyOS_ascii_formatd (see PEP 3101 for 'n' description). ........ r60910 | eric.smith | 2008-02-21 00:39:28 +0100 (Thu, 21 Feb 2008) | 1 line Now that PyOS_ascii_formatd supports the 'n' format, simplify the float formatting code to just call it. ........ r60918 | andrew.kuchling | 2008-02-21 15:23:38 +0100 (Thu, 21 Feb 2008) | 2 lines Close manifest file. This change doesn't make any difference to CPython, but is a necessary fix for Jython. ........ r60921 | guido.van.rossum | 2008-02-21 18:46:16 +0100 (Thu, 21 Feb 2008) | 2 lines Remove news about float repr() -- issue 1580 is still in limbo. ........ r60923 | guido.van.rossum | 2008-02-21 19:18:37 +0100 (Thu, 21 Feb 2008) | 5 lines Removed uses of dict.has_key() from distutils, and uses of callable() from copy_reg.py, so the interpreter now starts up without warnings when '-3' is given. More work like this needs to be done in the rest of the stdlib. ........ r60924 | thomas.heller | 2008-02-21 19:28:48 +0100 (Thu, 21 Feb 2008) | 4 lines configure.ac: Remove the configure check for _Bool, it is already done in the top-level Python configure script. configure, fficonfig.h.in: regenerated. ........ r60925 | thomas.heller | 2008-02-21 19:52:20 +0100 (Thu, 21 Feb 2008) | 3 lines Replace 'has_key()' with 'in'. Replace 'raise Error, stuff' with 'raise Error(stuff)'. ........ r60927 | raymond.hettinger | 2008-02-21 20:24:53 +0100 (Thu, 21 Feb 2008) | 1 line Update more instances of has_key(). ........ r60928 | guido.van.rossum | 2008-02-21 20:46:35 +0100 (Thu, 21 Feb 2008) | 3 lines Fix a few typos and layout glitches (more work is needed). Move 2.5 news to Misc/HISTORY. ........ r60936 | georg.brandl | 2008-02-21 21:33:38 +0100 (Thu, 21 Feb 2008) | 2 lines #2079: typo in userdict docs. ........ r60938 | georg.brandl | 2008-02-21 21:38:13 +0100 (Thu, 21 Feb 2008) | 2 lines Part of #2154: minimal syntax fixes in doc example snippets. ........ r60942 | raymond.hettinger | 2008-02-22 04:16:42 +0100 (Fri, 22 Feb 2008) | 1 line First draft for itertools.product(). Docs and other updates forthcoming. ........ r60955 | nick.coghlan | 2008-02-22 11:54:06 +0100 (Fri, 22 Feb 2008) | 1 line Try to make command line error messages from runpy easier to understand (and suppress traceback cruft from the implicitly invoked runpy machinery) ........ r60956 | georg.brandl | 2008-02-22 13:31:45 +0100 (Fri, 22 Feb 2008) | 2 lines A lot more typo fixes by Ori Avtalion. ........ r60957 | georg.brandl | 2008-02-22 13:56:34 +0100 (Fri, 22 Feb 2008) | 2 lines Don't reference pyshell. ........ r60958 | georg.brandl | 2008-02-22 13:57:05 +0100 (Fri, 22 Feb 2008) | 2 lines Another fix. ........ Modified: python/branches/py3k/Doc/c-api/long.rst ============================================================================== --- python/branches/py3k/Doc/c-api/long.rst (original) +++ python/branches/py3k/Doc/c-api/long.rst Fri Feb 22 17:37:40 2008 @@ -190,7 +190,7 @@ .. cfunction:: void* PyLong_AsVoidPtr(PyObject *pylong) - Convert a Python integer *pylong* to a C :ctype:`void` pointer. If *pylong* - cannot be converted, an :exc:`OverflowError` will be raised. This is only - assured to produce a usable :ctype:`void` pointer for values created with - :cfunc:`PyLong_FromVoidPtr`. + Convert a Python integer *pylong* to a C :ctype:`void` pointer. + If *pylong* cannot be converted, an :exc:`OverflowError` will be raised. This + is only assured to produce a usable :ctype:`void` pointer for values created + with :cfunc:`PyLong_FromVoidPtr`. Modified: python/branches/py3k/Doc/c-api/objbuffer.rst ============================================================================== --- python/branches/py3k/Doc/c-api/objbuffer.rst (original) +++ python/branches/py3k/Doc/c-api/objbuffer.rst Fri Feb 22 17:37:40 2008 @@ -8,7 +8,7 @@ .. cfunction:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len) - Returns a pointer to a read-only memory location useable as character- based + Returns a pointer to a read-only memory location usable as character-based input. The *obj* argument must support the single-segment character buffer interface. On success, returns ``0``, sets *buffer* to the memory location and *buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:`TypeError` Modified: python/branches/py3k/Doc/c-api/typeobj.rst ============================================================================== --- python/branches/py3k/Doc/c-api/typeobj.rst (original) +++ python/branches/py3k/Doc/c-api/typeobj.rst Fri Feb 22 17:37:40 2008 @@ -560,7 +560,7 @@ The :attr:`tp_traverse` pointer is used by the garbage collector to detect reference cycles. A typical implementation of a :attr:`tp_traverse` function simply calls :cfunc:`Py_VISIT` on each of the instance's members that are Python - objects. For exampe, this is function :cfunc:`local_traverse` from the + objects. For example, this is function :cfunc:`local_traverse` from the :mod:`thread` extension module:: static int Modified: python/branches/py3k/Doc/distutils/builtdist.rst ============================================================================== --- python/branches/py3k/Doc/distutils/builtdist.rst (original) +++ python/branches/py3k/Doc/distutils/builtdist.rst Fri Feb 22 17:37:40 2008 @@ -195,7 +195,7 @@ | | or --- & :option:`maintainer` and | | | :option:`maintainer_email` | +------------------------------------------+----------------------------------------------+ -| Copyright | :option:`licence` | +| Copyright | :option:`license` | +------------------------------------------+----------------------------------------------+ | Url | :option:`url` | +------------------------------------------+----------------------------------------------+ Modified: python/branches/py3k/Doc/distutils/packageindex.rst ============================================================================== --- python/branches/py3k/Doc/distutils/packageindex.rst (original) +++ python/branches/py3k/Doc/distutils/packageindex.rst Fri Feb 22 17:37:40 2008 @@ -53,13 +53,13 @@ The .pypirc file ================ -The format of the :file:`.pypirc` file is formated as follows:: +The format of the :file:`.pypirc` file is as follows:: [server-login] repository: username: password: -*repository* can be ommitted and defaults to ``http://www.python.org/pypi``. +*repository* can be omitted and defaults to ``http://www.python.org/pypi``. Modified: python/branches/py3k/Doc/distutils/setupscript.rst ============================================================================== --- python/branches/py3k/Doc/distutils/setupscript.rst (original) +++ python/branches/py3k/Doc/distutils/setupscript.rst Fri Feb 22 17:37:40 2008 @@ -185,7 +185,7 @@ same base package), use the :option:`ext_package` keyword argument to :func:`setup`. For example, :: - setup(... + setup(..., ext_package='pkg', ext_modules=[Extension('foo', ['foo.c']), Extension('subpkg.bar', ['bar.c'])], @@ -214,7 +214,7 @@ This warning notwithstanding, options to SWIG can be currently passed like this:: - setup(... + setup(..., ext_modules=[Extension('_foo', ['foo.i'], swig_opts=['-modern', '-I../include'])], py_modules=['foo'], @@ -443,7 +443,7 @@ The :option:`scripts` option simply is a list of files to be handled in this way. From the PyXML setup script:: - setup(... + setup(..., scripts=['scripts/xmlproc_parse', 'scripts/xmlproc_val'] ) @@ -499,7 +499,7 @@ :option:`data_files` specifies a sequence of (*directory*, *files*) pairs in the following way:: - setup(... + setup(..., data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']), ('config', ['cfg/data.cfg']), ('/etc/init.d', ['init-script'])] @@ -611,7 +611,7 @@ :option:`classifiers` are specified in a python list:: - setup(... + setup(..., classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', Modified: python/branches/py3k/Doc/howto/advocacy.rst ============================================================================== --- python/branches/py3k/Doc/howto/advocacy.rst (original) +++ python/branches/py3k/Doc/howto/advocacy.rst Fri Feb 22 17:37:40 2008 @@ -276,7 +276,7 @@ product in any way. * If something goes wrong, you can't sue for damages. Practically all software - licences contain this condition. + licenses contain this condition. Notice that you don't have to provide source code for anything that contains Python or is built with it. Also, the Python interpreter and accompanying Modified: python/branches/py3k/Doc/howto/doanddont.rst ============================================================================== --- python/branches/py3k/Doc/howto/doanddont.rst (original) +++ python/branches/py3k/Doc/howto/doanddont.rst Fri Feb 22 17:37:40 2008 @@ -81,7 +81,7 @@ This is a "don't" which is much weaker then the previous "don't"s but is still something you should not do if you don't have good reasons to do that. The reason it is usually bad idea is because you suddenly have an object which lives -in two seperate namespaces. When the binding in one namespace changes, the +in two separate namespaces. When the binding in one namespace changes, the binding in the other will not, so there will be a discrepancy between them. This happens when, for example, one module is reloaded, or changes the definition of a function at runtime. Modified: python/branches/py3k/Doc/howto/functional.rst ============================================================================== --- python/branches/py3k/Doc/howto/functional.rst (original) +++ python/branches/py3k/Doc/howto/functional.rst Fri Feb 22 17:37:40 2008 @@ -892,7 +892,7 @@ itertools.izip(['a', 'b', 'c'], (1, 2, 3)) => ('a', 1), ('b', 2), ('c', 3) -It's similiar to the built-in :func:`zip` function, but doesn't construct an +It's similar to the built-in :func:`zip` function, but doesn't construct an in-memory list and exhaust all the input iterators before returning; instead tuples are constructed and returned only if they're requested. (The technical term for this behaviour is `lazy evaluation Modified: python/branches/py3k/Doc/howto/sockets.rst ============================================================================== --- python/branches/py3k/Doc/howto/sockets.rst (original) +++ python/branches/py3k/Doc/howto/sockets.rst Fri Feb 22 17:37:40 2008 @@ -354,7 +354,7 @@ reason to do otherwise. In return, you will get three lists. They have the sockets that are actually -readable, writable and in error. Each of these lists is a subset (possbily +readable, writable and in error. Each of these lists is a subset (possibly empty) of the corresponding list you passed in. And if you put a socket in more than one input list, it will only be (at most) in one output list. @@ -368,7 +368,7 @@ If you have a "server" socket, put it in the potential_readers list. If it comes out in the readable list, your ``accept`` will (almost certainly) work. If you have created a new socket to ``connect`` to someone else, put it in the -ptoential_writers list. If it shows up in the writable list, you have a decent +potential_writers list. If it shows up in the writable list, you have a decent chance that it has connected. One very nasty problem with ``select``: if somewhere in those input lists of Modified: python/branches/py3k/Doc/library/codecs.rst ============================================================================== --- python/branches/py3k/Doc/library/codecs.rst (original) +++ python/branches/py3k/Doc/library/codecs.rst Fri Feb 22 17:37:40 2008 @@ -1018,7 +1018,7 @@ +-----------------+--------------------------------+--------------------------------+ | iso8859_3 | iso-8859-3, latin3, L3 | Esperanto, Maltese | +-----------------+--------------------------------+--------------------------------+ -| iso8859_4 | iso-8859-4, latin4, L4 | Baltic languagues | +| iso8859_4 | iso-8859-4, latin4, L4 | Baltic languages | +-----------------+--------------------------------+--------------------------------+ | iso8859_5 | iso-8859-5, cyrillic | Bulgarian, Byelorussian, | | | | Macedonian, Russian, Serbian | Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Fri Feb 22 17:37:40 2008 @@ -452,7 +452,7 @@ .. function:: namedtuple(typename, fieldnames, [verbose]) Returns a new tuple subclass named *typename*. The new subclass is used to - create tuple-like objects that have fields accessable by attribute lookup as + create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have a helpful docstring (with typename and fieldnames) and a helpful :meth:`__repr__` method which lists the tuple contents in a ``name=value`` format. @@ -516,7 +516,7 @@ >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) - >>> p.x + p.y # fields also accessable by name + >>> p.x + p.y # fields also accessible by name 33 >>> p # readable __repr__ with a name=value style Point(x=11, y=22) @@ -708,7 +708,7 @@ in that case. :class:`UserString` objects -------------------------- +--------------------------- The class, :class:`UserString` acts as a wrapper around string objects. The need for this class has been partially supplanted by the ability to Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Fri Feb 22 17:37:40 2008 @@ -1557,7 +1557,7 @@ original's two-place significance. If an application does not care about tracking significance, it is easy to -remove the exponent and trailing zeroes, losing signficance, but keeping the +remove the exponent and trailing zeroes, losing significance, but keeping the value unchanged:: >>> def remove_exponent(d): Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Fri Feb 22 17:37:40 2008 @@ -41,7 +41,7 @@ It is, of course, possible to log messages with different verbosity levels or to different destinations. Support for writing log messages to files, HTTP GET/POST locations, email via SMTP, generic sockets, or OS-specific logging -mechnisms are all supported by the standard module. You can also create your +mechanisms are all supported by the standard module. You can also create your own log destination class if you have special requirements not met by any of the built-in classes. @@ -265,7 +265,7 @@ with an :func:`addHandler` method. As an example scenario, an application may want to send all log messages to a log file, all log messages of error or higher to stdout, and all messages of critical to an email address. This scenario -requires three individual handlers where each hander is responsible for sending +requires three individual handlers where each handler is responsible for sending messages of a specific severity to a specific location. The standard library includes quite a few handler types; this tutorial uses only Modified: python/branches/py3k/Doc/library/mailbox.rst ============================================================================== --- python/branches/py3k/Doc/library/mailbox.rst (original) +++ python/branches/py3k/Doc/library/mailbox.rst Fri Feb 22 17:37:40 2008 @@ -432,7 +432,7 @@ original format, which is sometimes referred to as :dfn:`mboxo`. This means that the :mailheader:`Content-Length` header, if present, is ignored and that any occurrences of "From " at the beginning of a line in a message body are -transformed to ">From " when storing the message, although occurences of ">From +transformed to ">From " when storing the message, although occurrences of ">From " are not transformed to "From " when reading the message. Some :class:`Mailbox` methods implemented by :class:`mbox` deserve special @@ -580,7 +580,7 @@ .. method:: MH.close() - :class:`MH` instances do not keep any open files, so this method is equivelant + :class:`MH` instances do not keep any open files, so this method is equivalent to :meth:`unlock`. Modified: python/branches/py3k/Doc/library/optparse.rst ============================================================================== --- python/branches/py3k/Doc/library/optparse.rst (original) +++ python/branches/py3k/Doc/library/optparse.rst Fri Feb 22 17:37:40 2008 @@ -1629,7 +1629,7 @@ value.append(arg) del rargs[0] - setattr(parser.values, option.dest, value) + setattr(parser.values, option.dest, value) [...] parser.add_option("-c", "--callback", Modified: python/branches/py3k/Doc/library/platform.rst ============================================================================== --- python/branches/py3k/Doc/library/platform.rst (original) +++ python/branches/py3k/Doc/library/platform.rst Fri Feb 22 17:37:40 2008 @@ -237,7 +237,7 @@ version)`` which default to the given parameters in case the lookup fails. Note that this function has intimate knowledge of how different libc versions - add symbols to the executable is probably only useable for executables compiled + add symbols to the executable is probably only usable for executables compiled using :program:`gcc`. The file is read and scanned in chunks of *chunksize* bytes. Modified: python/branches/py3k/Doc/library/profile.rst ============================================================================== --- python/branches/py3k/Doc/library/profile.rst (original) +++ python/branches/py3k/Doc/library/profile.rst Fri Feb 22 17:37:40 2008 @@ -513,7 +513,7 @@ non-parenthesized number repeats the cumulative time spent in the function at the right. - * With :mod:`cProfile`, each caller is preceeded by three numbers: the number of + * With :mod:`cProfile`, each caller is preceded by three numbers: the number of times this specific call was made, and the total and cumulative times spent in the current function while it was invoked by this specific caller. Modified: python/branches/py3k/Doc/library/random.rst ============================================================================== --- python/branches/py3k/Doc/library/random.rst (original) +++ python/branches/py3k/Doc/library/random.rst Fri Feb 22 17:37:40 2008 @@ -68,6 +68,17 @@ the time :func:`setstate` was called. +.. function:: jumpahead(n) + + Change the internal state to one different from and likely far away from the + current state. *n* is a non-negative integer which is used to scramble the + current state vector. This is most useful in multi-threaded programs, in + conjunction with multiple instances of the :class:`Random` class: + :meth:`setstate` or :meth:`seed` can be used to force all instances into the + same internal state, and then :meth:`jumpahead` can be used to force the + instances' states far apart. + + .. function:: getrandbits(k) Returns a python integer with *k* random bits. This method is supplied with Modified: python/branches/py3k/Doc/library/re.rst ============================================================================== --- python/branches/py3k/Doc/library/re.rst (original) +++ python/branches/py3k/Doc/library/re.rst Fri Feb 22 17:37:40 2008 @@ -1089,7 +1089,7 @@ 'Heather Albrecht 548.326.4584 919 Park Place'] Finally, split each entry into a list with first name, last name, telephone -number, and address. We use the ``maxsplit`` paramater of :func:`split` +number, and address. We use the ``maxsplit`` parameter of :func:`split` because the address has spaces, our splitting pattern, in it:: >>> [re.split(":? ", entry, 3) for entry in entries] @@ -1099,7 +1099,7 @@ ['Heather', 'Albrecht', '548.326.4584', '919 Park Place']] The ``:?`` pattern matches the colon after the last name, so that it does not -occur in the result list. With a ``maxsplit`` of ``4``, we could seperate the +occur in the result list. With a ``maxsplit`` of ``4``, we could separate the house number from the street name:: >>> [re.split(":? ", entry, 4) for entry in entries] @@ -1131,7 +1131,7 @@ Finding all Adverbs ^^^^^^^^^^^^^^^^^^^ -:func:`findall` matches *all* occurences of a pattern, not just the first +:func:`findall` matches *all* occurrences of a pattern, not just the first one as :func:`search` does. For example, if one was a writer and wanted to find all of the adverbs in some text, he or she might use :func:`findall` in the following manner:: Modified: python/branches/py3k/Doc/library/socket.rst ============================================================================== --- python/branches/py3k/Doc/library/socket.rst (original) +++ python/branches/py3k/Doc/library/socket.rst Fri Feb 22 17:37:40 2008 @@ -886,5 +886,5 @@ # receive a package print s.recvfrom(65565) - # disabled promiscous mode + # disabled promiscuous mode s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF) Modified: python/branches/py3k/Doc/library/tokenize.rst ============================================================================== --- python/branches/py3k/Doc/library/tokenize.rst (original) +++ python/branches/py3k/Doc/library/tokenize.rst Fri Feb 22 17:37:40 2008 @@ -18,7 +18,7 @@ .. function:: generate_tokens(readline) - The :func:`generate_tokens` generator requires one argment, *readline*, which + The :func:`generate_tokens` generator requires one argument, *readline*, which must be a callable object which provides the same interface as the :meth:`readline` method of built-in file objects (see section :ref:`bltin-file-objects`). Each call to the function should return one line of Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Fri Feb 22 17:37:40 2008 @@ -61,7 +61,7 @@ class Dict(dict): pass - obj = Dict(red=1, green=2, blue=3) # this object is weak referencable + obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: python/branches/py3k/Doc/library/xml.etree.elementtree.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.etree.elementtree.rst (original) +++ python/branches/py3k/Doc/library/xml.etree.elementtree.rst Fri Feb 22 17:37:40 2008 @@ -421,7 +421,7 @@ .. method:: TreeBuilder.close() - Flushes the parser buffers, and returns the toplevel documen element. Returns an + Flushes the parser buffers, and returns the toplevel document element. Returns an Element instance. Modified: python/branches/py3k/Doc/reference/compound_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/compound_stmts.rst (original) +++ python/branches/py3k/Doc/reference/compound_stmts.rst Fri Feb 22 17:37:40 2008 @@ -589,7 +589,7 @@ .. rubric:: Footnotes -.. [#] The exception is propogated to the invocation stack only if there is no +.. [#] The exception is propagated to the invocation stack only if there is no :keyword:`finally` clause that negates the exception. .. [#] Currently, control "flows off the end" except in the case of an exception or the Modified: python/branches/py3k/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k/Doc/reference/expressions.rst (original) +++ python/branches/py3k/Doc/reference/expressions.rst Fri Feb 22 17:37:40 2008 @@ -380,7 +380,7 @@ generator, or raises :exc:`StopIteration` if the generator exits without yielding another value. When :meth:`send` is called to start the generator, it must be called with :const:`None` as the argument, because there is no - :keyword:`yield` expression that could receieve the value. + :keyword:`yield` expression that could receive the value. .. method:: generator.throw(type[, value[, traceback]]) @@ -652,7 +652,7 @@ If the syntax ``*expression`` appears in the function call, ``expression`` must evaluate to a sequence. Elements from this sequence are treated as if they were -additional positional arguments; if there are postional arguments *x1*,...,*xN* +additional positional arguments; if there are positional arguments *x1*,...,*xN* , and ``expression`` evaluates to a sequence *y1*,...,*yM*, this is equivalent to a call with M+N positional arguments *x1*,...,*xN*,*y1*,...,*yM*. Modified: python/branches/py3k/Doc/reference/index.rst ============================================================================== --- python/branches/py3k/Doc/reference/index.rst (original) +++ python/branches/py3k/Doc/reference/index.rst Fri Feb 22 17:37:40 2008 @@ -17,7 +17,7 @@ interfaces available to C/C++ programmers in detail. .. toctree:: - :maxdepth: 3 + :maxdepth: 2 introduction.rst lexical_analysis.rst Modified: python/branches/py3k/Doc/tutorial/stdlib2.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/stdlib2.rst (original) +++ python/branches/py3k/Doc/tutorial/stdlib2.rst Fri Feb 22 17:37:40 2008 @@ -269,7 +269,7 @@ 0 >>> d['primary'] # entry was automatically removed Traceback (most recent call last): - File "", line 1, in -toplevel- + File "", line 1, in d['primary'] # entry was automatically removed File "C:/python30/lib/weakref.py", line 46, in __getitem__ o = self.data[key]() Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Fri Feb 22 17:37:40 2008 @@ -560,7 +560,7 @@ Numbers are further divided into :class:`Exact` and :class:`Inexact`. Exact numbers can represent values precisely and operations never round off the results or introduce tiny errors that may break the -communtativity and associativity properties; inexact numbers may +commutativity and associativity properties; inexact numbers may perform such rounding or introduce small errors. Integers, long integers, and rational numbers are exact, while floating-point and complex numbers are inexact. @@ -707,8 +707,10 @@ Other functions in the :mod:`math` module, :func:`isinf` and :func:`isnan`, return true if their floating-point argument is - infinite or Not A Number. + infinite or Not A Number. + .. Patch 1640 + The ``math.copysign(x, y)`` function copies the sign bit of an IEEE 754 number, returning the absolute value of *x* combined with the sign bit of *y*. For example, @@ -1078,7 +1080,7 @@ * Integrating signal handling with GUI handling event loops like those used by Tkinter or GTk+ has long been a problem; most - software ends up polling, waking up every fraction of a second. Thi + software ends up polling, waking up every fraction of a second. The :mod:`signal` module can now make this more efficient. Calling ``signal.set_wakeup_fd(fd)`` sets a file descriptor to be used; when a signal is received, a byte is written to that @@ -1293,7 +1295,8 @@ z.extractall() (Contributed by Alan McIntyre.) - .. % Patch 467924 + + .. Patch 467924 .. ====================================================================== .. whole new modules get described in subsections here @@ -1392,7 +1395,7 @@ .. Issue 1534 * Python's C API now includes two functions for case-insensitive string - comparisions, ``PyOS_stricmp(char*, char*)`` + comparisons, ``PyOS_stricmp(char*, char*)`` and ``PyOS_strnicmp(char*, char*, Py_ssize_t)``. (Contributed by Christian Heimes.) Modified: python/branches/py3k/Lib/distutils/ccompiler.py ============================================================================== --- python/branches/py3k/Lib/distutils/ccompiler.py (original) +++ python/branches/py3k/Lib/distutils/ccompiler.py Fri Feb 22 17:37:40 2008 @@ -147,11 +147,11 @@ # discovered at run-time, since there are many different ways to do # basically the same things with Unix C compilers. - for key, value in kwargs.items(): + for key in kwargs: if key not in self.executables: - raise ValueError("unknown executable '%s' for class %s" % \ + raise ValueError("unknown executable '%s' for class %s" % (key, self.__class__.__name__)) - self.set_executable(key, value) + self.set_executable(key, kwargs[key]) def set_executable(self, key, value): if isinstance(value, str): Modified: python/branches/py3k/Lib/distutils/command/sdist.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/sdist.py (original) +++ python/branches/py3k/Lib/distutils/command/sdist.py Fri Feb 22 17:37:40 2008 @@ -357,6 +357,7 @@ if line[-1] == '\n': line = line[0:-1] self.filelist.append(line) + manifest.close() def make_release_tree(self, base_dir, files): """Create the directory tree that will become the source Modified: python/branches/py3k/Lib/runpy.py ============================================================================== --- python/branches/py3k/Lib/runpy.py (original) +++ python/branches/py3k/Lib/runpy.py Fri Feb 22 17:37:40 2008 @@ -89,6 +89,9 @@ # XXX ncoghlan: Should this be documented and made public? +# (Current thoughts: don't repeat the mistake that lead to its +# creation when run_module() no longer met the needs of +# mainmodule.c, but couldn't be changed because it was public) def _run_module_as_main(mod_name, set_argv0=True): """Runs the designated module in the __main__ namespace @@ -96,7 +99,20 @@ __file__ __loader__ """ - loader, code, fname = _get_module_details(mod_name) + try: + loader, code, fname = _get_module_details(mod_name) + except ImportError as exc: + # Try to provide a good error message + # for directories, zip files and the -m switch + if set_argv0: + # For -m switch, just disply the exception + info = str(exc) + else: + # For directories/zipfiles, let the user + # know what the code was looking for + info = "can't find '__main__.py' in %r" % sys.argv[0] + msg = "%s: %s" % (sys.executable, info) + sys.exit(msg) pkg_name = mod_name.rpartition('.')[0] main_globals = sys.modules["__main__"].__dict__ if set_argv0: Modified: python/branches/py3k/Lib/test/test_itertools.py ============================================================================== --- python/branches/py3k/Lib/test/test_itertools.py (original) +++ python/branches/py3k/Lib/test/test_itertools.py Fri Feb 22 17:37:40 2008 @@ -5,6 +5,7 @@ import sys import operator import random +from functools import reduce maxsize = test_support.MAX_Py_ssize_t minsize = -maxsize-1 @@ -261,6 +262,28 @@ ids = list(map(id, list(izip_longest('abc', 'def')))) self.assertEqual(len(dict.fromkeys(ids)), len(ids)) + def test_product(self): + for args, result in [ + ([], []), # zero iterables ??? is this correct + (['ab'], [('a',), ('b',)]), # one iterable + ([range(2), range(3)], [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)]), # two iterables + ([range(0), range(2), range(3)], []), # first iterable with zero length + ([range(2), range(0), range(3)], []), # middle iterable with zero length + ([range(2), range(3), range(0)], []), # last iterable with zero length + ]: + self.assertEqual(list(product(*args)), result) + self.assertEqual(len(list(product(*[range(7)]*6))), 7**6) + self.assertRaises(TypeError, product, range(6), None) + argtypes = ['', 'abc', '', range(0), range(4), dict(a=1, b=2, c=3), + set('abcdefg'), range(11), tuple(range(13))] + for i in range(100): + args = [random.choice(argtypes) for j in range(random.randrange(5))] + n = reduce(operator.mul, map(len, args), 1) if args else 0 + self.assertEqual(len(list(product(*args))), n) + args = map(iter, args) + self.assertEqual(len(list(product(*args))), n) + + def test_repeat(self): self.assertEqual(lzip(range(3),repeat('a')), [(0, 'a'), (1, 'a'), (2, 'a')]) @@ -636,6 +659,12 @@ self.assertRaises(TypeError, chain, N(s)) self.assertRaises(ZeroDivisionError, list, chain(E(s))) + def test_product(self): + for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): + self.assertRaises(TypeError, product, X(s)) + self.assertRaises(TypeError, product, N(s)) + self.assertRaises(ZeroDivisionError, product, E(s)) + def test_cycle(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): Modified: python/branches/py3k/Lib/test/test_types.py ============================================================================== --- python/branches/py3k/Lib/test/test_types.py (original) +++ python/branches/py3k/Lib/test/test_types.py Fri Feb 22 17:37:40 2008 @@ -89,6 +89,29 @@ if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass else: self.fail('float() does not work properly') + def test_float_to_string(self): + def test(f, result): + self.assertEqual(f.__format__('e'), result) + self.assertEqual('%e' % f, result) + + # test all 2 digit exponents, both with __format__ and with + # '%' formatting + for i in range(-99, 100): + test(float('1.5e'+str(i)), '1.500000e{0:+03d}'.format(i)) + + # test some 3 digit exponents + self.assertEqual(1.5e100.__format__('e'), '1.500000e+100') + self.assertEqual('%e' % 1.5e100, '1.500000e+100') + + self.assertEqual(1.5e101.__format__('e'), '1.500000e+101') + self.assertEqual('%e' % 1.5e101, '1.500000e+101') + + self.assertEqual(1.5e-100.__format__('e'), '1.500000e-100') + self.assertEqual('%e' % 1.5e-100, '1.500000e-100') + + self.assertEqual(1.5e-101.__format__('e'), '1.500000e-101') + self.assertEqual('%e' % 1.5e-101, '1.500000e-101') + def test_normal_integers(self): # Ensure the first 256 integers are shared a = 256 @@ -416,16 +439,17 @@ test(-1.0, ' f', '-1.000000') test( 1.0, '+f', '+1.000000') test(-1.0, '+f', '-1.000000') + test(1.1234e90, 'f', '1.1234e+90') + test(1.1234e90, 'F', '1.1234e+90') test(1.1234e200, 'f', '1.1234e+200') test(1.1234e200, 'F', '1.1234e+200') - # temporarily removed. see issue 1600 - # test( 1.0, 'e', '1.000000e+00') - # test(-1.0, 'e', '-1.000000e+00') - # test( 1.0, 'E', '1.000000E+00') - # test(-1.0, 'E', '-1.000000E+00') - # test(1.1234e20, 'e', '1.123400e+20') - # test(1.1234e20, 'E', '1.123400E+20') + test( 1.0, 'e', '1.000000e+00') + test(-1.0, 'e', '-1.000000e+00') + test( 1.0, 'E', '1.000000E+00') + test(-1.0, 'E', '-1.000000E+00') + test(1.1234e20, 'e', '1.123400e+20') + test(1.1234e20, 'E', '1.123400E+20') # % formatting test(-1.0, '%', '-100.000000%') Modified: python/branches/py3k/Misc/HISTORY ============================================================================== --- python/branches/py3k/Misc/HISTORY (original) +++ python/branches/py3k/Misc/HISTORY Fri Feb 22 17:37:40 2008 @@ -3,11 +3,2150 @@ This file contains the release messages for previous Python releases. As you read on you go back to the dark ages of Python's history. +(Note: news about 2.5c2 and later 2.5 releases is in the Misc/NEWS +file of the release25-maint branch.) ====================================================================== +What's New in Python 2.5 release candidate 1? +============================================= + +*Release date: 17-AUG-2006* + +Core and builtins +----------------- + +- Unicode objects will no longer raise an exception when being + compared equal or unequal to a string and a UnicodeDecodeError + exception occurs, e.g. as result of a decoding failure. + + Instead, the equal (==) and unequal (!=) comparison operators will + now issue a UnicodeWarning and interpret the two objects as + unequal. The UnicodeWarning can be filtered as desired using + the warning framework, e.g. silenced completely, turned into an + exception, logged, etc. + + Note that compare operators other than equal and unequal will still + raise UnicodeDecodeError exceptions as they've always done. + +- Fix segfault when doing string formatting on subclasses of long. + +- Fix bug related to __len__ functions using values > 2**32 on 64-bit machines + with new-style classes. + +- Fix bug related to __len__ functions returning negative values with + classic classes. + +- Patch #1538606, Fix __index__() clipping. There were some problems + discovered with the API and how integers that didn't fit into Py_ssize_t + were handled. This patch attempts to provide enough alternatives + to effectively use __index__. + +- Bug #1536021: __hash__ may now return long int; the final hash + value is obtained by invoking hash on the long int. + +- Bug #1536786: buffer comparison could emit a RuntimeWarning. + +- Bug #1535165: fixed a segfault in input() and raw_input() when + sys.stdin is closed. + +- On Windows, the PyErr_Warn function is now exported from + the Python dll again. + +- Bug #1191458: tracing over for loops now produces a line event + on each iteration. Fixing this problem required changing the .pyc + magic number. This means that .pyc files generated before 2.5c1 + will be regenerated. + +- Bug #1333982: string/number constants were inappropriately stored + in the byte code and co_consts even if they were not used, ie + immediately popped off the stack. + +- Fixed a reference-counting problem in property(). + + +Library +------- + +- Fix a bug in the ``compiler`` package that caused invalid code to be + generated for generator expressions. + +- The distutils version has been changed to 2.5.0. The change to + keep it programmatically in sync with the Python version running + the code (introduced in 2.5b3) has been reverted. It will continue + to be maintained manually as static string literal. + +- If the Python part of a ctypes callback function returns None, + and this cannot be converted to the required C type, an exception is + printed with PyErr_WriteUnraisable. Before this change, the C + callback returned arbitrary values to the calling code. + +- The __repr__ method of a NULL ctypes.py_object() no longer raises + an exception. + +- uuid.UUID now has a bytes_le attribute. This returns the UUID in + little-endian byte order for Windows. In addition, uuid.py gained some + workarounds for clocks with low resolution, to stop the code yielding + duplicate UUIDs. + +- Patch #1540892: site.py Quitter() class attempts to close sys.stdin + before raising SystemExit, allowing IDLE to honor quit() and exit(). + +- Bug #1224621: make tabnanny recognize IndentationErrors raised by tokenize. + +- Patch #1536071: trace.py should now find the full module name of a + file correctly even on Windows. + +- logging's atexit hook now runs even if the rest of the module has + already been cleaned up. + +- Bug #1112549, fix DoS attack on cgi.FieldStorage. + +- Bug #1531405, format_exception no longer raises an exception if + str(exception) raised an exception. + +- Fix a bug in the ``compiler`` package that caused invalid code to be + generated for nested functions. + + +Extension Modules +----------------- + +- Patch #1511317: don't crash on invalid hostname (alias) info. + +- Patch #1535500: fix segfault in BZ2File.writelines and make sure it + raises the correct exceptions. + +- Patch # 1536908: enable building ctypes on OpenBSD/AMD64. The + '-no-stack-protector' compiler flag for OpenBSD has been removed. + +- Patch #1532975 was applied, which fixes Bug #1533481: ctypes now + uses the _as_parameter_ attribute when objects are passed to foreign + function calls. The ctypes version number was changed to 1.0.1. + +- Bug #1530559, struct.pack raises TypeError where it used to convert. + Passing float arguments to struct.pack when integers are expected + now triggers a DeprecationWarning. + + +Tests +----- + +- test_socketserver should now work on cygwin and not fail sporadically + on other platforms. + +- test_mailbox should now work on cygwin versions 2006-08-10 and later. + +- Bug #1535182: really test the xreadlines() method of bz2 objects. + +- test_threading now skips testing alternate thread stack sizes on + platforms that don't support changing thread stack size. + + +Documentation +------------- + +- Patch #1534922: unittest docs were corrected and enhanced. + + +Build +----- + +- Bug #1535502, build _hashlib on Windows, and use masm assembler + code in OpenSSL. + +- Bug #1534738, win32 debug version of _msi should be _msi_d.pyd. + +- Bug #1530448, ctypes build failure on Solaris 10 was fixed. + + +C API +----- + +- New API for Unicode rich comparisons: PyUnicode_RichCompare() + +- Bug #1069160. Internal correctness changes were made to + ``PyThreadState_SetAsyncExc()``. A test case was added, and + the documentation was changed to state that the return value + is always 1 (normal) or 0 (if the specified thread wasn't found). + + +What's New in Python 2.5 beta 3? +================================ + +*Release date: 03-AUG-2006* + +Core and builtins +----------------- + +- _PyWeakref_GetWeakrefCount() now returns a Py_ssize_t; it previously + returned a long (see PEP 353). + +- Bug #1515471: string.replace() accepts character buffers again. + +- Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn(). + This provides the proper warning for struct.pack(). + PyErr_Warn() is now deprecated in favor of PyErr_WarnEx(). + +- Patch #1531113: Fix augmented assignment with yield expressions. + Also fix a SystemError when trying to assign to yield expressions. + +- Bug #1529871: The speed enhancement patch #921466 broke Python's compliance + with PEP 302. This was fixed by adding an ``imp.NullImporter`` type that is + used in ``sys.path_importer_cache`` to cache non-directory paths and avoid + excessive filesystem operations during imports. + +- Bug #1521947: When checking for overflow, ``PyOS_strtol()`` used some + operations on signed longs that are formally undefined by C. + Unfortunately, at least one compiler now cares about that, so complicated + the code to make that compiler happy again. + +- Bug #1524310: Properly report errors from FindNextFile in os.listdir. + +- Patch #1232023: Stop including current directory in search + path on Windows. + +- Fix some potential crashes found with failmalloc. + +- Fix warnings reported by Klocwork's static analysis tool. + +- Bug #1512814, Fix incorrect lineno's when code within a function + had more than 255 blank lines. + +- Patch #1521179: Python now accepts the standard options ``--help`` and + ``--version`` as well as ``/?`` on Windows. + +- Bug #1520864: unpacking singleton tuples in a 'for' loop (for x, in) works + again. Fixing this problem required changing the .pyc magic number. + This means that .pyc files generated before 2.5b3 will be regenerated. + +- Bug #1524317: Compiling Python ``--without-threads`` failed. + The Python core compiles again, and, in a build without threads, the + new ``sys._current_frames()`` returns a dictionary with one entry, + mapping the faux "thread id" 0 to the current frame. + +- Bug #1525447: build on MacOS X on a case-sensitive filesystem. + + +Library +------- + +- Fix #1693149. Now you can pass several modules separated by + comma to trace.py in the same --ignore-module option. + +- Correction of patch #1455898: In the mbcs decoder, set final=False + for stream decoder, but final=True for the decode function. + +- os.urandom no longer masks unrelated exceptions like SystemExit or + KeyboardInterrupt. + +- Bug #1525866: Don't copy directory stat times in + shutil.copytree on Windows + +- Bug #1002398: The documentation for os.path.sameopenfile now correctly + refers to file descriptors, not file objects. + +- The renaming of the xml package to xmlcore, and the import hackery done + to make it appear at both names, has been removed. Bug #1511497, + #1513611, and probably others. + +- Bug #1441397: The compiler module now recognizes module and function + docstrings correctly as it did in Python 2.4. + +- Bug #1529297: The rewrite of doctest for Python 2.4 unintentionally + lost that tests are sorted by name before being run. This rarely + matters for well-written tests, but can create baffling symptoms if + side effects from one test to the next affect outcomes. ``DocTestFinder`` + has been changed to sort the list of tests it returns. + +- The distutils version has been changed to 2.5.0, and is now kept + in sync with sys.version_info[:3]. + +- Bug #978833: Really close underlying socket in _socketobject.close. + +- Bug #1459963: urllib and urllib2 now normalize HTTP header names with + title(). + +- Patch #1525766: In pkgutil.walk_packages, correctly pass the onerror callback + to recursive calls and call it with the failing package name. + +- Bug #1525817: Don't truncate short lines in IDLE's tool tips. + +- Patch #1515343: Fix printing of deprecated string exceptions with a + value in the traceback module. + +- Resync optparse with Optik 1.5.3: minor tweaks for/to tests. + +- Patch #1524429: Use repr() instead of backticks in Tkinter again. + +- Bug #1520914: Change time.strftime() to accept a zero for any position in its + argument tuple. For arguments where zero is illegal, the value is forced to + the minimum value that is correct. This is to support an undocumented but + common way people used to fill in inconsequential information in the time + tuple pre-2.4. + +- Patch #1220874: Update the binhex module for Mach-O. + +- The email package has improved RFC 2231 support, specifically for + recognizing the difference between encoded (name*0*=) and non-encoded + (name*0=) parameter continuations. This may change the types of + values returned from email.message.Message.get_param() and friends. + Specifically in some cases where non-encoded continuations were used, + get_param() used to return a 3-tuple of (None, None, string) whereas now it + will just return the string (since non-encoded continuations don't have + charset and language parts). + + Also, whereas % values were decoded in all parameter continuations, they are + now only decoded in encoded parameter parts. + +- Bug #1517990: IDLE keybindings on MacOS X now work correctly + +- Bug #1517996: IDLE now longer shows the default Tk menu when a + path browser, class browser or debugger is the frontmost window on MacOS X + +- Patch #1520294: Support for getset and member descriptors in types.py, + inspect.py, and pydoc.py. Specifically, this allows for querying the type + of an object against these built-in types and more importantly, for getting + their docstrings printed in the interactive interpreter's help() function. + + +Extension Modules +----------------- + +- Patch #1519025 and bug #926423: If a KeyboardInterrupt occurs during + a socket operation on a socket with a timeout, the exception will be + caught correctly. Previously, the exception was not caught. + +- Patch #1529514: The _ctypes extension is now compiled on more + openbsd target platforms. + +- The ``__reduce__()`` method of the new ``collections.defaultdict`` had + a memory leak, affecting pickles and deep copies. + +- Bug #1471938: Fix curses module build problem on Solaris 8; patch by + Paul Eggert. + +- Patch #1448199: Release interpreter lock in _winreg.ConnectRegistry. + +- Patch #1521817: Index range checking on ctypes arrays containing + exactly one element enabled again. This allows iterating over these + arrays, without the need to check the array size before. + +- Bug #1521375: When the code in ctypes.util.find_library was + run with root privileges, it could overwrite or delete + /dev/null in certain cases; this is now fixed. + +- Bug #1467450: On Mac OS X 10.3, RTLD_GLOBAL is now used as the + default mode for loading shared libraries in ctypes. + +- Because of a misspelled preprocessor symbol, ctypes was always + compiled without thread support; this is now fixed. + +- pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename + methods now allow their database parameter to be None as the + sleepycat API allows. + +- Bug #1526460: Fix socketmodule compile on NetBSD as it has a different + bluetooth API compared with Linux and FreeBSD. + +Tests +----- + +- Bug #1501330: Change test_ossaudiodev to be much more tolerant in terms of + how long the test file should take to play. Now accepts taking 2.93 secs + (exact time) +/- 10% instead of the hard-coded 3.1 sec. + +- Patch #1529686: The standard tests ``test_defaultdict``, ``test_iterlen``, + ``test_uuid`` and ``test_email_codecs`` didn't actually run any tests when + run via ``regrtest.py``. Now they do. + +Build +----- + +- Bug #1439538: Drop usage of test -e in configure as it is not portable. + +Mac +--- + +- PythonLauncher now works correctly when the path to the script contains + characters that are treated specially by the shell (such as quotes). + +- Bug #1527397: PythonLauncher now launches scripts with the working directory + set to the directory that contains the script instead of the user home + directory. That latter was an implementation accident and not what users + expect. + + +What's New in Python 2.5 beta 2? +================================ + +*Release date: 11-JUL-2006* + +Core and builtins +----------------- + +- Bug #1441486: The literal representation of -(sys.maxint - 1) + again evaluates to a int object, not a long. + +- Bug #1501934: The scope of global variables that are locally assigned + using augmented assignment is now correctly determined. + +- Bug #927248: Recursive method-wrapper objects can now safely + be released. + +- Bug #1417699: Reject locale-specific decimal point in float() + and atof(). + +- Bug #1511381: codec_getstreamcodec() in codec.c is corrected to + omit a default "error" argument for NULL pointer. This allows + the parser to take a codec from cjkcodecs again. + +- Bug #1519018: 'as' is now validated properly in import statements. + +- On 64 bit systems, int literals that use less than 64 bits are + now ints rather than longs. + +- Bug #1512814, Fix incorrect lineno's when code at module scope + started after line 256. + +- New function ``sys._current_frames()`` returns a dict mapping thread + id to topmost thread stack frame. This is for expert use, and is + especially useful for debugging application deadlocks. The functionality + was previously available in Fazal Majid's ``threadframe`` extension + module, but it wasn't possible to do this in a wholly threadsafe way from + an extension. + +Library +------- + +- Bug #1257728: Mention Cygwin in distutils error message about a missing + VS 2003. + +- Patch #1519566: Update turtle demo, make begin_fill idempotent. + +- Bug #1508010: msvccompiler now requires the DISTUTILS_USE_SDK + environment variable to be set in order to the SDK environment + for finding the compiler, include files, etc. + +- Bug #1515998: Properly generate logical ids for files in bdist_msi. + +- warnings.py now ignores ImportWarning by default + +- string.Template() now correctly handles tuple-values. Previously, + multi-value tuples would raise an exception and single-value tuples would + be treated as the value they contain, instead. + +- Bug #822974: Honor timeout in telnetlib.{expect,read_until} + even if some data are received. + +- Bug #1267547: Put proper recursive setup.py call into the + spec file generated by bdist_rpm. + +- Bug #1514693: Update turtle's heading when switching between + degrees and radians. + +- Reimplement turtle.circle using a polyline, to allow correct + filling of arcs. + +- Bug #1514703: Only setup canvas window in turtle when the canvas + is created. + +- Bug #1513223: .close() of a _socketobj now releases the underlying + socket again, which then gets closed as it becomes unreferenced. + +- Bug #1504333: Make sgmllib support angle brackets in quoted + attribute values. + +- Bug #853506: Fix IPv6 address parsing in unquoted attributes in + sgmllib ('[' and ']' were not accepted). + +- Fix a bug in the turtle module's end_fill function. + +- Bug #1510580: The 'warnings' module improperly required that a Warning + category be either a types.ClassType and a subclass of Warning. The proper + check is just that it is a subclass with Warning as the documentation states. + +- The compiler module now correctly compiles the new try-except-finally + statement (bug #1509132). + +- The wsgiref package is now installed properly on Unix. + +- A bug was fixed in logging.config.fileConfig() which caused a crash on + shutdown when fileConfig() was called multiple times. + +- The sqlite3 module did cut off data from the SQLite database at the first + null character before sending it to a custom converter. This has been fixed + now. + +Extension Modules +----------------- + +- #1494314: Fix a regression with high-numbered sockets in 2.4.3. This + means that select() on sockets > FD_SETSIZE (typically 1024) work again. + The patch makes sockets use poll() internally where available. + +- Assigning None to pointer type fields in ctypes structures possible + overwrote the wrong fields, this is fixed now. + +- Fixed a segfault in _ctypes when ctypes.wintypes were imported + on non-Windows platforms. + +- Bug #1518190: The ctypes.c_void_p constructor now accepts any + integer or long, without range checking. + +- Patch #1517790: It is now possible to use custom objects in the ctypes + foreign function argtypes sequence as long as they provide a from_param + method, no longer is it required that the object is a ctypes type. + +- The '_ctypes' extension module now works when Python is configured + with the --without-threads option. + +- Bug #1513646: os.access on Windows now correctly determines write + access, again. + +- Bug #1512695: cPickle.loads could crash if it was interrupted with + a KeyboardInterrupt. + +- Bug #1296433: parsing XML with a non-default encoding and + a CharacterDataHandler could crash the interpreter in pyexpat. + +- Patch #1516912: improve Modules support for OpenVMS. + +Build +----- + +- Automate Windows build process for the Win64 SSL module. + +- 'configure' now detects the zlib library the same way as distutils. + Previously, the slight difference could cause compilation errors of the + 'zlib' module on systems with more than one version of zlib. + +- The MSI compileall step was fixed to also support a TARGETDIR + with spaces in it. + +- Bug #1517388: sqlite3.dll is now installed on Windows independent + of Tcl/Tk. + +- Bug #1513032: 'make install' failed on FreeBSD 5.3 due to lib-old + trying to be installed even though it's empty. + +Tests +----- + +- Call os.waitpid() at the end of tests that spawn child processes in order + to minimize resources (zombies). + +Documentation +------------- + +- Cover ImportWarning, PendingDeprecationWarning and simplefilter() in the + documentation for the warnings module. + +- Patch #1509163: MS Toolkit Compiler no longer available. + +- Patch #1504046: Add documentation for xml.etree. + + +What's New in Python 2.5 beta 1? +================================ + +*Release date: 20-JUN-2006* + +Core and builtins +----------------- + +- Patch #1507676: Error messages returned by invalid abstract object operations + (such as iterating over an integer) have been improved and now include the + type of the offending object to help with debugging. + +- Bug #992017: A classic class that defined a __coerce__() method that returned + its arguments swapped would infinitely recurse and segfault the interpreter. + +- Fix the socket tests so they can be run concurrently. + +- Removed 5 integers from C frame objects (PyFrameObject). + f_nlocals, f_ncells, f_nfreevars, f_stack_size, f_restricted. + +- Bug #532646: object.__call__() will continue looking for the __call__ + attribute on objects until one without one is found. This leads to recursion + when you take a class and set its __call__ attribute to an instance of the + class. Originally fixed for classic classes, but this fix is for new-style. + Removes the infinite_rec_3 crasher. + +- The string and unicode methods startswith() and endswith() now accept + a tuple of prefixes/suffixes to look for. Implements RFE #1491485. + +- Buffer objects, at the C level, never used the char buffer + implementation even when the char buffer for the wrapped object was + explicitly requested (originally returned the read or write buffer). + Now a TypeError is raised if the char buffer is not present but is + requested. + +- Patch #1346214: Statements like "if 0: suite" are now again optimized + away like they were in Python 2.4. + +- Builtin exceptions are now full-blown new-style classes instead of + instances pretending to be classes, which speeds up exception handling + by about 80% in comparison to 2.5a2. + +- Patch #1494554: Update unicodedata.numeric and unicode.isnumeric to + Unicode 4.1. + +- Patch #921466: sys.path_importer_cache is now used to cache valid and + invalid file paths for the built-in import machinery which leads to + fewer open calls on startup. + +- Patch #1442927: ``long(str, base)`` is now up to 6x faster for non-power- + of-2 bases. The largest speedup is for inputs with about 1000 decimal + digits. Conversion from non-power-of-2 bases remains quadratic-time in + the number of input digits (it was and remains linear-time for bases + 2, 4, 8, 16 and 32). + +- Bug #1334662: ``int(string, base)`` could deliver a wrong answer + when ``base`` was not 2, 4, 8, 10, 16 or 32, and ``string`` represented + an integer close to ``sys.maxint``. This was repaired by patch + #1335972, which also gives a nice speedup. + +- Patch #1337051: reduced size of frame objects. + +- PyErr_NewException now accepts a tuple of base classes as its + "base" parameter. + +- Patch #876206: function call speedup by retaining allocated frame + objects. + +- Bug #1462152: file() now checks more thoroughly for invalid mode + strings and removes a possible "U" before passing the mode to the + C library function. + +- Patch #1488312, Fix memory alignment problem on SPARC in unicode + +- Bug #1487966: Fix SystemError with conditional expression in assignment + +- WindowsError now has two error code attributes: errno, which carries + the error values from errno.h, and winerror, which carries the error + values from winerror.h. Previous versions put the winerror.h values + (from GetLastError()) into the errno attribute. + +- Patch #1475845: Raise IndentationError for unexpected indent. + +- Patch #1479181: split open() and file() from being aliases for each other. + +- Patch #1497053 & bug #1275608: Exceptions occurring in ``__eq__()`` + methods were always silently ignored by dictionaries when comparing keys. + They are now passed through (except when using the C API function + ``PyDict_GetItem()``, whose semantics did not change). + +- Bug #1456209: In some obscure cases it was possible for a class with a + custom ``__eq__()`` method to confuse dict internals when class instances + were used as a dict's keys and the ``__eq__()`` method mutated the dict. + No, you don't have any code that did this ;-) + +Extension Modules +----------------- + +- Bug #1295808: expat symbols should be namespaced in pyexpat + +- Patch #1462338: Upgrade pyexpat to expat 2.0.0 + +- Change binascii.hexlify to accept a read-only buffer instead of only a char + buffer and actually follow its documentation. + +- Fixed a potentially invalid memory access of CJKCodecs' shift-jis decoder. + +- Patch #1478788 (modified version): The functional extension module has + been renamed to _functools and a functools Python wrapper module added. + This provides a home for additional function related utilities that are + not specifically about functional programming. See PEP 309. + +- Patch #1493701: performance enhancements for struct module. + +- Patch #1490224: time.altzone is now set correctly on Cygwin. + +- Patch #1435422: zlib's compress and decompress objects now have a + copy() method. + +- Patch #1454481: thread stack size is now tunable at runtime for thread + enabled builds on Windows and systems with Posix threads support. + +- On Win32, os.listdir now supports arbitrarily-long Unicode path names + (up to the system limit of 32K characters). + +- Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. + As a result, these functions now raise WindowsError instead of OSError. + +- ``time.clock()`` on Win64 should use the high-performance Windows + ``QueryPerformanceCounter()`` now (as was already the case on 32-bit + Windows platforms). + +- Calling Tk_Init twice is refused if the first call failed as that + may deadlock. + +- bsddb: added the DB_ARCH_REMOVE flag and fixed db.DBEnv.log_archive() to + accept it without potentially using an uninitialized pointer. + +- bsddb: added support for the DBEnv.log_stat() and DBEnv.lsn_reset() methods + assuming BerkeleyDB >= 4.0 and 4.4 respectively. [pybsddb project SF + patch numbers 1494885 and 1494902] + +- bsddb: added an interface for the BerkeleyDB >= 4.3 DBSequence class. + [pybsddb project SF patch number 1466734] + +- bsddb: fix DBCursor.pget() bug with keyword argument names when no data + parameter is supplied. [SF pybsddb bug #1477863] + +- bsddb: the __len__ method of a DB object has been fixed to return correct + results. It could previously incorrectly return 0 in some cases. + Fixes SF bug 1493322 (pybsddb bug 1184012). + +- bsddb: the bsddb.dbtables Modify method now raises the proper error and + aborts the db transaction safely when a modifier callback fails. + Fixes SF python patch/bug #1408584. + +- bsddb: multithreaded DB access using the simple bsddb module interface + now works reliably. It has been updated to use automatic BerkeleyDB + deadlock detection and the bsddb.dbutils.DeadlockWrap wrapper to retry + database calls that would previously deadlock. [SF python bug #775414] + +- Patch #1446489: add support for the ZIP64 extensions to zipfile. + +- Patch #1506645: add Python wrappers for the curses functions + is_term_resized, resize_term and resizeterm. + +Library +------- + +- Patch #815924: Restore ability to pass type= and icon= in tkMessageBox + functions. + +- Patch #812986: Update turtle output even if not tracing. + +- Patch #1494750: Destroy master after deleting children in + Tkinter.BaseWidget. + +- Patch #1096231: Add ``default`` argument to Tkinter.Wm.wm_iconbitmap. + +- Patch #763580: Add name and value arguments to Tkinter variable + classes. + +- Bug #1117556: SimpleHTTPServer now tries to find and use the system's + mime.types file for determining MIME types. + +- Bug #1339007: Shelf objects now don't raise an exception in their + __del__ method when initialization failed. + +- Patch #1455898: The MBCS codec now supports the incremental mode for + double-byte encodings. + +- ``difflib``'s ``SequenceMatcher.get_matching_blocks()`` was changed to + guarantee that adjacent triples in the return list always describe + non-adjacent blocks. Previously, a pair of matching blocks could end + up being described by multiple adjacent triples that formed a partition + of the matching pair. + +- Bug #1498146: fix optparse to handle Unicode strings in option help, + description, and epilog. + +- Bug #1366250: minor optparse documentation error. + +- Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately; + clarify docs. + +- The wsgiref package has been added to the standard library. + +- The functions update_wrapper() and wraps() have been added to the functools + module. These make it easier to copy relevant metadata from the original + function when writing wrapper functions. + +- The optional ``isprivate`` argument to ``doctest.testmod()``, and the + ``doctest.is_private()`` function, both deprecated in 2.4, were removed. + +- Patch #1359618: Speed up charmap encoder by using a trie structure + for lookup. + +- The functions in the ``pprint`` module now sort dictionaries by key + before computing the display. Before 2.5, ``pprint`` sorted a dictionary + if and only if its display required more than one line, although that + wasn't documented. The new behavior increases predictability; e.g., + using ``pprint.pprint(a_dict)`` in a doctest is now reliable. + +- Patch #1497027: try HTTP digest auth before basic auth in urllib2 + (thanks for J. J. Lee). + +- Patch #1496206: improve urllib2 handling of passwords with respect to + default HTTP and HTTPS ports. + +- Patch #1080727: add "encoding" parameter to doctest.DocFileSuite. + +- Patch #1281707: speed up gzip.readline. + +- Patch #1180296: Two new functions were added to the locale module: + format_string() to get the effect of "format % items" but locale-aware, + and currency() to format a monetary number with currency sign. + +- Patch #1486962: Several bugs in the turtle Tk demo module were fixed + and several features added, such as speed and geometry control. + +- Patch #1488881: add support for external file objects in bz2 compressed + tarfiles. + +- Patch #721464: pdb.Pdb instances can now be given explicit stdin and + stdout arguments, making it possible to redirect input and output + for remote debugging. + +- Patch #1484695: Update the tarfile module to version 0.8. This fixes + a couple of issues, notably handling of long file names using the + GNU LONGNAME extension. + +- Patch #1478292. ``doctest.register_optionflag(name)`` shouldn't create a + new flag when ``name`` is already the name of an option flag. + +- Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler + package. + +- Patch #1472854: make the rlcompleter.Completer class usable on non- + UNIX platforms. + +- Patch #1470846: fix urllib2 ProxyBasicAuthHandler. + +- Bug #1472827: correctly escape newlines and tabs in attribute values in + the saxutils.XMLGenerator class. + + +Build +----- + +- Bug #1502728: Correctly link against librt library on HP-UX. + +- OpenBSD 3.9 is supported now. + +- Patch #1492356: Port to Windows CE. + +- Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64. + +- Patch #1471883: Add --enable-universalsdk. + +C API +----- + +Tests +----- + +Tools +----- + +Documentation +------------- + + + +What's New in Python 2.5 alpha 2? +================================= + +*Release date: 27-APR-2006* + +Core and builtins +----------------- + +- Bug #1465834: 'bdist_wininst preinstall script support' was fixed + by converting these apis from macros into exported functions again: + + PyParser_SimpleParseFile PyParser_SimpleParseString PyRun_AnyFile + PyRun_AnyFileEx PyRun_AnyFileFlags PyRun_File PyRun_FileEx + PyRun_FileFlags PyRun_InteractiveLoop PyRun_InteractiveOne + PyRun_SimpleFile PyRun_SimpleFileEx PyRun_SimpleString + PyRun_String Py_CompileString + +- Under COUNT_ALLOCS, types are not necessarily immortal anymore. + +- All uses of PyStructSequence_InitType have been changed to initialize + the type objects only once, even if the interpreter is initialized + multiple times. + +- Bug #1454485, array.array('u') could crash the interpreter. This was + due to PyArgs_ParseTuple(args, 'u#', ...) trying to convert buffers (strings) + to unicode when it didn't make sense. 'u#' now requires a unicode string. + +- Py_UNICODE is unsigned. It was always documented as unsigned, but + due to a bug had a signed value in previous versions. + +- Patch #837242: ``id()`` of any Python object always gives a positive + number now, which might be a long integer. ``PyLong_FromVoidPtr`` and + ``PyLong_AsVoidPtr`` have been changed accordingly. Note that it has + never been correct to implement a ``__hash()__`` method that returns the + ``id()`` of an object: + + def __hash__(self): + return id(self) # WRONG + + because a hash result must be a (short) Python int but it was always + possible for ``id()`` to return a Python long. However, because ``id()`` + could return negative values before, on a 32-bit box an ``id()`` result + was always usable as a hash value before this patch. That's no longer + necessarily so. + +- Python on OS X 10.3 and above now uses dlopen() (via dynload_shlib.c) + to load extension modules and now provides the dl module. As a result, + sys.setdlopenflags() now works correctly on these systems. (SF patch + #1454844) + +- Patch #1463867: enhanced garbage collection to allow cleanup of cycles + involving generators that have paused outside of any ``try`` or ``with`` + blocks. (In 2.5a1, a paused generator that was part of a reference + cycle could not be garbage collected, regardless of whether it was + paused in a ``try`` or ``with`` block.) + +Extension Modules +----------------- + +- Patch #1191065: Fix preprocessor problems on systems where recvfrom + is a macro. + +- Bug #1467952: os.listdir() now correctly raises an error if readdir() + fails with an error condition. + +- Fixed bsddb.db.DBError derived exceptions so they can be unpickled. + +- Bug #1117761: bsddb.*open() no longer raises an exception when using + the cachesize parameter. + +- Bug #1149413: bsddb.*open() no longer raises an exception when using + a temporary db (file=None) with the 'n' flag to truncate on open. + +- Bug #1332852: bsddb module minimum BerkeleyDB version raised to 3.3 + as older versions cause excessive test failures. + +- Patch #1062014: AF_UNIX sockets under Linux have a special + abstract namespace that is now fully supported. + +Library +------- + +- Bug #1223937: subprocess.CalledProcessError reports the exit status + of the process using the returncode attribute, instead of + abusing errno. + +- Patch #1475231: ``doctest`` has a new ``SKIP`` option, which causes + a doctest to be skipped (the code is not run, and the expected output + or exception is ignored). + +- Fixed contextlib.nested to cope with exceptions being raised and + caught inside exit handlers. + +- Updated optparse module to Optik 1.5.1 (allow numeric constants in + hex, octal, or binary; add ``append_const`` action; keep going if + gettext cannot be imported; added ``OptionParser.destroy()`` method; + added ``epilog`` for better help generation). + +- Bug #1473760: ``tempfile.TemporaryFile()`` could hang on Windows, when + called from a thread spawned as a side effect of importing a module. + +- The pydoc module now supports documenting packages contained in + .zip or .egg files. + +- The pkgutil module now has several new utility functions, such + as ``walk_packages()`` to support working with packages that are either + in the filesystem or zip files. + +- The mailbox module can now modify and delete messages from + mailboxes, in addition to simply reading them. Thanks to Gregory + K. Johnson for writing the code, and to the 2005 Google Summer of + Code for funding his work. + +- The ``__del__`` method of class ``local`` in module ``_threading_local`` + returned before accomplishing any of its intended cleanup. + +- Patch #790710: Add breakpoint command lists in pdb. + +- Patch #1063914: Add Tkinter.Misc.clipboard_get(). + +- Patch #1191700: Adjust column alignment in bdb breakpoint lists. + +- SimpleXMLRPCServer relied on the fcntl module, which is unavailable on + Windows. Bug #1469163. + +- The warnings, linecache, inspect, traceback, site, and doctest modules + were updated to work correctly with modules imported from zipfiles or + via other PEP 302 __loader__ objects. + +- Patch #1467770: Reduce usage of subprocess._active to processes which + the application hasn't waited on. + +- Patch #1462222: Fix Tix.Grid. + +- Fix exception when doing glob.glob('anything*/') + +- The pstats.Stats class accepts an optional stream keyword argument to + direct output to an alternate file-like object. + +Build +----- + +- The Makefile now has a reindent target, which runs reindent.py on + the library. + +- Patch #1470875: Building Python with MS Free Compiler + +- Patch #1161914: Add a python-config script. + +- Patch #1324762:Remove ccpython.cc; replace --with-cxx with + --with-cxx-main. Link with C++ compiler only if --with-cxx-main was + specified. (Can be overridden by explicitly setting LINKCC.) Decouple + CXX from --with-cxx-main, see description in README. + +- Patch #1429775: Link extension modules with the shared libpython. + +- Fixed a libffi build problem on MIPS systems. + +- ``PyString_FromFormat``, ``PyErr_Format``, and ``PyString_FromFormatV`` + now accept formats "%u" for unsigned ints, "%lu" for unsigned longs, + and "%zu" for unsigned integers of type ``size_t``. + +Tests +----- + +- test_contextlib now checks contextlib.nested can cope with exceptions + being raised and caught inside exit handlers. + +- test_cmd_line now checks operation of the -m and -c command switches + +- The test_contextlib test in 2.5a1 wasn't actually run unless you ran + it separately and by hand. It also wasn't cleaning up its changes to + the current Decimal context. + +- regrtest.py now has a -M option to run tests that test the new limits of + containers, on 64-bit architectures. Running these tests is only sensible + on 64-bit machines with more than two gigabytes of memory. The argument + passed is the maximum amount of memory for the tests to use. + +Tools +----- + +- Added the Python benchmark suite pybench to the Tools/ directory; + contributed by Marc-Andre Lemburg. + +Documentation +------------- + +- Patch #1473132: Improve docs for ``tp_clear`` and ``tp_traverse``. + +- PEP 343: Added Context Types section to the library reference + and attempted to bring other PEP 343 related documentation into + line with the implementation and/or python-dev discussions. + +- Bug #1337990: clarified that ``doctest`` does not support examples + requiring both expected output and an exception. + + +What's New in Python 2.5 alpha 1? +================================= + +*Release date: 05-APR-2006* + +Core and builtins +----------------- + +- PEP 338: -m command line switch now delegates to runpy.run_module + allowing it to support modules in packages and zipfiles + +- On Windows, .DLL is not an accepted file name extension for + extension modules anymore; extensions are only found if they + end in .PYD. + +- Bug #1421664: sys.stderr.encoding is now set to the same value as + sys.stdout.encoding. + +- __import__ accepts keyword arguments. + +- Patch #1460496: round() now accepts keyword arguments. + +- Fixed bug #1459029 - unicode reprs were double-escaped. + +- Patch #1396919: The system scope threads are reenabled on FreeBSD + 5.4 and later versions. + +- Bug #1115379: Compiling a Unicode string with an encoding declaration + now gives a SyntaxError. + +- Previously, Python code had no easy way to access the contents of a + cell object. Now, a ``cell_contents`` attribute has been added + (closes patch #1170323). + +- Patch #1123430: Python's small-object allocator now returns an arena to + the system ``free()`` when all memory within an arena becomes unused + again. Prior to Python 2.5, arenas (256KB chunks of memory) were never + freed. Some applications will see a drop in virtual memory size now, + especially long-running applications that, from time to time, temporarily + use a large number of small objects. Note that when Python returns an + arena to the platform C's ``free()``, there's no guarantee that the + platform C library will in turn return that memory to the operating system. + The effect of the patch is to stop making that impossible, and in tests it + appears to be effective at least on Microsoft C and gcc-based systems. + Thanks to Evan Jones for hard work and patience. + +- Patch #1434038: property() now uses the getter's docstring if there is + no "doc" argument given. This makes it possible to legitimately use + property() as a decorator to produce a read-only property. + +- PEP 357, patch 1436368: add an __index__ method to int/long and a matching + nb_index slot to the PyNumberMethods struct. The slot is consulted instead + of requiring an int or long in slicing and a few other contexts, enabling + other objects (e.g. Numeric Python's integers) to be used as slice indices. + +- Fixed various bugs reported by Coverity's Prevent tool. + +- PEP 352, patch #1104669: Make exceptions new-style objects. Introduced the + new exception base class, BaseException, which has a new message attribute. + KeyboardInterrupt and SystemExit to directly inherit from BaseException now. + Raising a string exception now raises a DeprecationWarning. + +- Patch #1438387, PEP 328: relative and absolute imports. Imports can now be + explicitly relative, using 'from .module import name' to mean 'from the same + package as this module is in. Imports without dots still default to the + old relative-then-absolute, unless 'from __future__ import + absolute_import' is used. + +- Properly check if 'warnings' raises an exception (usually when a filter set + to "error" is triggered) when raising a warning for raising string + exceptions. + +- CO_GENERATOR_ALLOWED is no longer defined. This behavior is the default. + The name was removed from Include/code.h. + +- PEP 308: conditional expressions were added: (x if cond else y). + +- Patch 1433928: + - The copy module now "copies" function objects (as atomic objects). + - dict.__getitem__ now looks for a __missing__ hook before raising + KeyError. + +- PEP 343: with statement implemented. Needs ``from __future__ import + with_statement``. Use of 'with' as a variable will generate a warning. + Use of 'as' as a variable will also generate a warning (unless it's + part of an import statement). + The following objects have __context__ methods: + - The built-in file type. + - The thread.LockType type. + - The following types defined by the threading module: + Lock, RLock, Condition, Semaphore, BoundedSemaphore. + - The decimal.Context class. + +- Fix the encodings package codec search function to only search + inside its own package. Fixes problem reported in patch #1433198. + + Note: Codec packages should implement and register their own + codec search function. PEP 100 has the details. + +- PEP 353: Using ``Py_ssize_t`` as the index type. + +- ``PYMALLOC_DEBUG`` builds now add ``4*sizeof(size_t)`` bytes of debugging + info to each allocated block, since the ``Py_ssize_t`` changes (PEP 353) + now allow Python to make use of memory blocks exceeding 2**32 bytes for + some purposes on 64-bit boxes. A ``PYMALLOC_DEBUG`` build was limited + to 4-byte allocations before. + +- Patch #1400181, fix unicode string formatting to not use the locale. + This is how string objects work. u'%f' could use , instead of . + for the decimal point. Now both strings and unicode always use periods. + +- Bug #1244610, #1392915, fix build problem on OpenBSD 3.7 and 3.8. + configure would break checking curses.h. + +- Bug #959576: The pwd module is now builtin. This allows Python to be + built on UNIX platforms without $HOME set. + +- Bug #1072182, fix some potential problems if characters are signed. + +- Bug #889500, fix line number on SyntaxWarning for global declarations. + +- Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter. + +- Support for converting hex strings to floats no longer works. + This was not portable. float('0x3') now raises a ValueError. + +- Patch #1382163: Expose Subversion revision number to Python. New C API + function Py_GetBuildNumber(). New attribute sys.subversion. Build number + is now displayed in interactive prompt banner. + +- Implementation of PEP 341 - Unification of try/except and try/finally. + "except" clauses can now be written together with a "finally" clause in + one try statement instead of two nested ones. Patch #1355913. + +- Bug #1379994: Builtin unicode_escape and raw_unicode_escape codec + now encodes backslash correctly. + +- Patch #1350409: Work around signal handling bug in Visual Studio 2005. + +- Bug #1281408: Py_BuildValue now works correctly even with unsigned longs + and long longs. + +- SF Bug #1350188, "setdlopenflags" leads to crash upon "import" + It was possible for dlerror() to return a NULL pointer, so + it will now use a default error message in this case. + +- Replaced most Unicode charmap codecs with new ones using the + new Unicode translate string feature in the builtin charmap + codec; the codecs were created from the mapping tables available + at ftp.unicode.org and contain a few updates (e.g. the Mac OS + encodings now include a mapping for the Apple logo) + +- Added a few more codecs for Mac OS encodings + +- Sped up some Unicode operations. + +- A new AST parser implementation was completed. The abstract + syntax tree is available for read-only (non-compile) access + to Python code; an _ast module was added. + +- SF bug #1167751: fix incorrect code being produced for generator expressions. + The following code now raises a SyntaxError: foo(a = i for i in range(10)) + +- SF Bug #976608: fix SystemError when mtime of an imported file is -1. + +- SF Bug #887946: fix segfault when redirecting stdin from a directory. + Provide a warning when a directory is passed on the command line. + +- Fix segfault with invalid coding. + +- SF bug #772896: unknown encoding results in MemoryError. + +- All iterators now have a Boolean value of True. Formerly, some iterators + supported a __len__() method which evaluated to False when the iterator + was empty. + +- On 64-bit platforms, when __len__() returns a value that cannot be + represented as a C int, raise OverflowError. + +- test__locale is skipped on OS X < 10.4 (only partial locale support is + present). + +- SF bug #893549: parsing keyword arguments was broken with a few format + codes. + +- Changes donated by Elemental Security to make it work on AIX 5.3 + with IBM's 64-bit compiler (SF patch #1284289). This also closes SF + bug #105470: test_pwd fails on 64bit system (Opteron). + +- Changes donated by Elemental Security to make it work on HP-UX 11 on + Itanium2 with HP's 64-bit compiler (SF patch #1225212). + +- Disallow keyword arguments for type constructors that don't use them + (fixes bug #1119418). + +- Forward UnicodeDecodeError into SyntaxError for source encoding errors. + +- SF bug #900092: When tracing (e.g. for hotshot), restore 'return' events for + exceptions that cause a function to exit. + +- The implementation of set() and frozenset() was revised to use its + own internal data structure. Memory consumption is reduced by 1/3 + and there are modest speed-ups as well. The API is unchanged. + +- SF bug #1238681: freed pointer is used in longobject.c:long_pow(). + +- SF bug #1229429: PyObject_CallMethod failed to decrement some + reference counts in some error exit cases. + +- SF bug #1185883: Python's small-object memory allocator took over + a block managed by the platform C library whenever a realloc specified + a small new size. However, there's no portable way to know then how + much of the address space following the pointer is valid, so there's no + portable way to copy data from the C-managed block into Python's + small-object space without risking a memory fault. Python's small-object + realloc now leaves such blocks under the control of the platform C + realloc. + +- SF bug #1232517: An overflow error was not detected properly when + attempting to convert a large float to an int in os.utime(). + +- SF bug #1224347: hex longs now print with lowercase letters just + like their int counterparts. + +- SF bug #1163563: the original fix for bug #1010677 ("thread Module + Breaks PyGILState_Ensure()") broke badly in the case of multiple + interpreter states; back out that fix and do a better job (see + http://mail.python.org/pipermail/python-dev/2005-June/054258.html + for a longer write-up of the problem). + +- SF patch #1180995: marshal now uses a binary format by default when + serializing floats. + +- SF patch #1181301: on platforms that appear to use IEEE 754 floats, + the routines that promise to produce IEEE 754 binary representations + of floats now simply copy bytes around. + +- bug #967182: disallow opening files with 'wU' or 'aU' as specified by PEP + 278. + +- patch #1109424: int, long, float, complex, and unicode now check for the + proper magic slot for type conversions when subclassed. Previously the + magic slot was ignored during conversion. Semantics now match the way + subclasses of str always behaved. int/long/float, conversion of an instance + to the base class has been moved to the proper nb_* magic slot and out of + PyNumber_*(). + Thanks Walter D?rwald. + +- Descriptors defined in C with a PyGetSetDef structure, where the setter is + NULL, now raise an AttributeError when attempting to set or delete the + attribute. Previously a TypeError was raised, but this was inconsistent + with the equivalent pure-Python implementation. + +- It is now safe to call PyGILState_Release() before + PyEval_InitThreads() (note that if there is reason to believe there + are multiple threads around you still must call PyEval_InitThreads() + before using the Python API; this fix is for extension modules that + have no way of knowing if Python is multi-threaded yet). + +- Typing Ctrl-C whilst raw_input() was waiting in a build with threads + disabled caused a crash. + +- Bug #1165306: instancemethod_new allowed the creation of a method + with im_class == im_self == NULL, which caused a crash when called. + +- Move exception finalisation later in the shutdown process - this + fixes the crash seen in bug #1165761 + +- Added two new builtins, any() and all(). + +- Defining a class with empty parentheses is now allowed + (e.g., ``class C(): pass`` is no longer a syntax error). + Patch #1176012 added support to the 'parser' module and 'compiler' package + (thanks to logistix for that added support). + +- Patch #1115086: Support PY_LONGLONG in structmember. + +- Bug #1155938: new style classes did not check that __init__() was + returning None. + +- Patch #802188: Report characters after line continuation character + ('\') with a specific error message. + +- Bug #723201: Raise a TypeError for passing bad objects to 'L' format. + +- Bug #1124295: the __name__ attribute of file objects was + inadvertently made inaccessible in restricted mode. + +- Bug #1074011: closing sys.std{out,err} now causes a flush() and + an ferror() call. + +- min() and max() now support key= arguments with the same meaning as in + list.sort(). + +- The peephole optimizer now performs simple constant folding in expressions: + (2+3) --> (5). + +- set and frozenset objects can now be marshalled. SF #1098985. + +- Bug #1077106: Poor argument checking could cause memory corruption + in calls to os.read(). + +- The parser did not complain about future statements in illegal + positions. It once again reports a syntax error if a future + statement occurs after anything other than a doc string. + +- Change the %s format specifier for str objects so that it returns a + unicode instance if the argument is not an instance of basestring and + calling __str__ on the argument returns a unicode instance. + +- Patch #1413181: changed ``PyThreadState_Delete()`` to forget about the + current thread state when the auto-GIL-state machinery knows about + it (since the thread state is being deleted, continuing to remember it + can't help, but can hurt if another thread happens to get created with + the same thread id). + +Extension Modules +----------------- + +- Patch #1380952: fix SSL objects timing out on consecutive read()s + +- Patch #1309579: wait3 and wait4 were added to the posix module. + +- Patch #1231053: The audioop module now supports encoding/decoding of alaw. + In addition, the existing ulaw code was updated. + +- RFE #567972: Socket objects' family, type and proto properties are + now exposed via new attributes. + +- Everything under lib-old was removed. This includes the following modules: + Para, addpack, cmp, cmpcache, codehack, dircmp, dump, find, fmt, grep, + lockfile, newdir, ni, packmail, poly, rand, statcache, tb, tzparse, + util, whatsound, whrandom, zmod + +- The following modules were removed: regsub, reconvert, regex, regex_syntax. + +- re and sre were swapped, so help(re) provides full help. importing sre + is deprecated. The undocumented re.engine variable no longer exists. + +- Bug #1448490: Fixed a bug that ISO-2022 codecs could not handle + SS2 (single-shift 2) escape sequences correctly. + +- The unicodedata module was updated to the 4.1 version of the Unicode + database. The 3.2 version is still available as unicodedata.db_3_2_0 + for applications that require this specific version (such as IDNA). + +- The timing module is no longer built by default. It was deprecated + in PEP 4 in Python 2.0 or earlier. + +- Patch 1433928: Added a new type, defaultdict, to the collections module. + This uses the new __missing__ hook behavior added to dict (see above). + +- Bug #854823: socketmodule now builds on Sun platforms even when + INET_ADDRSTRLEN is not defined. + +- Patch #1393157: os.startfile() now has an optional argument to specify + a "command verb" to invoke on the file. + +- Bug #876637, prevent stack corruption when socket descriptor + is larger than FD_SETSIZE. + +- Patch #1407135, bug #1424041: harmonize mmap behavior of anonymous memory. + mmap.mmap(-1, size) now returns anonymous memory in both Unix and Windows. + mmap.mmap(0, size) should not be used on Windows for anonymous memory. + +- Patch #1422385: The nis module now supports access to domains other + than the system default domain. + +- Use Win32 API to implement os.stat/fstat. As a result, subsecond timestamps + are reported, the limit on path name lengths is removed, and stat reports + WindowsError now (instead of OSError). + +- Add bsddb.db.DBEnv.set_tx_timestamp allowing time based database recovery. + +- Bug #1413192, fix seg fault in bsddb if a transaction was deleted + before the env. + +- Patch #1103116: Basic AF_NETLINK support. + +- Bug #1402308, (possible) segfault when using mmap.mmap(-1, ...) + +- Bug #1400822, _curses over{lay,write} doesn't work when passing 6 ints. + Also fix ungetmouse() which did not accept arguments properly. + The code now conforms to the documented signature. + +- Bug #1400115, Fix segfault when calling curses.panel.userptr() + without prior setting of the userptr. + +- Fix 64-bit problems in bsddb. + +- Patch #1365916: fix some unsafe 64-bit mmap methods. + +- Bug #1290333: Added a workaround for cjkcodecs' _codecs_cn build + problem on AIX. + +- Bug #869197: os.setgroups rejects long integer arguments + +- Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint + +- Bug #1344508, Fix UNIX mmap leaking file descriptors + +- Patch #1338314, Bug #1336623: fix tarfile so it can extract + REGTYPE directories from tarfiles written by old programs. + +- Patch #1407992, fixes broken bsddb module db associate when using + BerkeleyDB 3.3, 4.0 or 4.1. + +- Get bsddb module to build with BerkeleyDB version 4.4 + +- Get bsddb module to build with BerkeleyDB version 3.2 + +- Patch #1309009, Fix segfault in pyexpat when the XML document is in latin_1, + but Python incorrectly assumes it is in UTF-8 format + +- Fix parse errors in the readline module when compiling without threads. + +- Patch #1288833: Removed thread lock from socket.getaddrinfo on + FreeBSD 5.3 and later versions which got thread-safe getaddrinfo(3). + +- Patches #1298449 and #1298499: Add some missing checks for error + returns in cStringIO.c. + +- Patch #1297028: fix segfault if call type on MultibyteCodec, + MultibyteStreamReader, or MultibyteStreamWriter + +- Fix memory leak in posix.access(). + +- Patch #1213831: Fix typo in unicodedata._getcode. + +- Bug #1007046: os.startfile() did not accept unicode strings encoded in + the file system encoding. + +- Patch #756021: Special-case socket.inet_aton('255.255.255.255') for + platforms that don't have inet_aton(). + +- Bug #1215928: Fix bz2.BZ2File.seek() for 64-bit file offsets. + +- Bug #1191043: Fix bz2.BZ2File.(x)readlines for files containing one + line without newlines. + +- Bug #728515: mmap.resize() now resizes the file on Unix as it did + on Windows. + +- Patch #1180695: Add nanosecond stat resolution, and st_gen, + st_birthtime for FreeBSD. + +- Patch #1231069: The fcntl.ioctl function now uses the 'I' code for + the request code argument, which results in more C-like behaviour + for large or negative values. + +- Bug #1234979: For the argument of thread.Lock.acquire, the Windows + implementation treated all integer values except 1 as false. + +- Bug #1194181: bz2.BZ2File didn't handle mode 'U' correctly. + +- Patch #1212117: os.stat().st_flags is now accessible as a attribute + if available on the platform. + +- Patch #1103951: Expose O_SHLOCK and O_EXLOCK in the posix module if + available on the platform. + +- Bug #1166660: The readline module could segfault if hook functions + were set in a different thread than that which called readline. + +- collections.deque objects now support a remove() method. + +- operator.itemgetter() and operator.attrgetter() now support retrieving + multiple fields. This provides direct support for sorting on multiple + keys (primary, secondary, etc). + +- os.access now supports Unicode path names on non-Win32 systems. + +- Patches #925152, #1118602: Avoid reading after the end of the buffer + in pyexpat.GetInputContext. + +- Patches #749830, #1144555: allow UNIX mmap size to default to current + file size. + +- Added functional.partial(). See PEP309. + +- Patch #1093585: raise a ValueError for negative history items in readline. + {remove_history,replace_history} + +- The spwd module has been added, allowing access to the shadow password + database. + +- stat_float_times is now True. + +- array.array objects are now picklable. + +- the cPickle module no longer accepts the deprecated None option in the + args tuple returned by __reduce__(). + +- itertools.islice() now accepts None for the start and step arguments. + This allows islice() to work more readily with slices: + islice(s.start, s.stop, s.step) + +- datetime.datetime() now has a strptime class method which can be used to + create datetime object using a string and format. + +- Patch #1117961: Replace the MD5 implementation from RSA Data Security Inc + with the implementation from http://sourceforge.net/projects/libmd5-rfc/. + +Library +------- + +- Patch #1388073: Numerous __-prefixed attributes of unittest.TestCase have + been renamed to have only a single underscore prefix. This was done to + make subclassing easier. + +- PEP 338: new module runpy defines a run_module function to support + executing modules which provide access to source code or a code object + via the PEP 302 import mechanisms. + +- The email module's parsedate_tz function now sets the daylight savings + flag to -1 (unknown) since it can't tell from the date whether it should + be set. + +- Patch #624325: urlparse.urlparse() and urlparse.urlsplit() results + now sport attributes that provide access to the parts of the result. + +- Patch #1462498: sgmllib now handles entity and character references + in attribute values. + +- Added the sqlite3 package. This is based on pysqlite2.1.3, and provides + a DB-API interface in the standard library. You'll need sqlite 3.0.8 or + later to build this - if you have an earlier version, the C extension + module will not be built. + +- Bug #1460340: ``random.sample(dict)`` failed in various ways. Dicts + aren't officially supported here, and trying to use them will probably + raise an exception some day. But dicts have been allowed, and "mostly + worked", so support for them won't go away without warning. + +- Bug #1445068: getpass.getpass() can now be given an explicit stream + argument to specify where to write the prompt. + +- Patch #1462313, bug #1443328: the pickle modules now can handle classes + that have __private names in their __slots__. + +- Bug #1250170: mimetools now handles socket.gethostname() failures gracefully. + +- patch #1457316: "setup.py upload" now supports --identity to select the + key to be used for signing the uploaded code. + +- Queue.Queue objects now support .task_done() and .join() methods + to make it easier to monitor when daemon threads have completed + processing all enqueued tasks. Patch #1455676. + +- popen2.Popen objects now preserve the command in a .cmd attribute. + +- Added the ctypes ffi package. + +- email 4.0 package now integrated. This is largely the same as the email 3.0 + package that was included in Python 2.3, except that PEP 8 module names are + now used (e.g. mail.message instead of email.Message). The MIME classes + have been moved to a subpackage (e.g. email.mime.text instead of + email.MIMEText). The old names are still supported for now. Several + deprecated Message methods have been removed and lots of bugs have been + fixed. More details can be found in the email package documentation. + +- Patches #1436130/#1443155: codecs.lookup() now returns a CodecInfo object + (a subclass of tuple) that provides incremental decoders and encoders + (a way to use stateful codecs without the stream API). Python functions + codecs.getincrementaldecoder() and codecs.getincrementalencoder() as well + as C functions PyCodec_IncrementalEncoder() and PyCodec_IncrementalDecoder() + have been added. + +- Patch #1359365: Calling next() on a closed StringIO.String object raises + a ValueError instead of a StopIteration now (like file and cString.String do). + cStringIO.StringIO.isatty() will raise a ValueError now if close() has been + called before (like file and StringIO.StringIO do). + +- A regrtest option -w was added to re-run failed tests in verbose mode. + +- Patch #1446372: quit and exit can now be called from the interactive + interpreter to exit. + +- The function get_count() has been added to the gc module, and gc.collect() + grew an optional 'generation' argument. + +- A library msilib to generate Windows Installer files, and a distutils + command bdist_msi have been added. + +- PEP 343: new module contextlib.py defines decorator @contextmanager + and helpful context managers nested() and closing(). + +- The compiler package now supports future imports after the module docstring. + +- Bug #1413790: zipfile now sanitizes absolute archive names that are + not allowed by the specs. + +- Patch #1215184: FileInput now can be given an opening hook which can + be used to control how files are opened. + +- Patch #1212287: fileinput.input() now has a mode parameter for + specifying the file mode input files should be opened with. + +- Patch #1215184: fileinput now has a fileno() function for getting the + current file number. + +- Patch #1349274: gettext.install() now optionally installs additional + translation functions other than _() in the builtin namespace. + +- Patch #1337756: fileinput now accepts Unicode filenames. + +- Patch #1373643: The chunk module can now read chunks larger than + two gigabytes. + +- Patch #1417555: SimpleHTTPServer now returns Last-Modified headers. + +- Bug #1430298: It is now possible to send a mail with an empty + return address using smtplib. + +- Bug #1432260: The names of lambda functions are now properly displayed + in pydoc. + +- Patch #1412872: zipfile now sets the creator system to 3 (Unix) + unless the system is Win32. + +- Patch #1349118: urllib now supports user:pass@ style proxy + specifications, raises IOErrors when proxies for unsupported protocols + are defined, and uses the https proxy on https redirections. + +- Bug #902075: urllib2 now supports 'host:port' style proxy specifications. + +- Bug #1407902: Add support for sftp:// URIs to urlparse. + +- Bug #1371247: Update Windows locale identifiers in locale.py. + +- Bug #1394565: SimpleHTTPServer now doesn't choke on query parameters + any more. + +- Bug #1403410: The warnings module now doesn't get confused + when it can't find out the module name it generates a warning for. + +- Patch #1177307: Added a new codec utf_8_sig for UTF-8 with a BOM signature. + +- Patch #1157027: cookielib mishandles RFC 2109 cookies in Netscape mode + +- Patch #1117398: cookielib.LWPCookieJar and .MozillaCookieJar now raise + LoadError as documented, instead of IOError. For compatibility, + LoadError subclasses IOError. + +- Added the hashlib module. It provides secure hash functions for MD5 and + SHA1, 224, 256, 384, and 512. Note that recent developments make the + historic MD5 and SHA1 unsuitable for cryptographic-strength applications. + In + Ronald L. Rivest offered this advice for Python: + + "The consensus of researchers in this area (at least as + expressed at the NIST Hash Function Workshop 10/31/05), + is that SHA-256 is a good choice for the time being, but + that research should continue, and other alternatives may + arise from this research. The larger SHA's also seem OK." + +- Added a subset of Fredrik Lundh's ElementTree package. Available + modules are xml.etree.ElementTree, xml.etree.ElementPath, and + xml.etree.ElementInclude, from ElementTree 1.2.6. + +- Patch #1162825: Support non-ASCII characters in IDLE window titles. + +- Bug #1365984: urllib now opens "data:" URLs again. + +- Patch #1314396: prevent deadlock for threading.Thread.join() when an exception + is raised within the method itself on a previous call (e.g., passing in an + illegal argument) + +- Bug #1340337: change time.strptime() to always return ValueError when there + is an error in the format string. + +- Patch #754022: Greatly enhanced webbrowser.py (by Oleg Broytmann). + +- Bug #729103: pydoc.py: Fix docother() method to accept additional + "parent" argument. + +- Patch #1300515: xdrlib.py: Fix pack_fstring() to really use null bytes + for padding. + +- Bug #1296004: httplib.py: Limit maximal amount of data read from the + socket to avoid a MemoryError on Windows. + +- Patch #1166948: locale.py: Prefer LC_ALL, LC_CTYPE and LANG over LANGUAGE + to get the correct encoding. + +- Patch #1166938: locale.py: Parse LANGUAGE as a colon separated list of + languages. + +- Patch #1268314: Cache lines in StreamReader.readlines for performance. + +- Bug #1290505: Fix clearing the regex cache for time.strptime(). + +- Bug #1167128: Fix size of a symlink in a tarfile to be 0. + +- Patch #810023: Fix off-by-one bug in urllib.urlretrieve reporthook + functionality. + +- Bug #1163178: Make IDNA return an empty string when the input is empty. + +- Patch #848017: Make Cookie more RFC-compliant. Use CRLF as default output + separator and do not output trailing semicolon. + +- Patch #1062060: urllib.urlretrieve() now raises a new exception, named + ContentTooShortException, when the actually downloaded size does not + match the Content-Length header. + +- Bug #1121494: distutils.dir_utils.mkpath now accepts Unicode strings. + +- Bug #1178484: Return complete lines from codec stream readers + even if there is an exception in later lines, resulting in + correct line numbers for decoding errors in source code. + +- Bug #1192315: Disallow negative arguments to clear() in pdb. + +- Patch #827386: Support absolute source paths in msvccompiler.py. + +- Patch #1105730: Apply the new implementation of commonprefix in posixpath + to ntpath, macpath, os2emxpath and riscospath. + +- Fix a problem in Tkinter introduced by SF patch #869468: delete bogus + __hasattr__ and __delattr__ methods on class Tk that were breaking + Tkdnd. + +- Bug #1015140: disambiguated the term "article id" in nntplib docs and + docstrings to either "article number" or "message id". + +- Bug #1238170: threading.Thread.__init__ no longer has "kwargs={}" as a + parameter, but uses the usual "kwargs=None". + +- textwrap now processes text chunks at O(n) speed instead of O(n**2). + Patch #1209527 (Contributed by Connelly). + +- urllib2 has now an attribute 'httpresponses' mapping from HTTP status code + to W3C name (404 -> 'Not Found'). RFE #1216944. + +- Bug #1177468: Don't cache the /dev/urandom file descriptor for os.urandom, + as this can cause problems with apps closing all file descriptors. + +- Bug #839151: Fix an attempt to access sys.argv in the warnings module; + it can be missing in embedded interpreters + +- Bug #1155638: Fix a bug which affected HTTP 0.9 responses in httplib. + +- Bug #1100201: Cross-site scripting was possible on BaseHTTPServer via + error messages. + +- Bug #1108948: Cookie.py produced invalid JavaScript code. + +- The tokenize module now detects and reports indentation errors. + Bug #1224621. + +- The tokenize module has a new untokenize() function to support a full + roundtrip from lexed tokens back to Python source code. In addition, + the generate_tokens() function now accepts a callable argument that + terminates by raising StopIteration. + +- Bug #1196315: fix weakref.WeakValueDictionary constructor. + +- Bug #1213894: os.path.realpath didn't resolve symlinks that were the first + component of the path. + +- Patch #1120353: The xmlrpclib module provides better, more transparent, + support for datetime.{datetime,date,time} objects. With use_datetime set + to True, applications shouldn't have to fiddle with the DateTime wrapper + class at all. + +- distutils.commands.upload was added to support uploading distribution + files to PyPI. + +- distutils.commands.register now encodes the data as UTF-8 before posting + them to PyPI. + +- decimal operator and comparison methods now return NotImplemented + instead of raising a TypeError when interacting with other types. This + allows other classes to implement __radd__ style methods and have them + work as expected. + +- Bug #1163325: Decimal infinities failed to hash. Attempting to + hash a NaN raised an InvalidOperation instead of a TypeError. + +- Patch #918101: Add tarfile open mode r|* for auto-detection of the + stream compression; add, for symmetry reasons, r:* as a synonym of r. + +- Patch #1043890: Add extractall method to tarfile. + +- Patch #1075887: Don't require MSVC in distutils if there is nothing + to build. + +- Patch #1103407: Properly deal with tarfile iterators when untarring + symbolic links on Windows. + +- Patch #645894: Use getrusage for computing the time consumption in + profile.py if available. + +- Patch #1046831: Use get_python_version where appropriate in sysconfig.py. + +- Patch #1117454: Remove code to special-case cookies without values + in LWPCookieJar. + +- Patch #1117339: Add cookielib special name tests. + +- Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. + +- Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. + +- Patch #1107973: Allow to iterate over the lines of a tarfile.ExFileObject. + +- Patch #1104111: Alter setup.py --help and --help-commands. + +- Patch #1121234: Properly cleanup _exit and tkerror commands. + +- Patch #1049151: xdrlib now unpacks booleans as True or False. + +- Fixed bug in a NameError bug in cookielib. Patch #1116583. + +- Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This + disables recursive traversal through instance attributes, which can + be exploited in various ways. + +- Bug #1222790: in SimpleXMLRPCServer, set the reuse-address and close-on-exec + flags on the HTTP listening socket. + +- Bug #792570: SimpleXMLRPCServer had problems if the request grew too large. + Fixed by reading the HTTP body in chunks instead of one big socket.read(). + +- Patches #893642, #1039083: add allow_none, encoding arguments to + constructors of SimpleXMLRPCServer and CGIXMLRPCRequestHandler. + +- Bug #1110478: Revert os.environ.update to do putenv again. + +- Bug #1103844: fix distutils.install.dump_dirs() with negated options. + +- os.{SEEK_SET, SEEK_CUR, SEEK_END} have been added for convenience. + +- Enhancements to the csv module: + + + Dialects are now validated by the underlying C code, better + reflecting its capabilities, and improving its compliance with + PEP 305. + + Dialect parameter parsing has been re-implemented to improve error + reporting. + + quotechar=None and quoting=QUOTE_NONE now work the way PEP 305 + dictates. + + the parser now removes the escapechar prefix from escaped characters. + + when quoting=QUOTE_NONNUMERIC, the writer now tests for numeric + types, rather than any object that can be represented as a numeric. + + when quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields + to floats. + + reader now allows \r characters to be quoted (previously it only allowed + \n to be quoted). + + writer doublequote handling improved. + + Dialect classes passed to the module are no longer instantiated by + the module before being parsed (the former validation scheme required + this, but the mechanism was unreliable). + + The dialect registry now contains instances of the internal + C-coded dialect type, rather than references to python objects. + + the internal c-coded dialect type is now immutable. + + register_dialect now accepts the same keyword dialect specifications + as the reader and writer, allowing the user to register dialects + without first creating a dialect class. + + a configurable limit to the size of parsed fields has been added - + previously, an unmatched quote character could result in the entire + file being read into the field buffer before an error was reported. + + A new module method csv.field_size_limit() has been added that sets + the parser field size limit (returning the former limit). The initial + limit is 128kB. + + A line_num attribute has been added to the reader object, which tracks + the number of lines read from the source iterator. This is not + the same as the number of records returned, as records can span + multiple lines. + + reader and writer objects were not being registered with the cyclic-GC. + This has been fixed. + +- _DummyThread objects in the threading module now delete self.__block that is + inherited from _Thread since it uses up a lock allocated by 'thread'. The + lock primitives tend to be limited in number and thus should not be wasted on + a _DummyThread object. Fixes bug #1089632. + +- The imghdr module now detects Exif files. + +- StringIO.truncate() now correctly adjusts the size attribute. + (Bug #951915). + +- locale.py now uses an updated locale alias table (built using + Tools/i18n/makelocalealias.py, a tool to parse the X11 locale + alias file); the encoding lookup was enhanced to use Python's + encoding alias table. + +- moved deprecated modules to Lib/lib-old: whrandom, tzparse, statcache. + +- the pickle module no longer accepts the deprecated None option in the + args tuple returned by __reduce__(). + +- optparse now optionally imports gettext. This allows its use in setup.py. + +- the pickle module no longer uses the deprecated bin parameter. + +- the shelve module no longer uses the deprecated binary parameter. + +- the pstats module no longer uses the deprecated ignore() method. + +- the filecmp module no longer uses the deprecated use_statcache argument. + +- unittest.TestCase.run() and unittest.TestSuite.run() can now be successfully + extended or overridden by subclasses. Formerly, the subclassed method would + be ignored by the rest of the module. (Bug #1078905). + +- heapq.nsmallest() and heapq.nlargest() now support key= arguments with + the same meaning as in list.sort(). + +- Bug #1076985: ``codecs.StreamReader.readline()`` now calls ``read()`` only + once when a size argument is given. This prevents a buffer overflow in the + tokenizer with very long source lines. + +- Bug #1083110: ``zlib.decompress.flush()`` would segfault if called + immediately after creating the object, without any intervening + ``.decompress()`` calls. + +- The reconvert.quote function can now emit triple-quoted strings. The + reconvert module now has some simple documentation. + +- ``UserString.MutableString`` now supports negative indices in + ``__setitem__`` and ``__delitem__`` + +- Bug #1149508: ``textwrap`` now handles hyphenated numbers (eg. "2004-03-05") + correctly. + +- Partial fixes for SF bugs #1163244 and #1175396: If a chunk read by + ``codecs.StreamReader.readline()`` has a trailing "\r", read one more + character even if the user has passed a size parameter to get a proper + line ending. Remove the special handling of a "\r\n" that has been split + between two lines. + +- Bug #1251300: On UCS-4 builds the "unicode-internal" codec will now complain + about illegal code points. The codec now supports PEP 293 style error + handlers. + +- Bug #1235646: ``codecs.StreamRecoder.next()`` now reencodes the data it reads + from the input stream, so that the output is a byte string in the correct + encoding instead of a unicode string. + +- Bug #1202493: Fixing SRE parser to handle '{}' as perl does, rather than + considering it exactly like a '*'. + +- Bug #1245379: Add "unicode-1-1-utf-7" as an alias for "utf-7" to + ``encodings.aliases``. + +- ` uu.encode()`` and ``uu.decode()`` now support unicode filenames. + +- Patch #1413711: Certain patterns of differences were making difflib + touch the recursion limit. + +- Bug #947906: An object oriented interface has been added to the calendar + module. It's possible to generate HTML calendar now and the module can be + called as a script (e.g. via ``python -mcalendar``). Localized month and + weekday names can be ouput (even if an exotic encoding is used) using + special classes that use unicode. + +Build +----- + +- Fix test_float, test_long, and test_struct failures on Tru64 with gcc + by using -mieee gcc option. + +- Patch #1432345: Make python compile on DragonFly. + +- Build support for Win64-AMD64 was added. + +- Patch #1428494: Prefer linking against ncursesw over ncurses library. + +- Patch #881820: look for openpty and forkpty also in libbsd. + +- The sources of zlib are now part of the Python distribution (zlib 1.2.3). + The zlib module is now builtin on Windows. + +- Use -xcode=pic32 for CCSHARED on Solaris with SunPro. + +- Bug #1189330: configure did not correctly determine the necessary + value of LINKCC if python was built with GCC 4.0. + +- Upgrade Windows build to zlib 1.2.3 which eliminates a potential security + vulnerability in zlib 1.2.1 and 1.2.2. + +- EXTRA_CFLAGS has been introduced as an environment variable to hold compiler + flags that change binary compatibility. Changes were also made to + distutils.sysconfig to also use the environment variable when used during + compilation of the interpreter and of C extensions through distutils. + +- SF patch 1171735: Darwin 8's headers are anal about POSIX compliance, + and linking has changed (prebinding is now deprecated, and libcc_dynamic + no longer exists). This configure patch makes things right. + +- Bug #1158607: Build with --disable-unicode again. + +- spwdmodule.c is built only if either HAVE_GETSPNAM or HAVE_HAVE_GETSPENT is + defined. Discovered as a result of not being able to build on OS X. + +- setup.py now uses the directories specified in LDFLAGS using the -L option + and in CPPFLAGS using the -I option for adding library and include + directories, respectively, for compiling extension modules against. This has + led to the core being compiled using the values in CPPFLAGS. It also removes + the need for the special-casing of both DarwinPorts and Fink for darwin since + the proper directories can be specified in LDFLAGS (``-L/sw/lib`` for Fink, + ``-L/opt/local/lib`` for DarwinPorts) and CPPFLAGS (``-I/sw/include`` for + Fink, ``-I/opt/local/include`` for DarwinPorts). + +- Test in configure.in that checks for tzset no longer dependent on tm->tm_zone + to exist in the struct (not required by either ISO C nor the UNIX 2 spec). + Tests for sanity in tzname when HAVE_TZNAME defined were also defined. + Closes bug #1096244. Thanks Gregory Bond. + +C API +----- + +- ``PyMem_{Del, DEL}`` and ``PyMem_{Free, FREE}`` no longer map to + ``PyObject_{Free, FREE}``. They map to the system ``free()`` now. If memory + is obtained via the ``PyObject_`` family, it must be released via the + ``PyObject_`` family, and likewise for the ``PyMem_`` family. This has + always been officially true, but when Python's small-object allocator was + introduced, an attempt was made to cater to a few extension modules + discovered at the time that obtained memory via ``PyObject_New`` but + released it via ``PyMem_DEL``. It's years later, and if such code still + exists it will fail now (probably with segfaults, but calling wrong + low-level memory management functions can yield many symptoms). + +- Added a C API for set and frozenset objects. + +- Removed PyRange_New(). + +- Patch #1313939: PyUnicode_DecodeCharmap() accepts a unicode string as the + mapping argument now. This string is used as a mapping table. Byte values + greater than the length of the string and 0xFFFE are treated as undefined + mappings. + + +Tests +----- + +- In test_os, st_?time is now truncated before comparing it with ST_?TIME. + +- Patch #1276356: New resource "urlfetch" is implemented. This enables + even impatient people to run tests that require remote files. + + +Documentation +------------- + +- Bug #1402224: Add warning to dl docs about crashes. + +- Bug #1396471: Document that Windows' ftell() can return invalid + values for text files with UNIX-style line endings. + +- Bug #1274828: Document os.path.splitunc(). + +- Bug #1190204: Clarify which directories are searched by site.py. + +- Bug #1193849: Clarify os.path.expanduser() documentation. + +- Bug #1243192: re.UNICODE and re.LOCALE affect \d, \D, \s and \S. + +- Bug #755617: Document the effects of os.chown() on Windows. + +- Patch #1180012: The documentation for modulefinder is now in the library reference. + +- Patch #1213031: Document that os.chown() accepts argument values of -1. + +- Bug #1190563: Document os.waitpid() return value with WNOHANG flag. + +- Bug #1175022: Correct the example code for property(). + +- Document the IterableUserDict class in the UserDict module. + Closes bug #1166582. + +- Remove all latent references for "Macintosh" that referred to semantics for + Mac OS 9 and change to reflect the state for OS X. + Closes patch #1095802. Thanks Jack Jansen. + +Mac +--- + + +New platforms +------------- + +- FreeBSD 7 support is added. + + +Tools/Demos +----------- + +- Created Misc/Vim/vim_syntax.py to auto-generate a python.vim file in that + directory for syntax highlighting in Vim. Vim directory was added and placed + vimrc to it (was previous up a level). + +- Added two new files to Tools/scripts: pysource.py, which recursively + finds Python source files, and findnocoding.py, which finds Python + source files that need an encoding declaration. + Patch #784089, credits to Oleg Broytmann. + +- Bug #1072853: pindent.py used an uninitialized variable. + +- Patch #1177597: Correct Complex.__init__. + +- Fixed a display glitch in Pynche, which could cause the right arrow to + wiggle over by a pixel. + + What's New in Python 2.4 final? =============================== Modified: python/branches/py3k/Modules/_ctypes/libffi/configure ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/configure (original) +++ python/branches/py3k/Modules/_ctypes/libffi/configure Fri Feb 22 17:37:40 2008 @@ -1,27 +1,56 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for libffi 2.1. +# Generated by GNU Autoconf 2.61 for libffi 2.1. # # Report bugs to . # -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -31,8 +60,43 @@ fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -46,18 +110,19 @@ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -65,157 +130,388 @@ # Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` +# CDPATH. +$as_unset CDPATH -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no fi + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in + case $as_dir in /*) - if ("$as_dir/$as_base" -c ' + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf at gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || + chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -224,7 +520,28 @@ as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -233,39 +550,27 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH +exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` -exec 6>&1 - # # Initializations. # ac_default_prefix=/usr/local +ac_clean_files= ac_config_libobj_dir=. +LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - # Identity of this package. PACKAGE_NAME='libffi' PACKAGE_TARNAME='libffi' @@ -276,42 +581,112 @@ # Factoring default headers for most tests. ac_includes_default="\ #include -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include # include #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include #endif -#if HAVE_INTTYPES_H +#ifdef HAVE_INTTYPES_H # include -#else -# if HAVE_STDINT_H -# include -# endif #endif -#if HAVE_UNISTD_H +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC ac_ct_CC EXEEXT OBJEXT CFLAGS CPP CPPFLAGS EGREP ALLOCA HAVE_LONG_DOUBLE TARGET TARGETDIR MKTARGET LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +build +build_cpu +build_vendor +build_os +host +host_cpu +host_vendor +host_os +target +target_cpu +target_vendor +target_os +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +CPP +GREP +EGREP +ALLOCA +HAVE_LONG_DOUBLE +TARGET +TARGETDIR +MKTARGET +LIBOBJS +LTLIBOBJS' ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CPP +CPPFLAGS' + # Initialize some variables set by options. ac_init_help= @@ -338,34 +713,48 @@ # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' +datarootdir='${prefix}/share' +datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' ac_prev= +ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" + eval $ac_prev=\$ac_option ac_prev= continue fi - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_option in + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; @@ -387,33 +776,45 @@ --config-cache | -C) cache_file=config.cache ;; - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) + -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -440,6 +841,12 @@ -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; @@ -464,13 +871,16 @@ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) + | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) @@ -535,6 +945,16 @@ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -587,24 +1007,20 @@ -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. @@ -635,8 +1051,7 @@ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" + eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) @@ -656,27 +1071,19 @@ { (exit 1); exit 1; }; } fi -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir do - eval ac_val=$`echo $ac_var` + eval ac_val=\$$ac_var case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' @@ -703,64 +1110,78 @@ test "$silent" = yes && exec 6>/dev/null +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then + if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } - fi fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CPP_set=${CPP+set} -ac_env_CPP_value=$CPP -ac_cv_env_CPP_set=${CPP+set} -ac_cv_env_CPP_value=$CPP -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS - -# + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# # Report the --help message. # if test "$ac_init_help" = "long"; then @@ -787,9 +1208,6 @@ -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] -_ACEOF - - cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] @@ -807,15 +1225,22 @@ --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/libffi] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -838,8 +1263,9 @@ CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help @@ -847,120 +1273,86 @@ Report bugs to . _ACEOF +ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. - ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue + test -d "$ac_dir" || continue ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd "$ac_popdir" + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } done fi -test -n "$ac_init_help" && exit 0 +test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF libffi configure 2.1 -generated by GNU Autoconf 2.59 +generated by GNU Autoconf 2.61 -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF - exit 0 + exit fi -exec 5>config.log -cat >&5 <<_ACEOF +cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by libffi $as_me 2.1, which was -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF +exec 5>>config.log { cat <<_ASUNAME ## --------- ## @@ -979,7 +1371,7 @@ /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` @@ -993,6 +1385,7 @@ test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done +IFS=$as_save_IFS } >&5 @@ -1014,7 +1407,6 @@ ac_configure_args= ac_configure_args0= ac_configure_args1= -ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do @@ -1025,7 +1417,7 @@ -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in @@ -1047,9 +1439,7 @@ -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " + ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done @@ -1060,8 +1450,8 @@ # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { @@ -1074,20 +1464,34 @@ _ASBOX echo # The following way of writing the cache mishandles newlines in values, -{ +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} + esac | + sort +) echo cat <<\_ASBOX @@ -1098,22 +1502,28 @@ echo for ac_var in $ac_subst_vars do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## +## ------------------- ## +## File substitutions. ## +## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo fi @@ -1125,26 +1535,24 @@ ## ----------- ## _ASBOX echo - sed "/^$/d" confdefs.h | sort + cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status - ' 0 +' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h +rm -f -r conftest* confdefs.h # Predefined preprocessor variables. @@ -1175,14 +1583,17 @@ # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" fi -for ac_site_file in $CONFIG_SITE; do +shift +for ac_site_file +do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} @@ -1198,8 +1609,8 @@ { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; esac fi else @@ -1211,12 +1622,11 @@ # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do +for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 @@ -1241,8 +1651,7 @@ # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1259,12 +1668,6 @@ { (exit 1); exit 1; }; } fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - @@ -1289,110 +1692,165 @@ +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu - ac_config_headers="$ac_config_headers fficonfig.h" +ac_config_headers="$ac_config_headers fficonfig.h" ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break - elif test -f $ac_dir/install.sh; then + elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break - elif test -f $ac_dir/shtool; then + elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + # Make sure we can run config.sub. -$ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 -echo "$as_me: error: cannot run $ac_config_sub" >&2;} +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking build system type" >&5 -echo $ECHO_N "checking build system type... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_build_alias=$build_alias -test -z "$ac_cv_build_alias" && - ac_cv_build_alias=`$ac_config_guess` -test -z "$ac_cv_build_alias" && + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } -ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi -echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac build=$ac_cv_build -build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -echo "$as_me:$LINENO: checking host system type" >&5 -echo $ECHO_N "checking host system type... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_host_alias=$host_alias -test -z "$ac_cv_host_alias" && - ac_cv_host_alias=$ac_cv_build_alias -ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } +fi fi -echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -echo "${ECHO_T}$ac_cv_host" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac host=$ac_cv_host -host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -echo "$as_me:$LINENO: checking target system type" >&5 -echo $ECHO_N "checking target system type... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6; } if test "${ac_cv_target+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_target_alias=$target_alias -test "x$ac_cv_target_alias" = "x" && - ac_cv_target_alias=$ac_cv_host_alias -ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} { (exit 1); exit 1; }; } +fi fi -echo "$as_me:$LINENO: result: $ac_cv_target" >&5 -echo "${ECHO_T}$ac_cv_target" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +echo "$as_me: error: invalid value of canonical target" >&2;} + { (exit 1); exit 1; }; };; +esac target=$ac_cv_target -target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. @@ -1413,8 +1871,8 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1427,32 +1885,34 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1465,36 +1925,51 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf at gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf at gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1507,74 +1982,34 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi + fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1588,7 +2023,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -1599,6 +2034,7 @@ fi done done +IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. @@ -1616,22 +2052,23 @@ fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1644,36 +2081,38 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1686,29 +2125,45 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$ac_ct_CC" && break done - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf at gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf at gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi fi fi @@ -1721,21 +2176,35 @@ { (exit 1); exit 1; }; } # Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 +echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } @@ -1760,47 +2229,77 @@ # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. break;; * ) break;; esac done +test "$ac_cv_exeext" = no && ac_cv_exeext= + else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -1812,19 +2311,21 @@ fi ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -1843,22 +2344,27 @@ fi fi fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then @@ -1869,9 +2375,8 @@ for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext break;; * ) break;; esac @@ -1885,14 +2390,14 @@ fi rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1912,14 +2417,20 @@ } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac @@ -1937,12 +2448,12 @@ rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1965,49 +2476,49 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_compiler_gnu=no + ac_compiler_gnu=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2023,37 +2534,118 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_prog_cc_g=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2069,12 +2661,12 @@ CFLAGS= fi fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_cc_stdc=no + ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2108,12 +2700,17 @@ /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get + as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ + that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2128,201 +2725,57 @@ return 0; } _ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest.err conftest.$ac_objext + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break done -rm -f conftest.$ac_ext conftest.$ac_objext +rm -f conftest.$ac_ext CC=$ac_save_CC fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2339,8 +2792,8 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -2374,24 +2827,22 @@ #endif Syntax error _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -2400,9 +2851,10 @@ # Broken: fails on valid input. continue fi + rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether non-existent headers + # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2412,24 +2864,22 @@ /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -2440,6 +2890,7 @@ ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done @@ -2457,8 +2908,8 @@ else ac_cv_prog_CPP=$CPP fi -echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6 +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do @@ -2481,24 +2932,22 @@ #endif Syntax error _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -2507,9 +2956,10 @@ # Broken: fails on valid input. continue fi + rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether non-existent headers + # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2519,24 +2969,22 @@ /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -2547,6 +2995,7 @@ ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done @@ -2569,23 +3018,170 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2609,34 +3205,31 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_header_stdc=no + ac_cv_header_stdc=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. @@ -2692,6 +3285,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include +#include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) @@ -2711,18 +3305,27 @@ for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); + return 2; + return 0; } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -2735,12 +3338,14 @@ ( exit $ac_status ) ac_cv_header_stdc=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + + fi fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF @@ -2763,9 +3368,9 @@ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -2779,37 +3384,35 @@ #include <$ac_header> _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_Header=no" + eval "$as_ac_Header=no" fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 @@ -2824,18 +3427,19 @@ for ac_header in sys/mman.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -2846,40 +3450,37 @@ #include <$ac_header> _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no + ac_header_compiler=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -2888,24 +3489,22 @@ /* end confdefs.h. */ #include <$ac_header> _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -2913,9 +3512,10 @@ ac_header_preproc=no fi + rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -2939,25 +3539,24 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX + ( cat <<\_ASBOX ## ------------------------------------------- ## ## Report this to http://gcc.gnu.org/bugs.html ## ## ------------------------------------------- ## _ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then @@ -2973,9 +3572,9 @@ for ac_func in mmap do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -3001,67 +3600,60 @@ #undef $ac_func -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" -{ #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +#if defined __stub_$ac_func || defined __stub___$ac_func choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} #endif int main () { -return f != $ac_func; +return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" + eval "$as_ac_var=no" fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 @@ -3072,17 +3664,17 @@ if test "${ac_cv_header_sys_mman_h+set}" = set; then - echo "$as_me:$LINENO: checking for sys/mman.h" >&5 -echo $ECHO_N "checking for sys/mman.h... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for sys/mman.h" >&5 +echo $ECHO_N "checking for sys/mman.h... $ECHO_C" >&6; } if test "${ac_cv_header_sys_mman_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -echo "$as_me:$LINENO: result: $ac_cv_header_sys_mman_h" >&5 -echo "${ECHO_T}$ac_cv_header_sys_mman_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_mman_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_mman_h" >&6; } else # Is the header compilable? -echo "$as_me:$LINENO: checking sys/mman.h usability" >&5 -echo $ECHO_N "checking sys/mman.h usability... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking sys/mman.h usability" >&5 +echo $ECHO_N "checking sys/mman.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3093,40 +3685,37 @@ #include _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no + ac_header_compiler=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -echo "$as_me:$LINENO: checking sys/mman.h presence" >&5 -echo $ECHO_N "checking sys/mman.h presence... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking sys/mman.h presence" >&5 +echo $ECHO_N "checking sys/mman.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3135,24 +3724,22 @@ /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -3160,9 +3747,10 @@ ac_header_preproc=no fi + rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -3186,25 +3774,23 @@ echo "$as_me: WARNING: sys/mman.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: sys/mman.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: sys/mman.h: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX + ( cat <<\_ASBOX ## ------------------------------------------- ## ## Report this to http://gcc.gnu.org/bugs.html ## ## ------------------------------------------- ## _ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac -echo "$as_me:$LINENO: checking for sys/mman.h" >&5 -echo $ECHO_N "checking for sys/mman.h... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for sys/mman.h" >&5 +echo $ECHO_N "checking for sys/mman.h... $ECHO_C" >&6; } if test "${ac_cv_header_sys_mman_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_sys_mman_h=$ac_header_preproc fi -echo "$as_me:$LINENO: result: $ac_cv_header_sys_mman_h" >&5 -echo "${ECHO_T}$ac_cv_header_sys_mman_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_mman_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_mman_h" >&6; } fi if test $ac_cv_header_sys_mman_h = yes; then @@ -3214,8 +3800,8 @@ fi -echo "$as_me:$LINENO: checking for mmap" >&5 -echo $ECHO_N "checking for mmap... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for mmap" >&5 +echo $ECHO_N "checking for mmap... $ECHO_C" >&6; } if test "${ac_cv_func_mmap+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3242,67 +3828,59 @@ #undef mmap -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" -{ #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char mmap (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_mmap) || defined (__stub___mmap) +#if defined __stub_mmap || defined __stub___mmap choke me -#else -char (*f) () = mmap; -#endif -#ifdef __cplusplus -} #endif int main () { -return f != mmap; +return mmap (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func_mmap=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_mmap=no + ac_cv_func_mmap=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_mmap" >&5 -echo "${ECHO_T}$ac_cv_func_mmap" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap" >&5 +echo "${ECHO_T}$ac_cv_func_mmap" >&6; } if test $ac_cv_func_mmap = yes; then libffi_func_mmap=yes else @@ -3315,8 +3893,8 @@ ac_cv_func_mmap_dev_zero=no ac_cv_func_mmap_anon=no else - echo "$as_me:$LINENO: checking whether read-only mmap of a plain file works" >&5 -echo $ECHO_N "checking whether read-only mmap of a plain file works... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking whether read-only mmap of a plain file works" >&5 +echo $ECHO_N "checking whether read-only mmap of a plain file works... $ECHO_C" >&6; } if test "${ac_cv_func_mmap_file+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3332,10 +3910,10 @@ ac_cv_func_mmap_file=yes;; esac fi -echo "$as_me:$LINENO: result: $ac_cv_func_mmap_file" >&5 -echo "${ECHO_T}$ac_cv_func_mmap_file" >&6 - echo "$as_me:$LINENO: checking whether mmap from /dev/zero works" >&5 -echo $ECHO_N "checking whether mmap from /dev/zero works... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap_file" >&5 +echo "${ECHO_T}$ac_cv_func_mmap_file" >&6; } + { echo "$as_me:$LINENO: checking whether mmap from /dev/zero works" >&5 +echo $ECHO_N "checking whether mmap from /dev/zero works... $ECHO_C" >&6; } if test "${ac_cv_func_mmap_dev_zero+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3356,12 +3934,12 @@ ac_cv_func_mmap_dev_zero=yes;; esac fi -echo "$as_me:$LINENO: result: $ac_cv_func_mmap_dev_zero" >&5 -echo "${ECHO_T}$ac_cv_func_mmap_dev_zero" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap_dev_zero" >&5 +echo "${ECHO_T}$ac_cv_func_mmap_dev_zero" >&6; } # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for. - echo "$as_me:$LINENO: checking for MAP_ANON(YMOUS)" >&5 -echo $ECHO_N "checking for MAP_ANON(YMOUS)... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for MAP_ANON(YMOUS)" >&5 +echo $ECHO_N "checking for MAP_ANON(YMOUS)... $ECHO_C" >&6; } if test "${ac_cv_decl_map_anon+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3388,43 +3966,40 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_decl_map_anon=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_decl_map_anon=no + ac_cv_decl_map_anon=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_decl_map_anon" >&5 -echo "${ECHO_T}$ac_cv_decl_map_anon" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_decl_map_anon" >&5 +echo "${ECHO_T}$ac_cv_decl_map_anon" >&6; } if test $ac_cv_decl_map_anon = no; then ac_cv_func_mmap_anon=no else - echo "$as_me:$LINENO: checking whether mmap with MAP_ANON(YMOUS) works" >&5 -echo $ECHO_N "checking whether mmap with MAP_ANON(YMOUS) works... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking whether mmap with MAP_ANON(YMOUS) works" >&5 +echo $ECHO_N "checking whether mmap with MAP_ANON(YMOUS) works... $ECHO_C" >&6; } if test "${ac_cv_func_mmap_anon+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3440,8 +4015,8 @@ ac_cv_func_mmap_anon=yes;; esac fi -echo "$as_me:$LINENO: result: $ac_cv_func_mmap_anon" >&5 -echo "${ECHO_T}$ac_cv_func_mmap_anon" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap_anon" >&5 +echo "${ECHO_T}$ac_cv_func_mmap_anon" >&6; } fi fi @@ -3536,8 +4111,8 @@ *) ;; esac -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3561,34 +4136,31 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_header_stdc=no + ac_cv_header_stdc=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. @@ -3644,6 +4216,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include +#include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) @@ -3663,18 +4236,27 @@ for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); + return 2; + return 0; } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -3687,12 +4269,14 @@ ( exit $ac_status ) ac_cv_header_stdc=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + + fi fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF @@ -3705,9 +4289,9 @@ for ac_func in memcpy do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -3733,67 +4317,60 @@ #undef $ac_func -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" -{ #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +#if defined __stub_$ac_func || defined __stub___$ac_func choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} #endif int main () { -return f != $ac_func; +return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" + eval "$as_ac_var=no" fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 @@ -3804,8 +4381,8 @@ # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! -echo "$as_me:$LINENO: checking for working alloca.h" >&5 -echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for working alloca.h" >&5 +echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6; } if test "${ac_cv_working_alloca_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3820,43 +4397,42 @@ main () { char *p = (char *) alloca (2 * sizeof (int)); + if (p) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_working_alloca_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_working_alloca_h=no + ac_cv_working_alloca_h=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 -echo "${ECHO_T}$ac_cv_working_alloca_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 +echo "${ECHO_T}$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then cat >>confdefs.h <<\_ACEOF @@ -3865,8 +4441,8 @@ fi -echo "$as_me:$LINENO: checking for alloca" >&5 -echo $ECHO_N "checking for alloca... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for alloca" >&5 +echo $ECHO_N "checking for alloca... $ECHO_C" >&6; } if test "${ac_cv_func_alloca_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3883,7 +4459,7 @@ # include # define alloca _alloca # else -# if HAVE_ALLOCA_H +# ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX @@ -3901,43 +4477,42 @@ main () { char *p = (char *) alloca (1); + if (p) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func_alloca_works=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_alloca_works=no + ac_cv_func_alloca_works=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 -echo "${ECHO_T}$ac_cv_func_alloca_works" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 +echo "${ECHO_T}$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then @@ -3951,15 +4526,15 @@ # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. -ALLOCA=alloca.$ac_objext +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext cat >>confdefs.h <<\_ACEOF #define C_ALLOCA 1 _ACEOF -echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 -echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 +echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6; } if test "${ac_cv_os_cray+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3969,7 +4544,7 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#if defined(CRAY) && ! defined(CRAY2) +#if defined CRAY && ! defined CRAY2 webecray #else wenotbecray @@ -3985,14 +4560,14 @@ rm -f conftest* fi -echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 -echo "${ECHO_T}$ac_cv_os_cray" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 +echo "${ECHO_T}$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -4018,67 +4593,60 @@ #undef $ac_func -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" -{ #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +#if defined __stub_$ac_func || defined __stub___$ac_func choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} #endif int main () { -return f != $ac_func; +return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" + eval "$as_ac_var=no" fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF @@ -4091,8 +4659,8 @@ done fi -echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 -echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 +echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6; } if test "${ac_cv_c_stack_direction+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4105,6 +4673,7 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default int find_stack_direction () { @@ -4122,17 +4691,26 @@ int main () { - exit (find_stack_direction () < 0); + return find_stack_direction () < 0; } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -4145,11 +4723,13 @@ ( exit $ac_status ) ac_cv_c_stack_direction=-1 fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + + fi -echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 -echo "${ECHO_T}$ac_cv_c_stack_direction" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 +echo "${ECHO_T}$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction @@ -4159,8 +4739,8 @@ fi -echo "$as_me:$LINENO: checking for double" >&5 -echo $ECHO_N "checking for double... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for double" >&5 +echo $ECHO_N "checking for double... $ECHO_C" >&6; } if test "${ac_cv_type_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4171,60 +4751,57 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default +typedef double ac__type_new_; int main () { -if ((double *) 0) +if ((ac__type_new_ *) 0) return 0; -if (sizeof (double)) +if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_double=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_double=no + ac_cv_type_double=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5 -echo "${ECHO_T}$ac_cv_type_double" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5 +echo "${ECHO_T}$ac_cv_type_double" >&6; } -echo "$as_me:$LINENO: checking size of double" >&5 -echo $ECHO_N "checking size of double... $ECHO_C" >&6 +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of double" >&5 +echo $ECHO_N "checking size of double... $ECHO_C" >&6; } if test "${ac_cv_sizeof_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_double" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -4234,10 +4811,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (double))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -4245,26 +4823,22 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -4274,10 +4848,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (double))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -4285,55 +4860,53 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (double))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -4341,26 +4914,22 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -4370,10 +4939,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (double))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -4381,49 +4951,48 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo= ac_hi= + ac_lo= ac_hi= fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` @@ -4434,10 +5003,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (double))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -4445,49 +5015,45 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo=`expr '(' $ac_mid ')' + 1` + ac_lo=`expr '(' $ac_mid ')' + 1` fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_double=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (double), 77 +'') if test "$ac_cv_type_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (double), 77 +echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_double=0 + fi ;; esac else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -echo "$as_me: error: internal error: not reached in cross-compile" >&2;} - { (exit 1); exit 1; }; } -else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4495,8 +5061,9 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (double)); } -unsigned long ulongval () { return (long) (sizeof (double)); } + typedef double ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -4505,35 +5072,44 @@ FILE *f = fopen ("conftest.val", "w"); if (! f) - exit (1); - if (((long) (sizeof (double))) < 0) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { - long i = longval (); - if (i != ((long) (sizeof (double)))) - exit (1); + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; fprintf (f, "%ld\n", i); } else { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (double)))) - exit (1); + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; fprintf (f, "%lu\n", i); } - exit (ferror (f) || fclose (f) != 0); + return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -4544,29 +5120,32 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (double), 77 +if test "$ac_cv_type_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (double), 77 +echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_double=0 + fi fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_double=0 -fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 -echo "${ECHO_T}$ac_cv_sizeof_double" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 +echo "${ECHO_T}$ac_cv_sizeof_double" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_DOUBLE $ac_cv_sizeof_double _ACEOF -echo "$as_me:$LINENO: checking for long double" >&5 -echo $ECHO_N "checking for long double... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for long double" >&5 +echo $ECHO_N "checking for long double... $ECHO_C" >&6; } if test "${ac_cv_type_long_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4577,60 +5156,57 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default +typedef long double ac__type_new_; int main () { -if ((long double *) 0) +if ((ac__type_new_ *) 0) return 0; -if (sizeof (long double)) +if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_long_double=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_long_double=no + ac_cv_type_long_double=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_long_double" >&5 -echo "${ECHO_T}$ac_cv_type_long_double" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_type_long_double" >&5 +echo "${ECHO_T}$ac_cv_type_long_double" >&6; } -echo "$as_me:$LINENO: checking size of long double" >&5 -echo $ECHO_N "checking size of long double... $ECHO_C" >&6 +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of long double" >&5 +echo $ECHO_N "checking size of long double... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long_double" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -4640,10 +5216,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long double))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -4651,26 +5228,22 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -4680,10 +5253,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long double))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -4691,55 +5265,53 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long double))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -4747,26 +5319,22 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -4776,10 +5344,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long double))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -4787,49 +5356,48 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo= ac_hi= + ac_lo= ac_hi= fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` @@ -4840,10 +5408,11 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long double))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -4851,49 +5420,45 @@ } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo=`expr '(' $ac_mid ')' + 1` + ac_lo=`expr '(' $ac_mid ')' + 1` fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_long_double=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long double), 77 +'') if test "$ac_cv_type_long_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long double) See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long double), 77 +echo "$as_me: error: cannot compute sizeof (long double) See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long_double=0 + fi ;; esac else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -echo "$as_me: error: internal error: not reached in cross-compile" >&2;} - { (exit 1); exit 1; }; } -else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4901,8 +5466,9 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (long double)); } -unsigned long ulongval () { return (long) (sizeof (long double)); } + typedef long double ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -4911,35 +5477,44 @@ FILE *f = fopen ("conftest.val", "w"); if (! f) - exit (1); - if (((long) (sizeof (long double))) < 0) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { - long i = longval (); - if (i != ((long) (sizeof (long double)))) - exit (1); + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; fprintf (f, "%ld\n", i); } else { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (long double)))) - exit (1); + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; fprintf (f, "%lu\n", i); } - exit (ferror (f) || fclose (f) != 0); + return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -4950,22 +5525,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long double), 77 +if test "$ac_cv_type_long_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long double) See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long double), 77 +echo "$as_me: error: cannot compute sizeof (long double) See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long_double=0 + fi fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_long_double=0 -fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_double" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long_double" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_double" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long_double" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_DOUBLE $ac_cv_sizeof_long_double _ACEOF @@ -4986,171 +5564,163 @@ fi -echo "$as_me:$LINENO: checking for _Bool support" >&5 -echo $ECHO_N "checking for _Bool support... $ECHO_C" >&6 -have_c99_bool=no +{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +#include +#include int main () { -_Bool x; x = (_Bool)0; +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) + bogus endian macros +#endif + ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_C99_BOOL 1 -_ACEOF - - have_c99_bool=yes - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $have_c99_bool" >&5 -echo "${ECHO_T}$have_c99_bool" >&6 -if test "$have_c99_bool" = yes ; then -echo "$as_me:$LINENO: checking for _Bool" >&5 -echo $ECHO_N "checking for _Bool... $ECHO_C" >&6 -if test "${ac_cv_type__Bool+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +#include +#include + int main () { -if ((_Bool *) 0) - return 0; -if (sizeof (_Bool)) - return 0; +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type__Bool=yes + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type__Bool=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_c_bigendian=no fi -echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 -echo "${ECHO_T}$ac_cv_type__Bool" >&6 -echo "$as_me:$LINENO: checking size of _Bool" >&5 -echo $ECHO_N "checking size of _Bool... $ECHO_C" >&6 -if test "${ac_cv_sizeof__Bool+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else - if test "$ac_cv_type__Bool" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () { -static int test_array [1 - 2 * !(((long) (sizeof (_Bool))) >= 0)]; -test_array [0] = 0 - + _ascii (); _ebcdic (); ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -5160,652 +5730,200 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (_Bool))) <= $ac_mid)]; -test_array [0] = 0 + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=$ac_mid; break + ac_cv_c_bigendian=no else - echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` +( exit $ac_status ) +ac_cv_c_bigendian=yes fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 +_ACEOF + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + + + + + +if test x$TARGET = xSPARC; then + { echo "$as_me:$LINENO: checking assembler and linker support unaligned pc related relocs" >&5 +echo $ECHO_N "checking assembler and linker support unaligned pc related relocs... $ECHO_C" >&6; } +if test "${libffi_cv_as_sparc_ua_pcrel+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -cat >conftest.$ac_ext <<_ACEOF + save_CFLAGS="$CFLAGS" + save_LDFLAGS="$LDFLAGS" + CFLAGS="$CFLAGS -fpic" + LDFLAGS="$LDFLAGS -shared" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text"); int main () { -static int test_array [1 - 2 * !(((long) (sizeof (_Bool))) < 0)]; -test_array [0] = 0 ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + libffi_cv_as_sparc_ua_pcrel=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + libffi_cv_as_sparc_ua_pcrel=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$save_CFLAGS" + LDFLAGS="$save_LDFLAGS" +fi +{ echo "$as_me:$LINENO: result: $libffi_cv_as_sparc_ua_pcrel" >&5 +echo "${ECHO_T}$libffi_cv_as_sparc_ua_pcrel" >&6; } + if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_AS_SPARC_UA_PCREL 1 +_ACEOF + + fi + + { echo "$as_me:$LINENO: checking assembler .register pseudo-op support" >&5 +echo $ECHO_N "checking assembler .register pseudo-op support... $ECHO_C" >&6; } +if test "${libffi_cv_as_register_pseudo_op+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + libffi_cv_as_register_pseudo_op=unknown + # Check if we have .register + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +asm (".register %g2, #scratch"); int main () { -static int test_array [1 - 2 * !(((long) (sizeof (_Bool))) >= $ac_mid)]; -test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=$ac_mid; break + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + libffi_cv_as_register_pseudo_op=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` + libffi_cv_as_register_pseudo_op=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo= ac_hi= -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (_Bool))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo=`expr '(' $ac_mid ')' + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof__Bool=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (_Bool), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (_Bool), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; -esac -else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -echo "$as_me: error: internal error: not reached in cross-compile" >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -long longval () { return (long) (sizeof (_Bool)); } -unsigned long ulongval () { return (long) (sizeof (_Bool)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - exit (1); - if (((long) (sizeof (_Bool))) < 0) - { - long i = longval (); - if (i != ((long) (sizeof (_Bool)))) - exit (1); - fprintf (f, "%ld\n", i); - } - else - { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (_Bool)))) - exit (1); - fprintf (f, "%lu\n", i); - } - exit (ferror (f) || fclose (f) != 0); - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof__Bool=`cat conftest.val` -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (_Bool), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (_Bool), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -rm -f conftest.val -else - ac_cv_sizeof__Bool=0 -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof__Bool" >&5 -echo "${ECHO_T}$ac_cv_sizeof__Bool" >&6 -cat >>confdefs.h <<_ACEOF -#define SIZEOF__BOOL $ac_cv_sizeof__Bool -_ACEOF - - -fi - -echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 -if test "${ac_cv_c_bigendian+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # See if sys/param.h defines the BYTE_ORDER macro. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include - -int -main () -{ -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - # It does; now see whether it defined to BIG_ENDIAN or not. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include - -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_bigendian=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_c_bigendian=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -# It does not; compile a test program. -if test "$cross_compiling" = yes; then - # try to guess the endianness by grepping values into an object file - ac_cv_c_bigendian=unknown - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; -void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; -void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } -int -main () -{ - _ascii (); _ebcdic (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then - ac_cv_c_bigendian=yes -fi -if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi -fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -int -main () -{ - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long l; - char c[sizeof (long)]; - } u; - u.l = 1; - exit (u.c[sizeof (long) - 1] == 1); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_bigendian=no -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_bigendian=yes -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6 -case $ac_cv_c_bigendian in - yes) - -cat >>confdefs.h <<\_ACEOF -#define WORDS_BIGENDIAN 1 -_ACEOF - ;; - no) - ;; - *) - { { echo "$as_me:$LINENO: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&5 -echo "$as_me: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} - { (exit 1); exit 1; }; } ;; -esac - - - - - -if test x$TARGET = xSPARC; then - echo "$as_me:$LINENO: checking assembler and linker support unaligned pc related relocs" >&5 -echo $ECHO_N "checking assembler and linker support unaligned pc related relocs... $ECHO_C" >&6 -if test "${libffi_cv_as_sparc_ua_pcrel+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - save_CFLAGS="$CFLAGS" - save_LDFLAGS="$LDFLAGS" - CFLAGS="$CFLAGS -fpic" - LDFLAGS="$LDFLAGS -shared" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text"); -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - libffi_cv_as_sparc_ua_pcrel=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -libffi_cv_as_sparc_ua_pcrel=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - CFLAGS="$save_CFLAGS" - LDFLAGS="$save_LDFLAGS" -fi -echo "$as_me:$LINENO: result: $libffi_cv_as_sparc_ua_pcrel" >&5 -echo "${ECHO_T}$libffi_cv_as_sparc_ua_pcrel" >&6 - if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_AS_SPARC_UA_PCREL 1 -_ACEOF - - fi - - echo "$as_me:$LINENO: checking assembler .register pseudo-op support" >&5 -echo $ECHO_N "checking assembler .register pseudo-op support... $ECHO_C" >&6 -if test "${libffi_cv_as_register_pseudo_op+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - libffi_cv_as_register_pseudo_op=unknown - # Check if we have .register - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -asm (".register %g2, #scratch"); -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - libffi_cv_as_register_pseudo_op=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -libffi_cv_as_register_pseudo_op=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -echo "$as_me:$LINENO: result: $libffi_cv_as_register_pseudo_op" >&5 -echo "${ECHO_T}$libffi_cv_as_register_pseudo_op" >&6 +{ echo "$as_me:$LINENO: result: $libffi_cv_as_register_pseudo_op" >&5 +echo "${ECHO_T}$libffi_cv_as_register_pseudo_op" >&6; } if test "x$libffi_cv_as_register_pseudo_op" = xyes; then cat >>confdefs.h <<\_ACEOF @@ -5815,8 +5933,8 @@ fi fi -echo "$as_me:$LINENO: checking whether .eh_frame section should be read-only" >&5 -echo $ECHO_N "checking whether .eh_frame section should be read-only... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether .eh_frame section should be read-only" >&5 +echo $ECHO_N "checking whether .eh_frame section should be read-only... $ECHO_C" >&6; } if test "${libffi_cv_ro_eh_frame+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -5834,8 +5952,8 @@ rm -f conftest.* fi -echo "$as_me:$LINENO: result: $libffi_cv_ro_eh_frame" >&5 -echo "${ECHO_T}$libffi_cv_ro_eh_frame" >&6 +{ echo "$as_me:$LINENO: result: $libffi_cv_ro_eh_frame" >&5 +echo "${ECHO_T}$libffi_cv_ro_eh_frame" >&6; } if test "x$libffi_cv_ro_eh_frame" = xyes; then cat >>confdefs.h <<\_ACEOF @@ -5855,8 +5973,8 @@ fi -echo "$as_me:$LINENO: checking for __attribute__((visibility(\"hidden\")))" >&5 -echo $ECHO_N "checking for __attribute__((visibility(\"hidden\")))... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for __attribute__((visibility(\"hidden\")))" >&5 +echo $ECHO_N "checking for __attribute__((visibility(\"hidden\")))... $ECHO_C" >&6; } if test "${libffi_cv_hidden_visibility_attribute+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -5876,8 +5994,8 @@ rm -f conftest.* fi -echo "$as_me:$LINENO: result: $libffi_cv_hidden_visibility_attribute" >&5 -echo "${ECHO_T}$libffi_cv_hidden_visibility_attribute" >&6 +{ echo "$as_me:$LINENO: result: $libffi_cv_hidden_visibility_attribute" >&5 +echo "${ECHO_T}$libffi_cv_hidden_visibility_attribute" >&6; } if test $libffi_cv_hidden_visibility_attribute = yes; then cat >>confdefs.h <<\_ACEOF @@ -5901,9 +6019,9 @@ _ACEOF - ac_config_commands="$ac_config_commands include" +ac_config_commands="$ac_config_commands include" - ac_config_commands="$ac_config_commands src" +ac_config_commands="$ac_config_commands src" TARGETINCDIR=$TARGETDIR @@ -5914,12 +6032,12 @@ esac - ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" +ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" - ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h" +ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h" - ac_config_files="$ac_config_files include/ffi.h fficonfig.py" +ac_config_files="$ac_config_files include/ffi.h fficonfig.py" cat >confcache <<\_ACEOF @@ -5940,39 +6058,58 @@ # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. +# So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -{ +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; + ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} | + esac | + sort +) | sed ' + /^ac_cv_env_/b end t clear - : clear + :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - echo "not updating unwritable cache $cache_file" + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -5981,32 +6118,18 @@ # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -6037,17 +6160,45 @@ ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -6057,8 +6208,43 @@ fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -6072,18 +6258,19 @@ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -6091,159 +6278,120 @@ # Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi +# CDPATH. +$as_unset CDPATH - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -6252,7 +6400,28 @@ as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -6261,31 +6430,14 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - exec 6>&1 -# Open the log real soon, to keep \$[0] and so on meaningful, and to +# Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - +# values after options handling. +ac_log=" This file was extended by libffi $as_me 2.1, which was -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -6293,30 +6445,21 @@ CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + _ACEOF +cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_links="$ac_config_links" +config_commands="$ac_config_commands" -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi +_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF - ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. @@ -6324,7 +6467,7 @@ Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number, then exit + -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions @@ -6346,18 +6489,20 @@ $config_commands Report bugs to ." -_ACEOF +_ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ libffi config.status 2.1 -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir + +ac_pwd='$ac_pwd' +srcdir='$srcdir' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -6368,39 +6513,24 @@ do case $1 in --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; - -*) + *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; esac case $ac_option in # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift @@ -6410,18 +6540,24 @@ $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; - *) ac_config_targets="$ac_config_targets $1" ;; + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; esac shift @@ -6437,41 +6573,53 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 +_ACEOF cat >>$CONFIG_STATUS <<_ACEOF # -# INIT-COMMANDS section. +# INIT-COMMANDS # - TARGETDIR="$TARGETDIR" _ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. for ac_config_target in $ac_config_targets do - case "$ac_config_target" in - # Handling of arguments. - "include/ffi.h" ) CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;; - "fficonfig.py" ) CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; - "include/ffitarget.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ;; - "include/ffi_common.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; - "include" ) CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;; - "src" ) CONFIG_COMMANDS="$CONFIG_COMMANDS src" ;; - "fficonfig.h" ) CONFIG_HEADERS="$CONFIG_HEADERS fficonfig.h" ;; + case $ac_config_target in + "fficonfig.h") CONFIG_HEADERS="$CONFIG_HEADERS fficonfig.h" ;; + "include") CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;; + "src") CONFIG_COMMANDS="$CONFIG_COMMANDS src" ;; + "include/ffitarget.h") CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ;; + "include/ffi_common.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; + "include/ffi.h") CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;; + "fficonfig.py") CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done + # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely @@ -6484,308 +6632,376 @@ fi # Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, +# simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. $debug || { - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } - # Create a (secure) tmp directory for tmp files. { - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - # -# CONFIG_FILES section. +# Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s, at SHELL@,$SHELL,;t t -s, at PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s, at PACKAGE_NAME@,$PACKAGE_NAME,;t t -s, at PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s, at PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s, at PACKAGE_STRING@,$PACKAGE_STRING,;t t -s, at PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s, at exec_prefix@,$exec_prefix,;t t -s, at prefix@,$prefix,;t t -s, at program_transform_name@,$program_transform_name,;t t -s, at bindir@,$bindir,;t t -s, at sbindir@,$sbindir,;t t -s, at libexecdir@,$libexecdir,;t t -s, at datadir@,$datadir,;t t -s, at sysconfdir@,$sysconfdir,;t t -s, at sharedstatedir@,$sharedstatedir,;t t -s, at localstatedir@,$localstatedir,;t t -s, at libdir@,$libdir,;t t -s, at includedir@,$includedir,;t t -s, at oldincludedir@,$oldincludedir,;t t -s, at infodir@,$infodir,;t t -s, at mandir@,$mandir,;t t -s, at build_alias@,$build_alias,;t t -s, at host_alias@,$host_alias,;t t -s, at target_alias@,$target_alias,;t t -s, at DEFS@,$DEFS,;t t -s, at ECHO_C@,$ECHO_C,;t t -s, at ECHO_N@,$ECHO_N,;t t -s, at ECHO_T@,$ECHO_T,;t t -s, at LIBS@,$LIBS,;t t -s, at build@,$build,;t t -s, at build_cpu@,$build_cpu,;t t -s, at build_vendor@,$build_vendor,;t t -s, at build_os@,$build_os,;t t -s, at host@,$host,;t t -s, at host_cpu@,$host_cpu,;t t -s, at host_vendor@,$host_vendor,;t t -s, at host_os@,$host_os,;t t -s, at target@,$target,;t t -s, at target_cpu@,$target_cpu,;t t -s, at target_vendor@,$target_vendor,;t t -s, at target_os@,$target_os,;t t -s, at CC@,$CC,;t t -s, at ac_ct_CC@,$ac_ct_CC,;t t -s, at EXEEXT@,$EXEEXT,;t t -s, at OBJEXT@,$OBJEXT,;t t -s, at CFLAGS@,$CFLAGS,;t t -s, at CPP@,$CPP,;t t -s, at CPPFLAGS@,$CPPFLAGS,;t t -s, at EGREP@,$EGREP,;t t -s, at ALLOCA@,$ALLOCA,;t t -s, at HAVE_LONG_DOUBLE@,$HAVE_LONG_DOUBLE,;t t -s, at TARGET@,$TARGET,;t t -s, at TARGETDIR@,$TARGETDIR,;t t -s, at MKTARGET@,$MKTARGET,;t t -s, at LIBOBJS@,$LIBOBJS,;t t -s, at LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF - -_ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +target!$target$ac_delim +target_cpu!$target_cpu$ac_delim +target_vendor!$target_vendor$ac_delim +target_os!$target_os$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +ALLOCA!$ALLOCA$ac_delim +HAVE_LONG_DOUBLE!$HAVE_LONG_DOUBLE$ac_delim +TARGET!$TARGET$ac_delim +TARGETDIR!$TARGETDIR$ac_delim +MKTARGET!$MKTARGET$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 66; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi -fi # test -n "$CONFIG_FILES" +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :L $CONFIG_LINKS :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; esac - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || + ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } - ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + case $ac_mode in + :F) + # + # CONFIG_FILE + # - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } +_ACEOF - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac _ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub @@ -6793,511 +7009,173 @@ cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s, at configure_input@,$configure_input,;t t -s, at srcdir@,$ac_srcdir,;t t -s, at abs_srcdir@,$ac_abs_srcdir,;t t -s, at top_srcdir@,$ac_top_srcdir,;t t -s, at abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s, at builddir@,$ac_builddir,;t t -s, at abs_builddir@,$ac_abs_builddir,;t t -s, at top_builddir@,$ac_top_builddir,;t t -s, at abs_top_builddir@,$ac_abs_top_builddir,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_HEADER section. -# - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='[ ].*$,\1#\2' -ac_dC=' ' -ac_dD=',;t' -# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='$,\1#\2define\3' -ac_uC=' ' -ac_uD=',;t' +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} -for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + rm -f "$tmp/stdin" case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac + ;; + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' - test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - # Do quote $f, to prevent DOS paths from being IFS'd. - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - # Remove the trailing spaces. - sed 's/[ ]*$//' $ac_file_inputs >$tmp/in - -_ACEOF - -# Transform confdefs.h into two sed scripts, `conftest.defines' and -# `conftest.undefs', that substitutes the proper values into -# config.h.in to produce config.h. The first handles `#define' -# templates, and the second `#undef' templates. -# And first: Protect against being on the right side of a sed subst in -# config.status. Protect against being in an unquoted here document -# in config.status. -rm -f conftest.defines conftest.undefs -# Using a here document instead of a string reduces the quoting nightmare. -# Putting comments in sed scripts is not portable. -# -# `end' is used to avoid that the second main sed command (meant for -# 0-ary CPP macros) applies to n-ary macro definitions. -# See the Autoconf documentation for `clear'. -cat >confdef2sed.sed <<\_ACEOF -s/[\\&,]/\\&/g -s,[\\$`],\\&,g -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp -t end -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp -: end -_ACEOF -# If some macros were called several times there might be several times -# the same #defines, which is useless. Nevertheless, we may not want to -# sort them, since we want the *last* AC-DEFINE to be honored. -uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines -sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs -rm -f confdef2sed.sed +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines -# This sed command replaces #undef with comments. This is necessary, for +# Remove the space that was appended to ease matching. +# Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. -cat >>conftest.undefs <<\_ACEOF -s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, -_ACEOF +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' -# Break up conftest.defines because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS -echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS -echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS -echo ' :' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.defines >/dev/null +while : do - # Write a limited-size here document to $tmp/defines.sed. - echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#define' lines. - echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF - sed -f $tmp/defines.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done -rm -f conftest.defines -echo ' fi # grep' >>$CONFIG_STATUS -echo >>$CONFIG_STATUS - -# Break up conftest.undefs because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #undef templates' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.undefs >/dev/null -do - # Write a limited-size here document to $tmp/undefs.sed. - echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#undef' - echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/undefs.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail - rm -f conftest.undefs - mv conftest.tail conftest.undefs -done -rm -f conftest.undefs +rm -f conftest.defines conftest.tail +echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - echo "/* Generated by configure. */" >$tmp/config.h - else - echo "/* $ac_file. Generated by configure. */" >$tmp/config.h - fi - cat $tmp/in >>$tmp/config.h - rm -f $tmp/in if test x"$ac_file" != x-; then - if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - rm -f $ac_file - mv $tmp/config.h $ac_file + mv "$tmp/config.h" $ac_file fi else - cat $tmp/config.h - rm -f $tmp/config.h + echo "/* $configure_input */" + cat "$ac_result" fi -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_LINKS section. -# - -for ac_file in : $CONFIG_LINKS; do test "x$ac_file" = x: && continue - ac_dest=`echo "$ac_file" | sed 's,:.*,,'` - ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + rm -f "$tmp/out12" + ;; + :L) + # + # CONFIG_LINK + # - { echo "$as_me:$LINENO: linking $srcdir/$ac_source to $ac_dest" >&5 -echo "$as_me: linking $srcdir/$ac_source to $ac_dest" >&6;} + { echo "$as_me:$LINENO: linking $srcdir/$ac_source to $ac_file" >&5 +echo "$as_me: linking $srcdir/$ac_source to $ac_file" >&6;} - if test ! -r $srcdir/$ac_source; then + if test ! -r "$srcdir/$ac_source"; then { { echo "$as_me:$LINENO: error: $srcdir/$ac_source: file not found" >&5 echo "$as_me: error: $srcdir/$ac_source: file not found" >&2;} { (exit 1); exit 1; }; } fi - rm -f $ac_dest - - # Make relative symlinks. - ac_dest_dir=`(dirname "$ac_dest") 2>/dev/null || -$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_dest" : 'X\(//\)[^/]' \| \ - X"$ac_dest" : 'X\(//\)$' \| \ - X"$ac_dest" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_dest" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dest_dir" - else - as_dir="$ac_dest_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dest_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dest_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dest_dir" != .; then - ac_dir_suffix=/`echo "$ac_dest_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dest_dir";; -*) - case "$ac_dest_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dest_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dest_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - + rm -f "$ac_file" + # Try a relative symlink, then a hard link, then a copy. case $srcdir in [\\/$]* | ?:[\\/]* ) ac_rel_source=$srcdir/$ac_source ;; - *) ac_rel_source=$ac_top_builddir$srcdir/$ac_source ;; + *) ac_rel_source=$ac_top_build_prefix$srcdir/$ac_source ;; esac - - # Try a symlink, then a hard link, then a copy. - ln -s $ac_rel_source $ac_dest 2>/dev/null || - ln $srcdir/$ac_source $ac_dest 2>/dev/null || - cp -p $srcdir/$ac_source $ac_dest || - { { echo "$as_me:$LINENO: error: cannot link or copy $srcdir/$ac_source to $ac_dest" >&5 -echo "$as_me: error: cannot link or copy $srcdir/$ac_source to $ac_dest" >&2;} + ln -s "$ac_rel_source" "$ac_file" 2>/dev/null || + ln "$srcdir/$ac_source" "$ac_file" 2>/dev/null || + cp -p "$srcdir/$ac_source" "$ac_file" || + { { echo "$as_me:$LINENO: error: cannot link or copy $srcdir/$ac_source to $ac_file" >&5 +echo "$as_me: error: cannot link or copy $srcdir/$ac_source to $ac_file" >&2;} { (exit 1); exit 1; }; } -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_COMMANDS section. -# -for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue - ac_dest=`echo "$ac_file" | sed 's,:.*,,'` - ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_dir=`(dirname "$ac_dest") 2>/dev/null || -$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_dest" : 'X\(//\)[^/]' \| \ - X"$ac_dest" : 'X\(//\)$' \| \ - X"$ac_dest" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_dest" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac + ;; + :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac - { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 -echo "$as_me: executing $ac_dest commands" >&6;} - case $ac_dest in - include ) test -d include || mkdir include ;; - src ) + case $ac_file$ac_mode in + "include":C) test -d include || mkdir include ;; + "src":C) test -d src || mkdir src test -d src/$TARGETDIR || mkdir src/$TARGETDIR ;; + esac -done -_ACEOF +done # for ac_tag -cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF Modified: python/branches/py3k/Modules/_ctypes/libffi/configure.ac ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/configure.ac (original) +++ python/branches/py3k/Modules/_ctypes/libffi/configure.ac Fri Feb 22 17:37:40 2008 @@ -106,17 +106,6 @@ fi AC_SUBST(HAVE_LONG_DOUBLE) -AC_MSG_CHECKING(for _Bool support) -have_c99_bool=no -AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [ - AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) - have_c99_bool=yes -]) -AC_MSG_RESULT($have_c99_bool) -if test "$have_c99_bool" = yes ; then -AC_CHECK_SIZEOF(_Bool, 1) -fi - AC_C_BIGENDIAN AH_VERBATIM([WORDS_BIGENDIAN], [ Modified: python/branches/py3k/Modules/_ctypes/libffi/fficonfig.h.in ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/fficonfig.h.in (original) +++ python/branches/py3k/Modules/_ctypes/libffi/fficonfig.h.in Fri Feb 22 17:37:40 2008 @@ -28,9 +28,6 @@ */ #undef HAVE_AS_SPARC_UA_PCREL -/* Define this if you have the type _Bool. */ -#undef HAVE_C99_BOOL - /* Define if __attribute__((visibility("hidden"))) is supported. */ #undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE @@ -100,18 +97,15 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* The size of a `double', as computed by sizeof. */ +/* The size of `double', as computed by sizeof. */ #undef SIZEOF_DOUBLE -/* The size of a `long double', as computed by sizeof. */ +/* The size of `long double', as computed by sizeof. */ #undef SIZEOF_LONG_DOUBLE -/* The size of a `_Bool', as computed by sizeof. */ -#undef SIZEOF__BOOL - /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. + automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Fri Feb 22 17:37:40 2008 @@ -1711,6 +1711,216 @@ }; +/* product object ************************************************************/ + +typedef struct { + PyObject_HEAD + PyObject *pools; /* tuple of pool tuples */ + Py_ssize_t *maxvec; + Py_ssize_t *indices; + PyObject *result; + int stopped; +} productobject; + +static PyTypeObject product_type; + +static PyObject * +product_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + productobject *lz; + Py_ssize_t npools; + PyObject *pools = NULL; + Py_ssize_t *maxvec = NULL; + Py_ssize_t *indices = NULL; + Py_ssize_t i; + + if (type == &product_type && !_PyArg_NoKeywords("product()", kwds)) + return NULL; + + assert(PyTuple_Check(args)); + npools = PyTuple_GET_SIZE(args); + + maxvec = PyMem_Malloc(npools * sizeof(Py_ssize_t)); + indices = PyMem_Malloc(npools * sizeof(Py_ssize_t)); + if (maxvec == NULL || indices == NULL) { + PyErr_NoMemory(); + goto error; + } + + pools = PyTuple_New(npools); + if (pools == NULL) + goto error; + + for (i=0; i < npools; ++i) { + PyObject *item = PyTuple_GET_ITEM(args, i); + PyObject *pool = PySequence_Tuple(item); + if (pool == NULL) + goto error; + + PyTuple_SET_ITEM(pools, i, pool); + maxvec[i] = PyTuple_GET_SIZE(pool); + indices[i] = 0; + } + + /* create productobject structure */ + lz = (productobject *)type->tp_alloc(type, 0); + if (lz == NULL) { + Py_DECREF(pools); + return NULL; + } + + lz->pools = pools; + lz->maxvec = maxvec; + lz->indices = indices; + lz->result = NULL; + lz->stopped = 0; + + return (PyObject *)lz; + +error: + if (maxvec != NULL) + PyMem_Free(maxvec); + if (indices != NULL) + PyMem_Free(indices); + Py_XDECREF(pools); + return NULL; +} + +static void +product_dealloc(productobject *lz) +{ + PyObject_GC_UnTrack(lz); + Py_XDECREF(lz->pools); + Py_XDECREF(lz->result); + PyMem_Free(lz->maxvec); + PyMem_Free(lz->indices); + Py_TYPE(lz)->tp_free(lz); +} + +static int +product_traverse(productobject *lz, visitproc visit, void *arg) +{ + Py_VISIT(lz->pools); + Py_VISIT(lz->result); + return 0; +} + +static PyObject * +product_next(productobject *lz) +{ + PyObject *pool; + PyObject *elem; + PyObject *tuple_result; + PyObject *pools = lz->pools; + PyObject *result = lz->result; + Py_ssize_t npools = PyTuple_GET_SIZE(pools); + Py_ssize_t i; + + if (lz->stopped) + return NULL; + if (result == NULL) { + if (npools == 0) + goto empty; + result = PyList_New(npools); + if (result == NULL) + goto empty; + lz->result = result; + for (i=0; i < npools; i++) { + pool = PyTuple_GET_ITEM(pools, i); + if (PyTuple_GET_SIZE(pool) == 0) + goto empty; + elem = PyTuple_GET_ITEM(pool, 0); + Py_INCREF(elem); + PyList_SET_ITEM(result, i, elem); + } + } else { + Py_ssize_t *indices = lz->indices; + Py_ssize_t *maxvec = lz->maxvec; + for (i=npools-1 ; i >= 0 ; i--) { + pool = PyTuple_GET_ITEM(pools, i); + indices[i]++; + if (indices[i] == maxvec[i]) { + indices[i] = 0; + elem = PyTuple_GET_ITEM(pool, 0); + Py_INCREF(elem); + PyList_SetItem(result, i, elem); + } else { + elem = PyTuple_GET_ITEM(pool, indices[i]); + Py_INCREF(elem); + PyList_SetItem(result, i, elem); + break; + } + } + if (i < 0) + return NULL; + } + + tuple_result = PySequence_Tuple(result); + if (tuple_result == NULL) + lz->stopped = 1; + return tuple_result; + +empty: + lz->stopped = 1; + return NULL; +} + +PyDoc_STRVAR(product_doc, +"product(*iterables) --> product object\n\ +\n\ +Cartesian product of input interables. Equivalent to nested for-loops.\n\n\ +For example, product(A, B) returns the same as: ((x,y) for x in A for y in B).\n\ +The leftmost iterators are in the outermost for-loop, so the output tuples\n\ +cycle in a manner similar to an odometer (with the rightmost element changing\n\ +on every iteration).\n\n\ +product('ab', range(3)) --> ('a',0) ('a',1) ('a',2) ('b',0) ('b',1) ('b',2)\n\ +product((0,1), (0,1), (0,1)) --> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ..."); + +static PyTypeObject product_type = { + PyVarObject_HEAD_INIT(NULL, 0) + "itertools.product", /* tp_name */ + sizeof(productobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)product_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + product_doc, /* tp_doc */ + (traverseproc)product_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)product_next, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + product_new, /* tp_new */ + PyObject_GC_Del, /* tp_free */ +}; + + /* ifilter object ************************************************************/ typedef struct { @@ -2748,7 +2958,8 @@ &ifilterfalse_type, &count_type, &izip_type, - &iziplongest_type, + &iziplongest_type, + &product_type, &repeat_type, &groupby_type, NULL Modified: python/branches/py3k/Objects/stringlib/formatter.h ============================================================================== --- python/branches/py3k/Objects/stringlib/formatter.h (original) +++ python/branches/py3k/Objects/stringlib/formatter.h Fri Feb 22 17:37:40 2008 @@ -130,16 +130,16 @@ } else if (end-ptr >= 1 && is_alignment_token(ptr[0])) { format->align = ptr[0]; - ptr++; + ++ptr; } /* Parse the various sign options */ if (end-ptr >= 1 && is_sign_element(ptr[0])) { format->sign = ptr[0]; - ptr++; + ++ptr; #if ALLOW_PARENS_FOR_SIGN if (end-ptr >= 1 && ptr[0] == ')') { - ptr++; + ++ptr; } #endif } @@ -150,7 +150,7 @@ if (format->align == '\0') { format->align = '='; } - ptr++; + ++ptr; } /* XXX add error checking */ @@ -165,7 +165,7 @@ /* Parse field precision */ if (end-ptr && ptr[0] == '.') { - ptr++; + ++ptr; /* XXX add error checking */ specified_width = get_integer(&ptr, end, &format->precision); @@ -189,7 +189,7 @@ if (end-ptr == 1) { format->type = ptr[0]; - ptr++; + ++ptr; } return 1; @@ -570,7 +570,7 @@ /* if X, convert to uppercase */ if (format->type == 'X') { Py_ssize_t t; - for (t = 0; t < n_digits; t++) + for (t = 0; t < n_digits; ++t) p[t + n_leading_chars] = STRINGLIB_TOUPPER(p[t + n_leading_chars]); } @@ -596,37 +596,20 @@ { register Py_ssize_t i; Py_ssize_t len = strlen(charbuffer); - for (i = len - 1; i >= 0; i--) + for (i = len - 1; i >= 0; --i) buffer[i] = (Py_UNICODE) charbuffer[i]; return len; } #endif -/* the callback function to call to do the actual float formatting. - it matches the definition of PyOS_ascii_formatd */ -typedef char* -(*DoubleSnprintfFunction)(char *buffer, size_t buf_len, - const char *format, double d); - -/* just a wrapper to make PyOS_snprintf look like DoubleSnprintfFunction */ -static char* -snprintf_double(char *buffer, size_t buf_len, const char *format, double d) -{ - PyOS_snprintf(buffer, buf_len, format, d); - return NULL; -} - /* see FORMATBUFLEN in unicodeobject.c */ #define FLOAT_FORMATBUFLEN 120 /* much of this is taken from unicodeobject.c */ -/* use type instead of format->type, so that it can be overridden by - format_number() */ static PyObject * -_format_float(STRINGLIB_CHAR type, PyObject *value, - const InternalFormatSpec *format, - DoubleSnprintfFunction snprintf) +format_float_internal(PyObject *value, + const InternalFormatSpec *format) { /* fmt = '%.' + `prec` + `type` + '%%' worst case length = 2 + 10 (len of INT_MAX) + 1 + 2 = 15 (use 20)*/ @@ -658,6 +641,7 @@ char* trailing = ""; STRINGLIB_CHAR *p; NumberFieldWidths spec; + STRINGLIB_CHAR type = format->type; #if STRINGLIB_IS_UNICODE Py_UNICODE unicodebuf[FLOAT_FORMATBUFLEN]; @@ -692,8 +676,8 @@ PyOS_snprintf(fmt, sizeof(fmt), "%%.%" PY_FORMAT_SIZE_T "d%c", precision, (char)type); - /* call the passed in function to do the actual formatting */ - snprintf(charbuf, sizeof(charbuf), fmt, x); + /* do the actual formatting */ + PyOS_ascii_formatd(charbuf, sizeof(charbuf), fmt, x); /* adding trailing to fmt with PyOS_snprintf doesn't work, not sure why. we'll just concatentate it here, no harm done. we @@ -719,8 +703,8 @@ and skip it */ sign = p[0]; if (sign == '-') { - p++; - n_digits--; + ++p; + --n_digits; } calc_number_widths(&spec, sign, n_digits, format); @@ -743,15 +727,6 @@ done: return result; } - -static PyObject * -format_float_internal(PyObject *value, const InternalFormatSpec *format) -{ - if (format->type == 'n') - return _format_float('f', value, format, snprintf_double); - else - return _format_float(format->type, value, format, PyOS_ascii_formatd); -} #endif /* FORMAT_FLOAT */ /************************************************************************/ Modified: python/branches/py3k/Python/pystrtod.c ============================================================================== --- python/branches/py3k/Python/pystrtod.c (original) +++ python/branches/py3k/Python/pystrtod.c Fri Feb 22 17:37:40 2008 @@ -186,6 +186,15 @@ } +/* From the C99 standard, section 7.19.6: +The exponent always contains at least two digits, and only as many more digits +as necessary to represent the exponent. +*/ +#define MIN_EXPONENT_DIGITS 2 + +/* see FORMATBUFLEN in unicodeobject.c */ +#define FLOAT_FORMATBUFLEN 120 + /** * PyOS_ascii_formatd: * @buffer: A buffer to place the resulting string in @@ -197,8 +206,10 @@ * Converts a #gdouble to a string, using the '.' as * decimal point. To format the number you pass in * a printf()-style format string. Allowed conversion - * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'. + * specifiers are 'e', 'E', 'f', 'F', 'g', 'G', and 'n'. * + * 'n' is the same as 'g', except it uses the current locale. + * * Return value: The pointer to the buffer with the converted string. **/ char * @@ -207,17 +218,23 @@ const char *format, double d) { - struct lconv *locale_data; - const char *decimal_point; - size_t decimal_point_len, rest_len; char *p; char format_char; + size_t format_len = strlen(format); + + /* For type 'n', we need to make a copy of the format string, because + we're going to modify 'n' -> 'g', and format is const char*, so we + can't modify it directly. FLOAT_FORMATBUFLEN should be longer than + we ever need this to be. There's an upcoming check to ensure it's + big enough. */ + char tmp_format[FLOAT_FORMATBUFLEN]; /* g_return_val_if_fail (buffer != NULL, NULL); */ /* g_return_val_if_fail (format[0] == '%', NULL); */ /* g_return_val_if_fail (strpbrk (format + 1, "'l%") == NULL, NULL); */ - format_char = format[strlen(format) - 1]; + /* The last character in the format string must be the format char */ + format_char = format[format_len - 1]; /* g_return_val_if_fail (format_char == 'e' || format_char == 'E' || */ /* format_char == 'f' || format_char == 'F' || */ @@ -227,43 +244,126 @@ if (format[0] != '%') return NULL; + /* I'm not sure why this test is here. It's ensuring that the format + string after the first character doesn't have a single quote, a + lowercase l, or a percent. This is the reverse of the commented-out + test about 10 lines ago. */ if (strpbrk(format + 1, "'l%")) return NULL; if (!(format_char == 'e' || format_char == 'E' || format_char == 'f' || format_char == 'F' || - format_char == 'g' || format_char == 'G')) + format_char == 'g' || format_char == 'G' || + format_char == 'n')) return NULL; + /* Map 'n' format_char to 'g', by copying the format string and + replacing the final 'n' with a 'g' */ + if (format_char == 'n') { + if (format_len + 1 >= sizeof(tmp_format)) { + /* The format won't fit in our copy. Error out. In + practice, this will never happen and will be detected + by returning NULL */ + return NULL; + } + strcpy(tmp_format, format); + tmp_format[format_len - 1] = 'g'; + format = tmp_format; + } + /* Have PyOS_snprintf do the hard work */ PyOS_snprintf(buffer, buf_len, format, d); - locale_data = localeconv(); - decimal_point = locale_data->decimal_point; - decimal_point_len = strlen(decimal_point); - - assert(decimal_point_len != 0); - - if (decimal_point[0] != '.' || - decimal_point[1] != 0) - { - p = buffer; - - if (*p == '+' || *p == '-') - p++; - - while (isdigit((unsigned char)*p)) - p++; - - if (strncmp(p, decimal_point, decimal_point_len) == 0) - { - *p = '.'; - p++; - if (decimal_point_len > 1) { - rest_len = strlen(p + (decimal_point_len - 1)); - memmove(p, p + (decimal_point_len - 1), - rest_len); - p[rest_len] = 0; + /* Get the current local, and find the decimal point character (or + string?). Convert that string back to a dot. Do not do this if + using the 'n' (number) format code. */ + if (format_char != 'n') { + struct lconv *locale_data = localeconv(); + const char *decimal_point = locale_data->decimal_point; + size_t decimal_point_len = strlen(decimal_point); + size_t rest_len; + + assert(decimal_point_len != 0); + + if (decimal_point[0] != '.' || decimal_point[1] != 0) { + p = buffer; + + if (*p == '+' || *p == '-') + p++; + + while (isdigit(Py_CHARMASK(*p))) + p++; + + if (strncmp(p, decimal_point, decimal_point_len) == 0) { + *p = '.'; + p++; + if (decimal_point_len > 1) { + rest_len = strlen(p + + (decimal_point_len - 1)); + memmove(p, p + (decimal_point_len - 1), + rest_len); + p[rest_len] = 0; + } + } + } + } + + /* If an exponent exists, ensure that the exponent is at least + MIN_EXPONENT_DIGITS digits, providing the buffer is large enough + for the extra zeros. Also, if there are more than + MIN_EXPONENT_DIGITS, remove as many zeros as possible until we get + back to MIN_EXPONENT_DIGITS */ + p = strpbrk(buffer, "eE"); + if (p && (*(p + 1) == '-' || *(p + 1) == '+')) { + char *start = p + 2; + int exponent_digit_cnt = 0; + int leading_zero_cnt = 0; + int in_leading_zeros = 1; + int significant_digit_cnt; + + p += 2; + while (*p && isdigit(Py_CHARMASK(*p))) { + if (in_leading_zeros && *p == '0') + ++leading_zero_cnt; + if (*p != '0') + in_leading_zeros = 0; + ++p; + ++exponent_digit_cnt; + } + + significant_digit_cnt = exponent_digit_cnt - leading_zero_cnt; + if (exponent_digit_cnt == MIN_EXPONENT_DIGITS) { + /* If there are 2 exactly digits, we're done, + regardless of what they contain */ + } + else if (exponent_digit_cnt > MIN_EXPONENT_DIGITS) { + int extra_zeros_cnt; + + /* There are more than 2 digits in the exponent. See + if we can delete some of the leading zeros */ + if (significant_digit_cnt < MIN_EXPONENT_DIGITS) + significant_digit_cnt = MIN_EXPONENT_DIGITS; + extra_zeros_cnt = exponent_digit_cnt - significant_digit_cnt; + + /* Delete extra_zeros_cnt worth of characters from the + front of the exponent */ + assert(extra_zeros_cnt >= 0); + + /* Add one to significant_digit_cnt to copy the + trailing 0 byte, thus setting the length */ + memmove(start, + start + extra_zeros_cnt, + significant_digit_cnt + 1); + } + else { + /* If there are fewer than 2 digits, add zeros + until there are 2, if there's enough room */ + int zeros = MIN_EXPONENT_DIGITS - exponent_digit_cnt; + if (start + zeros + exponent_digit_cnt + 1 + < buffer + buf_len) { + memmove(start + zeros, start, + exponent_digit_cnt + 1); + memset(start, '0', zeros); } } } From python-3000-checkins at python.org Sat Feb 23 04:11:44 2008 From: python-3000-checkins at python.org (eric.smith) Date: Sat, 23 Feb 2008 04:11:44 +0100 (CET) Subject: [Python-3000-checkins] r60971 - python/branches/py3k Message-ID: <20080223031144.DD52B1E4002@bag.python.org> Author: eric.smith Date: Sat Feb 23 04:11:44 2008 New Revision: 60971 Modified: python/branches/py3k/ (props changed) Log: Blocked r60970 with svnmerge. From python-3000-checkins at python.org Sat Feb 23 14:18:04 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 23 Feb 2008 14:18:04 +0100 (CET) Subject: [Python-3000-checkins] r60977 - in python/branches/py3k: Doc/library/configparser.rst Doc/library/itertools.rst Lib/ConfigParser.py Lib/smtplib.py Lib/test/test_builtin.py Lib/test/test_cfgparser.py Lib/test/test_itertools.py Lib/test/test_parser.py Lib/test/test_smtplib.py Modules/itertoolsmodule.c Parser/parser.h Message-ID: <20080223131804.83FD21E4020@bag.python.org> Author: christian.heimes Date: Sat Feb 23 14:18:03 2008 New Revision: 60977 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/configparser.rst python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Lib/ConfigParser.py python/branches/py3k/Lib/smtplib.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_cfgparser.py python/branches/py3k/Lib/test/test_itertools.py python/branches/py3k/Lib/test/test_parser.py python/branches/py3k/Lib/test/test_smtplib.py python/branches/py3k/Modules/itertoolsmodule.c python/branches/py3k/Parser/parser.h Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900,60902-60906,60908,60911-60917,60919-60920,60922,60926,60929-60931,60933-60935,60937,60939-60941,60943-60954,60959-60961,60963-60969,60971-60976 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60965 | eric.smith | 2008-02-22 18:43:17 +0100 (Fri, 22 Feb 2008) | 1 line Tests for bin() builtin. These need to get merged into py3k, which has no tests for bin. ........ r60968 | raymond.hettinger | 2008-02-22 20:50:06 +0100 (Fri, 22 Feb 2008) | 1 line Document itertools.product(). ........ r60969 | raymond.hettinger | 2008-02-23 03:20:41 +0100 (Sat, 23 Feb 2008) | 9 lines Improve the implementation of itertools.product() * Fix-up issues pointed-out by Neal Norwitz. * Add extensive comments. * The lz->result variable is now a tuple instead of a list. * Use fast macro getitem/setitem calls so most code is in-line. * Re-use the result tuple if available (modify in-place instead of copy). ........ r60972 | raymond.hettinger | 2008-02-23 05:03:50 +0100 (Sat, 23 Feb 2008) | 1 line Add more comments ........ r60973 | raymond.hettinger | 2008-02-23 11:04:15 +0100 (Sat, 23 Feb 2008) | 1 line Add recipe using itertools.product(). ........ r60974 | facundo.batista | 2008-02-23 13:01:13 +0100 (Sat, 23 Feb 2008) | 6 lines Issue 1881. Increased the stack limit from 500 to 1500. Also added a test for this (and because of this test you'll see in stderr a message that parser.c sends before raising MemoryError). Thanks Ralf Schmitt. ........ r60975 | facundo.batista | 2008-02-23 13:27:17 +0100 (Sat, 23 Feb 2008) | 4 lines Issue 1776581. Minor corrections to smtplib, and two small tests. Thanks Alan McIntyre. ........ r60976 | facundo.batista | 2008-02-23 13:46:10 +0100 (Sat, 23 Feb 2008) | 5 lines Issue 1781. Now ConfigParser.add_section does not let you add a DEFAULT section any more, because it duplicated sections with the rest of the machinery. Thanks Tim Lesher and Manuel Kaufmann. ........ Modified: python/branches/py3k/Doc/library/configparser.rst ============================================================================== --- python/branches/py3k/Doc/library/configparser.rst (original) +++ python/branches/py3k/Doc/library/configparser.rst Sat Feb 23 14:18:03 2008 @@ -176,8 +176,9 @@ .. method:: RawConfigParser.add_section(section) Add a section named *section* to the instance. If a section by the given name - already exists, :exc:`DuplicateSectionError` is raised. - + already exists, :exc:`DuplicateSectionError` is raised. If the name + ``DEFAULT`` (or any of it's case-insensitive variants) is passed, + :exc:`ValueError` is raised. .. method:: RawConfigParser.has_section(section) Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Sat Feb 23 14:18:03 2008 @@ -289,6 +289,29 @@ example :func:`islice` or :func:`takewhile`). +.. function:: product(*iterables) + + Cartesian product of input iterables. + + Equivalent to nested for-loops in a generator expression. For example, + ``product(A, B)`` returns the same as ``((x,y) for x in A for y in B)``. + + The leftmost iterators are in the outermost for-loop, so the output tuples + cycle in a manner similar to an odometer (with the rightmost element + changing on every iteration). + + Equivalent to (but without building the entire result in memory):: + + def product(*args): + pools = map(tuple, args) + if pools: + result = [[]] + for pool in pools: + result = [x+[y] for x in result for y in pool] + for prod in result: + yield tuple(prod) + + .. function:: repeat(object[, times]) Make an iterator that returns *object* over and over again. Runs indefinitely @@ -526,3 +549,9 @@ pending -= 1 nexts = cycle(islice(nexts, pending)) + def powerset(iterable): + "powerset('ab') --> set([]), set(['b']), set(['a']), set(['a', 'b'])" + skip = object() + for t in product(*izip(repeat(skip), iterable)): + yield set(e for e in t if e is not skip) + Modified: python/branches/py3k/Lib/ConfigParser.py ============================================================================== --- python/branches/py3k/Lib/ConfigParser.py (original) +++ python/branches/py3k/Lib/ConfigParser.py Sat Feb 23 14:18:03 2008 @@ -235,8 +235,12 @@ """Create a new section in the configuration. Raise DuplicateSectionError if a section by the specified name - already exists. + already exists. Raise ValueError if name is DEFAULT or any of it's + case-insensitive variants. """ + if section.lower() == "default": + raise ValueError('Invalid section name: %s' % section) + if section in self._sections: raise DuplicateSectionError(section) self._sections[section] = self._dict() Modified: python/branches/py3k/Lib/smtplib.py ============================================================================== --- python/branches/py3k/Lib/smtplib.py (original) +++ python/branches/py3k/Lib/smtplib.py Sat Feb 23 14:18:03 2008 @@ -298,7 +298,7 @@ def send(self, s): """Send `s' to the server.""" if self.debuglevel > 0: print('send:', repr(s), file=stderr) - if self.sock: + if hasattr(self, 'sock') and self.sock: if isinstance(s, str): s = s.encode("ascii") try: @@ -489,7 +489,7 @@ vrfy=verify def expn(self, address): - """SMTP 'verify' command -- checks for address validity.""" + """SMTP 'expn' command -- expands a mailing list.""" self.putcmd("expn", quoteaddr(address)) return self.getreply() Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Sat Feb 23 14:18:03 2008 @@ -1829,6 +1829,15 @@ return i self.assertRaises(ValueError, list, zip(BadSeq(), BadSeq())) + def test_bin(self): + self.assertEqual(bin(0), '0b0') + self.assertEqual(bin(1), '0b1') + self.assertEqual(bin(-1), '-0b1') + self.assertEqual(bin(2**65), '0b1' + '0' * 65) + self.assertEqual(bin(2**65-1), '0b' + '1' * 65) + self.assertEqual(bin(-(2**65)), '-0b1' + '0' * 65) + self.assertEqual(bin(-(2**65-1)), '-0b' + '1' * 65) + class TestSorted(unittest.TestCase): def test_basic(self): Modified: python/branches/py3k/Lib/test/test_cfgparser.py ============================================================================== --- python/branches/py3k/Lib/test/test_cfgparser.py (original) +++ python/branches/py3k/Lib/test/test_cfgparser.py Sat Feb 23 14:18:03 2008 @@ -436,6 +436,14 @@ self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0) self.assertRaises(TypeError, cf.set, "sect", "option2", object()) + def test_add_section_default_1(self): + cf = self.newconfig() + self.assertRaises(ValueError, cf.add_section, "default") + + def test_add_section_default_2(self): + cf = self.newconfig() + self.assertRaises(ValueError, cf.add_section, "DEFAULT") + class SortedTestCase(RawConfigParserTestCase): def newconfig(self, defaults=None): self.cf = self.config_class(defaults=defaults, dict_type=SortedDict) Modified: python/branches/py3k/Lib/test/test_itertools.py ============================================================================== --- python/branches/py3k/Lib/test/test_itertools.py (original) +++ python/branches/py3k/Lib/test/test_itertools.py Sat Feb 23 14:18:03 2008 @@ -283,6 +283,9 @@ args = map(iter, args) self.assertEqual(len(list(product(*args))), n) + # Test implementation detail: tuple re-use + self.assertEqual(len(set(map(id, product('abc', 'def')))), 1) + self.assertNotEqual(len(set(map(id, list(product('abc', 'def'))))), 1) def test_repeat(self): self.assertEqual(lzip(range(3),repeat('a')), Modified: python/branches/py3k/Lib/test/test_parser.py ============================================================================== --- python/branches/py3k/Lib/test/test_parser.py (original) +++ python/branches/py3k/Lib/test/test_parser.py Sat Feb 23 14:18:03 2008 @@ -450,11 +450,29 @@ st = parser.suite('a = "\\u1"') self.assertRaises(SyntaxError, parser.compilest, st) +class ParserStackLimitTestCase(unittest.TestCase): + """try to push the parser to/over it's limits. + see http://bugs.python.org/issue1881 for a discussion + """ + def _nested_expression(self, level): + return "["*level+"]"*level + + def test_deeply_nested_list(self): + # XXX used to be 99 levels in 2.x + e = self._nested_expression(93) + st = parser.expr(e) + st.compile() + + def test_trigger_memory_error(self): + e = self._nested_expression(100) + self.assertRaises(MemoryError, parser.expr, e) + def test_main(): test_support.run_unittest( RoundtripLegalSyntaxTestCase, IllegalSyntaxTestCase, CompileTestCase, + ParserStackLimitTestCase, ) Modified: python/branches/py3k/Lib/test/test_smtplib.py ============================================================================== --- python/branches/py3k/Lib/test/test_smtplib.py (original) +++ python/branches/py3k/Lib/test/test_smtplib.py Sat Feb 23 14:18:03 2008 @@ -82,8 +82,9 @@ # to reference the nonexistent 'sock' attribute of the SMTP object # causes an AttributeError) smtp = smtplib.SMTP() - self.assertRaises(AttributeError, smtp.ehlo) - self.assertRaises(AttributeError, smtp.send, 'test msg') + self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo) + self.assertRaises(smtplib.SMTPServerDisconnected, + smtp.send, 'test msg') def testLocalHostName(self): # check that supplied local_hostname is used Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Sat Feb 23 14:18:03 2008 @@ -1716,10 +1716,10 @@ typedef struct { PyObject_HEAD PyObject *pools; /* tuple of pool tuples */ - Py_ssize_t *maxvec; - Py_ssize_t *indices; - PyObject *result; - int stopped; + Py_ssize_t *maxvec; /* size of each pool */ + Py_ssize_t *indices; /* one index per pool */ + PyObject *result; /* most recently returned result tuple */ + int stopped; /* set to 1 when the product iterator is exhausted */ } productobject; static PyTypeObject product_type; @@ -1766,7 +1766,7 @@ lz = (productobject *)type->tp_alloc(type, 0); if (lz == NULL) { Py_DECREF(pools); - return NULL; + goto error; } lz->pools = pools; @@ -1810,7 +1810,7 @@ { PyObject *pool; PyObject *elem; - PyObject *tuple_result; + PyObject *oldelem; PyObject *pools = lz->pools; PyObject *result = lz->result; Py_ssize_t npools = PyTuple_GET_SIZE(pools); @@ -1818,10 +1818,14 @@ if (lz->stopped) return NULL; + if (result == NULL) { + /* On the first pass, return an initial tuple filled with the + first element from each pool. If any pool is empty, then + whole product is empty and we're already done */ if (npools == 0) goto empty; - result = PyList_New(npools); + result = PyTuple_New(npools); if (result == NULL) goto empty; lz->result = result; @@ -1831,34 +1835,61 @@ goto empty; elem = PyTuple_GET_ITEM(pool, 0); Py_INCREF(elem); - PyList_SET_ITEM(result, i, elem); + PyTuple_SET_ITEM(result, i, elem); } } else { Py_ssize_t *indices = lz->indices; Py_ssize_t *maxvec = lz->maxvec; + + /* Copy the previous result tuple or re-use it if available */ + if (Py_REFCNT(result) > 1) { + PyObject *old_result = result; + result = PyTuple_New(npools); + if (result == NULL) + goto empty; + lz->result = result; + for (i=0; i < npools; i++) { + elem = PyTuple_GET_ITEM(old_result, i); + Py_INCREF(elem); + PyTuple_SET_ITEM(result, i, elem); + } + Py_DECREF(old_result); + } + /* Now, we've got the only copy so we can update it in-place */ + assert (Py_REFCNT(result) == 1); + + /* Update the pool indices right-to-left. Only advance to the + next pool when the previous one rolls-over */ for (i=npools-1 ; i >= 0 ; i--) { pool = PyTuple_GET_ITEM(pools, i); indices[i]++; if (indices[i] == maxvec[i]) { + /* Roll-over and advance to next pool */ indices[i] = 0; elem = PyTuple_GET_ITEM(pool, 0); Py_INCREF(elem); - PyList_SetItem(result, i, elem); + oldelem = PyTuple_GET_ITEM(result, i); + PyTuple_SET_ITEM(result, i, elem); + Py_DECREF(oldelem); } else { + /* No rollover. Just increment and stop here. */ elem = PyTuple_GET_ITEM(pool, indices[i]); Py_INCREF(elem); - PyList_SetItem(result, i, elem); + oldelem = PyTuple_GET_ITEM(result, i); + PyTuple_SET_ITEM(result, i, elem); + Py_DECREF(oldelem); break; } } + + /* If i is negative, then the indices have all rolled-over + and we're done. */ if (i < 0) - return NULL; + goto empty; } - tuple_result = PySequence_Tuple(result); - if (tuple_result == NULL) - lz->stopped = 1; - return tuple_result; + Py_INCREF(result); + return result; empty: lz->stopped = 1; @@ -1868,7 +1899,7 @@ PyDoc_STRVAR(product_doc, "product(*iterables) --> product object\n\ \n\ -Cartesian product of input interables. Equivalent to nested for-loops.\n\n\ +Cartesian product of input iterables. Equivalent to nested for-loops.\n\n\ For example, product(A, B) returns the same as: ((x,y) for x in A for y in B).\n\ The leftmost iterators are in the outermost for-loop, so the output tuples\n\ cycle in a manner similar to an odometer (with the rightmost element changing\n\ Modified: python/branches/py3k/Parser/parser.h ============================================================================== --- python/branches/py3k/Parser/parser.h (original) +++ python/branches/py3k/Parser/parser.h Sat Feb 23 14:18:03 2008 @@ -7,7 +7,7 @@ /* Parser interface */ -#define MAXSTACK 500 +#define MAXSTACK 1500 typedef struct { int s_state; /* State in current DFA */ From python-3000-checkins at python.org Sat Feb 23 16:01:07 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 23 Feb 2008 16:01:07 +0100 (CET) Subject: [Python-3000-checkins] r60979 - in python/branches/py3k: Lib/test/test_inspect.py Misc/NEWS Python/ast.c Message-ID: <20080223150107.36F521E4019@bag.python.org> Author: christian.heimes Date: Sat Feb 23 16:01:06 2008 New Revision: 60979 Modified: python/branches/py3k/Lib/test/test_inspect.py python/branches/py3k/Misc/NEWS python/branches/py3k/Python/ast.c Log: Patch from Georg Brandl: Fix co_lineno of decorated function and class objects. If you see an error in test_inspect please delete all pyc files. Modified: python/branches/py3k/Lib/test/test_inspect.py ============================================================================== --- python/branches/py3k/Lib/test/test_inspect.py (original) +++ python/branches/py3k/Lib/test/test_inspect.py Sat Feb 23 16:01:06 2008 @@ -239,7 +239,7 @@ fodderFile = mod2 def test_wrapped_decorator(self): - self.assertSourceEqual(mod2.wrapped, 16, 17) + self.assertSourceEqual(mod2.wrapped, 14, 17) def test_replacing_decorator(self): self.assertSourceEqual(mod2.gone, 9, 10) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Feb 23 16:01:06 2008 @@ -363,6 +363,8 @@ Library ------- +- inspect.getsource() includes the decorators again. + - Issue #1916. Added isgenerator() and isgeneratorfunction() to inspect.py. - #1224: Fixed bad url parsing when path begins with double slash. Modified: python/branches/py3k/Python/ast.c ============================================================================== --- python/branches/py3k/Python/ast.c (original) +++ python/branches/py3k/Python/ast.c Sat Feb 23 16:01:06 2008 @@ -1015,6 +1015,12 @@ } else if (TYPE(CHILD(n, 1)) == classdef) { thing = ast_for_classdef(c, CHILD(n, 1), decorator_seq); } + /* we count the decorators in when talking about the class' or + * function's line number */ + if (thing) { + thing->lineno = LINENO(n); + thing->col_offset = n->n_col_offset; + } return thing; } From python-3000-checkins at python.org Sat Feb 23 16:03:07 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 23 Feb 2008 16:03:07 +0100 (CET) Subject: [Python-3000-checkins] r60981 - python/branches/py3k Message-ID: <20080223150307.DBFB11E4016@bag.python.org> Author: christian.heimes Date: Sat Feb 23 16:03:07 2008 New Revision: 60981 Modified: python/branches/py3k/ (props changed) Log: block -r60978 From python-3000-checkins at python.org Sat Feb 23 17:23:06 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 23 Feb 2008 17:23:06 +0100 (CET) Subject: [Python-3000-checkins] r60992 - in python/branches/py3k: Doc/library/basehttpserver.rst Doc/library/difflib.rst Doc/library/dis.rst Doc/library/signal.rst Doc/library/simplexmlrpcserver.rst Lib/BaseHTTPServer.py Lib/curses/__init__.py Lib/test/test_logging.py Lib/test/test_signal.py Modules/signalmodule.c Message-ID: <20080223162306.BC0DD1E4016@bag.python.org> Author: christian.heimes Date: Sat Feb 23 17:23:06 2008 New Revision: 60992 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/basehttpserver.rst python/branches/py3k/Doc/library/difflib.rst python/branches/py3k/Doc/library/dis.rst python/branches/py3k/Doc/library/signal.rst python/branches/py3k/Doc/library/simplexmlrpcserver.rst python/branches/py3k/Lib/BaseHTTPServer.py python/branches/py3k/Lib/curses/__init__.py python/branches/py3k/Lib/test/test_logging.py python/branches/py3k/Lib/test/test_signal.py python/branches/py3k/Modules/signalmodule.c Log: Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900,60902-60906,60908,60911-60917,60919-60920,60922,60926,60929-60931,60933-60935,60937,60939-60941,60943-60954,60959-60961,60963-60964,60966-60967,60971,60977,60979-60989 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60980 | georg.brandl | 2008-02-23 16:02:28 +0100 (Sat, 23 Feb 2008) | 2 lines #1492: allow overriding BaseHTTPServer's content type for error messages. ........ r60982 | georg.brandl | 2008-02-23 16:06:25 +0100 (Sat, 23 Feb 2008) | 2 lines #2165: fix test_logging failure on some machines. ........ r60983 | facundo.batista | 2008-02-23 16:07:35 +0100 (Sat, 23 Feb 2008) | 6 lines Issue 1089358. Adds the siginterrupt() function, that is just a wrapper around the system call with the same name. Also added test cases, doc changes and NEWS entry. Thanks Jason and Ralf Schmitt. ........ r60984 | georg.brandl | 2008-02-23 16:11:18 +0100 (Sat, 23 Feb 2008) | 2 lines #2067: file.__exit__() now calls subclasses' close() method. ........ r60985 | georg.brandl | 2008-02-23 16:19:54 +0100 (Sat, 23 Feb 2008) | 2 lines More difflib examples. Written for GHOP by Josip Dzolonga. ........ r60987 | andrew.kuchling | 2008-02-23 16:41:51 +0100 (Sat, 23 Feb 2008) | 1 line #2072: correct documentation for .rpc_paths ........ r60988 | georg.brandl | 2008-02-23 16:43:48 +0100 (Sat, 23 Feb 2008) | 2 lines #2161: Fix opcode name. ........ r60989 | andrew.kuchling | 2008-02-23 16:49:35 +0100 (Sat, 23 Feb 2008) | 2 lines #1119331: ncurses will just call exit() if the terminal name isn't found. Call setupterm() first so that we get a Python exception instead of just existing. ........ Modified: python/branches/py3k/Doc/library/basehttpserver.rst ============================================================================== --- python/branches/py3k/Doc/library/basehttpserver.rst (original) +++ python/branches/py3k/Doc/library/basehttpserver.rst Sat Feb 23 17:23:06 2008 @@ -122,6 +122,15 @@ class variable. +.. attribute:: BaseHTTPRequestHandler.error_content_type + + Specifies the Content-Type HTTP header of error responses sent to the client. + The default value is ``'text/html'``. + + .. versionadded:: 2.6 + Previously, the content type was always ``'text/html'``. + + .. attribute:: BaseHTTPRequestHandler.protocol_version This specifies the HTTP protocol version used in responses. If set to Modified: python/branches/py3k/Doc/library/difflib.rst ============================================================================== --- python/branches/py3k/Doc/library/difflib.rst (original) +++ python/branches/py3k/Doc/library/difflib.rst Sat Feb 23 17:23:06 2008 @@ -144,7 +144,27 @@ expressed in the format returned by :func:`time.ctime`. If not specified, the strings default to blanks. - :file:`Tools/scripts/diff.py` is a command-line front-end for this function. + :: + + >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n'] + >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n'] + >>> for line in context_diff(s1, s2, fromfile='before.py', tofile='after.py'): + ... sys.stdout.write(line) + *** before.py + --- after.py + *************** + *** 1,4 **** + ! bacon + ! eggs + ! ham + guido + --- 1,4 ---- + ! python + ! eggy + ! hamster + guido + + See :ref:`difflib-interface` for a more detailed example. .. function:: get_close_matches(word, possibilities[, n][, cutoff]) @@ -259,7 +279,24 @@ expressed in the format returned by :func:`time.ctime`. If not specified, the strings default to blanks. - :file:`Tools/scripts/diff.py` is a command-line front-end for this function. + :: + + >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n'] + >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n'] + >>> for line in unified_diff(s1, s2, fromfile='before.py', tofile='after.py'): + ... sys.stdout.write(line) + --- before.py + +++ after.py + @@ -1,4 +1,4 @@ + -bacon + -eggs + -ham + +python + +eggy + +hamster + guido + + See :ref:`difflib-interface` for a more detailed example. .. function:: IS_LINE_JUNK(line) @@ -635,3 +672,75 @@ ? ++++ ^ ^ + 5. Flat is better than nested. + +.. _difflib-interface: + +A command-line interface to difflib +----------------------------------- + +This example shows how to use difflib to create a ``diff``-like utility. +It is also contained in the Python source distribution, as +:file:`Tools/scripts/diff.py`. + +:: + + """ Command line interface to difflib.py providing diffs in four formats: + + * ndiff: lists every line and highlights interline changes. + * context: highlights clusters of changes in a before/after format. + * unified: highlights clusters of changes in an inline format. + * html: generates side by side comparison with change highlights. + + """ + + import sys, os, time, difflib, optparse + + def main(): + # Configure the option parser + usage = "usage: %prog [options] fromfile tofile" + parser = optparse.OptionParser(usage) + parser.add_option("-c", action="store_true", default=False, + help='Produce a context format diff (default)') + parser.add_option("-u", action="store_true", default=False, + help='Produce a unified format diff') + hlp = 'Produce HTML side by side diff (can use -c and -l in conjunction)' + parser.add_option("-m", action="store_true", default=False, help=hlp) + parser.add_option("-n", action="store_true", default=False, + help='Produce a ndiff format diff') + parser.add_option("-l", "--lines", type="int", default=3, + help='Set number of context lines (default 3)') + (options, args) = parser.parse_args() + + if len(args) == 0: + parser.print_help() + sys.exit(1) + if len(args) != 2: + parser.error("need to specify both a fromfile and tofile") + + n = options.lines + fromfile, tofile = args # as specified in the usage string + + # we're passing these as arguments to the diff function + fromdate = time.ctime(os.stat(fromfile).st_mtime) + todate = time.ctime(os.stat(tofile).st_mtime) + fromlines = open(fromfile, 'U').readlines() + tolines = open(tofile, 'U').readlines() + + if options.u: + diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, + fromdate, todate, n=n) + elif options.n: + diff = difflib.ndiff(fromlines, tolines) + elif options.m: + diff = difflib.HtmlDiff().make_file(fromlines, tolines, fromfile, + tofile, context=options.c, + numlines=n) + else: + diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, + fromdate, todate, n=n) + + # we're using writelines because diff is a generator + sys.stdout.writelines(diff) + + if __name__ == '__main__': + main() Modified: python/branches/py3k/Doc/library/dis.rst ============================================================================== --- python/branches/py3k/Doc/library/dis.rst (original) +++ python/branches/py3k/Doc/library/dis.rst Sat Feb 23 17:23:06 2008 @@ -437,7 +437,7 @@ .. opcode:: STORE_NAME (namei) Implements ``name = TOS``. *namei* is the index of *name* in the attribute - :attr:`co_names` of the code object. The compiler tries to use ``STORE_LOCAL`` + :attr:`co_names` of the code object. The compiler tries to use ``STORE_FAST`` or ``STORE_GLOBAL`` if possible. Modified: python/branches/py3k/Doc/library/signal.rst ============================================================================== --- python/branches/py3k/Doc/library/signal.rst (original) +++ python/branches/py3k/Doc/library/signal.rst Sat Feb 23 17:23:06 2008 @@ -124,6 +124,21 @@ exception to be raised. + +.. function:: siginterrupt(signalnum, flag) + + Change system call restart behaviour: if *flag* is :const:`False`, system calls + will be restarted when interrupted by signal *signalnum*, else system calls will + be interrupted. Returns nothing. Availability: Unix, Mac (see the man page + :manpage:`siginterrupt(3)` for further information). + + Note that installing a signal handler with :func:`signal` will reset the restart + behaviour to interruptible by implicitly calling siginterrupt with a true *flag* + value for the given signal. + + .. versionadded:: 2.6 + + .. function:: signal(signalnum, handler) Set the handler for signal *signalnum* to the function *handler*. *handler* can Modified: python/branches/py3k/Doc/library/simplexmlrpcserver.rst ============================================================================== --- python/branches/py3k/Doc/library/simplexmlrpcserver.rst (original) +++ python/branches/py3k/Doc/library/simplexmlrpcserver.rst Sat Feb 23 17:23:06 2008 @@ -101,7 +101,7 @@ Registers the XML-RPC multicall function system.multicall. -.. attribute:: SimpleXMLRPCServer.rpc_paths +.. attribute:: SimpleXMLRPCRequestHandler.rpc_paths An attribute value that must be a tuple listing valid path portions of the URL for receiving XML-RPC requests. Requests posted to other paths will result in a @@ -116,9 +116,15 @@ Server code:: from SimpleXMLRPCServer import SimpleXMLRPCServer + from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler + + # Restrict to a particular path. + class RequestHandler(SimpleXMLRPCRequestHandler): + rpc_paths = ('/RPC2',) # Create server - server = SimpleXMLRPCServer(("localhost", 8000)) + server = SimpleXMLRPCServer(("localhost", 8000), + requestHandler=RequestHandler) server.register_introspection_functions() # Register pow() function; this will use the value of Modified: python/branches/py3k/Lib/BaseHTTPServer.py ============================================================================== --- python/branches/py3k/Lib/BaseHTTPServer.py (original) +++ python/branches/py3k/Lib/BaseHTTPServer.py Sat Feb 23 17:23:06 2008 @@ -77,7 +77,7 @@ import mimetools import SocketServer -# Default error message +# Default error message template DEFAULT_ERROR_MESSAGE = """\ Error response @@ -90,6 +90,8 @@ """ +DEFAULT_ERROR_CONTENT_TYPE = "text/html;charset=utf-8" + def _quote_html(html): return html.replace("&", "&").replace("<", "<").replace(">", ">") @@ -217,6 +219,9 @@ # where each string is of the form name[/version]. server_version = "BaseHTTP/" + __version__ + error_message_format = DEFAULT_ERROR_MESSAGE + error_content_type = DEFAULT_ERROR_CONTENT_TYPE + def parse_request(self): """Parse a request (internal). @@ -356,14 +361,12 @@ content = (self.error_message_format % {'code': code, 'message': _quote_html(message), 'explain': explain}) self.send_response(code, message) - self.send_header("Content-Type", "text/html;charset=utf-8") + self.send_header("Content-Type", self.error_content_type) self.send_header('Connection', 'close') self.end_headers() if self.command != 'HEAD' and code >= 200 and code not in (204, 304): self.wfile.write(content.encode('UTF-8', 'replace')) - error_message_format = DEFAULT_ERROR_MESSAGE - def send_response(self, code, message=None): """Send the response header and log the response code. Modified: python/branches/py3k/Lib/curses/__init__.py ============================================================================== --- python/branches/py3k/Lib/curses/__init__.py (original) +++ python/branches/py3k/Lib/curses/__init__.py Sat Feb 23 17:23:06 2008 @@ -14,6 +14,7 @@ from _curses import * from curses.wrapper import wrapper +import os as _os # Some constants, most notably the ACS_* ones, are only added to the C # _curses module's dictionary after initscr() is called. (Some @@ -25,6 +26,9 @@ def initscr(): import _curses, curses + # we call setupterm() here because it raises an error + # instead of calling exit() in error cases. + setupterm(term=_os.environ.get("TERM", "unknown")) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): Modified: python/branches/py3k/Lib/test/test_logging.py ============================================================================== --- python/branches/py3k/Lib/test/test_logging.py (original) +++ python/branches/py3k/Lib/test/test_logging.py Sat Feb 23 17:23:06 2008 @@ -1828,8 +1828,7 @@ >>> import logging, logging.handlers, logging.config >>> from test import test_logging -XXX: The test is unstable! -#>>> test_logging.test_main_inner() +>>> test_logging.test_main_inner() ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) ERR -> ERROR: Message 1 (via logrecv.tcp.ERR) INF -> CRITICAL: Message 2 (via logrecv.tcp.INF) @@ -2010,7 +2009,7 @@ port=logging.handlers.DEFAULT_TCP_LOGGING_PORT, handler=LogRecordStreamHandler): ThreadingTCPServer.__init__(self, (host, port), handler) - self.abort = 0 + self.abort = False self.timeout = 1 def serve_until_stopped(self): @@ -2019,11 +2018,11 @@ self.timeout) if rd: self.handle_request() + socketDataProcessed.set() # close the listen socket self.server_close() def process_request(self, request, client_address): - #import threading t = threading.Thread(target = self.finish_request, args = (request, client_address)) t.start() @@ -2108,28 +2107,18 @@ rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) - # Find an unused port number - port = logging.handlers.DEFAULT_TCP_LOGGING_PORT - while port < logging.handlers.DEFAULT_TCP_LOGGING_PORT+100: - try: - tcpserver = LogRecordSocketReceiver(port=port) - except socket.error: - port += 1 - else: - break - else: - raise ImportError("Could not find unused port") - + tcpserver = LogRecordSocketReceiver(port=0) + port = tcpserver.socket.getsockname()[1] - #Set up a handler such that all events are sent via a socket to the log - #receiver (logrecv). - #The handler will only be added to the rootLogger for some of the tests + # Set up a handler such that all events are sent via a socket to the log + # receiver (logrecv). + # The handler will only be added to the rootLogger for some of the tests shdlr = logging.handlers.SocketHandler('localhost', port) rootLogger.addHandler(shdlr) - #Configure the logger for logrecv so events do not propagate beyond it. - #The sockLogger output is buffered in memory until the end of the test, - #and printed at the end. + # Configure the logger for logrecv so events do not propagate beyond it. + # The sockLogger output is buffered in memory until the end of the test, + # and printed at the end. sockOut = io.StringIO() sockLogger = logging.getLogger("logrecv") sockLogger.setLevel(logging.DEBUG) @@ -2158,9 +2147,9 @@ finally: #wait for TCP receiver to terminate -# socketDataProcessed.wait() + socketDataProcessed.wait() # ensure the server dies - tcpserver.abort = 1 + tcpserver.abort = True for thread in threads: thread.join(2.0) print(sockOut.getvalue()) Modified: python/branches/py3k/Lib/test/test_signal.py ============================================================================== --- python/branches/py3k/Lib/test/test_signal.py (original) +++ python/branches/py3k/Lib/test/test_signal.py Sat Feb 23 17:23:06 2008 @@ -1,7 +1,7 @@ import unittest from test import test_support import signal -import os, sys, time +import os, sys, time, errno class HandlerBCalled(Exception): pass @@ -211,6 +211,50 @@ os.close(self.write) signal.signal(signal.SIGALRM, self.alrm) +class SiginterruptTest(unittest.TestCase): + signum = signal.SIGUSR1 + def readpipe_interrupted(self, cb): + r, w = os.pipe() + ppid = os.getpid() + pid = os.fork() + + oldhandler = signal.signal(self.signum, lambda x,y: None) + cb() + if pid==0: + # child code: sleep, kill, sleep. and then exit, + # which closes the pipe from which the parent process reads + try: + time.sleep(0.2) + os.kill(ppid, self.signum) + time.sleep(0.2) + finally: + os._exit(0) + + try: + os.close(w) + + try: + d=os.read(r, 1) + return False + except OSError as err: + if err.errno != errno.EINTR: + raise + return True + finally: + signal.signal(self.signum, oldhandler) + os.waitpid(pid, 0) + + def test_without_siginterrupt(self): + i=self.readpipe_interrupted(lambda: None) + self.assertEquals(i, True) + + def test_siginterrupt_on(self): + i=self.readpipe_interrupted(lambda: signal.siginterrupt(self.signum, 1)) + self.assertEquals(i, True) + + def test_siginterrupt_off(self): + i=self.readpipe_interrupted(lambda: signal.siginterrupt(self.signum, 0)) + self.assertEquals(i, False) def test_main(): if sys.platform[:3] in ('win', 'os2'): @@ -218,7 +262,7 @@ sys.platform) test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, - WakeupSignalTests) + WakeupSignalTests, SiginterruptTest) if __name__ == "__main__": Modified: python/branches/py3k/Modules/signalmodule.c ============================================================================== --- python/branches/py3k/Modules/signalmodule.c (original) +++ python/branches/py3k/Modules/signalmodule.c Sat Feb 23 17:23:06 2008 @@ -272,6 +272,36 @@ None -- if an unknown handler is in effect\n\ anything else -- the callable Python object used as a handler"); +#ifdef HAVE_SIGINTERRUPT +PyDoc_STRVAR(siginterrupt_doc, +"siginterrupt(sig, flag) -> None\n\ +change system call restart behaviour: if flag is False, system calls\n\ +will be restarted when interrupted by signal sig, else system calls\n\ +will be interrupted."); + +static PyObject * +signal_siginterrupt(PyObject *self, PyObject *args) +{ + int sig_num; + int flag; + + if (!PyArg_ParseTuple(args, "ii:siginterrupt", &sig_num, &flag)) + return NULL; + if (sig_num < 1 || sig_num >= NSIG) { + PyErr_SetString(PyExc_ValueError, + "signal number out of range"); + return NULL; + } + if (siginterrupt(sig_num, flag)<0) { + PyErr_SetFromErrno(PyExc_RuntimeError); + return NULL; + } + + Py_INCREF(Py_None); + return Py_None; +} + +#endif static PyObject * signal_set_wakeup_fd(PyObject *self, PyObject *args) @@ -325,6 +355,9 @@ {"signal", signal_signal, METH_VARARGS, signal_doc}, {"getsignal", signal_getsignal, METH_VARARGS, getsignal_doc}, {"set_wakeup_fd", signal_set_wakeup_fd, METH_VARARGS, set_wakeup_fd_doc}, +#ifdef HAVE_SIGINTERRUPT + {"siginterrupt", signal_siginterrupt, METH_VARARGS, siginterrupt_doc}, +#endif #ifdef HAVE_PAUSE {"pause", (PyCFunction)signal_pause, METH_NOARGS,pause_doc}, From python-3000-checkins at python.org Sat Feb 23 17:29:43 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 23 Feb 2008 17:29:43 +0100 (CET) Subject: [Python-3000-checkins] r60993 - python/branches/py3k Message-ID: <20080223162943.4C34B1E4016@bag.python.org> Author: christian.heimes Date: Sat Feb 23 17:29:43 2008 New Revision: 60993 Modified: python/branches/py3k/ (props changed) Log: Simplified svnmerge blocked and integrated. We are never ever going to integrate the blocked revisions. The old values were: svnmerge-blocked : /python/trunk:60480,60521-60522,60528-60529,60534,60539,60599,60707,60713,60879,60893,60899,60932,60962,60970,60978 svnmerge-integrated : /python/trunk:1-60479,60481-60520,60523-60527,60530-60533,60535-60538,60540-60598,60600-60706,60708-60712,60714-60878,60880-60892,60894-60898,60900-60931,60933-60961,60963-60969,60971-60977,60979-60989 From python-3000-checkins at python.org Sat Feb 23 19:30:21 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 23 Feb 2008 19:30:21 +0100 (CET) Subject: [Python-3000-checkins] r61003 - in python/branches/py3k: Doc/library/pickle.rst Doc/library/xmlrpclib.rst Doc/whatsnew/2.6.rst Lib/SimpleHTTPServer.py Lib/ctypes/test/__init__.py Lib/ctypes/test/test_checkretval.py Lib/ctypes/test/test_find.py Lib/ctypes/test/test_libc.py Lib/ctypes/test/test_numbers.py Lib/curses/wrapper.py Lib/distutils/bcppcompiler.py Lib/distutils/command/bdist_dumb.py Lib/distutils/command/bdist_rpm.py Lib/distutils/command/build_scripts.py Lib/distutils/command/install.py Lib/distutils/command/install_headers.py Lib/distutils/command/register.py Lib/distutils/filelist.py Lib/distutils/tests/test_dist.py Lib/distutils/tests/test_sysconfig.py Lib/distutils/unixccompiler.py Lib/email/base64mime.py Lib/httplib.py Lib/idlelib/MultiCall.py Lib/idlelib/RemoteDebugger.py Lib/idlelib/TreeWidget.py Lib/idlelib/UndoDelegator.py Lib/idlelib/keybindingDialog.py Lib/idlelib/run.py Lib/lib-tk/tkSimpleDialog.py Lib/logging/handlers.py Lib/ntpath.py Lib/plat-mac/MiniAEFrame.py Lib/plat-mac/aepack.py Lib/plat-mac/bgenlocations.py Lib/plat-mac/macostools.py Lib/sqlite3/test/hooks.py Lib/ssl.py Lib/test/fork_wait.py Lib/test/list_tests.py Lib/test/seq_tests.py Lib/test/test___all__.py Lib/test/test_abc.py Lib/test/test_applesingle.py Lib/test/test_class.py Lib/test/test_cmd.py Lib/test/test_compare.py Lib/test/test_copy.py Lib/test/test_datetime.py Lib/test/test_dbm.py Lib/test/test_dis.py Lib/test/test_dummy_threading.py Lib/test/test_email.py Lib/test/test_eof.py Lib/test/test_extcall.py Lib/test/test_fileinput.py Lib/test/test_fractions.py Lib/test/test_getargs2.py Lib/test/test_gzip.py Lib/test/test_htmlparser.py Lib/test/test_httplib.py Lib/test/test_imp.py Lib/test/test_index.py Lib/test/test_list.py Lib/test/test_minidom.py Lib/test/test_module.py Lib/test/test_modulefinder.py Lib/test/test_multibytecodec_support.py Lib/test/test_optparse.py Lib/test/test_ossaudiodev.py Lib/test/test_pickle.py Lib/test/test_pkg.py Lib/test/test_plistlib.py Lib/test/test_poll.py Lib/test/test_posix.py Lib/test/test_pyclbr.py Lib/test/test_resource.py Lib/test/test_rfc822.py Lib/test/test_scriptpackages.py Lib/test/test_sgmllib.py Lib/test/test_site.py Lib/test/test_socketserver.py Lib/test/test_sqlite.py Lib/test/test_strftime.py Lib/test/test_support.py Lib/test/test_tuple.py Lib/test/test_unpack.py Lib/test/test_urllib.py Lib/test/test_urllib2.py Lib/test/test_urllib2_localnet.py Lib/test/test_userdict.py Lib/test/test_userlist.py Lib/test/test_userstring.py Lib/test/test_whichdb.py Lib/test/test_xml_etree.py Lib/test/test_xml_etree_c.py Lib/test/test_xmlrpc.py Lib/xml/dom/minidom.py Lib/xmlrpclib.py Mac/Demo/PICTbrowse/ICONbrowse.py Mac/Demo/PICTbrowse/PICTbrowse.py Mac/Demo/PICTbrowse/PICTbrowse2.py Mac/Demo/PICTbrowse/cicnbrowse.py Mac/Demo/PICTbrowse/oldPICTbrowse.py Mac/Demo/example1/dnslookup-1.py Mac/Demo/example2/dnslookup-2.py Mac/Demo/imgbrowse/imgbrowse.py Mac/Demo/imgbrowse/mac_image.py Mac/Modules/ae/aescan.py Mac/Modules/ah/ahscan.py Mac/Modules/app/appscan.py Mac/Modules/carbonevt/CarbonEvtscan.py Mac/Modules/cf/cfscan.py Mac/Modules/cg/cgscan.py Mac/Modules/cm/cmscan.py Mac/Modules/ctl/ctlscan.py Mac/Modules/dlg/dlgscan.py Mac/Modules/drag/dragscan.py Mac/Modules/evt/evtscan.py Mac/Modules/file/filescan.py Mac/Modules/fm/fmscan.py Mac/Modules/folder/folderscan.py Mac/Modules/help/helpscan.py Mac/Modules/ibcarbon/IBCarbonscan.py Mac/Modules/icn/icnscan.py Mac/Modules/launch/launchscan.py Mac/Modules/list/listscan.py Mac/Modules/menu/menuscan.py Mac/Modules/mlte/mltescan.py Mac/Modules/osa/osascan.py Mac/Modules/qd/qdscan.py Mac/Modules/qdoffs/qdoffsscan.py Mac/Modules/qt/qtscan.py Mac/Modules/res/resscan.py Mac/Modules/scrap/scrapscan.py Mac/Modules/snd/sndscan.py Mac/Modules/te/tescan.py Mac/Modules/win/winscan.py Misc/ACKS Modules/syslogmodule.c PC/VS8.0/build_tkinter.py PCbuild/build_tkinter.py Parser/asdl_c.py Parser/spark.py Python/Python-ast.c Python/import.c Python/mystrtoul.c Tools/faqwiz/faqw.py Tools/modulator/Tkextra.py Tools/pybench/systimes.py Tools/pynche/ChipViewer.py Tools/pynche/TypeinViewer.py Tools/scripts/logmerge.py Tools/scripts/nm2def.py Tools/scripts/pindent.py Tools/scripts/pysource.py Tools/scripts/xxci.py Tools/ssl/get-remote-certificate.py Tools/unicode/gencodec.py Tools/webchecker/wcgui.py Tools/webchecker/wsgui.py Message-ID: <20080223183021.C68A71E4016@bag.python.org> Author: christian.heimes Date: Sat Feb 23 19:30:17 2008 New Revision: 61003 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/pickle.rst python/branches/py3k/Doc/library/xmlrpclib.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/SimpleHTTPServer.py python/branches/py3k/Lib/ctypes/test/__init__.py python/branches/py3k/Lib/ctypes/test/test_checkretval.py python/branches/py3k/Lib/ctypes/test/test_find.py python/branches/py3k/Lib/ctypes/test/test_libc.py python/branches/py3k/Lib/ctypes/test/test_numbers.py python/branches/py3k/Lib/curses/wrapper.py python/branches/py3k/Lib/distutils/bcppcompiler.py python/branches/py3k/Lib/distutils/command/bdist_dumb.py python/branches/py3k/Lib/distutils/command/bdist_rpm.py python/branches/py3k/Lib/distutils/command/build_scripts.py python/branches/py3k/Lib/distutils/command/install.py python/branches/py3k/Lib/distutils/command/install_headers.py python/branches/py3k/Lib/distutils/command/register.py python/branches/py3k/Lib/distutils/filelist.py python/branches/py3k/Lib/distutils/tests/test_dist.py python/branches/py3k/Lib/distutils/tests/test_sysconfig.py python/branches/py3k/Lib/distutils/unixccompiler.py python/branches/py3k/Lib/email/base64mime.py python/branches/py3k/Lib/httplib.py python/branches/py3k/Lib/idlelib/MultiCall.py python/branches/py3k/Lib/idlelib/RemoteDebugger.py python/branches/py3k/Lib/idlelib/TreeWidget.py python/branches/py3k/Lib/idlelib/UndoDelegator.py python/branches/py3k/Lib/idlelib/keybindingDialog.py python/branches/py3k/Lib/idlelib/run.py python/branches/py3k/Lib/lib-tk/tkSimpleDialog.py python/branches/py3k/Lib/logging/handlers.py python/branches/py3k/Lib/ntpath.py python/branches/py3k/Lib/plat-mac/MiniAEFrame.py python/branches/py3k/Lib/plat-mac/aepack.py python/branches/py3k/Lib/plat-mac/bgenlocations.py python/branches/py3k/Lib/plat-mac/macostools.py python/branches/py3k/Lib/sqlite3/test/hooks.py python/branches/py3k/Lib/ssl.py python/branches/py3k/Lib/test/fork_wait.py python/branches/py3k/Lib/test/list_tests.py python/branches/py3k/Lib/test/seq_tests.py python/branches/py3k/Lib/test/test___all__.py python/branches/py3k/Lib/test/test_abc.py python/branches/py3k/Lib/test/test_applesingle.py python/branches/py3k/Lib/test/test_class.py python/branches/py3k/Lib/test/test_cmd.py python/branches/py3k/Lib/test/test_compare.py python/branches/py3k/Lib/test/test_copy.py python/branches/py3k/Lib/test/test_datetime.py python/branches/py3k/Lib/test/test_dbm.py python/branches/py3k/Lib/test/test_dis.py python/branches/py3k/Lib/test/test_dummy_threading.py python/branches/py3k/Lib/test/test_email.py python/branches/py3k/Lib/test/test_eof.py python/branches/py3k/Lib/test/test_extcall.py python/branches/py3k/Lib/test/test_fileinput.py python/branches/py3k/Lib/test/test_fractions.py python/branches/py3k/Lib/test/test_getargs2.py python/branches/py3k/Lib/test/test_gzip.py python/branches/py3k/Lib/test/test_htmlparser.py python/branches/py3k/Lib/test/test_httplib.py python/branches/py3k/Lib/test/test_imp.py python/branches/py3k/Lib/test/test_index.py python/branches/py3k/Lib/test/test_list.py python/branches/py3k/Lib/test/test_minidom.py python/branches/py3k/Lib/test/test_module.py python/branches/py3k/Lib/test/test_modulefinder.py python/branches/py3k/Lib/test/test_multibytecodec_support.py python/branches/py3k/Lib/test/test_optparse.py python/branches/py3k/Lib/test/test_ossaudiodev.py python/branches/py3k/Lib/test/test_pickle.py python/branches/py3k/Lib/test/test_pkg.py python/branches/py3k/Lib/test/test_plistlib.py python/branches/py3k/Lib/test/test_poll.py python/branches/py3k/Lib/test/test_posix.py python/branches/py3k/Lib/test/test_pyclbr.py python/branches/py3k/Lib/test/test_resource.py python/branches/py3k/Lib/test/test_rfc822.py python/branches/py3k/Lib/test/test_scriptpackages.py python/branches/py3k/Lib/test/test_sgmllib.py python/branches/py3k/Lib/test/test_site.py python/branches/py3k/Lib/test/test_socketserver.py python/branches/py3k/Lib/test/test_sqlite.py python/branches/py3k/Lib/test/test_strftime.py python/branches/py3k/Lib/test/test_support.py python/branches/py3k/Lib/test/test_tuple.py python/branches/py3k/Lib/test/test_unpack.py python/branches/py3k/Lib/test/test_urllib.py python/branches/py3k/Lib/test/test_urllib2.py python/branches/py3k/Lib/test/test_urllib2_localnet.py python/branches/py3k/Lib/test/test_userdict.py python/branches/py3k/Lib/test/test_userlist.py python/branches/py3k/Lib/test/test_userstring.py python/branches/py3k/Lib/test/test_whichdb.py python/branches/py3k/Lib/test/test_xml_etree.py python/branches/py3k/Lib/test/test_xml_etree_c.py python/branches/py3k/Lib/test/test_xmlrpc.py python/branches/py3k/Lib/xml/dom/minidom.py python/branches/py3k/Lib/xmlrpclib.py python/branches/py3k/Mac/Demo/PICTbrowse/ICONbrowse.py python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse.py python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse2.py python/branches/py3k/Mac/Demo/PICTbrowse/cicnbrowse.py python/branches/py3k/Mac/Demo/PICTbrowse/oldPICTbrowse.py python/branches/py3k/Mac/Demo/example1/dnslookup-1.py python/branches/py3k/Mac/Demo/example2/dnslookup-2.py python/branches/py3k/Mac/Demo/imgbrowse/imgbrowse.py python/branches/py3k/Mac/Demo/imgbrowse/mac_image.py python/branches/py3k/Mac/Modules/ae/aescan.py python/branches/py3k/Mac/Modules/ah/ahscan.py python/branches/py3k/Mac/Modules/app/appscan.py python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py python/branches/py3k/Mac/Modules/cf/cfscan.py python/branches/py3k/Mac/Modules/cg/cgscan.py python/branches/py3k/Mac/Modules/cm/cmscan.py python/branches/py3k/Mac/Modules/ctl/ctlscan.py python/branches/py3k/Mac/Modules/dlg/dlgscan.py python/branches/py3k/Mac/Modules/drag/dragscan.py python/branches/py3k/Mac/Modules/evt/evtscan.py python/branches/py3k/Mac/Modules/file/filescan.py python/branches/py3k/Mac/Modules/fm/fmscan.py python/branches/py3k/Mac/Modules/folder/folderscan.py python/branches/py3k/Mac/Modules/help/helpscan.py python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py python/branches/py3k/Mac/Modules/icn/icnscan.py python/branches/py3k/Mac/Modules/launch/launchscan.py python/branches/py3k/Mac/Modules/list/listscan.py python/branches/py3k/Mac/Modules/menu/menuscan.py python/branches/py3k/Mac/Modules/mlte/mltescan.py python/branches/py3k/Mac/Modules/osa/osascan.py python/branches/py3k/Mac/Modules/qd/qdscan.py python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py python/branches/py3k/Mac/Modules/qt/qtscan.py python/branches/py3k/Mac/Modules/res/resscan.py python/branches/py3k/Mac/Modules/scrap/scrapscan.py python/branches/py3k/Mac/Modules/snd/sndscan.py python/branches/py3k/Mac/Modules/te/tescan.py python/branches/py3k/Mac/Modules/win/winscan.py python/branches/py3k/Misc/ACKS python/branches/py3k/Modules/syslogmodule.c python/branches/py3k/PC/VS8.0/build_tkinter.py python/branches/py3k/PCbuild/build_tkinter.py python/branches/py3k/Parser/asdl_c.py python/branches/py3k/Parser/spark.py python/branches/py3k/Python/Python-ast.c python/branches/py3k/Python/import.c python/branches/py3k/Python/mystrtoul.c python/branches/py3k/Tools/faqwiz/faqw.py python/branches/py3k/Tools/modulator/Tkextra.py python/branches/py3k/Tools/pybench/systimes.py python/branches/py3k/Tools/pynche/ChipViewer.py python/branches/py3k/Tools/pynche/TypeinViewer.py python/branches/py3k/Tools/scripts/logmerge.py python/branches/py3k/Tools/scripts/nm2def.py python/branches/py3k/Tools/scripts/pindent.py python/branches/py3k/Tools/scripts/pysource.py python/branches/py3k/Tools/scripts/xxci.py python/branches/py3k/Tools/ssl/get-remote-certificate.py python/branches/py3k/Tools/unicode/gencodec.py python/branches/py3k/Tools/webchecker/wcgui.py python/branches/py3k/Tools/webchecker/wsgui.py Log: Merged revisions 60990-61002 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r60990 | eric.smith | 2008-02-23 17:05:26 +0100 (Sat, 23 Feb 2008) | 1 line Removed duplicate Py_CHARMASK define. It's already defined in Python.h. ........ r60991 | andrew.kuchling | 2008-02-23 17:23:05 +0100 (Sat, 23 Feb 2008) | 4 lines #1330538: Improve comparison of xmlrpclib.DateTime and datetime instances. Remove automatic handling of datetime.date and datetime.time. This breaks backward compatibility, but python-dev discussion was strongly against this automatic conversion; see the bug for a link. ........ r60994 | andrew.kuchling | 2008-02-23 17:39:43 +0100 (Sat, 23 Feb 2008) | 1 line #835521: Add index entries for various pickle-protocol methods and attributes ........ r60995 | andrew.kuchling | 2008-02-23 18:10:46 +0100 (Sat, 23 Feb 2008) | 2 lines #1433694: minidom's .normalize() failed to set .nextSibling for last element. Fix by Malte Helmert ........ r61000 | christian.heimes | 2008-02-23 18:40:11 +0100 (Sat, 23 Feb 2008) | 1 line Patch #2167 from calvin: Remove unused imports ........ r61001 | christian.heimes | 2008-02-23 18:42:31 +0100 (Sat, 23 Feb 2008) | 1 line Patch #1957: syslogmodule: Release GIL when calling syslog(3) ........ r61002 | christian.heimes | 2008-02-23 18:52:07 +0100 (Sat, 23 Feb 2008) | 2 lines Issue #2051 and patch from Alexander Belopolsky: Permission for pyc and pyo files are inherited from the py file. ........ Modified: python/branches/py3k/Doc/library/pickle.rst ============================================================================== --- python/branches/py3k/Doc/library/pickle.rst (original) +++ python/branches/py3k/Doc/library/pickle.rst Sat Feb 23 19:30:17 2008 @@ -451,6 +451,11 @@ Pickling and unpickling extension types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. index:: + single: __reduce__() (pickle protocol) + single: __reduce_ex__() (pickle protocol) + single: __safe_for_unpickling__ (pickle protocol) + When the :class:`Pickler` encounters an object of a type it knows nothing about --- such as an extension type --- it looks in two places for a hint of how to pickle it. One alternative is for the object to implement a :meth:`__reduce__` @@ -526,6 +531,10 @@ Pickling and unpickling external objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. index:: + single: persistent_id (pickle protocol) + single: persistent_load (pickle protocol) + For the benefit of object persistence, the :mod:`pickle` module supports the notion of a reference to an object outside the pickled data stream. Such objects are referenced by a "persistent id", which is just an arbitrary string @@ -615,6 +624,10 @@ Subclassing Unpicklers ---------------------- +.. index:: + single: load_global() (pickle protocol) + single: find_global() (pickle protocol) + By default, unpickling will import any class that it finds in the pickle data. You can control exactly what gets unpickled and what gets called by customizing your unpickler. Unfortunately, exactly how you do this is different depending Modified: python/branches/py3k/Doc/library/xmlrpclib.rst ============================================================================== --- python/branches/py3k/Doc/library/xmlrpclib.rst (original) +++ python/branches/py3k/Doc/library/xmlrpclib.rst Sat Feb 23 19:30:17 2008 @@ -32,10 +32,7 @@ all clients and servers; see http://ontosys.com/xml-rpc/extensions.php for a description. The *use_datetime* flag can be used to cause date/time values to be presented as :class:`datetime.datetime` objects; this is false by default. - :class:`datetime.datetime`, :class:`datetime.date` and :class:`datetime.time` - objects may be passed to calls. :class:`datetime.date` objects are converted - with a time of "00:00:00". :class:`datetime.time` objects are converted using - today's date. + :class:`datetime.datetime` objects may be passed to calls. Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication: ``http://user:pass at host:port/path``. The ``user:pass`` @@ -79,9 +76,7 @@ +---------------------------------+---------------------------------------------+ | :const:`dates` | in seconds since the epoch (pass in an | | | instance of the :class:`DateTime` class) or | - | | a :class:`datetime.datetime`, | - | | :class:`datetime.date` or | - | | :class:`datetime.time` instance | + | | a :class:`datetime.datetime` instance. | +---------------------------------+---------------------------------------------+ | :const:`binary data` | pass in an instance of the :class:`Binary` | | | wrapper class | @@ -211,10 +206,10 @@ DateTime Objects ---------------- -This class may be initialized with seconds since the epoch, a time tuple, an ISO -8601 time/date string, or a :class:`datetime.datetime`, :class:`datetime.date` -or :class:`datetime.time` instance. It has the following methods, supported -mainly for internal use by the marshalling/unmarshalling code: +This class may be initialized with seconds since the epoch, a time +tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime` +instance. It has the following methods, supported mainly for internal +use by the marshalling/unmarshalling code: .. method:: DateTime.decode(string) @@ -495,10 +490,7 @@ ``None`` if no method name is present in the packet. If the XML-RPC packet represents a fault condition, this function will raise a :exc:`Fault` exception. The *use_datetime* flag can be used to cause date/time values to be presented as - :class:`datetime.datetime` objects; this is false by default. Note that even if - you call an XML-RPC method with :class:`datetime.date` or :class:`datetime.time` - objects, they are converted to :class:`DateTime` objects internally, so only - :class:`datetime.datetime` objects will be returned. + :class:`datetime.datetime` objects; this is false by default. .. _xmlrpc-client-example: Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Sat Feb 23 19:30:17 2008 @@ -1511,6 +1511,15 @@ .. Issue 1706815 +* The :mod:`xmlrpclib` module no longer automatically converts + :class:`datetime.date` and :class:`datetime.time` to the + :class:`xmlrpclib.DateTime` type; the conversion semantics were + not necessarily correct for all applications. Code using + :mod:`xmlrpclib` should convert :class:`date` and :class:`time` + instances. + + .. Issue 1330538 + .. ====================================================================== Modified: python/branches/py3k/Lib/SimpleHTTPServer.py ============================================================================== --- python/branches/py3k/Lib/SimpleHTTPServer.py (original) +++ python/branches/py3k/Lib/SimpleHTTPServer.py Sat Feb 23 19:30:17 2008 @@ -14,7 +14,6 @@ import posixpath import BaseHTTPServer import urllib -import urlparse import cgi import shutil import mimetypes Modified: python/branches/py3k/Lib/ctypes/test/__init__.py ============================================================================== --- python/branches/py3k/Lib/ctypes/test/__init__.py (original) +++ python/branches/py3k/Lib/ctypes/test/__init__.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,4 @@ -import glob, os, sys, unittest, getopt, time +import os, sys, unittest, getopt, time use_resources = [] Modified: python/branches/py3k/Lib/ctypes/test/test_checkretval.py ============================================================================== --- python/branches/py3k/Lib/ctypes/test/test_checkretval.py (original) +++ python/branches/py3k/Lib/ctypes/test/test_checkretval.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,4 @@ import unittest -import sys from ctypes import * Modified: python/branches/py3k/Lib/ctypes/test/test_find.py ============================================================================== --- python/branches/py3k/Lib/ctypes/test/test_find.py (original) +++ python/branches/py3k/Lib/ctypes/test/test_find.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,5 @@ import unittest -import os, sys +import sys from ctypes import * from ctypes.util import find_library from ctypes.test import is_resource_enabled Modified: python/branches/py3k/Lib/ctypes/test/test_libc.py ============================================================================== --- python/branches/py3k/Lib/ctypes/test/test_libc.py (original) +++ python/branches/py3k/Lib/ctypes/test/test_libc.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,3 @@ -import sys, os import unittest from ctypes import * Modified: python/branches/py3k/Lib/ctypes/test/test_numbers.py ============================================================================== --- python/branches/py3k/Lib/ctypes/test/test_numbers.py (original) +++ python/branches/py3k/Lib/ctypes/test/test_numbers.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,6 @@ from ctypes import * import unittest -import sys, struct +import struct def valid_ranges(*types): # given a sequence of numeric types, collect their _type_ Modified: python/branches/py3k/Lib/curses/wrapper.py ============================================================================== --- python/branches/py3k/Lib/curses/wrapper.py (original) +++ python/branches/py3k/Lib/curses/wrapper.py Sat Feb 23 19:30:17 2008 @@ -7,7 +7,7 @@ """ -import sys, curses +import curses def wrapper(func, *args, **kwds): """Wrapper function that initializes curses and calls another function, Modified: python/branches/py3k/Lib/distutils/bcppcompiler.py ============================================================================== --- python/branches/py3k/Lib/distutils/bcppcompiler.py (original) +++ python/branches/py3k/Lib/distutils/bcppcompiler.py Sat Feb 23 19:30:17 2008 @@ -14,7 +14,7 @@ __revision__ = "$Id$" -import sys, os +import os from distutils.errors import \ DistutilsExecError, DistutilsPlatformError, \ CompileError, LibError, LinkError, UnknownFileError Modified: python/branches/py3k/Lib/distutils/command/bdist_dumb.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/bdist_dumb.py (original) +++ python/branches/py3k/Lib/distutils/command/bdist_dumb.py Sat Feb 23 19:30:17 2008 @@ -9,7 +9,7 @@ import os from distutils.core import Command from distutils.util import get_platform -from distutils.dir_util import create_tree, remove_tree, ensure_relative +from distutils.dir_util import remove_tree, ensure_relative from distutils.errors import * from distutils.sysconfig import get_python_version from distutils import log Modified: python/branches/py3k/Lib/distutils/command/bdist_rpm.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/bdist_rpm.py (original) +++ python/branches/py3k/Lib/distutils/command/bdist_rpm.py Sat Feb 23 19:30:17 2008 @@ -6,7 +6,6 @@ __revision__ = "$Id$" import sys, os -import glob from distutils.core import Command from distutils.debug import DEBUG from distutils.util import get_platform Modified: python/branches/py3k/Lib/distutils/command/build_scripts.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/build_scripts.py (original) +++ python/branches/py3k/Lib/distutils/command/build_scripts.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,7 @@ __revision__ = "$Id$" -import sys, os, re +import os, re from stat import ST_MODE from distutils import sysconfig from distutils.core import Command Modified: python/branches/py3k/Lib/distutils/command/install.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/install.py (original) +++ python/branches/py3k/Lib/distutils/command/install.py Sat Feb 23 19:30:17 2008 @@ -14,7 +14,6 @@ from distutils.file_util import write_file from distutils.util import convert_path, subst_vars, change_root from distutils.errors import DistutilsOptionError -from glob import glob if sys.version < "2.2": WINDOWS_SCHEME = { Modified: python/branches/py3k/Lib/distutils/command/install_headers.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/install_headers.py (original) +++ python/branches/py3k/Lib/distutils/command/install_headers.py Sat Feb 23 19:30:17 2008 @@ -5,7 +5,6 @@ __revision__ = "$Id$" -import os from distutils.core import Command Modified: python/branches/py3k/Lib/distutils/command/register.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/register.py (original) +++ python/branches/py3k/Lib/distutils/command/register.py Sat Feb 23 19:30:17 2008 @@ -7,7 +7,7 @@ __revision__ = "$Id$" -import sys, os, urllib2, getpass, urlparse +import os, string, urllib2, getpass, urlparse import io, ConfigParser from distutils.core import Command Modified: python/branches/py3k/Lib/distutils/filelist.py ============================================================================== --- python/branches/py3k/Lib/distutils/filelist.py (original) +++ python/branches/py3k/Lib/distutils/filelist.py Sat Feb 23 19:30:17 2008 @@ -8,7 +8,6 @@ import os, re import fnmatch -from glob import glob from distutils.util import convert_path from distutils.errors import DistutilsTemplateError, DistutilsInternalError from distutils import log Modified: python/branches/py3k/Lib/distutils/tests/test_dist.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_dist.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_dist.py Sat Feb 23 19:30:17 2008 @@ -3,10 +3,8 @@ import distutils.cmd import distutils.dist import os -import shutil import io import sys -import tempfile import unittest from test.test_support import TESTFN Modified: python/branches/py3k/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_sysconfig.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_sysconfig.py Sat Feb 23 19:30:17 2008 @@ -2,7 +2,6 @@ from distutils import sysconfig import os -import sys import unittest from test.test_support import TESTFN Modified: python/branches/py3k/Lib/distutils/unixccompiler.py ============================================================================== --- python/branches/py3k/Lib/distutils/unixccompiler.py (original) +++ python/branches/py3k/Lib/distutils/unixccompiler.py Sat Feb 23 19:30:17 2008 @@ -16,7 +16,6 @@ __revision__ = "$Id$" import os, sys -from copy import copy from distutils import sysconfig from distutils.dep_util import newer Modified: python/branches/py3k/Lib/email/base64mime.py ============================================================================== --- python/branches/py3k/Lib/email/base64mime.py (original) +++ python/branches/py3k/Lib/email/base64mime.py Sat Feb 23 19:30:17 2008 @@ -35,7 +35,6 @@ 'header_length', ] -import re from base64 import b64encode from binascii import b2a_base64, a2b_base64 Modified: python/branches/py3k/Lib/httplib.py ============================================================================== --- python/branches/py3k/Lib/httplib.py (original) +++ python/branches/py3k/Lib/httplib.py Sat Feb 23 19:30:17 2008 @@ -66,7 +66,6 @@ Req-sent-unread-response _CS_REQ_SENT """ -import errno import io import mimetools import socket Modified: python/branches/py3k/Lib/idlelib/MultiCall.py ============================================================================== --- python/branches/py3k/Lib/idlelib/MultiCall.py (original) +++ python/branches/py3k/Lib/idlelib/MultiCall.py Sat Feb 23 19:30:17 2008 @@ -30,7 +30,6 @@ """ import sys -import os import re import Tkinter Modified: python/branches/py3k/Lib/idlelib/RemoteDebugger.py ============================================================================== --- python/branches/py3k/Lib/idlelib/RemoteDebugger.py (original) +++ python/branches/py3k/Lib/idlelib/RemoteDebugger.py Sat Feb 23 19:30:17 2008 @@ -20,7 +20,6 @@ """ -import sys import types from idlelib import rpc from idlelib import Debugger Modified: python/branches/py3k/Lib/idlelib/TreeWidget.py ============================================================================== --- python/branches/py3k/Lib/idlelib/TreeWidget.py (original) +++ python/branches/py3k/Lib/idlelib/TreeWidget.py Sat Feb 23 19:30:17 2008 @@ -15,7 +15,6 @@ # - optimize tree redraw after expand of subnode import os -import sys from Tkinter import * import imp Modified: python/branches/py3k/Lib/idlelib/UndoDelegator.py ============================================================================== --- python/branches/py3k/Lib/idlelib/UndoDelegator.py (original) +++ python/branches/py3k/Lib/idlelib/UndoDelegator.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,3 @@ -import sys import string from Tkinter import * Modified: python/branches/py3k/Lib/idlelib/keybindingDialog.py ============================================================================== --- python/branches/py3k/Lib/idlelib/keybindingDialog.py (original) +++ python/branches/py3k/Lib/idlelib/keybindingDialog.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,7 @@ """ from Tkinter import * import tkMessageBox -import string, os +import string class GetKeysDialog(Toplevel): def __init__(self,parent,title,action,currentKeySequences): Modified: python/branches/py3k/Lib/idlelib/run.py ============================================================================== --- python/branches/py3k/Lib/idlelib/run.py (original) +++ python/branches/py3k/Lib/idlelib/run.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,4 @@ import sys -import os import linecache import time import socket Modified: python/branches/py3k/Lib/lib-tk/tkSimpleDialog.py ============================================================================== --- python/branches/py3k/Lib/lib-tk/tkSimpleDialog.py (original) +++ python/branches/py3k/Lib/lib-tk/tkSimpleDialog.py Sat Feb 23 19:30:17 2008 @@ -26,7 +26,6 @@ ''' from Tkinter import * -import os class Dialog(Toplevel): Modified: python/branches/py3k/Lib/logging/handlers.py ============================================================================== --- python/branches/py3k/Lib/logging/handlers.py (original) +++ python/branches/py3k/Lib/logging/handlers.py Sat Feb 23 19:30:17 2008 @@ -24,8 +24,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, socket, os, struct, time, glob -import pickle +import logging, socket, os, pickle, struct, time, glob from stat import ST_DEV, ST_INO try: Modified: python/branches/py3k/Lib/ntpath.py ============================================================================== --- python/branches/py3k/Lib/ntpath.py (original) +++ python/branches/py3k/Lib/ntpath.py Sat Feb 23 19:30:17 2008 @@ -6,8 +6,8 @@ """ import os -import stat import sys +import stat import genericpath from genericpath import * Modified: python/branches/py3k/Lib/plat-mac/MiniAEFrame.py ============================================================================== --- python/branches/py3k/Lib/plat-mac/MiniAEFrame.py (original) +++ python/branches/py3k/Lib/plat-mac/MiniAEFrame.py Sat Feb 23 19:30:17 2008 @@ -6,7 +6,6 @@ only suitable for the simplest of AppleEvent servers. """ -import sys import traceback import MacOS from Carbon import AE Modified: python/branches/py3k/Lib/plat-mac/aepack.py ============================================================================== --- python/branches/py3k/Lib/plat-mac/aepack.py (original) +++ python/branches/py3k/Lib/plat-mac/aepack.py Sat Feb 23 19:30:17 2008 @@ -20,7 +20,6 @@ import io import aetypes from aetypes import mkenum, ObjectSpecifier -import os # These ones seem to be missing from AppleEvents # (they're in AERegistry.h) Modified: python/branches/py3k/Lib/plat-mac/bgenlocations.py ============================================================================== --- python/branches/py3k/Lib/plat-mac/bgenlocations.py (original) +++ python/branches/py3k/Lib/plat-mac/bgenlocations.py Sat Feb 23 19:30:17 2008 @@ -5,7 +5,7 @@ # but mac-style for MacPython, whether running on OS9 or OSX. # -import sys, os +import os Error = "bgenlocations.Error" # Modified: python/branches/py3k/Lib/plat-mac/macostools.py ============================================================================== --- python/branches/py3k/Lib/plat-mac/macostools.py (original) +++ python/branches/py3k/Lib/plat-mac/macostools.py Sat Feb 23 19:30:17 2008 @@ -7,9 +7,7 @@ from Carbon import Res from Carbon import File, Files import os -import sys import MacOS -import time try: openrf = MacOS.openrf except AttributeError: Modified: python/branches/py3k/Lib/sqlite3/test/hooks.py ============================================================================== --- python/branches/py3k/Lib/sqlite3/test/hooks.py (original) +++ python/branches/py3k/Lib/sqlite3/test/hooks.py Sat Feb 23 19:30:17 2008 @@ -21,7 +21,7 @@ # misrepresented as being the original software. # 3. This notice may not be removed or altered from any source distribution. -import os, unittest +import unittest import sqlite3 as sqlite class CollationTests(unittest.TestCase): Modified: python/branches/py3k/Lib/ssl.py ============================================================================== --- python/branches/py3k/Lib/ssl.py (original) +++ python/branches/py3k/Lib/ssl.py Sat Feb 23 19:30:17 2008 @@ -54,7 +54,7 @@ PROTOCOL_TLSv1 """ -import os, sys, textwrap +import textwrap import _ssl # if we can't import it, let the error propagate Modified: python/branches/py3k/Lib/test/fork_wait.py ============================================================================== --- python/branches/py3k/Lib/test/fork_wait.py (original) +++ python/branches/py3k/Lib/test/fork_wait.py Sat Feb 23 19:30:17 2008 @@ -10,7 +10,6 @@ """ import os, sys, time, thread, unittest -from test.test_support import TestSkipped LONGSLEEP = 2 SHORTSLEEP = 0.5 Modified: python/branches/py3k/Lib/test/list_tests.py ============================================================================== --- python/branches/py3k/Lib/test/list_tests.py (original) +++ python/branches/py3k/Lib/test/list_tests.py Sat Feb 23 19:30:17 2008 @@ -5,7 +5,6 @@ import sys import os -import unittest from test import test_support, seq_tests def CmpToKey(mycmp): Modified: python/branches/py3k/Lib/test/seq_tests.py ============================================================================== --- python/branches/py3k/Lib/test/seq_tests.py (original) +++ python/branches/py3k/Lib/test/seq_tests.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,6 @@ """ import unittest -from test import test_support import sys # Various iterables Modified: python/branches/py3k/Lib/test/test___all__.py ============================================================================== --- python/branches/py3k/Lib/test/test___all__.py (original) +++ python/branches/py3k/Lib/test/test___all__.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,5 @@ import unittest -from test.test_support import verbose, run_unittest +from test.test_support import run_unittest import sys Modified: python/branches/py3k/Lib/test/test_abc.py ============================================================================== --- python/branches/py3k/Lib/test/test_abc.py (original) +++ python/branches/py3k/Lib/test/test_abc.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,6 @@ """Unit tests for abc.py.""" -import sys import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_applesingle.py ============================================================================== --- python/branches/py3k/Lib/test/test_applesingle.py (original) +++ python/branches/py3k/Lib/test/test_applesingle.py Sat Feb 23 19:30:17 2008 @@ -5,7 +5,6 @@ import Carbon.File import MacOS import os -import sys from test import test_support import struct import applesingle Modified: python/branches/py3k/Lib/test/test_class.py ============================================================================== --- python/branches/py3k/Lib/test/test_class.py (original) +++ python/branches/py3k/Lib/test/test_class.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ "Test the functionality of Python classes implementing operators." import unittest -import sys from test import test_support Modified: python/branches/py3k/Lib/test/test_cmd.py ============================================================================== --- python/branches/py3k/Lib/test/test_cmd.py (original) +++ python/branches/py3k/Lib/test/test_cmd.py Sat Feb 23 19:30:17 2008 @@ -5,7 +5,6 @@ """ -from test import test_support import cmd import sys import trace Modified: python/branches/py3k/Lib/test/test_compare.py ============================================================================== --- python/branches/py3k/Lib/test/test_compare.py (original) +++ python/branches/py3k/Lib/test/test_compare.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,3 @@ -import sys import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_copy.py ============================================================================== --- python/branches/py3k/Lib/test/test_copy.py (original) +++ python/branches/py3k/Lib/test/test_copy.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ """Unit tests for the copy module.""" -import sys import copy import copy_reg Modified: python/branches/py3k/Lib/test/test_datetime.py ============================================================================== --- python/branches/py3k/Lib/test/test_datetime.py (original) +++ python/branches/py3k/Lib/test/test_datetime.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,6 @@ """ import os -import sys import pickle import unittest Modified: python/branches/py3k/Lib/test/test_dbm.py ============================================================================== --- python/branches/py3k/Lib/test/test_dbm.py (original) +++ python/branches/py3k/Lib/test/test_dbm.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,6 @@ Roger E. Masse """ import os -import random import dbm from dbm import error from test.test_support import verbose, verify, TestSkipped, TESTFN Modified: python/branches/py3k/Lib/test/test_dis.py ============================================================================== --- python/branches/py3k/Lib/test/test_dis.py (original) +++ python/branches/py3k/Lib/test/test_dis.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,6 @@ # Minimal tests for dis module -from test.test_support import verbose, run_unittest +from test.test_support import run_unittest import unittest import sys import dis Modified: python/branches/py3k/Lib/test/test_dummy_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_dummy_threading.py (original) +++ python/branches/py3k/Lib/test/test_dummy_threading.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,6 @@ # Create a bunch of threads, let each do some work, wait until all are done from test.test_support import verbose -import random import dummy_threading as _threading import time Modified: python/branches/py3k/Lib/test/test_email.py ============================================================================== --- python/branches/py3k/Lib/test/test_email.py (original) +++ python/branches/py3k/Lib/test/test_email.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Copyright (C) 2001-2007 Python Software Foundation # email package unit tests -import unittest # The specific tests now live in Lib/email/test from email.test.test_email import suite from test import test_support Modified: python/branches/py3k/Lib/test/test_eof.py ============================================================================== --- python/branches/py3k/Lib/test/test_eof.py (original) +++ python/branches/py3k/Lib/test/test_eof.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ #! /usr/bin/env python """test script for a few new invalid token catches""" -import os import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_extcall.py ============================================================================== --- python/branches/py3k/Lib/test/test_extcall.py (original) +++ python/branches/py3k/Lib/test/test_extcall.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,4 @@ -from test.test_support import verify, verbose, TestFailed, sortdict +from test.test_support import verify, TestFailed, sortdict from collections import UserDict, UserList def e(a, b): Modified: python/branches/py3k/Lib/test/test_fileinput.py ============================================================================== --- python/branches/py3k/Lib/test/test_fileinput.py (original) +++ python/branches/py3k/Lib/test/test_fileinput.py Sat Feb 23 19:30:17 2008 @@ -6,7 +6,7 @@ import unittest from test.test_support import verbose, TESTFN, run_unittest from test.test_support import unlink as safe_unlink -import sys, os, re +import sys, re from io import StringIO from fileinput import FileInput, hook_encoded Modified: python/branches/py3k/Lib/test/test_fractions.py ============================================================================== --- python/branches/py3k/Lib/test/test_fractions.py (original) +++ python/branches/py3k/Lib/test/test_fractions.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,7 @@ """Tests for Lib/fractions.py.""" from decimal import Decimal -from test.test_support import run_unittest, verbose +from test.test_support import run_unittest import math import operator import fractions Modified: python/branches/py3k/Lib/test/test_getargs2.py ============================================================================== --- python/branches/py3k/Lib/test/test_getargs2.py (original) +++ python/branches/py3k/Lib/test/test_getargs2.py Sat Feb 23 19:30:17 2008 @@ -1,8 +1,7 @@ import unittest from test import test_support -import sys -import warnings, re +import warnings warnings.filterwarnings("ignore", category=DeprecationWarning, message=".*integer argument expected, got float", Modified: python/branches/py3k/Lib/test/test_gzip.py ============================================================================== --- python/branches/py3k/Lib/test/test_gzip.py (original) +++ python/branches/py3k/Lib/test/test_gzip.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,7 @@ import unittest from test import test_support -import sys, os +import os import gzip Modified: python/branches/py3k/Lib/test/test_htmlparser.py ============================================================================== --- python/branches/py3k/Lib/test/test_htmlparser.py (original) +++ python/branches/py3k/Lib/test/test_htmlparser.py Sat Feb 23 19:30:17 2008 @@ -2,7 +2,6 @@ import HTMLParser import pprint -import sys import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_httplib.py ============================================================================== --- python/branches/py3k/Lib/test/test_httplib.py (original) +++ python/branches/py3k/Lib/test/test_httplib.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ import httplib import io -import sys import socket from unittest import TestCase Modified: python/branches/py3k/Lib/test/test_imp.py ============================================================================== --- python/branches/py3k/Lib/test/test_imp.py (original) +++ python/branches/py3k/Lib/test/test_imp.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,4 @@ import imp -import thread import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_index.py ============================================================================== --- python/branches/py3k/Lib/test/test_index.py (original) +++ python/branches/py3k/Lib/test/test_index.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ import unittest from test import test_support import operator -import sys maxsize = test_support.MAX_Py_ssize_t minsize = -maxsize-1 Modified: python/branches/py3k/Lib/test/test_list.py ============================================================================== --- python/branches/py3k/Lib/test/test_list.py (original) +++ python/branches/py3k/Lib/test/test_list.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,3 @@ -import unittest import sys from test import test_support, list_tests Modified: python/branches/py3k/Lib/test/test_minidom.py ============================================================================== --- python/branches/py3k/Lib/test/test_minidom.py (original) +++ python/branches/py3k/Lib/test/test_minidom.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,6 @@ import os import sys import pickle -import traceback from io import StringIO from test.test_support import verbose, run_unittest, TestSkipped import unittest @@ -791,6 +790,14 @@ "testNormalize -- single empty node removed") doc.unlink() + def testBug1433694(self): + doc = parseString("t") + node = doc.documentElement + node.childNodes[1].nodeValue = "" + node.normalize() + self.confirm(node.childNodes[-1].nextSibling == None, + "Final child's .nextSibling should be None") + def testSiblings(self): doc = parseString("text?") root = doc.documentElement Modified: python/branches/py3k/Lib/test/test_module.py ============================================================================== --- python/branches/py3k/Lib/test/test_module.py (original) +++ python/branches/py3k/Lib/test/test_module.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,6 @@ # Test the module type import unittest -from test.test_support import verbose, run_unittest +from test.test_support import run_unittest import sys ModuleType = type(sys) Modified: python/branches/py3k/Lib/test/test_modulefinder.py ============================================================================== --- python/branches/py3k/Lib/test/test_modulefinder.py (original) +++ python/branches/py3k/Lib/test/test_modulefinder.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,5 @@ import __future__ -import sys, os +import os import unittest import distutils.dir_util import tempfile Modified: python/branches/py3k/Lib/test/test_multibytecodec_support.py ============================================================================== --- python/branches/py3k/Lib/test/test_multibytecodec_support.py (original) +++ python/branches/py3k/Lib/test/test_multibytecodec_support.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,7 @@ # Common Unittest Routines for CJK codecs # -import sys, codecs, os.path +import sys, codecs import unittest, re from test import test_support from io import BytesIO Modified: python/branches/py3k/Lib/test/test_optparse.py ============================================================================== --- python/branches/py3k/Lib/test/test_optparse.py (original) +++ python/branches/py3k/Lib/test/test_optparse.py Sat Feb 23 19:30:17 2008 @@ -15,7 +15,6 @@ import unittest from io import StringIO -from pprint import pprint from test import test_support Modified: python/branches/py3k/Lib/test/test_ossaudiodev.py ============================================================================== --- python/branches/py3k/Lib/test/test_ossaudiodev.py (original) +++ python/branches/py3k/Lib/test/test_ossaudiodev.py Sat Feb 23 19:30:17 2008 @@ -1,14 +1,11 @@ from test import test_support test_support.requires('audio') -from test.test_support import verbose, findfile, TestSkipped +from test.test_support import findfile, TestSkipped import errno -import fcntl import ossaudiodev -import os import sys -import select import sunaudio import time import audioop Modified: python/branches/py3k/Lib/test/test_pickle.py ============================================================================== --- python/branches/py3k/Lib/test/test_pickle.py (original) +++ python/branches/py3k/Lib/test/test_pickle.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,4 @@ import pickle -import unittest import io from test import test_support Modified: python/branches/py3k/Lib/test/test_pkg.py ============================================================================== --- python/branches/py3k/Lib/test/test_pkg.py (original) +++ python/branches/py3k/Lib/test/test_pkg.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,6 @@ import os import tempfile import textwrap -import traceback import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_plistlib.py ============================================================================== --- python/branches/py3k/Lib/test/test_plistlib.py (original) +++ python/branches/py3k/Lib/test/test_plistlib.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,6 @@ import unittest import plistlib import os -import time import datetime from test import test_support Modified: python/branches/py3k/Lib/test/test_poll.py ============================================================================== --- python/branches/py3k/Lib/test/test_poll.py (original) +++ python/branches/py3k/Lib/test/test_poll.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,6 @@ # Test case for the os.poll() function -import sys, os, select, random, unittest +import os, select, random, unittest from test.test_support import TestSkipped, TESTFN, run_unittest try: Modified: python/branches/py3k/Lib/test/test_posix.py ============================================================================== --- python/branches/py3k/Lib/test/test_posix.py (original) +++ python/branches/py3k/Lib/test/test_posix.py Sat Feb 23 19:30:17 2008 @@ -9,7 +9,6 @@ import time import os -import sys import unittest import warnings warnings.filterwarnings('ignore', '.* potential security risk .*', Modified: python/branches/py3k/Lib/test/test_pyclbr.py ============================================================================== --- python/branches/py3k/Lib/test/test_pyclbr.py (original) +++ python/branches/py3k/Lib/test/test_pyclbr.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,7 @@ Nick Mathewson ''' from test.test_support import run_unittest -import unittest, sys +import sys from types import FunctionType, MethodType, BuiltinFunctionType import pyclbr from unittest import TestCase Modified: python/branches/py3k/Lib/test/test_resource.py ============================================================================== --- python/branches/py3k/Lib/test/test_resource.py (original) +++ python/branches/py3k/Lib/test/test_resource.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ import unittest from test import test_support -import os import resource import time Modified: python/branches/py3k/Lib/test/test_rfc822.py ============================================================================== --- python/branches/py3k/Lib/test/test_rfc822.py (original) +++ python/branches/py3k/Lib/test/test_rfc822.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,4 @@ import rfc822 -import sys import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_scriptpackages.py ============================================================================== --- python/branches/py3k/Lib/test/test_scriptpackages.py (original) +++ python/branches/py3k/Lib/test/test_scriptpackages.py Sat Feb 23 19:30:17 2008 @@ -1,9 +1,6 @@ # Copyright (C) 2003 Python Software Foundation import unittest -import os -import sys -import tempfile from test import test_support import aetools Modified: python/branches/py3k/Lib/test/test_sgmllib.py ============================================================================== --- python/branches/py3k/Lib/test/test_sgmllib.py (original) +++ python/branches/py3k/Lib/test/test_sgmllib.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,3 @@ -import htmlentitydefs import pprint import re import sgmllib @@ -116,7 +115,7 @@ try: events = self.get_events(source) except: - import sys + #import sys #print >>sys.stderr, pprint.pformat(self.events) raise if events != expected_events: Modified: python/branches/py3k/Lib/test/test_site.py ============================================================================== --- python/branches/py3k/Lib/test/test_site.py (original) +++ python/branches/py3k/Lib/test/test_site.py Sat Feb 23 19:30:17 2008 @@ -5,12 +5,11 @@ """ import unittest -from test.test_support import TestSkipped, TestFailed, run_unittest, TESTFN +from test.test_support import TestSkipped, run_unittest, TESTFN import builtins import os import sys import encodings -import tempfile # Need to make sure to not import 'site' if someone specified ``-S`` at the # command-line. Detect this by just making sure 'site' has not been imported # already. Modified: python/branches/py3k/Lib/test/test_socketserver.py ============================================================================== --- python/branches/py3k/Lib/test/test_socketserver.py (original) +++ python/branches/py3k/Lib/test/test_socketserver.py Sat Feb 23 19:30:17 2008 @@ -9,7 +9,6 @@ import select import time import threading -from functools import wraps import unittest import SocketServer Modified: python/branches/py3k/Lib/test/test_sqlite.py ============================================================================== --- python/branches/py3k/Lib/test/test_sqlite.py (original) +++ python/branches/py3k/Lib/test/test_sqlite.py Sat Feb 23 19:30:17 2008 @@ -1,5 +1,4 @@ from test.test_support import run_unittest, TestSkipped -import unittest try: import _sqlite3 Modified: python/branches/py3k/Lib/test/test_strftime.py ============================================================================== --- python/branches/py3k/Lib/test/test_strftime.py (original) +++ python/branches/py3k/Lib/test/test_strftime.py Sat Feb 23 19:30:17 2008 @@ -2,7 +2,7 @@ # Sanity checker for time.strftime -import time, calendar, sys, os, re +import time, calendar, sys, re from test.test_support import verbose def main(): Modified: python/branches/py3k/Lib/test/test_support.py ============================================================================== --- python/branches/py3k/Lib/test/test_support.py (original) +++ python/branches/py3k/Lib/test/test_support.py Sat Feb 23 19:30:17 2008 @@ -10,7 +10,6 @@ import os import os.path import warnings -import types import unittest class Error(Exception): Modified: python/branches/py3k/Lib/test/test_tuple.py ============================================================================== --- python/branches/py3k/Lib/test/test_tuple.py (original) +++ python/branches/py3k/Lib/test/test_tuple.py Sat Feb 23 19:30:17 2008 @@ -1,4 +1,3 @@ -import unittest from test import test_support, seq_tests class TupleTest(seq_tests.CommonTest): Modified: python/branches/py3k/Lib/test/test_unpack.py ============================================================================== --- python/branches/py3k/Lib/test/test_unpack.py (original) +++ python/branches/py3k/Lib/test/test_unpack.py Sat Feb 23 19:30:17 2008 @@ -122,7 +122,6 @@ __test__ = {'doctests' : doctests} def test_main(verbose=False): - import sys from test import test_support from test import test_unpack test_support.run_doctest(test_unpack, verbose) Modified: python/branches/py3k/Lib/test/test_urllib.py ============================================================================== --- python/branches/py3k/Lib/test/test_urllib.py (original) +++ python/branches/py3k/Lib/test/test_urllib.py Sat Feb 23 19:30:17 2008 @@ -8,10 +8,6 @@ import os import mimetools import tempfile -import ftplib -import threading -import socket -import time def hexescape(char): """Escape char as RFC 2396 specifies""" Modified: python/branches/py3k/Lib/test/test_urllib2.py ============================================================================== --- python/branches/py3k/Lib/test/test_urllib2.py (original) +++ python/branches/py3k/Lib/test/test_urllib2.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,7 @@ import unittest from test import test_support -import os, socket +import os import io import urllib2 @@ -584,7 +584,7 @@ self.assertEqual(int(headers["Content-length"]), len(data)) def test_file(self): - import time, rfc822, socket + import rfc822, socket h = urllib2.FileHandler() o = h.parent = MockOpener() @@ -988,7 +988,7 @@ def _test_basic_auth(self, opener, auth_handler, auth_header, realm, http_handler, password_manager, request_url, protected_url): - import base64, httplib + import base64 user, password = "wile", "coyote" # .add_password() fed through to password manager Modified: python/branches/py3k/Lib/test/test_urllib2_localnet.py ============================================================================== --- python/branches/py3k/Lib/test/test_urllib2_localnet.py (original) +++ python/branches/py3k/Lib/test/test_urllib2_localnet.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ #!/usr/bin/env python -import sys import threading import urlparse import urllib2 Modified: python/branches/py3k/Lib/test/test_userdict.py ============================================================================== --- python/branches/py3k/Lib/test/test_userdict.py (original) +++ python/branches/py3k/Lib/test/test_userdict.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ # Check every path through every method of UserDict -import unittest from test import test_support, mapping_tests import collections Modified: python/branches/py3k/Lib/test/test_userlist.py ============================================================================== --- python/branches/py3k/Lib/test/test_userlist.py (original) +++ python/branches/py3k/Lib/test/test_userlist.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Check every path through every method of UserList from collections import UserList -import unittest from test import test_support, list_tests class UserListTest(list_tests.CommonTest): Modified: python/branches/py3k/Lib/test/test_userstring.py ============================================================================== --- python/branches/py3k/Lib/test/test_userstring.py (original) +++ python/branches/py3k/Lib/test/test_userstring.py Sat Feb 23 19:30:17 2008 @@ -2,7 +2,6 @@ # UserString is a wrapper around the native builtin string type. # UserString instances should behave similar to builtin string objects. -import unittest import string from test import test_support, string_tests Modified: python/branches/py3k/Lib/test/test_whichdb.py ============================================================================== --- python/branches/py3k/Lib/test/test_whichdb.py (original) +++ python/branches/py3k/Lib/test/test_whichdb.py Sat Feb 23 19:30:17 2008 @@ -8,7 +8,6 @@ import unittest import whichdb import anydbm -import tempfile import glob from test.test_anydbm import delete_files, dbm_iterator Modified: python/branches/py3k/Lib/test/test_xml_etree.py ============================================================================== --- python/branches/py3k/Lib/test/test_xml_etree.py (original) +++ python/branches/py3k/Lib/test/test_xml_etree.py Sat Feb 23 19:30:17 2008 @@ -2,7 +2,8 @@ # all included components work as they should. For a more extensive # test suite, see the selftest script in the ElementTree distribution. -import doctest, sys +import doctest +import sys from test import test_support Modified: python/branches/py3k/Lib/test/test_xml_etree_c.py ============================================================================== --- python/branches/py3k/Lib/test/test_xml_etree_c.py (original) +++ python/branches/py3k/Lib/test/test_xml_etree_c.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,7 @@ # xml.etree test for cElementTree -import doctest, sys +import doctest +import sys from test import test_support Modified: python/branches/py3k/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k/Lib/test/test_xmlrpc.py Sat Feb 23 19:30:17 2008 @@ -26,10 +26,6 @@ (2005, 2, 10, 11, 41, 23, 0, 1, -1)), 'datetime3': xmlrpclib.DateTime( datetime.datetime(2005, 2, 10, 11, 41, 23)), - 'datetime4': xmlrpclib.DateTime( - datetime.date(2005, 2, 10)), - 'datetime5': xmlrpclib.DateTime( - datetime.time(11, 41, 23)), }] class XMLRPCTestCase(unittest.TestCase): @@ -53,34 +49,14 @@ (newdt,), m = xmlrpclib.loads(s, use_datetime=0) self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23')) - def test_dump_bare_date(self): - # This checks that an unwrapped datetime.date object can be handled - # by the marshalling code. This can't be done via test_dump_load() - # since the unmarshaller produces a datetime object - d = datetime.datetime(2005, 2, 10, 11, 41, 23).date() - s = xmlrpclib.dumps((d,)) - (newd,), m = xmlrpclib.loads(s, use_datetime=1) - self.assertEquals(newd.date(), d) - self.assertEquals(newd.time(), datetime.time(0, 0, 0)) - self.assertEquals(m, None) - - (newdt,), m = xmlrpclib.loads(s, use_datetime=0) - self.assertEquals(newdt, xmlrpclib.DateTime('20050210T00:00:00')) - - def test_dump_bare_time(self): - # This checks that an unwrapped datetime.time object can be handled - # by the marshalling code. This can't be done via test_dump_load() - # since the unmarshaller produces a datetime object - t = datetime.datetime(2005, 2, 10, 11, 41, 23).time() - s = xmlrpclib.dumps((t,)) - (newt,), m = xmlrpclib.loads(s, use_datetime=1) - today = datetime.datetime.now().date().strftime("%Y%m%d") - self.assertEquals(newt.time(), t) - self.assertEquals(newt.date(), datetime.datetime.now().date()) - self.assertEquals(m, None) - - (newdt,), m = xmlrpclib.loads(s, use_datetime=0) - self.assertEquals(newdt, xmlrpclib.DateTime('%sT11:41:23'%today)) + def test_cmp_datetime_DateTime(self): + now = datetime.datetime.now() + dt = xmlrpclib.DateTime(now.timetuple()) + self.assert_(dt == now) + self.assert_(now == dt) + then = now + datetime.timedelta(seconds=4) + self.assert_(then >= dt) + self.assert_(dt < then) def test_bug_1164912 (self): d = xmlrpclib.DateTime() @@ -201,21 +177,6 @@ t = xmlrpclib.DateTime(d) self.assertEqual(str(t), '20070102T03:04:05') - def test_datetime_date(self): - d = datetime.date(2007,9,8) - t = xmlrpclib.DateTime(d) - self.assertEqual(str(t), '20070908T00:00:00') - - def test_datetime_time(self): - d = datetime.time(13,17,19) - # allow for date rollover by checking today's or tomorrow's dates - dd1 = datetime.datetime.now().date() - dd2 = dd1 + datetime.timedelta(days=1) - vals = (dd1.strftime('%Y%m%dT13:17:19'), - dd2.strftime('%Y%m%dT13:17:19')) - t = xmlrpclib.DateTime(d) - self.assertEqual(str(t) in vals, True) - def test_repr(self): d = datetime.datetime(2007,1,2,3,4,5) t = xmlrpclib.DateTime(d) Modified: python/branches/py3k/Lib/xml/dom/minidom.py ============================================================================== --- python/branches/py3k/Lib/xml/dom/minidom.py (original) +++ python/branches/py3k/Lib/xml/dom/minidom.py Sat Feb 23 19:30:17 2008 @@ -204,6 +204,8 @@ L.append(child) if child.nodeType == Node.ELEMENT_NODE: child.normalize() + if L: + L[-1].nextSibling = None self.childNodes[:] = L def cloneNode(self, deep): Modified: python/branches/py3k/Lib/xmlrpclib.py ============================================================================== --- python/branches/py3k/Lib/xmlrpclib.py (original) +++ python/branches/py3k/Lib/xmlrpclib.py Sat Feb 23 19:30:17 2008 @@ -298,13 +298,6 @@ if datetime and isinstance(value, datetime.datetime): self.value = value.strftime("%Y%m%dT%H:%M:%S") return - if datetime and isinstance(value, datetime.date): - self.value = value.strftime("%Y%m%dT%H:%M:%S") - return - if datetime and isinstance(value, datetime.time): - today = datetime.datetime.now().strftime("%Y%m%d") - self.value = value.strftime(today+"T%H:%M:%S") - return if not isinstance(value, (tuple, time.struct_time)): if value == 0: value = time.time() @@ -312,15 +305,57 @@ value = time.strftime("%Y%m%dT%H:%M:%S", value) self.value = value - def __eq__(self, other): + def make_comparable(self, other): if isinstance(other, DateTime): - other = other.value - return self.value == other + s = self.value + o = other.value + elif datetime and isinstance(other, datetime.datetime): + s = self.value + o = other.strftime("%Y%m%dT%H:%M:%S") + elif isinstance(other, (str, unicode)): + s = self.value + o = other + elif hasattr(other, "timetuple"): + s = self.timetuple() + o = other.timetuple() + else: + otype = (hasattr(other, "__class__") + and other.__class__.__name__ + or type(other)) + raise TypeError("Can't compare %s and %s" % + (self.__class__.__name__, otype)) + return s, o + + def __lt__(self, other): + s, o = self.make_comparable(other) + return s < o + + def __le__(self, other): + s, o = self.make_comparable(other) + return s <= o + + def __gt__(self, other): + s, o = self.make_comparable(other) + return s > o + + def __ge__(self, other): + s, o = self.make_comparable(other) + return s >= o + + def __eq__(self, other): + s, o = self.make_comparable(other) + return s == o def __ne__(self, other): - if isinstance(other, DateTime): - other = other.value - return self.value != other + s, o = self.make_comparable(other) + return s != o + + def timetuple(self): + return time.strptime(self.value, "%Y%m%dT%H:%M:%S") + + def __cmp__(self, other): + s, o = self.make_comparable(other) + return cmp(s, o) ## # Get date/time value. @@ -669,19 +704,6 @@ write("\n") dispatch[datetime.datetime] = dump_datetime - def dump_date(self, value, write): - write("") - write(value.strftime("%Y%m%dT00:00:00")) - write("\n") - dispatch[datetime.date] = dump_date - - def dump_time(self, value, write): - write("") - write(datetime.datetime.now().date().strftime("%Y%m%dT")) - write(value.strftime("%H:%M:%S")) - write("\n") - dispatch[datetime.time] = dump_time - def dump_instance(self, value, write): # check for special wrappers if value.__class__ in WRAPPERS: Modified: python/branches/py3k/Mac/Demo/PICTbrowse/ICONbrowse.py ============================================================================== --- python/branches/py3k/Mac/Demo/PICTbrowse/ICONbrowse.py (original) +++ python/branches/py3k/Mac/Demo/PICTbrowse/ICONbrowse.py Sat Feb 23 19:30:17 2008 @@ -7,8 +7,6 @@ from Carbon import Win from Carbon import Controls from Carbon import List -import sys -import struct from Carbon import Icn import macresource Modified: python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse.py ============================================================================== --- python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse.py (original) +++ python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse.py Sat Feb 23 19:30:17 2008 @@ -7,7 +7,6 @@ from Carbon import Win from Carbon import Controls from Carbon import List -import sys import struct import macresource Modified: python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse2.py ============================================================================== --- python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse2.py (original) +++ python/branches/py3k/Mac/Demo/PICTbrowse/PICTbrowse2.py Sat Feb 23 19:30:17 2008 @@ -7,7 +7,6 @@ from Carbon import Win from Carbon import Controls from Carbon import List -import sys import struct import macresource Modified: python/branches/py3k/Mac/Demo/PICTbrowse/cicnbrowse.py ============================================================================== --- python/branches/py3k/Mac/Demo/PICTbrowse/cicnbrowse.py (original) +++ python/branches/py3k/Mac/Demo/PICTbrowse/cicnbrowse.py Sat Feb 23 19:30:17 2008 @@ -7,8 +7,6 @@ from Carbon import Win from Carbon import Controls from Carbon import List -import sys -import struct from Carbon import Icn import macresource Modified: python/branches/py3k/Mac/Demo/PICTbrowse/oldPICTbrowse.py ============================================================================== --- python/branches/py3k/Mac/Demo/PICTbrowse/oldPICTbrowse.py (original) +++ python/branches/py3k/Mac/Demo/PICTbrowse/oldPICTbrowse.py Sat Feb 23 19:30:17 2008 @@ -6,7 +6,6 @@ from Carbon import Qd from Carbon import Win from Carbon import List -import sys import struct import macresource Modified: python/branches/py3k/Mac/Demo/example1/dnslookup-1.py ============================================================================== --- python/branches/py3k/Mac/Demo/example1/dnslookup-1.py (original) +++ python/branches/py3k/Mac/Demo/example1/dnslookup-1.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,6 @@ import EasyDialogs from Carbon import Res from Carbon import Dlg -import sys import socket import string import macresource Modified: python/branches/py3k/Mac/Demo/example2/dnslookup-2.py ============================================================================== --- python/branches/py3k/Mac/Demo/example2/dnslookup-2.py (original) +++ python/branches/py3k/Mac/Demo/example2/dnslookup-2.py Sat Feb 23 19:30:17 2008 @@ -2,7 +2,6 @@ import EasyDialogs from Carbon import Res from Carbon import Dlg -import sys import socket import string import macresource Modified: python/branches/py3k/Mac/Demo/imgbrowse/imgbrowse.py ============================================================================== --- python/branches/py3k/Mac/Demo/imgbrowse/imgbrowse.py (original) +++ python/branches/py3k/Mac/Demo/imgbrowse/imgbrowse.py Sat Feb 23 19:30:17 2008 @@ -7,11 +7,9 @@ from Carbon import QuickDraw from Carbon import Win #ifrom Carbon mport List -import sys import struct import img import imgformat -import struct import mac_image Modified: python/branches/py3k/Mac/Demo/imgbrowse/mac_image.py ============================================================================== --- python/branches/py3k/Mac/Demo/imgbrowse/mac_image.py (original) +++ python/branches/py3k/Mac/Demo/imgbrowse/mac_image.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ """mac_image - Helper routines (hacks) for images""" import imgformat from Carbon import Qd -import time import struct import MacOS Modified: python/branches/py3k/Mac/Modules/ae/aescan.py ============================================================================== --- python/branches/py3k/Mac/Modules/ae/aescan.py (original) +++ python/branches/py3k/Mac/Modules/ae/aescan.py Sat Feb 23 19:30:17 2008 @@ -3,8 +3,6 @@ # (Should learn how to tell the compiler to compile it as well.) import sys -import os -import string import MacOS from bgenlocations import TOOLBOXDIR, BGENDIR Modified: python/branches/py3k/Mac/Modules/ah/ahscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/ah/ahscan.py (original) +++ python/branches/py3k/Mac/Modules/ah/ahscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner_OSX Modified: python/branches/py3k/Mac/Modules/app/appscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/app/appscan.py (original) +++ python/branches/py3k/Mac/Modules/app/appscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py (original) +++ python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py Sat Feb 23 19:30:17 2008 @@ -1,8 +1,6 @@ # IBCarbonscan.py import sys -import os -import string import MacOS import sys Modified: python/branches/py3k/Mac/Modules/cf/cfscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/cf/cfscan.py (original) +++ python/branches/py3k/Mac/Modules/cf/cfscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner_OSX Modified: python/branches/py3k/Mac/Modules/cg/cgscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/cg/cgscan.py (original) +++ python/branches/py3k/Mac/Modules/cg/cgscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner_OSX Modified: python/branches/py3k/Mac/Modules/cm/cmscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/cm/cmscan.py (original) +++ python/branches/py3k/Mac/Modules/cm/cmscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/ctl/ctlscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/ctl/ctlscan.py (original) +++ python/branches/py3k/Mac/Modules/ctl/ctlscan.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ # Scan , generating ctlgen.py. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/dlg/dlgscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/dlg/dlgscan.py (original) +++ python/branches/py3k/Mac/Modules/dlg/dlgscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/drag/dragscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/drag/dragscan.py (original) +++ python/branches/py3k/Mac/Modules/drag/dragscan.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ # Scan , generating draggen.py. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR, INCLUDEDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/evt/evtscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/evt/evtscan.py (original) +++ python/branches/py3k/Mac/Modules/evt/evtscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/file/filescan.py ============================================================================== --- python/branches/py3k/Mac/Modules/file/filescan.py (original) +++ python/branches/py3k/Mac/Modules/file/filescan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner_OSX Modified: python/branches/py3k/Mac/Modules/fm/fmscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/fm/fmscan.py (original) +++ python/branches/py3k/Mac/Modules/fm/fmscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/folder/folderscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/folder/folderscan.py (original) +++ python/branches/py3k/Mac/Modules/folder/folderscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner_OSX Modified: python/branches/py3k/Mac/Modules/help/helpscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/help/helpscan.py (original) +++ python/branches/py3k/Mac/Modules/help/helpscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py (original) +++ python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py Sat Feb 23 19:30:17 2008 @@ -1,8 +1,6 @@ # IBCarbonscan.py import sys -import os -import string from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/icn/icnscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/icn/icnscan.py (original) +++ python/branches/py3k/Mac/Modules/icn/icnscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/launch/launchscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/launch/launchscan.py (original) +++ python/branches/py3k/Mac/Modules/launch/launchscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/list/listscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/list/listscan.py (original) +++ python/branches/py3k/Mac/Modules/list/listscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/menu/menuscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/menu/menuscan.py (original) +++ python/branches/py3k/Mac/Modules/menu/menuscan.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ # Scan , generating menugen.py. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/mlte/mltescan.py ============================================================================== --- python/branches/py3k/Mac/Modules/mlte/mltescan.py (original) +++ python/branches/py3k/Mac/Modules/mlte/mltescan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner_OSX Modified: python/branches/py3k/Mac/Modules/osa/osascan.py ============================================================================== --- python/branches/py3k/Mac/Modules/osa/osascan.py (original) +++ python/branches/py3k/Mac/Modules/osa/osascan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/qd/qdscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/qd/qdscan.py (original) +++ python/branches/py3k/Mac/Modules/qd/qdscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py (original) +++ python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/qt/qtscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/qt/qtscan.py (original) +++ python/branches/py3k/Mac/Modules/qt/qtscan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/res/resscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/res/resscan.py (original) +++ python/branches/py3k/Mac/Modules/res/resscan.py Sat Feb 23 19:30:17 2008 @@ -3,8 +3,6 @@ # (Should learn how to tell the compiler to compile it as well.) import sys -import os -import string import MacOS from bgenlocations import TOOLBOXDIR, BGENDIR Modified: python/branches/py3k/Mac/Modules/scrap/scrapscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/scrap/scrapscan.py (original) +++ python/branches/py3k/Mac/Modules/scrap/scrapscan.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,6 @@ # generates a boilerplate to be edited by hand. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/snd/sndscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/snd/sndscan.py (original) +++ python/branches/py3k/Mac/Modules/snd/sndscan.py Sat Feb 23 19:30:17 2008 @@ -3,7 +3,6 @@ # (Should learn how to tell the compiler to compile it as well.) import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Mac/Modules/te/tescan.py ============================================================================== --- python/branches/py3k/Mac/Modules/te/tescan.py (original) +++ python/branches/py3k/Mac/Modules/te/tescan.py Sat Feb 23 19:30:17 2008 @@ -1,7 +1,6 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) from scantools import Scanner Modified: python/branches/py3k/Mac/Modules/win/winscan.py ============================================================================== --- python/branches/py3k/Mac/Modules/win/winscan.py (original) +++ python/branches/py3k/Mac/Modules/win/winscan.py Sat Feb 23 19:30:17 2008 @@ -1,6 +1,5 @@ # Scan an Apple header file, generating a Python file of generator calls. import sys -import os from bgenlocations import TOOLBOXDIR, BGENDIR sys.path.append(BGENDIR) Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Sat Feb 23 19:30:17 2008 @@ -277,6 +277,7 @@ Jochen Hayek Christian Heimes Thomas Heller +Malte Helmert Lance Finn Helsten Jonathan Hendry James Henstridge Modified: python/branches/py3k/Modules/syslogmodule.c ============================================================================== --- python/branches/py3k/Modules/syslogmodule.c (original) +++ python/branches/py3k/Modules/syslogmodule.c Sat Feb 23 19:30:17 2008 @@ -100,9 +100,10 @@ message = PyUnicode_AsString(message_object); if (message == NULL) return NULL; + Py_BEGIN_ALLOW_THREADS; syslog(priority, "%s", message); - Py_INCREF(Py_None); - return Py_None; + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } static PyObject * Modified: python/branches/py3k/PC/VS8.0/build_tkinter.py ============================================================================== --- python/branches/py3k/PC/VS8.0/build_tkinter.py (original) +++ python/branches/py3k/PC/VS8.0/build_tkinter.py Sat Feb 23 19:30:17 2008 @@ -7,7 +7,6 @@ import os import sys -import shutil here = os.path.abspath(os.path.dirname(__file__)) par = os.path.pardir Modified: python/branches/py3k/PCbuild/build_tkinter.py ============================================================================== --- python/branches/py3k/PCbuild/build_tkinter.py (original) +++ python/branches/py3k/PCbuild/build_tkinter.py Sat Feb 23 19:30:17 2008 @@ -7,7 +7,6 @@ import os import sys -import shutil here = os.path.abspath(os.path.dirname(__file__)) par = os.path.pardir Modified: python/branches/py3k/Parser/asdl_c.py ============================================================================== --- python/branches/py3k/Parser/asdl_c.py (original) +++ python/branches/py3k/Parser/asdl_c.py Sat Feb 23 19:30:17 2008 @@ -4,7 +4,7 @@ # TO DO # handle fields that have a type but no name -import os, sys, traceback +import os, sys import asdl Modified: python/branches/py3k/Parser/spark.py ============================================================================== --- python/branches/py3k/Parser/spark.py (original) +++ python/branches/py3k/Parser/spark.py Sat Feb 23 19:30:17 2008 @@ -22,7 +22,6 @@ __version__ = 'SPARK-0.7 (pre-alpha-5)' import re -import sys # Compatability with older pythons. def output(string='', end='\n'): Modified: python/branches/py3k/Python/Python-ast.c ============================================================================== --- python/branches/py3k/Python/Python-ast.c (original) +++ python/branches/py3k/Python/Python-ast.c Sat Feb 23 19:30:17 2008 @@ -2,7 +2,7 @@ /* - __version__ 57783. + __version__ 60978. This module must be committed separately after each AST grammar change; The __version__ number is set to the revision number of the commit @@ -3171,7 +3171,7 @@ if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) return; - if (PyModule_AddStringConstant(m, "__version__", "57783") < 0) + if (PyModule_AddStringConstant(m, "__version__", "60978") < 0) return; if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Sat Feb 23 19:30:17 2008 @@ -833,7 +833,7 @@ /* Helper to open a bytecode file for writing in exclusive mode */ static FILE * -open_exclusive(char *filename) +open_exclusive(char *filename, mode_t mode) { #if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) /* Use O_EXCL to avoid a race condition when another process tries to @@ -849,9 +849,9 @@ |O_BINARY /* necessary for Windows */ #endif #ifdef __VMS - , 0666, "ctxt=bin", "shr=nil" + , mode, "ctxt=bin", "shr=nil" #else - , 0666 + , mode #endif ); if (fd < 0) @@ -870,11 +870,13 @@ remove the file. */ static void -write_compiled_module(PyCodeObject *co, char *cpathname, time_t mtime) +write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat) { FILE *fp; + time_t mtime = srcstat->st_mtime; + mode_t mode = srcstat->st_mode; - fp = open_exclusive(cpathname); + fp = open_exclusive(cpathname, mode); if (fp == NULL) { if (Py_VerboseFlag) PySys_WriteStderr( @@ -911,17 +913,16 @@ static PyObject * load_source_module(char *name, char *pathname, FILE *fp) { - time_t mtime; + struct stat st; FILE *fpc; char buf[MAXPATHLEN+1]; char *cpathname; PyCodeObject *co; PyObject *m; - - mtime = PyOS_GetLastModificationTime(pathname, fp); - if (mtime == (time_t)(-1)) { + + if (fstat(fileno(fp), &st) != 0) { PyErr_Format(PyExc_RuntimeError, - "unable to get modification time from '%s'", + "unable to get file status from '%s'", pathname); return NULL; } @@ -930,7 +931,7 @@ in 4 bytes. This will be fine until sometime in the year 2038, when a 4-byte signed time_t will overflow. */ - if (mtime >> 32) { + if (st.st_mtime >> 32) { PyErr_SetString(PyExc_OverflowError, "modification time overflows a 4 byte field"); return NULL; @@ -939,7 +940,7 @@ cpathname = make_compiled_pathname(pathname, buf, (size_t)MAXPATHLEN + 1); if (cpathname != NULL && - (fpc = check_compiled_module(pathname, mtime, cpathname))) { + (fpc = check_compiled_module(pathname, st.st_mtime, cpathname))) { co = read_compiled_module(cpathname, fpc); fclose(fpc); if (co == NULL) @@ -959,7 +960,7 @@ if (cpathname) { PyObject *ro = PySys_GetObject("dont_write_bytecode"); if (ro == NULL || !PyObject_IsTrue(ro)) - write_compiled_module(co, cpathname, mtime); + write_compiled_module(co, cpathname, &st); } } m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname); Modified: python/branches/py3k/Python/mystrtoul.c ============================================================================== --- python/branches/py3k/Python/mystrtoul.c (original) +++ python/branches/py3k/Python/mystrtoul.c Sat Feb 23 19:30:17 2008 @@ -5,14 +5,6 @@ #define _SGI_MP_SOURCE #endif -/* Convert a possibly signed character to a nonnegative int */ -/* XXX This assumes characters are 8 bits wide */ -#ifdef __CHAR_UNSIGNED__ -#define Py_CHARMASK(c) (c) -#else -#define Py_CHARMASK(c) ((c) & 0xff) -#endif - /* strtol and strtoul, renamed to avoid conflicts */ Modified: python/branches/py3k/Tools/faqwiz/faqw.py ============================================================================== --- python/branches/py3k/Tools/faqwiz/faqw.py (original) +++ python/branches/py3k/Tools/faqwiz/faqw.py Sat Feb 23 19:30:17 2008 @@ -20,7 +20,7 @@ try: FAQDIR = "/usr/people/guido/python/FAQ" SRCDIR = "/usr/people/guido/python/src/Tools/faqwiz" - import os, sys, time, operator + import os, sys os.chdir(FAQDIR) sys.path.insert(0, SRCDIR) import faqwiz Modified: python/branches/py3k/Tools/modulator/Tkextra.py ============================================================================== --- python/branches/py3k/Tools/modulator/Tkextra.py (original) +++ python/branches/py3k/Tools/modulator/Tkextra.py Sat Feb 23 19:30:17 2008 @@ -218,7 +218,6 @@ 0, 'Save', 'Save as text')) def _test(): - import sys global mainWidget mainWidget = Frame() Pack.config(mainWidget) Modified: python/branches/py3k/Tools/pybench/systimes.py ============================================================================== --- python/branches/py3k/Tools/pybench/systimes.py (original) +++ python/branches/py3k/Tools/pybench/systimes.py Sat Feb 23 19:30:17 2008 @@ -31,7 +31,7 @@ the author. All Rights Reserved. """ -import time, sys, struct +import time, sys # # Note: Please keep this module compatible to Python 1.5.2. Modified: python/branches/py3k/Tools/pynche/ChipViewer.py ============================================================================== --- python/branches/py3k/Tools/pynche/ChipViewer.py (original) +++ python/branches/py3k/Tools/pynche/ChipViewer.py Sat Feb 23 19:30:17 2008 @@ -13,7 +13,6 @@ selected and nearest ChipWidgets. """ -from types import StringType from Tkinter import * import ColorDB Modified: python/branches/py3k/Tools/pynche/TypeinViewer.py ============================================================================== --- python/branches/py3k/Tools/pynche/TypeinViewer.py (original) +++ python/branches/py3k/Tools/pynche/TypeinViewer.py Sat Feb 23 19:30:17 2008 @@ -12,8 +12,6 @@ you must hit Return or Tab to select the color. """ -import sys -import re from Tkinter import * Modified: python/branches/py3k/Tools/scripts/logmerge.py ============================================================================== --- python/branches/py3k/Tools/scripts/logmerge.py (original) +++ python/branches/py3k/Tools/scripts/logmerge.py Sat Feb 23 19:30:17 2008 @@ -34,7 +34,7 @@ from their output. """ -import os, sys, errno, getopt, re +import sys, errno, getopt, re sep1 = '='*77 + '\n' # file separator sep2 = '-'*28 + '\n' # revision separator Modified: python/branches/py3k/Tools/scripts/nm2def.py ============================================================================== --- python/branches/py3k/Tools/scripts/nm2def.py (original) +++ python/branches/py3k/Tools/scripts/nm2def.py Sat Feb 23 19:30:17 2008 @@ -34,7 +34,7 @@ option to produce this format (since it is the original v7 Unix format). """ -import os,re,sys +import os, sys PYTHONLIB = 'libpython'+sys.version[:3]+'.a' PC_PYTHONLIB = 'Python'+sys.version[0]+sys.version[2]+'.dll' Modified: python/branches/py3k/Tools/scripts/pindent.py ============================================================================== --- python/branches/py3k/Tools/scripts/pindent.py (original) +++ python/branches/py3k/Tools/scripts/pindent.py Sat Feb 23 19:30:17 2008 @@ -81,7 +81,6 @@ TABSIZE = 8 EXPANDTABS = 0 -import os import re import sys Modified: python/branches/py3k/Tools/scripts/pysource.py ============================================================================== --- python/branches/py3k/Tools/scripts/pysource.py (original) +++ python/branches/py3k/Tools/scripts/pysource.py Sat Feb 23 19:30:17 2008 @@ -20,7 +20,7 @@ __all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_python_files"] -import sys, os, re +import os, re binary_re = re.compile('[\x00-\x08\x0E-\x1F\x7F]') Modified: python/branches/py3k/Tools/scripts/xxci.py ============================================================================== --- python/branches/py3k/Tools/scripts/xxci.py (original) +++ python/branches/py3k/Tools/scripts/xxci.py Sat Feb 23 19:30:17 2008 @@ -7,7 +7,6 @@ import sys import os from stat import * -import commands import fnmatch EXECMAGIC = '\001\140\000\010' Modified: python/branches/py3k/Tools/ssl/get-remote-certificate.py ============================================================================== --- python/branches/py3k/Tools/ssl/get-remote-certificate.py (original) +++ python/branches/py3k/Tools/ssl/get-remote-certificate.py Sat Feb 23 19:30:17 2008 @@ -6,7 +6,7 @@ # # By Bill Janssen. -import sys, os +import sys def fetch_server_certificate (host, port): Modified: python/branches/py3k/Tools/unicode/gencodec.py ============================================================================== --- python/branches/py3k/Tools/unicode/gencodec.py (original) +++ python/branches/py3k/Tools/unicode/gencodec.py Sat Feb 23 19:30:17 2008 @@ -26,7 +26,7 @@ """#" -import re, os, time, marshal, codecs +import re, os, marshal, codecs # Maximum allowed size of charmap tables MAX_TABLE_SIZE = 8192 Modified: python/branches/py3k/Tools/webchecker/wcgui.py ============================================================================== --- python/branches/py3k/Tools/webchecker/wcgui.py (original) +++ python/branches/py3k/Tools/webchecker/wcgui.py Sat Feb 23 19:30:17 2008 @@ -63,7 +63,6 @@ from Tkinter import * import tktools import webchecker -import random # Override some for a weaker platform if sys.platform == 'mac': Modified: python/branches/py3k/Tools/webchecker/wsgui.py ============================================================================== --- python/branches/py3k/Tools/webchecker/wsgui.py (original) +++ python/branches/py3k/Tools/webchecker/wsgui.py Sat Feb 23 19:30:17 2008 @@ -7,9 +7,7 @@ """ from Tkinter import * -import Tkinter import websucker -import sys import os import threading import Queue From python-3000-checkins at python.org Sun Feb 24 01:38:50 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 24 Feb 2008 01:38:50 +0100 (CET) Subject: [Python-3000-checkins] r61036 - in python/branches/py3k: Demo/tkinter/guido/ShellWindow.py Doc/Makefile Doc/README.txt Doc/conf.py Doc/library/modulefinder.rst Doc/library/msilib.rst Doc/library/operator.rst Doc/library/thread.rst Doc/library/threading.rst Doc/library/xml.dom.rst Lib/imaplib.py Lib/test/test_bisect.py Lib/test/test_heapq.py Lib/test/test_mutex.py Lib/test/test_operator.py Lib/test/test_threading.py Lib/threading.py Modules/operator.c Python/Python-ast.c Python/import.c Message-ID: <20080224003850.B12AC1E4016@bag.python.org> Author: christian.heimes Date: Sun Feb 24 01:38:49 2008 New Revision: 61036 Added: python/branches/py3k/Lib/test/test_mutex.py - copied unchanged from r61033, python/trunk/Lib/test/test_mutex.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/tkinter/guido/ShellWindow.py python/branches/py3k/Doc/Makefile python/branches/py3k/Doc/README.txt python/branches/py3k/Doc/conf.py python/branches/py3k/Doc/library/modulefinder.rst python/branches/py3k/Doc/library/msilib.rst python/branches/py3k/Doc/library/operator.rst python/branches/py3k/Doc/library/thread.rst python/branches/py3k/Doc/library/threading.rst python/branches/py3k/Doc/library/xml.dom.rst python/branches/py3k/Lib/imaplib.py python/branches/py3k/Lib/test/test_bisect.py python/branches/py3k/Lib/test/test_heapq.py python/branches/py3k/Lib/test/test_operator.py python/branches/py3k/Lib/test/test_threading.py python/branches/py3k/Lib/threading.py python/branches/py3k/Modules/operator.c python/branches/py3k/Python/Python-ast.c python/branches/py3k/Python/import.c Log: Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........ Modified: python/branches/py3k/Demo/tkinter/guido/ShellWindow.py ============================================================================== --- python/branches/py3k/Demo/tkinter/guido/ShellWindow.py (original) +++ python/branches/py3k/Demo/tkinter/guido/ShellWindow.py Sun Feb 24 01:38:49 2008 @@ -121,11 +121,7 @@ sys.stderr.write('popen2: bad write dup\n') if os.dup(c2pwrite) != 2: sys.stderr.write('popen2: bad write dup\n') - for i in range(3, MAXFD): - try: - os.close(i) - except: - pass + os.closerange(3, MAXFD) try: os.execvp(prog, args) finally: Modified: python/branches/py3k/Doc/Makefile ============================================================================== --- python/branches/py3k/Doc/Makefile (original) +++ python/branches/py3k/Doc/Makefile Sun Feb 24 01:38:49 2008 @@ -12,7 +12,7 @@ ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \ $(SPHINXOPTS) . build/$(BUILDER) -.PHONY: help checkout update build html web htmlhelp clean +.PHONY: help checkout update build html web htmlhelp clean coverage help: @echo "Please use \`make ' where is one of" @@ -22,6 +22,7 @@ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @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" checkout: @if [ ! -d tools/sphinx ]; then \ @@ -74,9 +75,13 @@ linkcheck: BUILDER = linkcheck linkcheck: build - @echo "Link check complete; look for any errors in the above output "\ + @echo "Link check complete; look for any errors in the above output " \ "or in build/$(BUILDER)/output.txt" +coverage: BUILDER = coverage +coverage: build + @echo "Coverage finished; see c.txt and python.txt in build/coverage" + clean: -rm -rf build/* -rm -rf tools/sphinx Modified: python/branches/py3k/Doc/README.txt ============================================================================== --- python/branches/py3k/Doc/README.txt (original) +++ python/branches/py3k/Doc/README.txt Sun Feb 24 01:38:49 2008 @@ -64,6 +64,9 @@ deprecated items in the current version. This is meant as a help for the writer of the "What's New" document. + * "coverage", which builds a coverage overview for standard library modules + and C API. + A "make update" updates the Subversion checkouts in `tools/`. Modified: python/branches/py3k/Doc/conf.py ============================================================================== --- python/branches/py3k/Doc/conf.py (original) +++ python/branches/py3k/Doc/conf.py Sun Feb 24 01:38:49 2008 @@ -13,7 +13,7 @@ # General configuration # --------------------- -extensions = ['sphinx.addons.refcounting'] +extensions = ['sphinx.addons.refcounting', 'sphinx.addons.coverage'] # General substitutions. project = 'Python' @@ -140,3 +140,39 @@ # Documents to append as an appendix to all manuals. latex_appendices = ['glossary', 'about', 'license', 'copyright'] + +# Options for the coverage checker +# -------------------------------- + +# The coverage checker will ignore all modules/functions/classes whose names +# match any of the following regexes (using re.match). +coverage_ignore_modules = [ + r'[T|t][k|K]', + r'Tix', + r'distutils.*', +] + +coverage_ignore_functions = [ + 'test($|_)', +] + +coverage_ignore_classes = [ +] + +# Glob patterns for C source files for C API coverage, relative to this directory. +coverage_c_path = [ + '../Include/*.h', +] + +# Regexes to find C items in the source files. +coverage_c_regexes = { + 'cfunction': (r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'), + 'data': (r'^PyAPI_DATA\(.*\)\s+([^_][\w_]+)'), + 'macro': (r'^#define ([^_][\w_]+)\(.*\)[\s|\\]'), +} + +# The coverage checker will ignore all C items whose names match these regexes +# (using re.match) -- the keys must be the same as in coverage_c_regexes. +coverage_ignore_c_items = { +# 'cfunction': [...] +} Modified: python/branches/py3k/Doc/library/modulefinder.rst ============================================================================== --- python/branches/py3k/Doc/library/modulefinder.rst (original) +++ python/branches/py3k/Doc/library/modulefinder.rst Sun Feb 24 01:38:49 2008 @@ -48,3 +48,65 @@ Analyze the contents of the *pathname* file, which must contain Python code. +.. attribute:: ModuleFinder.modules + + A dictionary mapping module names to modules. See :ref:`modulefinder-example` + + +.. _modulefinder-example: + +Example usage of :class:`ModuleFinder` +-------------------------------------- + +The script that is going to get analyzed later on (bacon.py):: + + import re, itertools + + try: + import baconhameggs + except ImportError: + pass + + try: + import guido.python.ham + except ImportError: + pass + + +The script that will output the report of bacon.py:: + + from modulefinder import ModuleFinder + + finder = ModuleFinder() + finder.run_script('bacon.py') + + print 'Loaded modules:' + for name, mod in finder.modules.iteritems(): + print '%s: ' % name, + print ','.join(mod.globalnames.keys()[:3]) + + print '-'*50 + print 'Modules not imported:' + print '\n'.join(finder.badmodules.iterkeys()) + +Sample output (may vary depending on the architecture):: + + Loaded modules: + _types: + copy_reg: _inverted_registry,_slotnames,__all__ + sre_compile: isstring,_sre,_optimize_unicode + _sre: + sre_constants: REPEAT_ONE,makedict,AT_END_LINE + sys: + re: __module__,finditer,_expand + itertools: + __main__: re,itertools,baconhameggs + sre_parse: __getslice__,_PATTERNENDERS,SRE_FLAG_UNICODE + array: + types: __module__,IntType,TypeType + --------------------------------------------------- + Modules not imported: + guido.python.ham + baconhameggs + + Modified: python/branches/py3k/Doc/library/msilib.rst ============================================================================== --- python/branches/py3k/Doc/library/msilib.rst (original) +++ python/branches/py3k/Doc/library/msilib.rst Sun Feb 24 01:38:49 2008 @@ -65,7 +65,7 @@ .. function:: init_database(name, schema, ProductName, ProductCode, ProductVersion, Manufacturer) - Create and return a new database *name*, initialize it with *schema*, and set + Create and return a new database *name*, initialize it with *schema*, and set the properties *ProductName*, *ProductCode*, *ProductVersion*, and *Manufacturer*. @@ -77,13 +77,20 @@ function returns. -.. function:: add_data(database, records) +.. function:: add_data(database, table, records) - Add all *records* to *database*. *records* should be a list of tuples, each one - containing all fields of a record according to the schema of the table. For - optional fields, ``None`` can be passed. + Add all *records* to the table named *table* in *database*. - Field values can be integers, strings, or instances of the Binary class. + The *table* argument must be one of the predefined tables in the MSI schema, + e.g. ``'Feature'``, ``'File'``, ``'Component'``, ``'Dialog'``, ``'Control'``, + etc. + + *records* should be a list of tuples, each one containing all fields of a + record according to the schema of the table. For optional fields, + ``None`` can be passed. + + Field values can be int or long numbers, strings, or instances of the Binary + class. .. class:: Binary(filename) Modified: python/branches/py3k/Doc/library/operator.rst ============================================================================== --- python/branches/py3k/Doc/library/operator.rst (original) +++ python/branches/py3k/Doc/library/operator.rst Sun Feb 24 01:38:49 2008 @@ -419,10 +419,12 @@ Return a callable object that fetches *attr* from its operand. If more than one attribute is requested, returns a tuple of attributes. After, - ``f=attrgetter('name')``, the call ``f(b)`` returns ``b.name``. After, - ``f=attrgetter('name', 'date')``, the call ``f(b)`` returns ``(b.name, + ``f = attrgetter('name')``, the call ``f(b)`` returns ``b.name``. After, + ``f = attrgetter('name', 'date')``, the call ``f(b)`` returns ``(b.name, b.date)``. + The attribute names can also contain dots; after ``f = attrgetter('date.month')``, + the call ``f(b)`` returns ``b.date.month``. .. function:: itemgetter(item[, args...]) @@ -443,6 +445,15 @@ [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)] +.. function:: methodcaller(name[, args...]) + + Return a callable object that calls the method *name* on its operand. If + additional arguments and/or keyword arguments are given, they will be given + to the method as well. After ``f = methodcaller('name')``, the call ``f(b)`` + returns ``b.name()``. After ``f = methodcaller('name', 'foo', bar=1)``, the + call ``f(b)`` returns ``b.name('foo', bar=1)``. + + .. _operator-map: Mapping Operators to Functions Modified: python/branches/py3k/Doc/library/thread.rst ============================================================================== --- python/branches/py3k/Doc/library/thread.rst (original) +++ python/branches/py3k/Doc/library/thread.rst Sun Feb 24 01:38:49 2008 @@ -147,6 +147,11 @@ exception will be received by an arbitrary thread. (When the :mod:`signal` module is available, interrupts always go to the main thread.) +* The import machinery is not thread safe. In general, an import may not + have the side effect of importing a module, and only the main thread + should import modules. Imports within or caused by a thread other than + the main thread isn't safe. + * Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is equivalent to calling :func:`exit`. @@ -167,4 +172,3 @@ * When the main thread exits, it does not do any of its usual cleanup (except that :keyword:`try` ... :keyword:`finally` clauses are honored), and the standard I/O files are not flushed. - Modified: python/branches/py3k/Doc/library/threading.rst ============================================================================== --- python/branches/py3k/Doc/library/threading.rst (original) +++ python/branches/py3k/Doc/library/threading.rst Sun Feb 24 01:38:49 2008 @@ -555,6 +555,13 @@ There is a "main thread" object; this corresponds to the initial thread of control in the Python program. It is not a daemon thread. +.. warning:: + + The import machinery is not thread safe. In general, an import may not + have the side effect of importing a module, and only the main thread + should import modules. Imports within or caused by a thread other than + the main thread isn't safe. + There is the possibility that "dummy thread objects" are created. These are thread objects corresponding to "alien threads", which are threads of control started outside the threading module, such as directly from C code. Dummy Modified: python/branches/py3k/Doc/library/xml.dom.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.dom.rst (original) +++ python/branches/py3k/Doc/library/xml.dom.rst Sun Feb 24 01:38:49 2008 @@ -641,8 +641,8 @@ .. method:: Element.removeAttribute(name) - Remove an attribute by name. No exception is raised if there is no matching - attribute. + Remove an attribute by name. If there is no matching attribute, a + :exc:`NotFoundErr` is raised. .. method:: Element.removeAttributeNode(oldAttr) Modified: python/branches/py3k/Lib/imaplib.py ============================================================================== --- python/branches/py3k/Lib/imaplib.py (original) +++ python/branches/py3k/Lib/imaplib.py Sun Feb 24 01:38:49 2008 @@ -1151,6 +1151,52 @@ self.file = self.sock.makefile('rb') + def read(self, size): + """Read 'size' bytes from remote.""" + # sslobj.read() sometimes returns < size bytes + chunks = [] + read = 0 + while read < size: + data = self.sslobj.read(min(size-read, 16384)) + read += len(data) + chunks.append(data) + + return b''.join(chunks) + + + def readline(self): + """Read line from remote.""" + line = [] + while 1: + char = self.sslobj.read(1) + line.append(char) + if char == b"\n": return b''.join(line) + + + def send(self, data): + """Send data to remote.""" + bytes = len(data) + while bytes > 0: + sent = self.sslobj.write(data) + if sent == bytes: + break # avoid copy + data = data[sent:] + bytes = bytes - sent + + + def shutdown(self): + """Close I/O established in "open".""" + self.sock.close() + + + def socket(self): + """Return socket instance used to connect to IMAP4 server. + + socket = .socket() + """ + return self.sock + + def ssl(self): """Return SSLObject instance used to communicate with the IMAP4 server. Modified: python/branches/py3k/Lib/test/test_bisect.py ============================================================================== --- python/branches/py3k/Lib/test/test_bisect.py (original) +++ python/branches/py3k/Lib/test/test_bisect.py Sun Feb 24 01:38:49 2008 @@ -1,91 +1,113 @@ +import sys import unittest from test import test_support -from bisect import bisect_right, bisect_left, insort_left, insort_right, insort, bisect from collections import UserList +# We do a bit of trickery here to be able to test both the C implementation +# and the Python implementation of the module. + +# Make it impossible to import the C implementation anymore. +sys.modules['_bisect'] = 0 +# We must also handle the case that bisect was imported before. +if 'bisect' in sys.modules: + del sys.modules['bisect'] + +# Now we can import the module and get the pure Python implementation. +import bisect as py_bisect + +# Restore everything to normal. +del sys.modules['_bisect'] +del sys.modules['bisect'] + +# This is now the module with the C implementation. +import bisect as c_bisect + + class TestBisect(unittest.TestCase): + module = None - precomputedCases = [ - (bisect_right, [], 1, 0), - (bisect_right, [1], 0, 0), - (bisect_right, [1], 1, 1), - (bisect_right, [1], 2, 1), - (bisect_right, [1, 1], 0, 0), - (bisect_right, [1, 1], 1, 2), - (bisect_right, [1, 1], 2, 2), - (bisect_right, [1, 1, 1], 0, 0), - (bisect_right, [1, 1, 1], 1, 3), - (bisect_right, [1, 1, 1], 2, 3), - (bisect_right, [1, 1, 1, 1], 0, 0), - (bisect_right, [1, 1, 1, 1], 1, 4), - (bisect_right, [1, 1, 1, 1], 2, 4), - (bisect_right, [1, 2], 0, 0), - (bisect_right, [1, 2], 1, 1), - (bisect_right, [1, 2], 1.5, 1), - (bisect_right, [1, 2], 2, 2), - (bisect_right, [1, 2], 3, 2), - (bisect_right, [1, 1, 2, 2], 0, 0), - (bisect_right, [1, 1, 2, 2], 1, 2), - (bisect_right, [1, 1, 2, 2], 1.5, 2), - (bisect_right, [1, 1, 2, 2], 2, 4), - (bisect_right, [1, 1, 2, 2], 3, 4), - (bisect_right, [1, 2, 3], 0, 0), - (bisect_right, [1, 2, 3], 1, 1), - (bisect_right, [1, 2, 3], 1.5, 1), - (bisect_right, [1, 2, 3], 2, 2), - (bisect_right, [1, 2, 3], 2.5, 2), - (bisect_right, [1, 2, 3], 3, 3), - (bisect_right, [1, 2, 3], 4, 3), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 1), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 3), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 6), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 10), - (bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10), - - (bisect_left, [], 1, 0), - (bisect_left, [1], 0, 0), - (bisect_left, [1], 1, 0), - (bisect_left, [1], 2, 1), - (bisect_left, [1, 1], 0, 0), - (bisect_left, [1, 1], 1, 0), - (bisect_left, [1, 1], 2, 2), - (bisect_left, [1, 1, 1], 0, 0), - (bisect_left, [1, 1, 1], 1, 0), - (bisect_left, [1, 1, 1], 2, 3), - (bisect_left, [1, 1, 1, 1], 0, 0), - (bisect_left, [1, 1, 1, 1], 1, 0), - (bisect_left, [1, 1, 1, 1], 2, 4), - (bisect_left, [1, 2], 0, 0), - (bisect_left, [1, 2], 1, 0), - (bisect_left, [1, 2], 1.5, 1), - (bisect_left, [1, 2], 2, 1), - (bisect_left, [1, 2], 3, 2), - (bisect_left, [1, 1, 2, 2], 0, 0), - (bisect_left, [1, 1, 2, 2], 1, 0), - (bisect_left, [1, 1, 2, 2], 1.5, 2), - (bisect_left, [1, 1, 2, 2], 2, 2), - (bisect_left, [1, 1, 2, 2], 3, 4), - (bisect_left, [1, 2, 3], 0, 0), - (bisect_left, [1, 2, 3], 1, 0), - (bisect_left, [1, 2, 3], 1.5, 1), - (bisect_left, [1, 2, 3], 2, 1), - (bisect_left, [1, 2, 3], 2.5, 2), - (bisect_left, [1, 2, 3], 3, 2), - (bisect_left, [1, 2, 3], 4, 3), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 0), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 1), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 3), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 6), - (bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10) - ] + def setUp(self): + self.precomputedCases = [ + (self.module.bisect_right, [], 1, 0), + (self.module.bisect_right, [1], 0, 0), + (self.module.bisect_right, [1], 1, 1), + (self.module.bisect_right, [1], 2, 1), + (self.module.bisect_right, [1, 1], 0, 0), + (self.module.bisect_right, [1, 1], 1, 2), + (self.module.bisect_right, [1, 1], 2, 2), + (self.module.bisect_right, [1, 1, 1], 0, 0), + (self.module.bisect_right, [1, 1, 1], 1, 3), + (self.module.bisect_right, [1, 1, 1], 2, 3), + (self.module.bisect_right, [1, 1, 1, 1], 0, 0), + (self.module.bisect_right, [1, 1, 1, 1], 1, 4), + (self.module.bisect_right, [1, 1, 1, 1], 2, 4), + (self.module.bisect_right, [1, 2], 0, 0), + (self.module.bisect_right, [1, 2], 1, 1), + (self.module.bisect_right, [1, 2], 1.5, 1), + (self.module.bisect_right, [1, 2], 2, 2), + (self.module.bisect_right, [1, 2], 3, 2), + (self.module.bisect_right, [1, 1, 2, 2], 0, 0), + (self.module.bisect_right, [1, 1, 2, 2], 1, 2), + (self.module.bisect_right, [1, 1, 2, 2], 1.5, 2), + (self.module.bisect_right, [1, 1, 2, 2], 2, 4), + (self.module.bisect_right, [1, 1, 2, 2], 3, 4), + (self.module.bisect_right, [1, 2, 3], 0, 0), + (self.module.bisect_right, [1, 2, 3], 1, 1), + (self.module.bisect_right, [1, 2, 3], 1.5, 1), + (self.module.bisect_right, [1, 2, 3], 2, 2), + (self.module.bisect_right, [1, 2, 3], 2.5, 2), + (self.module.bisect_right, [1, 2, 3], 3, 3), + (self.module.bisect_right, [1, 2, 3], 4, 3), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 1), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 3), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 6), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 10), + (self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10), + + (self.module.bisect_left, [], 1, 0), + (self.module.bisect_left, [1], 0, 0), + (self.module.bisect_left, [1], 1, 0), + (self.module.bisect_left, [1], 2, 1), + (self.module.bisect_left, [1, 1], 0, 0), + (self.module.bisect_left, [1, 1], 1, 0), + (self.module.bisect_left, [1, 1], 2, 2), + (self.module.bisect_left, [1, 1, 1], 0, 0), + (self.module.bisect_left, [1, 1, 1], 1, 0), + (self.module.bisect_left, [1, 1, 1], 2, 3), + (self.module.bisect_left, [1, 1, 1, 1], 0, 0), + (self.module.bisect_left, [1, 1, 1, 1], 1, 0), + (self.module.bisect_left, [1, 1, 1, 1], 2, 4), + (self.module.bisect_left, [1, 2], 0, 0), + (self.module.bisect_left, [1, 2], 1, 0), + (self.module.bisect_left, [1, 2], 1.5, 1), + (self.module.bisect_left, [1, 2], 2, 1), + (self.module.bisect_left, [1, 2], 3, 2), + (self.module.bisect_left, [1, 1, 2, 2], 0, 0), + (self.module.bisect_left, [1, 1, 2, 2], 1, 0), + (self.module.bisect_left, [1, 1, 2, 2], 1.5, 2), + (self.module.bisect_left, [1, 1, 2, 2], 2, 2), + (self.module.bisect_left, [1, 1, 2, 2], 3, 4), + (self.module.bisect_left, [1, 2, 3], 0, 0), + (self.module.bisect_left, [1, 2, 3], 1, 0), + (self.module.bisect_left, [1, 2, 3], 1.5, 1), + (self.module.bisect_left, [1, 2, 3], 2, 1), + (self.module.bisect_left, [1, 2, 3], 2.5, 2), + (self.module.bisect_left, [1, 2, 3], 3, 2), + (self.module.bisect_left, [1, 2, 3], 4, 3), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 0), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 1), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 3), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 6), + (self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10) + ] def test_precomputed(self): for func, data, elem, expected in self.precomputedCases: @@ -98,12 +120,12 @@ data = [randrange(0, n, 2) for j in range(i)] data.sort() elem = randrange(-1, n+1) - ip = bisect_left(data, elem) + ip = self.module.bisect_left(data, elem) if ip < len(data): self.failUnless(elem <= data[ip]) if ip > 0: self.failUnless(data[ip-1] < elem) - ip = bisect_right(data, elem) + ip = self.module.bisect_right(data, elem) if ip < len(data): self.failUnless(elem < data[ip]) if ip > 0: @@ -117,32 +139,39 @@ hi = min(len(data), hi) ip = func(data, elem, lo, hi) self.failUnless(lo <= ip <= hi) - if func is bisect_left and ip < hi: + if func is self.module.bisect_left and ip < hi: self.failUnless(elem <= data[ip]) - if func is bisect_left and ip > lo: + if func is self.module.bisect_left and ip > lo: self.failUnless(data[ip-1] < elem) - if func is bisect_right and ip < hi: + if func is self.module.bisect_right and ip < hi: self.failUnless(elem < data[ip]) - if func is bisect_right and ip > lo: + if func is self.module.bisect_right and ip > lo: self.failUnless(data[ip-1] <= elem) self.assertEqual(ip, max(lo, min(hi, expected))) def test_backcompatibility(self): - self.assertEqual(bisect, bisect_right) + self.assertEqual(self.module.bisect, self.module.bisect_right) def test_keyword_args(self): data = [10, 20, 30, 40, 50] - self.assertEqual(bisect_left(a=data, x=25, lo=1, hi=3), 2) - self.assertEqual(bisect_right(a=data, x=25, lo=1, hi=3), 2) - self.assertEqual(bisect(a=data, x=25, lo=1, hi=3), 2) - insort_left(a=data, x=25, lo=1, hi=3) - insort_right(a=data, x=25, lo=1, hi=3) - insort(a=data, x=25, lo=1, hi=3) + self.assertEqual(self.module.bisect_left(a=data, x=25, lo=1, hi=3), 2) + self.assertEqual(self.module.bisect_right(a=data, x=25, lo=1, hi=3), 2) + self.assertEqual(self.module.bisect(a=data, x=25, lo=1, hi=3), 2) + self.module.insort_left(a=data, x=25, lo=1, hi=3) + self.module.insort_right(a=data, x=25, lo=1, hi=3) + self.module.insort(a=data, x=25, lo=1, hi=3) self.assertEqual(data, [10, 20, 25, 25, 25, 30, 40, 50]) +class TestBisectPython(TestBisect): + module = py_bisect + +class TestBisectC(TestBisect): + module = c_bisect + #============================================================================== class TestInsort(unittest.TestCase): + module = None def test_vsBuiltinSort(self, n=500): from random import choice @@ -150,14 +179,20 @@ for i in range(n): digit = choice("0123456789") if digit in "02468": - f = insort_left + f = self.module.insort_left else: - f = insort_right + f = self.module.insort_right f(insorted, digit) self.assertEqual(sorted(insorted), insorted) def test_backcompatibility(self): - self.assertEqual(insort, insort_right) + self.assertEqual(self.module.insort, self.module.insort_right) + +class TestInsortPython(TestInsort): + module = py_bisect + +class TestInsortC(TestInsort): + module = c_bisect #============================================================================== @@ -183,32 +218,44 @@ __ne__ = __lt__ class TestErrorHandling(unittest.TestCase): + module = None def test_non_sequence(self): - for f in (bisect_left, bisect_right, insort_left, insort_right): + for f in (self.module.bisect_left, self.module.bisect_right, + self.module.insort_left, self.module.insort_right): self.assertRaises(TypeError, f, 10, 10) def test_len_only(self): - for f in (bisect_left, bisect_right, insort_left, insort_right): + for f in (self.module.bisect_left, self.module.bisect_right, + self.module.insort_left, self.module.insort_right): self.assertRaises(TypeError, f, LenOnly(), 10) def test_get_only(self): - for f in (bisect_left, bisect_right, insort_left, insort_right): + for f in (self.module.bisect_left, self.module.bisect_right, + self.module.insort_left, self.module.insort_right): self.assertRaises(TypeError, f, GetOnly(), 10) def test_cmp_err(self): seq = [CmpErr(), CmpErr(), CmpErr()] - for f in (bisect_left, bisect_right, insort_left, insort_right): + for f in (self.module.bisect_left, self.module.bisect_right, + self.module.insort_left, self.module.insort_right): self.assertRaises(ZeroDivisionError, f, seq, 10) def test_arg_parsing(self): - for f in (bisect_left, bisect_right, insort_left, insort_right): + for f in (self.module.bisect_left, self.module.bisect_right, + self.module.insort_left, self.module.insort_right): self.assertRaises(TypeError, f, 10) +class TestErrorHandlingPython(TestErrorHandling): + module = py_bisect + +class TestErrorHandlingC(TestErrorHandling): + module = c_bisect + #============================================================================== libreftest = """ -Example from the Library Reference: Doc/lib/libbisect.tex +Example from the Library Reference: Doc/library/bisect.rst The bisect() function is generally useful for categorizing numeric data. This example uses bisect() to look up a letter grade for an exam total @@ -234,12 +281,10 @@ def test_main(verbose=None): from test import test_bisect - from types import BuiltinFunctionType - import sys - test_classes = [TestBisect, TestInsort] - if isinstance(bisect_left, BuiltinFunctionType): - test_classes.append(TestErrorHandling) + test_classes = [TestBisectPython, TestBisectC, + TestInsortPython, TestInsortC, + TestErrorHandlingPython, TestErrorHandlingC] test_support.run_unittest(*test_classes) test_support.run_doctest(test_bisect, verbose) Modified: python/branches/py3k/Lib/test/test_heapq.py ============================================================================== --- python/branches/py3k/Lib/test/test_heapq.py (original) +++ python/branches/py3k/Lib/test/test_heapq.py Sun Feb 24 01:38:49 2008 @@ -1,21 +1,32 @@ """Unittests for heapq.""" -from heapq import heappush, heappop, heapify, heapreplace, merge, nlargest, nsmallest import random import unittest from test import test_support import sys +# We do a bit of trickery here to be able to test both the C implementation +# and the Python implementation of the module. + +# Make it impossible to import the C implementation anymore. +sys.modules['_heapq'] = 0 +# We must also handle the case that heapq was imported before. +if 'heapq' in sys.modules: + del sys.modules['heapq'] + +# Now we can import the module and get the pure Python implementation. +import heapq as py_heapq + +# Restore everything to normal. +del sys.modules['_heapq'] +del sys.modules['heapq'] + +# This is now the module with the C implementation. +import heapq as c_heapq -def heapiter(heap): - # An iterator returning a heap's elements, smallest-first. - try: - while 1: - yield heappop(heap) - except IndexError: - pass class TestHeap(unittest.TestCase): + module = None def test_push_pop(self): # 1) Push 256 random numbers and pop them off, verifying all's OK. @@ -25,11 +36,11 @@ for i in range(256): item = random.random() data.append(item) - heappush(heap, item) + self.module.heappush(heap, item) self.check_invariant(heap) results = [] while heap: - item = heappop(heap) + item = self.module.heappop(heap) self.check_invariant(heap) results.append(item) data_sorted = data[:] @@ -38,10 +49,10 @@ # 2) Check that the invariant holds for a sorted array self.check_invariant(results) - self.assertRaises(TypeError, heappush, []) + self.assertRaises(TypeError, self.module.heappush, []) try: - self.assertRaises(TypeError, heappush, None, None) - self.assertRaises(TypeError, heappop, None) + self.assertRaises(TypeError, self.module.heappush, None, None) + self.assertRaises(TypeError, self.module.heappop, None) except AttributeError: pass @@ -55,21 +66,29 @@ def test_heapify(self): for size in range(30): heap = [random.random() for dummy in range(size)] - heapify(heap) + self.module.heapify(heap) self.check_invariant(heap) - self.assertRaises(TypeError, heapify, None) + self.assertRaises(TypeError, self.module.heapify, None) def test_naive_nbest(self): data = [random.randrange(2000) for i in range(1000)] heap = [] for item in data: - heappush(heap, item) + self.module.heappush(heap, item) if len(heap) > 10: - heappop(heap) + self.module.heappop(heap) heap.sort() self.assertEqual(heap, sorted(data)[-10:]) + def heapiter(self, heap): + # An iterator returning a heap's elements, smallest-first. + try: + while 1: + yield self.module.heappop(heap) + except IndexError: + pass + def test_nbest(self): # Less-naive "N-best" algorithm, much faster (if len(data) is big # enough ) than sorting all of data. However, if we had a max @@ -78,15 +97,15 @@ # (10 log-time steps). data = [random.randrange(2000) for i in range(1000)] heap = data[:10] - heapify(heap) + self.module.heapify(heap) for item in data[10:]: if item > heap[0]: # this gets rarer the longer we run - heapreplace(heap, item) - self.assertEqual(list(heapiter(heap)), sorted(data)[-10:]) + self.module.heapreplace(heap, item) + self.assertEqual(list(self.heapiter(heap)), sorted(data)[-10:]) - self.assertRaises(TypeError, heapreplace, None) - self.assertRaises(TypeError, heapreplace, None, None) - self.assertRaises(IndexError, heapreplace, [], None) + self.assertRaises(TypeError, self.module.heapreplace, None) + self.assertRaises(TypeError, self.module.heapreplace, None, None) + self.assertRaises(IndexError, self.module.heapreplace, [], None) def test_heapsort(self): # Exercise everything with repeated heapsort checks @@ -95,12 +114,12 @@ data = [random.randrange(25) for i in range(size)] if trial & 1: # Half of the time, use heapify heap = data[:] - heapify(heap) + self.module.heapify(heap) else: # The rest of the time, use heappush heap = [] for item in data: - heappush(heap, item) - heap_sorted = [heappop(heap) for i in range(size)] + self.module.heappush(heap, item) + heap_sorted = [self.module.heappop(heap) for i in range(size)] self.assertEqual(heap_sorted, sorted(data)) def test_merge(self): @@ -108,8 +127,8 @@ for i in range(random.randrange(5)): row = sorted(random.randrange(1000) for j in range(random.randrange(10))) inputs.append(row) - self.assertEqual(sorted(chain(*inputs)), list(merge(*inputs))) - self.assertEqual(list(merge()), []) + self.assertEqual(sorted(chain(*inputs)), list(self.module.merge(*inputs))) + self.assertEqual(list(self.module.merge()), []) def test_merge_stability(self): class Int(int): @@ -123,26 +142,33 @@ inputs[stream].append(obj) for stream in inputs: stream.sort() - result = [i.pair for i in merge(*inputs)] + result = [i.pair for i in self.module.merge(*inputs)] self.assertEqual(result, sorted(result)) def test_nsmallest(self): data = [(random.randrange(2000), i) for i in range(1000)] for f in (None, lambda x: x[0] * 547 % 2000): for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100): - self.assertEqual(list(nsmallest(n, data)), sorted(data)[:n]) - self.assertEqual(list(nsmallest(n, data, key=f)), + self.assertEqual(list(self.module.nsmallest(n, data)), + sorted(data)[:n]) + self.assertEqual(list(self.module.nsmallest(n, data, key=f)), sorted(data, key=f)[:n]) def test_nlargest(self): data = [(random.randrange(2000), i) for i in range(1000)] for f in (None, lambda x: x[0] * 547 % 2000): for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100): - self.assertEqual(list(nlargest(n, data)), + self.assertEqual(list(self.module.nlargest(n, data)), sorted(data, reverse=True)[:n]) - self.assertEqual(list(nlargest(n, data, key=f)), + self.assertEqual(list(self.module.nlargest(n, data, key=f)), sorted(data, key=f, reverse=True)[:n]) +class TestHeapPython(TestHeap): + module = py_heapq + +class TestHeapC(TestHeap): + module = c_heapq + #============================================================================== @@ -240,44 +266,49 @@ return chain(imap(lambda x:x, R(Ig(G(seqn))))) class TestErrorHandling(unittest.TestCase): + # only for C implementation + module = c_heapq def test_non_sequence(self): - for f in (heapify, heappop): + for f in (self.module.heapify, self.module.heappop): self.assertRaises(TypeError, f, 10) - for f in (heappush, heapreplace, nlargest, nsmallest): + for f in (self.module.heappush, self.module.heapreplace, + self.module.nlargest, self.module.nsmallest): self.assertRaises(TypeError, f, 10, 10) def test_len_only(self): - for f in (heapify, heappop): + for f in (self.module.heapify, self.module.heappop): self.assertRaises(TypeError, f, LenOnly()) - for f in (heappush, heapreplace): + for f in (self.module.heappush, self.module.heapreplace): self.assertRaises(TypeError, f, LenOnly(), 10) - for f in (nlargest, nsmallest): + for f in (self.module.nlargest, self.module.nsmallest): self.assertRaises(TypeError, f, 2, LenOnly()) def test_get_only(self): - for f in (heapify, heappop): + for f in (self.module.heapify, self.module.heappop): self.assertRaises(TypeError, f, GetOnly()) - for f in (heappush, heapreplace): + for f in (self.module.heappush, self.module.heapreplace): self.assertRaises(TypeError, f, GetOnly(), 10) - for f in (nlargest, nsmallest): + for f in (self.module.nlargest, self.module.nsmallest): self.assertRaises(TypeError, f, 2, GetOnly()) def test_get_only(self): seq = [CmpErr(), CmpErr(), CmpErr()] - for f in (heapify, heappop): + for f in (self.module.heapify, self.module.heappop): self.assertRaises(ZeroDivisionError, f, seq) - for f in (heappush, heapreplace): + for f in (self.module.heappush, self.module.heapreplace): self.assertRaises(ZeroDivisionError, f, seq, 10) - for f in (nlargest, nsmallest): + for f in (self.module.nlargest, self.module.nsmallest): self.assertRaises(ZeroDivisionError, f, 2, seq) def test_arg_parsing(self): - for f in (heapify, heappop, heappush, heapreplace, nlargest, nsmallest): + for f in (self.module.heapify, self.module.heappop, + self.module.heappush, self.module.heapreplace, + self.module.nlargest, self.module.nsmallest): self.assertRaises(TypeError, f, 10) def test_iterable_args(self): - for f in (nlargest, nsmallest): + for f in (self.module.nlargest, self.module.nsmallest): for s in ("123", "", range(1000), (1, 1.2), range(2000,2200,5)): for g in (G, I, Ig, L, R): self.assertEqual(list(f(2, g(s))), list(f(2,s))) @@ -286,15 +317,14 @@ self.assertRaises(TypeError, f, 2, N(s)) self.assertRaises(ZeroDivisionError, f, 2, E(s)) + #============================================================================== def test_main(verbose=None): from types import BuiltinFunctionType - test_classes = [TestHeap] - if isinstance(heapify, BuiltinFunctionType): - test_classes.append(TestErrorHandling) + test_classes = [TestHeapPython, TestHeapC, TestErrorHandling] test_support.run_unittest(*test_classes) # verify reference counting Modified: python/branches/py3k/Lib/test/test_operator.py ============================================================================== --- python/branches/py3k/Lib/test/test_operator.py (original) +++ python/branches/py3k/Lib/test/test_operator.py Sun Feb 24 01:38:49 2008 @@ -368,6 +368,26 @@ raise SyntaxError self.failUnlessRaises(SyntaxError, operator.attrgetter('foo'), C()) + # recursive gets + a = A() + a.name = 'arthur' + a.child = A() + a.child.name = 'thomas' + f = operator.attrgetter('child.name') + self.assertEqual(f(a), 'thomas') + self.assertRaises(AttributeError, f, a.child) + f = operator.attrgetter('name', 'child.name') + self.assertEqual(f(a), ('arthur', 'thomas')) + f = operator.attrgetter('name', 'child.name', 'child.child.name') + self.assertRaises(AttributeError, f, a) + + a.child.child = A() + a.child.child.name = 'johnson' + f = operator.attrgetter('child.child.name') + self.assertEqual(f(a), 'johnson') + f = operator.attrgetter('name', 'child.name', 'child.child.name') + self.assertEqual(f(a), ('arthur', 'thomas', 'johnson')) + def test_itemgetter(self): a = 'ABCDE' f = operator.itemgetter(2) @@ -402,6 +422,24 @@ self.assertEqual(operator.itemgetter(2,10,5)(data), ('2', '10', '5')) self.assertRaises(TypeError, operator.itemgetter(2, 'x', 5), data) + def test_methodcaller(self): + self.assertRaises(TypeError, operator.methodcaller) + class A: + def foo(self, *args, **kwds): + return args[0] + args[1] + def bar(self, f=42): + return f + a = A() + f = operator.methodcaller('foo') + self.assertRaises(IndexError, f, a) + f = operator.methodcaller('foo', 1, 2) + self.assertEquals(f(a), 3) + f = operator.methodcaller('bar') + self.assertEquals(f(a), 42) + self.assertRaises(TypeError, f, a, a) + f = operator.methodcaller('bar', f=5) + self.assertEquals(f(a), 5) + def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Sun Feb 24 01:38:49 2008 @@ -8,6 +8,7 @@ import thread import time import unittest +import weakref # A trivial mutable counter. class Counter(object): @@ -253,6 +254,33 @@ finally: sys.setcheckinterval(old_interval) + def test_no_refcycle_through_target(self): + class RunSelfFunction(object): + def __init__(self, should_raise): + # The links in this refcycle from Thread back to self + # should be cleaned up when the thread completes. + self.should_raise = should_raise + self.thread = threading.Thread(target=self._run, + args=(self,), + kwargs={'yet_another':self}) + self.thread.start() + + def _run(self, other_ref, yet_another): + if self.should_raise: + raise SystemExit + + cyclic_object = RunSelfFunction(should_raise=False) + weak_cyclic_object = weakref.ref(cyclic_object) + cyclic_object.thread.join() + del cyclic_object + self.assertEquals(None, weak_cyclic_object()) + + raising_cyclic_object = RunSelfFunction(should_raise=True) + weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) + raising_cyclic_object.thread.join() + del raising_cyclic_object + self.assertEquals(None, weak_raising_cyclic_object()) + class ThreadingExceptionTests(unittest.TestCase): # A RuntimeError should be raised if Thread.start() is called Modified: python/branches/py3k/Lib/threading.py ============================================================================== --- python/branches/py3k/Lib/threading.py (original) +++ python/branches/py3k/Lib/threading.py Sun Feb 24 01:38:49 2008 @@ -441,8 +441,13 @@ _sleep(0.000001) # 1 usec, to let the thread run (Solaris hack) def run(self): - if self._target: - self._target(*self._args, **self._kwargs) + try: + if self._target: + self._target(*self._args, **self._kwargs) + finally: + # Avoid a refcycle if the thread is running a function with + # an argument that has a member that points to the thread. + del self._target, self._args, self._kwargs def _bootstrap(self): # Wrapper around the real bootstrap code that ignores Modified: python/branches/py3k/Modules/operator.c ============================================================================== --- python/branches/py3k/Modules/operator.c (original) +++ python/branches/py3k/Modules/operator.c Sun Feb 24 01:38:49 2008 @@ -486,6 +486,41 @@ } static PyObject * +dotted_getattr(PyObject *obj, PyObject *attr) +{ + char *s, *p; + + if (!PyUnicode_Check(attr)) { + PyErr_SetString(PyExc_TypeError, + "attribute name must be a string"); + return NULL; + } + + s = PyUnicode_AsString(attr); + Py_INCREF(obj); + for (;;) { + PyObject *newobj, *str; + p = strchr(s, '.'); + str = p ? PyUnicode_FromStringAndSize(s, (p-s)) : + PyUnicode_FromString(s); + if (str == NULL) { + Py_DECREF(obj); + return NULL; + } + newobj = PyObject_GetAttr(obj, str); + Py_DECREF(str); + Py_DECREF(obj); + if (newobj == NULL) + return NULL; + obj = newobj; + if (p == NULL) break; + s = p+1; + } + + return obj; +} + +static PyObject * attrgetter_call(attrgetterobject *ag, PyObject *args, PyObject *kw) { PyObject *obj, *result; @@ -494,7 +529,7 @@ if (!PyArg_UnpackTuple(args, "attrgetter", 1, 1, &obj)) return NULL; if (ag->nattrs == 1) - return PyObject_GetAttr(obj, ag->attr); + return dotted_getattr(obj, ag->attr); assert(PyTuple_Check(ag->attr)); assert(PyTuple_GET_SIZE(ag->attr) == nattrs); @@ -506,7 +541,7 @@ for (i=0 ; i < nattrs ; i++) { PyObject *attr, *val; attr = PyTuple_GET_ITEM(ag->attr, i); - val = PyObject_GetAttr(obj, attr); + val = dotted_getattr(obj, attr); if (val == NULL) { Py_DECREF(result); return NULL; @@ -521,7 +556,9 @@ \n\ Return a callable object that fetches the given attribute(s) from its operand.\n\ After, f=attrgetter('name'), the call f(r) returns r.name.\n\ -After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date)."); +After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\ +After, h=attrgetter('name.first', 'name.last'), the call h(r) returns\n\ +(r.name.first, r.name.last)."); static PyTypeObject attrgetter_type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -565,6 +602,139 @@ attrgetter_new, /* tp_new */ 0, /* tp_free */ }; + + +/* methodcaller object **********************************************************/ + +typedef struct { + PyObject_HEAD + PyObject *name; + PyObject *args; + PyObject *kwds; +} methodcallerobject; + +static PyTypeObject methodcaller_type; + +static PyObject * +methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + methodcallerobject *mc; + PyObject *name, *newargs; + + if (PyTuple_GET_SIZE(args) < 1) { + PyErr_SetString(PyExc_TypeError, "methodcaller needs at least " + "one argument, the method name"); + return NULL; + } + + /* create methodcallerobject structure */ + mc = PyObject_GC_New(methodcallerobject, &methodcaller_type); + if (mc == NULL) + return NULL; + + newargs = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); + if (newargs == NULL) { + Py_DECREF(mc); + return NULL; + } + mc->args = newargs; + + name = PyTuple_GET_ITEM(args, 0); + Py_INCREF(name); + mc->name = name; + + Py_XINCREF(kwds); + mc->kwds = kwds; + + PyObject_GC_Track(mc); + return (PyObject *)mc; +} + +static void +methodcaller_dealloc(methodcallerobject *mc) +{ + PyObject_GC_UnTrack(mc); + Py_XDECREF(mc->name); + Py_XDECREF(mc->args); + Py_XDECREF(mc->kwds); + PyObject_GC_Del(mc); +} + +static int +methodcaller_traverse(methodcallerobject *mc, visitproc visit, void *arg) +{ + Py_VISIT(mc->args); + Py_VISIT(mc->kwds); + return 0; +} + +static PyObject * +methodcaller_call(methodcallerobject *mc, PyObject *args, PyObject *kw) +{ + PyObject *method, *obj, *result; + + if (!PyArg_UnpackTuple(args, "methodcaller", 1, 1, &obj)) + return NULL; + method = PyObject_GetAttr(obj, mc->name); + if (method == NULL) + return NULL; + result = PyObject_Call(method, mc->args, mc->kwds); + Py_DECREF(method); + return result; +} + +PyDoc_STRVAR(methodcaller_doc, +"methodcaller(name, ...) --> methodcaller object\n\ +\n\ +Return a callable object that calls the given method on its operand.\n\ +After, f = methodcaller('name'), the call f(r) returns r.name().\n\ +After, g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\ +r.name('date', foo=1)."); + +static PyTypeObject methodcaller_type = { + PyVarObject_HEAD_INIT(NULL, 0) + "operator.methodcaller", /* tp_name */ + sizeof(methodcallerobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)methodcaller_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)methodcaller_call, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ + methodcaller_doc, /* tp_doc */ + (traverseproc)methodcaller_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + methodcaller_new, /* tp_new */ + 0, /* tp_free */ +}; + + /* Initialization function for the module (*must* be called initoperator) */ PyMODINIT_FUNC @@ -587,4 +757,9 @@ return; Py_INCREF(&attrgetter_type); PyModule_AddObject(m, "attrgetter", (PyObject *)&attrgetter_type); + + if (PyType_Ready(&methodcaller_type) < 0) + return; + Py_INCREF(&methodcaller_type); + PyModule_AddObject(m, "methodcaller", (PyObject *)&methodcaller_type); } Modified: python/branches/py3k/Python/Python-ast.c ============================================================================== --- python/branches/py3k/Python/Python-ast.c (original) +++ python/branches/py3k/Python/Python-ast.c Sun Feb 24 01:38:49 2008 @@ -2,7 +2,7 @@ /* - __version__ 60978. + __version__ 57783. This module must be committed separately after each AST grammar change; The __version__ number is set to the revision number of the commit @@ -3171,7 +3171,7 @@ if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) return; - if (PyModule_AddStringConstant(m, "__version__", "60978") < 0) + if (PyModule_AddStringConstant(m, "__version__", "57783") < 0) return; if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Sun Feb 24 01:38:49 2008 @@ -22,6 +22,11 @@ extern "C" { #endif +#ifdef MS_WINDOWS +/* for stat.st_mode */ +typedef unsigned short mode_t; +#endif + extern time_t PyOS_GetLastModificationTime(char *, FILE *); /* In getmtime.c */ From python-3000-checkins at python.org Sun Feb 24 03:22:41 2008 From: python-3000-checkins at python.org (neal.norwitz) Date: Sun, 24 Feb 2008 03:22:41 +0100 (CET) Subject: [Python-3000-checkins] r61038 - python/branches/py3k Message-ID: <20080224022241.59E7D1E4016@bag.python.org> Author: neal.norwitz Date: Sun Feb 24 03:22:41 2008 New Revision: 61038 Modified: python/branches/py3k/ (props changed) Log: Blocked revisions 61037 via svnmerge ........ r61037 | neal.norwitz | 2008-02-23 18:20:25 -0800 (Sat, 23 Feb 2008) | 2 lines map(None, ...) is not supported in 3.0. ........ From python-3000-checkins at python.org Sun Feb 24 14:08:19 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 24 Feb 2008 14:08:19 +0100 (CET) Subject: [Python-3000-checkins] r61050 - in python/branches/py3k: Doc/howto/regex.rst Lib/httplib.py Lib/test/string_tests.py Lib/test/test_format.py Lib/test/test_httplib.py Misc/cheatsheet Modules/_ctypes/_ctypes_test.c Objects/unicodeobject.c Message-ID: <20080224130819.36A131E4012@bag.python.org> Author: christian.heimes Date: Sun Feb 24 14:08:18 2008 New Revision: 61050 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/howto/regex.rst python/branches/py3k/Lib/httplib.py python/branches/py3k/Lib/test/string_tests.py python/branches/py3k/Lib/test/test_format.py python/branches/py3k/Lib/test/test_httplib.py python/branches/py3k/Misc/cheatsheet python/branches/py3k/Modules/_ctypes/_ctypes_test.c python/branches/py3k/Objects/unicodeobject.c Log: Merged revisions 61034-61036,61038-61048 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61034 | georg.brandl | 2008-02-24 01:03:22 +0100 (Sun, 24 Feb 2008) | 4 lines #900744: If an invalid chunked-encoding header is sent by a server, httplib will now raise IncompleteRead and close the connection instead of raising ValueError. ........ r61035 | georg.brandl | 2008-02-24 01:14:24 +0100 (Sun, 24 Feb 2008) | 2 lines #1627: httplib now ignores negative Content-Length headers. ........ r61039 | andrew.kuchling | 2008-02-24 03:39:15 +0100 (Sun, 24 Feb 2008) | 1 line Remove stray word ........ r61040 | neal.norwitz | 2008-02-24 03:40:58 +0100 (Sun, 24 Feb 2008) | 3 lines Add a little info to the 3k deprecation warnings about what to use instead. Suggested by Raymond Hettinger. ........ r61041 | facundo.batista | 2008-02-24 04:17:21 +0100 (Sun, 24 Feb 2008) | 4 lines Issue 1742669. Now %d accepts very big float numbers. Thanks Gabriel Genellina. ........ r61046 | neal.norwitz | 2008-02-24 08:21:56 +0100 (Sun, 24 Feb 2008) | 5 lines Get ctypes working on the Alpha (Tru64). The problem was that there were two module_methods and the one used depended on the order the modules were loaded. By making the test module_methods static, it is not exported and the correct version is picked up. ........ r61048 | neal.norwitz | 2008-02-24 09:27:49 +0100 (Sun, 24 Feb 2008) | 1 line Fix typo of hexidecimal ........ Modified: python/branches/py3k/Doc/howto/regex.rst ============================================================================== --- python/branches/py3k/Doc/howto/regex.rst (original) +++ python/branches/py3k/Doc/howto/regex.rst Sun Feb 24 14:08:18 2008 @@ -203,7 +203,7 @@ | | | ``bc``. | +------+-----------+---------------------------------+ | 6 | ``abcb`` | Try ``b`` again. This time | -| | | but the character at the | +| | | the character at the | | | | current position is ``'b'``, so | | | | it succeeds. | +------+-----------+---------------------------------+ Modified: python/branches/py3k/Lib/httplib.py ============================================================================== --- python/branches/py3k/Lib/httplib.py (original) +++ python/branches/py3k/Lib/httplib.py Sun Feb 24 14:08:18 2008 @@ -448,7 +448,12 @@ try: self.length = int(length) except ValueError: - pass + self.length = None + else: + if self.length < 0: # ignore nonsensical negative lengths + self.length = None + else: + self.length = None # does the body have a fixed length? (of zero) if (status == NO_CONTENT or status == NOT_MODIFIED or @@ -569,7 +574,13 @@ i = line.find(b";") if i >= 0: line = line[:i] # strip chunk-extensions - chunk_left = int(line, 16) + try: + chunk_left = int(line, 16) + except ValueError: + # close the connection as protocol synchronisation is + # probably lost + self.close() + raise IncompleteRead(value) if chunk_left == 0: break if amt is None: Modified: python/branches/py3k/Lib/test/string_tests.py ============================================================================== --- python/branches/py3k/Lib/test/string_tests.py (original) +++ python/branches/py3k/Lib/test/string_tests.py Sun Feb 24 14:08:18 2008 @@ -1053,7 +1053,13 @@ # unicode raises ValueError, str raises OverflowError self.checkraises((ValueError, OverflowError), '%c', '__mod__', ordinal) + longvalue = sys.maxsize + 10 + slongvalue = str(longvalue) + if slongvalue[-1] in ("L","l"): slongvalue = slongvalue[:-1] self.checkequal(' 42', '%3ld', '__mod__', 42) + self.checkequal('42', '%d', '__mod__', 42.0) + self.checkequal(slongvalue, '%d', '__mod__', longvalue) + self.checkcall('%d', '__mod__', float(longvalue)) self.checkequal('0042.00', '%07.2f', '__mod__', 42) self.checkequal('0042.00', '%07.2F', '__mod__', 42) @@ -1063,6 +1069,8 @@ self.checkraises(TypeError, '%c', '__mod__', (None,)) self.checkraises(ValueError, '%(foo', '__mod__', {}) self.checkraises(TypeError, '%(foo)s %(bar)s', '__mod__', ('foo', 42)) + self.checkraises(TypeError, '%d', '__mod__', "42") # not numeric + self.checkraises(TypeError, '%d', '__mod__', (42+0j)) # no int/long conversion provided # argument names with properly nested brackets are supported self.checkequal('bar', '%((foo))s', '__mod__', {'(foo)': 'bar'}) Modified: python/branches/py3k/Lib/test/test_format.py ============================================================================== --- python/branches/py3k/Lib/test/test_format.py (original) +++ python/branches/py3k/Lib/test/test_format.py Sun Feb 24 14:08:18 2008 @@ -11,7 +11,7 @@ overflowok = 1 overflowrequired = 0 -def testformat(formatstr, args, output=None): +def testformat(formatstr, args, output=None, limit=None): if verbose: if output: print("%r %% %r =? %r ..." %\ @@ -30,11 +30,22 @@ if verbose: print('no') print("overflow expected on %r %% %r" % (formatstr, args)) - elif output and result != output: + elif output and limit is None and result != output: if verbose: print('no') print("%r %% %r == %r != %r" %\ (formatstr, args, result, output)) + # when 'limit' is specified, it determines how many characters + # must match exactly; lengths must always match. + # ex: limit=5, '12345678' matches '12345___' + # (mainly for floating point format tests for which an exact match + # can't be guaranteed due to rounding and representation errors) + elif output and limit is not None and ( + len(result)!=len(output) or result[:limit]!=output[:limit]): + if verbose: + print('no') + print("%s %% %s == %s != %s" % \ + (repr(formatstr), repr(args), repr(result), repr(output))) else: if verbose: print('yes') @@ -91,6 +102,7 @@ testformat("%.30d", big, "123456789012345678901234567890") testformat("%.31d", big, "0123456789012345678901234567890") testformat("%32.31d", big, " 0123456789012345678901234567890") +testformat("%d", float(big), "123456________________________", 6) big = 0x1234567890abcdef12345 # 21 hex digits testformat("%x", big, "1234567890abcdef12345") @@ -128,6 +140,7 @@ testformat("%#+027.23X", big, "+0X0001234567890ABCDEF12345") # same, except no 0 flag testformat("%#+27.23X", big, " +0X001234567890ABCDEF12345") +testformat("%x", float(big), "123456_______________", 6) big = 0o12345670123456701234567012345670 # 32 octal digits testformat("%o", big, "12345670123456701234567012345670") @@ -169,6 +182,7 @@ testformat("%0#38.33o", big, "0o000012345670123456701234567012345670") # padding spaces come before marker testformat("%#36.33o", big, " 0o012345670123456701234567012345670") +testformat("%o", float(big), "123456__________________________", 6) # Some small ints, in both Python int and long flavors). testformat("%d", 42, "42") @@ -186,11 +200,13 @@ testformat("%x", 0x42, "42") testformat("%x", -0x42, "-42") +testformat("%x", float(0x42), "42") testformat("%o", 0o42, "42") testformat("%o", -0o42, "-42") testformat("%o", 0o42, "42") testformat("%o", -0o42, "-42") +testformat("%o", float(0o42), "42") # Test exception for unknown format characters if verbose: Modified: python/branches/py3k/Lib/test/test_httplib.py ============================================================================== --- python/branches/py3k/Lib/test/test_httplib.py (original) +++ python/branches/py3k/Lib/test/test_httplib.py Sun Feb 24 14:08:18 2008 @@ -159,6 +159,42 @@ self.assertTrue(sock.data.startswith(expected), '%r != %r' % (sock.data[:len(expected)], expected)) + def test_chunked(self): + chunked_start = ( + 'HTTP/1.1 200 OK\r\n' + 'Transfer-Encoding: chunked\r\n\r\n' + 'a\r\n' + 'hello worl\r\n' + '1\r\n' + 'd\r\n' + ) + sock = FakeSocket(chunked_start + '0\r\n') + resp = httplib.HTTPResponse(sock, method="GET") + resp.begin() + self.assertEquals(resp.read(), b'hello world') + resp.close() + + for x in ('', 'foo\r\n'): + sock = FakeSocket(chunked_start + x) + resp = httplib.HTTPResponse(sock, method="GET") + resp.begin() + try: + resp.read() + except httplib.IncompleteRead as i: + self.assertEquals(i.partial, b'hello world') + else: + self.fail('IncompleteRead expected') + finally: + resp.close() + + def test_negative_content_length(self): + sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: -1\r\n\r\nHello\r\n') + resp = httplib.HTTPResponse(sock, method="GET") + resp.begin() + self.assertEquals(resp.read(), b'Hello\r\n') + resp.close() + + class OfflineTest(TestCase): def test_responses(self): self.assertEquals(httplib.responses[httplib.NOT_FOUND], "Not Found") Modified: python/branches/py3k/Misc/cheatsheet ============================================================================== --- python/branches/py3k/Misc/cheatsheet (original) +++ python/branches/py3k/Misc/cheatsheet Sun Feb 24 14:08:18 2008 @@ -561,8 +561,8 @@ i Signed integer decimal. o Unsigned octal. u Unsigned decimal. -x Unsigned hexidecimal (lowercase). -X Unsigned hexidecimal (uppercase). +x Unsigned hexadecimal (lowercase). +X Unsigned hexadecimal (uppercase). e Floating point exponential format (lowercase). E Floating point exponential format (uppercase). f Floating point decimal format. Modified: python/branches/py3k/Modules/_ctypes/_ctypes_test.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes_test.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes_test.c Sun Feb 24 14:08:18 2008 @@ -398,7 +398,7 @@ return 0; } -PyMethodDef module_methods[] = { +static PyMethodDef module_methods[] = { /* {"get_last_tf_arg_s", get_last_tf_arg_s, METH_NOARGS}, {"get_last_tf_arg_u", get_last_tf_arg_u, METH_NOARGS}, */ Modified: python/branches/py3k/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k/Objects/unicodeobject.c (original) +++ python/branches/py3k/Objects/unicodeobject.c Sun Feb 24 14:08:18 2008 @@ -8600,6 +8600,7 @@ int prec = -1; Py_UNICODE c = '\0'; Py_UNICODE fill; + int isnumok; PyObject *v = NULL; PyObject *temp = NULL; Py_UNICODE *pbuf; @@ -8804,21 +8805,38 @@ case 'X': if (c == 'i') c = 'd'; - if (PyLong_Check(v)) { - temp = formatlong(v, flags, prec, c); - if (!temp) - goto onError; - pbuf = PyUnicode_AS_UNICODE(temp); - len = PyUnicode_GET_SIZE(temp); - sign = 1; + isnumok = 0; + if (PyNumber_Check(v)) { + PyObject *iobj=NULL; + + if (PyLong_Check(v)) { + iobj = v; + Py_INCREF(iobj); + } + else { + iobj = PyNumber_Long(v); + } + if (iobj!=NULL) { + if (PyLong_Check(iobj)) { + isnumok = 1; + temp = formatlong(iobj, flags, prec, c); + Py_DECREF(iobj); + if (!temp) + goto onError; + pbuf = PyUnicode_AS_UNICODE(temp); + len = PyUnicode_GET_SIZE(temp); + sign = 1; + } + else { + Py_DECREF(iobj); + } + } } - else { - pbuf = formatbuf; - len = formatint(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), - flags, prec, c, v); - if (len < 0) + if (!isnumok) { + PyErr_Format(PyExc_TypeError, + "%%%c format: a number is required, " + "not %.200s", c, Py_TYPE(v)->tp_name); goto onError; - sign = 1; } if (flags & F_ZERO) fill = '0'; From python-3000-checkins at python.org Sun Feb 24 22:43:18 2008 From: python-3000-checkins at python.org (eric.smith) Date: Sun, 24 Feb 2008 22:43:18 +0100 (CET) Subject: [Python-3000-checkins] r61055 - python/branches/py3k Message-ID: <20080224214318.416431E4012@bag.python.org> Author: eric.smith Date: Sun Feb 24 22:43:18 2008 New Revision: 61055 Modified: python/branches/py3k/ (props changed) Log: Block r61054. I'll manually merge it, since it's breaking the buildbots. From python-3000-checkins at python.org Sun Feb 24 22:44:34 2008 From: python-3000-checkins at python.org (eric.smith) Date: Sun, 24 Feb 2008 22:44:34 +0100 (CET) Subject: [Python-3000-checkins] r61056 - python/branches/py3k/Objects/stringlib/string_format.h Message-ID: <20080224214434.4B2811E4012@bag.python.org> Author: eric.smith Date: Sun Feb 24 22:44:34 2008 New Revision: 61056 Modified: python/branches/py3k/Objects/stringlib/string_format.h Log: Corrected assert to check for correct type in py3k. Modified: python/branches/py3k/Objects/stringlib/string_format.h ============================================================================== --- python/branches/py3k/Objects/stringlib/string_format.h (original) +++ python/branches/py3k/Objects/stringlib/string_format.h Sun Feb 24 22:44:34 2008 @@ -494,7 +494,7 @@ goto done; #if PY_VERSION_HEX >= 0x03000000 - assert(PyString_Check(result)); + assert(PyUnicode_Check(result)); #else assert(PyString_Check(result) || PyUnicode_Check(result)); From lists at cheimes.de Sun Feb 24 22:53:41 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 24 Feb 2008 22:53:41 +0100 Subject: [Python-3000-checkins] r61055 - python/branches/py3k In-Reply-To: <20080224214318.416431E4012@bag.python.org> References: <20080224214318.416431E4012@bag.python.org> Message-ID: <47C1E765.40905@cheimes.de> eric.smith wrote: > Author: eric.smith > Date: Sun Feb 24 22:43:18 2008 > New Revision: 61055 > > Modified: > python/branches/py3k/ (props changed) > Log: > Block r61054. I'll manually merge it, since it's breaking the buildbots. You can specify the revision for svnmerge.py merge. For example you could have used "svnmerge.py merge -r 61054" instead of blocking the revision and doing a manual merge. It's not a big issue but it's probably easier :] Christian From python-3000-checkins at python.org Mon Feb 25 13:39:24 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 25 Feb 2008 13:39:24 +0100 (CET) Subject: [Python-3000-checkins] r61061 - in python/branches/py3k: Lib/bsddb/test/test_associate.py Lib/bsddb/test/test_basics.py Lib/bsddb/test/test_compare.py Lib/bsddb/test/test_cursor_pget_bug.py Lib/bsddb/test/test_dbobj.py Lib/bsddb/test/test_dbshelve.py Lib/bsddb/test/test_dbtables.py Lib/bsddb/test/test_env_close.py Lib/bsddb/test/test_join.py Lib/bsddb/test/test_lock.py Lib/bsddb/test/test_misc.py Lib/bsddb/test/test_pickle.py Lib/bsddb/test/test_recno.py Lib/bsddb/test/test_sequence.py Lib/bsddb/test/test_thread.py Lib/decimal.py Lib/test/test_bsddb3.py Lib/test/test_format.py Lib/test/test_support.py Makefile.pre.in Objects/dictobject.c Objects/listobject.c Message-ID: <20080225123924.6B7291E4012@bag.python.org> Author: christian.heimes Date: Mon Feb 25 13:39:23 2008 New Revision: 61061 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/bsddb/test/test_associate.py python/branches/py3k/Lib/bsddb/test/test_basics.py python/branches/py3k/Lib/bsddb/test/test_compare.py python/branches/py3k/Lib/bsddb/test/test_cursor_pget_bug.py python/branches/py3k/Lib/bsddb/test/test_dbobj.py python/branches/py3k/Lib/bsddb/test/test_dbshelve.py python/branches/py3k/Lib/bsddb/test/test_dbtables.py python/branches/py3k/Lib/bsddb/test/test_env_close.py python/branches/py3k/Lib/bsddb/test/test_join.py python/branches/py3k/Lib/bsddb/test/test_lock.py python/branches/py3k/Lib/bsddb/test/test_misc.py python/branches/py3k/Lib/bsddb/test/test_pickle.py python/branches/py3k/Lib/bsddb/test/test_recno.py python/branches/py3k/Lib/bsddb/test/test_sequence.py python/branches/py3k/Lib/bsddb/test/test_thread.py python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/test/test_bsddb3.py python/branches/py3k/Lib/test/test_format.py python/branches/py3k/Lib/test/test_support.py python/branches/py3k/Makefile.pre.in python/branches/py3k/Objects/dictobject.c python/branches/py3k/Objects/listobject.c Log: Merged revisions 61038,61042-61045,61047,61049-61053,61055-61057 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61049 | christian.heimes | 2008-02-24 13:26:16 +0100 (Sun, 24 Feb 2008) | 1 line Use PY_FORMAT_SIZE_T instead of z for string formatting. Thanks Neal. ........ r61051 | mark.dickinson | 2008-02-24 19:12:36 +0100 (Sun, 24 Feb 2008) | 2 lines Remove duplicate 'import re' in decimal.py ........ r61052 | neal.norwitz | 2008-02-24 19:47:03 +0100 (Sun, 24 Feb 2008) | 11 lines Create a db_home directory with a unique name so multiple users can run the test simultaneously. The simplest thing I found that worked on both Windows and Unix was to use the PID. It's unique so should be sufficient. This should prevent many of the spurious failures of the automated tests since they run as different users. Also cleanup the directory consistenly in the tearDown methods. It would be nice if someone ensured that the directories are always created with a consistent name. ........ r61057 | christian.heimes | 2008-02-24 23:48:05 +0100 (Sun, 24 Feb 2008) | 2 lines Added dependency rules for Objects/stringlib/*.h stringobject, unicodeobject and the two formatters are rebuild whenever a header files changes ........ Modified: python/branches/py3k/Lib/bsddb/test/test_associate.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_associate.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_associate.py Mon Feb 25 13:39:23 2008 @@ -92,15 +92,23 @@ class AssociateErrorTestCase(unittest.TestCase): def setUp(self): self.filename = self.__class__.__name__ + '.db' - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) + self.homeDir = homeDir + try: + os.mkdir(homeDir) + except os.error: + import glob + files = glob.glob(os.path.join(self.homeDir, '*')) + for file in files: + os.remove(file) self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL) def tearDown(self): self.env.close() self.env = None - shutil.rmtree(self.homeDir) - + from test import test_support + test_support.rmtree(self.homeDir) def test00_associateDBError(self): if verbose: @@ -141,7 +149,7 @@ def setUp(self): self.filename = self.__class__.__name__ + '.db' - homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) self.homeDir = homeDir try: os.mkdir(homeDir) Modified: python/branches/py3k/Lib/bsddb/test/test_basics.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_basics.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_basics.py Mon Feb 25 13:39:23 2008 @@ -6,10 +6,10 @@ import os import sys import errno -import shutil import string import tempfile from pprint import pprint +from test import test_support import unittest import time @@ -54,7 +54,10 @@ def setUp(self): if self.useEnv: - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) + self.homeDir = homeDir + test_support.rmtree(homeDir) + os.mkdir(homeDir) try: self.env = db.DBEnv() self.env.set_lg_max(1024*1024) @@ -68,7 +71,7 @@ tempfile.tempdir = old_tempfile_tempdir # Yes, a bare except is intended, since we're re-raising the exc. except: - shutil.rmtree(self.homeDir) + test_support.rmtree(homeDir) raise else: self.env = None @@ -92,8 +95,8 @@ def tearDown(self): self.d.close() if self.env is not None: + test_support.rmtree(self.homeDir) self.env.close() - shutil.rmtree(self.homeDir) ## Make a new DBEnv to remove the env files from the home dir. ## (It can't be done while the env is open, nor after it has been ## closed, so we make a new one to do it.) Modified: python/branches/py3k/Lib/bsddb/test/test_compare.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_compare.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_compare.py Mon Feb 25 13:39:23 2008 @@ -66,7 +66,7 @@ def setUp (self): self.filename = self.__class__.__name__ + '.db' - homeDir = os.path.join (tempfile.gettempdir(), 'db_home') + homeDir = os.path.join (tempfile.gettempdir(), 'db_home%d'%os.getpid()) self.homeDir = homeDir try: os.mkdir (homeDir) @@ -84,7 +84,8 @@ if self.env is not None: self.env.close () self.env = None - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.homeDir) def addDataToDB (self, data): i = 0 Modified: python/branches/py3k/Lib/bsddb/test/test_cursor_pget_bug.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_cursor_pget_bug.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_cursor_pget_bug.py Mon Feb 25 13:39:23 2008 @@ -14,7 +14,7 @@ db_name = 'test-cursor_pget.db' def setUp(self): - self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) try: os.mkdir(self.homeDir) except os.error: @@ -39,7 +39,8 @@ del self.secondary_db del self.primary_db del self.env - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.homeDir) def test_pget(self): cursor = self.secondary_db.cursor() Modified: python/branches/py3k/Lib/bsddb/test/test_dbobj.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_dbobj.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_dbobj.py Mon Feb 25 13:39:23 2008 @@ -2,7 +2,6 @@ import shutil import sys, os import unittest -import glob import tempfile try: @@ -20,14 +19,18 @@ db_name = 'test-dbobj.db' def setUp(self): - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) + self.homeDir = homeDir + try: os.mkdir(homeDir) + except os.error: pass def tearDown(self): if hasattr(self, 'db'): del self.db if hasattr(self, 'env'): del self.env - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.homeDir) def test01_both(self): class TestDBEnv(dbobj.DBEnv): pass Modified: python/branches/py3k/Lib/bsddb/test/test_dbshelve.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_dbshelve.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_dbshelve.py Mon Feb 25 13:39:23 2008 @@ -262,6 +262,10 @@ self.do_open() def do_open(self): + self.homeDir = homeDir = os.path.join( + tempfile.gettempdir(), 'db_home%d'%os.getpid()) + try: os.mkdir(homeDir) + except os.error: pass self.env = db.DBEnv() self.env.open(self.homeDir, self.envflags | db.DB_INIT_MPOOL | db.DB_CREATE) @@ -275,9 +279,9 @@ def tearDown(self): + from test import test_support + test_support.rmtree(self.homeDir) self.do_close() - shutil.rmtree(self.homeDir) - class EnvBTreeShelveTestCase(BasicEnvShelveTestCase): Modified: python/branches/py3k/Lib/bsddb/test/test_dbtables.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_dbtables.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_dbtables.py Mon Feb 25 13:39:23 2008 @@ -20,7 +20,6 @@ # # $Id$ -import shutil import sys, os, re import pickle import tempfile @@ -43,13 +42,18 @@ db_name = 'test-table.db' def setUp(self): - self.homeDir = tempfile.mkdtemp() + homeDir = tempfile.mkdtemp() + self.testHomeDir = homeDir + try: os.mkdir(homeDir) + except os.error: pass + self.tdb = dbtables.bsdTableDB( - filename='tabletest.db', dbhome=self.homeDir, create=1) + filename='tabletest.db', dbhome=homeDir, create=1) def tearDown(self): self.tdb.close() - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.testHomeDir) def test01(self): tabname = "test01" Modified: python/branches/py3k/Lib/bsddb/test/test_env_close.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_env_close.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_env_close.py Mon Feb 25 13:39:23 2008 @@ -6,7 +6,6 @@ import shutil import sys import tempfile -import glob import unittest try: @@ -34,15 +33,16 @@ class DBEnvClosedEarlyCrash(unittest.TestCase): def setUp(self): - self.homeDir = tempfile.mkdtemp() - old_tempfile_tempdir = tempfile.tempdir + self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) + try: os.mkdir(self.homeDir) + except os.error: pass tempfile.tempdir = self.homeDir self.filename = os.path.split(tempfile.mktemp())[1] - tempfile.tempdir = old_tempfile_tempdir + tempfile.tempdir = None def tearDown(self): - shutil.rmtree(self.homeDir) - + from test import test_support + test_support.rmtree(self.homeDir) def test01_close_dbenv_before_db(self): dbenv = db.DBEnv() Modified: python/branches/py3k/Lib/bsddb/test/test_join.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_join.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_join.py Mon Feb 25 13:39:23 2008 @@ -48,13 +48,17 @@ def setUp(self): self.filename = self.__class__.__name__ + '.db' - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) + self.homeDir = homeDir + try: os.mkdir(homeDir) + except os.error: pass self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK ) def tearDown(self): self.env.close() - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.homeDir) def test01_join(self): if verbose: Modified: python/branches/py3k/Lib/bsddb/test/test_lock.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_lock.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_lock.py Mon Feb 25 13:39:23 2008 @@ -2,9 +2,6 @@ TestCases for testing the locking sub-system. """ -import os -from pprint import pprint -import shutil import sys import tempfile import time @@ -40,7 +37,8 @@ def tearDown(self): self.env.close() - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.homeDir) def test01_simple(self): Modified: python/branches/py3k/Lib/bsddb/test/test_misc.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_misc.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_misc.py Mon Feb 25 13:39:23 2008 @@ -19,14 +19,17 @@ class MiscTestCase(unittest.TestCase): def setUp(self): self.filename = self.__class__.__name__ + '.db' - self.homeDir = tempfile.mkdtemp() - - def tearDown(self): + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) + self.homeDir = homeDir try: - os.remove(self.filename) + os.mkdir(homeDir) except OSError: pass - shutil.rmtree(self.homeDir) + + def tearDown(self): + from test import test_support + test_support.unlink(self.filename) + test_support.rmtree(self.homeDir) def test01_badpointer(self): dbs = dbshelve.open(self.filename) Modified: python/branches/py3k/Lib/bsddb/test/test_pickle.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_pickle.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_pickle.py Mon Feb 25 13:39:23 2008 @@ -5,7 +5,6 @@ import tempfile import unittest import tempfile -import glob try: # For Pythons w/distutils pybsddb @@ -22,7 +21,7 @@ db_name = 'test-dbobj.db' def setUp(self): - homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass @@ -32,7 +31,8 @@ del self.db if hasattr(self, 'env'): del self.env - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.homeDir) def _base_test_pickle_DBError(self, pickle): self.env = db.DBEnv() Modified: python/branches/py3k/Lib/bsddb/test/test_recno.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_recno.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_recno.py Mon Feb 25 13:39:23 2008 @@ -26,14 +26,13 @@ class SimpleRecnoTestCase(unittest.TestCase): def setUp(self): self.filename = tempfile.mktemp() - self.homeDir = tempfile.mkdtemp() + self.homeDir = None def tearDown(self): - try: - os.remove(self.filename) - except OSError as e: - if e.errno != errno.EEXIST: raise - shutil.rmtree(self.homeDir) + from test import test_support + test_support.unlink(self.filename) + if self.homeDir: + test_support.rmtree(self.homeDir) def test01_basic(self): d = db.DB() @@ -206,7 +205,11 @@ just a line in the file, but you can set a different record delimiter if needed. """ - source = os.path.join(self.homeDir, 'test_recno.txt') + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) + self.homeDir = homeDir + source = os.path.join(homeDir, 'test_recno.txt') + if not os.path.isdir(homeDir): + os.mkdir(homeDir) f = open(source, 'w') # create the file f.close() Modified: python/branches/py3k/Lib/bsddb/test/test_sequence.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_sequence.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_sequence.py Mon Feb 25 13:39:23 2008 @@ -3,7 +3,6 @@ import shutil import sys import tempfile -import glob try: # For Pythons w/distutils pybsddb @@ -17,7 +16,7 @@ class DBSequenceTest(unittest.TestCase): def setUp(self): self.int_32_max = 0x100000000 - self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) try: os.mkdir(self.homeDir) except os.error: @@ -42,7 +41,8 @@ self.dbenv.close() del self.dbenv - shutil.rmtree(self.homeDir) + from test import test_support + test_support.rmtree(self.homeDir) def test_get(self): self.seq = db.DBSequence(self.d, flags=0) Modified: python/branches/py3k/Lib/bsddb/test/test_thread.py ============================================================================== --- python/branches/py3k/Lib/bsddb/test/test_thread.py (original) +++ python/branches/py3k/Lib/bsddb/test/test_thread.py Mon Feb 25 13:39:23 2008 @@ -5,7 +5,6 @@ import sys import time import errno -import shutil import tempfile from pprint import pprint from random import random @@ -47,7 +46,7 @@ if verbose: dbutils._deadlock_VerboseFile = sys.stdout - homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid()) self.homeDir = homeDir try: os.mkdir(homeDir) @@ -64,12 +63,10 @@ self.d.open(self.filename, self.dbtype, self.dbopenflags|db.DB_CREATE) def tearDown(self): + from test import test_support + test_support.rmtree(self.homeDir) self.d.close() self.env.close() - try: - shutil.rmtree(self.homeDir) - except OSError as e: - if e.errno != errno.EEXIST: raise def setEnvOpts(self): pass Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Mon Feb 25 13:39:23 2008 @@ -5202,8 +5202,7 @@ ##### crud for parsing strings ############################################# -import re - +# # Regular expression used for parsing numeric strings. Additional # comments: # Modified: python/branches/py3k/Lib/test/test_bsddb3.py ============================================================================== --- python/branches/py3k/Lib/test/test_bsddb3.py (original) +++ python/branches/py3k/Lib/test/test_bsddb3.py Mon Feb 25 13:39:23 2008 @@ -2,11 +2,12 @@ """ Run all test cases. """ +import os import sys +import tempfile import time import unittest -import test.test_support -from test.test_support import requires, run_unittest, unlink +from test.test_support import requires, verbose, run_unittest, unlink, rmtree # When running as a script instead of within the regrtest framework, skip the # requires test, since it's obvious we want to run them. @@ -88,6 +89,15 @@ # For invocation through regrtest def test_main(): run_unittest(suite()) + db_home = os.path.join(tempfile.gettempdir(), 'db_home') + # The only reason to remove db_home is in case if there is an old + # one lying around. This might be by a different user, so just + # ignore errors. We should always make a unique name now. + try: + rmtree(db_home) + except: + pass + rmtree('db_home%d' % os.getpid()) # For invocation as a script if __name__ == '__main__': Modified: python/branches/py3k/Lib/test/test_format.py ============================================================================== --- python/branches/py3k/Lib/test/test_format.py (original) +++ python/branches/py3k/Lib/test/test_format.py Mon Feb 25 13:39:23 2008 @@ -234,7 +234,8 @@ test_exc(str(b'abc %\u3000', 'raw-unicode-escape'), 1, ValueError, "unsupported format character '?' (0x3000) at index 5") -test_exc('%d', '1', TypeError, "an integer is required") +#test_exc('%d', '1', TypeError, "an integer is required") +test_exc('%d', '1', TypeError, '%d format: a number is required, not str') test_exc('%g', '1', TypeError, "a float is required") test_exc('no format', '1', TypeError, "not all arguments converted during string formatting") Modified: python/branches/py3k/Lib/test/test_support.py ============================================================================== --- python/branches/py3k/Lib/test/test_support.py (original) +++ python/branches/py3k/Lib/test/test_support.py Mon Feb 25 13:39:23 2008 @@ -9,6 +9,7 @@ import sys import os import os.path +import shutil import warnings import unittest @@ -64,6 +65,14 @@ except OSError: pass +def rmtree(path): + try: + shutil.rmtree(path) + except OSError as e: + # Unix returns ENOENT, Windows returns ESRCH. + if e.errno not in (errno.ENOENT, errno.ESRCH): + raise + def forget(modname): '''"Forget" a module was ever imported by removing it from sys.modules and deleting any .pyc and .pyo files.''' Modified: python/branches/py3k/Makefile.pre.in ============================================================================== --- python/branches/py3k/Makefile.pre.in (original) +++ python/branches/py3k/Makefile.pre.in Mon Feb 25 13:39:23 2008 @@ -518,28 +518,26 @@ $(srcdir)/Objects/unicodetype_db.h BYTESTR_DEPS = Include/bytes_methods.h \ - $(srcdir)/Objects/stringlib/fastsearch.h \ $(srcdir)/Objects/stringlib/count.h \ + $(srcdir)/Objects/stringlib/ctype.h \ + $(srcdir)/Objects/stringlib/eq.h \ + $(srcdir)/Objects/stringlib/fastsearch.h \ $(srcdir)/Objects/stringlib/find.h \ $(srcdir)/Objects/stringlib/partition.h \ - $(srcdir)/Objects/stringlib/ctype.h \ - $(srcdir)/Objects/stringlib/transmogrify.h + $(srcdir)/Objects/stringlib/stringdefs.h \ + $(srcdir)/Objects/stringlib/string_format.h \ + $(srcdir)/Objects/stringlib/transmogrify.h \ + $(srcdir)/Objects/stringlib/unicodedefs.h \ Objects/stringobject.o: $(srcdir)/Objects/stringobject.c $(BYTESTR_DEPS) Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS) Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \ - $(srcdir)/Objects/stringlib/string_format.h \ - $(srcdir)/Objects/stringlib/unicodedefs.h \ - $(srcdir)/Objects/stringlib/fastsearch.h \ - $(srcdir)/Objects/stringlib/count.h \ - $(srcdir)/Objects/stringlib/find.h \ - $(srcdir)/Objects/stringlib/partition.h + $(BYTESTR_DEPS) Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \ - $(srcdir)/Objects/stringlib/formatter.h - + $(BYTESTR_DEPS) ############################################################################ Modified: python/branches/py3k/Objects/dictobject.c ============================================================================== --- python/branches/py3k/Objects/dictobject.c (original) +++ python/branches/py3k/Objects/dictobject.c Mon Feb 25 13:39:23 2008 @@ -172,8 +172,10 @@ static void show_alloc(void) { - fprintf(stderr, "Dict allocations: %zd\n", count_alloc); - fprintf(stderr, "Dict reuse through freelist: %zd\n", count_reuse); + fprintf(stderr, "Dict allocations: %" PY_FORMAT_SIZE_T "d\n", + count_alloc); + fprintf(stderr, "Dict reuse through freelist: %" PY_FORMAT_SIZE_T + "d\n", count_reuse); fprintf(stderr, "%.2f%% reuse rate\n\n", (100.0*count_reuse/(count_alloc+count_reuse))); } Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Mon Feb 25 13:39:23 2008 @@ -72,8 +72,10 @@ static void show_alloc(void) { - fprintf(stderr, "List allocations: %zd\n", count_alloc); - fprintf(stderr, "List reuse through freelist: %zd\n", count_reuse); + fprintf(stderr, "List allocations: %" PY_FORMAT_SIZE_T "d\n", + count_alloc); + fprintf(stderr, "List reuse through freelist: %" PY_FORMAT_SIZE_T + "d\n", count_reuse); fprintf(stderr, "%.2f%% reuse rate\n\n", (100.0*count_reuse/(count_alloc+count_reuse))); } From python-3000-checkins at python.org Mon Feb 25 14:19:43 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 25 Feb 2008 14:19:43 +0100 (CET) Subject: [Python-3000-checkins] r61062 - in python/branches/py3k: Doc/library/logging.rst Lib/test/test_support.py Python/peephole.c Message-ID: <20080225131943.DEAF91E4004@bag.python.org> Author: christian.heimes Date: Mon Feb 25 14:19:43 2008 New Revision: 61062 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/logging.rst python/branches/py3k/Lib/test/test_support.py python/branches/py3k/Python/peephole.c Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61058-61061 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61058 | neal.norwitz | 2008-02-25 02:45:37 +0100 (Mon, 25 Feb 2008) | 1 line Fix indentation ........ r61059 | brett.cannon | 2008-02-25 06:33:07 +0100 (Mon, 25 Feb 2008) | 2 lines Add minor markup for a string. ........ r61060 | brett.cannon | 2008-02-25 06:33:33 +0100 (Mon, 25 Feb 2008) | 2 lines Fix a minor typo in a docstring. ........ Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Mon Feb 25 14:19:43 2008 @@ -243,8 +243,8 @@ little more verbose for logging messages than using the log level convenience methods listed above, but this is how to log at custom log levels. -:func:`getLogger` returns a reference to a logger instance with a name of name -if a name is provided, or root if not. The names are period-separated +:func:`getLogger` returns a reference to a logger instance with the specified +if it it is provided, or ``root`` if not. The names are period-separated hierarchical structures. Multiple calls to :func:`getLogger` with the same name will return a reference to the same logger object. Loggers that are further down in the hierarchical list are children of loggers higher up in the list. @@ -296,7 +296,7 @@ ^^^^^^^^^^ Formatter objects configure the final order, structure, and contents of the log -message. Unlike the base logging.Handler class, application code may +message. Unlike the base :class:`logging.Handler` class, application code may instantiate formatter classes, although you could likely subclass the formatter if your application needs special behavior. The constructor takes two optional arguments: a message format string and a date format string. If there is no Modified: python/branches/py3k/Lib/test/test_support.py ============================================================================== --- python/branches/py3k/Lib/test/test_support.py (original) +++ python/branches/py3k/Lib/test/test_support.py Mon Feb 25 14:19:43 2008 @@ -105,7 +105,7 @@ def bind_port(sock, host='', preferred_port=54321): """Try to bind the sock to a port. If we are running multiple - tests and we don't try multiple ports, the test can fails. This + tests and we don't try multiple ports, the test can fail. This makes the test more robust.""" # Find some random ports that hopefully no one is listening on. Modified: python/branches/py3k/Python/peephole.c ============================================================================== --- python/branches/py3k/Python/peephole.c (original) +++ python/branches/py3k/Python/peephole.c Mon Feb 25 14:19:43 2008 @@ -342,7 +342,7 @@ if (codestr == NULL) goto exitUnchanged; codestr = (unsigned char *)memcpy(codestr, - PyString_AS_STRING(code), codelen); + PyString_AS_STRING(code), codelen); /* Verify that RETURN_VALUE terminates the codestring. This allows the various transformation patterns to look ahead several From python-3000-checkins at python.org Mon Feb 25 18:33:32 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 25 Feb 2008 18:33:32 +0100 (CET) Subject: [Python-3000-checkins] r61066 - python/branches/py3k Message-ID: <20080225173332.9E0471E402C@bag.python.org> Author: christian.heimes Date: Mon Feb 25 18:33:32 2008 New Revision: 61066 Modified: python/branches/py3k/ (props changed) Log: svnmerge.py block -r 61065 From nnorwitz at gmail.com Tue Feb 26 02:46:23 2008 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 25 Feb 2008 20:46:23 -0500 Subject: [Python-3000-checkins] Python Regression Test Failures doc (1) Message-ID: <20080226014623.GA16334@python.psfb.org> svn update tools/sphinx svn: PROPFIND request failed on '/projects/doctools/trunk/sphinx' svn: PROPFIND of '/projects/doctools/trunk/sphinx': could not connect to server (http://svn.python.org) make: *** [update] Error 1 From python-3000-checkins at python.org Tue Feb 26 09:18:31 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 26 Feb 2008 09:18:31 +0100 (CET) Subject: [Python-3000-checkins] r61083 - in python/branches/py3k: Doc/conf.py Doc/library/itertools.rst Doc/library/thread.rst Doc/library/threading.rst Lib/curses/__init__.py Lib/test/test_curses.py Lib/test/test_ftplib.py Lib/test/test_itertools.py Lib/token.py Modules/dbmmodule.c Modules/gdbmmodule.c Modules/itertoolsmodule.c Python/getargs.c Message-ID: <20080226081831.93FE61E4016@bag.python.org> Author: christian.heimes Date: Tue Feb 26 09:18:30 2008 New Revision: 61083 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/conf.py python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Doc/library/thread.rst python/branches/py3k/Doc/library/threading.rst python/branches/py3k/Lib/curses/__init__.py python/branches/py3k/Lib/test/test_curses.py python/branches/py3k/Lib/test/test_ftplib.py python/branches/py3k/Lib/test/test_itertools.py python/branches/py3k/Lib/token.py python/branches/py3k/Modules/dbmmodule.c python/branches/py3k/Modules/gdbmmodule.c python/branches/py3k/Modules/itertoolsmodule.c python/branches/py3k/Python/getargs.c Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61064,61066-61080 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61063 | andrew.kuchling | 2008-02-25 17:29:19 +0100 (Mon, 25 Feb 2008) | 1 line Move .setupterm() output so that we don't try to call endwin() if it fails ........ r61064 | andrew.kuchling | 2008-02-25 17:29:58 +0100 (Mon, 25 Feb 2008) | 1 line Use file descriptor for real stdout ........ r61067 | facundo.batista | 2008-02-25 19:06:00 +0100 (Mon, 25 Feb 2008) | 4 lines Issue 2117. Update compiler module to handle class decorators. Thanks Thomas Herve ........ r61069 | georg.brandl | 2008-02-25 21:17:56 +0100 (Mon, 25 Feb 2008) | 2 lines Rename sphinx.addons to sphinx.ext. ........ r61071 | georg.brandl | 2008-02-25 21:20:45 +0100 (Mon, 25 Feb 2008) | 2 lines Revert r61029. ........ r61072 | facundo.batista | 2008-02-25 23:33:55 +0100 (Mon, 25 Feb 2008) | 4 lines Issue 2168. gdbm and dbm needs to be iterable; this fixes a failure in the shelve module. Thanks Thomas Herve. ........ r61073 | raymond.hettinger | 2008-02-25 23:42:32 +0100 (Mon, 25 Feb 2008) | 1 line Make sure the itertools filter functions give the same performance for func=bool as func=None. ........ r61074 | raymond.hettinger | 2008-02-26 00:17:41 +0100 (Tue, 26 Feb 2008) | 1 line Revert part of r60927 which made invalid assumptions about the API offered by db modules. ........ r61075 | facundo.batista | 2008-02-26 00:46:02 +0100 (Tue, 26 Feb 2008) | 3 lines Coerced PyBool_Type to be able to compare it. ........ r61076 | raymond.hettinger | 2008-02-26 03:46:54 +0100 (Tue, 26 Feb 2008) | 1 line Docs for itertools.combinations(). Implementation in forthcoming checkin. ........ r61077 | neal.norwitz | 2008-02-26 05:50:37 +0100 (Tue, 26 Feb 2008) | 3 lines Don't use a hard coded port. This test could hang/fail if the port is in use. Speed this test up by avoiding a sleep and using the event. ........ r61078 | neal.norwitz | 2008-02-26 06:12:50 +0100 (Tue, 26 Feb 2008) | 1 line Whitespace normalization ........ r61079 | neal.norwitz | 2008-02-26 06:23:51 +0100 (Tue, 26 Feb 2008) | 1 line Whitespace normalization ........ r61080 | georg.brandl | 2008-02-26 07:40:10 +0100 (Tue, 26 Feb 2008) | 2 lines Banish tab. ........ Modified: python/branches/py3k/Doc/conf.py ============================================================================== --- python/branches/py3k/Doc/conf.py (original) +++ python/branches/py3k/Doc/conf.py Tue Feb 26 09:18:30 2008 @@ -13,7 +13,7 @@ # General configuration # --------------------- -extensions = ['sphinx.addons.refcounting', 'sphinx.addons.coverage'] +extensions = ['sphinx.ext.refcounting', 'sphinx.ext.coverage'] # General substitutions. project = 'Python' Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Tue Feb 26 09:18:30 2008 @@ -74,6 +74,45 @@ yield element +.. function:: combinations(iterable, r) + + Return successive *r* length combinations of elements in the *iterable*. + + Combinations are emitted in a lexicographic sort order. So, if the + input *iterable* is sorted, the combination tuples will be produced + in sorted order. + + Elements are treated as unique based on their position, not on their + value. So if the input elements are unique, there will be no repeat + values within a single combination. + + Each result tuple is ordered to match the input order. So, every + combination is a subsequence of the input *iterable*. + + Example: ``combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)`` + + Equivalent to:: + + def combinations(iterable, r): + pool = tuple(iterable) + if pool: + n = len(pool) + vec = range(r) + yield tuple(pool[i] for i in vec) + while 1: + for i in reversed(range(r)): + if vec[i] == i + n-r: + continue + vec[i] += 1 + for j in range(i+1, r): + vec[j] = vec[j-1] + 1 + yield tuple(pool[i] for i in vec) + break + else: + return + + .. versionadded:: 2.6 + .. function:: count([n]) Make an iterator that returns consecutive integers starting with *n*. If not @@ -298,9 +337,12 @@ The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element - changing on every iteration). + changing on every iteration). This results in a lexicographic ordering + so that if the inputs iterables are sorted, the product tuples are emitted + in sorted order. - Equivalent to (but without building the entire result in memory):: + Equivalent to the following except that the actual implementation does not + build-up intermediate results in memory:: def product(*args): pools = map(tuple, args) Modified: python/branches/py3k/Doc/library/thread.rst ============================================================================== --- python/branches/py3k/Doc/library/thread.rst (original) +++ python/branches/py3k/Doc/library/thread.rst Tue Feb 26 09:18:30 2008 @@ -147,11 +147,6 @@ exception will be received by an arbitrary thread. (When the :mod:`signal` module is available, interrupts always go to the main thread.) -* The import machinery is not thread safe. In general, an import may not - have the side effect of importing a module, and only the main thread - should import modules. Imports within or caused by a thread other than - the main thread isn't safe. - * Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is equivalent to calling :func:`exit`. @@ -172,3 +167,4 @@ * When the main thread exits, it does not do any of its usual cleanup (except that :keyword:`try` ... :keyword:`finally` clauses are honored), and the standard I/O files are not flushed. + Modified: python/branches/py3k/Doc/library/threading.rst ============================================================================== --- python/branches/py3k/Doc/library/threading.rst (original) +++ python/branches/py3k/Doc/library/threading.rst Tue Feb 26 09:18:30 2008 @@ -555,13 +555,6 @@ There is a "main thread" object; this corresponds to the initial thread of control in the Python program. It is not a daemon thread. -.. warning:: - - The import machinery is not thread safe. In general, an import may not - have the side effect of importing a module, and only the main thread - should import modules. Imports within or caused by a thread other than - the main thread isn't safe. - There is the possibility that "dummy thread objects" are created. These are thread objects corresponding to "alien threads", which are threads of control started outside the threading module, such as directly from C code. Dummy Modified: python/branches/py3k/Lib/curses/__init__.py ============================================================================== --- python/branches/py3k/Lib/curses/__init__.py (original) +++ python/branches/py3k/Lib/curses/__init__.py Tue Feb 26 09:18:30 2008 @@ -15,6 +15,7 @@ from _curses import * from curses.wrapper import wrapper import os as _os +import sys as _sys # Some constants, most notably the ACS_* ones, are only added to the C # _curses module's dictionary after initscr() is called. (Some @@ -28,7 +29,8 @@ import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. - setupterm(term=_os.environ.get("TERM", "unknown")) + setupterm(term=_os.environ.get("TERM", "unknown"), + fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): Modified: python/branches/py3k/Lib/test/test_curses.py ============================================================================== --- python/branches/py3k/Lib/test/test_curses.py (original) +++ python/branches/py3k/Lib/test/test_curses.py Tue Feb 26 09:18:30 2008 @@ -269,13 +269,12 @@ curses.wrapper(main) unit_tests() else: + # testing setupterm() inside initscr/endwin + # causes terminal breakage + curses.setupterm(fd=sys.__stdout__.fileno()) try: - # testing setupterm() inside initscr/endwin - # causes terminal breakage - curses.setupterm(fd=sys.__stdout__.fileno()) stdscr = curses.initscr() main(stdscr) finally: curses.endwin() - unit_tests() Modified: python/branches/py3k/Lib/test/test_ftplib.py ============================================================================== --- python/branches/py3k/Lib/test/test_ftplib.py (original) +++ python/branches/py3k/Lib/test/test_ftplib.py Tue Feb 26 09:18:30 2008 @@ -6,34 +6,48 @@ from unittest import TestCase from test import test_support -def server(evt, ready): +server_port = None + +# This function sets the evt 3 times: +# 1) when the connection is ready to be accepted. +# 2) when it is safe for the caller to close the connection +# 3) when we have closed the socket +def server(evt): + global server_port serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serv.settimeout(3) serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - serv.bind(("", 9091)) + server_port = test_support.bind_port(serv, "", 9091) serv.listen(5) - ready.set() + + # (1) Signal the caller that we are ready to accept the connection. + evt.set() try: conn, addr = serv.accept() except socket.timeout: pass else: conn.send(b"1 Hola mundo\n") + # (2) Signal the caller that it is safe to close the socket. + evt.set() conn.close() finally: serv.close() + # (3) Signal the caller that we are done. evt.set() class GeneralTests(TestCase): def setUp(self): - ftplib.FTP.port = 9091 self.evt = threading.Event() - ready = threading.Event() - threading.Thread(target=server, args=(self.evt, ready)).start() - ready.wait() + threading.Thread(target=server, args=(self.evt,)).start() + # Wait for the server to be ready. + self.evt.wait() + self.evt.clear() + ftplib.FTP.port = server_port def tearDown(self): + # Wait on the closing of the socket (this shouldn't be necessary). self.evt.wait() def testBasic(self): @@ -42,30 +56,35 @@ # connects ftp = ftplib.FTP("localhost") + self.evt.wait() ftp.sock.close() def testTimeoutDefault(self): # default ftp = ftplib.FTP("localhost") self.assertTrue(ftp.sock.gettimeout() is None) + self.evt.wait() ftp.sock.close() def testTimeoutValue(self): # a value ftp = ftplib.FTP("localhost", timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) + self.evt.wait() ftp.sock.close() def testTimeoutConnect(self): ftp = ftplib.FTP() ftp.connect("localhost", timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) + self.evt.wait() ftp.sock.close() def testTimeoutDifferentOrder(self): ftp = ftplib.FTP(timeout=30) ftp.connect("localhost") self.assertEqual(ftp.sock.gettimeout(), 30) + self.evt.wait() ftp.sock.close() def testTimeoutDirectAccess(self): @@ -73,6 +92,7 @@ ftp.timeout = 30 ftp.connect("localhost") self.assertEqual(ftp.sock.gettimeout(), 30) + self.evt.wait() ftp.sock.close() def testTimeoutNone(self): @@ -84,10 +104,10 @@ finally: socket.setdefaulttimeout(previous) self.assertEqual(ftp.sock.gettimeout(), 30) + self.evt.wait() ftp.close() - def test_main(verbose=None): test_support.run_unittest(GeneralTests) Modified: python/branches/py3k/Lib/test/test_itertools.py ============================================================================== --- python/branches/py3k/Lib/test/test_itertools.py (original) +++ python/branches/py3k/Lib/test/test_itertools.py Tue Feb 26 09:18:30 2008 @@ -177,6 +177,7 @@ def test_ifilter(self): self.assertEqual(list(ifilter(isEven, range(6))), [0,2,4]) self.assertEqual(list(ifilter(None, [0,1,0,2,0])), [1,2]) + self.assertEqual(list(ifilter(bool, [0,1,0,2,0])), [1,2]) self.assertEqual(take(4, ifilter(isEven, count())), [0,2,4,6]) self.assertRaises(TypeError, ifilter) self.assertRaises(TypeError, ifilter, lambda x:x) @@ -187,6 +188,7 @@ def test_ifilterfalse(self): self.assertEqual(list(ifilterfalse(isEven, range(6))), [1,3,5]) self.assertEqual(list(ifilterfalse(None, [0,1,0,2,0])), [0,0,0]) + self.assertEqual(list(ifilterfalse(bool, [0,1,0,2,0])), [0,0,0]) self.assertEqual(take(4, ifilterfalse(isEven, count())), [1,3,5,7]) self.assertRaises(TypeError, ifilterfalse) self.assertRaises(TypeError, ifilterfalse, lambda x:x) Modified: python/branches/py3k/Lib/token.py ============================================================================== --- python/branches/py3k/Lib/token.py (original) +++ python/branches/py3k/Lib/token.py Tue Feb 26 09:18:30 2008 @@ -72,6 +72,7 @@ for _name, _value in list(globals().items()): if type(_value) is type(0): tok_name[_value] = _name +del _name, _value def ISTERMINAL(x): Modified: python/branches/py3k/Modules/dbmmodule.c ============================================================================== --- python/branches/py3k/Modules/dbmmodule.c (original) +++ python/branches/py3k/Modules/dbmmodule.c Tue Feb 26 09:18:30 2008 @@ -344,6 +344,13 @@ 0, /*tp_as_number*/ &dbm_as_sequence, /*tp_as_sequence*/ &dbm_as_mapping, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_xxx4*/ }; /* ----------------------------------------------------------------- */ Modified: python/branches/py3k/Modules/gdbmmodule.c ============================================================================== --- python/branches/py3k/Modules/gdbmmodule.c (original) +++ python/branches/py3k/Modules/gdbmmodule.c Tue Feb 26 09:18:30 2008 @@ -407,7 +407,7 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - 0, /*tp_xxx4*/ + Py_TPFLAGS_DEFAULT, /*tp_xxx4*/ gdbm_object__doc__, /*tp_doc*/ }; Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Tue Feb 26 09:18:30 2008 @@ -2025,7 +2025,7 @@ if (item == NULL) return NULL; - if (lz->func == Py_None) { + if (lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type) { ok = PyObject_IsTrue(item); } else { PyObject *good; @@ -2169,7 +2169,7 @@ if (item == NULL) return NULL; - if (lz->func == Py_None) { + if (lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type) { ok = PyObject_IsTrue(item); } else { PyObject *good; Modified: python/branches/py3k/Python/getargs.c ============================================================================== --- python/branches/py3k/Python/getargs.c (original) +++ python/branches/py3k/Python/getargs.c Tue Feb 26 09:18:30 2008 @@ -154,7 +154,7 @@ PyMem_FREE(ptr); return -1; } - if(PyList_Append(*freelist, cobj)) { + if (PyList_Append(*freelist, cobj)) { PyMem_FREE(ptr); Py_DECREF(cobj); return -1; @@ -166,8 +166,8 @@ static int cleanreturn(int retval, PyObject *freelist) { - if(freelist) { - if((retval) == 0) { + if (freelist) { + if (retval == 0) { Py_ssize_t len = PyList_GET_SIZE(freelist), i; for (i = 0; i < len; i++) PyMem_FREE(PyCObject_AsVoidPtr( @@ -708,7 +708,7 @@ case 'L': {/* PY_LONG_LONG */ PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); PY_LONG_LONG ival = PyLong_AsLongLong( arg ); - if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) { + if (ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) { return converterr("long", arg, msgbuf, bufsize); } else { *p = ival; @@ -1045,7 +1045,7 @@ "(memory error)", arg, msgbuf, bufsize); } - if(addcleanup(*buffer, freelist)) { + if (addcleanup(*buffer, freelist)) { Py_DECREF(s); return converterr( "(cleanup problem)", @@ -1087,7 +1087,7 @@ return converterr("(memory error)", arg, msgbuf, bufsize); } - if(addcleanup(*buffer, freelist)) { + if (addcleanup(*buffer, freelist)) { Py_DECREF(s); return converterr("(cleanup problem)", arg, msgbuf, bufsize); From python-3000-checkins at python.org Tue Feb 26 14:27:02 2008 From: python-3000-checkins at python.org (mark.summerfield) Date: Tue, 26 Feb 2008 14:27:02 +0100 (CET) Subject: [Python-3000-checkins] r61085 - python/branches/py3k/Doc/library/functions.rst Message-ID: <20080226132702.1C7F01E4028@bag.python.org> Author: mark.summerfield Date: Tue Feb 26 14:27:00 2008 New Revision: 61085 Modified: python/branches/py3k/Doc/library/functions.rst Log: Updated super() as per http://www.artima.com/weblogs/viewpost.jsp?thread=208549 but would be worth someone else checking if poss. Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Tue Feb 26 14:27:00 2008 @@ -1025,25 +1025,31 @@ sequence of strings is by calling ``''.join(sequence)``. -.. function:: super(type[, object-or-type]) +.. function:: super([type[, object-or-type]]) - .. XXX need to document PEP "new super" + .. XXX updated as per http://www.artima.com/weblogs/viewpost.jsp?thread=208549 but needs checking - Return the superclass of *type*. If the second argument is omitted the super - object returned is unbound. If the second argument is an object, - ``isinstance(obj, type)`` must be true. If the second argument is a type, + Return the superclass of *type*. + + Calling :func:`super()` without arguments is equivalent to + ``super(this_class, first_arg)``. If called with one + argument the super object returned is unbound. If called with two + arguments and the second argument is an object, ``isinstance(obj, + type)`` must be true. If the second argument is a type, ``issubclass(type2, type)`` must be true. A typical use for calling a cooperative superclass method is:: class C(B): - def meth(self, arg): - super(C, self).meth(arg) + def method(self, arg): + super().method(arg) # This does the same thing as: super(C, self).method(arg) Note that :func:`super` is implemented as part of the binding process for - explicit dotted attribute lookups such as ``super(C, self).__getitem__(name)``. + explicit dotted attribute lookups such as ``super().__getitem__(name)``. Accordingly, :func:`super` is undefined for implicit lookups using statements or - operators such as ``super(C, self)[name]``. + operators such as ``super()[name]``. Also, :func:`super` is not + limited to use inside methods: under the hood it searches the stack + frame for the class (``__class__``) and the first argument. .. function:: tuple([iterable]) From python-3000-checkins at python.org Thu Feb 28 12:19:05 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 28 Feb 2008 12:19:05 +0100 (CET) Subject: [Python-3000-checkins] r61103 - in python/branches/py3k: Doc/library/itertools.rst Doc/library/trace.rst Doc/using/unix.rst Doc/using/windows.rst Lib/test/test_getargs2.py Lib/test/test_itertools.py Lib/test/test_smtplib.py Lib/trace.py Modules/_testcapimodule.c Modules/itertoolsmodule.c Python/getargs.c Message-ID: <20080228111905.ED8D91E4010@bag.python.org> Author: christian.heimes Date: Thu Feb 28 12:19:05 2008 New Revision: 61103 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Doc/library/trace.rst python/branches/py3k/Doc/using/unix.rst python/branches/py3k/Doc/using/windows.rst python/branches/py3k/Lib/test/test_getargs2.py python/branches/py3k/Lib/test/test_itertools.py python/branches/py3k/Lib/test/test_smtplib.py python/branches/py3k/Lib/trace.py python/branches/py3k/Modules/_testcapimodule.c python/branches/py3k/Modules/itertoolsmodule.c python/branches/py3k/Python/getargs.c Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61081-61095 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61081 | neal.norwitz | 2008-02-26 09:04:59 +0100 (Tue, 26 Feb 2008) | 7 lines Speed up this test by about 99%. Remove sleeps and replace with events. (This may fail on some slow platforms, but we can fix those cases which should be relatively isolated and easier to find now.) Move two test cases that didn't require a server to be started to a separate TestCase. These tests were taking 3 seconds which is what the timeout was set to. ........ r61082 | christian.heimes | 2008-02-26 09:18:11 +0100 (Tue, 26 Feb 2008) | 1 line The contains function raised a gcc warning. The new code is copied straight from py3k. ........ r61084 | neal.norwitz | 2008-02-26 09:21:28 +0100 (Tue, 26 Feb 2008) | 3 lines Add a timing flag to Trace so you can see where slowness occurs like waiting for socket timeouts in test_smtplib :-). ........ r61086 | christian.heimes | 2008-02-26 18:23:51 +0100 (Tue, 26 Feb 2008) | 3 lines Patch #1691070 from Roger Upole: Speed up PyArg_ParseTupleAndKeywords() and improve error msg My tests don't show the promised speed up of 10%. The code is as fast as the old code for simple cases and slightly faster for complex cases with several of args and kwargs. But the patch simplifies the code, too. ........ r61087 | georg.brandl | 2008-02-26 20:13:45 +0100 (Tue, 26 Feb 2008) | 2 lines #2194: fix some typos. ........ r61088 | raymond.hettinger | 2008-02-27 00:40:50 +0100 (Wed, 27 Feb 2008) | 1 line Add itertools.combinations(). ........ r61089 | raymond.hettinger | 2008-02-27 02:08:04 +0100 (Wed, 27 Feb 2008) | 1 line One too many decrefs. ........ r61090 | raymond.hettinger | 2008-02-27 02:08:30 +0100 (Wed, 27 Feb 2008) | 1 line Larger test range ........ r61091 | raymond.hettinger | 2008-02-27 02:44:34 +0100 (Wed, 27 Feb 2008) | 1 line Simply the sample code for combinations(). ........ Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Thu Feb 28 12:19:05 2008 @@ -95,21 +95,20 @@ def combinations(iterable, r): pool = tuple(iterable) - if pool: - n = len(pool) - vec = range(r) - yield tuple(pool[i] for i in vec) - while 1: - for i in reversed(range(r)): - if vec[i] == i + n-r: - continue - vec[i] += 1 - for j in range(i+1, r): - vec[j] = vec[j-1] + 1 - yield tuple(pool[i] for i in vec) + n = len(pool) + assert 0 <= r <= n + vec = range(r) + yield tuple(pool[i] for i in vec) + while 1: + for i in reversed(range(r)): + if vec[i] != i + n - r: break - else: - return + else: + return + vec[i] += 1 + for j in range(i+1, r): + vec[j] = vec[j-1] + 1 + yield tuple(pool[i] for i in vec) .. versionadded:: 2.6 Modified: python/branches/py3k/Doc/library/trace.rst ============================================================================== --- python/branches/py3k/Doc/library/trace.rst (original) +++ python/branches/py3k/Doc/library/trace.rst Thu Feb 28 12:19:05 2008 @@ -80,7 +80,7 @@ --------------------- -.. class:: Trace([count=1[, trace=1[, countfuncs=0[, countcallers=0[, ignoremods=()[, ignoredirs=()[, infile=None[, outfile=None]]]]]]]]) +.. class:: Trace([count=1[, trace=1[, countfuncs=0[, countcallers=0[, ignoremods=()[, ignoredirs=()[, infile=None[, outfile=None[, timing=False]]]]]]]]]) Create an object to trace execution of a single statement or expression. All parameters are optional. *count* enables counting of line numbers. *trace* @@ -89,7 +89,8 @@ *ignoremods* is a list of modules or packages to ignore. *ignoredirs* is a list of directories whose modules or packages should be ignored. *infile* is the file from which to read stored count information. *outfile* is a file in which - to write updated count information. + to write updated count information. *timing* enables a timestamp relative + to when tracing was started to be displayed. .. method:: Trace.run(cmd) Modified: python/branches/py3k/Doc/using/unix.rst ============================================================================== --- python/branches/py3k/Doc/using/unix.rst (original) +++ python/branches/py3k/Doc/using/unix.rst Thu Feb 28 12:19:05 2008 @@ -20,7 +20,7 @@ that are not available on your distro's package. You can easily compile the latest version of Python from source. -In the event Python doesn't come preinstalled and isn't in the repositories as +In the event that Python doesn't come preinstalled and isn't in the repositories as well, you can easily make packages for your own distro. Have a look at the following links: Modified: python/branches/py3k/Doc/using/windows.rst ============================================================================== --- python/branches/py3k/Doc/using/windows.rst (original) +++ python/branches/py3k/Doc/using/windows.rst Thu Feb 28 12:19:05 2008 @@ -21,7 +21,7 @@ `_ for many years. With ongoing development of Python, some platforms that used to be supported -earlier are not longer supported (due to the lack of users or developers). +earlier are no longer supported (due to the lack of users or developers). Check :pep:`11` for details on all unsupported platforms. * DOS and Windows 3.x are deprecated since Python 2.0 and code specific to these Modified: python/branches/py3k/Lib/test/test_getargs2.py ============================================================================== --- python/branches/py3k/Lib/test/test_getargs2.py (original) +++ python/branches/py3k/Lib/test/test_getargs2.py Thu Feb 28 12:19:05 2008 @@ -1,5 +1,6 @@ import unittest from test import test_support +from _testcapi import getargs_keywords import warnings warnings.filterwarnings("ignore", @@ -248,9 +249,57 @@ raise ValueError self.assertRaises(TypeError, getargs_tuple, 1, seq()) +class Keywords_TestCase(unittest.TestCase): + def test_positional_args(self): + # using all positional args + self.assertEquals( + getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), 10), + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + ) + def test_mixed_args(self): + # positional and keyword args + self.assertEquals( + getargs_keywords((1,2), 3, (4,(5,6)), arg4=(7,8,9), arg5=10), + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + ) + def test_keyword_args(self): + # all keywords + self.assertEquals( + getargs_keywords(arg1=(1,2), arg2=3, arg3=(4,(5,6)), arg4=(7,8,9), arg5=10), + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + ) + def test_optional_args(self): + # missing optional keyword args, skipping tuples + self.assertEquals( + getargs_keywords(arg1=(1,2), arg2=3, arg5=10), + (1, 2, 3, -1, -1, -1, -1, -1, -1, 10) + ) + def test_required_args(self): + # required arg missing + try: + getargs_keywords(arg1=(1,2)) + except TypeError as err: + self.assertEquals(str(err), "Required argument 'arg2' (pos 2) not found") + else: + self.fail('TypeError should have been raised') + def test_too_many_args(self): + try: + getargs_keywords((1,2),3,(4,(5,6)),(7,8,9),10,111) + except TypeError as err: + self.assertEquals(str(err), "function takes at most 5 arguments (6 given)") + else: + self.fail('TypeError should have been raised') + def test_invalid_keyword(self): + # extraneous keyword arg + try: + getargs_keywords((1,2),3,arg5=10,arg666=666) + except TypeError as err: + self.assertEquals(str(err), "'arg666' is an invalid keyword argument for this function") + else: + self.fail('TypeError should have been raised') def test_main(): - tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase] + tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase, Keywords_TestCase] try: from _testcapi import getargs_L, getargs_K except ImportError: Modified: python/branches/py3k/Lib/test/test_itertools.py ============================================================================== --- python/branches/py3k/Lib/test/test_itertools.py (original) +++ python/branches/py3k/Lib/test/test_itertools.py Thu Feb 28 12:19:05 2008 @@ -44,6 +44,10 @@ 'Convenience function for partially consuming a long of infinite iterable' return list(islice(seq, n)) +def fact(n): + 'Factorial' + return reduce(operator.mul, range(1, n+1), 1) + class TestBasicOps(unittest.TestCase): def test_chain(self): self.assertEqual(list(chain('abc', 'def')), list('abcdef')) @@ -52,6 +56,26 @@ self.assertEqual(take(4, chain('abc', 'def')), list('abcd')) self.assertRaises(TypeError, chain, 2, 3) + def test_combinations(self): + self.assertRaises(TypeError, combinations, 'abc') # missing r argument + self.assertRaises(TypeError, combinations, 'abc', 2, 1) # too many arguments + self.assertRaises(ValueError, combinations, 'abc', -2) # r is negative + self.assertRaises(ValueError, combinations, 'abc', 32) # r is too big + self.assertEqual(list(combinations(range(4), 3)), + [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]) + for n in range(8): + values = [5*x-12 for x in range(n)] + for r in range(n+1): + result = list(combinations(values, r)) + self.assertEqual(len(result), fact(n) / fact(r) / fact(n-r)) # right number of combs + self.assertEqual(len(result), len(set(result))) # no repeats + self.assertEqual(result, sorted(result)) # lexicographic order + for c in result: + self.assertEqual(len(c), r) # r-length combinations + self.assertEqual(len(set(c)), r) # no duplicate elements + self.assertEqual(list(c), sorted(c)) # keep original ordering + self.assert_(all(e in values for e in c)) # elements taken from input iterable + def test_count(self): self.assertEqual(lzip('abc',count()), [('a', 0), ('b', 1), ('c', 2)]) self.assertEqual(lzip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)]) Modified: python/branches/py3k/Lib/test/test_smtplib.py ============================================================================== --- python/branches/py3k/Lib/test/test_smtplib.py (original) +++ python/branches/py3k/Lib/test/test_smtplib.py Thu Feb 28 12:19:05 2008 @@ -18,14 +18,15 @@ PORT = None def server(evt, buf): + serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + serv.settimeout(1) + serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + serv.bind(("", 0)) + global PORT + PORT = serv.getsockname()[1] + serv.listen(5) + evt.set() try: - serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - serv.settimeout(3) - serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - serv.bind(("", 0)) - global PORT - PORT = serv.getsockname()[1] - serv.listen(5) conn, addr = serv.accept() except socket.timeout: pass @@ -38,7 +39,6 @@ buf = buf[sent:] n -= 1 - time.sleep(0.01) conn.close() finally: @@ -52,16 +52,8 @@ self.evt = threading.Event() servargs = (self.evt, b"220 Hola mundo\n") threading.Thread(target=server, args=servargs).start() - - # wait until server thread has assigned a port number - n = 500 - while PORT is None and n > 0: - time.sleep(0.01) - n -= 1 - - # wait a little longer (sometimes connections are refused - # on slow machines without this additional wait) - time.sleep(0.5) + self.evt.wait() + self.evt.clear() def tearDown(self): self.evt.wait() @@ -76,29 +68,12 @@ smtp = smtplib.SMTP("%s:%s" % (HOST, PORT)) smtp.sock.close() - def testNotConnected(self): - # Test various operations on an unconnected SMTP object that - # should raise exceptions (at present the attempt in SMTP.send - # to reference the nonexistent 'sock' attribute of the SMTP object - # causes an AttributeError) - smtp = smtplib.SMTP() - self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo) - self.assertRaises(smtplib.SMTPServerDisconnected, - smtp.send, 'test msg') - def testLocalHostName(self): # check that supplied local_hostname is used smtp = smtplib.SMTP(HOST, PORT, local_hostname="testhost") self.assertEqual(smtp.local_hostname, "testhost") smtp.sock.close() - def testNonnumericPort(self): - # check that non-numeric port raises socket.error - self.assertRaises(socket.error, smtplib.SMTP, - "localhost", "bogus") - self.assertRaises(socket.error, smtplib.SMTP, - "localhost:bogus") - def testTimeoutDefault(self): # default smtp = smtplib.SMTP(HOST, PORT) @@ -128,6 +103,7 @@ serv = server_class(("", 0), ('nowhere', -1)) global PORT PORT = serv.getsockname()[1] + serv_evt.set() try: if hasattr(select, 'poll'): @@ -150,12 +126,12 @@ except socket.timeout: pass finally: - # allow some time for the client to read the result - time.sleep(0.5) - serv.close() + if not client_evt.isSet(): + # allow some time for the client to read the result + time.sleep(0.5) + serv.close() asyncore.close_all() PORT = None - time.sleep(0.5) serv_evt.set() MSG_BEGIN = '---------- MESSAGE FOLLOWS ----------\n' @@ -181,14 +157,8 @@ threading.Thread(target=debugging_server, args=serv_args).start() # wait until server thread has assigned a port number - n = 500 - while PORT is None and n > 0: - time.sleep(0.01) - n -= 1 - - # wait a little longer (sometimes connections are refused - # on slow machines without this additional wait) - time.sleep(0.5) + self.serv_evt.wait() + self.serv_evt.clear() def tearDown(self): # indicate that the client is finished @@ -258,6 +228,26 @@ self.assertEqual(self.output.getvalue(), mexpect) +class NonConnectingTests(TestCase): + + def testNotConnected(self): + # Test various operations on an unconnected SMTP object that + # should raise exceptions (at present the attempt in SMTP.send + # to reference the nonexistent 'sock' attribute of the SMTP object + # causes an AttributeError) + smtp = smtplib.SMTP() + self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo) + self.assertRaises(smtplib.SMTPServerDisconnected, + smtp.send, 'test msg') + + def testNonnumericPort(self): + # check that non-numeric port raises socket.error + self.assertRaises(socket.error, smtplib.SMTP, + "localhost", "bogus") + self.assertRaises(socket.error, smtplib.SMTP, + "localhost:bogus") + + # test response of client to a non-successful HELO message class BadHELOServerTests(TestCase): @@ -269,16 +259,8 @@ self.evt = threading.Event() servargs = (self.evt, b"199 no hello for you!\n") threading.Thread(target=server, args=servargs).start() - - # wait until server thread has assigned a port number - n = 500 - while PORT is None and n > 0: - time.sleep(0.01) - n -= 1 - - # wait a little longer (sometimes connections are refused - # on slow machines without this additional wait) - time.sleep(0.5) + self.evt.wait() + self.evt.clear() def tearDown(self): self.evt.wait() @@ -355,14 +337,8 @@ threading.Thread(target=debugging_server, args=serv_args).start() # wait until server thread has assigned a port number - n = 500 - while PORT is None and n > 0: - time.sleep(0.01) - n -= 1 - - # wait a little longer (sometimes connections are refused - # on slow machines without this additional wait) - time.sleep(0.5) + self.serv_evt.wait() + self.serv_evt.clear() def tearDown(self): # indicate that the client is finished @@ -430,6 +406,7 @@ def test_main(verbose=None): test_support.run_unittest(GeneralTests, DebuggingServerTests, + NonConnectingTests, BadHELOServerTests, SMTPSimTests) if __name__ == '__main__': Modified: python/branches/py3k/Lib/trace.py ============================================================================== --- python/branches/py3k/Lib/trace.py (original) +++ python/branches/py3k/Lib/trace.py Thu Feb 28 12:19:05 2008 @@ -53,6 +53,7 @@ import re import sys import threading +import time import token import tokenize import types @@ -94,6 +95,8 @@ with '>>>>>> '. -s, --summary Write a brief summary on stdout for each file. (Can only be used with --count or --report.) +-g, --timing Prefix each line with the time since the program started. + Only used while tracing. Filters, may be repeated multiple times: --ignore-module= Ignore the given module(s) and its submodules @@ -431,7 +434,8 @@ class Trace: def __init__(self, count=1, trace=1, countfuncs=0, countcallers=0, - ignoremods=(), ignoredirs=(), infile=None, outfile=None): + ignoremods=(), ignoredirs=(), infile=None, outfile=None, + timing=False): """ @param count true iff it should count number of times each line is executed @@ -447,6 +451,7 @@ @param infile file from which to read stored counts to be added into the results @param outfile file in which to write the results + @param timing true iff timing information be displayed """ self.infile = infile self.outfile = outfile @@ -459,6 +464,9 @@ self._calledfuncs = {} self._callers = {} self._caller_cache = {} + self.start_time = None + if timing: + self.start_time = time.time() if countcallers: self.globaltrace = self.globaltrace_trackcallers elif countfuncs: @@ -609,6 +617,8 @@ key = filename, lineno self.counts[key] = self.counts.get(key, 0) + 1 + if self.start_time: + print('%.2f' % (time.time() - self.start_time), end=' ') bname = os.path.basename(filename) print("%s(%d): %s" % (bname, lineno, linecache.getline(filename, lineno)), end=' ') @@ -620,6 +630,8 @@ filename = frame.f_code.co_filename lineno = frame.f_lineno + if self.start_time: + print('%.2f' % (time.time() - self.start_time), end=' ') bname = os.path.basename(filename) print("%s(%d): %s" % (bname, lineno, linecache.getline(filename, lineno)), end=' ') @@ -649,13 +661,13 @@ if argv is None: argv = sys.argv try: - opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:lT", + opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:lTg", ["help", "version", "trace", "count", "report", "no-report", "summary", "file=", "missing", "ignore-module=", "ignore-dir=", "coverdir=", "listfuncs", - "trackcalls"]) + "trackcalls", "timing"]) except getopt.error as msg: sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) @@ -675,6 +687,7 @@ summary = 0 listfuncs = False countcallers = False + timing = False for opt, val in opts: if opt == "--help": @@ -693,6 +706,10 @@ listfuncs = True continue + if opt == "-g" or opt == "--timing": + timing = True + continue + if opt == "-t" or opt == "--trace": trace = 1 continue @@ -775,7 +792,7 @@ t = Trace(count, trace, countfuncs=listfuncs, countcallers=countcallers, ignoremods=ignore_modules, ignoredirs=ignore_dirs, infile=counts_file, - outfile=counts_file) + outfile=counts_file, timing=timing) try: fp = open(progname) try: Modified: python/branches/py3k/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k/Modules/_testcapimodule.c (original) +++ python/branches/py3k/Modules/_testcapimodule.c Thu Feb 28 12:19:05 2008 @@ -308,6 +308,22 @@ return Py_BuildValue("iii", a, b, c); } +/* test PyArg_ParseTupleAndKeywords */ +static PyObject *getargs_keywords(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *keywords[] = {"arg1","arg2","arg3","arg4","arg5", NULL}; + static char *fmt="(ii)i|(i(ii))(iii)i"; + int int_args[10]={-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords, + &int_args[0], &int_args[1], &int_args[2], &int_args[3], &int_args[4], + &int_args[5], &int_args[6], &int_args[7], &int_args[8], &int_args[9])) + return NULL; + return Py_BuildValue("iiiiiiiiii", + int_args[0], int_args[1], int_args[2], int_args[3], int_args[4], + int_args[5], int_args[6], int_args[7], int_args[8], int_args[9]); +} + /* Functions to call PyArg_ParseTuple with integer format codes, and return the result. */ @@ -898,6 +914,8 @@ PyDoc_STR("This is a pretty normal docstring.")}, {"getargs_tuple", getargs_tuple, METH_VARARGS}, + {"getargs_keywords", (PyCFunction)getargs_keywords, + METH_VARARGS|METH_KEYWORDS}, {"getargs_b", getargs_b, METH_VARARGS}, {"getargs_B", getargs_B, METH_VARARGS}, {"getargs_H", getargs_H, METH_VARARGS}, Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Thu Feb 28 12:19:05 2008 @@ -1764,10 +1764,8 @@ /* create productobject structure */ lz = (productobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(pools); + if (lz == NULL) goto error; - } lz->pools = pools; lz->maxvec = maxvec; @@ -1952,6 +1950,232 @@ }; +/* combinations object ************************************************************/ + +typedef struct { + PyObject_HEAD + PyObject *pool; /* input converted to a tuple */ + Py_ssize_t *indices; /* one index per result element */ + PyObject *result; /* most recently returned result tuple */ + Py_ssize_t r; /* size of result tuple */ + int stopped; /* set to 1 when the combinations iterator is exhausted */ +} combinationsobject; + +static PyTypeObject combinations_type; + +static PyObject * +combinations_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + combinationsobject *co; + Py_ssize_t n; + Py_ssize_t r; + PyObject *pool = NULL; + PyObject *iterable = NULL; + Py_ssize_t *indices = NULL; + Py_ssize_t i; + static char *kwargs[] = {"iterable", "r", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "On:combinations", kwargs, + &iterable, &r)) + return NULL; + + pool = PySequence_Tuple(iterable); + if (pool == NULL) + goto error; + n = PyTuple_GET_SIZE(pool); + if (r < 0) { + PyErr_SetString(PyExc_ValueError, "r must be non-negative"); + goto error; + } + if (r > n) { + PyErr_SetString(PyExc_ValueError, "r cannot be bigger than the iterable"); + goto error; + } + + indices = PyMem_Malloc(r * sizeof(Py_ssize_t)); + if (indices == NULL) { + PyErr_NoMemory(); + goto error; + } + + for (i=0 ; itp_alloc(type, 0); + if (co == NULL) + goto error; + + co->pool = pool; + co->indices = indices; + co->result = NULL; + co->r = r; + co->stopped = 0; + + return (PyObject *)co; + +error: + if (indices != NULL) + PyMem_Free(indices); + Py_XDECREF(pool); + return NULL; +} + +static void +combinations_dealloc(combinationsobject *co) +{ + PyObject_GC_UnTrack(co); + Py_XDECREF(co->pool); + Py_XDECREF(co->result); + PyMem_Free(co->indices); + Py_TYPE(co)->tp_free(co); +} + +static int +combinations_traverse(combinationsobject *co, visitproc visit, void *arg) +{ + Py_VISIT(co->pool); + Py_VISIT(co->result); + return 0; +} + +static PyObject * +combinations_next(combinationsobject *co) +{ + PyObject *elem; + PyObject *oldelem; + PyObject *pool = co->pool; + Py_ssize_t *indices = co->indices; + PyObject *result = co->result; + Py_ssize_t n = PyTuple_GET_SIZE(pool); + Py_ssize_t r = co->r; + Py_ssize_t i, j, index; + + if (co->stopped) + return NULL; + + if (result == NULL) { + /* On the first pass, initialize result tuple using the indices */ + result = PyTuple_New(r); + if (result == NULL) + goto empty; + co->result = result; + for (i=0; i 1) { + PyObject *old_result = result; + result = PyTuple_New(r); + if (result == NULL) + goto empty; + co->result = result; + for (i=0; i= 0 && indices[i] == i+n-r ; i--) + ; + + /* If i is negative, then the indices are all at + their maximum value and we're done. */ + if (i < 0) + goto empty; + + /* Increment the current index which we know is not at its + maximum. Then move back to the right setting each index + to its lowest possible value (one higher than the index + to its left -- this maintains the sort order invariant). */ + indices[i]++; + for (j=i+1 ; jstopped = 1; + return NULL; +} + +PyDoc_STRVAR(combinations_doc, +"combinations(iterables) --> combinations object\n\ +\n\ +Return successive r-length combinations of elements in the iterable.\n\n\ +combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)"); + +static PyTypeObject combinations_type = { + PyVarObject_HEAD_INIT(NULL, 0) + "itertools.combinations", /* tp_name */ + sizeof(combinationsobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)combinations_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + combinations_doc, /* tp_doc */ + (traverseproc)combinations_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)combinations_next, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + combinations_new, /* tp_new */ + PyObject_GC_Del, /* tp_free */ +}; + + /* ifilter object ************************************************************/ typedef struct { @@ -2978,6 +3202,7 @@ PyObject *m; char *name; PyTypeObject *typelist[] = { + &combinations_type, &cycle_type, &dropwhile_type, &takewhile_type, @@ -2990,7 +3215,7 @@ &count_type, &izip_type, &iziplongest_type, - &product_type, + &product_type, &repeat_type, &groupby_type, NULL Modified: python/branches/py3k/Python/getargs.c ============================================================================== --- python/branches/py3k/Python/getargs.c (original) +++ python/branches/py3k/Python/getargs.c Thu Feb 28 12:19:05 2008 @@ -1401,6 +1401,7 @@ return retval; } +#define IS_END_OF_FORMAT(c) (c == '\0' || c == ';' || c == ':') static int vgetargskeywords(PyObject *args, PyObject *keywords, const char *format, @@ -1408,13 +1409,10 @@ { char msgbuf[512]; int levels[32]; - const char *fname, *message; - int min, max; - const char *formatsave; + const char *fname, *msg, *custom_msg, *keyword; + int min = INT_MAX; int i, len, nargs, nkeywords; - const char *msg; - char **p; - PyObject *freelist = NULL; + PyObject *freelist = NULL, *current_arg; assert(args != NULL && PyTuple_Check(args)); assert(keywords == NULL || PyDict_Check(keywords)); @@ -1422,168 +1420,108 @@ assert(kwlist != NULL); assert(p_va != NULL); - /* Search the format: - message <- error msg, if any (else NULL). - fname <- routine name, if any (else NULL). - min <- # of required arguments, or -1 if all are required. - max <- most arguments (required + optional). - Check that kwlist has a non-NULL entry for each arg. - Raise error if a tuple arg spec is found. - */ - fname = message = NULL; - formatsave = format; - p = kwlist; - min = -1; - max = 0; - while ((i = *format++) != '\0') { - if (isalpha(Py_CHARMASK(i)) && i != 'e') { - max++; - if (*p == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "more argument specifiers than " - "keyword list entries"); - return 0; - } - p++; - } - else if (i == '|') - min = max; - else if (i == ':') { - fname = format; - break; - } - else if (i == ';') { - message = format; - break; - } - else if (i == '(') { - PyErr_SetString(PyExc_RuntimeError, - "tuple found in format when using keyword " - "arguments"); - return 0; - } - } - format = formatsave; - if (*p != NULL) { - PyErr_SetString(PyExc_RuntimeError, - "more keyword list entries than " - "argument specifiers"); - return 0; - } - if (min < 0) { - /* All arguments are required. */ - min = max; + /* grab the function name or custom error msg first (mutually exclusive) */ + fname = strchr(format, ':'); + if (fname) { + fname++; + custom_msg = NULL; + } + else { + custom_msg = strchr(format,';'); + if (custom_msg) + custom_msg++; } - nargs = PyTuple_GET_SIZE(args); - nkeywords = keywords == NULL ? 0 : PyDict_Size(keywords); + /* scan kwlist and get greatest possible nbr of args */ + for (len=0; kwlist[len]; len++) + continue; - /* make sure there are no duplicate values for an argument; - its not clear when to use the term "keyword argument vs. - keyword parameter in messages */ - if (nkeywords > 0) { - for (i = 0; i < nargs; i++) { - const char *thiskw = kwlist[i]; - if (thiskw == NULL) - break; - if (PyDict_GetItemString(keywords, thiskw)) { - PyErr_Format(PyExc_TypeError, - "keyword parameter '%s' was given " - "by position and by name", - thiskw); - return 0; - } - else if (PyErr_Occurred()) - return 0; - } - } - - /* required arguments missing from args can be supplied by keyword - arguments; set len to the number of positional arguments, and, - if that's less than the minimum required, add in the number of - required arguments that are supplied by keywords */ - len = nargs; - if (nkeywords > 0 && nargs < min) { - for (i = nargs; i < min; i++) { - if (PyDict_GetItemString(keywords, kwlist[i])) - len++; - else if (PyErr_Occurred()) - return 0; - } - } - - /* make sure we got an acceptable number of arguments; the message - is a little confusing with keywords since keyword arguments - which are supplied, but don't match the required arguments - are not included in the "%d given" part of the message - XXX and this isn't a bug!? */ - if (len < min || max < len) { - if (message == NULL) { - PyOS_snprintf(msgbuf, sizeof(msgbuf), - "%.200s%s takes %s %d argument%s " - "(%d given)", - fname==NULL ? "function" : fname, - fname==NULL ? "" : "()", - min==max ? "exactly" - : len < min ? "at least" : "at most", - len < min ? min : max, - (len < min ? min : max) == 1 ? "" : "s", - len); - message = msgbuf; - } - PyErr_SetString(PyExc_TypeError, message); + nargs = PyTuple_GET_SIZE(args); + nkeywords = (keywords == NULL) ? 0 : PyDict_Size(keywords); + if (nargs + nkeywords > len) { + PyErr_Format(PyExc_TypeError, "%s%s takes at most %d " + "argument%s (%d given)", + (fname == NULL) ? "function" : fname, + (fname == NULL) ? "" : "()", + len, + (len == 1) ? "" : "s", + nargs + nkeywords); return 0; } - /* convert the positional arguments */ - for (i = 0; i < nargs; i++) { - if (*format == '|') + /* convert tuple args and keyword args in same loop, using kwlist to drive process */ + for (i = 0; i < len; i++) { + keyword = kwlist[i]; + if (*format == '|') { + min = i; format++; - msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va, - flags, levels, msgbuf, sizeof(msgbuf), - &freelist); - if (msg) { - seterror(i+1, msg, levels, fname, message); + } + if (IS_END_OF_FORMAT(*format)) { + PyErr_Format(PyExc_RuntimeError, + "More keyword list entries (%d) than " + "format specifiers (%d)", len, i); return cleanreturn(0, freelist); } - } - - /* handle no keyword parameters in call */ - if (nkeywords == 0) - return cleanreturn(1, freelist); - - /* convert the keyword arguments; this uses the format - string where it was left after processing args */ - for (i = nargs; i < max; i++) { - PyObject *item; - if (*format == '|') - format++; - item = PyDict_GetItemString(keywords, kwlist[i]); - if (item != NULL) { - Py_INCREF(item); - msg = convertitem(item, &format, p_va, flags, levels, - msgbuf, sizeof(msgbuf), &freelist); - Py_DECREF(item); - if (msg) { - seterror(i+1, msg, levels, fname, message); + current_arg = NULL; + if (nkeywords) { + current_arg = PyDict_GetItemString(keywords, keyword); + } + if (current_arg) { + --nkeywords; + if (i < nargs) { + /* arg present in tuple and in dict */ + PyErr_Format(PyExc_TypeError, + "Argument given by name ('%s') " + "and position (%d)", + keyword, i+1); return cleanreturn(0, freelist); } - --nkeywords; - if (nkeywords == 0) - break; } - else if (PyErr_Occurred()) + else if (nkeywords && PyErr_Occurred()) return cleanreturn(0, freelist); - else { - msg = skipitem(&format, p_va, flags); + else if (i < nargs) + current_arg = PyTuple_GET_ITEM(args, i); + + if (current_arg) { + msg = convertitem(current_arg, &format, p_va, flags, + levels, msgbuf, sizeof(msgbuf), &freelist); if (msg) { - levels[0] = 0; - seterror(i+1, msg, levels, fname, message); + seterror(i+1, msg, levels, fname, custom_msg); return cleanreturn(0, freelist); } + continue; + } + + if (i < min) { + PyErr_Format(PyExc_TypeError, "Required argument " + "'%s' (pos %d) not found", + keyword, i+1); + return cleanreturn(0, freelist); + } + /* current code reports success when all required args + * fulfilled and no keyword args left, with no further + * validation. XXX Maybe skip this in debug build ? + */ + if (!nkeywords) + return cleanreturn(1, freelist); + + /* We are into optional args, skip thru to any remaining + * keyword args */ + msg = skipitem(&format, p_va, flags); + if (msg) { + PyErr_Format(PyExc_RuntimeError, "%s: '%s'", msg, + format); + return cleanreturn(0, freelist); } } + if (!IS_END_OF_FORMAT(*format)) { + PyErr_Format(PyExc_RuntimeError, + "more argument specifiers than keyword list entries " + "(remaining format:'%s')", format); + return cleanreturn(0, freelist); + } + /* make sure there are no extraneous keyword arguments */ if (nkeywords > 0) { PyObject *key, *value; @@ -1597,7 +1535,7 @@ return cleanreturn(0, freelist); } ks = PyUnicode_AsString(key); - for (i = 0; i < max; i++) { + for (i = 0; i < len; i++) { if (!strcmp(ks, kwlist[i])) { match = 1; break; @@ -1620,7 +1558,7 @@ static char * skipitem(const char **p_format, va_list *p_va, int flags) { - const char *format = *p_format; + const char *format = *p_format; char c = *format++; switch (c) { @@ -1726,15 +1664,32 @@ break; } + case '(': /* bypass tuple, not handled at all previously */ + { + char *msg; + for (;;) { + if (*format==')') + break; + if (IS_END_OF_FORMAT(*format)) + return "Unmatched left paren in format " + "string"; + msg = skipitem(&format, p_va, flags); + if (msg) + return msg; + } + format++; + break; + } + + case ')': + return "Unmatched right paren in format string"; + default: err: return "impossible"; } - /* The "(...)" format code for tuples is not handled here because - * it is not allowed with keyword args. */ - *p_format = format; return NULL; } From python-3000-checkins at python.org Thu Feb 28 13:27:12 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 28 Feb 2008 13:27:12 +0100 (CET) Subject: [Python-3000-checkins] r61104 - in python/branches/py3k: Doc/library/itertools.rst Include/object.h Lib/abc.py Lib/decimal.py Lib/test/test_descrtut.py Lib/test/test_socketserver.py Lib/threading.py Objects/typeobject.c Message-ID: <20080228122712.CA7E71E4011@bag.python.org> Author: christian.heimes Date: Thu Feb 28 13:27:11 2008 New Revision: 61104 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Include/object.h python/branches/py3k/Lib/abc.py python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/test/test_descrtut.py python/branches/py3k/Lib/test/test_socketserver.py python/branches/py3k/Lib/threading.py python/branches/py3k/Objects/typeobject.c Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61103 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61098 | jeffrey.yasskin | 2008-02-28 05:45:36 +0100 (Thu, 28 Feb 2008) | 7 lines Move abc._Abstract into object by adding a new flag Py_TPFLAGS_IS_ABSTRACT, which forbids constructing types that have it set. The effect is to speed ./python.exe -m timeit -s 'import abc' -s 'class Foo(object): __metaclass__ = abc.ABCMeta' 'Foo()' up from 2.5us to 0.201us. This fixes issue 1762. ........ r61099 | jeffrey.yasskin | 2008-02-28 06:53:18 +0100 (Thu, 28 Feb 2008) | 3 lines Speed test_socketserver up from 28.739s to 0.226s, simplify the logic, and make sure all tests run even if some fail. ........ r61100 | jeffrey.yasskin | 2008-02-28 07:09:19 +0100 (Thu, 28 Feb 2008) | 21 lines Thread.start() used sleep(0.000001) to make sure it didn't return before the new thread had started. At least on my MacBook Pro, that wound up sleeping for a full 10ms (probably 1 jiffy). By using an Event instead, we can be absolutely certain that the thread has started, and return more quickly (217us). Before: $ ./python.exe -m timeit -s 'from threading import Thread' 't = Thread(); t.start(); t.join()' 100 loops, best of 3: 10.3 msec per loop $ ./python.exe -m timeit -s 'from threading import Thread; t = Thread()' 't.isAlive()' 1000000 loops, best of 3: 0.47 usec per loop After: $ ./python.exe -m timeit -s 'from threading import Thread' 't = Thread(); t.start(); t.join()' 1000 loops, best of 3: 217 usec per loop $ ./python.exe -m timeit -s 'from threading import Thread; t = Thread()' 't.isAlive()' 1000000 loops, best of 3: 0.86 usec per loop To be fair, the 10ms isn't CPU time, and other threads including the spawned one get to run during it. There are also some slightly more complicated ways to get back the .4us in isAlive() if we want. ........ r61101 | raymond.hettinger | 2008-02-28 10:23:48 +0100 (Thu, 28 Feb 2008) | 1 line Add repeat keyword argument to itertools.product(). ........ r61102 | christian.heimes | 2008-02-28 12:18:49 +0100 (Thu, 28 Feb 2008) | 1 line The empty tuple is usually a singleton with a much higher refcnt than 1 ........ Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Thu Feb 28 13:27:11 2008 @@ -327,7 +327,7 @@ example :func:`islice` or :func:`takewhile`). -.. function:: product(*iterables) +.. function:: product(*iterables[, repeat]) Cartesian product of input iterables. @@ -340,11 +340,15 @@ so that if the inputs iterables are sorted, the product tuples are emitted in sorted order. + To compute the product of an iterable with itself, specify the number of + repetitions with the optional *repeat* keyword argument. For example, + ``product(A, repeat=4)`` means the same as ``product(A, A, A, A)``. + Equivalent to the following except that the actual implementation does not build-up intermediate results in memory:: - def product(*args): - pools = map(tuple, args) + def product(*args, **kwds): + pools = map(tuple, args) * kwds.get('repeat', 1) if pools: result = [[]] for pool in pools: Modified: python/branches/py3k/Include/object.h ============================================================================== --- python/branches/py3k/Include/object.h (original) +++ python/branches/py3k/Include/object.h Thu Feb 28 13:27:11 2008 @@ -532,6 +532,9 @@ #define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18) #define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19) +/* Type is abstract and cannot be instantiated */ +#define Py_TPFLAGS_IS_ABSTRACT (1L<<20) + /* These flags are used to determine if a type is a subclass. */ #define Py_TPFLAGS_INT_SUBCLASS (1L<<23) #define Py_TPFLAGS_LONG_SUBCLASS (1L<<24) Modified: python/branches/py3k/Lib/abc.py ============================================================================== --- python/branches/py3k/Lib/abc.py (original) +++ python/branches/py3k/Lib/abc.py Thu Feb 28 13:27:11 2008 @@ -52,50 +52,6 @@ __isabstractmethod__ = True -class _Abstract(object): - - """Helper class inserted into the bases by ABCMeta (using _fix_bases()). - - You should never need to explicitly subclass this class. - """ - - def __new__(cls, *args, **kwds): - am = cls.__dict__.get("__abstractmethods__") - if am: - raise TypeError("Can't instantiate abstract class %s " - "with abstract methods %s" % - (cls.__name__, ", ".join(sorted(am)))) - if (args or kwds) and cls.__init__ is object.__init__: - raise TypeError("Can't pass arguments to __new__ " - "without overriding __init__") - return super().__new__(cls) - - @classmethod - def __subclasshook__(cls, subclass): - """Abstract classes can override this to customize issubclass(). - - This is invoked early on by __subclasscheck__() below. It - should return True, False or NotImplemented. If it returns - NotImplemented, the normal algorithm is used. Otherwise, it - overrides the normal algorithm (and the outcome is cached). - """ - return NotImplemented - - -def _fix_bases(bases): - """Helper method that inserts _Abstract in the bases if needed.""" - for base in bases: - if issubclass(base, _Abstract): - # _Abstract is already a base (maybe indirectly) - return bases - if object in bases: - # Replace object with _Abstract - return tuple([_Abstract if base is object else base - for base in bases]) - # Append _Abstract to the end - return bases + (_Abstract,) - - class ABCMeta(type): """Metaclass for defining Abstract Base Classes (ABCs). @@ -118,7 +74,6 @@ _abc_invalidation_counter = 0 def __new__(mcls, name, bases, namespace): - bases = _fix_bases(bases) cls = super().__new__(mcls, name, bases, namespace) # Compute set of abstract method names abstracts = {name @@ -129,7 +84,7 @@ value = getattr(cls, name, None) if getattr(value, "__isabstractmethod__", False): abstracts.add(name) - cls.__abstractmethods__ = abstracts + cls.__abstractmethods__ = frozenset(abstracts) # Set up inheritance registry cls._abc_registry = WeakSet() cls._abc_cache = WeakSet() Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Thu Feb 28 13:27:11 2008 @@ -1649,6 +1649,9 @@ else: return -1 + def __round__(self): + return self._round_down(0) + def _round_up(self, prec): """Rounds away from 0.""" return -self._round_down(prec) @@ -1684,6 +1687,9 @@ else: return -self._round_down(prec) + def __ceil__(self): + return self._round_ceiling(0) + def _round_floor(self, prec): """Rounds down (not towards 0 if negative)""" if not self._sign: @@ -1691,6 +1697,9 @@ else: return -self._round_down(prec) + def __floor__(self): + return self._round_floor(0) + def _round_05up(self, prec): """Round down unless digit prec-1 is 0 or 5.""" if prec and self._int[prec-1] not in '05': Modified: python/branches/py3k/Lib/test/test_descrtut.py ============================================================================== --- python/branches/py3k/Lib/test/test_descrtut.py (original) +++ python/branches/py3k/Lib/test/test_descrtut.py Thu Feb 28 13:27:11 2008 @@ -196,6 +196,7 @@ '__setattr__', '__setitem__', '__str__', + '__subclasshook__', 'append', 'count', 'extend', Modified: python/branches/py3k/Lib/test/test_socketserver.py ============================================================================== --- python/branches/py3k/Lib/test/test_socketserver.py (original) +++ python/branches/py3k/Lib/test/test_socketserver.py Thu Feb 28 13:27:11 2008 @@ -2,13 +2,15 @@ Test suite for SocketServer.py. """ -import os -import socket import errno import imp +import os import select -import time +import signal +import socket +import tempfile import threading +import time import unittest import SocketServer @@ -19,7 +21,6 @@ test.test_support.requires("network") NREQ = 3 -DELAY = 0.5 TEST_STR = b"hello world\n" HOST = "localhost" @@ -27,14 +28,6 @@ HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" -class MyMixinHandler: - def handle(self): - time.sleep(DELAY) - line = self.rfile.readline() - time.sleep(DELAY) - self.wfile.write(line) - - def receive(sock, n, timeout=20): r, w, x = select.select([sock], [], [], timeout) if sock in r: @@ -42,14 +35,6 @@ else: raise RuntimeError("timed out on %r" % (sock,)) - -class MyStreamHandler(MyMixinHandler, SocketServer.StreamRequestHandler): - pass - -class MyDatagramHandler(MyMixinHandler, - SocketServer.DatagramRequestHandler): - pass - if HAVE_UNIX_SOCKETS: class ForkingUnixStreamServer(SocketServer.ForkingMixIn, SocketServer.UnixStreamServer): @@ -111,47 +96,28 @@ pass if verbose: print("thread: creating server") svr = svrcls(self.__addr, self.__hdlrcls) - # pull the address out of the server in case it changed - # this can happen if another process is using the port - addr = svr.server_address - if addr: - self.__addr = addr - if self.__addr != svr.socket.getsockname(): - raise RuntimeError('server_address was %s, expected %s' % - (self.__addr, svr.socket.getsockname())) + # We had the OS pick a port, so pull the real address out of + # the server. + self.addr = svr.server_address + self.port = self.addr[1] + if self.addr != svr.socket.getsockname(): + raise RuntimeError('server_address was %s, expected %s' % + (self.addr, svr.socket.getsockname())) self.ready.set() if verbose: print("thread: serving three times") svr.serve_a_few() if verbose: print("thread: done") -class ForgivingTCPServer(SocketServer.TCPServer): - # prevent errors if another process is using the port we want - def server_bind(self): - host, default_port = self.server_address - # this code shamelessly stolen from test.test_support - # the ports were changed to protect the innocent - import sys - for port in [default_port, 3434, 8798, 23833]: - try: - self.server_address = host, port - SocketServer.TCPServer.server_bind(self) - break - except socket.error as e: - (err, msg) = e - if err != errno.EADDRINUSE: - raise - print(' WARNING: failed to listen on port %d, trying another' % port, file=sys.__stderr__) - class SocketServerTest(unittest.TestCase): """Test all socket servers.""" def setUp(self): + signal.alarm(20) # Kill deadlocks after 20 seconds. self.port_seed = 0 self.test_files = [] def tearDown(self): - time.sleep(DELAY) reap_children() for fn in self.test_files: @@ -160,16 +126,18 @@ except os.error: pass self.test_files[:] = [] - - def pickport(self): - self.port_seed += 1 - return 10000 + (os.getpid() % 1000)*10 + self.port_seed + signal.alarm(0) # Didn't deadlock. def pickaddr(self, proto): if proto == socket.AF_INET: - return (HOST, self.pickport()) + return (HOST, 0) else: - fn = TEST_FILE + str(self.pickport()) + # XXX: We need a way to tell AF_UNIX to pick its own name + # like AF_INET provides port==0. + dir = None + if os.name == 'os2': + dir = '\socket' + fn = tempfile.mktemp(prefix='unix_socket.', dir=dir) if os.name == 'os2': # AF_UNIX socket names on OS/2 require a specific prefix # which can't include a drive letter and must also use @@ -178,7 +146,6 @@ fn = fn[2:] if fn[0] in (os.sep, os.altsep): fn = fn[1:] - fn = os.path.join('\socket', fn) if os.sep == '/': fn = fn.replace(os.sep, os.altsep) else: @@ -186,25 +153,31 @@ self.test_files.append(fn) return fn - def run_servers(self, proto, servers, hdlrcls, testfunc): - for svrcls in servers: - addr = self.pickaddr(proto) - if verbose: - print("ADDR =", addr) - print("CLASS =", svrcls) - t = ServerThread(addr, svrcls, hdlrcls) - if verbose: print("server created") - t.start() - if verbose: print("server running") - for i in range(NREQ): - t.ready.wait(10*DELAY) - self.assert_(t.ready.isSet(), - "Server not ready within a reasonable time") - if verbose: print("test client", i) - testfunc(proto, addr) - if verbose: print("waiting for server") - t.join() - if verbose: print("done") + + def run_server(self, svrcls, hdlrbase, testfunc): + class MyHandler(hdlrbase): + def handle(self): + line = self.rfile.readline() + self.wfile.write(line) + + addr = self.pickaddr(svrcls.address_family) + if verbose: + print("ADDR =", addr) + print("CLASS =", svrcls) + t = ServerThread(addr, svrcls, MyHandler) + if verbose: print("server created") + t.start() + if verbose: print("server running") + t.ready.wait(10) + self.assert_(t.ready.isSet(), + "%s not ready within a reasonable time" % svrcls) + addr = t.addr + for i in range(NREQ): + if verbose: print("test client", i) + testfunc(svrcls.address_family, addr) + if verbose: print("waiting for server") + t.join() + if verbose: print("done") def stream_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_STREAM) @@ -227,47 +200,74 @@ self.assertEquals(buf, TEST_STR) s.close() - def test_TCPServers(self): - # Test SocketServer.TCPServer - servers = [ForgivingTCPServer, SocketServer.ThreadingTCPServer] - if HAVE_FORKING: - servers.append(SocketServer.ForkingTCPServer) - self.run_servers(socket.AF_INET, servers, - MyStreamHandler, self.stream_examine) - - def test_UDPServers(self): - # Test SocketServer.UDPServer - servers = [SocketServer.UDPServer, - SocketServer.ThreadingUDPServer] - if HAVE_FORKING: - servers.append(SocketServer.ForkingUDPServer) - self.run_servers(socket.AF_INET, servers, MyDatagramHandler, - self.dgram_examine) - - def test_stream_servers(self): - # Test SocketServer's stream servers - if not HAVE_UNIX_SOCKETS: - return - servers = [SocketServer.UnixStreamServer, - SocketServer.ThreadingUnixStreamServer] + def test_TCPServer(self): + self.run_server(SocketServer.TCPServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + + def test_ThreadingTCPServer(self): + self.run_server(SocketServer.ThreadingTCPServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + + if HAVE_FORKING: + def test_ThreadingTCPServer(self): + self.run_server(SocketServer.ForkingTCPServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + + if HAVE_UNIX_SOCKETS: + def test_UnixStreamServer(self): + self.run_server(SocketServer.UnixStreamServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + + def test_ThreadingUnixStreamServer(self): + self.run_server(SocketServer.ThreadingUnixStreamServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + if HAVE_FORKING: - servers.append(ForkingUnixStreamServer) - self.run_servers(socket.AF_UNIX, servers, MyStreamHandler, - self.stream_examine) + def test_ForkingUnixStreamServer(self): + self.run_server(ForkingUnixStreamServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + + def test_UDPServer(self): + self.run_server(SocketServer.UDPServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) + + def test_ThreadingUDPServer(self): + self.run_server(SocketServer.ThreadingUDPServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) + + if HAVE_FORKING: + def test_ForkingUDPServer(self): + self.run_server(SocketServer.ForkingUDPServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) # Alas, on Linux (at least) recvfrom() doesn't return a meaningful # client address so this cannot work: - # def test_dgram_servers(self): - # # Test SocketServer.UnixDatagramServer - # if not HAVE_UNIX_SOCKETS: - # return - # servers = [SocketServer.UnixDatagramServer, - # SocketServer.ThreadingUnixDatagramServer] + # if HAVE_UNIX_SOCKETS: + # def test_UnixDatagramServer(self): + # self.run_server(SocketServer.UnixDatagramServer, + # SocketServer.DatagramRequestHandler, + # self.dgram_examine) + # + # def test_ThreadingUnixDatagramServer(self): + # self.run_server(SocketServer.ThreadingUnixDatagramServer, + # SocketServer.DatagramRequestHandler, + # self.dgram_examine) + # # if HAVE_FORKING: - # servers.append(ForkingUnixDatagramServer) - # self.run_servers(socket.AF_UNIX, servers, MyDatagramHandler, - # self.dgram_examine) + # def test_ForkingUnixDatagramServer(self): + # self.run_server(SocketServer.ForkingUnixDatagramServer, + # SocketServer.DatagramRequestHandler, + # self.dgram_examine) def test_main(): @@ -279,3 +279,4 @@ if __name__ == "__main__": test_main() + signal.alarm(3) # Shutdown shouldn't take more than 3 seconds. Modified: python/branches/py3k/Lib/threading.py ============================================================================== --- python/branches/py3k/Lib/threading.py (original) +++ python/branches/py3k/Lib/threading.py Thu Feb 28 13:27:11 2008 @@ -403,7 +403,7 @@ self._args = args self._kwargs = kwargs self._daemonic = self._set_daemon() - self._started = False + self._started = Event() self._stopped = False self._block = Condition(Lock()) self._initialized = True @@ -418,7 +418,7 @@ def __repr__(self): assert self._initialized, "Thread.__init__() was not called" status = "initial" - if self._started: + if self._started.isSet(): status = "started" if self._stopped: status = "stopped" @@ -429,7 +429,8 @@ def start(self): if not self._initialized: raise RuntimeError("thread.__init__() not called") - if self._started: + + if self._started.isSet(): raise RuntimeError("thread already started") if __debug__: self._note("%s.start(): starting thread", self) @@ -437,8 +438,7 @@ _limbo[self] = self _active_limbo_lock.release() _start_new_thread(self._bootstrap, ()) - self._started = True - _sleep(0.000001) # 1 usec, to let the thread run (Solaris hack) + self._started.wait() def run(self): try: @@ -455,11 +455,11 @@ # happen when a daemon thread wakes up at an unfortunate # moment, finds the world around it destroyed, and raises some # random exception *** while trying to report the exception in - # __bootstrap_inner() below ***. Those random exceptions + # _bootstrap_inner() below ***. Those random exceptions # don't help anybody, and they confuse users, so we suppress # them. We suppress them only when it appears that the world # indeed has already been destroyed, so that exceptions in - # __bootstrap_inner() during normal business hours are properly + # _bootstrap_inner() during normal business hours are properly # reported. Also, we only suppress them for daemonic threads; # if a non-daemonic encounters this, something else is wrong. try: @@ -471,29 +471,29 @@ def _bootstrap_inner(self): try: - self._started = True + self._started.set() _active_limbo_lock.acquire() _active[_get_ident()] = self del _limbo[self] _active_limbo_lock.release() if __debug__: - self._note("%s.__bootstrap(): thread started", self) + self._note("%s._bootstrap(): thread started", self) if _trace_hook: - self._note("%s.__bootstrap(): registering trace hook", self) + self._note("%s._bootstrap(): registering trace hook", self) _sys.settrace(_trace_hook) if _profile_hook: - self._note("%s.__bootstrap(): registering profile hook", self) + self._note("%s._bootstrap(): registering profile hook", self) _sys.setprofile(_profile_hook) try: self.run() except SystemExit: if __debug__: - self._note("%s.__bootstrap(): raised SystemExit", self) + self._note("%s._bootstrap(): raised SystemExit", self) except: if __debug__: - self._note("%s.__bootstrap(): unhandled exception", self) + self._note("%s._bootstrap(): unhandled exception", self) # If sys.stderr is no more (most likely from interpreter # shutdown) use self._stderr. Otherwise still use sys (as in # _sys) in case sys.stderr was redefined since the creation of @@ -526,7 +526,7 @@ del exc_type, exc_value, exc_tb else: if __debug__: - self._note("%s.__bootstrap(): normal return", self) + self._note("%s._bootstrap(): normal return", self) finally: with _active_limbo_lock: self._stop() @@ -580,7 +580,7 @@ def join(self, timeout=None): if not self._initialized: raise RuntimeError("Thread.__init__() not called") - if not self._started: + if not self._started.isSet(): raise RuntimeError("cannot join thread before it is started") if self is currentThread(): raise RuntimeError("cannot join current thread") @@ -621,7 +621,7 @@ def isAlive(self): assert self._initialized, "Thread.__init__() not called" - return self._started and not self._stopped + return self._started.isSet() and not self._stopped def isDaemon(self): assert self._initialized, "Thread.__init__() not called" @@ -630,7 +630,7 @@ def setDaemon(self, daemonic): if not self._initialized: raise RuntimeError("Thread.__init__() not called") - if self._started: + if self._started.isSet(): raise RuntimeError("cannot set daemon status of active thread"); self._daemonic = daemonic @@ -672,7 +672,7 @@ def __init__(self): Thread.__init__(self, name="MainThread") - self._started = True + self._started.set() _active_limbo_lock.acquire() _active[_get_ident()] = self _active_limbo_lock.release() @@ -718,7 +718,8 @@ # instance is immortal, that's bad, so release this resource. del self._block - self._started = True + + self._started.set() _active_limbo_lock.acquire() _active[_get_ident()] = self _active_limbo_lock.release() Modified: python/branches/py3k/Objects/typeobject.c ============================================================================== --- python/branches/py3k/Objects/typeobject.c (original) +++ python/branches/py3k/Objects/typeobject.c Thu Feb 28 13:27:11 2008 @@ -319,6 +319,40 @@ } static PyObject * +type_abstractmethods(PyTypeObject *type, void *context) +{ + PyObject *mod = PyDict_GetItemString(type->tp_dict, + "__abstractmethods__"); + if (!mod) { + PyErr_Format(PyExc_AttributeError, "__abstractmethods__"); + return NULL; + } + Py_XINCREF(mod); + return mod; +} + +static int +type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context) +{ + /* __abstractmethods__ should only be set once on a type, in + abc.ABCMeta.__new__, so this function doesn't do anything + special to update subclasses. + */ + int res = PyDict_SetItemString(type->tp_dict, + "__abstractmethods__", value); + if (res == 0) { + type_modified(type); + if (value && PyObject_IsTrue(value)) { + type->tp_flags |= Py_TPFLAGS_IS_ABSTRACT; + } + else { + type->tp_flags &= ~Py_TPFLAGS_IS_ABSTRACT; + } + } + return res; +} + +static PyObject * type_get_bases(PyTypeObject *type, void *context) { Py_INCREF(type->tp_bases); @@ -555,6 +589,8 @@ {"__name__", (getter)type_name, (setter)type_set_name, NULL}, {"__bases__", (getter)type_get_bases, (setter)type_set_bases, NULL}, {"__module__", (getter)type_module, (setter)type_set_module, NULL}, + {"__abstractmethods__", (getter)type_abstractmethods, + (setter)type_set_abstractmethods, NULL}, {"__dict__", (getter)type_dict, NULL, NULL}, {"__doc__", (getter)type_get_doc, NULL, NULL}, {0} @@ -2638,6 +2674,52 @@ } if (err < 0) return NULL; + + if (type->tp_flags & Py_TPFLAGS_IS_ABSTRACT) { + static PyObject *comma = NULL; + PyObject *abstract_methods = NULL; + PyObject *builtins; + PyObject *sorted; + PyObject *sorted_methods = NULL; + PyObject *joined = NULL; + + /* Compute ", ".join(sorted(type.__abstractmethods__)) + into joined. */ + abstract_methods = type_abstractmethods(type, NULL); + if (abstract_methods == NULL) + goto error; + builtins = PyEval_GetBuiltins(); + if (builtins == NULL) + goto error; + sorted = PyDict_GetItemString(builtins, "sorted"); + if (sorted == NULL) + goto error; + sorted_methods = PyObject_CallFunctionObjArgs(sorted, + abstract_methods, + NULL); + if (sorted_methods == NULL) + goto error; + if (comma == NULL) { + comma = PyUnicode_InternFromString(", "); + if (comma == NULL) + goto error; + } + joined = PyObject_CallMethod(comma, "join", + "O", sorted_methods); + if (joined == NULL) + goto error; + + PyErr_Format(PyExc_TypeError, + "Can't instantiate abstract class %s " + "with abstract methods %U", + type->tp_name, + joined); + error: + Py_XDECREF(joined); + Py_XDECREF(sorted_methods); + Py_XDECREF(abstract_methods); + return NULL; + } return type->tp_alloc(type, 0); } @@ -3143,6 +3225,20 @@ return _common_reduce(self, proto); } +static PyObject * +object_subclasshook(PyObject *cls, PyObject *args) +{ + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; +} + +PyDoc_STRVAR(object_subclasshook_doc, +"Abstract classes can override this to customize issubclass().\n" +"\n" +"This is invoked early on by abc.ABCMeta.__subclasscheck__().\n" +"It should return True, False or NotImplemented. If it returns\n" +"NotImplemented, the normal algorithm is used. Otherwise, it\n" +"overrides the normal algorithm (and the outcome is cached).\n"); /* from PEP 3101, this code implements: @@ -3183,6 +3279,8 @@ PyDoc_STR("helper for pickle")}, {"__reduce__", object_reduce, METH_VARARGS, PyDoc_STR("helper for pickle")}, + {"__subclasshook__", object_subclasshook, METH_CLASS | METH_VARARGS, + object_subclasshook_doc}, {"__format__", object_format, METH_VARARGS, PyDoc_STR("default object formatter")}, {0} From python-3000-checkins at python.org Thu Feb 28 21:02:27 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 28 Feb 2008 21:02:27 +0100 (CET) Subject: [Python-3000-checkins] r61110 - in python/branches/py3k: Doc/library/itertools.rst Lib/SimpleHTTPServer.py Lib/SocketServer.py Lib/test/test_socketserver.py Tools/msi/uuids.py Message-ID: <20080228200227.B006C1E4013@bag.python.org> Author: christian.heimes Date: Thu Feb 28 21:02:27 2008 New Revision: 61110 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Lib/SimpleHTTPServer.py python/branches/py3k/Lib/SocketServer.py python/branches/py3k/Lib/test/test_socketserver.py python/branches/py3k/Tools/msi/uuids.py Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61108 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61105 | andrew.kuchling | 2008-02-28 15:03:03 +0100 (Thu, 28 Feb 2008) | 1 line #2169: make generated HTML more valid ........ r61106 | jeffrey.yasskin | 2008-02-28 19:03:15 +0100 (Thu, 28 Feb 2008) | 4 lines Prevent SocketServer.ForkingMixIn from waiting on child processes that it didn't create, in most cases. When there are max_children handlers running, it will still wait for any child process, not just handler processes. ........ r61107 | raymond.hettinger | 2008-02-28 20:41:24 +0100 (Thu, 28 Feb 2008) | 1 line Document impending updates to itertools. ........ r61108 | martin.v.loewis | 2008-02-28 20:44:22 +0100 (Thu, 28 Feb 2008) | 1 line Add 2.6aN uuids. ........ Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Thu Feb 28 21:02:27 2008 @@ -74,17 +74,30 @@ yield element +.. function:: itertools.chain.from_iterable(iterable) + + Alternate constructor for :func:`chain`. Gets chained inputs from a + single iterable argument that is evaluated lazily. Equivalent to:: + + @classmethod + def from_iterable(iterables): + for it in iterables: + for element in it: + yield element + + .. versionadded:: 2.6 + .. function:: combinations(iterable, r) Return successive *r* length combinations of elements in the *iterable*. - Combinations are emitted in a lexicographic sort order. So, if the + Combinations are emitted in lexicographic sort order. So, if the input *iterable* is sorted, the combination tuples will be produced in sorted order. Elements are treated as unique based on their position, not on their value. So if the input elements are unique, there will be no repeat - values within a single combination. + values in each combination. Each result tuple is ordered to match the input order. So, every combination is a subsequence of the input *iterable*. @@ -327,6 +340,26 @@ example :func:`islice` or :func:`takewhile`). +.. function:: permutations(iterable[, r]) + + Return successive *r* length permutations of elements in the *iterable*. + + If *r* is not specified or is ``None``, then *r* defaults to the length + of the *iterable* and all possible full-length permutations + are generated. + + Permutations are emitted in lexicographic sort order. So, if the + input *iterable* is sorted, the permutation tuples will be produced + in sorted order. + + Elements are treated as unique based on their position, not on their + value. So if the input elements are unique, there will be no repeat + values in each permutation. + + Example: ``permutations(range(3),2) --> (1,2) (1,3) (2,1) (2,3) (3,1) (3,2)`` + + .. versionadded:: 2.6 + .. function:: product(*iterables[, repeat]) Cartesian product of input iterables. @@ -553,13 +586,13 @@ def ncycles(seq, n): "Returns the sequence elements n times" - return chain(*repeat(seq, n)) + return chain.from_iterable(repeat(seq, n)) def dotproduct(vec1, vec2): return sum(imap(operator.mul, vec1, vec2)) def flatten(listOfLists): - return list(chain(*listOfLists)) + return list(chain.from_iterable(listOfLists)) def repeatfunc(func, times=None, *args): """Repeat calls to func with specified arguments. @@ -568,8 +601,7 @@ """ if times is None: return starmap(func, repeat(args)) - else: - return starmap(func, repeat(args, times)) + return starmap(func, repeat(args, times)) def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." @@ -583,7 +615,7 @@ def roundrobin(*iterables): "roundrobin('abc', 'd', 'ef') --> 'a', 'd', 'e', 'b', 'f', 'c'" - # Recipe contributed by George Sakkis + # Recipe credited to George Sakkis pending = len(iterables) nexts = cycle(iter(it).next for it in iterables) while pending: @@ -595,8 +627,9 @@ nexts = cycle(islice(nexts, pending)) def powerset(iterable): - "powerset('ab') --> set([]), set(['b']), set(['a']), set(['a', 'b'])" - skip = object() - for t in product(*izip(repeat(skip), iterable)): - yield set(e for e in t if e is not skip) + "powerset('ab') --> set([]), set(['a']), set(['b']), set(['a', 'b'])" + # Recipe credited to Eric Raymond + pairs = [(2**i, x) for i, x in enumerate(iterable)] + for n in xrange(2**len(pairs)): + yield set(x for m, x in pairs if m&n) Modified: python/branches/py3k/Lib/SimpleHTTPServer.py ============================================================================== --- python/branches/py3k/Lib/SimpleHTTPServer.py (original) +++ python/branches/py3k/Lib/SimpleHTTPServer.py Thu Feb 28 21:02:27 2008 @@ -109,8 +109,9 @@ list.sort(key=lambda a: a.lower()) f = StringIO() displaypath = cgi.escape(urllib.unquote(self.path)) - f.write("Directory listing for %s\n" % displaypath) - f.write("

    Directory listing for %s

    \n" % displaypath) + f.write('') + f.write("\nDirectory listing for %s\n" % displaypath) + f.write("\n

    Directory listing for %s

    \n" % displaypath) f.write("
    \n
      \n") for name in list: fullname = os.path.join(path, name) @@ -124,7 +125,7 @@ # Note: a link to a directory displays with @ and links with / f.write('
    • %s\n' % (urllib.quote(linkname), cgi.escape(displayname))) - f.write("
    \n
    \n") + f.write("\n
    \n\n\n") length = f.tell() f.seek(0) self.send_response(200) Modified: python/branches/py3k/Lib/SocketServer.py ============================================================================== --- python/branches/py3k/Lib/SocketServer.py (original) +++ python/branches/py3k/Lib/SocketServer.py Thu Feb 28 21:02:27 2008 @@ -440,18 +440,30 @@ def collect_children(self): """Internal routine to wait for children that have exited.""" - while self.active_children: - if len(self.active_children) < self.max_children: - options = os.WNOHANG - else: - # If the maximum number of children are already - # running, block while waiting for a child to exit - options = 0 + if self.active_children is None: return + while len(self.active_children) >= self.max_children: + # XXX: This will wait for any child process, not just ones + # spawned by this library. This could confuse other + # libraries that expect to be able to wait for their own + # children. try: - pid, status = os.waitpid(0, options) + pid, status = os.waitpid(0, options=0) except os.error: pid = None - if not pid: break + if pid not in self.active_children: continue + self.active_children.remove(pid) + + # XXX: This loop runs more system calls than it ought + # to. There should be a way to put the active_children into a + # process group and then use os.waitpid(-pgid) to wait for any + # of that set, but I couldn't find a way to allocate pgids + # that couldn't collide. + for child in self.active_children: + try: + pid, status = os.waitpid(child, os.WNOHANG) + except os.error: + pid = None + if not pid: continue try: self.active_children.remove(pid) except ValueError as e: Modified: python/branches/py3k/Lib/test/test_socketserver.py ============================================================================== --- python/branches/py3k/Lib/test/test_socketserver.py (original) +++ python/branches/py3k/Lib/test/test_socketserver.py Thu Feb 28 21:02:27 2008 @@ -2,6 +2,7 @@ Test suite for SocketServer.py. """ +import contextlib import errno import imp import os @@ -109,6 +110,18 @@ if verbose: print("thread: done") + at contextlib.contextmanager +def simple_subprocess(testcase): + pid = os.fork() + if pid == 0: + # Don't throw an exception; it would be caught by the test harness. + os._exit(72) + yield None + pid2, status = os.waitpid(pid, 0) + testcase.assertEquals(pid2, pid) + testcase.assertEquals(72 << 8, status) + + class SocketServerTest(unittest.TestCase): """Test all socket servers.""" @@ -211,10 +224,11 @@ self.stream_examine) if HAVE_FORKING: - def test_ThreadingTCPServer(self): - self.run_server(SocketServer.ForkingTCPServer, - SocketServer.StreamRequestHandler, - self.stream_examine) + def test_ForkingTCPServer(self): + with simple_subprocess(self): + self.run_server(SocketServer.ForkingTCPServer, + SocketServer.StreamRequestHandler, + self.stream_examine) if HAVE_UNIX_SOCKETS: def test_UnixStreamServer(self): @@ -229,9 +243,10 @@ if HAVE_FORKING: def test_ForkingUnixStreamServer(self): - self.run_server(ForkingUnixStreamServer, - SocketServer.StreamRequestHandler, - self.stream_examine) + with simple_subprocess(self): + self.run_server(ForkingUnixStreamServer, + SocketServer.StreamRequestHandler, + self.stream_examine) def test_UDPServer(self): self.run_server(SocketServer.UDPServer, @@ -245,9 +260,10 @@ if HAVE_FORKING: def test_ForkingUDPServer(self): - self.run_server(SocketServer.ForkingUDPServer, - SocketServer.DatagramRequestHandler, - self.dgram_examine) + with simple_subprocess(self): + self.run_server(SocketServer.ForkingUDPServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) # Alas, on Linux (at least) recvfrom() doesn't return a meaningful # client address so this cannot work: Modified: python/branches/py3k/Tools/msi/uuids.py ============================================================================== --- python/branches/py3k/Tools/msi/uuids.py (original) +++ python/branches/py3k/Tools/msi/uuids.py Thu Feb 28 21:02:27 2008 @@ -37,6 +37,10 @@ '2.5.1150':'{31800004-6386-4999-a519-518f2d78d8f0}', # 2.5.1 '2.5.2150':'{6304a7da-1132-4e91-a343-a296269eab8a}', # 2.5.2c1 '2.5.2150':'{6b976adf-8ae8-434e-b282-a06c7f624d2f}', # 2.5.2 + '2.6.101': '{0ba82e1b-52fd-4e03-8610-a6c76238e8a8}', # 2.6a1 + '2.6.102': '{3b27e16c-56db-4570-a2d3-e9a26180c60b}', # 2.6a2 + '2.6.103': '{cd06a9c5-bde5-4bd7-9874-48933997122a}', # 2.6a3 + '2.6.104': '{dc6ed634-474a-4a50-a547-8de4b7491e53}', # 2.6a4 '3.0.101': '{8554263a-3242-4857-9359-aa87bc2c58c2}', # 3.0a1 '3.0.102': '{692d6e2c-f0ac-40b8-a133-7191aeeb67f9}', # 3.0a2 '3.0.103': '{49cb2995-751a-4753-be7a-d0b1bb585e06}', # 3.0a3 From python-3000-checkins at python.org Thu Feb 28 21:52:40 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 28 Feb 2008 21:52:40 +0100 (CET) Subject: [Python-3000-checkins] r61112 - in python/branches/py3k: Tools/msi/msi.py Message-ID: <20080228205240.A65A01E4011@bag.python.org> Author: christian.heimes Date: Thu Feb 28 21:52:40 2008 New Revision: 61112 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Tools/msi/msi.py Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61104,61109-61111 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61109 | martin.v.loewis | 2008-02-28 20:57:34 +0100 (Thu, 28 Feb 2008) | 1 line Bundle msvcr90.dll as a "private assembly". ........ Modified: python/branches/py3k/Tools/msi/msi.py ============================================================================== --- python/branches/py3k/Tools/msi/msi.py (original) +++ python/branches/py3k/Tools/msi/msi.py Thu Feb 28 21:52:40 2008 @@ -845,21 +845,19 @@ prod_dir = _winreg.QueryValueEx(k, "ProductDir")[0] _winreg.CloseKey(k) - # Copy msvcr90* - dir = os.path.join(prod_dir, r'VC\redist\x86\Microsoft.VC90.CRT') - files = glob.glob1(dir, "*CRT*.dll") + glob.glob1(dir, "*VCR*.dll") - for file in files: - shutil.copy(os.path.join(dir, file), '.') - - dir = os.path.join(prod_dir, r'VC\redist\Debug_NonRedist\x86\Microsoft.VC90.DebugCRT') - files = glob.glob1(dir, "*CRT*.dll") + glob.glob1(dir, "*VCR*.dll") - for file in files: - shutil.copy(os.path.join(dir, file), '.') - - # Find the version/language of msvcr90.dll + result = [] installer = msilib.MakeInstaller() - return installer.FileVersion("msvcr90.dll", 0), \ - installer.FileVersion("msvcr90.dll", 1) + dir = os.path.join(prod_dir, r'VC\redist\x86\Microsoft.VC90.CRT') + # omit msvcm90 and msvcp90, as they aren't really needed + files = ["Microsoft.VC90.CRT.manifest", "msvcr90.dll"] + for f in files: + path = os.path.join(dir, f) + kw = {'src':path} + if f.endswith('.dll'): + kw['version'] = installer.FileVersion(path, 0) + kw['language'] = installer.FileVersion(path, 1) + result.append((f, kw)) + return result class PyDirectory(Directory): """By default, all components in the Python installer @@ -888,7 +886,10 @@ root.add_file("%s/pythonw.exe" % PCBUILD) # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table" - dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".") + #dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".") + #install python30.dll into root dir for now + dlldir = root + pydll = "python%s%s.dll" % (major, minor) pydllsrc = os.path.join(srcdir, PCBUILD, pydll) dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid) @@ -901,17 +902,14 @@ dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor), version=pyversion, language=installer.FileVersion(pydllsrc, 1)) + DLLs = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs") # XXX determine dependencies if MSVCR == "90": - # XXX don't package the CRT for the moment; - # this should probably use the merge module in the long run. - pass - #version, lang = extract_msvcr90() - #dlldir.start_component("msvcr90", flags=8, keyfile="msvcr90.dll", - # uuid=msvcr90_uuid) - #dlldir.add_file("msvcr90.dll", src=os.path.abspath("msvcr90.dll"), - # version=version, language=lang) - #tmpfiles.append("msvcr90.dll") + root.start_component("msvcr90") + for file, kw in extract_msvcr90(): + root.add_file(file, **kw) + if file.endswith("manifest"): + DLLs.add_file(file, **kw) else: version, lang = extract_msvcr71() dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll", @@ -1012,7 +1010,7 @@ pydirs.append((lib, f)) # Add DLLs default_feature.set_current() - lib = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs") + lib = DLLs lib.add_file("py.ico", src=srcdir+"/PC/py.ico") lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico") dlls = [] From python-3000-checkins at python.org Thu Feb 28 22:10:17 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 28 Feb 2008 22:10:17 +0100 (CET) Subject: [Python-3000-checkins] r61114 - python/branches/py3k/Lib/tempfile.py Message-ID: <20080228211017.EA24B1E4027@bag.python.org> Author: christian.heimes Date: Thu Feb 28 22:10:17 2008 New Revision: 61114 Modified: python/branches/py3k/Lib/tempfile.py Log: iter() doesn't use __getattr__ to find an __iter__ method. I'm not sure if the behavior is deliberately but this workaround fixes the issue for the next alpha release tomorrow. Modified: python/branches/py3k/Lib/tempfile.py ============================================================================== --- python/branches/py3k/Lib/tempfile.py (original) +++ python/branches/py3k/Lib/tempfile.py Thu Feb 28 22:10:17 2008 @@ -394,6 +394,10 @@ self.file.__enter__() return self + # XXX iter() doesn't use __getattr__ to find the __iter__ method + def __iter__(self): + return self.__getattr__('__iter__')() + # NT provides delete-on-close as a primitive, so we don't need # the wrapper to do anything special. We still use it so that # file.name is useful (i.e. not "(fdopen)") with NamedTemporaryFile. From python-3000-checkins at python.org Thu Feb 28 22:17:00 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 28 Feb 2008 22:17:00 +0100 (CET) Subject: [Python-3000-checkins] r61115 - in python/branches/py3k: Lib/test/test_signal.py Message-ID: <20080228211700.9921D1E4011@bag.python.org> Author: christian.heimes Date: Thu Feb 28 22:17:00 2008 New Revision: 61115 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_signal.py Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61104,61110-61113 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61113 | christian.heimes | 2008-02-28 22:00:45 +0100 (Thu, 28 Feb 2008) | 2 lines Windows fix for signal test - skip it earlier ........ Modified: python/branches/py3k/Lib/test/test_signal.py ============================================================================== --- python/branches/py3k/Lib/test/test_signal.py (original) +++ python/branches/py3k/Lib/test/test_signal.py Thu Feb 28 22:17:00 2008 @@ -1,7 +1,12 @@ import unittest from test import test_support import signal -import os, sys, time, errno +import sys, os, time, errno + +if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos': + raise test_support.TestSkipped("Can't test signal on %s" % \ + sys.platform) + class HandlerBCalled(Exception): pass @@ -257,10 +262,6 @@ self.assertEquals(i, False) def test_main(): - if sys.platform[:3] in ('win', 'os2'): - raise test_support.TestSkipped("Can't test signal on %s" % \ - sys.platform) - test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupSignalTests, SiginterruptTest) From guido at python.org Thu Feb 28 23:12:18 2008 From: guido at python.org (Guido van Rossum) Date: Thu, 28 Feb 2008 14:12:18 -0800 Subject: [Python-3000-checkins] r61114 - python/branches/py3k/Lib/tempfile.py In-Reply-To: <20080228211017.EA24B1E4027@bag.python.org> References: <20080228211017.EA24B1E4027@bag.python.org> Message-ID: IMO it should be def __iter__(self): return iter(self.file) On Thu, Feb 28, 2008 at 1:10 PM, christian.heimes wrote: > Author: christian.heimes > Date: Thu Feb 28 22:10:17 2008 > New Revision: 61114 > > Modified: > python/branches/py3k/Lib/tempfile.py > Log: > iter() doesn't use __getattr__ to find an __iter__ method. I'm not sure if the behavior is deliberately but this workaround fixes the issue for the next alpha release tomorrow. > > Modified: python/branches/py3k/Lib/tempfile.py > ============================================================================== > --- python/branches/py3k/Lib/tempfile.py (original) > +++ python/branches/py3k/Lib/tempfile.py Thu Feb 28 22:10:17 2008 > @@ -394,6 +394,10 @@ > self.file.__enter__() > return self > > + # XXX iter() doesn't use __getattr__ to find the __iter__ method > + def __iter__(self): > + return self.__getattr__('__iter__')() > + > # NT provides delete-on-close as a primitive, so we don't need > # the wrapper to do anything special. We still use it so that > # file.name is useful (i.e. not "(fdopen)") with NamedTemporaryFile. > _______________________________________________ > Python-3000-checkins mailing list > Python-3000-checkins at python.org > http://mail.python.org/mailman/listinfo/python-3000-checkins > -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-3000-checkins at python.org Thu Feb 28 23:21:11 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 28 Feb 2008 23:21:11 +0100 (CET) Subject: [Python-3000-checkins] r61117 - python/branches/py3k/Lib/tempfile.py Message-ID: <20080228222111.B11111E4011@bag.python.org> Author: christian.heimes Date: Thu Feb 28 23:21:11 2008 New Revision: 61117 Modified: python/branches/py3k/Lib/tempfile.py Log: As Guido says Modified: python/branches/py3k/Lib/tempfile.py ============================================================================== --- python/branches/py3k/Lib/tempfile.py (original) +++ python/branches/py3k/Lib/tempfile.py Thu Feb 28 23:21:11 2008 @@ -394,9 +394,9 @@ self.file.__enter__() return self - # XXX iter() doesn't use __getattr__ to find the __iter__ method + # iter() doesn't use __getattr__ to find the __iter__ method def __iter__(self): - return self.__getattr__('__iter__')() + return iter(self.file) # NT provides delete-on-close as a primitive, so we don't need # the wrapper to do anything special. We still use it so that From python-3000-checkins at python.org Fri Feb 29 00:01:33 2008 From: python-3000-checkins at python.org (martin.v.loewis) Date: Fri, 29 Feb 2008 00:01:33 +0100 (CET) Subject: [Python-3000-checkins] r61120 - in python/branches/py3k: Tools/msi/msi.py Message-ID: <20080228230133.6C89C1E401F@bag.python.org> Author: martin.v.loewis Date: Fri Feb 29 00:01:33 2008 New Revision: 61120 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Tools/msi/msi.py Log: Merged revisions 61116 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61116 | martin.v.loewis | 2008-02-28 23:20:50 +0100 (Do, 28 Feb 2008) | 1 line Locate VS installation dir from environment, so that it works with the express edition. ........ Modified: python/branches/py3k/Tools/msi/msi.py ============================================================================== --- python/branches/py3k/Tools/msi/msi.py (original) +++ python/branches/py3k/Tools/msi/msi.py Fri Feb 29 00:01:33 2008 @@ -837,17 +837,11 @@ installer.FileVersion("msvcr71.dll", 1) def extract_msvcr90(): - import _winreg - # Find the location of the merge modules - k = _winreg.OpenKey( - _winreg.HKEY_LOCAL_MACHINE, - r"Software\Microsoft\VisualStudio\9.0\Setup\VS") - prod_dir = _winreg.QueryValueEx(k, "ProductDir")[0] - _winreg.CloseKey(k) + # Find the redistributable files + dir = os.path.join(os.environ['VS90COMNTOOLS'], r"..\..\VC\redist\x86\Microsoft.VC90.CRT") result = [] installer = msilib.MakeInstaller() - dir = os.path.join(prod_dir, r'VC\redist\x86\Microsoft.VC90.CRT') # omit msvcm90 and msvcp90, as they aren't really needed files = ["Microsoft.VC90.CRT.manifest", "msvcr90.dll"] for f in files: From python-3000-checkins at python.org Fri Feb 29 00:03:53 2008 From: python-3000-checkins at python.org (martin.v.loewis) Date: Fri, 29 Feb 2008 00:03:53 +0100 (CET) Subject: [Python-3000-checkins] r61121 - python/branches/py3k/Tools/msi/msi.py Message-ID: <20080228230353.0F4611E4011@bag.python.org> Author: martin.v.loewis Date: Fri Feb 29 00:03:52 2008 New Revision: 61121 Modified: python/branches/py3k/Tools/msi/msi.py Log: Package 2to3. Modified: python/branches/py3k/Tools/msi/msi.py ============================================================================== --- python/branches/py3k/Tools/msi/msi.py (original) +++ python/branches/py3k/Tools/msi/msi.py Fri Feb 29 00:03:52 2008 @@ -1071,7 +1071,7 @@ # Add tools tools.set_current() tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools") - for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']: + for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker', '2to3']: lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f)) lib.glob("*.py") lib.glob("*.pyw", exclude=['pydocgui.pyw']) From python-3000-checkins at python.org Fri Feb 29 15:57:44 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Fri, 29 Feb 2008 15:57:44 +0100 (CET) Subject: [Python-3000-checkins] r61126 - in python/branches/py3k: Lib/decimal.py Lib/test/test_decimal.py Lib/test/test_itertools.py Modules/itertoolsmodule.c Message-ID: <20080229145744.EA0D91E4003@bag.python.org> Author: christian.heimes Date: Fri Feb 29 15:57:44 2008 New Revision: 61126 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/test/test_decimal.py python/branches/py3k/Lib/test/test_itertools.py python/branches/py3k/Modules/itertoolsmodule.c Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61104,61110-61112,61114-61115,61117-61125 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61118 | raymond.hettinger | 2008-02-28 23:30:42 +0100 (Thu, 28 Feb 2008) | 1 line Have itertools.chain() consume its inputs lazily instead of building a tuple of iterators at the outset. ........ r61119 | raymond.hettinger | 2008-02-28 23:46:41 +0100 (Thu, 28 Feb 2008) | 1 line Add alternate constructor for itertools.chain(). ........ r61123 | mark.dickinson | 2008-02-29 03:16:37 +0100 (Fri, 29 Feb 2008) | 2 lines Add __format__ method to Decimal, to support PEP 3101 ........ r61124 | raymond.hettinger | 2008-02-29 03:21:48 +0100 (Fri, 29 Feb 2008) | 1 line Handle the repeat keyword argument for itertools.product(). ........ r61125 | mark.dickinson | 2008-02-29 04:29:17 +0100 (Fri, 29 Feb 2008) | 2 lines Fix docstring typo. ........ Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Fri Feb 29 15:57:44 2008 @@ -2381,6 +2381,29 @@ coeff = str(int(coeff)+1) return _dec_from_triple(self._sign, coeff, exp) + def _round(self, places, rounding): + """Round a nonzero, nonspecial Decimal to a fixed number of + significant figures, using the given rounding mode. + + Infinities, NaNs and zeros are returned unaltered. + + This operation is quiet: it raises no flags, and uses no + information from the context. + + """ + if places <= 0: + raise ValueError("argument should be at least 1 in _round") + if self._is_special or not self: + return Decimal(self) + ans = self._rescale(self.adjusted()+1-places, rounding) + # it can happen that the rescale alters the adjusted exponent; + # for example when rounding 99.97 to 3 significant figures. + # When this happens we end up with an extra 0 at the end of + # the number; a second rescale fixes this. + if ans.adjusted() != self.adjusted(): + ans = ans._rescale(ans.adjusted()+1-places, rounding) + return ans + def to_integral_exact(self, rounding=None, context=None): """Rounds to a nearby integer. @@ -3432,6 +3455,95 @@ return self # My components are also immutable return self.__class__(str(self)) + # PEP 3101 support. See also _parse_format_specifier and _format_align + def __format__(self, specifier, context=None): + """Format a Decimal instance according to the given specifier. + + The specifier should be a standard format specifier, with the + form described in PEP 3101. Formatting types 'e', 'E', 'f', + 'F', 'g', 'G', and '%' are supported. If the formatting type + is omitted it defaults to 'g' or 'G', depending on the value + of context.capitals. + + At this time the 'n' format specifier type (which is supposed + to use the current locale) is not supported. + """ + + # Note: PEP 3101 says that if the type is not present then + # there should be at least one digit after the decimal point. + # We take the liberty of ignoring this requirement for + # Decimal---it's presumably there to make sure that + # format(float, '') behaves similarly to str(float). + if context is None: + context = getcontext() + + spec = _parse_format_specifier(specifier) + + # special values don't care about the type or precision... + if self._is_special: + return _format_align(str(self), spec) + + # a type of None defaults to 'g' or 'G', depending on context + # if type is '%', adjust exponent of self accordingly + if spec['type'] is None: + spec['type'] = ['g', 'G'][context.capitals] + elif spec['type'] == '%': + self = _dec_from_triple(self._sign, self._int, self._exp+2) + + # round if necessary, taking rounding mode from the context + rounding = context.rounding + precision = spec['precision'] + if precision is not None: + if spec['type'] in 'eE': + self = self._round(precision+1, rounding) + elif spec['type'] in 'gG': + if len(self._int) > precision: + self = self._round(precision, rounding) + elif spec['type'] in 'fF%': + self = self._rescale(-precision, rounding) + # special case: zeros with a positive exponent can't be + # represented in fixed point; rescale them to 0e0. + elif not self and self._exp > 0 and spec['type'] in 'fF%': + self = self._rescale(0, rounding) + + # figure out placement of the decimal point + leftdigits = self._exp + len(self._int) + if spec['type'] in 'fF%': + dotplace = leftdigits + elif spec['type'] in 'eE': + if not self and precision is not None: + dotplace = 1 - precision + else: + dotplace = 1 + elif spec['type'] in 'gG': + if self._exp <= 0 and leftdigits > -6: + dotplace = leftdigits + else: + dotplace = 1 + + # figure out main part of numeric string... + if dotplace <= 0: + num = '0.' + '0'*(-dotplace) + self._int + elif dotplace >= len(self._int): + # make sure we're not padding a '0' with extra zeros on the right + assert dotplace==len(self._int) or self._int != '0' + num = self._int + '0'*(dotplace-len(self._int)) + else: + num = self._int[:dotplace] + '.' + self._int[dotplace:] + + # ...then the trailing exponent, or trailing '%' + if leftdigits != dotplace or spec['type'] in 'eE': + echar = {'E': 'E', 'e': 'e', 'G': 'E', 'g': 'e'}[spec['type']] + num = num + "{0}{1:+}".format(echar, leftdigits-dotplace) + elif spec['type'] == '%': + num = num + '%' + + # add sign + if self._sign == 1: + num = '-' + num + return _format_align(num, spec) + + def _dec_from_triple(sign, coefficient, exponent, special=False): """Create a decimal instance directly, without any validation, normalization (e.g. removal of leading zeros) or argument @@ -5249,8 +5361,136 @@ _all_zeros = re.compile('0*$').match _exact_half = re.compile('50*$').match + +##### PEP3101 support functions ############################################## +# The functions parse_format_specifier and format_align have little to do +# with the Decimal class, and could potentially be reused for other pure +# Python numeric classes that want to implement __format__ +# +# A format specifier for Decimal looks like: +# +# [[fill]align][sign][0][minimumwidth][.precision][type] +# + +_parse_format_specifier_regex = re.compile(r"""\A +(?: + (?P.)? + (?P[<>=^]) +)? +(?P[-+ ])? +(?P0)? +(?P(?!0)\d+)? +(?:\.(?P0|(?!0)\d+))? +(?P[eEfFgG%])? +\Z +""", re.VERBOSE) + del re +def _parse_format_specifier(format_spec): + """Parse and validate a format specifier. + + Turns a standard numeric format specifier into a dict, with the + following entries: + + fill: fill character to pad field to minimum width + align: alignment type, either '<', '>', '=' or '^' + sign: either '+', '-' or ' ' + minimumwidth: nonnegative integer giving minimum width + precision: nonnegative integer giving precision, or None + type: one of the characters 'eEfFgG%', or None + unicode: either True or False (always True for Python 3.x) + + """ + m = _parse_format_specifier_regex.match(format_spec) + if m is None: + raise ValueError("Invalid format specifier: " + format_spec) + + # get the dictionary + format_dict = m.groupdict() + + # defaults for fill and alignment + fill = format_dict['fill'] + align = format_dict['align'] + if format_dict.pop('zeropad') is not None: + # in the face of conflict, refuse the temptation to guess + if fill is not None and fill != '0': + raise ValueError("Fill character conflicts with '0'" + " in format specifier: " + format_spec) + if align is not None and align != '=': + raise ValueError("Alignment conflicts with '0' in " + "format specifier: " + format_spec) + fill = '0' + align = '=' + format_dict['fill'] = fill or ' ' + format_dict['align'] = align or '<' + + if format_dict['sign'] is None: + format_dict['sign'] = '-' + + # turn minimumwidth and precision entries into integers. + # minimumwidth defaults to 0; precision remains None if not given + format_dict['minimumwidth'] = int(format_dict['minimumwidth'] or '0') + if format_dict['precision'] is not None: + format_dict['precision'] = int(format_dict['precision']) + + # if format type is 'g' or 'G' then a precision of 0 makes little + # sense; convert it to 1. Same if format type is unspecified. + if format_dict['precision'] == 0: + if format_dict['type'] in 'gG' or format_dict['type'] is None: + format_dict['precision'] = 1 + + # record whether return type should be str or unicode + format_dict['unicode'] = isinstance(format_spec, unicode) + + return format_dict + +def _format_align(body, spec_dict): + """Given an unpadded, non-aligned numeric string, add padding and + aligment to conform with the given format specifier dictionary (as + output from parse_format_specifier). + + It's assumed that if body is negative then it starts with '-'. + Any leading sign ('-' or '+') is stripped from the body before + applying the alignment and padding rules, and replaced in the + appropriate position. + + """ + # figure out the sign; we only examine the first character, so if + # body has leading whitespace the results may be surprising. + if len(body) > 0 and body[0] in '-+': + sign = body[0] + body = body[1:] + else: + sign = '' + + if sign != '-': + if spec_dict['sign'] in ' +': + sign = spec_dict['sign'] + else: + sign = '' + + # how much extra space do we have to play with? + minimumwidth = spec_dict['minimumwidth'] + fill = spec_dict['fill'] + padding = fill*(max(minimumwidth - (len(sign+body)), 0)) + + align = spec_dict['align'] + if align == '<': + result = padding + sign + body + elif align == '>': + result = sign + body + padding + elif align == '=': + result = sign + padding + body + else: #align == '^' + half = len(padding)//2 + result = padding[:half] + sign + body + padding[half:] + + # make sure that result is unicode if necessary + if spec_dict['unicode']: + result = unicode(result) + + return result ##### Useful Constants (internal use only) ################################ Modified: python/branches/py3k/Lib/test/test_decimal.py ============================================================================== --- python/branches/py3k/Lib/test/test_decimal.py (original) +++ python/branches/py3k/Lib/test/test_decimal.py Fri Feb 29 15:57:44 2008 @@ -610,6 +610,98 @@ self.assertEqual(eval('Decimal(10)' + sym + 'E()'), '10' + rop + 'str') +class DecimalFormatTest(unittest.TestCase): + '''Unit tests for the format function.''' + def test_formatting(self): + # triples giving a format, a Decimal, and the expected result + test_values = [ + ('e', '0E-15', '0e-15'), + ('e', '2.3E-15', '2.3e-15'), + ('e', '2.30E+2', '2.30e+2'), # preserve significant zeros + ('e', '2.30000E-15', '2.30000e-15'), + ('e', '1.23456789123456789e40', '1.23456789123456789e+40'), + ('e', '1.5', '1.5e+0'), + ('e', '0.15', '1.5e-1'), + ('e', '0.015', '1.5e-2'), + ('e', '0.0000000000015', '1.5e-12'), + ('e', '15.0', '1.50e+1'), + ('e', '-15', '-1.5e+1'), + ('e', '0', '0e+0'), + ('e', '0E1', '0e+1'), + ('e', '0.0', '0e-1'), + ('e', '0.00', '0e-2'), + ('.6e', '0E-15', '0.000000e-9'), + ('.6e', '0', '0.000000e+6'), + ('.6e', '9.999999', '9.999999e+0'), + ('.6e', '9.9999999', '1.000000e+1'), + ('.6e', '-1.23e5', '-1.230000e+5'), + ('.6e', '1.23456789e-3', '1.234568e-3'), + ('f', '0', '0'), + ('f', '0.0', '0.0'), + ('f', '0E-2', '0.00'), + ('f', '0.00E-8', '0.0000000000'), + ('f', '0E1', '0'), # loses exponent information + ('f', '3.2E1', '32'), + ('f', '3.2E2', '320'), + ('f', '3.20E2', '320'), + ('f', '3.200E2', '320.0'), + ('f', '3.2E-6', '0.0000032'), + ('.6f', '0E-15', '0.000000'), # all zeros treated equally + ('.6f', '0E1', '0.000000'), + ('.6f', '0', '0.000000'), + ('.0f', '0', '0'), # no decimal point + ('.0f', '0e-2', '0'), + ('.0f', '3.14159265', '3'), + ('.1f', '3.14159265', '3.1'), + ('.4f', '3.14159265', '3.1416'), + ('.6f', '3.14159265', '3.141593'), + ('.7f', '3.14159265', '3.1415926'), # round-half-even! + ('.8f', '3.14159265', '3.14159265'), + ('.9f', '3.14159265', '3.141592650'), + + ('g', '0', '0'), + ('g', '0.0', '0.0'), + ('g', '0E1', '0e+1'), + ('G', '0E1', '0E+1'), + ('g', '0E-5', '0.00000'), + ('g', '0E-6', '0.000000'), + ('g', '0E-7', '0e-7'), + ('g', '-0E2', '-0e+2'), + ('.0g', '3.14159265', '3'), # 0 sig fig -> 1 sig fig + ('.1g', '3.14159265', '3'), + ('.2g', '3.14159265', '3.1'), + ('.5g', '3.14159265', '3.1416'), + ('.7g', '3.14159265', '3.141593'), + ('.8g', '3.14159265', '3.1415926'), # round-half-even! + ('.9g', '3.14159265', '3.14159265'), + ('.10g', '3.14159265', '3.14159265'), # don't pad + + ('%', '0E1', '0%'), + ('%', '0E0', '0%'), + ('%', '0E-1', '0%'), + ('%', '0E-2', '0%'), + ('%', '0E-3', '0.0%'), + ('%', '0E-4', '0.00%'), + + ('.3%', '0', '0.000%'), # all zeros treated equally + ('.3%', '0E10', '0.000%'), + ('.3%', '0E-10', '0.000%'), + ('.3%', '2.34', '234.000%'), + ('.3%', '1.234567', '123.457%'), + ('.0%', '1.23', '123%'), + + ('e', 'NaN', 'NaN'), + ('f', '-NaN123', '-NaN123'), + ('+g', 'NaN456', '+NaN456'), + ('.3e', 'Inf', 'Infinity'), + ('.16f', '-Inf', '-Infinity'), + ('.0g', '-sNaN', '-sNaN'), + + ('', '1.00', '1.00'), + ] + for fmt, d, result in test_values: + self.assertEqual(format(Decimal(d), fmt), result) + class DecimalArithmeticOperatorsTest(unittest.TestCase): '''Unit tests for all arithmetic operators, binary and unary.''' @@ -1351,6 +1443,7 @@ DecimalExplicitConstructionTest, DecimalImplicitConstructionTest, DecimalArithmeticOperatorsTest, + DecimalFormatTest, DecimalUseOfContextTest, DecimalUsabilityTest, DecimalPythonAPItests, Modified: python/branches/py3k/Lib/test/test_itertools.py ============================================================================== --- python/branches/py3k/Lib/test/test_itertools.py (original) +++ python/branches/py3k/Lib/test/test_itertools.py Fri Feb 29 15:57:44 2008 @@ -54,7 +54,14 @@ self.assertEqual(list(chain('abc')), list('abc')) self.assertEqual(list(chain('')), []) self.assertEqual(take(4, chain('abc', 'def')), list('abcd')) - self.assertRaises(TypeError, chain, 2, 3) + self.assertRaises(TypeError, list,chain(2, 3)) + + def test_chain_from_iterable(self): + self.assertEqual(list(chain.from_iterable(['abc', 'def'])), list('abcdef')) + self.assertEqual(list(chain.from_iterable(['abc'])), list('abc')) + self.assertEqual(list(chain.from_iterable([''])), []) + self.assertEqual(take(4, chain.from_iterable(['abc', 'def'])), list('abcd')) + self.assertRaises(TypeError, list, chain.from_iterable([2, 3])) def test_combinations(self): self.assertRaises(TypeError, combinations, 'abc') # missing r argument @@ -298,6 +305,9 @@ ([range(2), range(3), range(0)], []), # last iterable with zero length ]: self.assertEqual(list(product(*args)), result) + for r in range(4): + self.assertEqual(list(product(*(args*r))), + list(product(*args, **dict(repeat=r)))) self.assertEqual(len(list(product(*[range(7)]*6))), 7**6) self.assertRaises(TypeError, product, range(6), None) argtypes = ['', 'abc', '', range(0), range(4), dict(a=1, b=2, c=3), @@ -684,7 +694,7 @@ for g in (G, I, Ig, S, L, R): self.assertEqual(list(chain(g(s))), list(g(s))) self.assertEqual(list(chain(g(s), g(s))), list(g(s))+list(g(s))) - self.assertRaises(TypeError, chain, X(s)) + self.assertRaises(TypeError, list, chain(X(s))) self.assertRaises(TypeError, chain, N(s)) self.assertRaises(ZeroDivisionError, list, chain(E(s))) Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Fri Feb 29 15:57:44 2008 @@ -1571,92 +1571,104 @@ typedef struct { PyObject_HEAD - Py_ssize_t tuplesize; - Py_ssize_t iternum; /* which iterator is active */ - PyObject *ittuple; /* tuple of iterators */ + PyObject *source; /* Iterator over input iterables */ + PyObject *active; /* Currently running input iterator */ } chainobject; static PyTypeObject chain_type; +static PyObject * +chain_new_internal(PyTypeObject *type, PyObject *source) +{ + chainobject *lz; + + lz = (chainobject *)type->tp_alloc(type, 0); + if (lz == NULL) { + Py_DECREF(source); + return NULL; + } + + lz->source = source; + lz->active = NULL; + return (PyObject *)lz; +} + static PyObject * chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - chainobject *lz; - Py_ssize_t tuplesize = PySequence_Length(args); - Py_ssize_t i; - PyObject *ittuple; + PyObject *source; if (type == &chain_type && !_PyArg_NoKeywords("chain()", kwds)) return NULL; - - /* obtain iterators */ - assert(PyTuple_Check(args)); - ittuple = PyTuple_New(tuplesize); - if (ittuple == NULL) + + source = PyObject_GetIter(args); + if (source == NULL) return NULL; - for (i=0; i < tuplesize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - PyObject *it = PyObject_GetIter(item); - if (it == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "chain argument #%zd must support iteration", - i+1); - Py_DECREF(ittuple); - return NULL; - } - PyTuple_SET_ITEM(ittuple, i, it); - } - /* create chainobject structure */ - lz = (chainobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(ittuple); - return NULL; - } + return chain_new_internal(type, source); +} - lz->ittuple = ittuple; - lz->iternum = 0; - lz->tuplesize = tuplesize; +static PyObject * +chain_new_from_iterable(PyTypeObject *type, PyObject *arg) +{ + PyObject *source; + + source = PyObject_GetIter(arg); + if (source == NULL) + return NULL; - return (PyObject *)lz; + return chain_new_internal(type, source); } static void chain_dealloc(chainobject *lz) { PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->ittuple); + Py_XDECREF(lz->active); + Py_XDECREF(lz->source); Py_TYPE(lz)->tp_free(lz); } static int chain_traverse(chainobject *lz, visitproc visit, void *arg) { - Py_VISIT(lz->ittuple); + Py_VISIT(lz->source); + Py_VISIT(lz->active); return 0; } static PyObject * chain_next(chainobject *lz) { - PyObject *it; PyObject *item; - while (lz->iternum < lz->tuplesize) { - it = PyTuple_GET_ITEM(lz->ittuple, lz->iternum); - item = PyIter_Next(it); - if (item != NULL) - return item; - if (PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_StopIteration)) - PyErr_Clear(); - else - return NULL; + if (lz->source == NULL) + return NULL; /* already stopped */ + + if (lz->active == NULL) { + PyObject *iterable = PyIter_Next(lz->source); + if (iterable == NULL) { + Py_CLEAR(lz->source); + return NULL; /* no more input sources */ + } + lz->active = PyObject_GetIter(iterable); + if (lz->active == NULL) { + Py_DECREF(iterable); + Py_CLEAR(lz->source); + return NULL; /* input not iterable */ } - lz->iternum++; } - return NULL; + item = PyIter_Next(lz->active); + if (item != NULL) + return item; + if (PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_StopIteration)) + PyErr_Clear(); + else + return NULL; /* input raised an exception */ + } + Py_CLEAR(lz->active); + return chain_next(lz); /* recurse and use next active */ } PyDoc_STRVAR(chain_doc, @@ -1666,6 +1678,18 @@ first iterable until it is exhausted, then elements from the next\n\ iterable, until all of the iterables are exhausted."); +PyDoc_STRVAR(chain_from_iterable_doc, +"chain.from_iterable(iterable) --> chain object\n\ +\n\ +Alternate chain() contructor taking a single iterable argument\n\ +that evaluates lazily."); + +static PyMethodDef chain_methods[] = { + {"from_iterable", (PyCFunction) chain_new_from_iterable, METH_O | METH_CLASS, + chain_from_iterable_doc}, + {NULL, NULL} /* sentinel */ +}; + static PyTypeObject chain_type = { PyVarObject_HEAD_INIT(NULL, 0) "itertools.chain", /* tp_name */ @@ -1696,7 +1720,7 @@ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ (iternextfunc)chain_next, /* tp_iternext */ - 0, /* tp_methods */ + chain_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -1728,17 +1752,32 @@ product_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { productobject *lz; - Py_ssize_t npools; + Py_ssize_t nargs, npools, repeat=1; PyObject *pools = NULL; Py_ssize_t *maxvec = NULL; Py_ssize_t *indices = NULL; Py_ssize_t i; - if (type == &product_type && !_PyArg_NoKeywords("product()", kwds)) - return NULL; + if (kwds != NULL) { + char *kwlist[] = {"repeat", 0}; + PyObject *tmpargs = PyTuple_New(0); + if (tmpargs == NULL) + return NULL; + if (!PyArg_ParseTupleAndKeywords(tmpargs, kwds, "|n:product", kwlist, &repeat)) { + Py_DECREF(tmpargs); + return NULL; + } + Py_DECREF(tmpargs); + if (repeat < 0) { + PyErr_SetString(PyExc_ValueError, + "repeat argument cannot be negative"); + return NULL; + } + } assert(PyTuple_Check(args)); - npools = PyTuple_GET_SIZE(args); + nargs = (repeat == 0) ? 0 : PyTuple_GET_SIZE(args); + npools = nargs * repeat; maxvec = PyMem_Malloc(npools * sizeof(Py_ssize_t)); indices = PyMem_Malloc(npools * sizeof(Py_ssize_t)); @@ -1751,7 +1790,7 @@ if (pools == NULL) goto error; - for (i=0; i < npools; ++i) { + for (i=0; i < nargs ; ++i) { PyObject *item = PyTuple_GET_ITEM(args, i); PyObject *pool = PySequence_Tuple(item); if (pool == NULL) @@ -1761,6 +1800,13 @@ maxvec[i] = PyTuple_GET_SIZE(pool); indices[i] = 0; } + for ( ; i < npools; ++i) { + PyObject *pool = PyTuple_GET_ITEM(pools, i - nargs); + Py_INCREF(pool); + PyTuple_SET_ITEM(pools, i, pool); + maxvec[i] = maxvec[i - nargs]; + indices[i] = 0; + } /* create productobject structure */ lz = (productobject *)type->tp_alloc(type, 0); From python-3000-checkins at python.org Fri Feb 29 16:03:39 2008 From: python-3000-checkins at python.org (christian.heimes) Date: Fri, 29 Feb 2008 16:03:39 +0100 (CET) Subject: [Python-3000-checkins] r61127 - python/branches/py3k/Lib/decimal.py Message-ID: <20080229150339.D52601E401A@bag.python.org> Author: christian.heimes Date: Fri Feb 29 16:03:39 2008 New Revision: 61127 Modified: python/branches/py3k/Lib/decimal.py Log: I forgot to start the unit test suite first. Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Fri Feb 29 16:03:39 2008 @@ -5441,7 +5441,7 @@ format_dict['precision'] = 1 # record whether return type should be str or unicode - format_dict['unicode'] = isinstance(format_spec, unicode) + format_dict['unicode'] = True return format_dict @@ -5486,10 +5486,6 @@ half = len(padding)//2 result = padding[:half] + sign + body + padding[half:] - # make sure that result is unicode if necessary - if spec_dict['unicode']: - result = unicode(result) - return result ##### Useful Constants (internal use only) ################################ From python-3000-checkins at python.org Fri Feb 29 20:39:26 2008 From: python-3000-checkins at python.org (martin.v.loewis) Date: Fri, 29 Feb 2008 20:39:26 +0100 (CET) Subject: [Python-3000-checkins] r61137 - in python/branches/py3k: Doc/make.bat Doc/tools/sphinxext/download.html PCbuild/_hashlib.vcproj PCbuild/_ssl.vcproj PCbuild/build_ssl.py PCbuild/pcbuild.sln PCbuild/readme.txt PCbuild/x64.vsprops Tools/buildbot/external.bat Message-ID: <20080229193926.0A6951E4009@bag.python.org> Author: martin.v.loewis Date: Fri Feb 29 20:39:25 2008 New Revision: 61137 Added: python/branches/py3k/PCbuild/_hashlib.vcproj - copied unchanged from r61136, python/trunk/PCbuild/_hashlib.vcproj Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/make.bat python/branches/py3k/Doc/tools/sphinxext/download.html python/branches/py3k/PCbuild/_ssl.vcproj python/branches/py3k/PCbuild/build_ssl.py python/branches/py3k/PCbuild/pcbuild.sln python/branches/py3k/PCbuild/readme.txt python/branches/py3k/PCbuild/x64.vsprops python/branches/py3k/Tools/buildbot/external.bat Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61104,61110-61112,61114-61115,61117,61120-61122,61126-61136 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61128 | martin.v.loewis | 2008-02-29 17:59:21 +0100 (Fr, 29 Feb 2008) | 1 line Make _hashlib a separate project. ........ r61132 | georg.brandl | 2008-02-29 19:15:36 +0100 (Fr, 29 Feb 2008) | 2 lines Until we got downloadable docs, stop confusing viewers by talking about a nonexisting table. ........ r61133 | martin.v.loewis | 2008-02-29 19:17:23 +0100 (Fr, 29 Feb 2008) | 1 line Build db-4.4.20 with VS9; remove VS2003 build if necessary. ........ r61135 | georg.brandl | 2008-02-29 19:21:29 +0100 (Fr, 29 Feb 2008) | 2 lines #2208: allow for non-standard HHC location. ........ r61136 | martin.v.loewis | 2008-02-29 19:54:45 +0100 (Fr, 29 Feb 2008) | 1 line Port build_ssl.py to 2.4; support HOST_PYTHON variable ........ Modified: python/branches/py3k/Doc/make.bat ============================================================================== --- python/branches/py3k/Doc/make.bat (original) +++ python/branches/py3k/Doc/make.bat Fri Feb 29 20:39:25 2008 @@ -1,8 +1,9 @@ - at echo off +@@echo off setlocal set SVNROOT=http://svn.python.org/projects -if "%PYTHON%" EQU "" set PYTHON=python25 +if "%PYTHON%" EQU "" set PYTHON=..\pcbuild\python +if "%HTMLHELP%" EQU "" set HTMLHELP=%ProgramFiles%\HTML Help Workshop\hhc.exe if "%1" EQU "" goto help if "%1" EQU "html" goto build @@ -41,7 +42,7 @@ if not exist build\%1 mkdir build\%1 if not exist build\doctrees mkdir build\doctrees cmd /C %PYTHON% tools\sphinx-build.py -b%1 -dbuild\doctrees . build\%1 -if "%1" EQU "htmlhelp" "%ProgramFiles%\HTML Help Workshop\hhc.exe" build\htmlhelp\pydoc.hhp +if "%1" EQU "htmlhelp" "%HTMLHELP%" build\htmlhelp\pydoc.hhp goto end :webrun Modified: python/branches/py3k/Doc/tools/sphinxext/download.html ============================================================================== --- python/branches/py3k/Doc/tools/sphinxext/download.html (original) +++ python/branches/py3k/Doc/tools/sphinxext/download.html Fri Feb 29 20:39:25 2008 @@ -5,6 +5,9 @@

    Download Python {{ release }} Documentation {%- if last_updated %} (last updated on {{ last_updated }}){% endif %}

    +

    Currently, the development documentation isn't packaged for download.

    + + + {% endblock %} Modified: python/branches/py3k/PCbuild/_ssl.vcproj ============================================================================== --- python/branches/py3k/PCbuild/_ssl.vcproj (original) +++ python/branches/py3k/PCbuild/_ssl.vcproj Fri Feb 29 20:39:25 2008 @@ -27,7 +27,7 @@ > - - Modified: python/branches/py3k/PCbuild/build_ssl.py ============================================================================== --- python/branches/py3k/PCbuild/build_ssl.py (original) +++ python/branches/py3k/PCbuild/build_ssl.py Fri Feb 29 20:39:25 2008 @@ -102,8 +102,11 @@ """ if not os.path.isfile(m32): return - with open(m32) as fin: - with open(makefile, 'w') as fout: + # 2.4 compatibility + fin = open(m32) + if 1: # with open(m32) as fin: + fout = open(makefile, 'w') + if 1: # with open(makefile, 'w') as fout: for line in fin: line = line.replace("=tmp32", "=tmp64") line = line.replace("=out32", "=out64") @@ -121,9 +124,13 @@ """ if not os.path.isfile(makefile): return - with open(makefile) as fin: + # 2.4 compatibility + fin = open(makefile) + if 1: # with open(makefile) as fin: lines = fin.readlines() - with open(makefile, 'w') as fout: + fin.close() + fout = open(makefile, 'w') + if 1: # with open(makefile, 'w') as fout: for line in lines: if line.startswith("PERL="): continue @@ -139,6 +146,7 @@ line = line + noalgo line = line + '\n' fout.write(line) + fout.close() def run_configure(configure, do_script): print("perl Configure "+configure) Modified: python/branches/py3k/PCbuild/pcbuild.sln ============================================================================== --- python/branches/py3k/PCbuild/pcbuild.sln (original) +++ python/branches/py3k/PCbuild/pcbuild.sln Fri Feb 29 20:39:25 2008 @@ -108,6 +108,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bdist_wininst", "bdist_wininst.vcproj", "{EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -464,6 +466,22 @@ {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGUpdate|x64.ActiveCfg = Release|Win32 {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Release|Win32.ActiveCfg = Release|Win32 {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Release|x64.ActiveCfg = Release|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|Win32.ActiveCfg = Debug|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|Win32.Build.0 = Debug|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|x64.ActiveCfg = Debug|x64 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|x64.Build.0 = Debug|x64 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|x64.Build.0 = PGInstrument|x64 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|x64.Build.0 = PGUpdate|x64 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|Win32.ActiveCfg = Release|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|Win32.Build.0 = Release|Win32 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|x64.ActiveCfg = Release|x64 + {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: python/branches/py3k/PCbuild/readme.txt ============================================================================== --- python/branches/py3k/PCbuild/readme.txt (original) +++ python/branches/py3k/PCbuild/readme.txt Fri Feb 29 20:39:25 2008 @@ -303,7 +303,8 @@ ------------------ The build process for AMD64 / x64 is very similar to standard builds. You just -have to set x64 as platform. +have to set x64 as platform. In addition, the HOST_PYTHON environment variable +must point to a Python interpreter (at least 2.4), to support cross-compilation. Building Python Using the free MS Toolkit Compiler -------------------------------------------------- Modified: python/branches/py3k/PCbuild/x64.vsprops ============================================================================== --- python/branches/py3k/PCbuild/x64.vsprops (original) +++ python/branches/py3k/PCbuild/x64.vsprops Fri Feb 29 20:39:25 2008 @@ -15,4 +15,8 @@ Name="VCLinkerTool" TargetMachine="17" /> + Modified: python/branches/py3k/Tools/buildbot/external.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/external.bat (original) +++ python/branches/py3k/Tools/buildbot/external.bat Fri Feb 29 20:39:25 2008 @@ -8,9 +8,14 @@ if not exist bzip2-1.0.3 svn export http://svn.python.org/projects/external/bzip2-1.0.3 @rem Sleepycat db -if not exist db-4.4.20 svn export http://svn.python.org/projects/external/db-4.4.20 + at rem Remove VS 2003 builds +if exist db-4.4.20 if not exist db-4.4.20\build_win32\this_is_for_vs9 ( + echo Removing old build + rd /s/q db-4.4.20 +) +if not exist db-4.4.20 svn export http://svn.python.org/projects/external/db-4.4.20-vs9 db-4.4.20 if not exist db-4.4.20\build_win32\debug\libdb44sd.lib ( - vcbuild db-4.4.20\build_win32\Berkeley_DB.sln /build Debug /project db_static + vcbuild db-4.4.20\build_win32\db_static.vcproj "Debug|Win32" ) @rem OpenSSL From python-3000-checkins at python.org Fri Feb 29 22:03:38 2008 From: python-3000-checkins at python.org (martin.v.loewis) Date: Fri, 29 Feb 2008 22:03:38 +0100 (CET) Subject: [Python-3000-checkins] r61140 - in python/branches/py3k: PCbuild/pcbuild.sln Tools/msi/msi.py Message-ID: <20080229210338.9A9ED1E4025@bag.python.org> Author: martin.v.loewis Date: Fri Feb 29 22:03:38 2008 New Revision: 61140 Modified: python/branches/py3k/ (props changed) python/branches/py3k/PCbuild/pcbuild.sln python/branches/py3k/Tools/msi/msi.py Log: Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61104,61110-61112,61114-61115,61117,61120-61122,61126-61127,61129-61131,61134,61137-61139 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r61138 | martin.v.loewis | 2008-02-29 21:26:53 +0100 (Fr, 29 Feb 2008) | 1 line Make _hashlib depend on pythoncore. ........ r61139 | martin.v.loewis | 2008-02-29 21:54:44 +0100 (Fr, 29 Feb 2008) | 1 line Package Tcl from tcltk64 on AMD64. ........ Modified: python/branches/py3k/PCbuild/pcbuild.sln ============================================================================== --- python/branches/py3k/PCbuild/pcbuild.sln (original) +++ python/branches/py3k/PCbuild/pcbuild.sln Fri Feb 29 22:03:38 2008 @@ -109,6 +109,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bdist_wininst", "bdist_wininst.vcproj", "{EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}" + ProjectSection(ProjectDependencies) = postProject + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Modified: python/branches/py3k/Tools/msi/msi.py ============================================================================== --- python/branches/py3k/Tools/msi/msi.py (original) +++ python/branches/py3k/Tools/msi/msi.py Fri Feb 29 22:03:38 2008 @@ -1022,8 +1022,10 @@ sqlite_arch = "/ia64" elif msilib.msi_type=="x64;1033": sqlite_arch = "/amd64" + tclsuffix = "64" else: sqlite_arch = "" + tclsuffix = "" lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll") if have_tcl: if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)): @@ -1032,7 +1034,7 @@ lib.start_component("TkDLLs", tcltk) lib.add_file("_tkinter.pyd") dlls.append("_tkinter.pyd") - tcldir = os.path.normpath(srcdir+"/../tcltk/bin") + tcldir = os.path.normpath(srcdir+("/../tcltk%s/bin" % tclsuffix)) for f in glob.glob1(tcldir, "*.dll"): lib.add_file(f, src=os.path.join(tcldir, f)) # check whether there are any unknown extensions @@ -1056,7 +1058,7 @@ lib.add_file('libpython%s%s.a' % (major, minor)) if have_tcl: # Add Tcl/Tk - tcldirs = [(root, '../tcltk/lib', 'tcl')] + tcldirs = [(root, '../tcltk%s/lib' % tclsuffix, 'tcl')] tcltk.set_current() while tcldirs: parent, phys, dir = tcldirs.pop() From python-3000-checkins at python.org Fri Feb 29 23:22:10 2008 From: python-3000-checkins at python.org (gerhard.haering) Date: Fri, 29 Feb 2008 23:22:10 +0100 (CET) Subject: [Python-3000-checkins] r61142 - in python/branches/py3k: Lib/sqlite3/test/regression.py Modules/_sqlite/cursor.c Message-ID: <20080229222210.2C4961E4009@bag.python.org> Author: gerhard.haering Date: Fri Feb 29 23:22:09 2008 New Revision: 61142 Modified: python/branches/py3k/Lib/sqlite3/test/regression.py python/branches/py3k/Modules/_sqlite/cursor.c Log: Make sure we get usable error messages when text could not be decoded when fetched from the database. Modified: python/branches/py3k/Lib/sqlite3/test/regression.py ============================================================================== --- python/branches/py3k/Lib/sqlite3/test/regression.py (original) +++ python/branches/py3k/Lib/sqlite3/test/regression.py Fri Feb 29 23:22:09 2008 @@ -79,6 +79,20 @@ cur.fetchone() cur.fetchone() + def CheckErrorMsgDecodeError(self): + # When porting the module to Python 3.0, the error message about + # decoding errors disappeared. This verifies they're back again. + failure = None + try: + self.con.execute("select 'xxx' || ? || 'yyy' colname", (bytes(bytearray([250])),)).fetchone() + failure = "should have raised an OperationalError with detailed description" + except sqlite.OperationalError as e: + msg = e.args[0] + if not msg.startswith("Could not decode to UTF-8 column 'colname' with text 'xxx"): + failure = "OperationalError did not have expected description text" + if failure: + self.fail(failure) + def suite(): regression_suite = unittest.makeSuite(RegressionTests, "Check") return unittest.TestSuite((regression_suite,)) Modified: python/branches/py3k/Modules/_sqlite/cursor.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/cursor.c (original) +++ python/branches/py3k/Modules/_sqlite/cursor.c Fri Feb 29 23:22:09 2008 @@ -295,6 +295,8 @@ const char* val_str; char buf[200]; const char* colname; + PyObject* buf_bytes; + PyObject* error_obj; Py_BEGIN_ALLOW_THREADS numcols = sqlite3_data_count(self->statement->st); @@ -363,7 +365,19 @@ } PyOS_snprintf(buf, sizeof(buf) - 1, "Could not decode to UTF-8 column '%s' with text '%s'", colname , val_str); - PyErr_SetString(pysqlite_OperationalError, buf); + buf_bytes = PyBytes_FromStringAndSize(buf, strlen(buf)); + if (!buf_bytes) { + PyErr_SetString(pysqlite_OperationalError, "Could not decode to UTF-8"); + } else { + error_obj = PyUnicode_FromEncodedObject(buf_bytes, "ascii", "replace"); + if (!error_obj) { + PyErr_SetString(pysqlite_OperationalError, "Could not decode to UTF-8"); + Py_DECREF(error_obj); + } else { + PyErr_SetObject(pysqlite_OperationalError, error_obj); + } + Py_DECREF(buf_bytes); + } } } else if (self->connection->text_factory == (PyObject*)&PyString_Type) { converted = PyString_FromString(val_str);