From python-3000-checkins at python.org Thu Nov 1 00:29:20 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 1 Nov 2007 00:29:20 +0100 (CET) Subject: [Python-3000-checkins] r58741 - in python/branches/py3k-pep3137: Include/abstract.h Include/object.h Include/opcode.h Lib/_abcoll.py Lib/copy.py Lib/dumbdbm.py Lib/encodings/__init__.py Lib/idlelib/OutputWindow.py Lib/io.py Lib/mailbox.py Lib/modulefinder.py Lib/pickle.py Lib/pickletools.py Lib/plat-mac/aepack.py Lib/sre_parse.py Lib/struct.py Lib/subprocess.py Lib/test/buffer_tests.py Lib/test/pickletester.py Lib/test/string_tests.py Lib/test/test_builtin.py Lib/test/test_bytes.py Lib/test/test_io.py Lib/test/test_pickle.py Lib/xmlrpclib.py Objects/bytesobject.c Objects/fileobject.c Objects/object.c Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c Python/bltinmodule.c Python/ceval.c Python/compile.c Python/pythonrun.c Message-ID: <20071031232920.687C91E400D@bag.python.org> Author: guido.van.rossum Date: Thu Nov 1 00:29:18 2007 New Revision: 58741 Modified: python/branches/py3k-pep3137/Include/abstract.h python/branches/py3k-pep3137/Include/object.h python/branches/py3k-pep3137/Include/opcode.h python/branches/py3k-pep3137/Lib/_abcoll.py python/branches/py3k-pep3137/Lib/copy.py python/branches/py3k-pep3137/Lib/dumbdbm.py python/branches/py3k-pep3137/Lib/encodings/__init__.py python/branches/py3k-pep3137/Lib/idlelib/OutputWindow.py python/branches/py3k-pep3137/Lib/io.py python/branches/py3k-pep3137/Lib/mailbox.py python/branches/py3k-pep3137/Lib/modulefinder.py python/branches/py3k-pep3137/Lib/pickle.py python/branches/py3k-pep3137/Lib/pickletools.py python/branches/py3k-pep3137/Lib/plat-mac/aepack.py python/branches/py3k-pep3137/Lib/sre_parse.py python/branches/py3k-pep3137/Lib/struct.py python/branches/py3k-pep3137/Lib/subprocess.py python/branches/py3k-pep3137/Lib/test/buffer_tests.py python/branches/py3k-pep3137/Lib/test/pickletester.py python/branches/py3k-pep3137/Lib/test/string_tests.py python/branches/py3k-pep3137/Lib/test/test_builtin.py python/branches/py3k-pep3137/Lib/test/test_bytes.py python/branches/py3k-pep3137/Lib/test/test_io.py python/branches/py3k-pep3137/Lib/test/test_pickle.py python/branches/py3k-pep3137/Lib/xmlrpclib.py python/branches/py3k-pep3137/Objects/bytesobject.c python/branches/py3k-pep3137/Objects/fileobject.c python/branches/py3k-pep3137/Objects/object.c python/branches/py3k-pep3137/Objects/stringobject.c python/branches/py3k-pep3137/Objects/typeobject.c python/branches/py3k-pep3137/Objects/unicodeobject.c python/branches/py3k-pep3137/Python/bltinmodule.c python/branches/py3k-pep3137/Python/ceval.c python/branches/py3k-pep3137/Python/compile.c python/branches/py3k-pep3137/Python/pythonrun.c Log: Veeeeeery preliminary submit (so I can go trick-or-treating). This has 59 failing tests (not using -uall)! Use at your own risk! I started out with Christian Heimes's "harmless" patch from issue 1247, but went way beyond, because this is *my* branch. ;-) This has the new names according to PEP 3137: PyString=bytes, PyBytes=buffer. It also removes much behavior from PyString that would interoperate with PyUnicode and vice versa. It makes PyString and PyBytes more similar in behavior. Modified: python/branches/py3k-pep3137/Include/abstract.h ============================================================================== --- python/branches/py3k-pep3137/Include/abstract.h (original) +++ python/branches/py3k-pep3137/Include/abstract.h Thu Nov 1 00:29:18 2007 @@ -259,7 +259,7 @@ string representation on success, NULL on failure. This is the equivalent of the Python expression: repr(o). - Called by the repr() built-in function and by reverse quotes. + Called by the repr() built-in function. */ @@ -271,20 +271,7 @@ string representation on success, NULL on failure. This is the equivalent of the Python expression: str(o).) - Called by the str() built-in function and by the print - statement. - - */ - - /* Implemented elsewhere: - - PyObject *PyObject_Unicode(PyObject *o); - - Compute the unicode representation of object, o. Returns the - unicode representation on success, NULL on failure. This is - the equivalent of the Python expression: unistr(o).) - - Called by the unistr() built-in function. + Called by the str() and print() built-in functions. */ Modified: python/branches/py3k-pep3137/Include/object.h ============================================================================== --- python/branches/py3k-pep3137/Include/object.h (original) +++ python/branches/py3k-pep3137/Include/object.h Thu Nov 1 00:29:18 2007 @@ -431,10 +431,8 @@ PyAPI_FUNC(void) _Py_BreakPoint(void); PyAPI_FUNC(void) _PyObject_Dump(PyObject *); PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_ReprStr8(PyObject *); -PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *); PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *); +#define PyObject_Unicode PyObject_Str /* Compatibility */ PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); @@ -478,7 +476,7 @@ PyAPI_FUNC(long) _Py_HashPointer(void*); /* Helper for passing objects to printf and the like */ -#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_ReprStr8(obj)) +#define PyObject_REPR(obj) PyUnicode_AsString(PyObject_Repr(obj)) /* Flag bits for printing: */ #define Py_PRINT_RAW 1 /* No string quotes etc. */ Modified: python/branches/py3k-pep3137/Include/opcode.h ============================================================================== --- python/branches/py3k-pep3137/Include/opcode.h (original) +++ python/branches/py3k-pep3137/Include/opcode.h Thu Nov 1 00:29:18 2007 @@ -65,7 +65,7 @@ #define RETURN_VALUE 83 #define IMPORT_STAR 84 -#define MAKE_BYTES 85 + #define YIELD_VALUE 86 #define POP_BLOCK 87 #define END_FINALLY 88 Modified: python/branches/py3k-pep3137/Lib/_abcoll.py ============================================================================== --- python/branches/py3k-pep3137/Lib/_abcoll.py (original) +++ python/branches/py3k-pep3137/Lib/_abcoll.py Thu Nov 1 00:29:18 2007 @@ -489,7 +489,7 @@ Sequence.register(tuple) Sequence.register(str) -Sequence.register(str8) +Sequence.register(bytes) Sequence.register(memoryview) Modified: python/branches/py3k-pep3137/Lib/copy.py ============================================================================== --- python/branches/py3k-pep3137/Lib/copy.py (original) +++ python/branches/py3k-pep3137/Lib/copy.py Thu Nov 1 00:29:18 2007 @@ -187,7 +187,7 @@ d[complex] = _deepcopy_atomic except NameError: pass -d[str8] = _deepcopy_atomic +d[bytes] = _deepcopy_atomic d[str] = _deepcopy_atomic try: d[types.CodeType] = _deepcopy_atomic Modified: python/branches/py3k-pep3137/Lib/dumbdbm.py ============================================================================== --- python/branches/py3k-pep3137/Lib/dumbdbm.py (original) +++ python/branches/py3k-pep3137/Lib/dumbdbm.py Thu Nov 1 00:29:18 2007 @@ -163,7 +163,7 @@ if not isinstance(key, bytes): raise TypeError("keys must be bytes") key = key.decode("latin-1") # hashable bytes - if not isinstance(val, (str8, bytes)): + if not isinstance(val, (bytes, bytes)): raise TypeError("values must be byte strings") if key not in self._index: self._addkey(key, self._addval(val)) Modified: python/branches/py3k-pep3137/Lib/encodings/__init__.py ============================================================================== --- python/branches/py3k-pep3137/Lib/encodings/__init__.py (original) +++ python/branches/py3k-pep3137/Lib/encodings/__init__.py Thu Nov 1 00:29:18 2007 @@ -52,7 +52,7 @@ non-ASCII characters, these must be Latin-1 compatible. """ - if isinstance(encoding, str8): + if isinstance(encoding, bytes): encoding = str(encoding, "ascii") chars = [] punct = False Modified: python/branches/py3k-pep3137/Lib/idlelib/OutputWindow.py ============================================================================== --- python/branches/py3k-pep3137/Lib/idlelib/OutputWindow.py (original) +++ python/branches/py3k-pep3137/Lib/idlelib/OutputWindow.py Thu Nov 1 00:29:18 2007 @@ -35,7 +35,7 @@ # Act as output file def write(self, s, tags=(), mark="insert"): - if isinstance(s, (bytes, str8)): + if isinstance(s, (bytes, bytes)): s = s.decode(IOBinding.encoding, "replace") self.text.insert(mark, s, tags) self.text.see(mark) Modified: python/branches/py3k-pep3137/Lib/io.py ============================================================================== --- python/branches/py3k-pep3137/Lib/io.py (original) +++ python/branches/py3k-pep3137/Lib/io.py Thu Nov 1 00:29:18 2007 @@ -391,7 +391,7 @@ return 1 if limit is None: limit = -1 - res = bytes() + res = buffer() while limit < 0 or len(res) < limit: b = self.read(nreadahead()) if not b: @@ -399,7 +399,7 @@ res += b if res.endswith(b"\n"): break - return res + return bytes(res) def __iter__(self): self._checkClosed() @@ -454,20 +454,20 @@ n = -1 if n < 0: return self.readall() - b = bytes(n.__index__()) + b = buffer(n.__index__()) n = self.readinto(b) del b[n:] - return b + return bytes(b) def readall(self): """readall() -> bytes. Read until EOF, using multiple read() call.""" - res = bytes() + res = buffer() while True: data = self.read(DEFAULT_BUFFER_SIZE) if not data: break res += data - return res + return bytes(res) def readinto(self, b: bytes) -> int: """readinto(b: bytes) -> int. Read up to len(b) bytes into b. @@ -655,10 +655,10 @@ # XXX More docs def __init__(self, initial_bytes=None): - buffer = b"" + buf = buffer() if initial_bytes is not None: - buffer += initial_bytes - self._buffer = buffer + buf += initial_bytes + self._buffer = buf self._pos = 0 def getvalue(self): @@ -819,7 +819,7 @@ self.max_buffer_size = (2*buffer_size if max_buffer_size is None else max_buffer_size) - self._write_buf = b"" + self._write_buf = buffer() def write(self, b): if self.closed: @@ -1186,7 +1186,7 @@ try: decoder.setstate((b"", decoder_state)) n = 0 - bb = bytes(1) + bb = buffer(1) for i, bb[0] in enumerate(readahead): n += len(decoder.decode(bb)) if n >= needed: Modified: python/branches/py3k-pep3137/Lib/mailbox.py ============================================================================== --- python/branches/py3k-pep3137/Lib/mailbox.py (original) +++ python/branches/py3k-pep3137/Lib/mailbox.py Thu Nov 1 00:29:18 2007 @@ -1762,11 +1762,11 @@ def read(self, size=None): """Read bytes.""" - return str(self._read(size, self._file.read)) + return self._read(size, self._file.read) def readline(self, size=None): """Read a line.""" - return str(self._read(size, self._file.readline)) + return self._read(size, self._file.readline) def readlines(self, sizehint=None): """Read multiple lines.""" Modified: python/branches/py3k-pep3137/Lib/modulefinder.py ============================================================================== --- python/branches/py3k-pep3137/Lib/modulefinder.py (original) +++ python/branches/py3k-pep3137/Lib/modulefinder.py Thu Nov 1 00:29:18 2007 @@ -17,12 +17,12 @@ READ_MODE = "r" # XXX Clean up once str8's cstor matches bytes. -LOAD_CONST = str8([dis.opname.index('LOAD_CONST')]) -IMPORT_NAME = str8([dis.opname.index('IMPORT_NAME')]) -STORE_NAME = str8([dis.opname.index('STORE_NAME')]) -STORE_GLOBAL = str8([dis.opname.index('STORE_GLOBAL')]) +LOAD_CONST = bytes([dis.opname.index('LOAD_CONST')]) +IMPORT_NAME = bytes([dis.opname.index('IMPORT_NAME')]) +STORE_NAME = bytes([dis.opname.index('STORE_NAME')]) +STORE_GLOBAL = bytes([dis.opname.index('STORE_GLOBAL')]) STORE_OPS = [STORE_NAME, STORE_GLOBAL] -HAVE_ARGUMENT = str8([dis.HAVE_ARGUMENT]) +HAVE_ARGUMENT = bytes([dis.HAVE_ARGUMENT]) # Modulefinder does a good job at simulating Python's, but it can not # handle __path__ modifications packages make at runtime. Therefore there @@ -368,7 +368,7 @@ consts = co.co_consts LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME while code: - c = str8([code[0]]) + c = bytes([code[0]]) if c in STORE_OPS: oparg, = unpack('= str8(b"ab"), True) - self.assertEqual(b"abc" > str8(b"ab"), True) - - self.assertEqual(b"abc" != str8(b"abc"), False) - self.assertEqual(b"ab" == str8(b"abc"), False) - self.assertEqual(b"ab" > str8(b"abc"), False) - self.assertEqual(b"ab" >= str8(b"abc"), False) - self.assertEqual(b"abc" < str8(b"ab"), False) - self.assertEqual(b"abc" <= str8(b"ab"), False) - - self.assertEqual(str8(b"abc") == b"abc", True) - self.assertEqual(str8(b"ab") != b"abc", True) - self.assertEqual(str8(b"ab") <= b"abc", True) - self.assertEqual(str8(b"ab") < b"abc", True) - self.assertEqual(str8(b"abc") >= b"ab", True) - self.assertEqual(str8(b"abc") > b"ab", True) - - self.assertEqual(str8(b"abc") != b"abc", False) - self.assertEqual(str8(b"ab") == b"abc", False) - self.assertEqual(str8(b"ab") > b"abc", False) - self.assertEqual(str8(b"ab") >= b"abc", False) - self.assertEqual(str8(b"abc") < b"ab", False) - self.assertEqual(str8(b"abc") <= b"ab", False) + def test_compare_bytes_to_buffer(self): + self.assertEqual(b"abc" == bytes(b"abc"), True) + self.assertEqual(b"ab" != bytes(b"abc"), True) + self.assertEqual(b"ab" <= bytes(b"abc"), True) + self.assertEqual(b"ab" < bytes(b"abc"), True) + self.assertEqual(b"abc" >= bytes(b"ab"), True) + self.assertEqual(b"abc" > bytes(b"ab"), True) + + self.assertEqual(b"abc" != bytes(b"abc"), False) + self.assertEqual(b"ab" == bytes(b"abc"), False) + self.assertEqual(b"ab" > bytes(b"abc"), False) + self.assertEqual(b"ab" >= bytes(b"abc"), False) + self.assertEqual(b"abc" < bytes(b"ab"), False) + self.assertEqual(b"abc" <= bytes(b"ab"), False) + + self.assertEqual(bytes(b"abc") == b"abc", True) + self.assertEqual(bytes(b"ab") != b"abc", True) + self.assertEqual(bytes(b"ab") <= b"abc", True) + self.assertEqual(bytes(b"ab") < b"abc", True) + self.assertEqual(bytes(b"abc") >= b"ab", True) + self.assertEqual(bytes(b"abc") > b"ab", True) + + self.assertEqual(bytes(b"abc") != b"abc", False) + self.assertEqual(bytes(b"ab") == b"abc", False) + self.assertEqual(bytes(b"ab") > b"abc", False) + self.assertEqual(bytes(b"ab") >= b"abc", False) + self.assertEqual(bytes(b"abc") < b"ab", False) + self.assertEqual(bytes(b"abc") <= b"ab", False) # Byte comparisons with unicode should always fail! # Test this for all expected byte orders and Unicode character sizes @@ -146,19 +154,21 @@ self.assertEqual(b"\0\0\0a\0\0\0b\0\0\0c" == "abc", False) self.assertEqual(b"a\0b\0c\0" == "abc", False) self.assertEqual(b"a\0\0\0b\0\0\0c\0\0\0" == "abc", False) - self.assertEqual(bytes() == str(), False) - self.assertEqual(bytes() != str(), True) + self.assertEqual(buffer() == str(), False) + self.assertEqual(buffer() != str(), True) def test_nohash(self): - self.assertRaises(TypeError, hash, bytes()) + self.assertRaises(TypeError, hash, buffer()) def test_doc(self): + self.failUnless(buffer.__doc__ != None) + self.failUnless(buffer.__doc__.startswith("buffer("), buffer.__doc__) self.failUnless(bytes.__doc__ != None) - self.failUnless(bytes.__doc__.startswith("bytes(")) + self.failUnless(bytes.__doc__.startswith("bytes("), bytes.__doc__) def test_buffer_api(self): short_sample = b"Hello world\n" - sample = short_sample + b"x"*(20 - len(short_sample)) + sample = short_sample + b"\0"*(20 - len(short_sample)) tfn = tempfile.mktemp() try: # Prepare @@ -166,7 +176,7 @@ f.write(short_sample) # Test readinto with open(tfn, "rb") as f: - b = b"x"*20 + b = buffer(20) n = f.readinto(b) self.assertEqual(n, len(short_sample)) self.assertEqual(list(b), list(sample)) @@ -184,25 +194,25 @@ def test_reversed(self): input = list(map(ord, "Hello")) - b = bytes(input) + b = buffer(input) output = list(reversed(b)) input.reverse() self.assertEqual(output, input) def test_reverse(self): - b = b'hello' + b = buffer(b'hello') self.assertEqual(b.reverse(), None) self.assertEqual(b, b'olleh') - b = b'hello1' # test even number of items + b = buffer(b'hello1') # test even number of items b.reverse() self.assertEqual(b, b'1olleh') - b = bytes() + b = buffer() b.reverse() self.assertFalse(b) def test_getslice(self): def by(s): - return bytes(map(ord, s)) + return buffer(map(ord, s)) b = by("Hello, world") self.assertEqual(b[:5], by("Hello")) @@ -223,33 +233,33 @@ def test_extended_getslice(self): # Test extended slicing by comparing with list slicing. L = list(range(255)) - b = bytes(L) + b = buffer(L) indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100) for start in indices: for stop in indices: # Skip step 0 (invalid) for step in indices[1:]: - self.assertEqual(b[start:stop:step], bytes(L[start:stop:step])) + self.assertEqual(b[start:stop:step], buffer(L[start:stop:step])) def test_regexps(self): def by(s): - return bytes(map(ord, s)) + return buffer(map(ord, s)) b = by("Hello, world") self.assertEqual(re.findall(r"\w+", b), [by("Hello"), by("world")]) def test_setitem(self): - b = bytes([1, 2, 3]) + b = buffer([1, 2, 3]) b[1] = 100 - self.assertEqual(b, bytes([1, 100, 3])) + self.assertEqual(b, buffer([1, 100, 3])) b[-1] = 200 - self.assertEqual(b, bytes([1, 100, 200])) + self.assertEqual(b, buffer([1, 100, 200])) class C: def __init__(self, i=0): self.i = i def __index__(self): return self.i b[0] = C(10) - self.assertEqual(b, bytes([10, 100, 200])) + self.assertEqual(b, buffer([10, 100, 200])) try: b[3] = 0 self.fail("Didn't raise IndexError") @@ -277,35 +287,35 @@ pass def test_delitem(self): - b = bytes(range(10)) + b = buffer(range(10)) del b[0] - self.assertEqual(b, bytes(range(1, 10))) + self.assertEqual(b, buffer(range(1, 10))) del b[-1] - self.assertEqual(b, bytes(range(1, 9))) + self.assertEqual(b, buffer(range(1, 9))) del b[4] - self.assertEqual(b, bytes([1, 2, 3, 4, 6, 7, 8])) + self.assertEqual(b, buffer([1, 2, 3, 4, 6, 7, 8])) def test_setslice(self): - b = bytes(range(10)) + b = buffer(range(10)) self.assertEqual(list(b), list(range(10))) - b[0:5] = bytes([1, 1, 1, 1, 1]) - self.assertEqual(b, bytes([1, 1, 1, 1, 1, 5, 6, 7, 8, 9])) + b[0:5] = buffer([1, 1, 1, 1, 1]) + self.assertEqual(b, buffer([1, 1, 1, 1, 1, 5, 6, 7, 8, 9])) del b[0:-5] - self.assertEqual(b, bytes([5, 6, 7, 8, 9])) + self.assertEqual(b, buffer([5, 6, 7, 8, 9])) - b[0:0] = bytes([0, 1, 2, 3, 4]) - self.assertEqual(b, bytes(range(10))) + b[0:0] = buffer([0, 1, 2, 3, 4]) + self.assertEqual(b, buffer(range(10))) - b[-7:-3] = bytes([100, 101]) - self.assertEqual(b, bytes([0, 1, 2, 100, 101, 7, 8, 9])) + b[-7:-3] = buffer([100, 101]) + self.assertEqual(b, buffer([0, 1, 2, 100, 101, 7, 8, 9])) b[3:5] = [3, 4, 5, 6] - self.assertEqual(b, bytes(range(10))) + self.assertEqual(b, buffer(range(10))) b[3:0] = [42, 42, 42] - self.assertEqual(b, bytes([0, 1, 2, 42, 42, 42, 3, 4, 5, 6, 7, 8, 9])) + self.assertEqual(b, buffer([0, 1, 2, 42, 42, 42, 3, 4, 5, 6, 7, 8, 9])) def test_extended_set_del_slice(self): indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) @@ -314,93 +324,95 @@ # Skip invalid step 0 for step in indices[1:]: L = list(range(255)) - b = bytes(L) + b = buffer(L) # Make sure we have a slice of exactly the right length, # but with different data. data = L[start:stop:step] data.reverse() L[start:stop:step] = data b[start:stop:step] = data - self.assertEquals(b, bytes(L)) + self.assertEquals(b, buffer(L)) del L[start:stop:step] del b[start:stop:step] - self.assertEquals(b, bytes(L)) + self.assertEquals(b, buffer(L)) def test_setslice_trap(self): # This test verifies that we correctly handle assigning self # to a slice of self (the old Lambert Meertens trap). - b = bytes(range(256)) + b = buffer(range(256)) b[8:] = b - self.assertEqual(b, bytes(list(range(8)) + list(range(256)))) + self.assertEqual(b, buffer(list(range(8)) + list(range(256)))) def test_encoding(self): sample = "Hello world\n\u1234\u5678\u9abc\udef0" for enc in ("utf8", "utf16"): - b = bytes(sample, enc) - self.assertEqual(b, bytes(sample.encode(enc))) - self.assertRaises(UnicodeEncodeError, bytes, sample, "latin1") - b = bytes(sample, "latin1", "ignore") - self.assertEqual(b, bytes(sample[:-4], "utf-8")) + b = buffer(sample, enc) + self.assertEqual(b, buffer(sample.encode(enc))) + self.assertRaises(UnicodeEncodeError, buffer, sample, "latin1") + b = buffer(sample, "latin1", "ignore") + self.assertEqual(b, buffer(sample[:-4], "utf-8")) def test_decode(self): sample = "Hello world\n\u1234\u5678\u9abc\def0\def0" for enc in ("utf8", "utf16"): - b = bytes(sample, enc) + b = buffer(sample, enc) self.assertEqual(b.decode(enc), sample) sample = "Hello world\n\x80\x81\xfe\xff" - b = bytes(sample, "latin1") + b = buffer(sample, "latin1") self.assertRaises(UnicodeDecodeError, b.decode, "utf8") self.assertEqual(b.decode("utf8", "ignore"), "Hello world\n") def test_from_buffer(self): - sample = str8(b"Hello world\n\x80\x81\xfe\xff") + sample = bytes(b"Hello world\n\x80\x81\xfe\xff") buf = memoryview(sample) - b = bytes(buf) - self.assertEqual(b, bytes(sample)) + b = buffer(buf) + self.assertEqual(b, buffer(sample)) def test_to_str(self): - sample = "Hello world\n\x80\x81\xfe\xff" - b = bytes(sample, "utf-8") - self.assertEqual(str(b), sample) + self.assertEqual(str(b''), "b''") + self.assertEqual(str(b'x'), "b'x'") + self.assertEqual(str(b'\x80'), "b'\\x80'") def test_from_int(self): - b = bytes(0) - self.assertEqual(b, bytes()) - b = bytes(10) - self.assertEqual(b, bytes([0]*10)) - b = bytes(10000) - self.assertEqual(b, bytes([0]*10000)) + b = buffer(0) + self.assertEqual(b, buffer()) + b = buffer(10) + self.assertEqual(b, buffer([0]*10)) + b = buffer(10000) + self.assertEqual(b, buffer([0]*10000)) def test_concat(self): b1 = b"abc" b2 = b"def" self.assertEqual(b1 + b2, b"abcdef") - self.assertEqual(b1 + str8(b"def"), b"abcdef") - self.assertEqual(str8(b"def") + b1, b"defabc") + self.assertEqual(b1 + bytes(b"def"), b"abcdef") + self.assertEqual(bytes(b"def") + b1, b"defabc") self.assertRaises(TypeError, lambda: b1 + "def") self.assertRaises(TypeError, lambda: "abc" + b2) def test_repeat(self): - b = b"abc" - self.assertEqual(b * 3, b"abcabcabc") - self.assertEqual(b * 0, bytes()) - self.assertEqual(b * -1, bytes()) - self.assertRaises(TypeError, lambda: b * 3.14) - self.assertRaises(TypeError, lambda: 3.14 * b) - self.assertRaises(MemoryError, lambda: b * sys.maxint) + for b in b"abc", buffer(b"abc"): + self.assertEqual(b * 3, b"abcabcabc") + self.assertEqual(b * 0, b"") + self.assertEqual(b * -1, b"") + self.assertRaises(TypeError, lambda: b * 3.14) + self.assertRaises(TypeError, lambda: 3.14 * b) + # XXX Shouldn't bytes and buffer agree on what to raise? + self.assertRaises((OverflowError, MemoryError), + lambda: b * sys.maxint) def test_repeat_1char(self): - self.assertEqual(b'x'*100, bytes([ord('x')]*100)) + self.assertEqual(b'x'*100, buffer([ord('x')]*100)) def test_iconcat(self): - b = b"abc" + b = buffer(b"abc") b1 = b b += b"def" self.assertEqual(b, b"abcdef") self.assertEqual(b, b1) self.failUnless(b is b1) - b += str8(b"xyz") + b += b"xyz" self.assertEqual(b, b"abcdefxyz") try: b += "" @@ -410,7 +422,7 @@ self.fail("bytes += unicode didn't raise TypeError") def test_irepeat(self): - b = b"abc" + b = buffer(b"abc") b1 = b b *= 3 self.assertEqual(b, b"abcabcabc") @@ -418,38 +430,39 @@ self.failUnless(b is b1) def test_irepeat_1char(self): - b = b"x" + b = buffer(b"x") b1 = b b *= 100 - self.assertEqual(b, bytes([ord("x")]*100)) + self.assertEqual(b, b"x"*100) self.assertEqual(b, b1) self.failUnless(b is b1) def test_contains(self): - b = b"abc" - self.failUnless(ord('a') in b) - self.failUnless(int(ord('a')) in b) - self.failIf(200 in b) - self.failIf(200 in b) - self.assertRaises(ValueError, lambda: 300 in b) - self.assertRaises(ValueError, lambda: -1 in b) - self.assertRaises(TypeError, lambda: None in b) - self.assertRaises(TypeError, lambda: float(ord('a')) in b) - self.assertRaises(TypeError, lambda: "a" in b) - self.failUnless(b"" in b) - self.failUnless(b"a" in b) - self.failUnless(b"b" in b) - self.failUnless(b"c" in b) - self.failUnless(b"ab" in b) - self.failUnless(b"bc" in b) - self.failUnless(b"abc" in b) - self.failIf(b"ac" in b) - self.failIf(b"d" in b) - self.failIf(b"dab" in b) - self.failIf(b"abd" in b) + for b in b"abc", buffer(b"abc"): + self.failUnless(ord('a') in b) + self.failUnless(int(ord('a')) in b) + self.failIf(200 in b) + self.failIf(200 in b) + self.assertRaises(ValueError, lambda: 300 in b) + self.assertRaises(ValueError, lambda: -1 in b) + self.assertRaises(TypeError, lambda: None in b) + self.assertRaises(TypeError, lambda: float(ord('a')) in b) + self.assertRaises(TypeError, lambda: "a" in b) + for f in bytes, buffer: + self.failUnless(f(b"") in b) + self.failUnless(f(b"a") in b) + self.failUnless(f(b"b") in b) + self.failUnless(f(b"c") in b) + self.failUnless(f(b"ab") in b) + self.failUnless(f(b"bc") in b) + self.failUnless(f(b"abc") in b) + self.failIf(f(b"ac") in b) + self.failIf(f(b"d") in b) + self.failIf(f(b"dab") in b) + self.failIf(f(b"abd") in b) def test_alloc(self): - b = bytes() + b = buffer() alloc = b.__alloc__() self.assert_(alloc >= 0) seq = [alloc] @@ -461,23 +474,23 @@ seq.append(alloc) def test_fromhex(self): - self.assertRaises(TypeError, bytes.fromhex) - self.assertRaises(TypeError, bytes.fromhex, 1) - self.assertEquals(bytes.fromhex(''), bytes()) - b = bytes([0x1a, 0x2b, 0x30]) - self.assertEquals(bytes.fromhex('1a2B30'), b) - self.assertEquals(bytes.fromhex(' 1A 2B 30 '), b) - self.assertEquals(bytes.fromhex('0000'), b'\0\0') - self.assertRaises(TypeError, bytes.fromhex, b'1B') - self.assertRaises(ValueError, bytes.fromhex, 'a') - self.assertRaises(ValueError, bytes.fromhex, 'rt') - self.assertRaises(ValueError, bytes.fromhex, '1a b cd') - self.assertRaises(ValueError, bytes.fromhex, '\x00') - self.assertRaises(ValueError, bytes.fromhex, '12 \x00 34') + self.assertRaises(TypeError, buffer.fromhex) + self.assertRaises(TypeError, buffer.fromhex, 1) + self.assertEquals(buffer.fromhex(''), buffer()) + b = buffer([0x1a, 0x2b, 0x30]) + self.assertEquals(buffer.fromhex('1a2B30'), b) + self.assertEquals(buffer.fromhex(' 1A 2B 30 '), b) + self.assertEquals(buffer.fromhex('0000'), b'\0\0') + self.assertRaises(TypeError, buffer.fromhex, b'1B') + self.assertRaises(ValueError, buffer.fromhex, 'a') + self.assertRaises(ValueError, buffer.fromhex, 'rt') + self.assertRaises(ValueError, buffer.fromhex, '1a b cd') + self.assertRaises(ValueError, buffer.fromhex, '\x00') + self.assertRaises(ValueError, buffer.fromhex, '12 \x00 34') def test_join(self): - self.assertEqual(b"".join([]), bytes()) - self.assertEqual(b"".join([bytes()]), bytes()) + self.assertEqual(b"".join([]), b"") + self.assertEqual(b"".join([b""]), b"") for lst in [[b"abc"], [b"a", b"bc"], [b"ab", b"c"], [b"a", b"b", b"c"]]: self.assertEqual(b"".join(lst), b"abc") self.assertEqual(b"".join(tuple(lst)), b"abc") @@ -493,20 +506,20 @@ (br"\xaa\x00\000\200", r"\xaa\x00\000\200"), ] for b, s in tests: - self.assertEqual(b, bytes(s, 'latin-1')) + self.assertEqual(b, buffer(s, 'latin-1')) for c in range(128, 256): self.assertRaises(SyntaxError, eval, 'b"%s"' % chr(c)) def test_extend(self): orig = b'hello' - a = bytes(orig) + a = buffer(orig) a.extend(a) self.assertEqual(a, orig + orig) self.assertEqual(a[5:], orig) def test_remove(self): - b = b'hello' + b = buffer(b'hello') b.remove(ord('l')) self.assertEqual(b, b'helo') b.remove(ord('l')) @@ -521,15 +534,15 @@ self.assertRaises(TypeError, lambda: b.remove(b'e')) def test_pop(self): - b = b'world' + b = buffer(b'world') self.assertEqual(b.pop(), ord('d')) self.assertEqual(b.pop(0), ord('w')) self.assertEqual(b.pop(-2), ord('r')) self.assertRaises(IndexError, lambda: b.pop(10)) - self.assertRaises(OverflowError, lambda: bytes().pop()) + self.assertRaises(OverflowError, lambda: buffer().pop()) def test_nosort(self): - self.assertRaises(AttributeError, lambda: bytes().sort()) + self.assertRaises(AttributeError, lambda: buffer().sort()) def test_index(self): b = b'parrot' @@ -545,17 +558,17 @@ self.assertEqual(b.count(b'w'), 0) def test_append(self): - b = b'hell' + b = buffer(b'hell') b.append(ord('o')) self.assertEqual(b, b'hello') self.assertEqual(b.append(100), None) - b = bytes() + b = buffer() b.append(ord('A')) self.assertEqual(len(b), 1) self.assertRaises(TypeError, lambda: b.append(b'o')) def test_insert(self): - b = b'msssspp' + b = buffer(b'msssspp') b.insert(1, ord('i')) b.insert(4, ord('i')) b.insert(-2, ord('i')) @@ -565,7 +578,7 @@ def test_startswith(self): b = b'hello' - self.assertFalse(bytes().startswith(b"anything")) + self.assertFalse(buffer().startswith(b"anything")) self.assertTrue(b.startswith(b"hello")) self.assertTrue(b.startswith(b"hel")) self.assertTrue(b.startswith(b"h")) @@ -574,7 +587,7 @@ def test_endswith(self): b = b'hello' - self.assertFalse(bytes().endswith(b"anything")) + self.assertFalse(buffer().endswith(b"anything")) self.assertTrue(b.endswith(b"hello")) self.assertTrue(b.endswith(b"llo")) self.assertTrue(b.endswith(b"o")) @@ -620,7 +633,7 @@ def test_translate(self): b = b'hello' - rosetta = bytes(range(0, 256)) + rosetta = buffer(range(0, 256)) rosetta[ord('o')] = ord('e') c = b.translate(rosetta, b'l') self.assertEqual(b, b'hello') @@ -666,10 +679,10 @@ self.assertEqual(b' a bb c '.rsplit(None,2), [b' a', b'bb', b'c']) self.assertEqual(b' a bb c '.rsplit(None, 3), [b'a', b'bb', b'c']) - def test_rplit_buffer(self): + def test_rsplit_buffer(self): self.assertEqual(b'a b'.rsplit(memoryview(b' ')), [b'a', b'b']) - def test_rplit_string_error(self): + def test_rsplit_string_error(self): self.assertRaises(TypeError, b'a b'.rsplit, ' ') def test_partition(self): @@ -753,7 +766,7 @@ class BufferPEP3137Test(unittest.TestCase, test.buffer_tests.MixinBytesBufferCommonTests): def marshal(self, x): - return bytes(x) + return buffer(x) # TODO this should become: #return buffer(x) # once the bytes -> buffer and str8 -> bytes rename happens @@ -771,7 +784,7 @@ class BytesAsStringTest(test.string_tests.BaseTest): - type2test = bytes + type2test = buffer def fixtype(self, obj): if isinstance(obj, str): Modified: python/branches/py3k-pep3137/Lib/test/test_io.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_io.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_io.py Thu Nov 1 00:29:18 2007 @@ -88,7 +88,7 @@ self.assertEqual(f.tell(), 6) self.assertEqual(f.seek(-1, 1), 5) self.assertEqual(f.tell(), 5) - self.assertEqual(f.write(str8(b" world\n\n\n")), 9) + self.assertEqual(f.write(buffer(b" world\n\n\n")), 9) self.assertEqual(f.seek(0), 0) self.assertEqual(f.write(b"h"), 1) self.assertEqual(f.seek(-1, 2), 13) @@ -99,6 +99,7 @@ def read_ops(self, f, buffered=False): data = f.read(5) self.assertEqual(data, b"hello") + data = buffer(data) self.assertEqual(f.readinto(data), 5) self.assertEqual(data, b" worl") self.assertEqual(f.readinto(data), 2) @@ -107,11 +108,11 @@ self.assertEqual(f.seek(0), 0) self.assertEqual(f.read(20), b"hello world\n") self.assertEqual(f.read(1), b"") - self.assertEqual(f.readinto(b"x"), 0) + self.assertEqual(f.readinto(buffer(b"x")), 0) self.assertEqual(f.seek(-6, 2), 6) self.assertEqual(f.read(5), b"world") self.assertEqual(f.read(0), b"") - self.assertEqual(f.readinto(b""), 0) + self.assertEqual(f.readinto(buffer()), 0) self.assertEqual(f.seek(-6, 1), 5) self.assertEqual(f.read(5), b" worl") self.assertEqual(f.tell(), 10) @@ -687,7 +688,7 @@ f.close() f = io.open(test_support.TESTFN, "r", encoding="utf-8") s = f.read(prefix_size) - self.assertEquals(s, str(prefix)) + self.assertEquals(s, str(prefix, "ascii")) self.assertEquals(f.tell(), prefix_size) self.assertEquals(f.readline(), u_suffix) Modified: python/branches/py3k-pep3137/Lib/test/test_pickle.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_pickle.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_pickle.py Thu Nov 1 00:29:18 2007 @@ -10,6 +10,9 @@ class PickleTests(AbstractPickleTests, AbstractPickleModuleTests): + module = pickle + error = KeyError + def dumps(self, arg, proto=0, fast=0): # Ignore fast return pickle.dumps(arg, proto) @@ -18,9 +21,6 @@ # Ignore fast return pickle.loads(buf) - module = pickle - error = KeyError - class PicklerTests(AbstractPickleTests): error = KeyError Modified: python/branches/py3k-pep3137/Lib/xmlrpclib.py ============================================================================== --- python/branches/py3k-pep3137/Lib/xmlrpclib.py (original) +++ python/branches/py3k-pep3137/Lib/xmlrpclib.py Thu Nov 1 00:29:18 2007 @@ -622,7 +622,7 @@ write("") write(escape(value)) write("\n") - dispatch[str8] = dump_string + dispatch[bytes] = dump_string def dump_unicode(self, value, write, escape=escape): write("") Modified: python/branches/py3k-pep3137/Objects/bytesobject.c ============================================================================== --- python/branches/py3k-pep3137/Objects/bytesobject.c (original) +++ python/branches/py3k-pep3137/Objects/bytesobject.c Thu Nov 1 00:29:18 2007 @@ -1,7 +1,5 @@ /* Bytes object implementation */ -/* XXX TO DO: optimizations */ - #define PY_SSIZE_T_CLEAN #include "Python.h" #include "structmember.h" @@ -214,26 +212,21 @@ { Py_ssize_t size; Py_buffer va, vb; - PyBytesObject *result; + PyBytesObject *result = NULL; va.len = -1; vb.len = -1; if (_getbuffer(a, &va) < 0 || _getbuffer(b, &vb) < 0) { - if (va.len != -1) - PyObject_ReleaseBuffer(a, &va); - if (vb.len != -1) - PyObject_ReleaseBuffer(b, &vb); PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s", Py_Type(a)->tp_name, Py_Type(b)->tp_name); - return NULL; + goto done; } size = va.len + vb.len; if (size < 0) { - PyObject_ReleaseBuffer(a, &va); - PyObject_ReleaseBuffer(b, &vb); return PyErr_NoMemory(); + goto done; } result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, size); @@ -242,8 +235,11 @@ memcpy(result->ob_bytes + va.len, vb.buf, vb.len); } - PyObject_ReleaseBuffer(a, &va); - PyObject_ReleaseBuffer(b, &vb); + done: + if (va.len != -1) + PyObject_ReleaseBuffer(a, &va); + if (vb.len != -1) + PyObject_ReleaseBuffer(b, &vb); return (PyObject *)result; } @@ -256,12 +252,6 @@ } static PyObject * -bytes_concat(PyBytesObject *self, PyObject *other) -{ - return PyBytes_Concat((PyObject *)self, other); -} - -static PyObject * bytes_iconcat(PyBytesObject *self, PyObject *other) { Py_ssize_t mysize; @@ -351,51 +341,13 @@ return (PyObject *)self; } -static int -bytes_substring(PyBytesObject *self, PyBytesObject *other) -{ - Py_ssize_t i; - - if (Py_Size(other) == 1) { - return memchr(self->ob_bytes, other->ob_bytes[0], - Py_Size(self)) != NULL; - } - if (Py_Size(other) == 0) - return 1; /* Edge case */ - for (i = 0; i + Py_Size(other) <= Py_Size(self); i++) { - /* XXX Yeah, yeah, lots of optimizations possible... */ - if (memcmp(self->ob_bytes + i, other->ob_bytes, Py_Size(other)) == 0) - return 1; - } - return 0; -} - -static int -bytes_contains(PyBytesObject *self, PyObject *value) -{ - Py_ssize_t ival; - - if (PyBytes_Check(value)) - return bytes_substring(self, (PyBytesObject *)value); - - ival = PyNumber_AsSsize_t(value, PyExc_ValueError); - if (ival == -1 && PyErr_Occurred()) - return -1; - if (ival < 0 || ival >= 256) { - PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); - return -1; - } - - return memchr(self->ob_bytes, ival, Py_Size(self)) != NULL; -} - static PyObject * bytes_getitem(PyBytesObject *self, Py_ssize_t i) { if (i < 0) i += Py_Size(self); if (i < 0 || i >= Py_Size(self)) { - PyErr_SetString(PyExc_IndexError, "bytes index out of range"); + PyErr_SetString(PyExc_IndexError, "buffer index out of range"); return NULL; } return PyInt_FromLong((unsigned char)(self->ob_bytes[i])); @@ -414,7 +366,7 @@ i += PyBytes_GET_SIZE(self); if (i < 0 || i >= Py_Size(self)) { - PyErr_SetString(PyExc_IndexError, "bytes index out of range"); + PyErr_SetString(PyExc_IndexError, "buffer index out of range"); return NULL; } return PyInt_FromLong((unsigned char)(self->ob_bytes[i])); @@ -451,7 +403,7 @@ } } else { - PyErr_SetString(PyExc_TypeError, "bytes indices must be integers"); + PyErr_SetString(PyExc_TypeError, "buffer indices must be integers"); return NULL; } } @@ -551,7 +503,7 @@ i += Py_Size(self); if (i < 0 || i >= Py_Size(self)) { - PyErr_SetString(PyExc_IndexError, "bytes index out of range"); + PyErr_SetString(PyExc_IndexError, "buffer index out of range"); return -1; } @@ -587,7 +539,7 @@ i += PyBytes_GET_SIZE(self); if (i < 0 || i >= Py_Size(self)) { - PyErr_SetString(PyExc_IndexError, "bytes index out of range"); + PyErr_SetString(PyExc_IndexError, "buffer index out of range"); return -1; } @@ -619,7 +571,7 @@ } } else { - PyErr_SetString(PyExc_TypeError, "bytes indices must be integer"); + PyErr_SetString(PyExc_TypeError, "buffer indices must be integer"); return -1; } @@ -889,11 +841,15 @@ bytes_repr(PyBytesObject *self) { static const char *hexdigits = "0123456789abcdef"; - size_t newsize = 3 + 4 * Py_Size(self); + const char *quote_prefix = "buffer(b"; + const char *quote_postfix = ")"; + Py_ssize_t length = Py_Size(self); + /* 9 prefix + 2 postfix */ + size_t newsize = 11 + 4 * length; PyObject *v; - if (newsize > PY_SSIZE_T_MAX || newsize / 4 != Py_Size(self)) { + if (newsize > PY_SSIZE_T_MAX || newsize / 4 - 2 != length) { PyErr_SetString(PyExc_OverflowError, - "bytes object is too large to make repr"); + "buffer object is too large to make repr"); return NULL; } v = PyUnicode_FromUnicode(NULL, newsize); @@ -904,17 +860,36 @@ register Py_ssize_t i; register Py_UNICODE c; register Py_UNICODE *p; - int quote = '\''; + int quote; + + /* Figure out which quote to use; single is preferred */ + quote = '\''; + { + char *test, *start; + start = PyBytes_AS_STRING(self); + for (test = start; test < start+length; ++test) { + if (*test == '"') { + quote = '\''; /* back to single */ + goto decided; + } + else if (*test == '\'') + quote = '"'; + } + decided: + ; + } p = PyUnicode_AS_UNICODE(v); - *p++ = 'b'; + while (*quote_prefix) + *p++ = *quote_prefix++; *p++ = quote; - for (i = 0; i < Py_Size(self); i++) { + + for (i = 0; i < length; i++) { /* There's at least enough room for a hex escape and a closing quote. */ assert(newsize - (p - PyUnicode_AS_UNICODE(v)) >= 5); c = self->ob_bytes[i]; - if (c == quote || c == '\\') + if (c == '\'' || c == '\\') *p++ = '\\', *p++ = c; else if (c == '\t') *p++ = '\\', *p++ = 't'; @@ -935,6 +910,9 @@ } assert(newsize - (p - PyUnicode_AS_UNICODE(v)) >= 1); *p++ = quote; + while (*quote_postfix) { + *p++ = *quote_postfix++; + } *p = '\0'; if (PyUnicode_Resize(&v, (p - PyUnicode_AS_UNICODE(v)))) { Py_DECREF(v); @@ -945,12 +923,6 @@ } static PyObject * -bytes_str(PyBytesObject *self) -{ - return PyString_FromStringAndSize(self->ob_bytes, Py_Size(self)); -} - -static PyObject * bytes_richcompare(PyObject *self, PyObject *other, int op) { Py_ssize_t self_size, other_size; @@ -1203,6 +1175,30 @@ } +static int +bytes_contains(PyObject *self, PyObject *arg) +{ + Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError); + if (ival == -1 && PyErr_Occurred()) { + Py_buffer varg; + int pos; + PyErr_Clear(); + if (_getbuffer(arg, &varg) < 0) + return -1; + pos = stringlib_find(PyBytes_AS_STRING(self), Py_Size(self), + varg.buf, varg.len, 0); + PyObject_ReleaseBuffer(arg, &varg); + return pos >= 0; + } + if (ival < 0 || ival >= 256) { + PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); + return -1; + } + + return memchr(PyBytes_AS_STRING(self), ival, Py_Size(self)) != NULL; +} + + /* Matches the end (direction >= 0) or start (direction < 0) of self * against substr, using the start and end arguments. Returns * -1 on error, 0 if not found and 1 if found. @@ -2028,7 +2024,7 @@ PyDoc_STRVAR(replace__doc__, "B.replace (old, new[, count]) -> bytes\n\ \n\ -Return a copy of bytes B with all occurrences of subsection\n\ +Return a copy of B with all occurrences of subsection\n\ old replaced by new. If the optional argument count is\n\ given, only the first count occurrences are replaced."); @@ -2149,23 +2145,23 @@ return NULL; for (i = j = 0; i < len; ) { - /* find a token */ - while (i < len && ISSPACE(s[i])) - i++; - j = i; - while (i < len && !ISSPACE(s[i])) - i++; - if (j < i) { - if (maxcount-- <= 0) - break; - SPLIT_ADD(s, j, i); - while (i < len && ISSPACE(s[i])) - i++; - j = i; - } + /* find a token */ + while (i < len && ISSPACE(s[i])) + i++; + j = i; + while (i < len && !ISSPACE(s[i])) + i++; + if (j < i) { + if (maxcount-- <= 0) + break; + SPLIT_ADD(s, j, i); + while (i < len && ISSPACE(s[i])) + i++; + j = i; + } } if (j < len) { - SPLIT_ADD(s, j, len); + SPLIT_ADD(s, j, len); } FIX_PREALLOC_SIZE(list); return list; @@ -2176,9 +2172,9 @@ } PyDoc_STRVAR(split__doc__, -"B.split([sep [, maxsplit]]) -> list of bytes\n\ +"B.split([sep [, maxsplit]]) -> list of buffer\n\ \n\ -Return a list of the bytes in the string B, using sep as the delimiter.\n\ +Return a list of the buffer in the string B, using sep as the delimiter.\n\ If sep is not given, B is split on ASCII whitespace charcters\n\ (space, tab, return, newline, formfeed, vertical tab).\n\ If maxsplit is given, at most maxsplit splits are done."); @@ -2260,7 +2256,7 @@ \n\ Searches for the separator sep in B, and returns the part before it,\n\ the separator itself, and the part after it. If the separator is not\n\ -found, returns B and two empty bytes."); +found, returns B and two empty buffer."); static PyObject * bytes_partition(PyBytesObject *self, PyObject *sep_obj) @@ -2287,7 +2283,7 @@ \n\ Searches for the separator sep in B, starting at the end of B, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns two empty bytes and B."); +separator is not found, returns two empty buffer and B."); static PyObject * bytes_rpartition(PyBytesObject *self, PyObject *sep_obj) @@ -2354,23 +2350,23 @@ return NULL; for (i = j = len - 1; i >= 0; ) { - /* find a token */ - while (i >= 0 && Py_UNICODE_ISSPACE(s[i])) - i--; - j = i; - while (i >= 0 && !Py_UNICODE_ISSPACE(s[i])) - i--; - if (j > i) { - if (maxcount-- <= 0) - break; - SPLIT_ADD(s, i + 1, j + 1); - while (i >= 0 && Py_UNICODE_ISSPACE(s[i])) - i--; - j = i; - } + /* find a token */ + while (i >= 0 && Py_UNICODE_ISSPACE(s[i])) + i--; + j = i; + while (i >= 0 && !Py_UNICODE_ISSPACE(s[i])) + i--; + if (j > i) { + if (maxcount-- <= 0) + break; + SPLIT_ADD(s, i + 1, j + 1); + while (i >= 0 && Py_UNICODE_ISSPACE(s[i])) + i--; + j = i; + } } if (j >= 0) { - SPLIT_ADD(s, 0, j + 1); + SPLIT_ADD(s, 0, j + 1); } FIX_PREALLOC_SIZE(list); if (PyList_Reverse(list) < 0) @@ -2384,10 +2380,10 @@ } PyDoc_STRVAR(rsplit__doc__, -"B.rsplit(sep [,maxsplit]) -> list of bytes\n\ +"B.rsplit(sep [,maxsplit]) -> list of buffer\n\ \n\ -Return a list of the sections in the byte B, using sep as the delimiter,\n\ -starting at the end of the bytes and working to the front.\n\ +Return a list of the sections in B, using sep as the delimiter,\n\ +starting at the end of B and working to the front.\n\ If sep is not given, B is split on ASCII whitespace characters\n\ (space, tab, return, newline, formfeed, vertical tab).\n\ If maxsplit is given, at most maxsplit splits are done."); @@ -2458,7 +2454,7 @@ "B.extend(iterable int) -> None\n\ \n\ Append all the elements from the iterator or sequence to the\n\ -end of the bytes."); +end of B."); static PyObject * bytes_extend(PyBytesObject *self, PyObject *arg) { @@ -2475,7 +2471,7 @@ PyDoc_STRVAR(reverse__doc__, "B.reverse() -> None\n\ \n\ -Reverse the order of the values in bytes in place."); +Reverse the order of the values in B in place."); static PyObject * bytes_reverse(PyBytesObject *self, PyObject *unused) { @@ -2497,7 +2493,7 @@ PyDoc_STRVAR(insert__doc__, "B.insert(index, int) -> None\n\ \n\ -Insert a single item into the bytes before the given index."); +Insert a single item into the buffer before the given index."); static PyObject * bytes_insert(PyBytesObject *self, PyObject *args) { @@ -2536,7 +2532,7 @@ PyDoc_STRVAR(append__doc__, "B.append(int) -> None\n\ \n\ -Append a single item to the end of the bytes."); +Append a single item to the end of B."); static PyObject * bytes_append(PyBytesObject *self, PyObject *arg) { @@ -2561,7 +2557,7 @@ PyDoc_STRVAR(pop__doc__, "B.pop([index]) -> int\n\ \n\ -Remove and return a single item from the bytes. If no index\n\ +Remove and return a single item from B. If no index\n\ argument is give, will pop the last value."); static PyObject * bytes_pop(PyBytesObject *self, PyObject *args) @@ -2595,7 +2591,7 @@ PyDoc_STRVAR(remove__doc__, "B.remove(int) -> None\n\ \n\ -Remove the first occurance of a value in bytes"); +Remove the first occurance of a value in B."); static PyObject * bytes_remove(PyBytesObject *self, PyObject *arg) { @@ -2644,7 +2640,7 @@ } PyDoc_STRVAR(strip__doc__, -"B.strip([bytes]) -> bytes\n\ +"B.strip([bytes]) -> buffer\n\ \n\ Strip leading and trailing bytes contained in the argument.\n\ If the argument is omitted, strip ASCII whitespace."); @@ -2662,10 +2658,10 @@ argsize = 6; } else { - if (_getbuffer(arg, &varg) < 0) - return NULL; - argptr = varg.buf; - argsize = varg.len; + if (_getbuffer(arg, &varg) < 0) + return NULL; + argptr = varg.buf; + argsize = varg.len; } myptr = self->ob_bytes; mysize = Py_Size(self); @@ -2675,12 +2671,12 @@ else right = rstrip_helper(myptr, mysize, argptr, argsize); if (arg != Py_None) - PyObject_ReleaseBuffer(arg, &varg); + PyObject_ReleaseBuffer(arg, &varg); return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left); } PyDoc_STRVAR(lstrip__doc__, -"B.lstrip([bytes]) -> bytes\n\ +"B.lstrip([bytes]) -> buffer\n\ \n\ Strip leading bytes contained in the argument.\n\ If the argument is omitted, strip leading ASCII whitespace."); @@ -2698,22 +2694,22 @@ argsize = 6; } else { - if (_getbuffer(arg, &varg) < 0) - return NULL; - argptr = varg.buf; - argsize = varg.len; + if (_getbuffer(arg, &varg) < 0) + return NULL; + argptr = varg.buf; + argsize = varg.len; } myptr = self->ob_bytes; mysize = Py_Size(self); left = lstrip_helper(myptr, mysize, argptr, argsize); right = mysize; if (arg != Py_None) - PyObject_ReleaseBuffer(arg, &varg); + PyObject_ReleaseBuffer(arg, &varg); return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left); } PyDoc_STRVAR(rstrip__doc__, -"B.rstrip([bytes]) -> bytes\n\ +"B.rstrip([bytes]) -> buffer\n\ \n\ Strip trailing bytes contained in the argument.\n\ If the argument is omitted, strip trailing ASCII whitespace."); @@ -2731,17 +2727,17 @@ argsize = 6; } else { - if (_getbuffer(arg, &varg) < 0) - return NULL; - argptr = varg.buf; - argsize = varg.len; + if (_getbuffer(arg, &varg) < 0) + return NULL; + argptr = varg.buf; + argsize = varg.len; } myptr = self->ob_bytes; mysize = Py_Size(self); left = 0; right = rstrip_helper(myptr, mysize, argptr, argsize); if (arg != Py_None) - PyObject_ReleaseBuffer(arg, &varg); + PyObject_ReleaseBuffer(arg, &varg); return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left); } @@ -2850,11 +2846,11 @@ } PyDoc_STRVAR(fromhex_doc, -"bytes.fromhex(string) -> bytes\n\ +"buffer.fromhex(string) -> buffer\n\ \n\ -Create a bytes object from a string of hexadecimal numbers.\n\ +Create a buffer object from a string of hexadecimal numbers.\n\ Spaces between two numbers are accepted. Example:\n\ -bytes.fromhex('10 1112') -> b'\\x10\\x11\\x12'."); +buffer.fromhex('10 1112') -> buffer(b'\\x10\\x11\\x12')."); static int hex_digit_to_int(Py_UNICODE c) @@ -2932,7 +2928,7 @@ static PySequenceMethods bytes_as_sequence = { (lenfunc)bytes_length, /* sq_length */ - (binaryfunc)bytes_concat, /* sq_concat */ + (binaryfunc)PyBytes_Concat, /* sq_concat */ (ssizeargfunc)bytes_repeat, /* sq_repeat */ (ssizeargfunc)bytes_getitem, /* sq_item */ 0, /* sq_slice */ @@ -3019,7 +3015,7 @@ }; PyDoc_STRVAR(bytes_doc, -"bytes([iterable]) -> new array of bytes.\n\ +"buffer([iterable]) -> new array of bytes.\n\ \n\ If an argument is given it must be an iterable yielding ints in range(256)."); @@ -3027,7 +3023,7 @@ PyTypeObject PyBytes_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "bytes", + "buffer", sizeof(PyBytesObject), 0, (destructor)bytes_dealloc, /* tp_dealloc */ @@ -3041,7 +3037,7 @@ &bytes_as_mapping, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - (reprfunc)bytes_str, /* tp_str */ + (reprfunc)bytes_repr, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &bytes_as_buffer, /* tp_as_buffer */ Modified: python/branches/py3k-pep3137/Objects/fileobject.c ============================================================================== --- python/branches/py3k-pep3137/Objects/fileobject.c (original) +++ python/branches/py3k-pep3137/Objects/fileobject.c Thu Nov 1 00:29:18 2007 @@ -146,7 +146,7 @@ if (writer == NULL) return -1; if (flags & Py_PRINT_RAW) { - value = _PyObject_Str(v); + value = PyObject_Str(v); } else value = PyObject_Repr(v); Modified: python/branches/py3k-pep3137/Objects/object.c ============================================================================== --- python/branches/py3k-pep3137/Objects/object.c (original) +++ python/branches/py3k-pep3137/Objects/object.c Thu Nov 1 00:29:18 2007 @@ -372,50 +372,34 @@ #endif if (v == NULL) return PyUnicode_FromString(""); - else if (Py_Type(v)->tp_repr == NULL) - return PyUnicode_FromFormat("<%s object at %p>", v->ob_type->tp_name, v); - else { - res = (*v->ob_type->tp_repr)(v); - if (res != NULL && !PyUnicode_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__repr__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; - } -} - -PyObject * -PyObject_ReprStr8(PyObject *v) -{ - PyObject *resu = PyObject_Repr(v); - if (resu) { - PyObject *resb = PyUnicode_AsEncodedString(resu, NULL, NULL); - Py_DECREF(resu); - if (resb) { - PyObject *ress = PyString_FromStringAndSize( - PyBytes_AS_STRING(resb), - PyBytes_GET_SIZE(resb) - ); - Py_DECREF(resb); - return ress; - } - } - return NULL; + if (Py_Type(v)->tp_repr == NULL) + return PyUnicode_FromFormat("<%s object at %p>", + v->ob_type->tp_name, v); + res = (*v->ob_type->tp_repr)(v); + if (res != NULL && !PyUnicode_Check(res)) { + PyErr_Format(PyExc_TypeError, + "__repr__ returned non-string (type %.200s)", + res->ob_type->tp_name); + Py_DECREF(res); + return NULL; + } + return res; } PyObject * -_PyObject_Str(PyObject *v) +PyObject_Str(PyObject *v) { PyObject *res; + if (PyErr_CheckSignals()) + return NULL; +#ifdef USE_STACKCHECK + if (PyOS_CheckStack()) { + PyErr_SetString(PyExc_MemoryError, "stack overflow"); + return NULL; + } +#endif if (v == NULL) return PyUnicode_FromString(""); - if (PyString_CheckExact(v)) { - Py_INCREF(v); - return v; - } if (PyUnicode_CheckExact(v)) { Py_INCREF(v); return v; @@ -426,7 +410,7 @@ res = (*Py_Type(v)->tp_str)(v); if (res == NULL) return NULL; - if (!(PyString_Check(res) || PyUnicode_Check(res))) { + if (!PyUnicode_Check(res)) { PyErr_Format(PyExc_TypeError, "__str__ returned non-string (type %.200s)", Py_Type(res)->tp_name); @@ -436,90 +420,12 @@ return res; } -PyObject * -PyObject_Str(PyObject *v) -{ - PyObject *res = _PyObject_Str(v); - if (res == NULL) - return NULL; - if (PyUnicode_Check(res)) { - PyObject* str; - str = _PyUnicode_AsDefaultEncodedString(res, NULL); - Py_XINCREF(str); - Py_DECREF(res); - if (str) - res = str; - else - return NULL; - } - assert(PyString_Check(res)); - return res; -} - -PyObject * -PyObject_Unicode(PyObject *v) -{ - PyObject *res; - PyObject *func; - PyObject *str; - static PyObject *unicodestr; - - if (v == NULL) - return PyUnicode_FromString(""); - else if (PyUnicode_CheckExact(v)) { - Py_INCREF(v); - return v; - } - /* XXX As soon as we have a tp_unicode slot, we should - check this before trying the __unicode__ - method. */ - if (unicodestr == NULL) { - unicodestr= PyUnicode_InternFromString("__unicode__"); - if (unicodestr == NULL) - return NULL; - } - func = PyObject_GetAttr(v, unicodestr); - if (func != NULL) { - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - } - else { - PyErr_Clear(); - if (PyUnicode_Check(v) && - v->ob_type->tp_str == PyUnicode_Type.tp_str) { - /* For a Unicode subtype that's didn't overwrite - __unicode__ or __str__, - return a true Unicode object with the same data. */ - return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(v), - PyUnicode_GET_SIZE(v)); - } - if (PyString_CheckExact(v)) { - Py_INCREF(v); - res = v; - } - else { - if (Py_Type(v)->tp_str != NULL) - res = (*Py_Type(v)->tp_str)(v); - else - res = PyObject_Repr(v); - } - } - if (res == NULL) - return NULL; - if (!PyUnicode_Check(res)) { - str = PyUnicode_FromEncodedObject(res, NULL, "strict"); - Py_DECREF(res); - res = str; - } - return res; -} - /* The new comparison philosophy is: we completely separate three-way comparison from rich comparison. That is, PyObject_Compare() and PyObject_Cmp() *just* use the tp_compare slot. And PyObject_RichCompare() and PyObject_RichCompareBool() *just* use the tp_richcompare slot. - + See (*) below for practical amendments. IOW, only cmp() uses tp_compare; the comparison operators (==, !=, <=, <, @@ -575,7 +481,7 @@ cmpfunc f; int ok; - if (v->ob_type == w->ob_type && + if (v->ob_type == w->ob_type && (f = v->ob_type->tp_compare) != NULL) { return (*f)(v, w); } @@ -733,25 +639,25 @@ return NULL; switch (op) { case Py_LT: - ok = cmp < 0; + ok = cmp < 0; break; case Py_LE: - ok = cmp <= 0; + ok = cmp <= 0; break; case Py_EQ: - ok = cmp == 0; + ok = cmp == 0; break; case Py_NE: - ok = cmp != 0; + ok = cmp != 0; break; - case Py_GT: - ok = cmp > 0; + case Py_GT: + ok = cmp > 0; break; case Py_GE: - ok = cmp >= 0; + ok = cmp >= 0; break; default: - PyErr_BadArgument(); + PyErr_BadArgument(); return NULL; } res = ok ? Py_True : Py_False; @@ -1330,10 +1236,10 @@ } /* Helper for PyObject_Dir of type objects: returns __dict__ and __bases__. - We deliberately don't suck up its __class__, as methods belonging to the - metaclass would probably be more confusing than helpful. + We deliberately don't suck up its __class__, as methods belonging to the + metaclass would probably be more confusing than helpful. */ -static PyObject * +static PyObject * _specialized_dir_type(PyObject *obj) { PyObject *result = NULL; @@ -1376,7 +1282,7 @@ PyObject *result = NULL; PyObject *dict = NULL; PyObject *itsclass = NULL; - + /* Get __dict__ (which may or may not be a real dict...) */ dict = PyObject_GetAttrString(obj, "__dict__"); if (dict == NULL) { @@ -1481,7 +1387,7 @@ Py_DECREF(result); result = NULL; } - + return result; } Modified: python/branches/py3k-pep3137/Objects/stringobject.c ============================================================================== --- python/branches/py3k-pep3137/Objects/stringobject.c (original) +++ python/branches/py3k-pep3137/Objects/stringobject.c Thu Nov 1 00:29:18 2007 @@ -6,6 +6,24 @@ #include "bytes_methods.h" +static Py_ssize_t +_getbuffer(PyObject *obj, Py_buffer *view) +{ + PyBufferProcs *buffer = Py_Type(obj)->tp_as_buffer; + + if (buffer == NULL || buffer->bf_getbuffer == NULL) + { + PyErr_Format(PyExc_TypeError, + "Type %.100s doesn't support the buffer API", + Py_Type(obj)->tp_name); + return -1; + } + + if (buffer->bf_getbuffer(obj, view, PyBUF_SIMPLE) < 0) + return -1; + return view->len; +} + #ifdef COUNT_ALLOCS int null_strings, one_strings; #endif @@ -450,8 +468,8 @@ /* do nothing */; else { PyErr_Format(PyExc_ValueError, - "decoding error; " - "unknown error handling code: %.400s", + "decoding error; unknown " + "error handling code: %.400s", errors); goto failed; } @@ -564,7 +582,7 @@ #define STRINGLIB_LEN PyString_GET_SIZE #define STRINGLIB_NEW PyString_FromStringAndSize #define STRINGLIB_STR PyString_AS_STRING -#define STRINGLIB_WANT_CONTAINS_OBJ 1 +/* #define STRINGLIB_WANT_CONTAINS_OBJ 1 */ #define STRINGLIB_EMPTY nullstring #define STRINGLIB_CHECK_EXACT PyString_CheckExact @@ -584,12 +602,12 @@ { static const char *hexdigits = "0123456789abcdef"; register PyStringObject* op = (PyStringObject*) obj; - Py_ssize_t length = PyString_GET_SIZE(op); - size_t newsize = 3 + 4 * Py_Size(op); + Py_ssize_t length = Py_Size(op); + size_t newsize = 3 + 4 * length; PyObject *v; - if (newsize > PY_SSIZE_T_MAX || newsize / 4 != Py_Size(op)) { + if (newsize > PY_SSIZE_T_MAX || (newsize-3) / 4 != length) { PyErr_SetString(PyExc_OverflowError, - "string is too large to make repr"); + "bytes object is too large to make repr"); } v = PyUnicode_FromUnicode(NULL, newsize); if (v == NULL) { @@ -601,14 +619,14 @@ register Py_UNICODE *p = PyUnicode_AS_UNICODE(v); int quote; - /* figure out which quote to use; single is preferred */ + /* Figure out which quote to use; single is preferred */ quote = '\''; if (smartquotes) { char *test, *start; start = PyString_AS_STRING(op); for (test = start; test < start+length; ++test) { if (*test == '"') { - quote = '\''; /* switch back to single quote */ + quote = '\''; /* back to single */ goto decided; } else if (*test == '\'') @@ -618,8 +636,8 @@ ; } - *p++ = 's', *p++ = quote; - for (i = 0; i < Py_Size(op); i++) { + *p++ = 'b', *p++ = quote; + for (i = 0; i < length; i++) { /* There's at least enough room for a hex escape and a closing quote. */ assert(newsize - (p - PyUnicode_AS_UNICODE(v)) >= 5); @@ -658,71 +676,59 @@ return PyString_Repr(op, 1); } -static PyObject * -string_str(PyObject *s) -{ - assert(PyString_Check(s)); - if (PyString_CheckExact(s)) { - Py_INCREF(s); - return s; - } - else { - /* Subtype -- return genuine string with the same value. */ - PyStringObject *t = (PyStringObject *) s; - return PyString_FromStringAndSize(t->ob_sval, Py_Size(t)); - } -} - static Py_ssize_t string_length(PyStringObject *a) { return Py_Size(a); } +/* This is also used by PyString_Concat() */ static PyObject * -string_concat(register PyStringObject *a, register PyObject *bb) +string_concat(PyObject *a, PyObject *b) { - register Py_ssize_t size; - register PyStringObject *op; - if (!PyString_Check(bb)) { - if (PyUnicode_Check(bb)) - return PyUnicode_Concat((PyObject *)a, bb); - if (PyBytes_Check(bb)) - return PyBytes_Concat((PyObject *)a, bb); - PyErr_Format(PyExc_TypeError, - "cannot concatenate 'str8' and '%.200s' objects", - Py_Type(bb)->tp_name); - return NULL; - } -#define b ((PyStringObject *)bb) - /* Optimize cases with empty left or right operand */ - if ((Py_Size(a) == 0 || Py_Size(b) == 0) && - PyString_CheckExact(a) && PyString_CheckExact(b)) { - if (Py_Size(a) == 0) { - Py_INCREF(bb); - return bb; - } - Py_INCREF(a); - return (PyObject *)a; + Py_ssize_t size; + Py_buffer va, vb; + PyObject *result = NULL; + + va.len = -1; + vb.len = -1; + if (_getbuffer(a, &va) < 0 || + _getbuffer(b, &vb) < 0) { + PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s", + Py_Type(a)->tp_name, Py_Type(b)->tp_name); + goto done; + } + + /* Optimize end cases */ + if (va.len == 0 && PyString_CheckExact(b)) { + result = b; + Py_INCREF(result); + goto done; + } + if (vb.len == 0 && PyString_CheckExact(a)) { + result = a; + Py_INCREF(result); + goto done; } - size = Py_Size(a) + Py_Size(b); + + size = va.len + vb.len; if (size < 0) { - PyErr_SetString(PyExc_OverflowError, - "strings are too large to concat"); - return NULL; + PyErr_NoMemory(); + goto done; } - /* Inline PyObject_NewVar */ - op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size); - if (op == NULL) - return PyErr_NoMemory(); - PyObject_INIT_VAR(op, &PyString_Type, size); - op->ob_shash = -1; - Py_MEMCPY(op->ob_sval, a->ob_sval, Py_Size(a)); - Py_MEMCPY(op->ob_sval + Py_Size(a), b->ob_sval, Py_Size(b)); - op->ob_sval[size] = '\0'; - return (PyObject *) op; -#undef b + result = PyString_FromStringAndSize(NULL, size); + if (result != NULL) { + memcpy(PyString_AS_STRING(result), va.buf, va.len); + memcpy(PyString_AS_STRING(result) + va.len, vb.buf, vb.len); + } + + done: + if (va.len != -1) + PyObject_ReleaseBuffer(a, &va); + if (vb.len != -1) + PyObject_ReleaseBuffer(b, &vb); + return result; } static PyObject * @@ -779,20 +785,26 @@ } static int -string_contains(PyObject *str_obj, PyObject *sub_obj) +string_contains(PyObject *self, PyObject *arg) { - if (!PyString_CheckExact(sub_obj)) { - if (PyUnicode_Check(sub_obj)) - return PyUnicode_Contains(str_obj, sub_obj); - if (!PyString_Check(sub_obj)) { - PyErr_Format(PyExc_TypeError, - "'in ' requires string as left operand, " - "not %.200s", Py_Type(sub_obj)->tp_name); - return -1; - } - } + Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError); + if (ival == -1 && PyErr_Occurred()) { + Py_buffer varg; + int pos; + PyErr_Clear(); + if (_getbuffer(arg, &varg) < 0) + return -1; + pos = stringlib_find(PyString_AS_STRING(self), Py_Size(self), + varg.buf, varg.len, 0); + PyObject_ReleaseBuffer(arg, &varg); + return pos >= 0; + } + if (ival < 0 || ival >= 256) { + PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); + return -1; + } - return stringlib_contains_obj(str_obj, sub_obj); + return memchr(PyString_AS_STRING(self), ival, Py_Size(self)) != NULL; } static PyObject* @@ -958,7 +970,8 @@ static int string_buffer_getbuffer(PyStringObject *self, Py_buffer *view, int flags) { - return PyBuffer_FillInfo(view, (void *)self->ob_sval, Py_Size(self), 0, flags); + return PyBuffer_FillInfo(view, (void *)self->ob_sval, Py_Size(self), + 0, flags); } static PySequenceMethods string_as_sequence = { @@ -1119,6 +1132,7 @@ Py_ssize_t len = PyString_GET_SIZE(self), n, i, j; Py_ssize_t maxsplit = -1, count=0; const char *s = PyString_AS_STRING(self), *sub; + Py_buffer vsub; PyObject *list, *str, *subobj = Py_None; #ifdef USE_FAST Py_ssize_t pos; @@ -1130,25 +1144,27 @@ maxsplit = PY_SSIZE_T_MAX; if (subobj == Py_None) return split_whitespace(s, len, maxsplit); - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - n = PyString_GET_SIZE(subobj); - } - else if (PyUnicode_Check(subobj)) - return PyUnicode_Split((PyObject *)self, subobj, maxsplit); - else if (PyObject_AsCharBuffer(subobj, &sub, &n)) + if (_getbuffer(subobj, &vsub) < 0) return NULL; + sub = vsub.buf; + n = vsub.len; if (n == 0) { PyErr_SetString(PyExc_ValueError, "empty separator"); + PyObject_ReleaseBuffer(subobj, &vsub); return NULL; } - else if (n == 1) - return split_char(s, len, sub[0], maxsplit); + else if (n == 1) { + char ch = sub[0]; + PyObject_ReleaseBuffer(subobj, &vsub); + return split_char(s, len, ch, maxsplit); + } list = PyList_New(PREALLOC_SIZE(maxsplit)); - if (list == NULL) + if (list == NULL) { + PyObject_ReleaseBuffer(subobj, &vsub); return NULL; + } #ifdef USE_FAST i = j = 0; @@ -1174,10 +1190,12 @@ #endif SPLIT_ADD(s, i, len); FIX_PREALLOC_SIZE(list); + PyObject_ReleaseBuffer(subobj, &vsub); return list; onError: Py_DECREF(list); + PyObject_ReleaseBuffer(subobj, &vsub); return NULL; } @@ -1259,8 +1277,8 @@ SPLIT_ADD(s, i + 1, j + 1); } if (i >= 0) { - /* Only occurs when maxsplit was reached */ - /* Skip any remaining whitespace and copy to beginning of string */ + /* Only occurs when maxsplit was reached. Skip any remaining + whitespace and copy to beginning of string. */ RSKIP_SPACE(s, i); if (i >= 0) SPLIT_ADD(s, 0, i + 1); @@ -1323,6 +1341,7 @@ Py_ssize_t len = PyString_GET_SIZE(self), n, i, j; Py_ssize_t maxsplit = -1, count=0; const char *s = PyString_AS_STRING(self), *sub; + Py_buffer vsub; PyObject *list, *str, *subobj = Py_None; if (!PyArg_ParseTuple(args, "|On:rsplit", &subobj, &maxsplit)) @@ -1331,25 +1350,27 @@ maxsplit = PY_SSIZE_T_MAX; if (subobj == Py_None) return rsplit_whitespace(s, len, maxsplit); - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - n = PyString_GET_SIZE(subobj); - } - else if (PyUnicode_Check(subobj)) - return PyUnicode_RSplit((PyObject *)self, subobj, maxsplit); - else if (PyObject_AsCharBuffer(subobj, &sub, &n)) + if (_getbuffer(subobj, &vsub) < 0) return NULL; + sub = vsub.buf; + n = vsub.len; if (n == 0) { PyErr_SetString(PyExc_ValueError, "empty separator"); + PyObject_ReleaseBuffer(subobj, &vsub); return NULL; } - else if (n == 1) - return rsplit_char(s, len, sub[0], maxsplit); + else if (n == 1) { + char ch = sub[0]; + PyObject_ReleaseBuffer(subobj, &vsub); + return rsplit_char(s, len, ch, maxsplit); + } list = PyList_New(PREALLOC_SIZE(maxsplit)); - if (list == NULL) + if (list == NULL) { + PyObject_ReleaseBuffer(subobj, &vsub); return NULL; + } j = len; i = j - n; @@ -1368,10 +1389,12 @@ FIX_PREALLOC_SIZE(list); if (PyList_Reverse(list) < 0) goto onError; + PyObject_ReleaseBuffer(subobj, &vsub); return list; onError: Py_DECREF(list); + PyObject_ReleaseBuffer(subobj, &vsub); return NULL; } @@ -1450,7 +1473,7 @@ sz += seplen; if (sz < old_sz || sz > PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, - "join() result is too long for a Python string"); + "join() result is too long for a Python string"); Py_DECREF(seq); return NULL; } @@ -1619,12 +1642,18 @@ Py_LOCAL_INLINE(PyObject *) do_xstrip(PyStringObject *self, int striptype, PyObject *sepobj) { + Py_buffer vsep; char *s = PyString_AS_STRING(self); Py_ssize_t len = PyString_GET_SIZE(self); - char *sep = PyString_AS_STRING(sepobj); - Py_ssize_t seplen = PyString_GET_SIZE(sepobj); + char *sep; + Py_ssize_t seplen; Py_ssize_t i, j; + if (_getbuffer(sepobj, &vsep) < 0) + return NULL; + sep = vsep.buf; + seplen = vsep.len; + i = 0; if (striptype != RIGHTSTRIP) { while (i < len && memchr(sep, Py_CHARMASK(s[i]), seplen)) { @@ -1640,6 +1669,8 @@ j++; } + PyObject_ReleaseBuffer(sepobj, &vsep); + if (i == 0 && j == len && PyString_CheckExact(self)) { Py_INCREF(self); return (PyObject*)self; @@ -1688,24 +1719,8 @@ return NULL; if (sep != NULL && sep != Py_None) { - if (PyString_Check(sep)) - return do_xstrip(self, striptype, sep); - else if (PyUnicode_Check(sep)) { - PyObject *uniself = PyUnicode_FromObject((PyObject *)self); - PyObject *res; - if (uniself==NULL) - return NULL; - res = _PyUnicode_XStrip((PyUnicodeObject *)uniself, - striptype, sep); - Py_DECREF(uniself); - return res; - } - PyErr_Format(PyExc_TypeError, - "%s arg must be None or string", - STRIPNAME(striptype)); - return NULL; + return do_xstrip(self, striptype, sep); } - return do_strip(self, striptype); } @@ -1996,7 +2011,7 @@ return end; } else { for (; start <= end; start++) - if (Py_STRING_MATCH(target, start, pattern, pattern_len)) + if (Py_STRING_MATCH(target, start,pattern,pattern_len)) return start; } return -1; @@ -2034,14 +2049,15 @@ end -= pattern_len; if (direction < 0) { for (; (end >= start); end--) - if (Py_STRING_MATCH(target, end, pattern, pattern_len)) { + if (Py_STRING_MATCH(target, end,pattern,pattern_len)) { count++; if (--maxcount <= 0) break; end -= pattern_len-1; } } else { for (; (start <= end); start++) - if (Py_STRING_MATCH(target, start, pattern, pattern_len)) { + if (Py_STRING_MATCH(target, start, + pattern, pattern_len)) { count++; if (--maxcount <= 0) break; @@ -2331,12 +2347,14 @@ /* result_len = self_len + count * (to_len-1) */ product = count * (to_len-1); if (product / (to_len-1) != count) { - PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); return NULL; } result_len = self_len + product; if (result_len < 0) { - PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); return NULL; } @@ -2399,12 +2417,14 @@ /* result_len = self_len + count * (to_len-from_len) */ product = count * (to_len-from_len); if (product / (to_len-from_len) != count) { - PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); return NULL; } result_len = self_len + product; if (result_len < 0) { - PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); return NULL; } @@ -2484,7 +2504,8 @@ return replace_delete_single_character( self, from_s[0], maxcount); } else { - return replace_delete_substring(self, from_s, from_len, maxcount); + return replace_delete_substring(self, from_s, + from_len, maxcount); } } @@ -2499,7 +2520,8 @@ maxcount); } else { return replace_substring_in_place( - self, from_s, from_len, to_s, to_len, maxcount); + self, from_s, from_len, to_s, to_len, + maxcount); } } @@ -2509,7 +2531,8 @@ to_s, to_len, maxcount); } else { /* len('from')>=2, len('to')>=1 */ - return replace_substring(self, from_s, from_len, to_s, to_len, maxcount); + return replace_substring(self, from_s, from_len, to_s, to_len, + maxcount); } } @@ -2709,11 +2732,11 @@ PyDoc_STRVAR(fromhex_doc, -"str8.fromhex(string) -> str8\n\ +"bytes.fromhex(string) -> bytes\n\ \n\ -Create a str8 object from a string of hexadecimal numbers.\n\ +Create a bytes object from a string of hexadecimal numbers.\n\ Spaces between two numbers are accepted. Example:\n\ -str8.fromhex('10 1112') -> s'\\x10\\x11\\x12'."); +bytes.fromhex('10 1112') -> s'\\x10\\x11\\x12'."); static int hex_digit_to_int(Py_UNICODE c) @@ -2771,7 +2794,7 @@ return newstring; error: - Py_DECREF(newstring); + Py_XDECREF(newstring); return NULL; } @@ -2858,7 +2881,7 @@ if (type != &PyString_Type) return str_subtype_new(type, args, kwds); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:str8", kwlist, &x, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:bytes", kwlist, &x, &encoding, &errors)) return NULL; if (x == NULL) { @@ -2885,7 +2908,8 @@ at the moment */ if (PyBytes_Check(new)) { PyObject *str; - str = PyString_FromString(PyBytes_AsString(new)); + str = PyString_FromStringAndSize( + PyBytes_AS_STRING(new), Py_Size(new)); Py_DECREF(new); if (!str) return NULL; @@ -2893,7 +2917,7 @@ } if (!PyString_Check(new)) { PyErr_Format(PyExc_TypeError, - "encoder did not return a str8 " + "encoder did not return a bytes " "object (type=%.400s)", Py_Type(new)->tp_name); Py_DECREF(new); @@ -2905,7 +2929,7 @@ /* If it's not unicode, there can't be encoding or errors */ if (encoding != NULL || errors != NULL) { PyErr_SetString(PyExc_TypeError, - "encoding or errors without a string argument"); + "encoding or errors without a string argument"); return NULL; } @@ -2949,8 +2973,8 @@ return NULL; } - /* For the iterator version, create a string object and resize as needed. */ - /* XXX(gb): is 64 a good value? also, optimize this if length is known */ + /* For iterator version, create a string object and resize as needed */ + /* XXX(gb): is 64 a good value? also, optimize if length is known */ size = 64; new = PyString_FromStringAndSize(NULL, size); if (new == NULL) @@ -2974,9 +2998,9 @@ item = iternext(it); if (item == NULL) { if (PyErr_Occurred()) { - if (!PyErr_ExceptionMatches(PyExc_StopIteration)) - goto error; - PyErr_Clear(); + if (!PyErr_ExceptionMatches(PyExc_StopIteration)) + goto error; + PyErr_Clear(); } break; } @@ -3039,7 +3063,7 @@ } PyDoc_STRVAR(string_doc, -"str(object) -> string\n\ +"bytes(object) -> string\n\ \n\ Return a nice string representation of the object.\n\ If the argument is a string, the return value is the same object."); @@ -3048,7 +3072,7 @@ PyTypeObject PyString_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "str8", + "bytes", sizeof(PyStringObject), sizeof(char), string_dealloc, /* tp_dealloc */ @@ -3062,7 +3086,7 @@ &string_as_mapping, /* tp_as_mapping */ (hashfunc)string_hash, /* tp_hash */ 0, /* tp_call */ - string_str, /* tp_str */ + string_repr, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &string_as_buffer, /* tp_as_buffer */ @@ -3093,14 +3117,15 @@ PyString_Concat(register PyObject **pv, register PyObject *w) { register PyObject *v; + assert(pv != NULL); if (*pv == NULL) return; - if (w == NULL || !PyString_Check(*pv)) { + if (w == NULL) { Py_DECREF(*pv); *pv = NULL; return; } - v = string_concat((PyStringObject *) *pv, w); + v = string_concat(*pv, w); Py_DECREF(*pv); *pv = v; } Modified: python/branches/py3k-pep3137/Objects/typeobject.c ============================================================================== --- python/branches/py3k-pep3137/Objects/typeobject.c (original) +++ python/branches/py3k-pep3137/Objects/typeobject.c Thu Nov 1 00:29:18 2007 @@ -1006,7 +1006,7 @@ if (name == NULL) { PyErr_Clear(); Py_XDECREF(name); - name = PyObject_ReprStr8(cls); + name = PyObject_Repr(cls); } if (name == NULL) return NULL; Modified: python/branches/py3k-pep3137/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k-pep3137/Objects/unicodeobject.c (original) +++ python/branches/py3k-pep3137/Objects/unicodeobject.c Thu Nov 1 00:29:18 2007 @@ -998,7 +998,10 @@ return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(obj), PyUnicode_GET_SIZE(obj)); } - return PyUnicode_FromEncodedObject(obj, NULL, "strict"); + PyErr_Format(PyExc_TypeError, + "Can't convert '%.100s' object to str implicitly", + Py_Type(obj)->tp_name); + return NULL; } PyObject *PyUnicode_FromEncodedObject(register PyObject *obj, @@ -6392,9 +6395,6 @@ { PyUnicodeObject *u = NULL, *v = NULL, *w; - if (PyBytes_Check(left) || PyBytes_Check(right)) - return PyBytes_Concat(left, right); - /* Coerce the two arguments */ u = (PyUnicodeObject *)PyUnicode_FromObject(left); if (u == NULL) Modified: python/branches/py3k-pep3137/Python/bltinmodule.c ============================================================================== --- python/branches/py3k-pep3137/Python/bltinmodule.c (original) +++ python/branches/py3k-pep3137/Python/bltinmodule.c Thu Nov 1 00:29:18 2007 @@ -1797,7 +1797,8 @@ SETBUILTIN("True", Py_True); SETBUILTIN("bool", &PyBool_Type); SETBUILTIN("memoryview", &PyMemoryView_Type); - SETBUILTIN("bytes", &PyBytes_Type); + SETBUILTIN("buffer", &PyBytes_Type); + SETBUILTIN("bytes", &PyString_Type); SETBUILTIN("classmethod", &PyClassMethod_Type); #ifndef WITHOUT_COMPLEX SETBUILTIN("complex", &PyComplex_Type); @@ -1816,7 +1817,6 @@ SETBUILTIN("slice", &PySlice_Type); SETBUILTIN("staticmethod", &PyStaticMethod_Type); SETBUILTIN("str", &PyUnicode_Type); - SETBUILTIN("str8", &PyString_Type); SETBUILTIN("super", &PySuper_Type); SETBUILTIN("tuple", &PyTuple_Type); SETBUILTIN("type", &PyType_Type); Modified: python/branches/py3k-pep3137/Python/ceval.c ============================================================================== --- python/branches/py3k-pep3137/Python/ceval.c (original) +++ python/branches/py3k-pep3137/Python/ceval.c Thu Nov 1 00:29:18 2007 @@ -1564,8 +1564,7 @@ break; } PyErr_Format(PyExc_SystemError, - "no locals found when storing %s", - PyObject_REPR(w)); + "no locals found when storing %R", w); break; case DELETE_NAME: @@ -1578,8 +1577,7 @@ break; } PyErr_Format(PyExc_SystemError, - "no locals when deleting %s", - PyObject_REPR(w)); + "no locals when deleting %R", w); break; PREDICTED_WITH_ARG(UNPACK_SEQUENCE); @@ -1668,8 +1666,7 @@ w = GETITEM(names, oparg); if ((v = f->f_locals) == NULL) { PyErr_Format(PyExc_SystemError, - "no locals when loading %s", - PyObject_REPR(w)); + "no locals when loading %R", w); break; } if (PyDict_CheckExact(v)) { @@ -1854,19 +1851,6 @@ PUSH(x); if (x != NULL) continue; break; - - case MAKE_BYTES: - w = POP(); - if (PyString_Check(w)) - x = PyBytes_FromStringAndSize( - PyString_AS_STRING(w), - PyString_GET_SIZE(w)); - else - x = NULL; - Py_DECREF(w); - PUSH(x); - if (x != NULL) continue; - break; case LOAD_ATTR: w = GETITEM(names, oparg); Modified: python/branches/py3k-pep3137/Python/compile.c ============================================================================== --- python/branches/py3k-pep3137/Python/compile.c (original) +++ python/branches/py3k-pep3137/Python/compile.c Thu Nov 1 00:29:18 2007 @@ -787,8 +787,6 @@ return 1-oparg; case BUILD_MAP: return 1; - case MAKE_BYTES: - return 0; case LOAD_ATTR: return 0; case COMPARE_OP: @@ -3222,7 +3220,6 @@ break; case Bytes_kind: ADDOP_O(c, LOAD_CONST, e->v.Bytes.s, consts); - ADDOP(c, MAKE_BYTES); break; case Ellipsis_kind: ADDOP_O(c, LOAD_CONST, Py_Ellipsis, consts); Modified: python/branches/py3k-pep3137/Python/pythonrun.c ============================================================================== --- python/branches/py3k-pep3137/Python/pythonrun.c (original) +++ python/branches/py3k-pep3137/Python/pythonrun.c Thu Nov 1 00:29:18 2007 @@ -743,6 +743,7 @@ PySys_SetObject("stdout", std); Py_DECREF(std); +#if 1 /* Disable this if you have trouble debugging bootstrap stuff */ /* Set sys.stderr, replaces the preliminary stderr */ if (!(std = PyFile_FromFd(fileno(stderr), "", "w", -1, NULL, "\n", 0))) { @@ -751,6 +752,7 @@ PySys_SetObject("__stderr__", std); PySys_SetObject("stderr", std); Py_DECREF(std); +#endif if (0) { error: @@ -1339,7 +1341,7 @@ PyArena *arena = PyArena_New(); if (arena == NULL) return NULL; - + mod = PyParser_ASTFromString(str, "", start, flags, arena); if (mod != NULL) ret = run_mod(mod, "", globals, locals, flags, arena); @@ -1356,7 +1358,7 @@ PyArena *arena = PyArena_New(); if (arena == NULL) return NULL; - + mod = PyParser_ASTFromFile(fp, filename, NULL, start, 0, 0, flags, NULL, arena); if (closeit) @@ -1705,7 +1707,7 @@ static void call_py_exitfuncs(void) { - if (pyexitfunc == NULL) + if (pyexitfunc == NULL) return; (*pyexitfunc)(); From python-3000-checkins at python.org Thu Nov 1 00:46:29 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 1 Nov 2007 00:46:29 +0100 (CET) Subject: [Python-3000-checkins] r58742 - in python/branches/py3k-pep3137: Lib/test/output/test_pep277 Message-ID: <20071031234629.31ABC1E400A@bag.python.org> Author: guido.van.rossum Date: Thu Nov 1 00:46:28 2007 New Revision: 58742 Modified: python/branches/py3k-pep3137/ (props changed) python/branches/py3k-pep3137/Lib/test/output/test_pep277 Log: Merged revisions 58735-58741 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r58736 | christian.heimes | 2007-10-31 12:51:01 -0700 (Wed, 31 Oct 2007) | 1 line Oh, I missed the output part of the test ... ........ Modified: python/branches/py3k-pep3137/Lib/test/output/test_pep277 ============================================================================== --- python/branches/py3k-pep3137/Lib/test/output/test_pep277 (original) +++ python/branches/py3k-pep3137/Lib/test/output/test_pep277 Thu Nov 1 00:46:28 2007 @@ -1,3 +1,3 @@ test_pep277 -u'\xdf-\u66e8\u66e9\u66eb' -[u'Gr\xfc\xdf-Gott', u'abc', u'ascii', u'\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', u'\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435', u'\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', u'\u306b\u307d\u3093', u'\u66e8\u05e9\u3093\u0434\u0393\xdf', u'\u66e8\u66e9\u66eb'] +'\xdf-\u66e8\u66e9\u66eb' +['Gr\xfc\xdf-Gott', 'abc', 'ascii', '\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', '\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435', '\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', '\u306b\u307d\u3093', '\u66e8\u05e9\u3093\u0434\u0393\xdf', '\u66e8\u66e9\u66eb'] From python-3000-checkins at python.org Thu Nov 1 16:38:24 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 1 Nov 2007 16:38:24 +0100 (CET) Subject: [Python-3000-checkins] r58744 - in python/branches/py3k-pep3137/Lib: encodings/idna.py encodings/punycode.py test/test_binascii.py test/test_compile.py test/test_datetime.py test/test_exceptions.py test/test_float.py test/test_marshal.py test/testcodec.py Message-ID: <20071101153824.4137D1E4003@bag.python.org> Author: christian.heimes Date: Thu Nov 1 16:38:23 2007 New Revision: 58744 Modified: python/branches/py3k-pep3137/Lib/encodings/idna.py python/branches/py3k-pep3137/Lib/encodings/punycode.py python/branches/py3k-pep3137/Lib/test/test_binascii.py python/branches/py3k-pep3137/Lib/test/test_compile.py python/branches/py3k-pep3137/Lib/test/test_datetime.py python/branches/py3k-pep3137/Lib/test/test_exceptions.py python/branches/py3k-pep3137/Lib/test/test_float.py python/branches/py3k-pep3137/Lib/test/test_marshal.py python/branches/py3k-pep3137/Lib/test/testcodec.py Log: A couple of smaller fixes for unit tests and encodings that were broken by the rename of str8 -> bytes, bytes -> buffer. Modified: python/branches/py3k-pep3137/Lib/encodings/idna.py ============================================================================== --- python/branches/py3k-pep3137/Lib/encodings/idna.py (original) +++ python/branches/py3k-pep3137/Lib/encodings/idna.py Thu Nov 1 16:38:23 2007 @@ -151,9 +151,9 @@ raise UnicodeError("unsupported error handling "+errors) if not input: - return b"", 0 + return buffer(), 0 - result = b"" + result = buffer() labels = dots.split(input) if labels and not labels[-1]: trailing_dot = b'.' @@ -216,7 +216,7 @@ if labels: trailing_dot = b'.' - result = b"" + result = buffer() size = 0 for label in labels: if size: Modified: python/branches/py3k-pep3137/Lib/encodings/punycode.py ============================================================================== --- python/branches/py3k-pep3137/Lib/encodings/punycode.py (original) +++ python/branches/py3k-pep3137/Lib/encodings/punycode.py Thu Nov 1 16:38:23 2007 @@ -10,7 +10,7 @@ def segregate(str): """3.1 Basic code point segregation""" - base = b"" + base = buffer() extended = set() for c in str: if ord(c) < 128: @@ -18,7 +18,7 @@ else: extended.add(c) extended = sorted(extended) - return (base, extended) + return base, extended def selective_len(str, max): """Return the length of str, considering only characters below max.""" @@ -78,7 +78,7 @@ digits = b"abcdefghijklmnopqrstuvwxyz0123456789" def generate_generalized_integer(N, bias): """3.3 Generalized variable-length integers""" - result = b"" + result = buffer() j = 0 while 1: t = T(j, bias) @@ -107,7 +107,7 @@ def generate_integers(baselen, deltas): """3.4 Bias adaptation""" # Punycode parameters: initial bias = 72, damp = 700, skew = 38 - result = b"" + result = buffer() bias = 72 for points, delta in enumerate(deltas): s = generate_generalized_integer(delta, bias) Modified: python/branches/py3k-pep3137/Lib/test/test_binascii.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_binascii.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_binascii.py Thu Nov 1 16:38:23 2007 @@ -56,7 +56,7 @@ a = binascii.b2a_base64(b) lines.append(a) - fillers = bytes() + fillers = buffer() valid = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/" for i in range(256): if i not in valid: @@ -64,7 +64,7 @@ def addnoise(line): noise = fillers ratio = len(line) // len(noise) - res = bytes() + res = buffer() while line and noise: if len(line) // len(noise) > ratio: c, line = line[0], line[1:] @@ -72,7 +72,7 @@ c, noise = noise[0], noise[1:] res.append(c) return res + noise + line - res = bytes() + res = buffer() for line in map(addnoise, lines): b = binascii.a2b_base64(line) res += b Modified: python/branches/py3k-pep3137/Lib/test/test_compile.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_compile.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_compile.py Thu Nov 1 16:38:23 2007 @@ -157,7 +157,7 @@ s256 = "".join(["\n"] * 256 + ["spam"]) co = compile(s256, 'fn', 'exec') self.assertEqual(co.co_firstlineno, 257) - self.assertEqual(co.co_lnotab, str8()) + self.assertEqual(co.co_lnotab, bytes()) def test_literals_with_leading_zeroes(self): for arg in ["077787", "0xj", "0x.", "0e", "090000000000000", Modified: python/branches/py3k-pep3137/Lib/test/test_datetime.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_datetime.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_datetime.py Thu Nov 1 16:38:23 2007 @@ -1111,7 +1111,7 @@ # This shouldn't blow up because of the month byte alone. If # the implementation changes to do more-careful checking, it may # blow up because other fields are insane. - self.theclass(bytes(base[:2] + chr(ord_byte) + base[3:], "ascii")) + self.theclass(buffer(base[:2] + chr(ord_byte) + base[3:], "ascii")) ############################################################################# # datetime tests Modified: python/branches/py3k-pep3137/Lib/test/test_exceptions.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_exceptions.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_exceptions.py Thu Nov 1 16:38:23 2007 @@ -278,7 +278,7 @@ try: e = exc(*args) except: - print("\nexc=%r, args=%r" % (exc, args)) + print("\nexc=%r, args=%r" % (exc, args), file=sys.stderr) raise else: # Verify module name Modified: python/branches/py3k-pep3137/Lib/test/test_float.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_float.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_float.py Thu Nov 1 16:38:23 2007 @@ -40,14 +40,14 @@ 'chicken', 'unknown') BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00' -LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF)) +LE_DOUBLE_INF = bytes(reversed(buffer(BE_DOUBLE_INF))) BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00' -LE_DOUBLE_NAN = bytes(reversed(BE_DOUBLE_NAN)) +LE_DOUBLE_NAN = bytes(reversed(buffer(BE_DOUBLE_NAN))) BE_FLOAT_INF = b'\x7f\x80\x00\x00' -LE_FLOAT_INF = bytes(reversed(BE_FLOAT_INF)) +LE_FLOAT_INF = bytes(reversed(buffer(BE_FLOAT_INF))) BE_FLOAT_NAN = b'\x7f\xc0\x00\x00' -LE_FLOAT_NAN = bytes(reversed(BE_FLOAT_NAN)) +LE_FLOAT_NAN = bytes(reversed(buffer(BE_FLOAT_NAN))) # on non-IEEE platforms, attempting to unpack a bit pattern # representing an infinity or a NaN should raise an exception. Modified: python/branches/py3k-pep3137/Lib/test/test_marshal.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/test_marshal.py (original) +++ python/branches/py3k-pep3137/Lib/test/test_marshal.py Thu Nov 1 16:38:23 2007 @@ -39,7 +39,7 @@ # we're running the test on a 32-bit box, of course. def to_little_endian_string(value, nbytes): - b = bytes() + b = buffer() for i in range(nbytes): b.append(value & 0xff) value >>= 8 Modified: python/branches/py3k-pep3137/Lib/test/testcodec.py ============================================================================== --- python/branches/py3k-pep3137/Lib/test/testcodec.py (original) +++ python/branches/py3k-pep3137/Lib/test/testcodec.py Thu Nov 1 16:38:23 2007 @@ -36,7 +36,7 @@ decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ 0x78: "abc", # 1-n decoding mapping - str8(b"abc"): 0x0078,# 1-n encoding mapping + b"abc": 0x0078,# 1-n encoding mapping 0x01: None, # decoding mapping to 0x79: "", # decoding mapping to }) From python-3000-checkins at python.org Thu Nov 1 20:08:42 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 1 Nov 2007 20:08:42 +0100 (CET) Subject: [Python-3000-checkins] r58747 - python/branches/py3k/Lib/test/test_import.py python/branches/py3k/Lib/test/test_os.py Message-ID: <20071101190842.BBCF71E4005@bag.python.org> Author: christian.heimes Date: Thu Nov 1 20:08:42 2007 New Revision: 58747 Modified: python/branches/py3k/Lib/test/test_import.py python/branches/py3k/Lib/test/test_os.py Log: Fixed unit tests for os.environ. Some of the tests didn't test at all because os.environ was empty. Added import test for sys.path entries with non ASCII characters. The tests are passing on my Ubuntu box with utf-8 locales but they aren't passing on Windows XP. Modified: python/branches/py3k/Lib/test/test_import.py ============================================================================== --- python/branches/py3k/Lib/test/test_import.py (original) +++ python/branches/py3k/Lib/test/test_import.py Thu Nov 1 20:08:42 2007 @@ -3,10 +3,11 @@ import unittest import os import random +import shutil import sys import py_compile import warnings -from test.test_support import unlink +from test.test_support import unlink, TESTFN, unload def remove_files(name): @@ -157,8 +158,37 @@ warnings.simplefilter('error', ImportWarning) self.assertRaises(ImportWarning, __import__, "site-packages") +class UnicodePathsTests(unittest.TestCase): + SAMPLES = ('test', 'test????', 'test??', 'test???') + path = TESTFN + + def setUp(self): + os.mkdir(self.path) + self.syspath = sys.path[:] + + def tearDown(self): + shutil.rmtree(self.path) + sys.path = self.syspath + + def test_sys_path(self): + for i, subpath in enumerate(self.SAMPLES): + path = os.path.join(self.path, subpath) + os.mkdir(path) + self.failUnless(os.path.exists(path), os.listdir(self.path)) + f = open(os.path.join(path, 'testimport%i.py' % i), 'w') + f.write("testdata = 'unicode path %i'\n" % i) + f.close() + sys.path.append(path) + try: + mod = __import__("testimport%i" % i) + except ImportError: + print(path, file=sys.stderr) + raise + self.assertEqual(mod.testdata, 'unicode path %i' % i) + unload("testimport%i" % i) + def test_main(verbose=None): - run_unittest(ImportTest) + run_unittest(ImportTest, UnicodePathsTests) if __name__ == '__main__': test_main() Modified: python/branches/py3k/Lib/test/test_os.py ============================================================================== --- python/branches/py3k/Lib/test/test_os.py (original) +++ python/branches/py3k/Lib/test/test_os.py Thu Nov 1 20:08:42 2007 @@ -191,20 +191,26 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol): """check that os.environ object conform to mapping protocol""" type2test = None - def _reference(self): - return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"} - def _empty_mapping(self): - os.environ.clear() - return os.environ + def setUp(self): self.__save = dict(os.environ) - os.environ.clear() + for key, value in self._reference().items(): + os.environ[key] = value + def tearDown(self): os.environ.clear() os.environ.update(self.__save) + def _reference(self): + return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"} + + def _empty_mapping(self): + os.environ.clear() + return os.environ + # Bug 1110478 def test_update2(self): + os.environ.clear() if os.path.exists("/bin/sh"): os.environ.update(HELLO="World") value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() @@ -217,6 +223,10 @@ self.assertEquals(type(key), str) self.assertEquals(type(val), str) + def test_items(self): + for key, value in self._reference().items(): + self.assertEqual(os.environ.get(key), value) + class WalkTests(unittest.TestCase): """Tests for os.walk().""" From python-3000-checkins at python.org Thu Nov 1 20:41:07 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 1 Nov 2007 20:41:07 +0100 (CET) Subject: [Python-3000-checkins] r58748 - python/branches/py3k/Lib/test/test_import.py Message-ID: <20071101194107.D08AE1E400A@bag.python.org> Author: christian.heimes Date: Thu Nov 1 20:41:07 2007 New Revision: 58748 Modified: python/branches/py3k/Lib/test/test_import.py Log: Added unit test for bug http://bugs.python.org/issue1293 Modified: python/branches/py3k/Lib/test/test_import.py ============================================================================== --- python/branches/py3k/Lib/test/test_import.py (original) +++ python/branches/py3k/Lib/test/test_import.py Thu Nov 1 20:41:07 2007 @@ -1,4 +1,4 @@ -from test.test_support import TESTFN, run_unittest, catch_warning +?from test.test_support import TESTFN, run_unittest, catch_warning import unittest import os @@ -187,6 +187,16 @@ self.assertEqual(mod.testdata, 'unicode path %i' % i) unload("testimport%i" % i) + # http://bugs.python.org/issue1293 + def test_trailing_slash(self): + f = open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') + f.write("testdata = 'test_trailing_slash'") + f.close() + sys.path.append(self.path+'/') + mod = __import__("test_trailing_slash") + self.assertEqual(mod.testdata, 'test_trailing_slash') + unload("test_trailing_slash") + def test_main(verbose=None): run_unittest(ImportTest, UnicodePathsTests) From python-3000-checkins at python.org Thu Nov 1 20:42:43 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 1 Nov 2007 20:42:43 +0100 (CET) Subject: [Python-3000-checkins] r58749 - in python/branches/py3k: Lib/bsddb/dbshelve.py Lib/bsddb/test/test_misc.py Lib/collections.py Lib/ctypes/__init__.py Lib/decimal.py Lib/httplib.py Lib/idlelib/AutoComplete.py Lib/idlelib/AutoCompleteWindow.py Lib/idlelib/EditorWindow.py Lib/idlelib/FileList.py Lib/idlelib/IOBinding.py Lib/idlelib/NEWS.txt Lib/idlelib/PyShell.py Lib/idlelib/WidgetRedirector.py Lib/idlelib/aboutDialog.py Lib/idlelib/configDialog.py Lib/idlelib/run.py Lib/idlelib/tabbedpages.py Lib/idlelib/textView.py Lib/logging/__init__.py Lib/logging/handlers.py Lib/mimetypes.py Lib/plat-freebsd6/IN.py Lib/plat-freebsd7/IN.py Lib/plat-freebsd8 Lib/sched.py Lib/smtpd.py Lib/test/crashers/file_threads.py Lib/test/crashers/multithreaded_close.py Lib/test/decimaltestdata/extra.decTest Lib/test/regrtest.py Lib/test/test_bufio.py Lib/test/test_collections.py Lib/test/test_decimal.py Lib/test/test_deque.py Lib/test/test_fcntl.py Lib/test/test_httplib.py Lib/test/test_itertools.py Lib/test/test_list.py Lib/test/test_mmap.py Lib/test/test_socket.py Lib/test/test_support.py Lib/test/test_univnewlines.py Lib/test/test_zlib.py Lib/xml/dom/minidom.py Makefile.pre.in Misc/developers.txt Modules/_bsddb.c Modules/_collectionsmodule.c Modules/_ctypes/cfield.c Modules/_ctypes/libffi/src/alpha/ffi.c Modules/_ctypes/libffi/src/ia64/ffi.c Modules/_ctypes/libffi/src/mips/ffi.c Modules/_ctypes/libffi/src/pa/ffi.c Modules/_ctypes/libffi/src/powerpc/ffi.c Modules/_ctypes/libffi/src/s390/ffi.c Modules/_ctypes/libffi/src/sparc/ffi.c Modules/bsddb.h Modules/itertoolsmodule.c Modules/main.c Modules/mmapmodule.c Objects/dictobject.c Objects/enumobject.c Objects/listobject.c Objects/object.c Objects/stringobject.c Objects/tupleobject.c Objects/unicodeobject.c PC/pyconfig.h Parser/pgen.c Python/ast.c Python/bltinmodule.c Python/marshal.c configure configure.in setup.py Message-ID: <20071101194243.90BB21E400A@bag.python.org> Author: guido.van.rossum Date: Thu Nov 1 20:42:39 2007 New Revision: 58749 Added: python/branches/py3k/Lib/idlelib/tabbedpages.py - copied unchanged from r58739, python/trunk/Lib/idlelib/tabbedpages.py python/branches/py3k/Lib/plat-freebsd8/ (props changed) - copied from r58739, python/trunk/Lib/plat-freebsd8/ python/branches/py3k/Lib/test/crashers/multithreaded_close.py - copied unchanged from r58739, python/trunk/Lib/test/crashers/multithreaded_close.py python/branches/py3k/Modules/bsddb.h - copied, changed from r58739, python/trunk/Modules/bsddb.h Removed: python/branches/py3k/Lib/test/crashers/file_threads.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/bsddb/dbshelve.py python/branches/py3k/Lib/bsddb/test/test_misc.py python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/ctypes/__init__.py python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/httplib.py python/branches/py3k/Lib/idlelib/AutoComplete.py python/branches/py3k/Lib/idlelib/AutoCompleteWindow.py python/branches/py3k/Lib/idlelib/EditorWindow.py python/branches/py3k/Lib/idlelib/FileList.py python/branches/py3k/Lib/idlelib/IOBinding.py python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/idlelib/PyShell.py python/branches/py3k/Lib/idlelib/WidgetRedirector.py python/branches/py3k/Lib/idlelib/aboutDialog.py python/branches/py3k/Lib/idlelib/configDialog.py python/branches/py3k/Lib/idlelib/run.py python/branches/py3k/Lib/idlelib/textView.py python/branches/py3k/Lib/logging/__init__.py python/branches/py3k/Lib/logging/handlers.py python/branches/py3k/Lib/mimetypes.py python/branches/py3k/Lib/plat-freebsd6/IN.py python/branches/py3k/Lib/plat-freebsd7/IN.py python/branches/py3k/Lib/sched.py python/branches/py3k/Lib/smtpd.py python/branches/py3k/Lib/test/decimaltestdata/extra.decTest python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Lib/test/test_bufio.py python/branches/py3k/Lib/test/test_collections.py python/branches/py3k/Lib/test/test_decimal.py python/branches/py3k/Lib/test/test_deque.py python/branches/py3k/Lib/test/test_fcntl.py python/branches/py3k/Lib/test/test_httplib.py python/branches/py3k/Lib/test/test_itertools.py python/branches/py3k/Lib/test/test_list.py python/branches/py3k/Lib/test/test_mmap.py python/branches/py3k/Lib/test/test_socket.py python/branches/py3k/Lib/test/test_support.py python/branches/py3k/Lib/test/test_univnewlines.py python/branches/py3k/Lib/test/test_zlib.py python/branches/py3k/Lib/xml/dom/minidom.py python/branches/py3k/Makefile.pre.in python/branches/py3k/Misc/developers.txt python/branches/py3k/Modules/_bsddb.c python/branches/py3k/Modules/_collectionsmodule.c python/branches/py3k/Modules/_ctypes/cfield.c python/branches/py3k/Modules/_ctypes/libffi/src/alpha/ffi.c python/branches/py3k/Modules/_ctypes/libffi/src/ia64/ffi.c python/branches/py3k/Modules/_ctypes/libffi/src/mips/ffi.c python/branches/py3k/Modules/_ctypes/libffi/src/pa/ffi.c python/branches/py3k/Modules/_ctypes/libffi/src/powerpc/ffi.c python/branches/py3k/Modules/_ctypes/libffi/src/s390/ffi.c python/branches/py3k/Modules/_ctypes/libffi/src/sparc/ffi.c python/branches/py3k/Modules/itertoolsmodule.c python/branches/py3k/Modules/main.c python/branches/py3k/Modules/mmapmodule.c python/branches/py3k/Objects/dictobject.c python/branches/py3k/Objects/enumobject.c python/branches/py3k/Objects/listobject.c python/branches/py3k/Objects/object.c python/branches/py3k/Objects/stringobject.c python/branches/py3k/Objects/tupleobject.c python/branches/py3k/Objects/unicodeobject.c python/branches/py3k/PC/pyconfig.h python/branches/py3k/Parser/pgen.c python/branches/py3k/Python/ast.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/marshal.c python/branches/py3k/configure python/branches/py3k/configure.in python/branches/py3k/setup.py Log: Merged revisions 58221-58741 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r58221 | georg.brandl | 2007-09-20 10:57:59 -0700 (Thu, 20 Sep 2007) | 2 lines Patch #1181: add os.environ.clear() method. ........ r58225 | sean.reifschneider | 2007-09-20 23:33:28 -0700 (Thu, 20 Sep 2007) | 3 lines Issue1704287: "make install" fails unless you do "make" first. Make oldsharedmods and sharedmods in "libinstall". ........ r58232 | guido.van.rossum | 2007-09-22 13:18:03 -0700 (Sat, 22 Sep 2007) | 4 lines Patch # 188 by Philip Jenvey. Make tell() mark CRLF as a newline. With unit test. ........ r58242 | georg.brandl | 2007-09-24 10:55:47 -0700 (Mon, 24 Sep 2007) | 2 lines Fix typo and double word. ........ r58245 | georg.brandl | 2007-09-24 10:59:28 -0700 (Mon, 24 Sep 2007) | 2 lines #1196: document default radix for int(). ........ r58247 | georg.brandl | 2007-09-24 11:08:24 -0700 (Mon, 24 Sep 2007) | 2 lines #1177: accept 2xx responses for https too, not only http. ........ r58249 | andrew.kuchling | 2007-09-24 16:45:51 -0700 (Mon, 24 Sep 2007) | 1 line Remove stray odd character; grammar fix ........ r58250 | andrew.kuchling | 2007-09-24 16:46:28 -0700 (Mon, 24 Sep 2007) | 1 line Typo fix ........ r58251 | andrew.kuchling | 2007-09-24 17:09:42 -0700 (Mon, 24 Sep 2007) | 1 line Add various items ........ r58268 | vinay.sajip | 2007-09-26 22:34:45 -0700 (Wed, 26 Sep 2007) | 1 line Change to flush and close logic to fix #1760556. ........ r58269 | vinay.sajip | 2007-09-26 22:38:51 -0700 (Wed, 26 Sep 2007) | 1 line Change to basicConfig() to fix #1021. ........ r58270 | georg.brandl | 2007-09-26 23:26:58 -0700 (Wed, 26 Sep 2007) | 2 lines #1208: document match object's boolean value. ........ r58271 | vinay.sajip | 2007-09-26 23:56:13 -0700 (Wed, 26 Sep 2007) | 1 line Minor date change. ........ r58272 | vinay.sajip | 2007-09-27 00:35:10 -0700 (Thu, 27 Sep 2007) | 1 line Change to LogRecord.__init__() to fix #1206. Note that archaic use of type(x) == types.DictType is because of keeping 1.5.2 compatibility. While this is much less relevant these days, there probably needs to be a separate commit for removing all archaic constructs at the same time. ........ r58288 | brett.cannon | 2007-09-30 12:45:10 -0700 (Sun, 30 Sep 2007) | 9 lines tuple.__repr__ did not consider a reference loop as it is not possible from Python code; but it is possible from C. object.__str__ had the issue of not expecting a type to doing something within it's tp_str implementation that could trigger an infinite recursion, but it could in C code.. Both found thanks to BaseException and how it handles its repr. Closes issue #1686386. Thanks to Thomas Herve for taking an initial stab at coming up with a solution. ........ r58289 | brett.cannon | 2007-09-30 13:37:19 -0700 (Sun, 30 Sep 2007) | 3 lines Fix error introduced by r58288; if a tuple is length 0 return its repr and don't worry about any self-referring tuples. ........ r58294 | facundo.batista | 2007-10-02 10:01:24 -0700 (Tue, 02 Oct 2007) | 11 lines Made the various is_* operations return booleans. This was discussed with Cawlishaw by mail, and he basically confirmed that to these is_* operations, there's no need to return Decimal(0) and Decimal(1) if the language supports the False and True booleans. Also added a few tests for the these functions in extra.decTest, since they are mostly untested (apart from the doctests). Thanks Mark Dickinson ........ r58295 | facundo.batista | 2007-10-02 11:21:18 -0700 (Tue, 02 Oct 2007) | 4 lines Added a class to store the digits of log(10), so that they can be made available when necessary without recomputing. Thanks Mark Dickinson ........ r58299 | mark.summerfield | 2007-10-03 01:53:21 -0700 (Wed, 03 Oct 2007) | 4 lines Added note in footnote about string comparisons about unicodedata.normalize(). ........ r58304 | raymond.hettinger | 2007-10-03 14:18:11 -0700 (Wed, 03 Oct 2007) | 1 line enumerate() is no longer bounded to using sequences shorter than LONG_MAX. The possibility of overflow was sending some newsgroup posters into a tizzy. ........ r58305 | raymond.hettinger | 2007-10-03 17:20:27 -0700 (Wed, 03 Oct 2007) | 1 line itertools.count() no longer limited to sys.maxint. ........ r58306 | kurt.kaiser | 2007-10-03 18:49:54 -0700 (Wed, 03 Oct 2007) | 3 lines Assume that the user knows when he wants to end the line; don't insert something he didn't select or complete. ........ r58307 | kurt.kaiser | 2007-10-03 19:07:50 -0700 (Wed, 03 Oct 2007) | 2 lines Remove unused theme that was causing a fault in p3k. ........ r58308 | kurt.kaiser | 2007-10-03 19:09:17 -0700 (Wed, 03 Oct 2007) | 2 lines Clean up EditorWindow close. ........ r58309 | kurt.kaiser | 2007-10-03 19:53:07 -0700 (Wed, 03 Oct 2007) | 7 lines textView cleanup. Patch 1718043 Tal Einat. M idlelib/EditorWindow.py M idlelib/aboutDialog.py M idlelib/textView.py M idlelib/NEWS.txt ........ r58310 | kurt.kaiser | 2007-10-03 20:11:12 -0700 (Wed, 03 Oct 2007) | 3 lines configDialog cleanup. Patch 1730217 Tal Einat. ........ r58311 | neal.norwitz | 2007-10-03 23:00:48 -0700 (Wed, 03 Oct 2007) | 4 lines Coverity #151: Remove deadcode. All this code already exists above starting at line 653. ........ r58325 | fred.drake | 2007-10-04 19:46:12 -0700 (Thu, 04 Oct 2007) | 1 line wrap lines to <80 characters before fixing errors ........ r58326 | raymond.hettinger | 2007-10-04 19:47:07 -0700 (Thu, 04 Oct 2007) | 6 lines Add __asdict__() to NamedTuple and refine the docs. Add maxlen support to deque() and fixup docs. Partially fix __reduce__(). The None as a third arg was no longer supported. Still needs work on __reduce__() to handle recursive inputs. ........ r58327 | fred.drake | 2007-10-04 19:48:32 -0700 (Thu, 04 Oct 2007) | 3 lines move descriptions of ac_(in|out)_buffer_size to the right place http://bugs.python.org/issue1053 ........ r58329 | neal.norwitz | 2007-10-04 20:39:17 -0700 (Thu, 04 Oct 2007) | 3 lines dict could be NULL, so we need to XDECREF. Fix a compiler warning about passing a PyTypeObject* instead of PyObject*. ........ r58330 | neal.norwitz | 2007-10-04 20:41:19 -0700 (Thu, 04 Oct 2007) | 2 lines Fix Coverity #158: Check the correct variable. ........ r58332 | neal.norwitz | 2007-10-04 22:01:38 -0700 (Thu, 04 Oct 2007) | 7 lines Fix Coverity #159. This code was broken if save() returned a negative number since i contained a boolean value and then we compared i < 0 which should never be true. Will backport (assuming it's necessary) ........ r58334 | neal.norwitz | 2007-10-04 22:29:17 -0700 (Thu, 04 Oct 2007) | 1 line Add a note about fixing some more warnings found by Coverity. ........ r58338 | raymond.hettinger | 2007-10-05 12:07:31 -0700 (Fri, 05 Oct 2007) | 1 line Restore BEGIN/END THREADS macros which were squashed in the previous checkin ........ r58343 | gregory.p.smith | 2007-10-06 00:48:10 -0700 (Sat, 06 Oct 2007) | 3 lines Stab in the dark attempt to fix the test_bsddb3 failure on sparc and S-390 ubuntu buildbots. ........ r58344 | gregory.p.smith | 2007-10-06 00:51:59 -0700 (Sat, 06 Oct 2007) | 2 lines Allows BerkeleyDB 4.6.x >= 4.6.21 for the bsddb module. ........ r58348 | gregory.p.smith | 2007-10-06 08:47:37 -0700 (Sat, 06 Oct 2007) | 3 lines Use the host the author likely meant in the first place. pop.gmail.com is reliable. gmail.org is someones personal domain. ........ r58351 | neal.norwitz | 2007-10-06 12:16:28 -0700 (Sat, 06 Oct 2007) | 3 lines Ensure that this test will pass even if another test left an unwritable TESTFN. Also use the safe unlink in test_support instead of rolling our own here. ........ r58368 | georg.brandl | 2007-10-08 00:50:24 -0700 (Mon, 08 Oct 2007) | 3 lines #1123: fix the docs for the str.split(None, sep) case. Also expand a few other methods' docs, which had more info in the deprecated string module docs. ........ r58369 | georg.brandl | 2007-10-08 01:06:05 -0700 (Mon, 08 Oct 2007) | 2 lines Update docstring of sched, also remove an unused assignment. ........ r58370 | raymond.hettinger | 2007-10-08 02:14:28 -0700 (Mon, 08 Oct 2007) | 5 lines Add comments to NamedTuple code. Let the field spec be either a string or a non-string sequence (suggested by Martin Blais with use cases). Improve the error message in the case of a SyntaxError (caused by a duplicate field name). ........ r58371 | raymond.hettinger | 2007-10-08 02:56:29 -0700 (Mon, 08 Oct 2007) | 1 line Missed a line in the docs ........ r58372 | raymond.hettinger | 2007-10-08 03:11:51 -0700 (Mon, 08 Oct 2007) | 1 line Better variable names ........ r58376 | georg.brandl | 2007-10-08 07:12:47 -0700 (Mon, 08 Oct 2007) | 3 lines #1199: docs for tp_as_{number,sequence,mapping}, by Amaury Forgeot d'Arc. No need to merge this to py3k! ........ r58380 | raymond.hettinger | 2007-10-08 14:26:58 -0700 (Mon, 08 Oct 2007) | 1 line Eliminate camelcase function name ........ r58381 | andrew.kuchling | 2007-10-08 16:23:03 -0700 (Mon, 08 Oct 2007) | 1 line Eliminate camelcase function name ........ r58382 | raymond.hettinger | 2007-10-08 18:36:23 -0700 (Mon, 08 Oct 2007) | 1 line Make the error messages more specific ........ r58384 | gregory.p.smith | 2007-10-08 23:02:21 -0700 (Mon, 08 Oct 2007) | 10 lines Splits Modules/_bsddb.c up into bsddb.h and _bsddb.c and adds a C API object available as bsddb.db.api. This is based on the patch submitted by Duncan Grisby here: http://sourceforge.net/tracker/index.php?func=detail&aid=1551895&group_id=13900&atid=313900 See this thread for additional info: http://sourceforge.net/mailarchive/forum.php?thread_name=E1GAVDK-0002rk-Iw%40apasphere.com&forum_name=pybsddb-users It also cleans up the code a little by removing some ifdef/endifs for python prior to 2.1 and for unsupported Berkeley DB <= 3.2. ........ r58385 | gregory.p.smith | 2007-10-08 23:50:43 -0700 (Mon, 08 Oct 2007) | 5 lines Fix a double free when positioning a database cursor to a non-existant string key (and probably a few other situations with string keys). This was reported with a patch as pybsddb sourceforge bug 1708868 by jjjhhhlll at gmail. ........ r58386 | gregory.p.smith | 2007-10-09 00:19:11 -0700 (Tue, 09 Oct 2007) | 3 lines Use the highest cPickle protocol in bsddb.dbshelve. This comes from sourceforge pybsddb patch 1551443 by w_barnes. ........ r58394 | gregory.p.smith | 2007-10-09 11:26:02 -0700 (Tue, 09 Oct 2007) | 2 lines remove another sleepycat reference ........ r58396 | kurt.kaiser | 2007-10-09 12:31:30 -0700 (Tue, 09 Oct 2007) | 3 lines Allow interrupt only when executing user code in subprocess Patch 1225 Tal Einat modified from IDLE-Spoon. ........ r58399 | brett.cannon | 2007-10-09 17:07:50 -0700 (Tue, 09 Oct 2007) | 5 lines Remove file-level typedefs that were inconsistently used throughout the file. Just move over to the public API names. Closes issue1238. ........ r58401 | raymond.hettinger | 2007-10-09 17:26:46 -0700 (Tue, 09 Oct 2007) | 1 line Accept Jim Jewett's api suggestion to use None instead of -1 to indicate unbounded deques. ........ r58403 | kurt.kaiser | 2007-10-09 17:55:40 -0700 (Tue, 09 Oct 2007) | 2 lines Allow cursor color change w/o restart. Patch 1725576 Tal Einat. ........ r58404 | kurt.kaiser | 2007-10-09 18:06:47 -0700 (Tue, 09 Oct 2007) | 2 lines show paste if > 80 columns. Patch 1659326 Tal Einat. ........ r58415 | thomas.heller | 2007-10-11 12:51:32 -0700 (Thu, 11 Oct 2007) | 5 lines On OS X, use os.uname() instead of gestalt.sysv(...) to get the operating system version. This allows to use ctypes when Python was configured with --disable-toolbox-glue. ........ r58419 | neal.norwitz | 2007-10-11 20:01:01 -0700 (Thu, 11 Oct 2007) | 1 line Get rid of warning about not being able to create an existing directory. ........ r58420 | neal.norwitz | 2007-10-11 20:01:30 -0700 (Thu, 11 Oct 2007) | 1 line Get rid of warnings on a bunch of platforms by using a proper prototype. ........ r58421 | neal.norwitz | 2007-10-11 20:01:54 -0700 (Thu, 11 Oct 2007) | 4 lines Get rid of compiler warning about retval being used (returned) without being initialized. (gcc warning and Coverity 202) ........ r58422 | neal.norwitz | 2007-10-11 20:03:23 -0700 (Thu, 11 Oct 2007) | 1 line Fix Coverity 168: Close the file before returning (exiting). ........ r58423 | neal.norwitz | 2007-10-11 20:04:18 -0700 (Thu, 11 Oct 2007) | 4 lines Fix Coverity 180: Don't overallocate. We don't need structs, but pointers. Also fix a memory leak. ........ r58424 | neal.norwitz | 2007-10-11 20:05:19 -0700 (Thu, 11 Oct 2007) | 5 lines Fix Coverity 185-186: If the passed in FILE is NULL, uninitialized memory would be accessed. Will backport. ........ r58425 | neal.norwitz | 2007-10-11 20:52:34 -0700 (Thu, 11 Oct 2007) | 1 line Get this module to compile with bsddb versions prior to 4.3 ........ r58430 | martin.v.loewis | 2007-10-12 01:56:52 -0700 (Fri, 12 Oct 2007) | 3 lines Bug #1216: Restore support for Visual Studio 2002. Will backport to 2.5. ........ r58433 | raymond.hettinger | 2007-10-12 10:53:11 -0700 (Fri, 12 Oct 2007) | 1 line Fix test of count.__repr__() to ignore the 'L' if the count is a long ........ r58434 | gregory.p.smith | 2007-10-12 11:44:06 -0700 (Fri, 12 Oct 2007) | 4 lines Fixes http://bugs.python.org/issue1233 - bsddb.dbshelve.DBShelf.append was useless due to inverted logic. Also adds a test case for RECNO dbs to test_dbshelve. ........ r58445 | georg.brandl | 2007-10-13 06:20:03 -0700 (Sat, 13 Oct 2007) | 2 lines Fix email example. ........ r58450 | gregory.p.smith | 2007-10-13 16:02:05 -0700 (Sat, 13 Oct 2007) | 2 lines Fix an uncollectable reference leak in bsddb.db.DBShelf.append ........ r58453 | neal.norwitz | 2007-10-13 17:18:40 -0700 (Sat, 13 Oct 2007) | 8 lines Let the O/S supply a port if none of the default ports can be used. This should make the tests more robust at the expense of allowing tests to be sloppier by not requiring them to cleanup after themselves. (It will legitamitely help when running two test suites simultaneously or if another process is already using one of the predefined ports.) Also simplifies (slightLy) the exception handling elsewhere. ........ r58459 | neal.norwitz | 2007-10-14 11:30:21 -0700 (Sun, 14 Oct 2007) | 2 lines Don't raise a string exception, they don't work anymore. ........ r58460 | neal.norwitz | 2007-10-14 11:40:37 -0700 (Sun, 14 Oct 2007) | 1 line Use unittest for assertions ........ r58468 | armin.rigo | 2007-10-15 00:48:35 -0700 (Mon, 15 Oct 2007) | 2 lines test_bigbits was not testing what it seemed to. ........ r58471 | guido.van.rossum | 2007-10-15 08:54:11 -0700 (Mon, 15 Oct 2007) | 3 lines Change a PyErr_Print() into a PyErr_Clear(), per discussion in issue 1031213. ........ r58500 | raymond.hettinger | 2007-10-16 12:18:30 -0700 (Tue, 16 Oct 2007) | 1 line Improve error messages ........ r58506 | raymond.hettinger | 2007-10-16 14:28:32 -0700 (Tue, 16 Oct 2007) | 1 line More docs, error messages, and tests ........ r58507 | andrew.kuchling | 2007-10-16 15:58:03 -0700 (Tue, 16 Oct 2007) | 1 line Add items ........ r58508 | brett.cannon | 2007-10-16 16:24:06 -0700 (Tue, 16 Oct 2007) | 3 lines Remove ``:const:`` notation on None in parameter list. Since the markup is not rendered for parameters it just showed up as ``:const:`None` `` in the output. ........ r58509 | brett.cannon | 2007-10-16 16:26:45 -0700 (Tue, 16 Oct 2007) | 3 lines Re-order some functions whose parameters differ between PyObject and const char * so that they are next to each other. ........ r58522 | armin.rigo | 2007-10-17 11:46:37 -0700 (Wed, 17 Oct 2007) | 5 lines Fix the overflow checking of list_repeat. Introduce overflow checking into list_inplace_repeat. Backport candidate, possibly. ........ r58530 | facundo.batista | 2007-10-17 20:16:03 -0700 (Wed, 17 Oct 2007) | 7 lines Issue #1580738. When HTTPConnection reads the whole stream with read(), it closes itself. When the stream is read in several calls to read(n), it should behave in the same way if HTTPConnection knows where the end of the stream is (through self.length). Added a test case for this behaviour. ........ r58531 | facundo.batista | 2007-10-17 20:44:48 -0700 (Wed, 17 Oct 2007) | 3 lines Issue 1289, just a typo. ........ r58532 | gregory.p.smith | 2007-10-18 00:56:54 -0700 (Thu, 18 Oct 2007) | 4 lines cleanup test_dbtables to use mkdtemp. cleanup dbtables to pass txn as a keyword argument whenever possible to avoid bugs and confusion. (dbtables.py line 447 self.db.get using txn as a non-keyword was an actual bug due to this) ........ r58533 | gregory.p.smith | 2007-10-18 01:34:20 -0700 (Thu, 18 Oct 2007) | 4 lines Fix a weird bug in dbtables: if it chose a random rowid string that contained NULL bytes it would cause the database all sorts of problems in the future leading to very strange random failures and corrupt dbtables.bsdTableDb dbs. ........ r58534 | gregory.p.smith | 2007-10-18 09:32:02 -0700 (Thu, 18 Oct 2007) | 3 lines A cleaner fix than the one committed last night. Generate random rowids that do not contain null bytes. ........ r58537 | gregory.p.smith | 2007-10-18 10:17:57 -0700 (Thu, 18 Oct 2007) | 2 lines mention bsddb fixes. ........ r58538 | raymond.hettinger | 2007-10-18 14:13:06 -0700 (Thu, 18 Oct 2007) | 1 line Remove useless warning ........ r58539 | gregory.p.smith | 2007-10-19 00:31:20 -0700 (Fri, 19 Oct 2007) | 2 lines squelch the warning that this test is supposed to trigger. ........ r58542 | georg.brandl | 2007-10-19 05:32:39 -0700 (Fri, 19 Oct 2007) | 2 lines Clarify wording for apply(). ........ r58544 | mark.summerfield | 2007-10-19 05:48:17 -0700 (Fri, 19 Oct 2007) | 3 lines Added a cross-ref to each other. ........ r58545 | georg.brandl | 2007-10-19 10:38:49 -0700 (Fri, 19 Oct 2007) | 2 lines #1284: "S" means "seen", not unread. ........ r58548 | thomas.heller | 2007-10-19 11:11:41 -0700 (Fri, 19 Oct 2007) | 4 lines Fix ctypes on 32-bit systems when Python is configured --with-system-ffi. See also https://bugs.launchpad.net/bugs/72505. Ported from release25-maint branch. ........ r58550 | facundo.batista | 2007-10-19 12:25:57 -0700 (Fri, 19 Oct 2007) | 8 lines The constructor from tuple was way too permissive: it allowed bad coefficient numbers, floats in the sign, and other details that generated directly the wrong number in the best case, or triggered misfunctionality in the alorithms. Test cases added for these issues. Thanks Mark Dickinson. ........ r58559 | georg.brandl | 2007-10-20 06:22:53 -0700 (Sat, 20 Oct 2007) | 2 lines Fix code being interpreted as a target. ........ r58561 | georg.brandl | 2007-10-20 06:36:24 -0700 (Sat, 20 Oct 2007) | 2 lines Document new "cmdoption" directive. ........ r58562 | georg.brandl | 2007-10-20 08:21:22 -0700 (Sat, 20 Oct 2007) | 2 lines Make a path more Unix-standardy. ........ r58564 | georg.brandl | 2007-10-20 10:51:39 -0700 (Sat, 20 Oct 2007) | 2 lines Document new directive "envvar". ........ r58567 | georg.brandl | 2007-10-20 11:08:14 -0700 (Sat, 20 Oct 2007) | 6 lines * Add new toplevel chapter, "Using Python." (how to install, configure and setup python on different platforms -- at least in theory.) * Move the Python on Mac docs in that chapter. * Add a new chapter about the command line invocation, by stargaming. ........ r58568 | georg.brandl | 2007-10-20 11:33:20 -0700 (Sat, 20 Oct 2007) | 2 lines Change title, for now. ........ r58569 | georg.brandl | 2007-10-20 11:39:25 -0700 (Sat, 20 Oct 2007) | 2 lines Add entry to ACKS. ........ r58570 | georg.brandl | 2007-10-20 12:05:45 -0700 (Sat, 20 Oct 2007) | 2 lines Clarify -E docs. ........ r58571 | georg.brandl | 2007-10-20 12:08:36 -0700 (Sat, 20 Oct 2007) | 2 lines Even more clarification. ........ r58572 | andrew.kuchling | 2007-10-20 12:25:37 -0700 (Sat, 20 Oct 2007) | 1 line Fix protocol name ........ r58573 | andrew.kuchling | 2007-10-20 12:35:18 -0700 (Sat, 20 Oct 2007) | 1 line Various items ........ r58574 | andrew.kuchling | 2007-10-20 12:39:35 -0700 (Sat, 20 Oct 2007) | 1 line Use correct header line ........ r58576 | armin.rigo | 2007-10-21 02:14:15 -0700 (Sun, 21 Oct 2007) | 3 lines Add a crasher for the long-standing issue with closing a file while another thread uses it. ........ r58577 | georg.brandl | 2007-10-21 03:01:56 -0700 (Sun, 21 Oct 2007) | 2 lines Remove duplicate crasher. ........ r58578 | georg.brandl | 2007-10-21 03:24:20 -0700 (Sun, 21 Oct 2007) | 2 lines Unify "byte code" to "bytecode". Also sprinkle :term: markup for it. ........ r58579 | georg.brandl | 2007-10-21 03:32:54 -0700 (Sun, 21 Oct 2007) | 2 lines Add markup to new function descriptions. ........ r58580 | georg.brandl | 2007-10-21 03:45:46 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term:s for descriptors. ........ r58581 | georg.brandl | 2007-10-21 03:46:24 -0700 (Sun, 21 Oct 2007) | 2 lines Unify "file-descriptor" to "file descriptor". ........ r58582 | georg.brandl | 2007-10-21 03:52:38 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term: for generators. ........ r58583 | georg.brandl | 2007-10-21 05:10:28 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term:s for iterator. ........ r58584 | georg.brandl | 2007-10-21 05:15:05 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term:s for "new-style class". ........ r58588 | neal.norwitz | 2007-10-21 21:47:54 -0700 (Sun, 21 Oct 2007) | 1 line Add Chris Monson so he can edit PEPs. ........ r58594 | guido.van.rossum | 2007-10-22 09:27:19 -0700 (Mon, 22 Oct 2007) | 4 lines Issue #1307, patch by Derek Shockey. When "MAIL" is received without args, an exception happens instead of sending a 501 syntax error response. ........ r58598 | travis.oliphant | 2007-10-22 19:40:56 -0700 (Mon, 22 Oct 2007) | 1 line Add phuang patch from Issue 708374 which adds offset parameter to mmap module. ........ r58601 | neal.norwitz | 2007-10-22 22:44:27 -0700 (Mon, 22 Oct 2007) | 2 lines Bug #1313, fix typo (wrong variable name) in example. ........ r58609 | georg.brandl | 2007-10-23 11:21:35 -0700 (Tue, 23 Oct 2007) | 2 lines Update Pygments version from externals. ........ r58618 | guido.van.rossum | 2007-10-23 12:25:41 -0700 (Tue, 23 Oct 2007) | 3 lines Issue 1307 by Derek Shockey, fox the same bug for RCPT. Neal: please backport! ........ r58620 | raymond.hettinger | 2007-10-23 13:37:41 -0700 (Tue, 23 Oct 2007) | 1 line Shorter name for namedtuple() ........ r58621 | andrew.kuchling | 2007-10-23 13:55:47 -0700 (Tue, 23 Oct 2007) | 1 line Update name ........ r58622 | raymond.hettinger | 2007-10-23 14:23:07 -0700 (Tue, 23 Oct 2007) | 1 line Fixup news entry ........ r58623 | raymond.hettinger | 2007-10-23 18:28:33 -0700 (Tue, 23 Oct 2007) | 1 line Optimize sum() for integer and float inputs. ........ r58624 | raymond.hettinger | 2007-10-23 19:05:51 -0700 (Tue, 23 Oct 2007) | 1 line Fixup error return and add support for intermixed ints and floats/ ........ r58628 | vinay.sajip | 2007-10-24 03:47:06 -0700 (Wed, 24 Oct 2007) | 1 line Bug #1321: Fixed logic error in TimedRotatingFileHandler.__init__() ........ r58641 | facundo.batista | 2007-10-24 12:11:08 -0700 (Wed, 24 Oct 2007) | 4 lines Issue 1290. CharacterData.__repr__ was constructing a string in response that keeped having a non-ascii character. ........ r58643 | thomas.heller | 2007-10-24 12:50:45 -0700 (Wed, 24 Oct 2007) | 1 line Added unittest for calling a function with paramflags (backport from py3k branch). ........ r58645 | matthias.klose | 2007-10-24 13:00:44 -0700 (Wed, 24 Oct 2007) | 2 lines - Build using system ffi library on arm*-linux*. ........ r58651 | georg.brandl | 2007-10-24 14:40:38 -0700 (Wed, 24 Oct 2007) | 2 lines Bug #1287: make os.environ.pop() work as expected. ........ r58652 | raymond.hettinger | 2007-10-24 19:26:58 -0700 (Wed, 24 Oct 2007) | 1 line Missing DECREFs ........ r58653 | matthias.klose | 2007-10-24 23:37:24 -0700 (Wed, 24 Oct 2007) | 2 lines - Build using system ffi library on arm*-linux*, pass --with-system-ffi to CONFIG_ARGS ........ r58655 | thomas.heller | 2007-10-25 12:47:32 -0700 (Thu, 25 Oct 2007) | 2 lines ffi_type_longdouble may be already #defined. See issue 1324. ........ r58656 | kurt.kaiser | 2007-10-25 15:43:45 -0700 (Thu, 25 Oct 2007) | 3 lines Correct an ancient bug in an unused path by removing that path: register() is now idempotent. ........ r58660 | kurt.kaiser | 2007-10-25 17:10:09 -0700 (Thu, 25 Oct 2007) | 4 lines 1. Add comments to provide top-level documentation. 2. Refactor to use more descriptive names. 3. Enhance tests in main(). ........ r58675 | georg.brandl | 2007-10-26 11:30:41 -0700 (Fri, 26 Oct 2007) | 2 lines Fix new pop() method on os.environ on ignorecase-platforms. ........ r58696 | neal.norwitz | 2007-10-27 15:32:21 -0700 (Sat, 27 Oct 2007) | 1 line Update URL for Pygments. 0.8.1 is no longer available ........ r58697 | hyeshik.chang | 2007-10-28 04:19:02 -0700 (Sun, 28 Oct 2007) | 3 lines - Add support for FreeBSD 8 which is recently forked from FreeBSD 7. - Regenerate IN module for most recent maintenance tree of FreeBSD 6 and 7. ........ r58698 | hyeshik.chang | 2007-10-28 05:38:09 -0700 (Sun, 28 Oct 2007) | 2 lines Enable platform-specific tweaks for FreeBSD 8 (exactly same to FreeBSD 7's yet) ........ r58700 | kurt.kaiser | 2007-10-28 12:03:59 -0700 (Sun, 28 Oct 2007) | 2 lines Add confirmation dialog before printing. Patch 1717170 Tal Einat. ........ r58706 | guido.van.rossum | 2007-10-29 13:52:45 -0700 (Mon, 29 Oct 2007) | 3 lines Patch 1353 by Jacob Winther. Add mp4 mapping to mimetypes.py. ........ r58709 | guido.van.rossum | 2007-10-29 15:15:05 -0700 (Mon, 29 Oct 2007) | 6 lines Backport fixes for the code that decodes octal escapes (and for PyString also hex escapes) -- this was reaching beyond the end of the input string buffer, even though it is not supposed to be \0-terminated. This has no visible effect but is clearly the correct thing to do. (In 3.0 it had a visible effect after removing ob_sstate from PyString.) ........ r58710 | kurt.kaiser | 2007-10-29 19:38:54 -0700 (Mon, 29 Oct 2007) | 7 lines check in Tal Einat's update to tabpage.py Patch 1612746 M configDialog.py M NEWS.txt AM tabbedpages.py ........ r58715 | georg.brandl | 2007-10-30 10:51:18 -0700 (Tue, 30 Oct 2007) | 2 lines Use correct markup. ........ r58716 | georg.brandl | 2007-10-30 10:57:12 -0700 (Tue, 30 Oct 2007) | 2 lines Make example about hiding None return values at the prompt clearer. ........ r58728 | neal.norwitz | 2007-10-30 23:33:20 -0700 (Tue, 30 Oct 2007) | 1 line Fix some compiler warnings for signed comparisons on Unix and Windows. ........ r58731 | martin.v.loewis | 2007-10-31 10:19:33 -0700 (Wed, 31 Oct 2007) | 2 lines Adding Christian Heimes. ........ r58737 | raymond.hettinger | 2007-10-31 14:57:58 -0700 (Wed, 31 Oct 2007) | 1 line Clarify the reasons why pickle is almost always better than marshal ........ r58739 | raymond.hettinger | 2007-10-31 15:15:49 -0700 (Wed, 31 Oct 2007) | 1 line Sets are marshalable. ........ Modified: python/branches/py3k/Lib/bsddb/dbshelve.py ============================================================================== --- python/branches/py3k/Lib/bsddb/dbshelve.py (original) +++ python/branches/py3k/Lib/bsddb/dbshelve.py Thu Nov 1 20:42:39 2007 @@ -30,11 +30,21 @@ #------------------------------------------------------------------------ import pickle -try: +import sys + +#At version 2.3 cPickle switched to using protocol instead of bin and +#DictMixin was added +if sys.version_info[:3] >= (2, 3, 0): + HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL + def _dumps(object, protocol): + return pickle.dumps(object, protocol=protocol) from UserDict import DictMixin -except ImportError: - # DictMixin is new in Python 2.3 +else: + HIGHEST_PROTOCOL = None + def _dumps(object, protocol): + return pickle.dumps(object, bin=protocol) class DictMixin: pass + from . import db _unspecified = object() @@ -87,7 +97,10 @@ def __init__(self, dbenv=None): self.db = db.DB(dbenv) self._closed = True - self.binary = 1 + if HIGHEST_PROTOCOL: + self.protocol = HIGHEST_PROTOCOL + else: + self.protocol = 1 def __del__(self): @@ -114,7 +127,7 @@ def __setitem__(self, key, value): - data = pickle.dumps(value, self.binary) + data = _dumps(value, self.protocol) self.db[key] = data @@ -169,7 +182,7 @@ # Other methods def __append(self, value, txn=None): - data = pickle.dumps(value, self.binary) + data = _dumps(value, self.protocol) return self.db.append(data, txn) def append(self, value, txn=None): @@ -200,19 +213,19 @@ return pickle.loads(data) def get_both(self, key, value, txn=None, flags=0): - data = pickle.dumps(value, self.binary) + data = _dumps(value, self.protocol) data = self.db.get(key, data, txn, flags) return pickle.loads(data) def cursor(self, txn=None, flags=0): c = DBShelfCursor(self.db.cursor(txn, flags)) - c.binary = self.binary + c.protocol = self.protocol return c def put(self, key, value, txn=None, flags=0): - data = pickle.dumps(value, self.binary) + data = _dumps(value, self.protocol) return self.db.put(key, data, txn, flags) @@ -252,11 +265,13 @@ #---------------------------------------------- def dup(self, flags=0): - return DBShelfCursor(self.dbc.dup(flags)) + c = DBShelfCursor(self.dbc.dup(flags)) + c.protocol = self.protocol + return c def put(self, key, value, flags=0): - data = pickle.dumps(value, self.binary) + data = _dumps(value, self.protocol) return self.dbc.put(key, data, flags) @@ -274,7 +289,7 @@ return self._extract(rec) def get_3(self, key, value, flags): - data = pickle.dumps(value, self.binary) + data = _dumps(value, self.protocol) rec = self.dbc.get(key, flags) return self._extract(rec) @@ -291,7 +306,7 @@ def get_both(self, key, value, flags=0): - data = pickle.dumps(value, self.binary) + data = _dumps(value, self.protocol) rec = self.dbc.get_both(key, flags) return self._extract(rec) 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 Thu Nov 1 20:42:39 2007 @@ -28,10 +28,10 @@ pass shutil.rmtree(self.homeDir) - def test01_badpointer(self): - dbs = dbshelve.open(self.filename) - dbs.close() - self.assertRaises(db.DBError, dbs.get, "foo") +## def test01_badpointer(self): +## dbs = dbshelve.open(self.filename) +## dbs.close() +## self.assertRaises(db.DBError, dbs.get, "foo") def test02_db_home(self): env = db.DBEnv() @@ -46,6 +46,26 @@ rp = repr(db) self.assertEquals(rp, "{}") + # http://sourceforge.net/tracker/index.php?func=detail&aid=1708868&group_id=13900&atid=313900 + # + # See the bug report for details. + # + # The problem was that make_key_dbt() was not allocating a copy of + # string keys but FREE_DBT() was always being told to free it when the + # database was opened with DB_THREAD. +## def test04_double_free_make_key_dbt(self): +## try: +## db1 = db.DB() +## db1.open(self.filename, None, db.DB_BTREE, +## db.DB_CREATE | db.DB_THREAD) + +## curs = db1.cursor() +## t = curs.get(b"/foo", db.DB_SET) +## # double free happened during exit from DBC_get +## finally: +## db1.close() +## os.unlink(self.filename) + #---------------------------------------------------------------------- Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Thu Nov 1 20:42:39 2007 @@ -1,7 +1,8 @@ -__all__ = ['deque', 'defaultdict', 'NamedTuple'] +__all__ = ['deque', 'defaultdict', 'namedtuple'] from _collections import deque, defaultdict from operator import itemgetter as _itemgetter +from keyword import iskeyword as _iskeyword import sys as _sys # For bootstrapping reasons, the collection ABCs are defined in _abcoll.py. @@ -10,11 +11,10 @@ import _abcoll __all__ += _abcoll.__all__ - -def NamedTuple(typename, s, verbose=False): +def namedtuple(typename, field_names, verbose=False): """Returns a new subclass of tuple with named fields. - >>> Point = NamedTuple('Point', 'x y') + >>> Point = namedtuple('Point', 'x y') >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords @@ -25,19 +25,36 @@ (11, 22) >>> p.x + p.y # fields also accessable by name 33 - >>> p # readable __repr__ with name=value style + >>> d = p.__asdict__() # convert to a dictionary + >>> d['x'] + 11 + >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p.__replace__('x', 100) # __replace__() is like str.replace() but targets a named field Point(x=100, y=22) - >>> d = dict(zip(p.__fields__, p)) # use __fields__ to make a dictionary - >>> d['x'] - 11 """ - field_names = tuple(s.replace(',', ' ').split()) # names separated by spaces and/or commas - if not ''.join((typename,) + field_names).replace('_', '').isalnum(): - raise ValueError('Type names and field names can only contain alphanumeric characters and underscores') + # Parse and validate the field names + if isinstance(field_names, str): + field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas + field_names = tuple(field_names) + for name in (typename,) + field_names: + if not name.replace('_', '').isalnum(): + raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name) + if _iskeyword(name): + raise ValueError('Type names and field names cannot be a keyword: %r' % name) + if name[0].isdigit(): + raise ValueError('Type names and field names cannot start with a number: %r' % name) + seen_names = set() + for name in field_names: + if name.startswith('__') and name.endswith('__'): + raise ValueError('Field names cannot start and end with double underscores: %r' % name) + if name in seen_names: + raise ValueError('Encountered duplicate field name: %r' % name) + seen_names.add(name) + + # Create and fill-in the class template argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes reprtxt = ', '.join('%s=%%r' % name for name in field_names) template = '''class %(typename)s(tuple): @@ -48,18 +65,31 @@ return tuple.__new__(cls, (%(argtxt)s)) def __repr__(self): return '%(typename)s(%(reprtxt)s)' %% self - def __replace__(self, field, value): + def __asdict__(self, dict=dict, zip=zip): + 'Return a new dict mapping field names to their values' + return dict(zip(%(field_names)r, self)) + def __replace__(self, field, value, dict=dict, zip=zip): 'Return a new %(typename)s object replacing one field with a new value' return %(typename)s(**dict(list(zip(%(field_names)r, self)) + [(field, value)])) \n''' % locals() for i, name in enumerate(field_names): template += ' %s = property(itemgetter(%d))\n' % (name, i) if verbose: print(template) - m = dict(itemgetter=_itemgetter) - exec(template, m) - result = m[typename] + + # Execute the template string in a temporary namespace + namespace = dict(itemgetter=_itemgetter) + try: + exec(template, namespace) + except SyntaxError as e: + raise SyntaxError(e.message + ':\n' + template) + result = namespace[typename] + + # For pickling to work, the __module__ variable needs to be set to the frame + # where the named tuple is created. Bypass this step in enviroments where + # sys._getframe is not defined (Jython for example). if hasattr(_sys, '_getframe'): result.__module__ = _sys._getframe(1).f_globals['__name__'] + return result @@ -69,10 +99,10 @@ if __name__ == '__main__': # verify that instances can be pickled from pickle import loads, dumps - Point = NamedTuple('Point', 'x, y', True) + Point = namedtuple('Point', 'x, y', True) p = Point(x=10, y=20) assert p == loads(dumps(p)) import doctest - TestResults = NamedTuple('TestResults', 'failed attempted') + TestResults = namedtuple('TestResults', 'failed attempted') print(TestResults(*doctest.testmod())) Modified: python/branches/py3k/Lib/ctypes/__init__.py ============================================================================== --- python/branches/py3k/Lib/ctypes/__init__.py (original) +++ python/branches/py3k/Lib/ctypes/__init__.py Thu Nov 1 20:42:39 2007 @@ -21,19 +21,12 @@ DEFAULT_MODE = RTLD_LOCAL if _os.name == "posix" and _sys.platform == "darwin": - import gestalt - - # gestalt.gestalt("sysv") returns the version number of the - # currently active system file as BCD. - # On OS X 10.4.6 -> 0x1046 - # On OS X 10.2.8 -> 0x1028 - # See also http://www.rgaros.nl/gestalt/ - # # On OS X 10.3, we use RTLD_GLOBAL as default mode # because RTLD_LOCAL does not work at least on some - # libraries. + # libraries. OS X 10.3 is Darwin 7, so we check for + # that. - if gestalt.gestalt("sysv") < 0x1040: + if int(_os.uname()[2].split('.')[0]) < 8: DEFAULT_MODE = RTLD_GLOBAL from _ctypes import FUNCFLAG_CDECL as _FUNCFLAG_CDECL, \ Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Thu Nov 1 20:42:39 2007 @@ -562,20 +562,46 @@ # tuple/list conversion (possibly from as_tuple()) if isinstance(value, (list,tuple)): if len(value) != 3: - raise ValueError('Invalid arguments') - if value[0] not in (0,1): - raise ValueError('Invalid sign') - for digit in value[1]: - if not isinstance(digit, int) or digit < 0: - raise ValueError("The second value in the tuple must be " - "composed of non negative integer elements.") + raise ValueError('Invalid tuple size in creation of Decimal ' + 'from list or tuple. The list or tuple ' + 'should have exactly three elements.') + # process sign. The isinstance test rejects floats + if not (isinstance(value[0], int) and value[0] in (0,1)): + raise ValueError("Invalid sign. The first value in the tuple " + "should be an integer; either 0 for a " + "positive number or 1 for a negative number.") self._sign = value[0] - self._int = tuple(value[1]) - if value[2] in ('F','n','N'): + if value[2] == 'F': + # infinity: value[1] is ignored + self._int = (0,) self._exp = value[2] self._is_special = True else: - self._exp = int(value[2]) + # process and validate the digits in value[1] + digits = [] + for digit in value[1]: + if isinstance(digit, int) and 0 <= digit <= 9: + # skip leading zeros + if digits or digit != 0: + digits.append(digit) + else: + raise ValueError("The second value in the tuple must " + "be composed of integers in the range " + "0 through 9.") + if value[2] in ('n', 'N'): + # NaN: digits form the diagnostic + self._int = tuple(digits) + self._exp = value[2] + self._is_special = True + elif isinstance(value[2], int): + # finite number: digits give the coefficient + self._int = tuple(digits or [0]) + self._exp = value[2] + self._is_special = False + else: + raise ValueError("The third value in the tuple must " + "be an integer, or one of the " + "strings 'F', 'n', 'N'.") return self if isinstance(value, float): @@ -679,14 +705,11 @@ return 0 def __bool__(self): - """return True if the number is non-zero. + """Return True if self is nonzero; otherwise return False. - False if self == 0 - True if self != 0 + NaNs and infinities are considered nonzero. """ - if self._is_special: - return True - return sum(self._int) != 0 + return self._is_special or self._int[0] != 0 def __cmp__(self, other): other = _convert_other(other) @@ -2252,15 +2275,18 @@ return ans def same_quantum(self, other): - """Test whether self and other have the same exponent. + """Return True if self and other have the same exponent; otherwise + return False. - same as self._exp == other._exp, except NaN == sNaN + If either operand is a special value, the following rules are used: + * return True if both operands are infinities + * return True if both operands are NaNs + * otherwise, return False. """ + other = _convert_other(other, raiseit=True) if self._is_special or other._is_special: - if self._isnan() or other._isnan(): - return self._isnan() and other._isnan() and True - if self._isinfinity() or other._isinfinity(): - return self._isinfinity() and other._isinfinity() and True + return (self.is_nan() and other.is_nan() or + self.is_infinite() and other.is_infinite()) return self._exp == other._exp def _rescale(self, exp, rounding): @@ -2743,84 +2769,60 @@ return ans def is_canonical(self): - """Returns 1 if self is canonical; otherwise returns 0.""" - return Dec_p1 + """Return True if self is canonical; otherwise return False. + + Currently, the encoding of a Decimal instance is always + canonical, so this method returns True for any Decimal. + """ + return True def is_finite(self): - """Returns 1 if self is finite, otherwise returns 0. + """Return True if self is finite; otherwise return False. - For it to be finite, it must be neither infinite nor a NaN. + A Decimal instance is considered finite if it is neither + infinite nor a NaN. """ - if self._is_special: - return Dec_0 - else: - return Dec_p1 + return not self._is_special def is_infinite(self): - """Returns 1 if self is an Infinite, otherwise returns 0.""" - if self._isinfinity(): - return Dec_p1 - else: - return Dec_0 + """Return True if self is infinite; otherwise return False.""" + return self._exp == 'F' def is_nan(self): - """Returns 1 if self is qNaN or sNaN, otherwise returns 0.""" - if self._isnan(): - return Dec_p1 - else: - return Dec_0 + """Return True if self is a qNaN or sNaN; otherwise return False.""" + return self._exp in ('n', 'N') def is_normal(self, context=None): - """Returns 1 if self is a normal number, otherwise returns 0.""" - if self._is_special: - return Dec_0 - if not self: - return Dec_0 + """Return True if self is a normal number; otherwise return False.""" + if self._is_special or not self: + return False if context is None: context = getcontext() - if context.Emin <= self.adjusted() <= context.Emax: - return Dec_p1 - else: - return Dec_0 + return context.Emin <= self.adjusted() <= context.Emax def is_qnan(self): - """Returns 1 if self is a quiet NaN, otherwise returns 0.""" - if self._isnan() == 1: - return Dec_p1 - else: - return Dec_0 + """Return True if self is a quiet NaN; otherwise return False.""" + return self._exp == 'n' def is_signed(self): - """Returns 1 if self is negative, otherwise returns 0.""" - return Decimal(self._sign) + """Return True if self is negative; otherwise return False.""" + return self._sign == 1 def is_snan(self): - """Returns 1 if self is a signaling NaN, otherwise returns 0.""" - if self._isnan() == 2: - return Dec_p1 - else: - return Dec_0 + """Return True if self is a signaling NaN; otherwise return False.""" + return self._exp == 'N' def is_subnormal(self, context=None): - """Returns 1 if self is subnormal, otherwise returns 0.""" - if self._is_special: - return Dec_0 - if not self: - return Dec_0 + """Return True if self is subnormal; otherwise return False.""" + if self._is_special or not self: + return False if context is None: context = getcontext() - - r = self._exp + len(self._int) - if r <= context.Emin: - return Dec_p1 - return Dec_0 + return self.adjusted() < context.Emin def is_zero(self): - """Returns 1 if self is a zero, otherwise returns 0.""" - if self: - return Dec_0 - else: - return Dec_p1 + """Return True if self is a zero; otherwise return False.""" + return not self._is_special and self._int[0] == 0 def _ln_exp_bound(self): """Compute a lower bound for the adjusted exponent of self.ln(). @@ -3883,138 +3885,145 @@ return a.fma(b, c, context=self) def is_canonical(self, a): - """Returns 1 if the operand is canonical; otherwise returns 0. + """Return True if the operand is canonical; otherwise return False. + + Currently, the encoding of a Decimal instance is always + canonical, so this method returns True for any Decimal. >>> ExtendedContext.is_canonical(Decimal('2.50')) - Decimal("1") + True """ - return Dec_p1 + return a.is_canonical() def is_finite(self, a): - """Returns 1 if the operand is finite, otherwise returns 0. + """Return True if the operand is finite; otherwise return False. - For it to be finite, it must be neither infinite nor a NaN. + A Decimal instance is considered finite if it is neither + infinite nor a NaN. >>> ExtendedContext.is_finite(Decimal('2.50')) - Decimal("1") + True >>> ExtendedContext.is_finite(Decimal('-0.3')) - Decimal("1") + True >>> ExtendedContext.is_finite(Decimal('0')) - Decimal("1") + True >>> ExtendedContext.is_finite(Decimal('Inf')) - Decimal("0") + False >>> ExtendedContext.is_finite(Decimal('NaN')) - Decimal("0") + False """ return a.is_finite() def is_infinite(self, a): - """Returns 1 if the operand is an Infinite, otherwise returns 0. + """Return True if the operand is infinite; otherwise return False. >>> ExtendedContext.is_infinite(Decimal('2.50')) - Decimal("0") + False >>> ExtendedContext.is_infinite(Decimal('-Inf')) - Decimal("1") + True >>> ExtendedContext.is_infinite(Decimal('NaN')) - Decimal("0") + False """ return a.is_infinite() def is_nan(self, a): - """Returns 1 if the operand is qNaN or sNaN, otherwise returns 0. + """Return True if the operand is a qNaN or sNaN; + otherwise return False. >>> ExtendedContext.is_nan(Decimal('2.50')) - Decimal("0") + False >>> ExtendedContext.is_nan(Decimal('NaN')) - Decimal("1") + True >>> ExtendedContext.is_nan(Decimal('-sNaN')) - Decimal("1") + True """ return a.is_nan() def is_normal(self, a): - """Returns 1 if the operand is a normal number, otherwise returns 0. + """Return True if the operand is a normal number; + otherwise return False. >>> c = ExtendedContext.copy() >>> c.Emin = -999 >>> c.Emax = 999 >>> c.is_normal(Decimal('2.50')) - Decimal("1") + True >>> c.is_normal(Decimal('0.1E-999')) - Decimal("0") + False >>> c.is_normal(Decimal('0.00')) - Decimal("0") + False >>> c.is_normal(Decimal('-Inf')) - Decimal("0") + False >>> c.is_normal(Decimal('NaN')) - Decimal("0") + False """ return a.is_normal(context=self) def is_qnan(self, a): - """Returns 1 if the operand is a quiet NaN, otherwise returns 0. + """Return True if the operand is a quiet NaN; otherwise return False. >>> ExtendedContext.is_qnan(Decimal('2.50')) - Decimal("0") + False >>> ExtendedContext.is_qnan(Decimal('NaN')) - Decimal("1") + True >>> ExtendedContext.is_qnan(Decimal('sNaN')) - Decimal("0") + False """ return a.is_qnan() def is_signed(self, a): - """Returns 1 if the operand is negative, otherwise returns 0. + """Return True if the operand is negative; otherwise return False. >>> ExtendedContext.is_signed(Decimal('2.50')) - Decimal("0") + False >>> ExtendedContext.is_signed(Decimal('-12')) - Decimal("1") + True >>> ExtendedContext.is_signed(Decimal('-0')) - Decimal("1") + True """ return a.is_signed() def is_snan(self, a): - """Returns 1 if the operand is a signaling NaN, otherwise returns 0. + """Return True if the operand is a signaling NaN; + otherwise return False. >>> ExtendedContext.is_snan(Decimal('2.50')) - Decimal("0") + False >>> ExtendedContext.is_snan(Decimal('NaN')) - Decimal("0") + False >>> ExtendedContext.is_snan(Decimal('sNaN')) - Decimal("1") + True """ return a.is_snan() def is_subnormal(self, a): - """Returns 1 if the operand is subnormal, otherwise returns 0. + """Return True if the operand is subnormal; otherwise return False. >>> c = ExtendedContext.copy() >>> c.Emin = -999 >>> c.Emax = 999 >>> c.is_subnormal(Decimal('2.50')) - Decimal("0") + False >>> c.is_subnormal(Decimal('0.1E-999')) - Decimal("1") + True >>> c.is_subnormal(Decimal('0.00')) - Decimal("0") + False >>> c.is_subnormal(Decimal('-Inf')) - Decimal("0") + False >>> c.is_subnormal(Decimal('NaN')) - Decimal("0") + False """ return a.is_subnormal(context=self) def is_zero(self, a): - """Returns 1 if the operand is a zero, otherwise returns 0. + """Return True if the operand is a zero; otherwise return False. >>> ExtendedContext.is_zero(Decimal('0')) - Decimal("1") + True >>> ExtendedContext.is_zero(Decimal('2.50')) - Decimal("0") + False >>> ExtendedContext.is_zero(Decimal('-0E+2')) - Decimal("1") + True """ return a.is_zero() @@ -4937,7 +4946,7 @@ c = _div_nearest(c, 10**-k) log_d = _ilog(c, M) # error < 5 + 22 = 27 - log_10 = _ilog(10*M, M) # error < 15 + log_10 = _log10_digits(p) # error < 1 log_d = _div_nearest(log_d*M, log_10) log_tenpower = f*M # exact else: @@ -4975,24 +4984,58 @@ # p <= 0: just approximate the whole thing by 0; error < 2.31 log_d = 0 - # compute approximation to 10**p*f*log(10), with error < 17 + # compute approximation to f*10**p*log(10), with error < 11. if f: - sign_f = [-1, 1][f > 0] - if p >= 0: - M = 10**p * abs(f) - else: - M = _div_nearest(abs(f), 10**-p) # M = 10**p*|f|, error <= 0.5 - - if M: - f_log_ten = sign_f*_ilog(10*M, M) # M*log(10), error <= 1.2 + 15 < 17 + extra = len(str(abs(f)))-1 + if p + extra >= 0: + # error in f * _log10_digits(p+extra) < |f| * 1 = |f| + # after division, error < |f|/10**extra + 0.5 < 10 + 0.5 < 11 + f_log_ten = _div_nearest(f*_log10_digits(p+extra), 10**extra) else: f_log_ten = 0 else: f_log_ten = 0 - # error in sum < 17+27 = 44; error after division < 0.44 + 0.5 < 1 + # error in sum < 11+27 = 38; error after division < 0.38 + 0.5 < 1 return _div_nearest(f_log_ten + log_d, 100) +class _Log10Memoize(object): + """Class to compute, store, and allow retrieval of, digits of the + constant log(10) = 2.302585.... This constant is needed by + Decimal.ln, Decimal.log10, Decimal.exp and Decimal.__pow__.""" + def __init__(self): + self.digits = "23025850929940456840179914546843642076011014886" + + def getdigits(self, p): + """Given an integer p >= 0, return floor(10**p)*log(10). + + For example, self.getdigits(3) returns 2302. + """ + # digits are stored as a string, for quick conversion to + # integer in the case that we've already computed enough + # digits; the stored digits should always be correct + # (truncated, not rounded to nearest). + if p < 0: + raise ValueError("p should be nonnegative") + + if p >= len(self.digits): + # compute p+3, p+6, p+9, ... digits; continue until at + # least one of the extra digits is nonzero + extra = 3 + while True: + # compute p+extra digits, correct to within 1ulp + M = 10**(p+extra+2) + digits = str(_div_nearest(_ilog(10*M, M), 100)) + if digits[-extra:] != '0'*extra: + break + extra += 3 + # keep all reliable digits so far; remove trailing zeros + # and next nonzero digit + self.digits = digits.rstrip('0')[:-1] + return int(self.digits[:p+1]) + +_log10_digits = _Log10Memoize().getdigits + def _iexp(x, M, L=8): """Given integers x and M, M > 0, such that x/M is small in absolute value, compute an integer approximation to M*exp(x/M). For 0 <= @@ -5034,7 +5077,7 @@ """Compute an approximation to exp(c*10**e), with p decimal places of precision. - Returns d, f such that: + Returns integers d, f such that: 10**(p-1) <= d <= 10**p, and (d-1)*10**f < exp(c*10**e) < (d+1)*10**f @@ -5047,19 +5090,18 @@ # we'll call iexp with M = 10**(p+2), giving p+3 digits of precision p += 2 - # compute log10 with extra precision = adjusted exponent of c*10**e + # compute log(10) with extra precision = adjusted exponent of c*10**e extra = max(0, e + len(str(c)) - 1) q = p + extra - log10 = _dlog(10, 0, q) # error <= 1 - # compute quotient c*10**e/(log10/10**q) = c*10**(e+q)/log10, + # compute quotient c*10**e/(log(10)) = c*10**(e+q)/(log(10)*10**q), # rounding down shift = e+q if shift >= 0: cshift = c*10**shift else: cshift = c//10**-shift - quot, rem = divmod(cshift, log10) + quot, rem = divmod(cshift, _log10_digits(q)) # reduce remainder back to original precision rem = _div_nearest(rem, 10**extra) Modified: python/branches/py3k/Lib/httplib.py ============================================================================== --- python/branches/py3k/Lib/httplib.py (original) +++ python/branches/py3k/Lib/httplib.py Thu Nov 1 20:42:39 2007 @@ -527,7 +527,7 @@ def read(self, amt=None): if self.fp is None: - return "" + return b"" if self.chunked: return self._read_chunked(amt) @@ -553,7 +553,8 @@ s = self.fp.read(amt) if self.length is not None: self.length -= len(s) - + if not self.length: + self.close() return s def _read_chunked(self, amt): @@ -595,7 +596,7 @@ ### note: we shouldn't have any trailers! while True: line = self.fp.readline() - if line == "\r\n": + if line == b"\r\n": break # we read everything; close the "file" Modified: python/branches/py3k/Lib/idlelib/AutoComplete.py ============================================================================== --- python/branches/py3k/Lib/idlelib/AutoComplete.py (original) +++ python/branches/py3k/Lib/idlelib/AutoComplete.py Thu Nov 1 20:42:39 2007 @@ -27,7 +27,7 @@ menudefs = [ ('edit', [ - ("Show completions", "<>"), + ("Show Completions", "<>"), ]) ] Modified: python/branches/py3k/Lib/idlelib/AutoCompleteWindow.py ============================================================================== --- python/branches/py3k/Lib/idlelib/AutoCompleteWindow.py (original) +++ python/branches/py3k/Lib/idlelib/AutoCompleteWindow.py Thu Nov 1 20:42:39 2007 @@ -283,20 +283,9 @@ self._selection_changed() return "break" - elif keysym == "Return" and not state: - # If start is a prefix of the selection, or there was an indication - # that the user used the completion window, put the selected - # completion in the text, and close the list. - # Otherwise, close the window and let the event through. - cursel = int(self.listbox.curselection()[0]) - if self.completions[cursel][:len(self.start)] == self.start or \ - self.userwantswindow: - self._change_start(self.completions[cursel]) - self.hide_window() - return "break" - else: - self.hide_window() - return + elif keysym == "Return": + self.hide_window() + return elif (self.mode == COMPLETE_ATTRIBUTES and keysym in ("period", "space", "parenleft", "parenright", "bracketleft", Modified: python/branches/py3k/Lib/idlelib/EditorWindow.py ============================================================================== --- python/branches/py3k/Lib/idlelib/EditorWindow.py (original) +++ python/branches/py3k/Lib/idlelib/EditorWindow.py Thu Nov 1 20:42:39 2007 @@ -386,7 +386,7 @@ def help_dialog(self, event=None): fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt') - textView.TextViewer(self.top,'Help',fn) + textView.view_file(self.top,'Help',fn) def python_docs(self, event=None): if sys.platform[:3] == 'win': @@ -408,6 +408,7 @@ def paste(self,event): self.text.event_generate("<>") + self.text.see("insert") return "break" def select_all(self, event=None): @@ -549,7 +550,8 @@ def close_hook(self): if self.flist: - self.flist.close_edit(self) + self.flist.unregister_maybe_terminate(self) + self.flist = None def set_close_hook(self, close_hook): self.close_hook = close_hook @@ -828,22 +830,21 @@ if self.io.filename: self.update_recent_files_list(new_file=self.io.filename) WindowList.unregister_callback(self.postwindowsmenu) - if self.close_hook: - self.close_hook() - self.flist = None - colorizing = 0 self.unload_extensions() - self.io.close(); self.io = None - self.undo = None # XXX + self.io.close() + self.io = None + self.undo = None if self.color: - colorizing = self.color.colorizing - doh = colorizing and self.top - self.color.close(doh) # Cancel colorization + self.color.close(False) + self.color = None self.text = None self.tkinter_vars = None - self.per.close(); self.per = None - if not colorizing: - self.top.destroy() + self.per.close() + self.per = None + self.top.destroy() + if self.close_hook: + # unless override: unregister from flist, terminate if last window + self.close_hook() def load_extensions(self): self.extensions = {} @@ -1501,6 +1502,7 @@ filename = None edit = EditorWindow(root=root, filename=filename) edit.set_close_hook(root.quit) + edit.text.bind("<>", edit.close_event) root.mainloop() root.destroy() Modified: python/branches/py3k/Lib/idlelib/FileList.py ============================================================================== --- python/branches/py3k/Lib/idlelib/FileList.py (original) +++ python/branches/py3k/Lib/idlelib/FileList.py Thu Nov 1 20:42:39 2007 @@ -55,7 +55,7 @@ break return "break" - def close_edit(self, edit): + def unregister_maybe_terminate(self, edit): try: key = self.inversedict[edit] except KeyError: Modified: python/branches/py3k/Lib/idlelib/IOBinding.py ============================================================================== --- python/branches/py3k/Lib/idlelib/IOBinding.py (original) +++ python/branches/py3k/Lib/idlelib/IOBinding.py Thu Nov 1 20:42:39 2007 @@ -485,13 +485,23 @@ self.text.insert("end-1c", "\n") def print_window(self, event): + m = tkMessageBox.Message( + title="Print", + message="Print to Default Printer", + icon=tkMessageBox.QUESTION, + type=tkMessageBox.OKCANCEL, + default=tkMessageBox.OK, + master=self.text) + reply = m.show() + if reply != tkMessageBox.OK: + self.text.focus_set() + return "break" tempfilename = None saved = self.get_saved() if saved: filename = self.filename # shell undo is reset after every prompt, looks saved, probably isn't if not saved or filename is None: - # XXX KBK 08Jun03 Wouldn't it be better to ask the user to save? (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_') filename = tempfilename os.close(tfd) Modified: python/branches/py3k/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/py3k/Lib/idlelib/NEWS.txt (original) +++ python/branches/py3k/Lib/idlelib/NEWS.txt Thu Nov 1 20:42:39 2007 @@ -30,6 +30,24 @@ *Release date: XX-XXX-200X* UNRELEASED, but merged into 3.0a1 +- tabpage.py updated: tabbedPages.py now supports multiple dynamic rows + of tabs. Patch 1612746 Tal Einat. + +- Add confirmation dialog before printing. Patch 1717170 Tal Einat. + +- Show paste position if > 80 col. Patch 1659326 Tal Einat. + +- Update cursor color without restarting. Patch 1725576 Tal Einat. + +- Allow keyboard interrupt only when user code is executing in subprocess. + Patch 1225 Tal Einat (reworked from IDLE-Spoon). + +- configDialog cleanup. Patch 1730217 Tal Einat. + +- textView cleanup. Patch 1718043 Tal Einat. + +- Clean up EditorWindow close. + - 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 @@ -51,6 +69,8 @@ - Bug #813342: Start the IDLE subprocess with -Qnew if the parent is started with that option. +- Honor the "Cancel" action in the save dialog (Debian bug #299092) + - Some syntax errors were being caught by tokenize during the tabnanny check, resulting in obscure error messages. Do the syntax check first. Bug 1562716, 1562719 Modified: python/branches/py3k/Lib/idlelib/PyShell.py ============================================================================== --- python/branches/py3k/Lib/idlelib/PyShell.py (original) +++ python/branches/py3k/Lib/idlelib/PyShell.py Thu Nov 1 20:42:39 2007 @@ -296,9 +296,6 @@ "stdout": idleConf.GetHighlight(theme, "stdout"), "stderr": idleConf.GetHighlight(theme, "stderr"), "console": idleConf.GetHighlight(theme, "console"), - ### KBK 10Aug07: None tag doesn't seem to serve a purpose and - ### breaks in py3k. Comment out for now. - #None: idleConf.GetHighlight(theme, "normal"), }) class ModifiedUndoDelegator(UndoDelegator): Modified: python/branches/py3k/Lib/idlelib/WidgetRedirector.py ============================================================================== --- python/branches/py3k/Lib/idlelib/WidgetRedirector.py (original) +++ python/branches/py3k/Lib/idlelib/WidgetRedirector.py Thu Nov 1 20:42:39 2007 @@ -1,17 +1,38 @@ from Tkinter import * - class WidgetRedirector: - """Support for redirecting arbitrary widget subcommands.""" + """Support for redirecting arbitrary widget subcommands. + + Some Tk operations don't normally pass through Tkinter. For example, if a + character is inserted into a Text widget by pressing a key, a default Tk + binding to the widget's 'insert' operation is activated, and the Tk library + processes the insert without calling back into Tkinter. + + Although a binding to could be made via Tkinter, what we really want + to do is to hook the Tk 'insert' operation itself. + + When a widget is instantiated, a Tcl command is created whose name is the + same as the pathname widget._w. This command is used to invoke the various + widget operations, e.g. insert (for a Text widget). We are going to hook + this command and provide a facility ('register') to intercept the widget + operation. + + In IDLE, the function being registered provides access to the top of a + Percolator chain. At the bottom of the chain is a call to the original + Tk widget operation. + """ def __init__(self, widget): - self.dict = {} - self.widget = widget - self.tk = tk = widget.tk - w = widget._w + self._operations = {} + self.widget = widget # widget instance + self.tk = tk = widget.tk # widget's root + w = widget._w # widget's (full) Tk pathname self.orig = w + "_orig" + # Rename the Tcl command within Tcl: tk.call("rename", w, self.orig) + # Create a new Tcl command whose name is the widget's pathname, and + # whose action is to dispatch on the operation passed to the widget: tk.createcommand(w, self.dispatch) def __repr__(self): @@ -19,74 +40,87 @@ self.widget._w) def close(self): - for name in list(self.dict.keys()): - self.unregister(name) + for operation in list(self._operations): + self.unregister(operation) widget = self.widget; del self.widget orig = self.orig; del self.orig tk = widget.tk w = widget._w tk.deletecommand(w) + # restore the original widget Tcl command: tk.call("rename", orig, w) - def register(self, name, function): - if name in self.dict: - previous = dict[name] - else: - previous = OriginalCommand(self, name) - self.dict[name] = function - setattr(self.widget, name, function) - return previous - - def unregister(self, name): - if name in self.dict: - function = self.dict[name] - del self.dict[name] - if hasattr(self.widget, name): - delattr(self.widget, name) + def register(self, operation, function): + self._operations[operation] = function + setattr(self.widget, operation, function) + return OriginalCommand(self, operation) + + def unregister(self, operation): + if operation in self._operations: + function = self._operations[operation] + del self._operations[operation] + if hasattr(self.widget, operation): + delattr(self.widget, operation) return function else: return None - def dispatch(self, cmd, *args): - m = self.dict.get(cmd) + def dispatch(self, operation, *args): + '''Callback from Tcl which runs when the widget is referenced. + + If an operation has been registered in self._operations, apply the + associated function to the args passed into Tcl. Otherwise, pass the + operation through to Tk via the original Tcl function. + + Note that if a registered function is called, the operation is not + passed through to Tk. Apply the function returned by self.register() + to *args to accomplish that. For an example, see ColorDelegator.py. + + ''' + m = self._operations.get(operation) try: if m: return m(*args) else: - return self.tk.call((self.orig, cmd) + args) + return self.tk.call((self.orig, operation) + args) except TclError: return "" class OriginalCommand: - def __init__(self, redir, name): + def __init__(self, redir, operation): self.redir = redir - self.name = name + self.operation = operation self.tk = redir.tk self.orig = redir.orig self.tk_call = self.tk.call - self.orig_and_name = (self.orig, self.name) + self.orig_and_operation = (self.orig, self.operation) def __repr__(self): - return "OriginalCommand(%r, %r)" % (self.redir, self.name) + return "OriginalCommand(%r, %r)" % (self.redir, self.operation) def __call__(self, *args): - return self.tk_call(self.orig_and_name + args) + return self.tk_call(self.orig_and_operation + args) def main(): root = Tk() + root.wm_protocol("WM_DELETE_WINDOW", root.quit) text = Text() text.pack() text.focus_set() redir = WidgetRedirector(text) - global orig_insert + global previous_tcl_fcn def my_insert(*args): print("insert", args) - orig_insert(*args) - orig_insert = redir.register("insert", my_insert) + previous_tcl_fcn(*args) + previous_tcl_fcn = redir.register("insert", my_insert) + root.mainloop() + redir.unregister("insert") # runs after first 'close window' + redir.close() root.mainloop() + root.destroy() if __name__ == "__main__": main() Modified: python/branches/py3k/Lib/idlelib/aboutDialog.py ============================================================================== --- python/branches/py3k/Lib/idlelib/aboutDialog.py (original) +++ python/branches/py3k/Lib/idlelib/aboutDialog.py Thu Nov 1 20:42:39 2007 @@ -111,45 +111,31 @@ idle_credits_b.pack(side=LEFT, padx=10, pady=10) def ShowLicense(self): - self.display_printer_text(license, 'About - License') + self.display_printer_text('About - License', license) def ShowCopyright(self): - self.display_printer_text(copyright, 'About - Copyright') + self.display_printer_text('About - Copyright', copyright) def ShowPythonCredits(self): - self.display_printer_text(credits, 'About - Python Credits') + self.display_printer_text('About - Python Credits', credits) def ShowIDLECredits(self): - self.ViewFile('About - Credits','CREDITS.txt') + self.display_file_text('About - Credits', 'CREDITS.txt', 'iso-8859-1') def ShowIDLEAbout(self): - self.ViewFile('About - Readme', 'README.txt') + self.display_file_text('About - Readme', 'README.txt') def ShowIDLENEWS(self): - self.ViewFile('About - NEWS', 'NEWS.txt') + self.display_file_text('About - NEWS', 'NEWS.txt') - def display_printer_text(self, printer, title): + def display_printer_text(self, title, printer): printer._Printer__setup() - data = '\n'.join(printer._Printer__lines) - textView.TextViewer(self, title, None, data) + text = '\n'.join(printer._Printer__lines) + textView.view_text(self, title, text) - def ViewFile(self, viewTitle, viewFile, encoding=None): - fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), viewFile) - if encoding: - import codecs - try: - textFile = codecs.open(fn, 'r') - except IOError: - import tkMessageBox - tkMessageBox.showerror(title='File Load Error', - message='Unable to load file %r .' % (fn,), - parent=self) - return - else: - data = textFile.read() - else: - data = None - textView.TextViewer(self, viewTitle, fn, data=data) + def display_file_text(self, title, filename, encoding=None): + fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename) + textView.view_file(self, title, fn, encoding) def Ok(self, event=None): self.destroy() Modified: python/branches/py3k/Lib/idlelib/configDialog.py ============================================================================== --- python/branches/py3k/Lib/idlelib/configDialog.py (original) +++ python/branches/py3k/Lib/idlelib/configDialog.py Thu Nov 1 20:42:39 2007 @@ -15,7 +15,7 @@ from idlelib.configHandler import idleConf from idlelib.dynOptionMenuWidget import DynOptionMenu -from idlelib.tabpage import TabPageSet +from idlelib.tabbedpages import TabbedPageSet from idlelib.keybindingDialog import GetKeysDialog from idlelib.configSectionNameDialog import GetCfgSectionNameDialog from idlelib.configHelpSourceEdit import GetHelpSourceDialog @@ -24,6 +24,8 @@ def __init__(self,parent,title): Toplevel.__init__(self, parent) + self.wm_withdraw() + self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+20, parent.winfo_rooty()+30)) @@ -58,31 +60,37 @@ #self.bind('',self.Help) #context help self.LoadConfigs() self.AttachVarCallbacks() #avoid callbacks during LoadConfigs + + self.wm_deiconify() self.wait_window() def CreateWidgets(self): - self.tabPages = TabPageSet(self, - pageNames=['Fonts/Tabs','Highlighting','Keys','General']) - self.tabPages.ChangePage()#activates default (first) page - frameActionButtons = Frame(self) + self.tabPages = TabbedPageSet(self, + page_names=['Fonts/Tabs','Highlighting','Keys','General']) + frameActionButtons = Frame(self,pady=2) #action buttons self.buttonHelp = Button(frameActionButtons,text='Help', - command=self.Help,takefocus=FALSE) + command=self.Help,takefocus=FALSE, + padx=6,pady=3) self.buttonOk = Button(frameActionButtons,text='Ok', - command=self.Ok,takefocus=FALSE) + command=self.Ok,takefocus=FALSE, + padx=6,pady=3) self.buttonApply = Button(frameActionButtons,text='Apply', - command=self.Apply,takefocus=FALSE) + command=self.Apply,takefocus=FALSE, + padx=6,pady=3) self.buttonCancel = Button(frameActionButtons,text='Cancel', - command=self.Cancel,takefocus=FALSE) + command=self.Cancel,takefocus=FALSE, + padx=6,pady=3) self.CreatePageFontTab() self.CreatePageHighlight() self.CreatePageKeys() self.CreatePageGeneral() - self.buttonHelp.pack(side=RIGHT,padx=5,pady=5) - self.buttonOk.pack(side=LEFT,padx=5,pady=5) - self.buttonApply.pack(side=LEFT,padx=5,pady=5) - self.buttonCancel.pack(side=LEFT,padx=5,pady=5) + self.buttonHelp.pack(side=RIGHT,padx=5) + self.buttonOk.pack(side=LEFT,padx=5) + self.buttonApply.pack(side=LEFT,padx=5) + self.buttonCancel.pack(side=LEFT,padx=5) frameActionButtons.pack(side=BOTTOM) + Frame(self, border=0).pack(side=BOTTOM,pady=2) self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH) def CreatePageFontTab(self): @@ -94,16 +102,17 @@ self.editFont=tkFont.Font(self,('courier',10,'normal')) ##widget creation #body frame - frame=self.tabPages.pages['Fonts/Tabs']['page'] + frame=self.tabPages.pages['Fonts/Tabs'].frame #body section frames - frameFont=Frame(frame,borderwidth=2,relief=GROOVE) - frameIndent=Frame(frame,borderwidth=2,relief=GROOVE) + frameFont=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Base Editor Font ') + frameIndent=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Indentation Width ') #frameFont - labelFontTitle=Label(frameFont,text='Set Base Editor Font') frameFontName=Frame(frameFont) frameFontParam=Frame(frameFont) labelFontNameTitle=Label(frameFontName,justify=LEFT, - text='Font :') + text='Font Face :') self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE, exportselection=FALSE) self.listFontName.bind('',self.OnListFontButtonRelease) @@ -124,14 +133,13 @@ labelSpaceNumTitle=Label(frameIndentSize, justify=LEFT, text='Python Standard: 4 Spaces!') self.scaleSpaceNum=Scale(frameIndentSize, variable=self.spaceNum, - label='Indentation Width', orient='horizontal', + orient='horizontal', tickinterval=2, from_=2, to=16) #widget packing #body - frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH) - frameIndent.pack(side=LEFT,padx=5,pady=10,fill=Y) + frameFont.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) + frameIndent.pack(side=LEFT,padx=5,pady=5,fill=Y) #frameFont - labelFontTitle.pack(side=TOP,anchor=W,padx=5,pady=5) frameFontName.pack(side=TOP,padx=5,pady=5,fill=X) frameFontParam.pack(side=TOP,padx=5,pady=5,fill=X) labelFontNameTitle.pack(side=TOP,anchor=W) @@ -143,7 +151,7 @@ frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) self.labelFontSample.pack(expand=TRUE,fill=BOTH) #frameIndent - frameIndentSize.pack(side=TOP,padx=5,pady=5,fill=BOTH) + frameIndentSize.pack(side=TOP,fill=X) labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5) self.scaleSpaceNum.pack(side=TOP,padx=5,fill=X) return frame @@ -158,10 +166,12 @@ self.highlightTarget=StringVar(self) ##widget creation #body frame - frame=self.tabPages.pages['Highlighting']['page'] + frame=self.tabPages.pages['Highlighting'].frame #body section frames - frameCustom=Frame(frame,borderwidth=2,relief=GROOVE) - frameTheme=Frame(frame,borderwidth=2,relief=GROOVE) + frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Custom Highlighting ') + frameTheme=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Highlighting Theme ') #frameCustom self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1, font=('courier',12,''),cursor='hand2',width=21,height=10, @@ -189,7 +199,6 @@ text.config(state=DISABLED) self.frameColourSet=Frame(frameCustom,relief=SOLID,borderwidth=1) frameFgBg=Frame(frameCustom) - labelCustomTitle=Label(frameCustom,text='Set Custom Highlighting') buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :', command=self.GetColour,highlightthickness=0) self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet, @@ -202,7 +211,6 @@ buttonSaveCustomTheme=Button(frameCustom, text='Save as New Custom Theme',command=self.SaveAsNewTheme) #frameTheme - labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme') labelTypeTitle=Label(frameTheme,text='Select : ') self.radioThemeBuiltin=Radiobutton(frameTheme,variable=self.themeIsBuiltin, value=1,command=self.SetThemeType,text='a Built-in Theme') @@ -216,10 +224,9 @@ command=self.DeleteCustomTheme) ##widget packing #body - frameCustom.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH) - frameTheme.pack(side=LEFT,padx=5,pady=10,fill=Y) + frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) + frameTheme.pack(side=LEFT,padx=5,pady=5,fill=Y) #frameCustom - labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5) self.frameColourSet.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=X) frameFgBg.pack(side=TOP,padx=5,pady=0) self.textHighlightSample.pack(side=TOP,padx=5,pady=5,expand=TRUE, @@ -230,7 +237,6 @@ self.radioBg.pack(side=RIGHT,anchor=W) buttonSaveCustomTheme.pack(side=BOTTOM,fill=X,padx=5,pady=5) #frameTheme - labelThemeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) self.radioThemeBuiltin.pack(side=TOP,anchor=W,padx=5) self.radioThemeCustom.pack(side=TOP,anchor=W,padx=5,pady=2) @@ -248,13 +254,14 @@ self.keyBinding=StringVar(self) ##widget creation #body frame - frame=self.tabPages.pages['Keys']['page'] + frame=self.tabPages.pages['Keys'].frame #body section frames - frameCustom=Frame(frame,borderwidth=2,relief=GROOVE) - frameKeySets=Frame(frame,borderwidth=2,relief=GROOVE) + frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Custom Key Bindings ') + frameKeySets=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Key Set ') #frameCustom frameTarget=Frame(frameCustom) - labelCustomTitle=Label(frameCustom,text='Set Custom Key Bindings') labelTargetTitle=Label(frameTarget,text='Action - Key(s)') scrollTargetY=Scrollbar(frameTarget) scrollTargetX=Scrollbar(frameTarget,orient=HORIZONTAL) @@ -270,7 +277,6 @@ buttonSaveCustomKeys=Button(frameCustom, text='Save as New Custom Key Set',command=self.SaveAsNewKeySet) #frameKeySets - labelKeysTitle=Label(frameKeySets,text='Select a Key Set') labelTypeTitle=Label(frameKeySets,text='Select : ') self.radioKeysBuiltin=Radiobutton(frameKeySets,variable=self.keysAreBuiltin, value=1,command=self.SetKeysType,text='a Built-in Key Set') @@ -287,7 +293,6 @@ frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) frameKeySets.pack(side=LEFT,padx=5,pady=5,fill=Y) #frameCustom - labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5) buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5) self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5) frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) @@ -299,7 +304,6 @@ scrollTargetY.grid(row=1,column=1,sticky=NS) scrollTargetX.grid(row=2,column=0,sticky=EW) #frameKeySets - labelKeysTitle.pack(side=TOP,anchor=W,padx=5,pady=5) labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) self.radioKeysBuiltin.pack(side=TOP,anchor=W,padx=5) self.radioKeysCustom.pack(side=TOP,anchor=W,padx=5,pady=2) @@ -320,23 +324,24 @@ self.helpBrowser=StringVar(self) #widget creation #body - frame=self.tabPages.pages['General']['page'] + frame=self.tabPages.pages['General'].frame #body section frames - frameRun=Frame(frame,borderwidth=2,relief=GROOVE) - frameSave=Frame(frame,borderwidth=2,relief=GROOVE) + frameRun=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Startup Preferences ') + frameSave=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Autosave Preferences ') frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE) frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE) frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE) - frameHelp=Frame(frame,borderwidth=2,relief=GROOVE) + frameHelp=LabelFrame(frame,borderwidth=2,relief=GROOVE, + text=' Additional Help Sources ') #frameRun - labelRunTitle=Label(frameRun,text='Startup Preferences') labelRunChoiceTitle=Label(frameRun,text='At Startup') radioStartupEdit=Radiobutton(frameRun,variable=self.startupEdit, value=1,command=self.SetKeysType,text="Open Edit Window") radioStartupShell=Radiobutton(frameRun,variable=self.startupEdit, value=0,command=self.SetKeysType,text='Open Shell Window') #frameSave - labelSaveTitle=Label(frameSave,text='Autosave Preference') labelRunSaveTitle=Label(frameSave,text='At Start of Run (F5) ') radioSaveAsk=Radiobutton(frameSave,variable=self.autoSave, value=0,command=self.SetKeysType,text="Prompt to Save") @@ -367,7 +372,6 @@ #frameHelp frameHelpList=Frame(frameHelp) frameHelpListButtons=Frame(frameHelpList) - labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:') scrollHelpList=Scrollbar(frameHelpList) self.listHelp=Listbox(frameHelpList,height=5,takefocus=FALSE, exportselection=FALSE) @@ -389,12 +393,10 @@ frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X) frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) #frameRun - labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5) labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5) radioStartupShell.pack(side=RIGHT,anchor=W,padx=5,pady=5) radioStartupEdit.pack(side=RIGHT,anchor=W,padx=5,pady=5) #frameSave - labelSaveTitle.pack(side=TOP,anchor=W,padx=5,pady=5) labelRunSaveTitle.pack(side=LEFT,anchor=W,padx=5,pady=5) radioSaveAuto.pack(side=RIGHT,anchor=W,padx=5,pady=5) radioSaveAsk.pack(side=RIGHT,anchor=W,padx=5,pady=5) @@ -415,7 +417,6 @@ #frameHelp frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y) frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) - labelHelpListTitle.pack(side=TOP,anchor=W) scrollHelpList.pack(side=RIGHT,anchor=W,fill=Y) self.listHelp.pack(side=LEFT,anchor=E,expand=TRUE,fill=BOTH) self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5) @@ -1116,12 +1117,15 @@ 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/idlelib/run.py ============================================================================== --- python/branches/py3k/Lib/idlelib/run.py (original) +++ python/branches/py3k/Lib/idlelib/run.py Thu Nov 1 20:42:39 2007 @@ -38,10 +38,11 @@ # Thread shared globals: Establish a queue between a subthread (which handles # the socket) and the main thread (which runs user code), plus global -# completion and exit flags: +# completion, exit and interruptable (the main thread) flags: exit_now = False quitting = False +interruptable = False def main(del_exitfunc=False): """Start the Python execution server in a subprocess @@ -278,9 +279,14 @@ self.autocomplete = AutoComplete.AutoComplete() def runcode(self, code): + global interruptable try: self.usr_exc_info = None - exec(code, self.locals) + interruptable = True + try: + exec(code, self.locals) + finally: + interruptable = False except: self.usr_exc_info = sys.exc_info() if quitting: @@ -294,7 +300,8 @@ flush_stdout() def interrupt_the_server(self): - thread.interrupt_main() + if interruptable: + thread.interrupt_main() def start_the_debugger(self, gui_adap_oid): return RemoteDebugger.start_debugger(self.rpchandler, gui_adap_oid) Modified: python/branches/py3k/Lib/idlelib/textView.py ============================================================================== --- python/branches/py3k/Lib/idlelib/textView.py (original) +++ python/branches/py3k/Lib/idlelib/textView.py Thu Nov 1 20:42:39 2007 @@ -6,13 +6,12 @@ import tkMessageBox class TextViewer(Toplevel): + """A simple text viewer dialog for IDLE + """ - simple text viewer dialog for idle - """ - def __init__(self, parent, title, fileName, data=None): - """If data exists, load it into viewer, otherwise try to load file. + def __init__(self, parent, title, text): + """Show the given text in a scrollable window with a 'close' button - fileName - string, should be an absoulute filename """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) @@ -33,23 +32,10 @@ #key bindings for this dialog self.bind('',self.Ok) #dismiss dialog self.bind('',self.Ok) #dismiss dialog - if data: - self.textView.insert(0.0, data) - else: - self.LoadTextFile(fileName) + self.textView.insert(0.0, text) self.textView.config(state=DISABLED) self.wait_window() - def LoadTextFile(self, fileName): - textFile = None - try: - textFile = open(fileName, 'r') - except IOError: - tkMessageBox.showerror(title='File Load Error', - message='Unable to load file %r .' % (fileName,)) - else: - self.textView.insert(0.0,textFile.read()) - def CreateWidgets(self): frameText = Frame(self, relief=SUNKEN, height=700) frameButtons = Frame(self) @@ -70,9 +56,38 @@ def Ok(self, event=None): self.destroy() + +def view_text(parent, title, text): + TextViewer(parent, title, text) + +def view_file(parent, title, filename, encoding=None): + try: + if encoding: + import codecs + textFile = codecs.open(filename, 'r') + else: + textFile = open(filename, 'r') + except IOError: + import tkMessageBox + tkMessageBox.showerror(title='File Load Error', + message='Unable to load file %r .' % filename, + parent=parent) + else: + return view_text(parent, title, textFile.read()) + + if __name__ == '__main__': #test the dialog root=Tk() - Button(root,text='View', - command=lambda:TextViewer(root,'Text','./textView.py')).pack() + root.title('textView test') + filename = './textView.py' + text = file(filename, 'r').read() + btn1 = Button(root, text='view_text', + command=lambda:view_text(root, 'view_text', text)) + btn1.pack(side=LEFT) + btn2 = Button(root, text='view_file', + command=lambda:view_file(root, 'view_file', filename)) + btn2.pack(side=LEFT) + close = Button(root, text='Close', command=root.destroy) + close.pack(side=RIGHT) root.mainloop() Modified: python/branches/py3k/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k/Lib/logging/__init__.py (original) +++ python/branches/py3k/Lib/logging/__init__.py Thu Nov 1 20:42:39 2007 @@ -41,8 +41,8 @@ __author__ = "Vinay Sajip " __status__ = "production" -__version__ = "0.5.0.2" -__date__ = "16 February 2007" +__version__ = "0.5.0.3" +__date__ = "26 September 2007" #--------------------------------------------------------------------------- # Miscellaneous module data @@ -236,7 +236,7 @@ # 'Value is %d' instead of 'Value is 0'. # For the use case of passing a dictionary, this should not be a # problem. - if args and (len(args) == 1) and args[0] and isinstance(args[0], dict): + if args and len(args) == 1 and isinstance(args[0], dict) and args[0]: args = args[0] self.args = args self.levelname = getLevelName(level) @@ -730,7 +730,8 @@ """ Flushes the stream. """ - self.stream.flush() + if self.stream: + self.stream.flush() def emit(self, record): """ @@ -780,9 +781,11 @@ """ Closes the stream. """ - self.flush() - self.stream.close() - StreamHandler.close(self) + if self.stream: + self.flush() + self.stream.close() + StreamHandler.close(self) + self.stream = None def _open(self): """ @@ -1245,7 +1248,7 @@ hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") - if level: + if level is not None: root.setLevel(level) #--------------------------------------------------------------------------- Modified: python/branches/py3k/Lib/logging/handlers.py ============================================================================== --- python/branches/py3k/Lib/logging/handlers.py (original) +++ python/branches/py3k/Lib/logging/handlers.py Thu Nov 1 20:42:39 2007 @@ -231,11 +231,11 @@ # of days in the next week until the rollover day (3). if when.startswith('W'): day = t[6] # 0 is Monday - if day > self.dayOfWeek: - daysToWait = (day - self.dayOfWeek) - 1 - self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24)) - if day < self.dayOfWeek: - daysToWait = (6 - self.dayOfWeek) + day + if day != self.dayOfWeek: + if day < self.dayOfWeek: + daysToWait = self.dayOfWeek - day - 1 + else: + daysToWait = 6 - day + self.dayOfWeek self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24)) #print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime) Modified: python/branches/py3k/Lib/mimetypes.py ============================================================================== --- python/branches/py3k/Lib/mimetypes.py (original) +++ python/branches/py3k/Lib/mimetypes.py Thu Nov 1 20:42:39 2007 @@ -393,6 +393,7 @@ '.movie' : 'video/x-sgi-movie', '.mp2' : 'audio/mpeg', '.mp3' : 'audio/mpeg', + '.mp4' : 'video/mp4', '.mpa' : 'video/mpeg', '.mpe' : 'video/mpeg', '.mpeg' : 'video/mpeg', Modified: python/branches/py3k/Lib/plat-freebsd6/IN.py ============================================================================== --- python/branches/py3k/Lib/plat-freebsd6/IN.py (original) +++ python/branches/py3k/Lib/plat-freebsd6/IN.py Thu Nov 1 20:42:39 2007 @@ -1,6 +1,28 @@ # Generated by h2py from /usr/include/netinet/in.h # Included from sys/cdefs.h +__GNUCLIKE_ASM = 3 +__GNUCLIKE_ASM = 2 +__GNUCLIKE___TYPEOF = 1 +__GNUCLIKE___OFFSETOF = 1 +__GNUCLIKE___SECTION = 1 +__GNUCLIKE_ATTRIBUTE_MODE_DI = 1 +__GNUCLIKE_CTOR_SECTION_HANDLING = 1 +__GNUCLIKE_BUILTIN_CONSTANT_P = 1 +__GNUCLIKE_BUILTIN_VARARGS = 1 +__GNUCLIKE_BUILTIN_STDARG = 1 +__GNUCLIKE_BUILTIN_VAALIST = 1 +__GNUC_VA_LIST_COMPATIBILITY = 1 +__GNUCLIKE_BUILTIN_NEXT_ARG = 1 +__GNUCLIKE_BUILTIN_MEMCPY = 1 +__CC_SUPPORTS_INLINE = 1 +__CC_SUPPORTS___INLINE = 1 +__CC_SUPPORTS___INLINE__ = 1 +__CC_SUPPORTS___FUNC__ = 1 +__CC_SUPPORTS_WARNING = 1 +__CC_SUPPORTS_VARADIC_XXX = 1 +__CC_SUPPORTS_DYNAMIC_ARRAY_INIT = 1 +__CC_INT_IS_32BIT = 1 def __P(protos): return protos def __STRING(x): return #x @@ -29,6 +51,8 @@ def __predict_false(exp): return (exp) +def __format_arg(fmtarg): return __attribute__((__format_arg__ (fmtarg))) + def __FBSDID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) def __RCSID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) @@ -86,8 +110,6 @@ BIG_ENDIAN = _BIG_ENDIAN PDP_ENDIAN = _PDP_ENDIAN BYTE_ORDER = _BYTE_ORDER -__INTEL_COMPILER_with_FreeBSD_endian = 1 -__INTEL_COMPILER_with_FreeBSD_endian = 1 def __word_swap_int_var(x): return \ def __word_swap_int_const(x): return \ @@ -96,12 +118,16 @@ def __byte_swap_int_var(x): return \ -def __byte_swap_int_var(x): return \ - def __byte_swap_int_const(x): return \ def __byte_swap_int(x): return __byte_swap_int_var(x) +def __byte_swap_long_var(x): return \ + +def __byte_swap_long_const(x): return \ + +def __byte_swap_long(x): return __byte_swap_long_var(x) + def __byte_swap_word_var(x): return \ def __byte_swap_word_const(x): return \ @@ -229,47 +255,50 @@ IPPROTO_APES = 99 IPPROTO_GMTP = 100 IPPROTO_IPCOMP = 108 +IPPROTO_SCTP = 132 IPPROTO_PIM = 103 +IPPROTO_CARP = 112 IPPROTO_PGM = 113 IPPROTO_PFSYNC = 240 IPPROTO_OLD_DIVERT = 254 IPPROTO_MAX = 256 IPPROTO_DONE = 257 IPPROTO_DIVERT = 258 +IPPROTO_SPACER = 32767 IPPORT_RESERVED = 1024 IPPORT_HIFIRSTAUTO = 49152 IPPORT_HILASTAUTO = 65535 IPPORT_RESERVEDSTART = 600 IPPORT_MAX = 65535 -def IN_CLASSA(i): return (((u_int32_t)(i) & (-2147483648)) == 0) +def IN_CLASSA(i): return (((u_int32_t)(i) & 0x80000000) == 0) -IN_CLASSA_NET = (-16777216) +IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSA_HOST = 0x00ffffff IN_CLASSA_MAX = 128 -def IN_CLASSB(i): return (((u_int32_t)(i) & (-1073741824)) == (-2147483648)) +def IN_CLASSB(i): return (((u_int32_t)(i) & 0xc0000000) == 0x80000000) -IN_CLASSB_NET = (-65536) +IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSB_HOST = 0x0000ffff IN_CLASSB_MAX = 65536 -def IN_CLASSC(i): return (((u_int32_t)(i) & (-536870912)) == (-1073741824)) +def IN_CLASSC(i): return (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) -IN_CLASSC_NET = (-256) +IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_CLASSC_HOST = 0x000000ff -def IN_CLASSD(i): return (((u_int32_t)(i) & (-268435456)) == (-536870912)) +def IN_CLASSD(i): return (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) -IN_CLASSD_NET = (-268435456) +IN_CLASSD_NET = 0xf0000000 IN_CLASSD_NSHIFT = 28 IN_CLASSD_HOST = 0x0fffffff def IN_MULTICAST(i): return IN_CLASSD(i) -def IN_EXPERIMENTAL(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456)) +def IN_EXPERIMENTAL(i): return (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) -def IN_BADCLASS(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456)) +def IN_BADCLASS(i): return (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) -INADDR_NONE = (-1) +INADDR_NONE = 0xffffffff IN_LOOPBACKNET = 127 IP_OPTIONS = 1 IP_HDRINCL = 2 @@ -311,6 +340,8 @@ IP_DUMMYNET_FLUSH = 62 IP_DUMMYNET_GET = 64 IP_RECVTTL = 65 +IP_MINTTL = 66 +IP_DONTFRAG = 67 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 IP_MAX_MEMBERSHIPS = 20 @@ -339,7 +370,7 @@ # Included from netinet6/in6.h -__KAME_VERSION = "20010528/FreeBSD" +__KAME_VERSION = "FreeBSD" IPV6PORT_RESERVED = 1024 IPV6PORT_ANONMIN = 49152 IPV6PORT_ANONMAX = 65535 @@ -348,8 +379,8 @@ INET6_ADDRSTRLEN = 46 IPV6_ADDR_INT32_ONE = 1 IPV6_ADDR_INT32_TWO = 2 -IPV6_ADDR_INT32_MNL = (-16711680) -IPV6_ADDR_INT32_MLL = (-16646144) +IPV6_ADDR_INT32_MNL = 0xff010000 +IPV6_ADDR_INT32_MLL = 0xff020000 IPV6_ADDR_INT32_SMP = 0x0000ffff IPV6_ADDR_INT16_ULL = 0xfe80 IPV6_ADDR_INT16_USL = 0xfec0 @@ -358,7 +389,7 @@ IPV6_ADDR_INT32_TWO = 0x02000000 IPV6_ADDR_INT32_MNL = 0x000001ff IPV6_ADDR_INT32_MLL = 0x000002ff -IPV6_ADDR_INT32_SMP = (-65536) +IPV6_ADDR_INT32_SMP = 0xffff0000 IPV6_ADDR_INT16_ULL = 0x80fe IPV6_ADDR_INT16_USL = 0xc0fe IPV6_ADDR_INT16_MLL = 0x02ff @@ -511,5 +542,10 @@ IPV6CTL_RIP6STATS = 36 IPV6CTL_PREFER_TEMPADDR = 37 IPV6CTL_ADDRCTLPOLICY = 38 +IPV6CTL_USE_DEFAULTZONE = 39 IPV6CTL_MAXFRAGS = 41 -IPV6CTL_MAXID = 42 +IPV6CTL_IFQ = 42 +IPV6CTL_ISATAPRTR = 43 +IPV6CTL_MCAST_PMTU = 44 +IPV6CTL_STEALTH = 45 +IPV6CTL_MAXID = 46 Modified: python/branches/py3k/Lib/plat-freebsd7/IN.py ============================================================================== --- python/branches/py3k/Lib/plat-freebsd7/IN.py (original) +++ python/branches/py3k/Lib/plat-freebsd7/IN.py Thu Nov 1 20:42:39 2007 @@ -10,9 +10,9 @@ __GNUCLIKE_CTOR_SECTION_HANDLING = 1 __GNUCLIKE_BUILTIN_CONSTANT_P = 1 __GNUCLIKE_BUILTIN_VARARGS = 1 +__GNUCLIKE_BUILTIN_STDARG = 1 __GNUCLIKE_BUILTIN_VAALIST = 1 __GNUC_VA_LIST_COMPATIBILITY = 1 -__GNUCLIKE_BUILTIN_STDARG = 1 __GNUCLIKE_BUILTIN_NEXT_ARG = 1 __GNUCLIKE_BUILTIN_MEMCPY = 1 __CC_SUPPORTS_INLINE = 1 @@ -51,6 +51,8 @@ def __predict_false(exp): return (exp) +def __format_arg(fmtarg): return __attribute__((__format_arg__ (fmtarg))) + def __FBSDID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) def __RCSID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) @@ -247,6 +249,7 @@ IPPROTO_APES = 99 IPPROTO_GMTP = 100 IPPROTO_IPCOMP = 108 +IPPROTO_SCTP = 132 IPPROTO_PIM = 103 IPPROTO_CARP = 112 IPPROTO_PGM = 113 @@ -289,6 +292,10 @@ def IN_BADCLASS(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456)) +def IN_LINKLOCAL(i): return (((u_int32_t)(i) & (-65536)) == (-1442971648)) + +def IN_LOCAL_GROUP(i): return (((u_int32_t)(i) & (-256)) == (-536870912)) + INADDR_NONE = (-1) IN_LOOPBACKNET = 127 IP_OPTIONS = 1 @@ -326,14 +333,35 @@ IP_FW_ZERO = 53 IP_FW_GET = 54 IP_FW_RESETLOG = 55 +IP_FW_NAT_CFG = 56 +IP_FW_NAT_DEL = 57 +IP_FW_NAT_GET_CONFIG = 58 +IP_FW_NAT_GET_LOG = 59 IP_DUMMYNET_CONFIGURE = 60 IP_DUMMYNET_DEL = 61 IP_DUMMYNET_FLUSH = 62 IP_DUMMYNET_GET = 64 IP_RECVTTL = 65 +IP_MINTTL = 66 +IP_DONTFRAG = 67 +IP_ADD_SOURCE_MEMBERSHIP = 70 +IP_DROP_SOURCE_MEMBERSHIP = 71 +IP_BLOCK_SOURCE = 72 +IP_UNBLOCK_SOURCE = 73 +IP_MSFILTER = 74 +MCAST_JOIN_GROUP = 80 +MCAST_LEAVE_GROUP = 81 +MCAST_JOIN_SOURCE_GROUP = 82 +MCAST_LEAVE_SOURCE_GROUP = 83 +MCAST_BLOCK_SOURCE = 84 +MCAST_UNBLOCK_SOURCE = 85 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 -IP_MAX_MEMBERSHIPS = 20 +IP_MIN_MEMBERSHIPS = 31 +IP_MAX_MEMBERSHIPS = 4095 +IP_MAX_SOURCE_FILTER = 1024 +MCAST_INCLUDE = 1 +MCAST_EXCLUDE = 2 IP_PORTRANGE_DEFAULT = 0 IP_PORTRANGE_HIGH = 1 IP_PORTRANGE_LOW = 2 @@ -359,7 +387,7 @@ # Included from netinet6/in6.h -__KAME_VERSION = "20010528/FreeBSD" +__KAME_VERSION = "FreeBSD" IPV6PORT_RESERVED = 1024 IPV6PORT_ANONMIN = 49152 IPV6PORT_ANONMAX = 65535 @@ -430,6 +458,8 @@ def IN6_IS_SCOPE_LINKLOCAL(a): return \ +def IN6_IS_SCOPE_EMBED(a): return \ + def IFA6_IS_DEPRECATED(a): return \ def IFA6_IS_INVALID(a): return \ @@ -488,6 +518,7 @@ IPV6_TCLASS = 61 IPV6_DONTFRAG = 62 IPV6_PREFER_TEMPADDR = 63 +IPV6_MSFILTER = 74 IPV6_RTHDR_LOOSE = 0 IPV6_RTHDR_STRICT = 1 IPV6_RTHDR_TYPE_0 = 0 @@ -531,5 +562,10 @@ IPV6CTL_RIP6STATS = 36 IPV6CTL_PREFER_TEMPADDR = 37 IPV6CTL_ADDRCTLPOLICY = 38 +IPV6CTL_USE_DEFAULTZONE = 39 IPV6CTL_MAXFRAGS = 41 -IPV6CTL_MAXID = 42 +IPV6CTL_IFQ = 42 +IPV6CTL_ISATAPRTR = 43 +IPV6CTL_MCAST_PMTU = 44 +IPV6CTL_STEALTH = 45 +IPV6CTL_MAXID = 46 Modified: python/branches/py3k/Lib/sched.py ============================================================================== --- python/branches/py3k/Lib/sched.py (original) +++ python/branches/py3k/Lib/sched.py Thu Nov 1 20:42:39 2007 @@ -16,11 +16,11 @@ Events are specified by tuples (time, priority, action, argument). As in UNIX, lower priority numbers mean higher priority; in this way the queue can be maintained as a priority queue. Execution of the -event means calling the action function, passing it the argument. -Remember that in Python, multiple function arguments can be packed -in a tuple. The action function may be an instance method so it +event means calling the action function, passing it the argument +sequence in "argument" (remember that in Python, multiple function +arguments are be packed in a sequence). +The action function may be an instance method so it has another way to reference private data (besides global variables). -Parameterless functions or methods cannot be used, however. """ # XXX The timefunc and delayfunc should have been defined as methods @@ -89,7 +89,7 @@ exceptions are not caught but the scheduler's state remains well-defined so run() may be called again. - A questionably hack is added to allow other threads to run: + A questionable hack is added to allow other threads to run: just after an event is executed, a delay of 0 is executed, to avoid monopolizing the CPU when other threads are also runnable. @@ -111,7 +111,7 @@ # Verify that the event was not removed or altered # by another thread after we last looked at q[0]. if event is checked_event: - void = action(*argument) + action(*argument) delayfunc(0) # Let other threads run else: heapq.heappush(event) Modified: python/branches/py3k/Lib/smtpd.py ============================================================================== --- python/branches/py3k/Lib/smtpd.py (original) +++ python/branches/py3k/Lib/smtpd.py Thu Nov 1 20:42:39 2007 @@ -221,7 +221,7 @@ def smtp_MAIL(self, arg): print('===> MAIL', arg, file=DEBUGSTREAM) - address = self.__getaddr('FROM:', arg) + address = self.__getaddr('FROM:', arg) if arg else None if not address: self.push('501 Syntax: MAIL FROM:
') return @@ -237,7 +237,7 @@ if not self.__mailfrom: self.push('503 Error: need MAIL command') return - address = self.__getaddr('TO:', arg) + address = self.__getaddr('TO:', arg) if arg else None if not address: self.push('501 Syntax: RCPT TO:
') return Deleted: /python/branches/py3k/Lib/test/crashers/file_threads.py ============================================================================== --- /python/branches/py3k/Lib/test/crashers/file_threads.py Thu Nov 1 20:42:39 2007 +++ (empty file) @@ -1,8 +0,0 @@ -# An example for http://bugs.python.org/issue815646 - -import thread - -while 1: - f = open("/tmp/dupa", "w") - thread.start_new_thread(f.close, ()) - f.close() Modified: python/branches/py3k/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/extra.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/extra.decTest Thu Nov 1 20:42:39 2007 @@ -154,6 +154,2112 @@ extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation +-- Tests for the is_* boolean operations +precision: 9 +maxExponent: 999 +minExponent: -999 + +bool0000 iscanonical 0E-2000 -> 1 +bool0001 iscanonical -0E-2000 -> 1 +bool0002 iscanonical 0E-1008 -> 1 +bool0003 iscanonical -0E-1008 -> 1 +bool0004 iscanonical 0E-1007 -> 1 +bool0005 iscanonical -0E-1007 -> 1 +bool0006 iscanonical 0E-1006 -> 1 +bool0007 iscanonical -0E-1006 -> 1 +bool0008 iscanonical 0E-1000 -> 1 +bool0009 iscanonical -0E-1000 -> 1 +bool0010 iscanonical 0E-999 -> 1 +bool0011 iscanonical -0E-999 -> 1 +bool0012 iscanonical 0E-998 -> 1 +bool0013 iscanonical -0E-998 -> 1 +bool0014 iscanonical 0E-100 -> 1 +bool0015 iscanonical -0E-100 -> 1 +bool0016 iscanonical 0.000000 -> 1 +bool0017 iscanonical -0.000000 -> 1 +bool0018 iscanonical 0.000 -> 1 +bool0019 iscanonical -0.000 -> 1 +bool0020 iscanonical 0.00 -> 1 +bool0021 iscanonical -0.00 -> 1 +bool0022 iscanonical 0.0 -> 1 +bool0023 iscanonical -0.0 -> 1 +bool0024 iscanonical 0 -> 1 +bool0025 iscanonical -0 -> 1 +bool0026 iscanonical 0E+1 -> 1 +bool0027 iscanonical -0E+1 -> 1 +bool0028 iscanonical 0E+2 -> 1 +bool0029 iscanonical -0E+2 -> 1 +bool0030 iscanonical 0E+3 -> 1 +bool0031 iscanonical -0E+3 -> 1 +bool0032 iscanonical 0E+6 -> 1 +bool0033 iscanonical -0E+6 -> 1 +bool0034 iscanonical 0E+100 -> 1 +bool0035 iscanonical -0E+100 -> 1 +bool0036 iscanonical 0E+990 -> 1 +bool0037 iscanonical -0E+990 -> 1 +bool0038 iscanonical 0E+991 -> 1 +bool0039 iscanonical -0E+991 -> 1 +bool0040 iscanonical 0E+992 -> 1 +bool0041 iscanonical -0E+992 -> 1 +bool0042 iscanonical 0E+998 -> 1 +bool0043 iscanonical -0E+998 -> 1 +bool0044 iscanonical 0E+999 -> 1 +bool0045 iscanonical -0E+999 -> 1 +bool0046 iscanonical 0E+1000 -> 1 +bool0047 iscanonical -0E+1000 -> 1 +bool0048 iscanonical 0E+2000 -> 1 +bool0049 iscanonical -0E+2000 -> 1 +bool0050 iscanonical 1E-2000 -> 1 +bool0051 iscanonical -1E-2000 -> 1 +bool0052 iscanonical 1E-1008 -> 1 +bool0053 iscanonical -1E-1008 -> 1 +bool0054 iscanonical 1E-1007 -> 1 +bool0055 iscanonical -1E-1007 -> 1 +bool0056 iscanonical 1E-1006 -> 1 +bool0057 iscanonical -1E-1006 -> 1 +bool0058 iscanonical 1E-1000 -> 1 +bool0059 iscanonical -1E-1000 -> 1 +bool0060 iscanonical 1E-999 -> 1 +bool0061 iscanonical -1E-999 -> 1 +bool0062 iscanonical 1E-998 -> 1 +bool0063 iscanonical -1E-998 -> 1 +bool0064 iscanonical 1E-100 -> 1 +bool0065 iscanonical -1E-100 -> 1 +bool0066 iscanonical 0.000001 -> 1 +bool0067 iscanonical -0.000001 -> 1 +bool0068 iscanonical 0.001 -> 1 +bool0069 iscanonical -0.001 -> 1 +bool0070 iscanonical 0.01 -> 1 +bool0071 iscanonical -0.01 -> 1 +bool0072 iscanonical 0.1 -> 1 +bool0073 iscanonical -0.1 -> 1 +bool0074 iscanonical 1 -> 1 +bool0075 iscanonical -1 -> 1 +bool0076 iscanonical 1E+1 -> 1 +bool0077 iscanonical -1E+1 -> 1 +bool0078 iscanonical 1E+2 -> 1 +bool0079 iscanonical -1E+2 -> 1 +bool0080 iscanonical 1E+3 -> 1 +bool0081 iscanonical -1E+3 -> 1 +bool0082 iscanonical 1E+6 -> 1 +bool0083 iscanonical -1E+6 -> 1 +bool0084 iscanonical 1E+100 -> 1 +bool0085 iscanonical -1E+100 -> 1 +bool0086 iscanonical 1E+990 -> 1 +bool0087 iscanonical -1E+990 -> 1 +bool0088 iscanonical 1E+991 -> 1 +bool0089 iscanonical -1E+991 -> 1 +bool0090 iscanonical 1E+992 -> 1 +bool0091 iscanonical -1E+992 -> 1 +bool0092 iscanonical 1E+998 -> 1 +bool0093 iscanonical -1E+998 -> 1 +bool0094 iscanonical 1E+999 -> 1 +bool0095 iscanonical -1E+999 -> 1 +bool0096 iscanonical 1E+1000 -> 1 +bool0097 iscanonical -1E+1000 -> 1 +bool0098 iscanonical 1E+2000 -> 1 +bool0099 iscanonical -1E+2000 -> 1 +bool0100 iscanonical 9E-2000 -> 1 +bool0101 iscanonical -9E-2000 -> 1 +bool0102 iscanonical 9E-1008 -> 1 +bool0103 iscanonical -9E-1008 -> 1 +bool0104 iscanonical 9E-1007 -> 1 +bool0105 iscanonical -9E-1007 -> 1 +bool0106 iscanonical 9E-1006 -> 1 +bool0107 iscanonical -9E-1006 -> 1 +bool0108 iscanonical 9E-1000 -> 1 +bool0109 iscanonical -9E-1000 -> 1 +bool0110 iscanonical 9E-999 -> 1 +bool0111 iscanonical -9E-999 -> 1 +bool0112 iscanonical 9E-998 -> 1 +bool0113 iscanonical -9E-998 -> 1 +bool0114 iscanonical 9E-100 -> 1 +bool0115 iscanonical -9E-100 -> 1 +bool0116 iscanonical 0.000009 -> 1 +bool0117 iscanonical -0.000009 -> 1 +bool0118 iscanonical 0.009 -> 1 +bool0119 iscanonical -0.009 -> 1 +bool0120 iscanonical 0.09 -> 1 +bool0121 iscanonical -0.09 -> 1 +bool0122 iscanonical 0.9 -> 1 +bool0123 iscanonical -0.9 -> 1 +bool0124 iscanonical 9 -> 1 +bool0125 iscanonical -9 -> 1 +bool0126 iscanonical 9E+1 -> 1 +bool0127 iscanonical -9E+1 -> 1 +bool0128 iscanonical 9E+2 -> 1 +bool0129 iscanonical -9E+2 -> 1 +bool0130 iscanonical 9E+3 -> 1 +bool0131 iscanonical -9E+3 -> 1 +bool0132 iscanonical 9E+6 -> 1 +bool0133 iscanonical -9E+6 -> 1 +bool0134 iscanonical 9E+100 -> 1 +bool0135 iscanonical -9E+100 -> 1 +bool0136 iscanonical 9E+990 -> 1 +bool0137 iscanonical -9E+990 -> 1 +bool0138 iscanonical 9E+991 -> 1 +bool0139 iscanonical -9E+991 -> 1 +bool0140 iscanonical 9E+992 -> 1 +bool0141 iscanonical -9E+992 -> 1 +bool0142 iscanonical 9E+998 -> 1 +bool0143 iscanonical -9E+998 -> 1 +bool0144 iscanonical 9E+999 -> 1 +bool0145 iscanonical -9E+999 -> 1 +bool0146 iscanonical 9E+1000 -> 1 +bool0147 iscanonical -9E+1000 -> 1 +bool0148 iscanonical 9E+2000 -> 1 +bool0149 iscanonical -9E+2000 -> 1 +bool0150 iscanonical 9.99999999E-2000 -> 1 +bool0151 iscanonical -9.99999999E-2000 -> 1 +bool0152 iscanonical 9.99999999E-1008 -> 1 +bool0153 iscanonical -9.99999999E-1008 -> 1 +bool0154 iscanonical 9.99999999E-1007 -> 1 +bool0155 iscanonical -9.99999999E-1007 -> 1 +bool0156 iscanonical 9.99999999E-1006 -> 1 +bool0157 iscanonical -9.99999999E-1006 -> 1 +bool0158 iscanonical 9.99999999E-1000 -> 1 +bool0159 iscanonical -9.99999999E-1000 -> 1 +bool0160 iscanonical 9.99999999E-999 -> 1 +bool0161 iscanonical -9.99999999E-999 -> 1 +bool0162 iscanonical 9.99999999E-998 -> 1 +bool0163 iscanonical -9.99999999E-998 -> 1 +bool0164 iscanonical 9.99999999E-100 -> 1 +bool0165 iscanonical -9.99999999E-100 -> 1 +bool0166 iscanonical 0.00000999999999 -> 1 +bool0167 iscanonical -0.00000999999999 -> 1 +bool0168 iscanonical 0.00999999999 -> 1 +bool0169 iscanonical -0.00999999999 -> 1 +bool0170 iscanonical 0.0999999999 -> 1 +bool0171 iscanonical -0.0999999999 -> 1 +bool0172 iscanonical 0.999999999 -> 1 +bool0173 iscanonical -0.999999999 -> 1 +bool0174 iscanonical 9.99999999 -> 1 +bool0175 iscanonical -9.99999999 -> 1 +bool0176 iscanonical 99.9999999 -> 1 +bool0177 iscanonical -99.9999999 -> 1 +bool0178 iscanonical 999.999999 -> 1 +bool0179 iscanonical -999.999999 -> 1 +bool0180 iscanonical 9999.99999 -> 1 +bool0181 iscanonical -9999.99999 -> 1 +bool0182 iscanonical 9999999.99 -> 1 +bool0183 iscanonical -9999999.99 -> 1 +bool0184 iscanonical 9.99999999E+100 -> 1 +bool0185 iscanonical -9.99999999E+100 -> 1 +bool0186 iscanonical 9.99999999E+990 -> 1 +bool0187 iscanonical -9.99999999E+990 -> 1 +bool0188 iscanonical 9.99999999E+991 -> 1 +bool0189 iscanonical -9.99999999E+991 -> 1 +bool0190 iscanonical 9.99999999E+992 -> 1 +bool0191 iscanonical -9.99999999E+992 -> 1 +bool0192 iscanonical 9.99999999E+998 -> 1 +bool0193 iscanonical -9.99999999E+998 -> 1 +bool0194 iscanonical 9.99999999E+999 -> 1 +bool0195 iscanonical -9.99999999E+999 -> 1 +bool0196 iscanonical 9.99999999E+1000 -> 1 +bool0197 iscanonical -9.99999999E+1000 -> 1 +bool0198 iscanonical 9.99999999E+2000 -> 1 +bool0199 iscanonical -9.99999999E+2000 -> 1 +bool0200 iscanonical Infinity -> 1 +bool0201 iscanonical -Infinity -> 1 +bool0202 iscanonical NaN -> 1 +bool0203 iscanonical -NaN -> 1 +bool0204 iscanonical NaN123 -> 1 +bool0205 iscanonical -NaN123 -> 1 +bool0206 iscanonical sNaN -> 1 +bool0207 iscanonical -sNaN -> 1 +bool0208 iscanonical sNaN123 -> 1 +bool0209 iscanonical -sNaN123 -> 1 +bool0210 isfinite 0E-2000 -> 1 +bool0211 isfinite -0E-2000 -> 1 +bool0212 isfinite 0E-1008 -> 1 +bool0213 isfinite -0E-1008 -> 1 +bool0214 isfinite 0E-1007 -> 1 +bool0215 isfinite -0E-1007 -> 1 +bool0216 isfinite 0E-1006 -> 1 +bool0217 isfinite -0E-1006 -> 1 +bool0218 isfinite 0E-1000 -> 1 +bool0219 isfinite -0E-1000 -> 1 +bool0220 isfinite 0E-999 -> 1 +bool0221 isfinite -0E-999 -> 1 +bool0222 isfinite 0E-998 -> 1 +bool0223 isfinite -0E-998 -> 1 +bool0224 isfinite 0E-100 -> 1 +bool0225 isfinite -0E-100 -> 1 +bool0226 isfinite 0.000000 -> 1 +bool0227 isfinite -0.000000 -> 1 +bool0228 isfinite 0.000 -> 1 +bool0229 isfinite -0.000 -> 1 +bool0230 isfinite 0.00 -> 1 +bool0231 isfinite -0.00 -> 1 +bool0232 isfinite 0.0 -> 1 +bool0233 isfinite -0.0 -> 1 +bool0234 isfinite 0 -> 1 +bool0235 isfinite -0 -> 1 +bool0236 isfinite 0E+1 -> 1 +bool0237 isfinite -0E+1 -> 1 +bool0238 isfinite 0E+2 -> 1 +bool0239 isfinite -0E+2 -> 1 +bool0240 isfinite 0E+3 -> 1 +bool0241 isfinite -0E+3 -> 1 +bool0242 isfinite 0E+6 -> 1 +bool0243 isfinite -0E+6 -> 1 +bool0244 isfinite 0E+100 -> 1 +bool0245 isfinite -0E+100 -> 1 +bool0246 isfinite 0E+990 -> 1 +bool0247 isfinite -0E+990 -> 1 +bool0248 isfinite 0E+991 -> 1 +bool0249 isfinite -0E+991 -> 1 +bool0250 isfinite 0E+992 -> 1 +bool0251 isfinite -0E+992 -> 1 +bool0252 isfinite 0E+998 -> 1 +bool0253 isfinite -0E+998 -> 1 +bool0254 isfinite 0E+999 -> 1 +bool0255 isfinite -0E+999 -> 1 +bool0256 isfinite 0E+1000 -> 1 +bool0257 isfinite -0E+1000 -> 1 +bool0258 isfinite 0E+2000 -> 1 +bool0259 isfinite -0E+2000 -> 1 +bool0260 isfinite 1E-2000 -> 1 +bool0261 isfinite -1E-2000 -> 1 +bool0262 isfinite 1E-1008 -> 1 +bool0263 isfinite -1E-1008 -> 1 +bool0264 isfinite 1E-1007 -> 1 +bool0265 isfinite -1E-1007 -> 1 +bool0266 isfinite 1E-1006 -> 1 +bool0267 isfinite -1E-1006 -> 1 +bool0268 isfinite 1E-1000 -> 1 +bool0269 isfinite -1E-1000 -> 1 +bool0270 isfinite 1E-999 -> 1 +bool0271 isfinite -1E-999 -> 1 +bool0272 isfinite 1E-998 -> 1 +bool0273 isfinite -1E-998 -> 1 +bool0274 isfinite 1E-100 -> 1 +bool0275 isfinite -1E-100 -> 1 +bool0276 isfinite 0.000001 -> 1 +bool0277 isfinite -0.000001 -> 1 +bool0278 isfinite 0.001 -> 1 +bool0279 isfinite -0.001 -> 1 +bool0280 isfinite 0.01 -> 1 +bool0281 isfinite -0.01 -> 1 +bool0282 isfinite 0.1 -> 1 +bool0283 isfinite -0.1 -> 1 +bool0284 isfinite 1 -> 1 +bool0285 isfinite -1 -> 1 +bool0286 isfinite 1E+1 -> 1 +bool0287 isfinite -1E+1 -> 1 +bool0288 isfinite 1E+2 -> 1 +bool0289 isfinite -1E+2 -> 1 +bool0290 isfinite 1E+3 -> 1 +bool0291 isfinite -1E+3 -> 1 +bool0292 isfinite 1E+6 -> 1 +bool0293 isfinite -1E+6 -> 1 +bool0294 isfinite 1E+100 -> 1 +bool0295 isfinite -1E+100 -> 1 +bool0296 isfinite 1E+990 -> 1 +bool0297 isfinite -1E+990 -> 1 +bool0298 isfinite 1E+991 -> 1 +bool0299 isfinite -1E+991 -> 1 +bool0300 isfinite 1E+992 -> 1 +bool0301 isfinite -1E+992 -> 1 +bool0302 isfinite 1E+998 -> 1 +bool0303 isfinite -1E+998 -> 1 +bool0304 isfinite 1E+999 -> 1 +bool0305 isfinite -1E+999 -> 1 +bool0306 isfinite 1E+1000 -> 1 +bool0307 isfinite -1E+1000 -> 1 +bool0308 isfinite 1E+2000 -> 1 +bool0309 isfinite -1E+2000 -> 1 +bool0310 isfinite 9E-2000 -> 1 +bool0311 isfinite -9E-2000 -> 1 +bool0312 isfinite 9E-1008 -> 1 +bool0313 isfinite -9E-1008 -> 1 +bool0314 isfinite 9E-1007 -> 1 +bool0315 isfinite -9E-1007 -> 1 +bool0316 isfinite 9E-1006 -> 1 +bool0317 isfinite -9E-1006 -> 1 +bool0318 isfinite 9E-1000 -> 1 +bool0319 isfinite -9E-1000 -> 1 +bool0320 isfinite 9E-999 -> 1 +bool0321 isfinite -9E-999 -> 1 +bool0322 isfinite 9E-998 -> 1 +bool0323 isfinite -9E-998 -> 1 +bool0324 isfinite 9E-100 -> 1 +bool0325 isfinite -9E-100 -> 1 +bool0326 isfinite 0.000009 -> 1 +bool0327 isfinite -0.000009 -> 1 +bool0328 isfinite 0.009 -> 1 +bool0329 isfinite -0.009 -> 1 +bool0330 isfinite 0.09 -> 1 +bool0331 isfinite -0.09 -> 1 +bool0332 isfinite 0.9 -> 1 +bool0333 isfinite -0.9 -> 1 +bool0334 isfinite 9 -> 1 +bool0335 isfinite -9 -> 1 +bool0336 isfinite 9E+1 -> 1 +bool0337 isfinite -9E+1 -> 1 +bool0338 isfinite 9E+2 -> 1 +bool0339 isfinite -9E+2 -> 1 +bool0340 isfinite 9E+3 -> 1 +bool0341 isfinite -9E+3 -> 1 +bool0342 isfinite 9E+6 -> 1 +bool0343 isfinite -9E+6 -> 1 +bool0344 isfinite 9E+100 -> 1 +bool0345 isfinite -9E+100 -> 1 +bool0346 isfinite 9E+990 -> 1 +bool0347 isfinite -9E+990 -> 1 +bool0348 isfinite 9E+991 -> 1 +bool0349 isfinite -9E+991 -> 1 +bool0350 isfinite 9E+992 -> 1 +bool0351 isfinite -9E+992 -> 1 +bool0352 isfinite 9E+998 -> 1 +bool0353 isfinite -9E+998 -> 1 +bool0354 isfinite 9E+999 -> 1 +bool0355 isfinite -9E+999 -> 1 +bool0356 isfinite 9E+1000 -> 1 +bool0357 isfinite -9E+1000 -> 1 +bool0358 isfinite 9E+2000 -> 1 +bool0359 isfinite -9E+2000 -> 1 +bool0360 isfinite 9.99999999E-2000 -> 1 +bool0361 isfinite -9.99999999E-2000 -> 1 +bool0362 isfinite 9.99999999E-1008 -> 1 +bool0363 isfinite -9.99999999E-1008 -> 1 +bool0364 isfinite 9.99999999E-1007 -> 1 +bool0365 isfinite -9.99999999E-1007 -> 1 +bool0366 isfinite 9.99999999E-1006 -> 1 +bool0367 isfinite -9.99999999E-1006 -> 1 +bool0368 isfinite 9.99999999E-1000 -> 1 +bool0369 isfinite -9.99999999E-1000 -> 1 +bool0370 isfinite 9.99999999E-999 -> 1 +bool0371 isfinite -9.99999999E-999 -> 1 +bool0372 isfinite 9.99999999E-998 -> 1 +bool0373 isfinite -9.99999999E-998 -> 1 +bool0374 isfinite 9.99999999E-100 -> 1 +bool0375 isfinite -9.99999999E-100 -> 1 +bool0376 isfinite 0.00000999999999 -> 1 +bool0377 isfinite -0.00000999999999 -> 1 +bool0378 isfinite 0.00999999999 -> 1 +bool0379 isfinite -0.00999999999 -> 1 +bool0380 isfinite 0.0999999999 -> 1 +bool0381 isfinite -0.0999999999 -> 1 +bool0382 isfinite 0.999999999 -> 1 +bool0383 isfinite -0.999999999 -> 1 +bool0384 isfinite 9.99999999 -> 1 +bool0385 isfinite -9.99999999 -> 1 +bool0386 isfinite 99.9999999 -> 1 +bool0387 isfinite -99.9999999 -> 1 +bool0388 isfinite 999.999999 -> 1 +bool0389 isfinite -999.999999 -> 1 +bool0390 isfinite 9999.99999 -> 1 +bool0391 isfinite -9999.99999 -> 1 +bool0392 isfinite 9999999.99 -> 1 +bool0393 isfinite -9999999.99 -> 1 +bool0394 isfinite 9.99999999E+100 -> 1 +bool0395 isfinite -9.99999999E+100 -> 1 +bool0396 isfinite 9.99999999E+990 -> 1 +bool0397 isfinite -9.99999999E+990 -> 1 +bool0398 isfinite 9.99999999E+991 -> 1 +bool0399 isfinite -9.99999999E+991 -> 1 +bool0400 isfinite 9.99999999E+992 -> 1 +bool0401 isfinite -9.99999999E+992 -> 1 +bool0402 isfinite 9.99999999E+998 -> 1 +bool0403 isfinite -9.99999999E+998 -> 1 +bool0404 isfinite 9.99999999E+999 -> 1 +bool0405 isfinite -9.99999999E+999 -> 1 +bool0406 isfinite 9.99999999E+1000 -> 1 +bool0407 isfinite -9.99999999E+1000 -> 1 +bool0408 isfinite 9.99999999E+2000 -> 1 +bool0409 isfinite -9.99999999E+2000 -> 1 +bool0410 isfinite Infinity -> 0 +bool0411 isfinite -Infinity -> 0 +bool0412 isfinite NaN -> 0 +bool0413 isfinite -NaN -> 0 +bool0414 isfinite NaN123 -> 0 +bool0415 isfinite -NaN123 -> 0 +bool0416 isfinite sNaN -> 0 +bool0417 isfinite -sNaN -> 0 +bool0418 isfinite sNaN123 -> 0 +bool0419 isfinite -sNaN123 -> 0 +bool0420 isinfinite 0E-2000 -> 0 +bool0421 isinfinite -0E-2000 -> 0 +bool0422 isinfinite 0E-1008 -> 0 +bool0423 isinfinite -0E-1008 -> 0 +bool0424 isinfinite 0E-1007 -> 0 +bool0425 isinfinite -0E-1007 -> 0 +bool0426 isinfinite 0E-1006 -> 0 +bool0427 isinfinite -0E-1006 -> 0 +bool0428 isinfinite 0E-1000 -> 0 +bool0429 isinfinite -0E-1000 -> 0 +bool0430 isinfinite 0E-999 -> 0 +bool0431 isinfinite -0E-999 -> 0 +bool0432 isinfinite 0E-998 -> 0 +bool0433 isinfinite -0E-998 -> 0 +bool0434 isinfinite 0E-100 -> 0 +bool0435 isinfinite -0E-100 -> 0 +bool0436 isinfinite 0.000000 -> 0 +bool0437 isinfinite -0.000000 -> 0 +bool0438 isinfinite 0.000 -> 0 +bool0439 isinfinite -0.000 -> 0 +bool0440 isinfinite 0.00 -> 0 +bool0441 isinfinite -0.00 -> 0 +bool0442 isinfinite 0.0 -> 0 +bool0443 isinfinite -0.0 -> 0 +bool0444 isinfinite 0 -> 0 +bool0445 isinfinite -0 -> 0 +bool0446 isinfinite 0E+1 -> 0 +bool0447 isinfinite -0E+1 -> 0 +bool0448 isinfinite 0E+2 -> 0 +bool0449 isinfinite -0E+2 -> 0 +bool0450 isinfinite 0E+3 -> 0 +bool0451 isinfinite -0E+3 -> 0 +bool0452 isinfinite 0E+6 -> 0 +bool0453 isinfinite -0E+6 -> 0 +bool0454 isinfinite 0E+100 -> 0 +bool0455 isinfinite -0E+100 -> 0 +bool0456 isinfinite 0E+990 -> 0 +bool0457 isinfinite -0E+990 -> 0 +bool0458 isinfinite 0E+991 -> 0 +bool0459 isinfinite -0E+991 -> 0 +bool0460 isinfinite 0E+992 -> 0 +bool0461 isinfinite -0E+992 -> 0 +bool0462 isinfinite 0E+998 -> 0 +bool0463 isinfinite -0E+998 -> 0 +bool0464 isinfinite 0E+999 -> 0 +bool0465 isinfinite -0E+999 -> 0 +bool0466 isinfinite 0E+1000 -> 0 +bool0467 isinfinite -0E+1000 -> 0 +bool0468 isinfinite 0E+2000 -> 0 +bool0469 isinfinite -0E+2000 -> 0 +bool0470 isinfinite 1E-2000 -> 0 +bool0471 isinfinite -1E-2000 -> 0 +bool0472 isinfinite 1E-1008 -> 0 +bool0473 isinfinite -1E-1008 -> 0 +bool0474 isinfinite 1E-1007 -> 0 +bool0475 isinfinite -1E-1007 -> 0 +bool0476 isinfinite 1E-1006 -> 0 +bool0477 isinfinite -1E-1006 -> 0 +bool0478 isinfinite 1E-1000 -> 0 +bool0479 isinfinite -1E-1000 -> 0 +bool0480 isinfinite 1E-999 -> 0 +bool0481 isinfinite -1E-999 -> 0 +bool0482 isinfinite 1E-998 -> 0 +bool0483 isinfinite -1E-998 -> 0 +bool0484 isinfinite 1E-100 -> 0 +bool0485 isinfinite -1E-100 -> 0 +bool0486 isinfinite 0.000001 -> 0 +bool0487 isinfinite -0.000001 -> 0 +bool0488 isinfinite 0.001 -> 0 +bool0489 isinfinite -0.001 -> 0 +bool0490 isinfinite 0.01 -> 0 +bool0491 isinfinite -0.01 -> 0 +bool0492 isinfinite 0.1 -> 0 +bool0493 isinfinite -0.1 -> 0 +bool0494 isinfinite 1 -> 0 +bool0495 isinfinite -1 -> 0 +bool0496 isinfinite 1E+1 -> 0 +bool0497 isinfinite -1E+1 -> 0 +bool0498 isinfinite 1E+2 -> 0 +bool0499 isinfinite -1E+2 -> 0 +bool0500 isinfinite 1E+3 -> 0 +bool0501 isinfinite -1E+3 -> 0 +bool0502 isinfinite 1E+6 -> 0 +bool0503 isinfinite -1E+6 -> 0 +bool0504 isinfinite 1E+100 -> 0 +bool0505 isinfinite -1E+100 -> 0 +bool0506 isinfinite 1E+990 -> 0 +bool0507 isinfinite -1E+990 -> 0 +bool0508 isinfinite 1E+991 -> 0 +bool0509 isinfinite -1E+991 -> 0 +bool0510 isinfinite 1E+992 -> 0 +bool0511 isinfinite -1E+992 -> 0 +bool0512 isinfinite 1E+998 -> 0 +bool0513 isinfinite -1E+998 -> 0 +bool0514 isinfinite 1E+999 -> 0 +bool0515 isinfinite -1E+999 -> 0 +bool0516 isinfinite 1E+1000 -> 0 +bool0517 isinfinite -1E+1000 -> 0 +bool0518 isinfinite 1E+2000 -> 0 +bool0519 isinfinite -1E+2000 -> 0 +bool0520 isinfinite 9E-2000 -> 0 +bool0521 isinfinite -9E-2000 -> 0 +bool0522 isinfinite 9E-1008 -> 0 +bool0523 isinfinite -9E-1008 -> 0 +bool0524 isinfinite 9E-1007 -> 0 +bool0525 isinfinite -9E-1007 -> 0 +bool0526 isinfinite 9E-1006 -> 0 +bool0527 isinfinite -9E-1006 -> 0 +bool0528 isinfinite 9E-1000 -> 0 +bool0529 isinfinite -9E-1000 -> 0 +bool0530 isinfinite 9E-999 -> 0 +bool0531 isinfinite -9E-999 -> 0 +bool0532 isinfinite 9E-998 -> 0 +bool0533 isinfinite -9E-998 -> 0 +bool0534 isinfinite 9E-100 -> 0 +bool0535 isinfinite -9E-100 -> 0 +bool0536 isinfinite 0.000009 -> 0 +bool0537 isinfinite -0.000009 -> 0 +bool0538 isinfinite 0.009 -> 0 +bool0539 isinfinite -0.009 -> 0 +bool0540 isinfinite 0.09 -> 0 +bool0541 isinfinite -0.09 -> 0 +bool0542 isinfinite 0.9 -> 0 +bool0543 isinfinite -0.9 -> 0 +bool0544 isinfinite 9 -> 0 +bool0545 isinfinite -9 -> 0 +bool0546 isinfinite 9E+1 -> 0 +bool0547 isinfinite -9E+1 -> 0 +bool0548 isinfinite 9E+2 -> 0 +bool0549 isinfinite -9E+2 -> 0 +bool0550 isinfinite 9E+3 -> 0 +bool0551 isinfinite -9E+3 -> 0 +bool0552 isinfinite 9E+6 -> 0 +bool0553 isinfinite -9E+6 -> 0 +bool0554 isinfinite 9E+100 -> 0 +bool0555 isinfinite -9E+100 -> 0 +bool0556 isinfinite 9E+990 -> 0 +bool0557 isinfinite -9E+990 -> 0 +bool0558 isinfinite 9E+991 -> 0 +bool0559 isinfinite -9E+991 -> 0 +bool0560 isinfinite 9E+992 -> 0 +bool0561 isinfinite -9E+992 -> 0 +bool0562 isinfinite 9E+998 -> 0 +bool0563 isinfinite -9E+998 -> 0 +bool0564 isinfinite 9E+999 -> 0 +bool0565 isinfinite -9E+999 -> 0 +bool0566 isinfinite 9E+1000 -> 0 +bool0567 isinfinite -9E+1000 -> 0 +bool0568 isinfinite 9E+2000 -> 0 +bool0569 isinfinite -9E+2000 -> 0 +bool0570 isinfinite 9.99999999E-2000 -> 0 +bool0571 isinfinite -9.99999999E-2000 -> 0 +bool0572 isinfinite 9.99999999E-1008 -> 0 +bool0573 isinfinite -9.99999999E-1008 -> 0 +bool0574 isinfinite 9.99999999E-1007 -> 0 +bool0575 isinfinite -9.99999999E-1007 -> 0 +bool0576 isinfinite 9.99999999E-1006 -> 0 +bool0577 isinfinite -9.99999999E-1006 -> 0 +bool0578 isinfinite 9.99999999E-1000 -> 0 +bool0579 isinfinite -9.99999999E-1000 -> 0 +bool0580 isinfinite 9.99999999E-999 -> 0 +bool0581 isinfinite -9.99999999E-999 -> 0 +bool0582 isinfinite 9.99999999E-998 -> 0 +bool0583 isinfinite -9.99999999E-998 -> 0 +bool0584 isinfinite 9.99999999E-100 -> 0 +bool0585 isinfinite -9.99999999E-100 -> 0 +bool0586 isinfinite 0.00000999999999 -> 0 +bool0587 isinfinite -0.00000999999999 -> 0 +bool0588 isinfinite 0.00999999999 -> 0 +bool0589 isinfinite -0.00999999999 -> 0 +bool0590 isinfinite 0.0999999999 -> 0 +bool0591 isinfinite -0.0999999999 -> 0 +bool0592 isinfinite 0.999999999 -> 0 +bool0593 isinfinite -0.999999999 -> 0 +bool0594 isinfinite 9.99999999 -> 0 +bool0595 isinfinite -9.99999999 -> 0 +bool0596 isinfinite 99.9999999 -> 0 +bool0597 isinfinite -99.9999999 -> 0 +bool0598 isinfinite 999.999999 -> 0 +bool0599 isinfinite -999.999999 -> 0 +bool0600 isinfinite 9999.99999 -> 0 +bool0601 isinfinite -9999.99999 -> 0 +bool0602 isinfinite 9999999.99 -> 0 +bool0603 isinfinite -9999999.99 -> 0 +bool0604 isinfinite 9.99999999E+100 -> 0 +bool0605 isinfinite -9.99999999E+100 -> 0 +bool0606 isinfinite 9.99999999E+990 -> 0 +bool0607 isinfinite -9.99999999E+990 -> 0 +bool0608 isinfinite 9.99999999E+991 -> 0 +bool0609 isinfinite -9.99999999E+991 -> 0 +bool0610 isinfinite 9.99999999E+992 -> 0 +bool0611 isinfinite -9.99999999E+992 -> 0 +bool0612 isinfinite 9.99999999E+998 -> 0 +bool0613 isinfinite -9.99999999E+998 -> 0 +bool0614 isinfinite 9.99999999E+999 -> 0 +bool0615 isinfinite -9.99999999E+999 -> 0 +bool0616 isinfinite 9.99999999E+1000 -> 0 +bool0617 isinfinite -9.99999999E+1000 -> 0 +bool0618 isinfinite 9.99999999E+2000 -> 0 +bool0619 isinfinite -9.99999999E+2000 -> 0 +bool0620 isinfinite Infinity -> 1 +bool0621 isinfinite -Infinity -> 1 +bool0622 isinfinite NaN -> 0 +bool0623 isinfinite -NaN -> 0 +bool0624 isinfinite NaN123 -> 0 +bool0625 isinfinite -NaN123 -> 0 +bool0626 isinfinite sNaN -> 0 +bool0627 isinfinite -sNaN -> 0 +bool0628 isinfinite sNaN123 -> 0 +bool0629 isinfinite -sNaN123 -> 0 +bool0630 isnan 0E-2000 -> 0 +bool0631 isnan -0E-2000 -> 0 +bool0632 isnan 0E-1008 -> 0 +bool0633 isnan -0E-1008 -> 0 +bool0634 isnan 0E-1007 -> 0 +bool0635 isnan -0E-1007 -> 0 +bool0636 isnan 0E-1006 -> 0 +bool0637 isnan -0E-1006 -> 0 +bool0638 isnan 0E-1000 -> 0 +bool0639 isnan -0E-1000 -> 0 +bool0640 isnan 0E-999 -> 0 +bool0641 isnan -0E-999 -> 0 +bool0642 isnan 0E-998 -> 0 +bool0643 isnan -0E-998 -> 0 +bool0644 isnan 0E-100 -> 0 +bool0645 isnan -0E-100 -> 0 +bool0646 isnan 0.000000 -> 0 +bool0647 isnan -0.000000 -> 0 +bool0648 isnan 0.000 -> 0 +bool0649 isnan -0.000 -> 0 +bool0650 isnan 0.00 -> 0 +bool0651 isnan -0.00 -> 0 +bool0652 isnan 0.0 -> 0 +bool0653 isnan -0.0 -> 0 +bool0654 isnan 0 -> 0 +bool0655 isnan -0 -> 0 +bool0656 isnan 0E+1 -> 0 +bool0657 isnan -0E+1 -> 0 +bool0658 isnan 0E+2 -> 0 +bool0659 isnan -0E+2 -> 0 +bool0660 isnan 0E+3 -> 0 +bool0661 isnan -0E+3 -> 0 +bool0662 isnan 0E+6 -> 0 +bool0663 isnan -0E+6 -> 0 +bool0664 isnan 0E+100 -> 0 +bool0665 isnan -0E+100 -> 0 +bool0666 isnan 0E+990 -> 0 +bool0667 isnan -0E+990 -> 0 +bool0668 isnan 0E+991 -> 0 +bool0669 isnan -0E+991 -> 0 +bool0670 isnan 0E+992 -> 0 +bool0671 isnan -0E+992 -> 0 +bool0672 isnan 0E+998 -> 0 +bool0673 isnan -0E+998 -> 0 +bool0674 isnan 0E+999 -> 0 +bool0675 isnan -0E+999 -> 0 +bool0676 isnan 0E+1000 -> 0 +bool0677 isnan -0E+1000 -> 0 +bool0678 isnan 0E+2000 -> 0 +bool0679 isnan -0E+2000 -> 0 +bool0680 isnan 1E-2000 -> 0 +bool0681 isnan -1E-2000 -> 0 +bool0682 isnan 1E-1008 -> 0 +bool0683 isnan -1E-1008 -> 0 +bool0684 isnan 1E-1007 -> 0 +bool0685 isnan -1E-1007 -> 0 +bool0686 isnan 1E-1006 -> 0 +bool0687 isnan -1E-1006 -> 0 +bool0688 isnan 1E-1000 -> 0 +bool0689 isnan -1E-1000 -> 0 +bool0690 isnan 1E-999 -> 0 +bool0691 isnan -1E-999 -> 0 +bool0692 isnan 1E-998 -> 0 +bool0693 isnan -1E-998 -> 0 +bool0694 isnan 1E-100 -> 0 +bool0695 isnan -1E-100 -> 0 +bool0696 isnan 0.000001 -> 0 +bool0697 isnan -0.000001 -> 0 +bool0698 isnan 0.001 -> 0 +bool0699 isnan -0.001 -> 0 +bool0700 isnan 0.01 -> 0 +bool0701 isnan -0.01 -> 0 +bool0702 isnan 0.1 -> 0 +bool0703 isnan -0.1 -> 0 +bool0704 isnan 1 -> 0 +bool0705 isnan -1 -> 0 +bool0706 isnan 1E+1 -> 0 +bool0707 isnan -1E+1 -> 0 +bool0708 isnan 1E+2 -> 0 +bool0709 isnan -1E+2 -> 0 +bool0710 isnan 1E+3 -> 0 +bool0711 isnan -1E+3 -> 0 +bool0712 isnan 1E+6 -> 0 +bool0713 isnan -1E+6 -> 0 +bool0714 isnan 1E+100 -> 0 +bool0715 isnan -1E+100 -> 0 +bool0716 isnan 1E+990 -> 0 +bool0717 isnan -1E+990 -> 0 +bool0718 isnan 1E+991 -> 0 +bool0719 isnan -1E+991 -> 0 +bool0720 isnan 1E+992 -> 0 +bool0721 isnan -1E+992 -> 0 +bool0722 isnan 1E+998 -> 0 +bool0723 isnan -1E+998 -> 0 +bool0724 isnan 1E+999 -> 0 +bool0725 isnan -1E+999 -> 0 +bool0726 isnan 1E+1000 -> 0 +bool0727 isnan -1E+1000 -> 0 +bool0728 isnan 1E+2000 -> 0 +bool0729 isnan -1E+2000 -> 0 +bool0730 isnan 9E-2000 -> 0 +bool0731 isnan -9E-2000 -> 0 +bool0732 isnan 9E-1008 -> 0 +bool0733 isnan -9E-1008 -> 0 +bool0734 isnan 9E-1007 -> 0 +bool0735 isnan -9E-1007 -> 0 +bool0736 isnan 9E-1006 -> 0 +bool0737 isnan -9E-1006 -> 0 +bool0738 isnan 9E-1000 -> 0 +bool0739 isnan -9E-1000 -> 0 +bool0740 isnan 9E-999 -> 0 +bool0741 isnan -9E-999 -> 0 +bool0742 isnan 9E-998 -> 0 +bool0743 isnan -9E-998 -> 0 +bool0744 isnan 9E-100 -> 0 +bool0745 isnan -9E-100 -> 0 +bool0746 isnan 0.000009 -> 0 +bool0747 isnan -0.000009 -> 0 +bool0748 isnan 0.009 -> 0 +bool0749 isnan -0.009 -> 0 +bool0750 isnan 0.09 -> 0 +bool0751 isnan -0.09 -> 0 +bool0752 isnan 0.9 -> 0 +bool0753 isnan -0.9 -> 0 +bool0754 isnan 9 -> 0 +bool0755 isnan -9 -> 0 +bool0756 isnan 9E+1 -> 0 +bool0757 isnan -9E+1 -> 0 +bool0758 isnan 9E+2 -> 0 +bool0759 isnan -9E+2 -> 0 +bool0760 isnan 9E+3 -> 0 +bool0761 isnan -9E+3 -> 0 +bool0762 isnan 9E+6 -> 0 +bool0763 isnan -9E+6 -> 0 +bool0764 isnan 9E+100 -> 0 +bool0765 isnan -9E+100 -> 0 +bool0766 isnan 9E+990 -> 0 +bool0767 isnan -9E+990 -> 0 +bool0768 isnan 9E+991 -> 0 +bool0769 isnan -9E+991 -> 0 +bool0770 isnan 9E+992 -> 0 +bool0771 isnan -9E+992 -> 0 +bool0772 isnan 9E+998 -> 0 +bool0773 isnan -9E+998 -> 0 +bool0774 isnan 9E+999 -> 0 +bool0775 isnan -9E+999 -> 0 +bool0776 isnan 9E+1000 -> 0 +bool0777 isnan -9E+1000 -> 0 +bool0778 isnan 9E+2000 -> 0 +bool0779 isnan -9E+2000 -> 0 +bool0780 isnan 9.99999999E-2000 -> 0 +bool0781 isnan -9.99999999E-2000 -> 0 +bool0782 isnan 9.99999999E-1008 -> 0 +bool0783 isnan -9.99999999E-1008 -> 0 +bool0784 isnan 9.99999999E-1007 -> 0 +bool0785 isnan -9.99999999E-1007 -> 0 +bool0786 isnan 9.99999999E-1006 -> 0 +bool0787 isnan -9.99999999E-1006 -> 0 +bool0788 isnan 9.99999999E-1000 -> 0 +bool0789 isnan -9.99999999E-1000 -> 0 +bool0790 isnan 9.99999999E-999 -> 0 +bool0791 isnan -9.99999999E-999 -> 0 +bool0792 isnan 9.99999999E-998 -> 0 +bool0793 isnan -9.99999999E-998 -> 0 +bool0794 isnan 9.99999999E-100 -> 0 +bool0795 isnan -9.99999999E-100 -> 0 +bool0796 isnan 0.00000999999999 -> 0 +bool0797 isnan -0.00000999999999 -> 0 +bool0798 isnan 0.00999999999 -> 0 +bool0799 isnan -0.00999999999 -> 0 +bool0800 isnan 0.0999999999 -> 0 +bool0801 isnan -0.0999999999 -> 0 +bool0802 isnan 0.999999999 -> 0 +bool0803 isnan -0.999999999 -> 0 +bool0804 isnan 9.99999999 -> 0 +bool0805 isnan -9.99999999 -> 0 +bool0806 isnan 99.9999999 -> 0 +bool0807 isnan -99.9999999 -> 0 +bool0808 isnan 999.999999 -> 0 +bool0809 isnan -999.999999 -> 0 +bool0810 isnan 9999.99999 -> 0 +bool0811 isnan -9999.99999 -> 0 +bool0812 isnan 9999999.99 -> 0 +bool0813 isnan -9999999.99 -> 0 +bool0814 isnan 9.99999999E+100 -> 0 +bool0815 isnan -9.99999999E+100 -> 0 +bool0816 isnan 9.99999999E+990 -> 0 +bool0817 isnan -9.99999999E+990 -> 0 +bool0818 isnan 9.99999999E+991 -> 0 +bool0819 isnan -9.99999999E+991 -> 0 +bool0820 isnan 9.99999999E+992 -> 0 +bool0821 isnan -9.99999999E+992 -> 0 +bool0822 isnan 9.99999999E+998 -> 0 +bool0823 isnan -9.99999999E+998 -> 0 +bool0824 isnan 9.99999999E+999 -> 0 +bool0825 isnan -9.99999999E+999 -> 0 +bool0826 isnan 9.99999999E+1000 -> 0 +bool0827 isnan -9.99999999E+1000 -> 0 +bool0828 isnan 9.99999999E+2000 -> 0 +bool0829 isnan -9.99999999E+2000 -> 0 +bool0830 isnan Infinity -> 0 +bool0831 isnan -Infinity -> 0 +bool0832 isnan NaN -> 1 +bool0833 isnan -NaN -> 1 +bool0834 isnan NaN123 -> 1 +bool0835 isnan -NaN123 -> 1 +bool0836 isnan sNaN -> 1 +bool0837 isnan -sNaN -> 1 +bool0838 isnan sNaN123 -> 1 +bool0839 isnan -sNaN123 -> 1 +bool0840 isnormal 0E-2000 -> 0 +bool0841 isnormal -0E-2000 -> 0 +bool0842 isnormal 0E-1008 -> 0 +bool0843 isnormal -0E-1008 -> 0 +bool0844 isnormal 0E-1007 -> 0 +bool0845 isnormal -0E-1007 -> 0 +bool0846 isnormal 0E-1006 -> 0 +bool0847 isnormal -0E-1006 -> 0 +bool0848 isnormal 0E-1000 -> 0 +bool0849 isnormal -0E-1000 -> 0 +bool0850 isnormal 0E-999 -> 0 +bool0851 isnormal -0E-999 -> 0 +bool0852 isnormal 0E-998 -> 0 +bool0853 isnormal -0E-998 -> 0 +bool0854 isnormal 0E-100 -> 0 +bool0855 isnormal -0E-100 -> 0 +bool0856 isnormal 0.000000 -> 0 +bool0857 isnormal -0.000000 -> 0 +bool0858 isnormal 0.000 -> 0 +bool0859 isnormal -0.000 -> 0 +bool0860 isnormal 0.00 -> 0 +bool0861 isnormal -0.00 -> 0 +bool0862 isnormal 0.0 -> 0 +bool0863 isnormal -0.0 -> 0 +bool0864 isnormal 0 -> 0 +bool0865 isnormal -0 -> 0 +bool0866 isnormal 0E+1 -> 0 +bool0867 isnormal -0E+1 -> 0 +bool0868 isnormal 0E+2 -> 0 +bool0869 isnormal -0E+2 -> 0 +bool0870 isnormal 0E+3 -> 0 +bool0871 isnormal -0E+3 -> 0 +bool0872 isnormal 0E+6 -> 0 +bool0873 isnormal -0E+6 -> 0 +bool0874 isnormal 0E+100 -> 0 +bool0875 isnormal -0E+100 -> 0 +bool0876 isnormal 0E+990 -> 0 +bool0877 isnormal -0E+990 -> 0 +bool0878 isnormal 0E+991 -> 0 +bool0879 isnormal -0E+991 -> 0 +bool0880 isnormal 0E+992 -> 0 +bool0881 isnormal -0E+992 -> 0 +bool0882 isnormal 0E+998 -> 0 +bool0883 isnormal -0E+998 -> 0 +bool0884 isnormal 0E+999 -> 0 +bool0885 isnormal -0E+999 -> 0 +bool0886 isnormal 0E+1000 -> 0 +bool0887 isnormal -0E+1000 -> 0 +bool0888 isnormal 0E+2000 -> 0 +bool0889 isnormal -0E+2000 -> 0 +bool0890 isnormal 1E-2000 -> 0 +bool0891 isnormal -1E-2000 -> 0 +bool0892 isnormal 1E-1008 -> 0 +bool0893 isnormal -1E-1008 -> 0 +bool0894 isnormal 1E-1007 -> 0 +bool0895 isnormal -1E-1007 -> 0 +bool0896 isnormal 1E-1006 -> 0 +bool0897 isnormal -1E-1006 -> 0 +bool0898 isnormal 1E-1000 -> 0 +bool0899 isnormal -1E-1000 -> 0 +bool0900 isnormal 1E-999 -> 1 +bool0901 isnormal -1E-999 -> 1 +bool0902 isnormal 1E-998 -> 1 +bool0903 isnormal -1E-998 -> 1 +bool0904 isnormal 1E-100 -> 1 +bool0905 isnormal -1E-100 -> 1 +bool0906 isnormal 0.000001 -> 1 +bool0907 isnormal -0.000001 -> 1 +bool0908 isnormal 0.001 -> 1 +bool0909 isnormal -0.001 -> 1 +bool0910 isnormal 0.01 -> 1 +bool0911 isnormal -0.01 -> 1 +bool0912 isnormal 0.1 -> 1 +bool0913 isnormal -0.1 -> 1 +bool0914 isnormal 1 -> 1 +bool0915 isnormal -1 -> 1 +bool0916 isnormal 1E+1 -> 1 +bool0917 isnormal -1E+1 -> 1 +bool0918 isnormal 1E+2 -> 1 +bool0919 isnormal -1E+2 -> 1 +bool0920 isnormal 1E+3 -> 1 +bool0921 isnormal -1E+3 -> 1 +bool0922 isnormal 1E+6 -> 1 +bool0923 isnormal -1E+6 -> 1 +bool0924 isnormal 1E+100 -> 1 +bool0925 isnormal -1E+100 -> 1 +bool0926 isnormal 1E+990 -> 1 +bool0927 isnormal -1E+990 -> 1 +bool0928 isnormal 1E+991 -> 1 +bool0929 isnormal -1E+991 -> 1 +bool0930 isnormal 1E+992 -> 1 +bool0931 isnormal -1E+992 -> 1 +bool0932 isnormal 1E+998 -> 1 +bool0933 isnormal -1E+998 -> 1 +bool0934 isnormal 1E+999 -> 1 +bool0935 isnormal -1E+999 -> 1 +bool0936 isnormal 1E+1000 -> 0 +bool0937 isnormal -1E+1000 -> 0 +bool0938 isnormal 1E+2000 -> 0 +bool0939 isnormal -1E+2000 -> 0 +bool0940 isnormal 9E-2000 -> 0 +bool0941 isnormal -9E-2000 -> 0 +bool0942 isnormal 9E-1008 -> 0 +bool0943 isnormal -9E-1008 -> 0 +bool0944 isnormal 9E-1007 -> 0 +bool0945 isnormal -9E-1007 -> 0 +bool0946 isnormal 9E-1006 -> 0 +bool0947 isnormal -9E-1006 -> 0 +bool0948 isnormal 9E-1000 -> 0 +bool0949 isnormal -9E-1000 -> 0 +bool0950 isnormal 9E-999 -> 1 +bool0951 isnormal -9E-999 -> 1 +bool0952 isnormal 9E-998 -> 1 +bool0953 isnormal -9E-998 -> 1 +bool0954 isnormal 9E-100 -> 1 +bool0955 isnormal -9E-100 -> 1 +bool0956 isnormal 0.000009 -> 1 +bool0957 isnormal -0.000009 -> 1 +bool0958 isnormal 0.009 -> 1 +bool0959 isnormal -0.009 -> 1 +bool0960 isnormal 0.09 -> 1 +bool0961 isnormal -0.09 -> 1 +bool0962 isnormal 0.9 -> 1 +bool0963 isnormal -0.9 -> 1 +bool0964 isnormal 9 -> 1 +bool0965 isnormal -9 -> 1 +bool0966 isnormal 9E+1 -> 1 +bool0967 isnormal -9E+1 -> 1 +bool0968 isnormal 9E+2 -> 1 +bool0969 isnormal -9E+2 -> 1 +bool0970 isnormal 9E+3 -> 1 +bool0971 isnormal -9E+3 -> 1 +bool0972 isnormal 9E+6 -> 1 +bool0973 isnormal -9E+6 -> 1 +bool0974 isnormal 9E+100 -> 1 +bool0975 isnormal -9E+100 -> 1 +bool0976 isnormal 9E+990 -> 1 +bool0977 isnormal -9E+990 -> 1 +bool0978 isnormal 9E+991 -> 1 +bool0979 isnormal -9E+991 -> 1 +bool0980 isnormal 9E+992 -> 1 +bool0981 isnormal -9E+992 -> 1 +bool0982 isnormal 9E+998 -> 1 +bool0983 isnormal -9E+998 -> 1 +bool0984 isnormal 9E+999 -> 1 +bool0985 isnormal -9E+999 -> 1 +bool0986 isnormal 9E+1000 -> 0 +bool0987 isnormal -9E+1000 -> 0 +bool0988 isnormal 9E+2000 -> 0 +bool0989 isnormal -9E+2000 -> 0 +bool0990 isnormal 9.99999999E-2000 -> 0 +bool0991 isnormal -9.99999999E-2000 -> 0 +bool0992 isnormal 9.99999999E-1008 -> 0 +bool0993 isnormal -9.99999999E-1008 -> 0 +bool0994 isnormal 9.99999999E-1007 -> 0 +bool0995 isnormal -9.99999999E-1007 -> 0 +bool0996 isnormal 9.99999999E-1006 -> 0 +bool0997 isnormal -9.99999999E-1006 -> 0 +bool0998 isnormal 9.99999999E-1000 -> 0 +bool0999 isnormal -9.99999999E-1000 -> 0 +bool1000 isnormal 9.99999999E-999 -> 1 +bool1001 isnormal -9.99999999E-999 -> 1 +bool1002 isnormal 9.99999999E-998 -> 1 +bool1003 isnormal -9.99999999E-998 -> 1 +bool1004 isnormal 9.99999999E-100 -> 1 +bool1005 isnormal -9.99999999E-100 -> 1 +bool1006 isnormal 0.00000999999999 -> 1 +bool1007 isnormal -0.00000999999999 -> 1 +bool1008 isnormal 0.00999999999 -> 1 +bool1009 isnormal -0.00999999999 -> 1 +bool1010 isnormal 0.0999999999 -> 1 +bool1011 isnormal -0.0999999999 -> 1 +bool1012 isnormal 0.999999999 -> 1 +bool1013 isnormal -0.999999999 -> 1 +bool1014 isnormal 9.99999999 -> 1 +bool1015 isnormal -9.99999999 -> 1 +bool1016 isnormal 99.9999999 -> 1 +bool1017 isnormal -99.9999999 -> 1 +bool1018 isnormal 999.999999 -> 1 +bool1019 isnormal -999.999999 -> 1 +bool1020 isnormal 9999.99999 -> 1 +bool1021 isnormal -9999.99999 -> 1 +bool1022 isnormal 9999999.99 -> 1 +bool1023 isnormal -9999999.99 -> 1 +bool1024 isnormal 9.99999999E+100 -> 1 +bool1025 isnormal -9.99999999E+100 -> 1 +bool1026 isnormal 9.99999999E+990 -> 1 +bool1027 isnormal -9.99999999E+990 -> 1 +bool1028 isnormal 9.99999999E+991 -> 1 +bool1029 isnormal -9.99999999E+991 -> 1 +bool1030 isnormal 9.99999999E+992 -> 1 +bool1031 isnormal -9.99999999E+992 -> 1 +bool1032 isnormal 9.99999999E+998 -> 1 +bool1033 isnormal -9.99999999E+998 -> 1 +bool1034 isnormal 9.99999999E+999 -> 1 +bool1035 isnormal -9.99999999E+999 -> 1 +bool1036 isnormal 9.99999999E+1000 -> 0 +bool1037 isnormal -9.99999999E+1000 -> 0 +bool1038 isnormal 9.99999999E+2000 -> 0 +bool1039 isnormal -9.99999999E+2000 -> 0 +bool1040 isnormal Infinity -> 0 +bool1041 isnormal -Infinity -> 0 +bool1042 isnormal NaN -> 0 +bool1043 isnormal -NaN -> 0 +bool1044 isnormal NaN123 -> 0 +bool1045 isnormal -NaN123 -> 0 +bool1046 isnormal sNaN -> 0 +bool1047 isnormal -sNaN -> 0 +bool1048 isnormal sNaN123 -> 0 +bool1049 isnormal -sNaN123 -> 0 +bool1050 isqnan 0E-2000 -> 0 +bool1051 isqnan -0E-2000 -> 0 +bool1052 isqnan 0E-1008 -> 0 +bool1053 isqnan -0E-1008 -> 0 +bool1054 isqnan 0E-1007 -> 0 +bool1055 isqnan -0E-1007 -> 0 +bool1056 isqnan 0E-1006 -> 0 +bool1057 isqnan -0E-1006 -> 0 +bool1058 isqnan 0E-1000 -> 0 +bool1059 isqnan -0E-1000 -> 0 +bool1060 isqnan 0E-999 -> 0 +bool1061 isqnan -0E-999 -> 0 +bool1062 isqnan 0E-998 -> 0 +bool1063 isqnan -0E-998 -> 0 +bool1064 isqnan 0E-100 -> 0 +bool1065 isqnan -0E-100 -> 0 +bool1066 isqnan 0.000000 -> 0 +bool1067 isqnan -0.000000 -> 0 +bool1068 isqnan 0.000 -> 0 +bool1069 isqnan -0.000 -> 0 +bool1070 isqnan 0.00 -> 0 +bool1071 isqnan -0.00 -> 0 +bool1072 isqnan 0.0 -> 0 +bool1073 isqnan -0.0 -> 0 +bool1074 isqnan 0 -> 0 +bool1075 isqnan -0 -> 0 +bool1076 isqnan 0E+1 -> 0 +bool1077 isqnan -0E+1 -> 0 +bool1078 isqnan 0E+2 -> 0 +bool1079 isqnan -0E+2 -> 0 +bool1080 isqnan 0E+3 -> 0 +bool1081 isqnan -0E+3 -> 0 +bool1082 isqnan 0E+6 -> 0 +bool1083 isqnan -0E+6 -> 0 +bool1084 isqnan 0E+100 -> 0 +bool1085 isqnan -0E+100 -> 0 +bool1086 isqnan 0E+990 -> 0 +bool1087 isqnan -0E+990 -> 0 +bool1088 isqnan 0E+991 -> 0 +bool1089 isqnan -0E+991 -> 0 +bool1090 isqnan 0E+992 -> 0 +bool1091 isqnan -0E+992 -> 0 +bool1092 isqnan 0E+998 -> 0 +bool1093 isqnan -0E+998 -> 0 +bool1094 isqnan 0E+999 -> 0 +bool1095 isqnan -0E+999 -> 0 +bool1096 isqnan 0E+1000 -> 0 +bool1097 isqnan -0E+1000 -> 0 +bool1098 isqnan 0E+2000 -> 0 +bool1099 isqnan -0E+2000 -> 0 +bool1100 isqnan 1E-2000 -> 0 +bool1101 isqnan -1E-2000 -> 0 +bool1102 isqnan 1E-1008 -> 0 +bool1103 isqnan -1E-1008 -> 0 +bool1104 isqnan 1E-1007 -> 0 +bool1105 isqnan -1E-1007 -> 0 +bool1106 isqnan 1E-1006 -> 0 +bool1107 isqnan -1E-1006 -> 0 +bool1108 isqnan 1E-1000 -> 0 +bool1109 isqnan -1E-1000 -> 0 +bool1110 isqnan 1E-999 -> 0 +bool1111 isqnan -1E-999 -> 0 +bool1112 isqnan 1E-998 -> 0 +bool1113 isqnan -1E-998 -> 0 +bool1114 isqnan 1E-100 -> 0 +bool1115 isqnan -1E-100 -> 0 +bool1116 isqnan 0.000001 -> 0 +bool1117 isqnan -0.000001 -> 0 +bool1118 isqnan 0.001 -> 0 +bool1119 isqnan -0.001 -> 0 +bool1120 isqnan 0.01 -> 0 +bool1121 isqnan -0.01 -> 0 +bool1122 isqnan 0.1 -> 0 +bool1123 isqnan -0.1 -> 0 +bool1124 isqnan 1 -> 0 +bool1125 isqnan -1 -> 0 +bool1126 isqnan 1E+1 -> 0 +bool1127 isqnan -1E+1 -> 0 +bool1128 isqnan 1E+2 -> 0 +bool1129 isqnan -1E+2 -> 0 +bool1130 isqnan 1E+3 -> 0 +bool1131 isqnan -1E+3 -> 0 +bool1132 isqnan 1E+6 -> 0 +bool1133 isqnan -1E+6 -> 0 +bool1134 isqnan 1E+100 -> 0 +bool1135 isqnan -1E+100 -> 0 +bool1136 isqnan 1E+990 -> 0 +bool1137 isqnan -1E+990 -> 0 +bool1138 isqnan 1E+991 -> 0 +bool1139 isqnan -1E+991 -> 0 +bool1140 isqnan 1E+992 -> 0 +bool1141 isqnan -1E+992 -> 0 +bool1142 isqnan 1E+998 -> 0 +bool1143 isqnan -1E+998 -> 0 +bool1144 isqnan 1E+999 -> 0 +bool1145 isqnan -1E+999 -> 0 +bool1146 isqnan 1E+1000 -> 0 +bool1147 isqnan -1E+1000 -> 0 +bool1148 isqnan 1E+2000 -> 0 +bool1149 isqnan -1E+2000 -> 0 +bool1150 isqnan 9E-2000 -> 0 +bool1151 isqnan -9E-2000 -> 0 +bool1152 isqnan 9E-1008 -> 0 +bool1153 isqnan -9E-1008 -> 0 +bool1154 isqnan 9E-1007 -> 0 +bool1155 isqnan -9E-1007 -> 0 +bool1156 isqnan 9E-1006 -> 0 +bool1157 isqnan -9E-1006 -> 0 +bool1158 isqnan 9E-1000 -> 0 +bool1159 isqnan -9E-1000 -> 0 +bool1160 isqnan 9E-999 -> 0 +bool1161 isqnan -9E-999 -> 0 +bool1162 isqnan 9E-998 -> 0 +bool1163 isqnan -9E-998 -> 0 +bool1164 isqnan 9E-100 -> 0 +bool1165 isqnan -9E-100 -> 0 +bool1166 isqnan 0.000009 -> 0 +bool1167 isqnan -0.000009 -> 0 +bool1168 isqnan 0.009 -> 0 +bool1169 isqnan -0.009 -> 0 +bool1170 isqnan 0.09 -> 0 +bool1171 isqnan -0.09 -> 0 +bool1172 isqnan 0.9 -> 0 +bool1173 isqnan -0.9 -> 0 +bool1174 isqnan 9 -> 0 +bool1175 isqnan -9 -> 0 +bool1176 isqnan 9E+1 -> 0 +bool1177 isqnan -9E+1 -> 0 +bool1178 isqnan 9E+2 -> 0 +bool1179 isqnan -9E+2 -> 0 +bool1180 isqnan 9E+3 -> 0 +bool1181 isqnan -9E+3 -> 0 +bool1182 isqnan 9E+6 -> 0 +bool1183 isqnan -9E+6 -> 0 +bool1184 isqnan 9E+100 -> 0 +bool1185 isqnan -9E+100 -> 0 +bool1186 isqnan 9E+990 -> 0 +bool1187 isqnan -9E+990 -> 0 +bool1188 isqnan 9E+991 -> 0 +bool1189 isqnan -9E+991 -> 0 +bool1190 isqnan 9E+992 -> 0 +bool1191 isqnan -9E+992 -> 0 +bool1192 isqnan 9E+998 -> 0 +bool1193 isqnan -9E+998 -> 0 +bool1194 isqnan 9E+999 -> 0 +bool1195 isqnan -9E+999 -> 0 +bool1196 isqnan 9E+1000 -> 0 +bool1197 isqnan -9E+1000 -> 0 +bool1198 isqnan 9E+2000 -> 0 +bool1199 isqnan -9E+2000 -> 0 +bool1200 isqnan 9.99999999E-2000 -> 0 +bool1201 isqnan -9.99999999E-2000 -> 0 +bool1202 isqnan 9.99999999E-1008 -> 0 +bool1203 isqnan -9.99999999E-1008 -> 0 +bool1204 isqnan 9.99999999E-1007 -> 0 +bool1205 isqnan -9.99999999E-1007 -> 0 +bool1206 isqnan 9.99999999E-1006 -> 0 +bool1207 isqnan -9.99999999E-1006 -> 0 +bool1208 isqnan 9.99999999E-1000 -> 0 +bool1209 isqnan -9.99999999E-1000 -> 0 +bool1210 isqnan 9.99999999E-999 -> 0 +bool1211 isqnan -9.99999999E-999 -> 0 +bool1212 isqnan 9.99999999E-998 -> 0 +bool1213 isqnan -9.99999999E-998 -> 0 +bool1214 isqnan 9.99999999E-100 -> 0 +bool1215 isqnan -9.99999999E-100 -> 0 +bool1216 isqnan 0.00000999999999 -> 0 +bool1217 isqnan -0.00000999999999 -> 0 +bool1218 isqnan 0.00999999999 -> 0 +bool1219 isqnan -0.00999999999 -> 0 +bool1220 isqnan 0.0999999999 -> 0 +bool1221 isqnan -0.0999999999 -> 0 +bool1222 isqnan 0.999999999 -> 0 +bool1223 isqnan -0.999999999 -> 0 +bool1224 isqnan 9.99999999 -> 0 +bool1225 isqnan -9.99999999 -> 0 +bool1226 isqnan 99.9999999 -> 0 +bool1227 isqnan -99.9999999 -> 0 +bool1228 isqnan 999.999999 -> 0 +bool1229 isqnan -999.999999 -> 0 +bool1230 isqnan 9999.99999 -> 0 +bool1231 isqnan -9999.99999 -> 0 +bool1232 isqnan 9999999.99 -> 0 +bool1233 isqnan -9999999.99 -> 0 +bool1234 isqnan 9.99999999E+100 -> 0 +bool1235 isqnan -9.99999999E+100 -> 0 +bool1236 isqnan 9.99999999E+990 -> 0 +bool1237 isqnan -9.99999999E+990 -> 0 +bool1238 isqnan 9.99999999E+991 -> 0 +bool1239 isqnan -9.99999999E+991 -> 0 +bool1240 isqnan 9.99999999E+992 -> 0 +bool1241 isqnan -9.99999999E+992 -> 0 +bool1242 isqnan 9.99999999E+998 -> 0 +bool1243 isqnan -9.99999999E+998 -> 0 +bool1244 isqnan 9.99999999E+999 -> 0 +bool1245 isqnan -9.99999999E+999 -> 0 +bool1246 isqnan 9.99999999E+1000 -> 0 +bool1247 isqnan -9.99999999E+1000 -> 0 +bool1248 isqnan 9.99999999E+2000 -> 0 +bool1249 isqnan -9.99999999E+2000 -> 0 +bool1250 isqnan Infinity -> 0 +bool1251 isqnan -Infinity -> 0 +bool1252 isqnan NaN -> 1 +bool1253 isqnan -NaN -> 1 +bool1254 isqnan NaN123 -> 1 +bool1255 isqnan -NaN123 -> 1 +bool1256 isqnan sNaN -> 0 +bool1257 isqnan -sNaN -> 0 +bool1258 isqnan sNaN123 -> 0 +bool1259 isqnan -sNaN123 -> 0 +bool1260 issigned 0E-2000 -> 0 +bool1261 issigned -0E-2000 -> 1 +bool1262 issigned 0E-1008 -> 0 +bool1263 issigned -0E-1008 -> 1 +bool1264 issigned 0E-1007 -> 0 +bool1265 issigned -0E-1007 -> 1 +bool1266 issigned 0E-1006 -> 0 +bool1267 issigned -0E-1006 -> 1 +bool1268 issigned 0E-1000 -> 0 +bool1269 issigned -0E-1000 -> 1 +bool1270 issigned 0E-999 -> 0 +bool1271 issigned -0E-999 -> 1 +bool1272 issigned 0E-998 -> 0 +bool1273 issigned -0E-998 -> 1 +bool1274 issigned 0E-100 -> 0 +bool1275 issigned -0E-100 -> 1 +bool1276 issigned 0.000000 -> 0 +bool1277 issigned -0.000000 -> 1 +bool1278 issigned 0.000 -> 0 +bool1279 issigned -0.000 -> 1 +bool1280 issigned 0.00 -> 0 +bool1281 issigned -0.00 -> 1 +bool1282 issigned 0.0 -> 0 +bool1283 issigned -0.0 -> 1 +bool1284 issigned 0 -> 0 +bool1285 issigned -0 -> 1 +bool1286 issigned 0E+1 -> 0 +bool1287 issigned -0E+1 -> 1 +bool1288 issigned 0E+2 -> 0 +bool1289 issigned -0E+2 -> 1 +bool1290 issigned 0E+3 -> 0 +bool1291 issigned -0E+3 -> 1 +bool1292 issigned 0E+6 -> 0 +bool1293 issigned -0E+6 -> 1 +bool1294 issigned 0E+100 -> 0 +bool1295 issigned -0E+100 -> 1 +bool1296 issigned 0E+990 -> 0 +bool1297 issigned -0E+990 -> 1 +bool1298 issigned 0E+991 -> 0 +bool1299 issigned -0E+991 -> 1 +bool1300 issigned 0E+992 -> 0 +bool1301 issigned -0E+992 -> 1 +bool1302 issigned 0E+998 -> 0 +bool1303 issigned -0E+998 -> 1 +bool1304 issigned 0E+999 -> 0 +bool1305 issigned -0E+999 -> 1 +bool1306 issigned 0E+1000 -> 0 +bool1307 issigned -0E+1000 -> 1 +bool1308 issigned 0E+2000 -> 0 +bool1309 issigned -0E+2000 -> 1 +bool1310 issigned 1E-2000 -> 0 +bool1311 issigned -1E-2000 -> 1 +bool1312 issigned 1E-1008 -> 0 +bool1313 issigned -1E-1008 -> 1 +bool1314 issigned 1E-1007 -> 0 +bool1315 issigned -1E-1007 -> 1 +bool1316 issigned 1E-1006 -> 0 +bool1317 issigned -1E-1006 -> 1 +bool1318 issigned 1E-1000 -> 0 +bool1319 issigned -1E-1000 -> 1 +bool1320 issigned 1E-999 -> 0 +bool1321 issigned -1E-999 -> 1 +bool1322 issigned 1E-998 -> 0 +bool1323 issigned -1E-998 -> 1 +bool1324 issigned 1E-100 -> 0 +bool1325 issigned -1E-100 -> 1 +bool1326 issigned 0.000001 -> 0 +bool1327 issigned -0.000001 -> 1 +bool1328 issigned 0.001 -> 0 +bool1329 issigned -0.001 -> 1 +bool1330 issigned 0.01 -> 0 +bool1331 issigned -0.01 -> 1 +bool1332 issigned 0.1 -> 0 +bool1333 issigned -0.1 -> 1 +bool1334 issigned 1 -> 0 +bool1335 issigned -1 -> 1 +bool1336 issigned 1E+1 -> 0 +bool1337 issigned -1E+1 -> 1 +bool1338 issigned 1E+2 -> 0 +bool1339 issigned -1E+2 -> 1 +bool1340 issigned 1E+3 -> 0 +bool1341 issigned -1E+3 -> 1 +bool1342 issigned 1E+6 -> 0 +bool1343 issigned -1E+6 -> 1 +bool1344 issigned 1E+100 -> 0 +bool1345 issigned -1E+100 -> 1 +bool1346 issigned 1E+990 -> 0 +bool1347 issigned -1E+990 -> 1 +bool1348 issigned 1E+991 -> 0 +bool1349 issigned -1E+991 -> 1 +bool1350 issigned 1E+992 -> 0 +bool1351 issigned -1E+992 -> 1 +bool1352 issigned 1E+998 -> 0 +bool1353 issigned -1E+998 -> 1 +bool1354 issigned 1E+999 -> 0 +bool1355 issigned -1E+999 -> 1 +bool1356 issigned 1E+1000 -> 0 +bool1357 issigned -1E+1000 -> 1 +bool1358 issigned 1E+2000 -> 0 +bool1359 issigned -1E+2000 -> 1 +bool1360 issigned 9E-2000 -> 0 +bool1361 issigned -9E-2000 -> 1 +bool1362 issigned 9E-1008 -> 0 +bool1363 issigned -9E-1008 -> 1 +bool1364 issigned 9E-1007 -> 0 +bool1365 issigned -9E-1007 -> 1 +bool1366 issigned 9E-1006 -> 0 +bool1367 issigned -9E-1006 -> 1 +bool1368 issigned 9E-1000 -> 0 +bool1369 issigned -9E-1000 -> 1 +bool1370 issigned 9E-999 -> 0 +bool1371 issigned -9E-999 -> 1 +bool1372 issigned 9E-998 -> 0 +bool1373 issigned -9E-998 -> 1 +bool1374 issigned 9E-100 -> 0 +bool1375 issigned -9E-100 -> 1 +bool1376 issigned 0.000009 -> 0 +bool1377 issigned -0.000009 -> 1 +bool1378 issigned 0.009 -> 0 +bool1379 issigned -0.009 -> 1 +bool1380 issigned 0.09 -> 0 +bool1381 issigned -0.09 -> 1 +bool1382 issigned 0.9 -> 0 +bool1383 issigned -0.9 -> 1 +bool1384 issigned 9 -> 0 +bool1385 issigned -9 -> 1 +bool1386 issigned 9E+1 -> 0 +bool1387 issigned -9E+1 -> 1 +bool1388 issigned 9E+2 -> 0 +bool1389 issigned -9E+2 -> 1 +bool1390 issigned 9E+3 -> 0 +bool1391 issigned -9E+3 -> 1 +bool1392 issigned 9E+6 -> 0 +bool1393 issigned -9E+6 -> 1 +bool1394 issigned 9E+100 -> 0 +bool1395 issigned -9E+100 -> 1 +bool1396 issigned 9E+990 -> 0 +bool1397 issigned -9E+990 -> 1 +bool1398 issigned 9E+991 -> 0 +bool1399 issigned -9E+991 -> 1 +bool1400 issigned 9E+992 -> 0 +bool1401 issigned -9E+992 -> 1 +bool1402 issigned 9E+998 -> 0 +bool1403 issigned -9E+998 -> 1 +bool1404 issigned 9E+999 -> 0 +bool1405 issigned -9E+999 -> 1 +bool1406 issigned 9E+1000 -> 0 +bool1407 issigned -9E+1000 -> 1 +bool1408 issigned 9E+2000 -> 0 +bool1409 issigned -9E+2000 -> 1 +bool1410 issigned 9.99999999E-2000 -> 0 +bool1411 issigned -9.99999999E-2000 -> 1 +bool1412 issigned 9.99999999E-1008 -> 0 +bool1413 issigned -9.99999999E-1008 -> 1 +bool1414 issigned 9.99999999E-1007 -> 0 +bool1415 issigned -9.99999999E-1007 -> 1 +bool1416 issigned 9.99999999E-1006 -> 0 +bool1417 issigned -9.99999999E-1006 -> 1 +bool1418 issigned 9.99999999E-1000 -> 0 +bool1419 issigned -9.99999999E-1000 -> 1 +bool1420 issigned 9.99999999E-999 -> 0 +bool1421 issigned -9.99999999E-999 -> 1 +bool1422 issigned 9.99999999E-998 -> 0 +bool1423 issigned -9.99999999E-998 -> 1 +bool1424 issigned 9.99999999E-100 -> 0 +bool1425 issigned -9.99999999E-100 -> 1 +bool1426 issigned 0.00000999999999 -> 0 +bool1427 issigned -0.00000999999999 -> 1 +bool1428 issigned 0.00999999999 -> 0 +bool1429 issigned -0.00999999999 -> 1 +bool1430 issigned 0.0999999999 -> 0 +bool1431 issigned -0.0999999999 -> 1 +bool1432 issigned 0.999999999 -> 0 +bool1433 issigned -0.999999999 -> 1 +bool1434 issigned 9.99999999 -> 0 +bool1435 issigned -9.99999999 -> 1 +bool1436 issigned 99.9999999 -> 0 +bool1437 issigned -99.9999999 -> 1 +bool1438 issigned 999.999999 -> 0 +bool1439 issigned -999.999999 -> 1 +bool1440 issigned 9999.99999 -> 0 +bool1441 issigned -9999.99999 -> 1 +bool1442 issigned 9999999.99 -> 0 +bool1443 issigned -9999999.99 -> 1 +bool1444 issigned 9.99999999E+100 -> 0 +bool1445 issigned -9.99999999E+100 -> 1 +bool1446 issigned 9.99999999E+990 -> 0 +bool1447 issigned -9.99999999E+990 -> 1 +bool1448 issigned 9.99999999E+991 -> 0 +bool1449 issigned -9.99999999E+991 -> 1 +bool1450 issigned 9.99999999E+992 -> 0 +bool1451 issigned -9.99999999E+992 -> 1 +bool1452 issigned 9.99999999E+998 -> 0 +bool1453 issigned -9.99999999E+998 -> 1 +bool1454 issigned 9.99999999E+999 -> 0 +bool1455 issigned -9.99999999E+999 -> 1 +bool1456 issigned 9.99999999E+1000 -> 0 +bool1457 issigned -9.99999999E+1000 -> 1 +bool1458 issigned 9.99999999E+2000 -> 0 +bool1459 issigned -9.99999999E+2000 -> 1 +bool1460 issigned Infinity -> 0 +bool1461 issigned -Infinity -> 1 +bool1462 issigned NaN -> 0 +bool1463 issigned -NaN -> 1 +bool1464 issigned NaN123 -> 0 +bool1465 issigned -NaN123 -> 1 +bool1466 issigned sNaN -> 0 +bool1467 issigned -sNaN -> 1 +bool1468 issigned sNaN123 -> 0 +bool1469 issigned -sNaN123 -> 1 +bool1470 issnan 0E-2000 -> 0 +bool1471 issnan -0E-2000 -> 0 +bool1472 issnan 0E-1008 -> 0 +bool1473 issnan -0E-1008 -> 0 +bool1474 issnan 0E-1007 -> 0 +bool1475 issnan -0E-1007 -> 0 +bool1476 issnan 0E-1006 -> 0 +bool1477 issnan -0E-1006 -> 0 +bool1478 issnan 0E-1000 -> 0 +bool1479 issnan -0E-1000 -> 0 +bool1480 issnan 0E-999 -> 0 +bool1481 issnan -0E-999 -> 0 +bool1482 issnan 0E-998 -> 0 +bool1483 issnan -0E-998 -> 0 +bool1484 issnan 0E-100 -> 0 +bool1485 issnan -0E-100 -> 0 +bool1486 issnan 0.000000 -> 0 +bool1487 issnan -0.000000 -> 0 +bool1488 issnan 0.000 -> 0 +bool1489 issnan -0.000 -> 0 +bool1490 issnan 0.00 -> 0 +bool1491 issnan -0.00 -> 0 +bool1492 issnan 0.0 -> 0 +bool1493 issnan -0.0 -> 0 +bool1494 issnan 0 -> 0 +bool1495 issnan -0 -> 0 +bool1496 issnan 0E+1 -> 0 +bool1497 issnan -0E+1 -> 0 +bool1498 issnan 0E+2 -> 0 +bool1499 issnan -0E+2 -> 0 +bool1500 issnan 0E+3 -> 0 +bool1501 issnan -0E+3 -> 0 +bool1502 issnan 0E+6 -> 0 +bool1503 issnan -0E+6 -> 0 +bool1504 issnan 0E+100 -> 0 +bool1505 issnan -0E+100 -> 0 +bool1506 issnan 0E+990 -> 0 +bool1507 issnan -0E+990 -> 0 +bool1508 issnan 0E+991 -> 0 +bool1509 issnan -0E+991 -> 0 +bool1510 issnan 0E+992 -> 0 +bool1511 issnan -0E+992 -> 0 +bool1512 issnan 0E+998 -> 0 +bool1513 issnan -0E+998 -> 0 +bool1514 issnan 0E+999 -> 0 +bool1515 issnan -0E+999 -> 0 +bool1516 issnan 0E+1000 -> 0 +bool1517 issnan -0E+1000 -> 0 +bool1518 issnan 0E+2000 -> 0 +bool1519 issnan -0E+2000 -> 0 +bool1520 issnan 1E-2000 -> 0 +bool1521 issnan -1E-2000 -> 0 +bool1522 issnan 1E-1008 -> 0 +bool1523 issnan -1E-1008 -> 0 +bool1524 issnan 1E-1007 -> 0 +bool1525 issnan -1E-1007 -> 0 +bool1526 issnan 1E-1006 -> 0 +bool1527 issnan -1E-1006 -> 0 +bool1528 issnan 1E-1000 -> 0 +bool1529 issnan -1E-1000 -> 0 +bool1530 issnan 1E-999 -> 0 +bool1531 issnan -1E-999 -> 0 +bool1532 issnan 1E-998 -> 0 +bool1533 issnan -1E-998 -> 0 +bool1534 issnan 1E-100 -> 0 +bool1535 issnan -1E-100 -> 0 +bool1536 issnan 0.000001 -> 0 +bool1537 issnan -0.000001 -> 0 +bool1538 issnan 0.001 -> 0 +bool1539 issnan -0.001 -> 0 +bool1540 issnan 0.01 -> 0 +bool1541 issnan -0.01 -> 0 +bool1542 issnan 0.1 -> 0 +bool1543 issnan -0.1 -> 0 +bool1544 issnan 1 -> 0 +bool1545 issnan -1 -> 0 +bool1546 issnan 1E+1 -> 0 +bool1547 issnan -1E+1 -> 0 +bool1548 issnan 1E+2 -> 0 +bool1549 issnan -1E+2 -> 0 +bool1550 issnan 1E+3 -> 0 +bool1551 issnan -1E+3 -> 0 +bool1552 issnan 1E+6 -> 0 +bool1553 issnan -1E+6 -> 0 +bool1554 issnan 1E+100 -> 0 +bool1555 issnan -1E+100 -> 0 +bool1556 issnan 1E+990 -> 0 +bool1557 issnan -1E+990 -> 0 +bool1558 issnan 1E+991 -> 0 +bool1559 issnan -1E+991 -> 0 +bool1560 issnan 1E+992 -> 0 +bool1561 issnan -1E+992 -> 0 +bool1562 issnan 1E+998 -> 0 +bool1563 issnan -1E+998 -> 0 +bool1564 issnan 1E+999 -> 0 +bool1565 issnan -1E+999 -> 0 +bool1566 issnan 1E+1000 -> 0 +bool1567 issnan -1E+1000 -> 0 +bool1568 issnan 1E+2000 -> 0 +bool1569 issnan -1E+2000 -> 0 +bool1570 issnan 9E-2000 -> 0 +bool1571 issnan -9E-2000 -> 0 +bool1572 issnan 9E-1008 -> 0 +bool1573 issnan -9E-1008 -> 0 +bool1574 issnan 9E-1007 -> 0 +bool1575 issnan -9E-1007 -> 0 +bool1576 issnan 9E-1006 -> 0 +bool1577 issnan -9E-1006 -> 0 +bool1578 issnan 9E-1000 -> 0 +bool1579 issnan -9E-1000 -> 0 +bool1580 issnan 9E-999 -> 0 +bool1581 issnan -9E-999 -> 0 +bool1582 issnan 9E-998 -> 0 +bool1583 issnan -9E-998 -> 0 +bool1584 issnan 9E-100 -> 0 +bool1585 issnan -9E-100 -> 0 +bool1586 issnan 0.000009 -> 0 +bool1587 issnan -0.000009 -> 0 +bool1588 issnan 0.009 -> 0 +bool1589 issnan -0.009 -> 0 +bool1590 issnan 0.09 -> 0 +bool1591 issnan -0.09 -> 0 +bool1592 issnan 0.9 -> 0 +bool1593 issnan -0.9 -> 0 +bool1594 issnan 9 -> 0 +bool1595 issnan -9 -> 0 +bool1596 issnan 9E+1 -> 0 +bool1597 issnan -9E+1 -> 0 +bool1598 issnan 9E+2 -> 0 +bool1599 issnan -9E+2 -> 0 +bool1600 issnan 9E+3 -> 0 +bool1601 issnan -9E+3 -> 0 +bool1602 issnan 9E+6 -> 0 +bool1603 issnan -9E+6 -> 0 +bool1604 issnan 9E+100 -> 0 +bool1605 issnan -9E+100 -> 0 +bool1606 issnan 9E+990 -> 0 +bool1607 issnan -9E+990 -> 0 +bool1608 issnan 9E+991 -> 0 +bool1609 issnan -9E+991 -> 0 +bool1610 issnan 9E+992 -> 0 +bool1611 issnan -9E+992 -> 0 +bool1612 issnan 9E+998 -> 0 +bool1613 issnan -9E+998 -> 0 +bool1614 issnan 9E+999 -> 0 +bool1615 issnan -9E+999 -> 0 +bool1616 issnan 9E+1000 -> 0 +bool1617 issnan -9E+1000 -> 0 +bool1618 issnan 9E+2000 -> 0 +bool1619 issnan -9E+2000 -> 0 +bool1620 issnan 9.99999999E-2000 -> 0 +bool1621 issnan -9.99999999E-2000 -> 0 +bool1622 issnan 9.99999999E-1008 -> 0 +bool1623 issnan -9.99999999E-1008 -> 0 +bool1624 issnan 9.99999999E-1007 -> 0 +bool1625 issnan -9.99999999E-1007 -> 0 +bool1626 issnan 9.99999999E-1006 -> 0 +bool1627 issnan -9.99999999E-1006 -> 0 +bool1628 issnan 9.99999999E-1000 -> 0 +bool1629 issnan -9.99999999E-1000 -> 0 +bool1630 issnan 9.99999999E-999 -> 0 +bool1631 issnan -9.99999999E-999 -> 0 +bool1632 issnan 9.99999999E-998 -> 0 +bool1633 issnan -9.99999999E-998 -> 0 +bool1634 issnan 9.99999999E-100 -> 0 +bool1635 issnan -9.99999999E-100 -> 0 +bool1636 issnan 0.00000999999999 -> 0 +bool1637 issnan -0.00000999999999 -> 0 +bool1638 issnan 0.00999999999 -> 0 +bool1639 issnan -0.00999999999 -> 0 +bool1640 issnan 0.0999999999 -> 0 +bool1641 issnan -0.0999999999 -> 0 +bool1642 issnan 0.999999999 -> 0 +bool1643 issnan -0.999999999 -> 0 +bool1644 issnan 9.99999999 -> 0 +bool1645 issnan -9.99999999 -> 0 +bool1646 issnan 99.9999999 -> 0 +bool1647 issnan -99.9999999 -> 0 +bool1648 issnan 999.999999 -> 0 +bool1649 issnan -999.999999 -> 0 +bool1650 issnan 9999.99999 -> 0 +bool1651 issnan -9999.99999 -> 0 +bool1652 issnan 9999999.99 -> 0 +bool1653 issnan -9999999.99 -> 0 +bool1654 issnan 9.99999999E+100 -> 0 +bool1655 issnan -9.99999999E+100 -> 0 +bool1656 issnan 9.99999999E+990 -> 0 +bool1657 issnan -9.99999999E+990 -> 0 +bool1658 issnan 9.99999999E+991 -> 0 +bool1659 issnan -9.99999999E+991 -> 0 +bool1660 issnan 9.99999999E+992 -> 0 +bool1661 issnan -9.99999999E+992 -> 0 +bool1662 issnan 9.99999999E+998 -> 0 +bool1663 issnan -9.99999999E+998 -> 0 +bool1664 issnan 9.99999999E+999 -> 0 +bool1665 issnan -9.99999999E+999 -> 0 +bool1666 issnan 9.99999999E+1000 -> 0 +bool1667 issnan -9.99999999E+1000 -> 0 +bool1668 issnan 9.99999999E+2000 -> 0 +bool1669 issnan -9.99999999E+2000 -> 0 +bool1670 issnan Infinity -> 0 +bool1671 issnan -Infinity -> 0 +bool1672 issnan NaN -> 0 +bool1673 issnan -NaN -> 0 +bool1674 issnan NaN123 -> 0 +bool1675 issnan -NaN123 -> 0 +bool1676 issnan sNaN -> 1 +bool1677 issnan -sNaN -> 1 +bool1678 issnan sNaN123 -> 1 +bool1679 issnan -sNaN123 -> 1 +bool1680 issubnormal 0E-2000 -> 0 +bool1681 issubnormal -0E-2000 -> 0 +bool1682 issubnormal 0E-1008 -> 0 +bool1683 issubnormal -0E-1008 -> 0 +bool1684 issubnormal 0E-1007 -> 0 +bool1685 issubnormal -0E-1007 -> 0 +bool1686 issubnormal 0E-1006 -> 0 +bool1687 issubnormal -0E-1006 -> 0 +bool1688 issubnormal 0E-1000 -> 0 +bool1689 issubnormal -0E-1000 -> 0 +bool1690 issubnormal 0E-999 -> 0 +bool1691 issubnormal -0E-999 -> 0 +bool1692 issubnormal 0E-998 -> 0 +bool1693 issubnormal -0E-998 -> 0 +bool1694 issubnormal 0E-100 -> 0 +bool1695 issubnormal -0E-100 -> 0 +bool1696 issubnormal 0.000000 -> 0 +bool1697 issubnormal -0.000000 -> 0 +bool1698 issubnormal 0.000 -> 0 +bool1699 issubnormal -0.000 -> 0 +bool1700 issubnormal 0.00 -> 0 +bool1701 issubnormal -0.00 -> 0 +bool1702 issubnormal 0.0 -> 0 +bool1703 issubnormal -0.0 -> 0 +bool1704 issubnormal 0 -> 0 +bool1705 issubnormal -0 -> 0 +bool1706 issubnormal 0E+1 -> 0 +bool1707 issubnormal -0E+1 -> 0 +bool1708 issubnormal 0E+2 -> 0 +bool1709 issubnormal -0E+2 -> 0 +bool1710 issubnormal 0E+3 -> 0 +bool1711 issubnormal -0E+3 -> 0 +bool1712 issubnormal 0E+6 -> 0 +bool1713 issubnormal -0E+6 -> 0 +bool1714 issubnormal 0E+100 -> 0 +bool1715 issubnormal -0E+100 -> 0 +bool1716 issubnormal 0E+990 -> 0 +bool1717 issubnormal -0E+990 -> 0 +bool1718 issubnormal 0E+991 -> 0 +bool1719 issubnormal -0E+991 -> 0 +bool1720 issubnormal 0E+992 -> 0 +bool1721 issubnormal -0E+992 -> 0 +bool1722 issubnormal 0E+998 -> 0 +bool1723 issubnormal -0E+998 -> 0 +bool1724 issubnormal 0E+999 -> 0 +bool1725 issubnormal -0E+999 -> 0 +bool1726 issubnormal 0E+1000 -> 0 +bool1727 issubnormal -0E+1000 -> 0 +bool1728 issubnormal 0E+2000 -> 0 +bool1729 issubnormal -0E+2000 -> 0 +bool1730 issubnormal 1E-2000 -> 1 +bool1731 issubnormal -1E-2000 -> 1 +bool1732 issubnormal 1E-1008 -> 1 +bool1733 issubnormal -1E-1008 -> 1 +bool1734 issubnormal 1E-1007 -> 1 +bool1735 issubnormal -1E-1007 -> 1 +bool1736 issubnormal 1E-1006 -> 1 +bool1737 issubnormal -1E-1006 -> 1 +bool1738 issubnormal 1E-1000 -> 1 +bool1739 issubnormal -1E-1000 -> 1 +bool1740 issubnormal 1E-999 -> 0 +bool1741 issubnormal -1E-999 -> 0 +bool1742 issubnormal 1E-998 -> 0 +bool1743 issubnormal -1E-998 -> 0 +bool1744 issubnormal 1E-100 -> 0 +bool1745 issubnormal -1E-100 -> 0 +bool1746 issubnormal 0.000001 -> 0 +bool1747 issubnormal -0.000001 -> 0 +bool1748 issubnormal 0.001 -> 0 +bool1749 issubnormal -0.001 -> 0 +bool1750 issubnormal 0.01 -> 0 +bool1751 issubnormal -0.01 -> 0 +bool1752 issubnormal 0.1 -> 0 +bool1753 issubnormal -0.1 -> 0 +bool1754 issubnormal 1 -> 0 +bool1755 issubnormal -1 -> 0 +bool1756 issubnormal 1E+1 -> 0 +bool1757 issubnormal -1E+1 -> 0 +bool1758 issubnormal 1E+2 -> 0 +bool1759 issubnormal -1E+2 -> 0 +bool1760 issubnormal 1E+3 -> 0 +bool1761 issubnormal -1E+3 -> 0 +bool1762 issubnormal 1E+6 -> 0 +bool1763 issubnormal -1E+6 -> 0 +bool1764 issubnormal 1E+100 -> 0 +bool1765 issubnormal -1E+100 -> 0 +bool1766 issubnormal 1E+990 -> 0 +bool1767 issubnormal -1E+990 -> 0 +bool1768 issubnormal 1E+991 -> 0 +bool1769 issubnormal -1E+991 -> 0 +bool1770 issubnormal 1E+992 -> 0 +bool1771 issubnormal -1E+992 -> 0 +bool1772 issubnormal 1E+998 -> 0 +bool1773 issubnormal -1E+998 -> 0 +bool1774 issubnormal 1E+999 -> 0 +bool1775 issubnormal -1E+999 -> 0 +bool1776 issubnormal 1E+1000 -> 0 +bool1777 issubnormal -1E+1000 -> 0 +bool1778 issubnormal 1E+2000 -> 0 +bool1779 issubnormal -1E+2000 -> 0 +bool1780 issubnormal 9E-2000 -> 1 +bool1781 issubnormal -9E-2000 -> 1 +bool1782 issubnormal 9E-1008 -> 1 +bool1783 issubnormal -9E-1008 -> 1 +bool1784 issubnormal 9E-1007 -> 1 +bool1785 issubnormal -9E-1007 -> 1 +bool1786 issubnormal 9E-1006 -> 1 +bool1787 issubnormal -9E-1006 -> 1 +bool1788 issubnormal 9E-1000 -> 1 +bool1789 issubnormal -9E-1000 -> 1 +bool1790 issubnormal 9E-999 -> 0 +bool1791 issubnormal -9E-999 -> 0 +bool1792 issubnormal 9E-998 -> 0 +bool1793 issubnormal -9E-998 -> 0 +bool1794 issubnormal 9E-100 -> 0 +bool1795 issubnormal -9E-100 -> 0 +bool1796 issubnormal 0.000009 -> 0 +bool1797 issubnormal -0.000009 -> 0 +bool1798 issubnormal 0.009 -> 0 +bool1799 issubnormal -0.009 -> 0 +bool1800 issubnormal 0.09 -> 0 +bool1801 issubnormal -0.09 -> 0 +bool1802 issubnormal 0.9 -> 0 +bool1803 issubnormal -0.9 -> 0 +bool1804 issubnormal 9 -> 0 +bool1805 issubnormal -9 -> 0 +bool1806 issubnormal 9E+1 -> 0 +bool1807 issubnormal -9E+1 -> 0 +bool1808 issubnormal 9E+2 -> 0 +bool1809 issubnormal -9E+2 -> 0 +bool1810 issubnormal 9E+3 -> 0 +bool1811 issubnormal -9E+3 -> 0 +bool1812 issubnormal 9E+6 -> 0 +bool1813 issubnormal -9E+6 -> 0 +bool1814 issubnormal 9E+100 -> 0 +bool1815 issubnormal -9E+100 -> 0 +bool1816 issubnormal 9E+990 -> 0 +bool1817 issubnormal -9E+990 -> 0 +bool1818 issubnormal 9E+991 -> 0 +bool1819 issubnormal -9E+991 -> 0 +bool1820 issubnormal 9E+992 -> 0 +bool1821 issubnormal -9E+992 -> 0 +bool1822 issubnormal 9E+998 -> 0 +bool1823 issubnormal -9E+998 -> 0 +bool1824 issubnormal 9E+999 -> 0 +bool1825 issubnormal -9E+999 -> 0 +bool1826 issubnormal 9E+1000 -> 0 +bool1827 issubnormal -9E+1000 -> 0 +bool1828 issubnormal 9E+2000 -> 0 +bool1829 issubnormal -9E+2000 -> 0 +bool1830 issubnormal 9.99999999E-2000 -> 1 +bool1831 issubnormal -9.99999999E-2000 -> 1 +bool1832 issubnormal 9.99999999E-1008 -> 1 +bool1833 issubnormal -9.99999999E-1008 -> 1 +bool1834 issubnormal 9.99999999E-1007 -> 1 +bool1835 issubnormal -9.99999999E-1007 -> 1 +bool1836 issubnormal 9.99999999E-1006 -> 1 +bool1837 issubnormal -9.99999999E-1006 -> 1 +bool1838 issubnormal 9.99999999E-1000 -> 1 +bool1839 issubnormal -9.99999999E-1000 -> 1 +bool1840 issubnormal 9.99999999E-999 -> 0 +bool1841 issubnormal -9.99999999E-999 -> 0 +bool1842 issubnormal 9.99999999E-998 -> 0 +bool1843 issubnormal -9.99999999E-998 -> 0 +bool1844 issubnormal 9.99999999E-100 -> 0 +bool1845 issubnormal -9.99999999E-100 -> 0 +bool1846 issubnormal 0.00000999999999 -> 0 +bool1847 issubnormal -0.00000999999999 -> 0 +bool1848 issubnormal 0.00999999999 -> 0 +bool1849 issubnormal -0.00999999999 -> 0 +bool1850 issubnormal 0.0999999999 -> 0 +bool1851 issubnormal -0.0999999999 -> 0 +bool1852 issubnormal 0.999999999 -> 0 +bool1853 issubnormal -0.999999999 -> 0 +bool1854 issubnormal 9.99999999 -> 0 +bool1855 issubnormal -9.99999999 -> 0 +bool1856 issubnormal 99.9999999 -> 0 +bool1857 issubnormal -99.9999999 -> 0 +bool1858 issubnormal 999.999999 -> 0 +bool1859 issubnormal -999.999999 -> 0 +bool1860 issubnormal 9999.99999 -> 0 +bool1861 issubnormal -9999.99999 -> 0 +bool1862 issubnormal 9999999.99 -> 0 +bool1863 issubnormal -9999999.99 -> 0 +bool1864 issubnormal 9.99999999E+100 -> 0 +bool1865 issubnormal -9.99999999E+100 -> 0 +bool1866 issubnormal 9.99999999E+990 -> 0 +bool1867 issubnormal -9.99999999E+990 -> 0 +bool1868 issubnormal 9.99999999E+991 -> 0 +bool1869 issubnormal -9.99999999E+991 -> 0 +bool1870 issubnormal 9.99999999E+992 -> 0 +bool1871 issubnormal -9.99999999E+992 -> 0 +bool1872 issubnormal 9.99999999E+998 -> 0 +bool1873 issubnormal -9.99999999E+998 -> 0 +bool1874 issubnormal 9.99999999E+999 -> 0 +bool1875 issubnormal -9.99999999E+999 -> 0 +bool1876 issubnormal 9.99999999E+1000 -> 0 +bool1877 issubnormal -9.99999999E+1000 -> 0 +bool1878 issubnormal 9.99999999E+2000 -> 0 +bool1879 issubnormal -9.99999999E+2000 -> 0 +bool1880 issubnormal Infinity -> 0 +bool1881 issubnormal -Infinity -> 0 +bool1882 issubnormal NaN -> 0 +bool1883 issubnormal -NaN -> 0 +bool1884 issubnormal NaN123 -> 0 +bool1885 issubnormal -NaN123 -> 0 +bool1886 issubnormal sNaN -> 0 +bool1887 issubnormal -sNaN -> 0 +bool1888 issubnormal sNaN123 -> 0 +bool1889 issubnormal -sNaN123 -> 0 +bool1890 iszero 0E-2000 -> 1 +bool1891 iszero -0E-2000 -> 1 +bool1892 iszero 0E-1008 -> 1 +bool1893 iszero -0E-1008 -> 1 +bool1894 iszero 0E-1007 -> 1 +bool1895 iszero -0E-1007 -> 1 +bool1896 iszero 0E-1006 -> 1 +bool1897 iszero -0E-1006 -> 1 +bool1898 iszero 0E-1000 -> 1 +bool1899 iszero -0E-1000 -> 1 +bool1900 iszero 0E-999 -> 1 +bool1901 iszero -0E-999 -> 1 +bool1902 iszero 0E-998 -> 1 +bool1903 iszero -0E-998 -> 1 +bool1904 iszero 0E-100 -> 1 +bool1905 iszero -0E-100 -> 1 +bool1906 iszero 0.000000 -> 1 +bool1907 iszero -0.000000 -> 1 +bool1908 iszero 0.000 -> 1 +bool1909 iszero -0.000 -> 1 +bool1910 iszero 0.00 -> 1 +bool1911 iszero -0.00 -> 1 +bool1912 iszero 0.0 -> 1 +bool1913 iszero -0.0 -> 1 +bool1914 iszero 0 -> 1 +bool1915 iszero -0 -> 1 +bool1916 iszero 0E+1 -> 1 +bool1917 iszero -0E+1 -> 1 +bool1918 iszero 0E+2 -> 1 +bool1919 iszero -0E+2 -> 1 +bool1920 iszero 0E+3 -> 1 +bool1921 iszero -0E+3 -> 1 +bool1922 iszero 0E+6 -> 1 +bool1923 iszero -0E+6 -> 1 +bool1924 iszero 0E+100 -> 1 +bool1925 iszero -0E+100 -> 1 +bool1926 iszero 0E+990 -> 1 +bool1927 iszero -0E+990 -> 1 +bool1928 iszero 0E+991 -> 1 +bool1929 iszero -0E+991 -> 1 +bool1930 iszero 0E+992 -> 1 +bool1931 iszero -0E+992 -> 1 +bool1932 iszero 0E+998 -> 1 +bool1933 iszero -0E+998 -> 1 +bool1934 iszero 0E+999 -> 1 +bool1935 iszero -0E+999 -> 1 +bool1936 iszero 0E+1000 -> 1 +bool1937 iszero -0E+1000 -> 1 +bool1938 iszero 0E+2000 -> 1 +bool1939 iszero -0E+2000 -> 1 +bool1940 iszero 1E-2000 -> 0 +bool1941 iszero -1E-2000 -> 0 +bool1942 iszero 1E-1008 -> 0 +bool1943 iszero -1E-1008 -> 0 +bool1944 iszero 1E-1007 -> 0 +bool1945 iszero -1E-1007 -> 0 +bool1946 iszero 1E-1006 -> 0 +bool1947 iszero -1E-1006 -> 0 +bool1948 iszero 1E-1000 -> 0 +bool1949 iszero -1E-1000 -> 0 +bool1950 iszero 1E-999 -> 0 +bool1951 iszero -1E-999 -> 0 +bool1952 iszero 1E-998 -> 0 +bool1953 iszero -1E-998 -> 0 +bool1954 iszero 1E-100 -> 0 +bool1955 iszero -1E-100 -> 0 +bool1956 iszero 0.000001 -> 0 +bool1957 iszero -0.000001 -> 0 +bool1958 iszero 0.001 -> 0 +bool1959 iszero -0.001 -> 0 +bool1960 iszero 0.01 -> 0 +bool1961 iszero -0.01 -> 0 +bool1962 iszero 0.1 -> 0 +bool1963 iszero -0.1 -> 0 +bool1964 iszero 1 -> 0 +bool1965 iszero -1 -> 0 +bool1966 iszero 1E+1 -> 0 +bool1967 iszero -1E+1 -> 0 +bool1968 iszero 1E+2 -> 0 +bool1969 iszero -1E+2 -> 0 +bool1970 iszero 1E+3 -> 0 +bool1971 iszero -1E+3 -> 0 +bool1972 iszero 1E+6 -> 0 +bool1973 iszero -1E+6 -> 0 +bool1974 iszero 1E+100 -> 0 +bool1975 iszero -1E+100 -> 0 +bool1976 iszero 1E+990 -> 0 +bool1977 iszero -1E+990 -> 0 +bool1978 iszero 1E+991 -> 0 +bool1979 iszero -1E+991 -> 0 +bool1980 iszero 1E+992 -> 0 +bool1981 iszero -1E+992 -> 0 +bool1982 iszero 1E+998 -> 0 +bool1983 iszero -1E+998 -> 0 +bool1984 iszero 1E+999 -> 0 +bool1985 iszero -1E+999 -> 0 +bool1986 iszero 1E+1000 -> 0 +bool1987 iszero -1E+1000 -> 0 +bool1988 iszero 1E+2000 -> 0 +bool1989 iszero -1E+2000 -> 0 +bool1990 iszero 9E-2000 -> 0 +bool1991 iszero -9E-2000 -> 0 +bool1992 iszero 9E-1008 -> 0 +bool1993 iszero -9E-1008 -> 0 +bool1994 iszero 9E-1007 -> 0 +bool1995 iszero -9E-1007 -> 0 +bool1996 iszero 9E-1006 -> 0 +bool1997 iszero -9E-1006 -> 0 +bool1998 iszero 9E-1000 -> 0 +bool1999 iszero -9E-1000 -> 0 +bool2000 iszero 9E-999 -> 0 +bool2001 iszero -9E-999 -> 0 +bool2002 iszero 9E-998 -> 0 +bool2003 iszero -9E-998 -> 0 +bool2004 iszero 9E-100 -> 0 +bool2005 iszero -9E-100 -> 0 +bool2006 iszero 0.000009 -> 0 +bool2007 iszero -0.000009 -> 0 +bool2008 iszero 0.009 -> 0 +bool2009 iszero -0.009 -> 0 +bool2010 iszero 0.09 -> 0 +bool2011 iszero -0.09 -> 0 +bool2012 iszero 0.9 -> 0 +bool2013 iszero -0.9 -> 0 +bool2014 iszero 9 -> 0 +bool2015 iszero -9 -> 0 +bool2016 iszero 9E+1 -> 0 +bool2017 iszero -9E+1 -> 0 +bool2018 iszero 9E+2 -> 0 +bool2019 iszero -9E+2 -> 0 +bool2020 iszero 9E+3 -> 0 +bool2021 iszero -9E+3 -> 0 +bool2022 iszero 9E+6 -> 0 +bool2023 iszero -9E+6 -> 0 +bool2024 iszero 9E+100 -> 0 +bool2025 iszero -9E+100 -> 0 +bool2026 iszero 9E+990 -> 0 +bool2027 iszero -9E+990 -> 0 +bool2028 iszero 9E+991 -> 0 +bool2029 iszero -9E+991 -> 0 +bool2030 iszero 9E+992 -> 0 +bool2031 iszero -9E+992 -> 0 +bool2032 iszero 9E+998 -> 0 +bool2033 iszero -9E+998 -> 0 +bool2034 iszero 9E+999 -> 0 +bool2035 iszero -9E+999 -> 0 +bool2036 iszero 9E+1000 -> 0 +bool2037 iszero -9E+1000 -> 0 +bool2038 iszero 9E+2000 -> 0 +bool2039 iszero -9E+2000 -> 0 +bool2040 iszero 9.99999999E-2000 -> 0 +bool2041 iszero -9.99999999E-2000 -> 0 +bool2042 iszero 9.99999999E-1008 -> 0 +bool2043 iszero -9.99999999E-1008 -> 0 +bool2044 iszero 9.99999999E-1007 -> 0 +bool2045 iszero -9.99999999E-1007 -> 0 +bool2046 iszero 9.99999999E-1006 -> 0 +bool2047 iszero -9.99999999E-1006 -> 0 +bool2048 iszero 9.99999999E-1000 -> 0 +bool2049 iszero -9.99999999E-1000 -> 0 +bool2050 iszero 9.99999999E-999 -> 0 +bool2051 iszero -9.99999999E-999 -> 0 +bool2052 iszero 9.99999999E-998 -> 0 +bool2053 iszero -9.99999999E-998 -> 0 +bool2054 iszero 9.99999999E-100 -> 0 +bool2055 iszero -9.99999999E-100 -> 0 +bool2056 iszero 0.00000999999999 -> 0 +bool2057 iszero -0.00000999999999 -> 0 +bool2058 iszero 0.00999999999 -> 0 +bool2059 iszero -0.00999999999 -> 0 +bool2060 iszero 0.0999999999 -> 0 +bool2061 iszero -0.0999999999 -> 0 +bool2062 iszero 0.999999999 -> 0 +bool2063 iszero -0.999999999 -> 0 +bool2064 iszero 9.99999999 -> 0 +bool2065 iszero -9.99999999 -> 0 +bool2066 iszero 99.9999999 -> 0 +bool2067 iszero -99.9999999 -> 0 +bool2068 iszero 999.999999 -> 0 +bool2069 iszero -999.999999 -> 0 +bool2070 iszero 9999.99999 -> 0 +bool2071 iszero -9999.99999 -> 0 +bool2072 iszero 9999999.99 -> 0 +bool2073 iszero -9999999.99 -> 0 +bool2074 iszero 9.99999999E+100 -> 0 +bool2075 iszero -9.99999999E+100 -> 0 +bool2076 iszero 9.99999999E+990 -> 0 +bool2077 iszero -9.99999999E+990 -> 0 +bool2078 iszero 9.99999999E+991 -> 0 +bool2079 iszero -9.99999999E+991 -> 0 +bool2080 iszero 9.99999999E+992 -> 0 +bool2081 iszero -9.99999999E+992 -> 0 +bool2082 iszero 9.99999999E+998 -> 0 +bool2083 iszero -9.99999999E+998 -> 0 +bool2084 iszero 9.99999999E+999 -> 0 +bool2085 iszero -9.99999999E+999 -> 0 +bool2086 iszero 9.99999999E+1000 -> 0 +bool2087 iszero -9.99999999E+1000 -> 0 +bool2088 iszero 9.99999999E+2000 -> 0 +bool2089 iszero -9.99999999E+2000 -> 0 +bool2090 iszero Infinity -> 0 +bool2091 iszero -Infinity -> 0 +bool2092 iszero NaN -> 0 +bool2093 iszero -NaN -> 0 +bool2094 iszero NaN123 -> 0 +bool2095 iszero -NaN123 -> 0 +bool2096 iszero sNaN -> 0 +bool2097 iszero -sNaN -> 0 +bool2098 iszero sNaN123 -> 0 +bool2099 iszero -sNaN123 -> 0 + ------------------------------------------------------------------------ -- The following tests (pwmx0 through pwmx440) are for the -- -- three-argument version of power: -- Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Thu Nov 1 20:42:39 2007 @@ -1105,6 +1105,7 @@ _expectations['freebsd5'] = _expectations['freebsd4'] _expectations['freebsd6'] = _expectations['freebsd4'] _expectations['freebsd7'] = _expectations['freebsd4'] +_expectations['freebsd8'] = _expectations['freebsd4'] class _ExpectedSkips: def __init__(self): Modified: python/branches/py3k/Lib/test/test_bufio.py ============================================================================== --- python/branches/py3k/Lib/test/test_bufio.py (original) +++ python/branches/py3k/Lib/test/test_bufio.py Thu Nov 1 20:42:39 2007 @@ -13,6 +13,9 @@ # Write s + "\n" + s to file, then open it and ensure that successive # .readline()s deliver what we wrote. + # Ensure we can open TESTFN for writing. + test_support.unlink(test_support.TESTFN) + # Since C doesn't guarantee we can write/read arbitrary bytes in text # files, use binary mode. f = open(test_support.TESTFN, "wb") @@ -31,11 +34,7 @@ self.assert_(not line) # Must be at EOF f.close() finally: - try: - import os - os.unlink(test_support.TESTFN) - except: - pass + test_support.unlink(test_support.TESTFN) def drive_one(self, pattern): for length in lengths: Modified: python/branches/py3k/Lib/test/test_collections.py ============================================================================== --- python/branches/py3k/Lib/test/test_collections.py (original) +++ python/branches/py3k/Lib/test/test_collections.py Thu Nov 1 20:42:39 2007 @@ -2,7 +2,7 @@ import unittest from test import test_support -from collections import NamedTuple +from collections import namedtuple from collections import Hashable, Iterable, Iterator from collections import Sized, Container, Callable from collections import Set, MutableSet @@ -13,18 +13,27 @@ class TestNamedTuple(unittest.TestCase): def test_factory(self): - Point = NamedTuple('Point', 'x y') + Point = namedtuple('Point', 'x y') self.assertEqual(Point.__name__, 'Point') self.assertEqual(Point.__doc__, 'Point(x, y)') self.assertEqual(Point.__slots__, ()) self.assertEqual(Point.__module__, __name__) self.assertEqual(Point.__getitem__, tuple.__getitem__) - self.assertRaises(ValueError, NamedTuple, 'abc%', 'def ghi') - self.assertRaises(ValueError, NamedTuple, 'abc', 'def g%hi') - NamedTuple('Point0', 'x1 y2') # Verify that numbers are allowed in names + + self.assertRaises(ValueError, namedtuple, 'abc%', 'efg ghi') # type has non-alpha char + self.assertRaises(ValueError, namedtuple, 'class', 'efg ghi') # type has keyword + self.assertRaises(ValueError, namedtuple, '9abc', 'efg ghi') # type starts with digit + + self.assertRaises(ValueError, namedtuple, 'abc', 'efg g%hi') # field with non-alpha char + self.assertRaises(ValueError, namedtuple, 'abc', 'abc class') # field has keyword + self.assertRaises(ValueError, namedtuple, 'abc', '8efg 9ghi') # field starts with digit + self.assertRaises(ValueError, namedtuple, 'abc', '__efg__ ghi') # field with double underscores + self.assertRaises(ValueError, namedtuple, 'abc', 'efg efg ghi') # duplicate field + + namedtuple('Point0', 'x1 y2') # Verify that numbers are allowed in names def test_instance(self): - Point = NamedTuple('Point', 'x y') + Point = namedtuple('Point', 'x y') p = Point(11, 22) self.assertEqual(p, Point(x=11, y=22)) self.assertEqual(p, Point(11, y=22)) @@ -40,14 +49,20 @@ self.assert_('__weakref__' not in dir(p)) self.assertEqual(p.__fields__, ('x', 'y')) # test __fields__ attribute self.assertEqual(p.__replace__('x', 1), (1, 22)) # test __replace__ method + self.assertEqual(p.__asdict__(), dict(x=11, y=22)) # test __dict__ method # verify that field string can have commas - Point = NamedTuple('Point', 'x, y') + Point = namedtuple('Point', 'x, y') + p = Point(x=11, y=22) + self.assertEqual(repr(p), 'Point(x=11, y=22)') + + # verify that fieldspec can be a non-string sequence + Point = namedtuple('Point', ('x', 'y')) p = Point(x=11, y=22) self.assertEqual(repr(p), 'Point(x=11, y=22)') def test_tupleness(self): - Point = NamedTuple('Point', 'x y') + Point = namedtuple('Point', 'x y') p = Point(11, 22) self.assert_(isinstance(p, tuple)) @@ -66,9 +81,9 @@ self.assertRaises(AttributeError, eval, 'p.z', locals()) def test_odd_sizes(self): - Zero = NamedTuple('Zero', '') + Zero = namedtuple('Zero', '') self.assertEqual(Zero(), ()) - Dot = NamedTuple('Dot', 'd') + Dot = namedtuple('Dot', 'd') self.assertEqual(Dot(1), (1,)) 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 Nov 1 20:42:39 2007 @@ -95,35 +95,61 @@ # Name adapter to be able to change the Decimal and Context # interface without changing the test files from Cowlishaw -nameAdapter = {'toeng':'to_eng_string', - 'tosci':'to_sci_string', - 'samequantum':'same_quantum', - 'tointegral':'to_integral_value', - 'tointegralx':'to_integral_exact', - 'remaindernear':'remainder_near', - 'divideint':'divide_int', - 'squareroot':'sqrt', +nameAdapter = {'and':'logical_and', 'apply':'_apply', 'class':'number_class', 'comparesig':'compare_signal', 'comparetotal':'compare_total', 'comparetotmag':'compare_total_mag', - 'copyabs':'copy_abs', 'copy':'copy_decimal', + 'copyabs':'copy_abs', 'copynegate':'copy_negate', 'copysign':'copy_sign', - 'and':'logical_and', - 'or':'logical_or', - 'xor':'logical_xor', + 'divideint':'divide_int', 'invert':'logical_invert', + 'iscanonical':'is_canonical', + 'isfinite':'is_finite', + 'isinfinite':'is_infinite', + 'isnan':'is_nan', + 'isnormal':'is_normal', + 'isqnan':'is_qnan', + 'issigned':'is_signed', + 'issnan':'is_snan', + 'issubnormal':'is_subnormal', + 'iszero':'is_zero', 'maxmag':'max_mag', 'minmag':'min_mag', 'nextminus':'next_minus', 'nextplus':'next_plus', 'nexttoward':'next_toward', + 'or':'logical_or', 'reduce':'normalize', + 'remaindernear':'remainder_near', + 'samequantum':'same_quantum', + 'squareroot':'sqrt', + 'toeng':'to_eng_string', + 'tointegral':'to_integral_value', + 'tointegralx':'to_integral_exact', + 'tosci':'to_sci_string', + 'xor':'logical_xor', } +# The following functions return True/False rather than a Decimal instance + +LOGICAL_FUNCTIONS = ( + 'is_canonical', + 'is_finite', + 'is_infinite', + 'is_nan', + 'is_normal', + 'is_qnan', + 'is_signed', + 'is_snan', + 'is_subnormal', + 'is_zero', + 'same_quantum', + ) + # For some operations (currently exp, ln, log10, power), the decNumber # reference implementation imposes additional restrictions on the # context and operands. These restrictions are not part of the @@ -321,7 +347,7 @@ print("--", self.context) try: result = str(funct(*vals)) - if fname == 'same_quantum': + if fname in LOGICAL_FUNCTIONS: result = str(int(eval(result))) # 'True', 'False' -> '1', '0' except Signals as error: self.fail("Raised %s in %s" % (error, s)) @@ -426,13 +452,18 @@ #bad sign self.assertRaises(ValueError, Decimal, (8, (4, 3, 4, 9, 1), 2) ) + self.assertRaises(ValueError, Decimal, (0., (4, 3, 4, 9, 1), 2) ) + self.assertRaises(ValueError, Decimal, (Decimal(1), (4, 3, 4, 9, 1), 2)) #bad exp self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') ) + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 0.) ) + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), '1') ) #bad coefficients self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, None, 1), 2) ) self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) + self.assertRaises(ValueError, Decimal, (1, (4, 10, 4, 9, 1), 2) ) def test_explicit_from_Decimal(self): @@ -1025,6 +1056,28 @@ d = Decimal("Infinity") self.assertEqual(d.as_tuple(), (0, (0,), 'F') ) + #leading zeros in coefficient should be stripped + d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), -2) ) + self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), -2) ) + d = Decimal( (1, (0, 0, 0), 37) ) + self.assertEqual(d.as_tuple(), (1, (0,), 37)) + d = Decimal( (1, (), 37) ) + self.assertEqual(d.as_tuple(), (1, (0,), 37)) + + #leading zeros in NaN diagnostic info should be stripped + d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), 'n') ) + self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), 'n') ) + d = Decimal( (1, (0, 0, 0), 'N') ) + self.assertEqual(d.as_tuple(), (1, (), 'N') ) + d = Decimal( (1, (), 'n') ) + self.assertEqual(d.as_tuple(), (1, (), 'n') ) + + #coefficient in infinity should be ignored + d = Decimal( (0, (4, 5, 3, 4), 'F') ) + self.assertEqual(d.as_tuple(), (0, (0,), 'F')) + d = Decimal( (1, (0, 2, 7, 1), 'F') ) + self.assertEqual(d.as_tuple(), (1, (0,), 'F')) + def test_immutability_operations(self): # Do operations and check that it didn't change change internal objects. Modified: python/branches/py3k/Lib/test/test_deque.py ============================================================================== --- python/branches/py3k/Lib/test/test_deque.py (original) +++ python/branches/py3k/Lib/test/test_deque.py Thu Nov 1 20:42:39 2007 @@ -47,6 +47,26 @@ self.assertEqual(right, list(range(150, 400))) self.assertEqual(list(d), list(range(50, 150))) + def test_maxlen(self): + self.assertRaises(ValueError, deque, 'abc', -1) + self.assertRaises(ValueError, deque, 'abc', -2) + d = deque(range(10), maxlen=3) + self.assertEqual(repr(d), 'deque([7, 8, 9], maxlen=3)') + self.assertEqual(list(d), [7, 8, 9]) + self.assertEqual(d, deque(range(10), 3)) + d.append(10) + self.assertEqual(list(d), [8, 9, 10]) + d.appendleft(7) + self.assertEqual(list(d), [7, 8, 9]) + d.extend([10, 11]) + self.assertEqual(list(d), [9, 10, 11]) + d.extendleft([8, 7]) + self.assertEqual(list(d), [7, 8, 9]) + d = deque(range(200), maxlen=10) + d.append(d) + d = deque(range(10), maxlen=None) + self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])') + def test_comparisons(self): d = deque('xabc'); d.popleft() for e in [d, deque('abc'), deque('ab'), deque(), list(d)]: @@ -254,7 +274,7 @@ os.remove(test_support.TESTFN) def test_init(self): - self.assertRaises(TypeError, deque, 'abc', 2); + self.assertRaises(TypeError, deque, 'abc', 2, 3); self.assertRaises(TypeError, deque, 1); def test_hash(self): @@ -340,13 +360,13 @@ self.assertNotEqual(id(d), id(e)) self.assertEqual(list(d), list(e)) - def test_pickle_recursive(self): - d = deque('abc') - d.append(d) - for i in (0, 1, 2): - e = pickle.loads(pickle.dumps(d, i)) - self.assertNotEqual(id(d), id(e)) - self.assertEqual(id(e), id(e[-1])) +## def test_pickle_recursive(self): +## d = deque('abc') +## d.append(d) +## for i in (0, 1, 2): +## e = pickle.loads(pickle.dumps(d, i)) +## self.assertNotEqual(id(d), id(e)) +## self.assertEqual(id(e), id(e[-1])) def test_deepcopy(self): mut = [10] @@ -452,24 +472,40 @@ self.assertEqual(type(d), type(e)) self.assertEqual(list(d), list(e)) - def test_pickle(self): - d = Deque('abc') - d.append(d) + d = Deque('abcde', maxlen=4) + + e = d.__copy__() + self.assertEqual(type(d), type(e)) + self.assertEqual(list(d), list(e)) + + e = Deque(d) + self.assertEqual(type(d), type(e)) + self.assertEqual(list(d), list(e)) - e = pickle.loads(pickle.dumps(d)) + s = pickle.dumps(d) + e = pickle.loads(s) self.assertNotEqual(id(d), id(e)) self.assertEqual(type(d), type(e)) - dd = d.pop() - ee = e.pop() - self.assertEqual(id(e), id(ee)) - self.assertEqual(d, e) - - d.x = d - e = pickle.loads(pickle.dumps(d)) - self.assertEqual(id(e), id(e.x)) + self.assertEqual(list(d), list(e)) - d = DequeWithBadIter('abc') - self.assertRaises(TypeError, pickle.dumps, d) +## def test_pickle(self): +## d = Deque('abc') +## d.append(d) +## +## e = pickle.loads(pickle.dumps(d)) +## self.assertNotEqual(id(d), id(e)) +## self.assertEqual(type(d), type(e)) +## dd = d.pop() +## ee = e.pop() +## self.assertEqual(id(e), id(ee)) +## self.assertEqual(d, e) +## +## d.x = d +## e = pickle.loads(pickle.dumps(d)) +## self.assertEqual(id(e), id(e.x)) +## +## d = DequeWithBadIter('abc') +## self.assertRaises(TypeError, pickle.dumps, d) def test_weakref(self): d = deque('gallahad') Modified: python/branches/py3k/Lib/test/test_fcntl.py ============================================================================== --- python/branches/py3k/Lib/test/test_fcntl.py (original) +++ python/branches/py3k/Lib/test/test_fcntl.py Thu Nov 1 20:42:39 2007 @@ -23,7 +23,7 @@ if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3', 'Darwin1.2', 'darwin', 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', - 'freebsd6', 'freebsd7', + 'freebsd6', 'freebsd7', 'freebsd8', 'bsdos2', 'bsdos3', 'bsdos4', 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'): if struct.calcsize('l') == 8: 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 Thu Nov 1 20:42:39 2007 @@ -83,13 +83,25 @@ resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(), b"Text") - resp.close() + self.assertTrue(resp.isclosed()) body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) self.assertRaises(httplib.BadStatusLine, resp.begin) + def test_partial_reads(self): + # if we have a lenght, the system knows when to close itself + # same behaviour than when we read the whole thing with read() + body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" + sock = FakeSocket(body) + resp = httplib.HTTPResponse(sock) + resp.begin() + self.assertEqual(resp.read(2), b'Te') + self.assertFalse(resp.isclosed()) + self.assertEqual(resp.read(2), b'xt') + self.assertTrue(resp.isclosed()) + def test_host_port(self): # Check invalid host_port @@ -135,7 +147,6 @@ resp.begin() if resp.read(): self.fail("Did not expect response from HEAD request") - resp.close() def test_send_file(self): expected = (b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' 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 Nov 1 20:42:39 2007 @@ -55,9 +55,14 @@ self.assertEqual(lzip('abc',count()), [('a', 0), ('b', 1), ('c', 2)]) self.assertEqual(lzip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)]) self.assertEqual(take(2, lzip('abc',count(3))), [('a', 3), ('b', 4)]) + self.assertEqual(take(2, zip('abc',count(-1))), [('a', -1), ('b', 0)]) + self.assertEqual(take(2, zip('abc',count(-3))), [('a', -3), ('b', -2)]) self.assertRaises(TypeError, count, 2, 3) self.assertRaises(TypeError, count, 'a') - self.assertRaises(OverflowError, list, islice(count(maxsize-5), 10)) + self.assertEqual(list(islice(count(maxsize-5), 10)), + list(range(maxsize-5, maxsize+5))) + self.assertEqual(list(islice(count(-maxsize-5), 10)), + list(range(-maxsize-5, -maxsize+5))) c = count(3) self.assertEqual(repr(c), 'count(3)') next(c) @@ -66,6 +71,11 @@ self.assertEqual(repr(c), 'count(-9)') next(c) self.assertEqual(next(c), -8) + for i in (-sys.maxint-5, -sys.maxint+5 ,-10, -1, 0, 10, sys.maxint-5, sys.maxint+5): + # Test repr (ignoring the L in longs) + r1 = repr(count(i)).replace('L', '') + r2 = 'count(%r)'.__mod__(i).replace('L', '') + self.assertEqual(r1, r2) def test_cycle(self): self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) 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 Thu Nov 1 20:42:39 2007 @@ -1,4 +1,5 @@ import unittest +import sys from test import test_support, list_tests class ListTest(list_tests.CommonTest): @@ -18,6 +19,14 @@ self.assertEqual(len([0]), 1) self.assertEqual(len([0, 1, 2]), 3) + def test_overflow(self): + lst = [4, 5, 6, 7] + n = int((sys.maxint*2+2) // len(lst)) + def mul(a, b): return a * b + def imul(a, b): a *= b + self.assertRaises((MemoryError, OverflowError), mul, lst, n) + self.assertRaises((MemoryError, OverflowError), imul, lst, n) + def test_main(verbose=None): test_support.run_unittest(ListTest) 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 Thu Nov 1 20:42:39 2007 @@ -339,6 +339,50 @@ m[start:stop:step] = data self.assertEquals(m[:], bytes(L)) + def make_mmap_file (self, f, halfsize): + # Write 2 pages worth of data to the file + f.write (b'\0' * halfsize) + f.write (b'foo') + f.write (b'\0' * (halfsize - 3)) + f.flush () + return mmap.mmap (f.fileno(), 0) + + def test_offset (self): + f = open (TESTFN, 'w+b') + + try: # unlink TESTFN no matter what + halfsize = mmap.ALLOCATIONGRANULARITY + m = self.make_mmap_file (f, halfsize) + m.close () + f.close () + + mapsize = halfsize * 2 + # Try invalid offset + f = open(TESTFN, "r+b") + for offset in [-2, -1, None]: + try: + m = mmap.mmap(f.fileno(), mapsize, offset=offset) + self.assertEqual(0, 1) + except (ValueError, TypeError, OverflowError): + pass + else: + self.assertEqual(0, 0) + f.close() + + # Try valid offset, hopefully 8192 works on all OSes + f = open(TESTFN, "r+b") + m = mmap.mmap(f.fileno(), mapsize - halfsize, offset=halfsize) + self.assertEqual(m[0:3], b'foo') + f.close() + m.close() + + finally: + f.close() + try: + os.unlink(TESTFN) + except OSError: + pass + def test_main(): run_unittest(MmapTests) Modified: python/branches/py3k/Lib/test/test_socket.py ============================================================================== --- python/branches/py3k/Lib/test/test_socket.py (original) +++ python/branches/py3k/Lib/test/test_socket.py Thu Nov 1 20:42:39 2007 @@ -338,7 +338,7 @@ # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. if sys.platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', - 'freebsd7', 'darwin'): + 'freebsd7', 'freebsd8', 'darwin'): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry services = ('daytime', 'qotd', 'domain') 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 Thu Nov 1 20:42:39 2007 @@ -100,10 +100,19 @@ tests and we don't try multiple ports, the test can fails. This makes the test more robust.""" - # some random ports that hopefully no one is listening on. - for port in [preferred_port, 9907, 10243, 32999]: + # Find some random ports that hopefully no one is listening on. + # Ideally each test would clean up after itself and not continue listening + # on any ports. However, this isn't the case. The last port (0) is + # a stop-gap that asks the O/S to assign a port. Whenever the warning + # message below is printed, the test that is listening on the port should + # be fixed to close the socket at the end of the test. + # Another reason why we can't use a port is another process (possibly + # another instance of the test suite) is using the same port. + for port in [preferred_port, 9907, 10243, 32999, 0]: try: sock.bind((host, port)) + if port == 0: + port = sock.getsockname()[1] return port except socket.error as e: (err, msg) = e.args @@ -519,8 +528,7 @@ elif len(result.failures) == 1 and not result.errors: err = result.failures[0][1] else: - msg = "errors occurred; run in verbose mode for details" - raise TestFailed(msg) + err = "errors occurred; run in verbose mode for details" raise TestFailed(err) Modified: python/branches/py3k/Lib/test/test_univnewlines.py ============================================================================== --- python/branches/py3k/Lib/test/test_univnewlines.py (original) +++ python/branches/py3k/Lib/test/test_univnewlines.py Thu Nov 1 20:42:39 2007 @@ -93,6 +93,13 @@ NEWLINE = '\r\n' DATA = DATA_CRLF + def test_tell(self): + fp = open(test_support.TESTFN, self.READMODE) + self.assertEqual(repr(fp.newlines), repr(None)) + data = fp.readline() + pos = fp.tell() + self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) + class TestMixedNewlines(TestGenericUnivNewlines): NEWLINE = ('\r', '\n') DATA = DATA_MIXED Modified: python/branches/py3k/Lib/test/test_zlib.py ============================================================================== --- python/branches/py3k/Lib/test/test_zlib.py (original) +++ python/branches/py3k/Lib/test/test_zlib.py Thu Nov 1 20:42:39 2007 @@ -42,14 +42,18 @@ class ExceptionTestCase(unittest.TestCase): # make sure we generate some expected errors - def test_bigbits(self): - # specifying total bits too large causes an error - self.assertRaises(zlib.error, - zlib.compress, 'ERROR', zlib.MAX_WBITS + 1) + def test_badlevel(self): + # specifying compression level out of range causes an error + # (but -1 is Z_DEFAULT_COMPRESSION and apparently the zlib + # accepts 0 too) + self.assertRaises(zlib.error, zlib.compress, 'ERROR', 10) def test_badcompressobj(self): # verify failure on building compress object with bad params self.assertRaises(ValueError, zlib.compressobj, 1, zlib.DEFLATED, 0) + # specifying total bits too large causes an error + self.assertRaises(ValueError, + zlib.compressobj, 1, zlib.DEFLATED, zlib.MAX_WBITS + 1) def test_baddecompressobj(self): # verify failure on building decompress object with bad params 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 Thu Nov 1 20:42:39 2007 @@ -960,7 +960,7 @@ dotdotdot = "..." else: dotdotdot = "" - return "" % ( + return '' % ( self.__class__.__name__, data[0:10], dotdotdot) def substringData(self, offset, count): Modified: python/branches/py3k/Makefile.pre.in ============================================================================== --- python/branches/py3k/Makefile.pre.in (original) +++ python/branches/py3k/Makefile.pre.in Thu Nov 1 20:42:39 2007 @@ -336,7 +336,8 @@ # Rules # Default target -all: $(BUILDPYTHON) oldsharedmods sharedmods +all: build_all +build_all: $(BUILDPYTHON) oldsharedmods sharedmods # Build the interpreter $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) @@ -476,7 +477,7 @@ $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT) - -@ mkdir Include + -@$(INSTALL) -d Include -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) $(PGEN): $(PGENOBJS) @@ -758,7 +759,7 @@ distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \ setuptools setuptools/command setuptools/tests setuptools.egg-info \ curses $(MACHDEPS) -libinstall: $(BUILDPYTHON) $(srcdir)/Lib/$(PLATDIR) +libinstall: build_all $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ do \ if test ! -d $(DESTDIR)$$i; then \ @@ -1126,7 +1127,7 @@ Python/thread.o: @THREADHEADERS@ # Declare targets that aren't real files -.PHONY: all sharedmods oldsharedmods test quicktest memtest +.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest .PHONY: install altinstall oldsharedinstall bininstall altbininstall .PHONY: maninstall libinstall inclinstall libainstall sharedinstall .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure Modified: python/branches/py3k/Misc/developers.txt ============================================================================== --- python/branches/py3k/Misc/developers.txt (original) +++ python/branches/py3k/Misc/developers.txt Thu Nov 1 20:42:39 2007 @@ -17,6 +17,12 @@ Permissions History ------------------- +- Christian Heimes was given SVN access on 31 October 2007 by MvL, + for general contributions to Python. + +- Chris Monson was given SVN access on 20 October 2007 by NCN, + for his work on editing PEPs. + - Bill Janssen was given SVN access on 28 August 2007 by NCN, for his work on the SSL module and other things related to (SSL) sockets. Modified: python/branches/py3k/Modules/_bsddb.c ============================================================================== --- python/branches/py3k/Modules/_bsddb.c (original) +++ python/branches/py3k/Modules/_bsddb.c Thu Nov 1 20:42:39 2007 @@ -87,20 +87,15 @@ #include /* for offsetof() */ #include -#include -/* --------------------------------------------------------------------- */ -/* Various macro definitions */ +#define COMPILING_BSDDB_C +#include "bsddb.h" +#undef COMPILING_BSDDB_C -/* 40 = 4.0, 33 = 3.3; this will break if the second number is > 9 */ -#define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) -#if DB_VERSION_MINOR > 9 -#error "eek! DBVER can't handle minor versions > 9" -#endif - -#define PY_BSDDB_VERSION "4.5.0" static char *svn_id = "$Id$"; +/* --------------------------------------------------------------------- */ +/* Various macro definitions */ #if (PY_VERSION_HEX < 0x02050000) typedef int Py_ssize_t; @@ -196,107 +191,15 @@ /* --------------------------------------------------------------------- */ /* Structure definitions */ -#if PYTHON_API_VERSION >= 1010 /* python >= 2.1 support weak references */ -#define HAVE_WEAKREF -#else -#undef HAVE_WEAKREF +#if PYTHON_API_VERSION < 1010 +#error "Python 2.1 or later required" #endif -/* if Python >= 2.1 better support warnings */ -#if PYTHON_API_VERSION >= 1010 -#define HAVE_WARNINGS -#else -#undef HAVE_WARNINGS -#endif - -#if PYTHON_API_VERSION <= 1007 - /* 1.5 compatibility */ -#define PyObject_New PyObject_NEW -#define PyObject_Del PyMem_DEL -#endif - -struct behaviourFlags { - /* What is the default behaviour when DB->get or DBCursor->get returns a - DB_NOTFOUND || DB_KEYEMPTY error? Return None or raise an exception? */ - unsigned int getReturnsNone : 1; - /* What is the default behaviour for DBCursor.set* methods when DBCursor->get - * returns a DB_NOTFOUND || DB_KEYEMPTY error? Return None or raise? */ - unsigned int cursorSetReturnsNone : 1; -}; +/* Defaults for moduleFlags in DBEnvObject and DBObject. */ #define DEFAULT_GET_RETURNS_NONE 1 #define DEFAULT_CURSOR_SET_RETURNS_NONE 1 /* 0 in pybsddb < 4.2, python < 2.4 */ -typedef struct { - PyObject_HEAD - DB_ENV* db_env; - u_int32_t flags; /* saved flags from open() */ - int closed; - struct behaviourFlags moduleFlags; -#ifdef HAVE_WEAKREF - PyObject *in_weakreflist; /* List of weak references */ -#endif -} DBEnvObject; - - -typedef struct { - PyObject_HEAD - DB* db; - DBEnvObject* myenvobj; /* PyObject containing the DB_ENV */ - u_int32_t flags; /* saved flags from open() */ - u_int32_t setflags; /* saved flags from set_flags() */ - int haveStat; - struct behaviourFlags moduleFlags; -#if (DBVER >= 33) - PyObject* associateCallback; - PyObject* btCompareCallback; - int primaryDBType; -#endif -#ifdef HAVE_WEAKREF - PyObject *in_weakreflist; /* List of weak references */ -#endif -} DBObject; - - -typedef struct { - PyObject_HEAD - DBC* dbc; - DBObject* mydb; -#ifdef HAVE_WEAKREF - PyObject *in_weakreflist; /* List of weak references */ -#endif -} DBCursorObject; - - -typedef struct { - PyObject_HEAD - DB_TXN* txn; - PyObject *env; -#ifdef HAVE_WEAKREF - PyObject *in_weakreflist; /* List of weak references */ -#endif -} DBTxnObject; - - -typedef struct { - PyObject_HEAD - DB_LOCK lock; -#ifdef HAVE_WEAKREF - PyObject *in_weakreflist; /* List of weak references */ -#endif -} DBLockObject; - -#if (DBVER >= 43) -typedef struct { - PyObject_HEAD - DB_SEQUENCE* sequence; - DBObject* mydb; -#ifdef HAVE_WEAKREF - PyObject *in_weakreflist; /* List of weak references */ -#endif -} DBSequenceObject; -static PyTypeObject DBSequence_Type; -#endif static PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type; @@ -628,12 +531,7 @@ strncat(errTxt, _db_errmsg, bytes_left); } _db_errmsg[0] = 0; -#ifdef HAVE_WARNINGS exceptionRaised = PyErr_WarnEx(PyExc_RuntimeWarning, errTxt, 1); -#else - fprintf(stderr, errTxt); - fprintf(stderr, "\n"); -#endif #else /* do an exception instead */ errObj = DBIncompleteError; @@ -887,9 +785,7 @@ self->btCompareCallback = NULL; self->primaryDBType = 0; #endif -#ifdef HAVE_WEAKREF self->in_weakreflist = NULL; -#endif /* keep a reference to our python DBEnv object */ if (arg) { @@ -940,21 +836,17 @@ MYDB_BEGIN_ALLOW_THREADS; self->db->close(self->db, 0); MYDB_END_ALLOW_THREADS; -#ifdef HAVE_WARNINGS } else { PyErr_WarnEx(PyExc_RuntimeWarning, "DB could not be closed in destructor:" " DBEnv already closed", 1); -#endif } self->db = NULL; } -#ifdef HAVE_WEAKREF if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); } -#endif if (self->myenvobj) { Py_DECREF(self->myenvobj); self->myenvobj = NULL; @@ -982,9 +874,7 @@ self->dbc = dbc; self->mydb = db; -#ifdef HAVE_WEAKREF self->in_weakreflist = NULL; -#endif Py_INCREF(self->mydb); return self; } @@ -995,11 +885,9 @@ { int err; -#ifdef HAVE_WEAKREF if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); } -#endif if (self->dbc != NULL) { MYDB_BEGIN_ALLOW_THREADS; @@ -1032,9 +920,7 @@ self->flags = flags; self->moduleFlags.getReturnsNone = DEFAULT_GET_RETURNS_NONE; self->moduleFlags.cursorSetReturnsNone = DEFAULT_CURSOR_SET_RETURNS_NONE; -#ifdef HAVE_WEAKREF self->in_weakreflist = NULL; -#endif MYDB_BEGIN_ALLOW_THREADS; err = db_env_create(&self->db_env, flags); @@ -1053,11 +939,9 @@ static void DBEnv_dealloc(DBEnvObject* self) { -#ifdef HAVE_WEAKREF if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); } -#endif if (self->db_env && !self->closed) { MYDB_BEGIN_ALLOW_THREADS; @@ -1077,9 +961,7 @@ return NULL; Py_INCREF(myenv); self->env = (PyObject*)myenv; -#ifdef HAVE_WEAKREF self->in_weakreflist = NULL; -#endif MYDB_BEGIN_ALLOW_THREADS; #if (DBVER >= 40) @@ -1100,13 +982,10 @@ static void DBTxn_dealloc(DBTxnObject* self) { -#ifdef HAVE_WEAKREF if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); } -#endif -#ifdef HAVE_WARNINGS if (self->txn) { /* it hasn't been finalized, abort it! */ MYDB_BEGIN_ALLOW_THREADS; @@ -1121,7 +1000,6 @@ " No prior commit() or abort().", 1); } -#endif Py_DECREF(self->env); PyObject_Del(self); @@ -1136,9 +1014,7 @@ DBLockObject* self = PyObject_New(DBLockObject, &DBLock_Type); if (self == NULL) return NULL; -#ifdef HAVE_WEAKREF self->in_weakreflist = NULL; -#endif MYDB_BEGIN_ALLOW_THREADS; #if (DBVER >= 40) @@ -1160,11 +1036,9 @@ static void DBLock_dealloc(DBLockObject* self) { -#ifdef HAVE_WEAKREF if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); } -#endif /* TODO: is this lock held? should we release it? */ PyObject_Del(self); @@ -1181,9 +1055,7 @@ return NULL; Py_INCREF(mydb); self->mydb = mydb; -#ifdef HAVE_WEAKREF self->in_weakreflist = NULL; -#endif MYDB_BEGIN_ALLOW_THREADS; @@ -1202,11 +1074,9 @@ static void DBSequence_dealloc(DBSequenceObject* self) { -#ifdef HAVE_WEAKREF if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); } -#endif Py_DECREF(self->mydb); PyObject_Del(self); @@ -1432,7 +1302,6 @@ } -#if (DBVER >= 32) static PyObject* _DB_consume(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag) { @@ -1500,8 +1369,6 @@ { return _DB_consume(self, args, kwargs, DB_CONSUME_WAIT); } -#endif - static PyObject* @@ -2526,7 +2393,6 @@ } -#if (DBVER >= 32) static PyObject* DB_set_q_extentsize(DBObject* self, PyObject* args) { @@ -2543,7 +2409,6 @@ RETURN_IF_ERR(); RETURN_NONE(); } -#endif static PyObject* DB_stat(DBObject* self, PyObject* args, PyObject* kwargs) @@ -4144,7 +4009,6 @@ } -#if (DBVER >= 32) static PyObject* DBEnv_set_flags(DBEnvObject* self, PyObject* args) { @@ -4161,7 +4025,6 @@ RETURN_IF_ERR(); RETURN_NONE(); } -#endif static PyObject* @@ -4288,7 +4151,6 @@ #endif -#if (DBVER >= 32) static PyObject* DBEnv_set_lk_max_locks(DBEnvObject* self, PyObject* args) @@ -4340,8 +4202,6 @@ RETURN_NONE(); } -#endif - static PyObject* DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args) @@ -4664,19 +4524,15 @@ MAKE_ENTRY(lastid); #endif MAKE_ENTRY(nmodes); -#if (DBVER >= 32) MAKE_ENTRY(maxlocks); MAKE_ENTRY(maxlockers); MAKE_ENTRY(maxobjects); MAKE_ENTRY(nlocks); MAKE_ENTRY(maxnlocks); -#endif MAKE_ENTRY(nlockers); MAKE_ENTRY(maxnlockers); -#if (DBVER >= 32) MAKE_ENTRY(nobjects); MAKE_ENTRY(maxnobjects); -#endif MAKE_ENTRY(nrequests); MAKE_ENTRY(nreleases); #if (DBVER < 44) @@ -5024,7 +4880,7 @@ { int err; DBT key; - PyObject *retval; + PyObject *retval = NULL; key.flags = DB_DBT_MALLOC; CHECK_SEQUENCE_NOT_CLOSED(self) MYDB_BEGIN_ALLOW_THREADS @@ -5265,10 +5121,8 @@ {"associate", (PyCFunction)DB_associate, METH_VARARGS|METH_KEYWORDS}, #endif {"close", (PyCFunction)DB_close, METH_VARARGS}, -#if (DBVER >= 32) {"consume", (PyCFunction)DB_consume, METH_VARARGS|METH_KEYWORDS}, {"consume_wait", (PyCFunction)DB_consume_wait, METH_VARARGS|METH_KEYWORDS}, -#endif {"cursor", (PyCFunction)DB_cursor, METH_VARARGS|METH_KEYWORDS}, {"delete", (PyCFunction)DB_delete, METH_VARARGS|METH_KEYWORDS}, {"fd", (PyCFunction)DB_fd, METH_VARARGS}, @@ -5306,9 +5160,7 @@ {"set_re_len", (PyCFunction)DB_set_re_len, METH_VARARGS}, {"set_re_pad", (PyCFunction)DB_set_re_pad, METH_VARARGS}, {"set_re_source", (PyCFunction)DB_set_re_source, METH_VARARGS}, -#if (DBVER >= 32) {"set_q_extentsize",(PyCFunction)DB_set_q_extentsize,METH_VARARGS}, -#endif {"stat", (PyCFunction)DB_stat, METH_VARARGS|METH_KEYWORDS}, {"sync", (PyCFunction)DB_sync, METH_VARARGS}, #if (DBVER >= 33) @@ -5376,9 +5228,7 @@ {"set_shm_key", (PyCFunction)DBEnv_set_shm_key, METH_VARARGS}, {"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS}, {"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS}, -#if (DBVER >= 32) {"set_flags", (PyCFunction)DBEnv_set_flags, METH_VARARGS}, -#endif {"set_lg_bsize", (PyCFunction)DBEnv_set_lg_bsize, METH_VARARGS}, {"set_lg_dir", (PyCFunction)DBEnv_set_lg_dir, METH_VARARGS}, {"set_lg_max", (PyCFunction)DBEnv_set_lg_max, METH_VARARGS}, @@ -5389,11 +5239,9 @@ #if (DBVER < 45) {"set_lk_max", (PyCFunction)DBEnv_set_lk_max, METH_VARARGS}, #endif -#if (DBVER >= 32) {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS}, {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS}, {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS}, -#endif {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS}, {"set_tmp_dir", (PyCFunction)DBEnv_set_tmp_dir, METH_VARARGS}, {"txn_begin", (PyCFunction)DBEnv_txn_begin, METH_VARARGS|METH_KEYWORDS}, @@ -5512,7 +5360,6 @@ 0, /*tp_as_sequence*/ &DB_mapping,/*tp_as_mapping*/ 0, /*tp_hash*/ -#ifdef HAVE_WEAKREF 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ @@ -5524,7 +5371,6 @@ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(DBObject, in_weakreflist), /* tp_weaklistoffset */ -#endif }; @@ -5544,7 +5390,6 @@ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ -#ifdef HAVE_WEAKREF 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ @@ -5556,7 +5401,6 @@ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(DBCursorObject, in_weakreflist), /* tp_weaklistoffset */ -#endif }; @@ -5576,7 +5420,6 @@ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ -#ifdef HAVE_WEAKREF 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ @@ -5588,7 +5431,6 @@ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(DBEnvObject, in_weakreflist), /* tp_weaklistoffset */ -#endif }; static PyTypeObject DBTxn_Type = { @@ -5607,7 +5449,6 @@ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ -#ifdef HAVE_WEAKREF 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ @@ -5619,7 +5460,6 @@ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(DBTxnObject, in_weakreflist), /* tp_weaklistoffset */ -#endif }; @@ -5639,7 +5479,6 @@ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ -#ifdef HAVE_WEAKREF 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ @@ -5651,7 +5490,6 @@ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(DBLockObject, in_weakreflist), /* tp_weaklistoffset */ -#endif }; #if (DBVER >= 43) @@ -5671,7 +5509,6 @@ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ -#ifdef HAVE_WEAKREF 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ @@ -5683,7 +5520,6 @@ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(DBSequenceObject, in_weakreflist), /* tp_weaklistoffset */ -#endif }; #endif @@ -5765,6 +5601,9 @@ {NULL, NULL} /* sentinel */ }; +/* API structure */ +static BSDDB_api bsddb_api; + /* --------------------------------------------------------------------- */ /* Module initialization */ @@ -5785,6 +5624,7 @@ PyObject* pybsddb_version_s = PyUnicode_FromString(PY_BSDDB_VERSION); PyObject* db_version_s = PyUnicode_FromString(DB_VERSION_STRING); PyObject* svnid_s = PyUnicode_FromString(svn_id); + PyObject* py_api; /* Initialize the type of the new type objects here; doing it here is required for portability to Windows without requiring C++. */ @@ -5846,9 +5686,7 @@ ADD_INT(d, DB_INIT_LOG); ADD_INT(d, DB_INIT_MPOOL); ADD_INT(d, DB_INIT_TXN); -#if (DBVER >= 32) ADD_INT(d, DB_JOINENV); -#endif ADD_INT(d, DB_RECOVER); ADD_INT(d, DB_RECOVER_FATAL); @@ -5869,11 +5707,9 @@ ADD_INT(d, DB_RDWRMASTER); ADD_INT(d, DB_RDONLY); ADD_INT(d, DB_TRUNCATE); -#if (DBVER >= 32) ADD_INT(d, DB_EXTENT); ADD_INT(d, DB_CDB_ALLDB); ADD_INT(d, DB_VERIFY); -#endif ADD_INT(d, DB_UPGRADE); ADD_INT(d, DB_AGGRESSIVE); @@ -5917,9 +5753,7 @@ ADD_INT(d, DB_LOCK_READ); ADD_INT(d, DB_LOCK_WRITE); ADD_INT(d, DB_LOCK_NOWAIT); -#if (DBVER >= 32) ADD_INT(d, DB_LOCK_WAIT); -#endif ADD_INT(d, DB_LOCK_IWRITE); ADD_INT(d, DB_LOCK_IREAD); ADD_INT(d, DB_LOCK_IWR); @@ -5934,9 +5768,7 @@ ADD_INT(d, DB_LOCK_RECORD); ADD_INT(d, DB_LOCK_UPGRADE); -#if (DBVER >= 32) ADD_INT(d, DB_LOCK_SWITCH); -#endif #if (DBVER >= 33) ADD_INT(d, DB_LOCK_UPGRADE_WRITE); #endif @@ -5997,9 +5829,7 @@ ADD_INT(d, DB_COMMIT); #endif ADD_INT(d, DB_CONSUME); -#if (DBVER >= 32) ADD_INT(d, DB_CONSUME_WAIT); -#endif ADD_INT(d, DB_CURRENT); #if (DBVER >= 33) ADD_INT(d, DB_FAST_STAT); @@ -6182,6 +6012,21 @@ #undef MAKE_EX + /* Initiliase the C API structure and add it to the module */ + bsddb_api.db_type = &DB_Type; + bsddb_api.dbcursor_type = &DBCursor_Type; + bsddb_api.dbenv_type = &DBEnv_Type; + bsddb_api.dbtxn_type = &DBTxn_Type; + bsddb_api.dblock_type = &DBLock_Type; +#if (DBVER >= 43) + bsddb_api.dbsequence_type = &DBSequence_Type; +#endif + bsddb_api.makeDBError = makeDBError; + + py_api = PyCObject_FromVoidPtr((void*)&bsddb_api, NULL); + PyDict_SetItemString(d, "api", py_api); + Py_DECREF(py_api); + /* Check for errors */ if (PyErr_Occurred()) { PyErr_Print(); Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Thu Nov 1 20:42:39 2007 @@ -83,10 +83,27 @@ int leftindex; /* in range(BLOCKLEN) */ int rightindex; /* in range(BLOCKLEN) */ int len; + int maxlen; long state; /* incremented whenever the indices move */ PyObject *weakreflist; /* List of weak references */ } dequeobject; +/* The deque's size limit is d.maxlen. The limit can be zero or positive. + * If there is no limit, then d.maxlen == -1. + * + * After an item is added to a deque, we check to see if the size has grown past + * the limit. If it has, we get the size back down to the limit by popping an + * item off of the opposite end. The methods that can trigger this are append(), + * appendleft(), extend(), and extendleft(). + */ + +#define TRIM(d, popfunction) \ + if (d->maxlen != -1 && d->len > d->maxlen) { \ + PyObject *rv = popfunction(d, NULL); \ + assert(rv != NULL && d->len <= d->maxlen); \ + Py_DECREF(rv); \ + } + static PyTypeObject deque_type; static PyObject * @@ -95,9 +112,6 @@ dequeobject *deque; block *b; - if (type == &deque_type && !_PyArg_NoKeywords("deque()", kwds)) - return NULL; - /* create dequeobject structure */ deque = (dequeobject *)type->tp_alloc(type, 0); if (deque == NULL) @@ -117,55 +131,12 @@ deque->len = 0; deque->state = 0; deque->weakreflist = NULL; + deque->maxlen = -1; return (PyObject *)deque; } static PyObject * -deque_append(dequeobject *deque, PyObject *item) -{ - deque->state++; - if (deque->rightindex == BLOCKLEN-1) { - block *b = newblock(deque->rightblock, NULL, deque->len); - if (b == NULL) - return NULL; - assert(deque->rightblock->rightlink == NULL); - deque->rightblock->rightlink = b; - deque->rightblock = b; - deque->rightindex = -1; - } - Py_INCREF(item); - deque->len++; - deque->rightindex++; - deque->rightblock->data[deque->rightindex] = item; - Py_RETURN_NONE; -} - -PyDoc_STRVAR(append_doc, "Add an element to the right side of the deque."); - -static PyObject * -deque_appendleft(dequeobject *deque, PyObject *item) -{ - deque->state++; - if (deque->leftindex == 0) { - block *b = newblock(NULL, deque->leftblock, deque->len); - if (b == NULL) - return NULL; - assert(deque->leftblock->leftlink == NULL); - deque->leftblock->leftlink = b; - deque->leftblock = b; - deque->leftindex = BLOCKLEN; - } - Py_INCREF(item); - deque->len++; - deque->leftindex--; - deque->leftblock->data[deque->leftindex] = item; - Py_RETURN_NONE; -} - -PyDoc_STRVAR(appendleft_doc, "Add an element to the left side of the deque."); - -static PyObject * deque_pop(dequeobject *deque, PyObject *unused) { PyObject *item; @@ -240,6 +211,52 @@ PyDoc_STRVAR(popleft_doc, "Remove and return the leftmost element."); static PyObject * +deque_append(dequeobject *deque, PyObject *item) +{ + deque->state++; + if (deque->rightindex == BLOCKLEN-1) { + block *b = newblock(deque->rightblock, NULL, deque->len); + if (b == NULL) + return NULL; + assert(deque->rightblock->rightlink == NULL); + deque->rightblock->rightlink = b; + deque->rightblock = b; + deque->rightindex = -1; + } + Py_INCREF(item); + deque->len++; + deque->rightindex++; + deque->rightblock->data[deque->rightindex] = item; + TRIM(deque, deque_popleft); + Py_RETURN_NONE; +} + +PyDoc_STRVAR(append_doc, "Add an element to the right side of the deque."); + +static PyObject * +deque_appendleft(dequeobject *deque, PyObject *item) +{ + deque->state++; + if (deque->leftindex == 0) { + block *b = newblock(NULL, deque->leftblock, deque->len); + if (b == NULL) + return NULL; + assert(deque->leftblock->leftlink == NULL); + deque->leftblock->leftlink = b; + deque->leftblock = b; + deque->leftindex = BLOCKLEN; + } + Py_INCREF(item); + deque->len++; + deque->leftindex--; + deque->leftblock->data[deque->leftindex] = item; + TRIM(deque, deque_pop); + Py_RETURN_NONE; +} + +PyDoc_STRVAR(appendleft_doc, "Add an element to the left side of the deque."); + +static PyObject * deque_extend(dequeobject *deque, PyObject *iterable) { PyObject *it, *item; @@ -266,6 +283,7 @@ deque->len++; deque->rightindex++; deque->rightblock->data[deque->rightindex] = item; + TRIM(deque, deque_popleft); } Py_DECREF(it); if (PyErr_Occurred()) @@ -303,6 +321,7 @@ deque->len++; deque->leftindex--; deque->leftblock->data[deque->leftindex] = item; + TRIM(deque, deque_pop); } Py_DECREF(it); if (PyErr_Occurred()) @@ -579,8 +598,11 @@ static PyObject * deque_copy(PyObject *deque) { - return PyObject_CallFunctionObjArgs((PyObject *)(Py_Type(deque)), - deque, NULL); + if (((dequeobject *)deque)->maxlen == -1) + return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "O", deque, NULL); + else + return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "Oi", + deque, ((dequeobject *)deque)->maxlen, NULL); } PyDoc_STRVAR(copy_doc, "Return a shallow copy of a deque."); @@ -588,21 +610,29 @@ static PyObject * deque_reduce(dequeobject *deque) { - PyObject *dict, *result, *it; + PyObject *dict, *result, *aslist; dict = PyObject_GetAttrString((PyObject *)deque, "__dict__"); - if (dict == NULL) { + if (dict == NULL) PyErr_Clear(); - dict = Py_None; - Py_INCREF(dict); - } - it = PyObject_GetIter((PyObject *)deque); - if (it == NULL) { - Py_DECREF(dict); + aslist = PySequence_List((PyObject *)deque); + if (aslist == NULL) { + Py_XDECREF(dict); return NULL; } - result = Py_BuildValue("O()ON", Py_Type(deque), dict, it); - Py_DECREF(dict); + if (dict == NULL) { + if (deque->maxlen == -1) + result = Py_BuildValue("O(O)", Py_Type(deque), aslist); + else + result = Py_BuildValue("O(Oi)", Py_Type(deque), aslist, deque->maxlen); + } else { + if (deque->maxlen == -1) + result = Py_BuildValue("O(OO)O", Py_Type(deque), aslist, Py_None, dict); + else + result = Py_BuildValue("O(Oi)O", Py_Type(deque), aslist, deque->maxlen, dict); + } + Py_XDECREF(dict); + Py_DECREF(aslist); return result; } @@ -626,8 +656,11 @@ Py_ReprLeave(deque); return NULL; } - - result = PyUnicode_FromFormat("deque(%R)", aslist); + if (((dequeobject *)deque)->maxlen != -1) + result = PyUnicode_FromFormat("deque(%R, maxlen=%i)", aslist, + ((dequeobject *)deque)->maxlen); + else + result = PyUnicode_FromFormat("deque(%R)", aslist); Py_DECREF(aslist); Py_ReprLeave(deque); return result; @@ -712,13 +745,25 @@ } static int -deque_init(dequeobject *deque, PyObject *args, PyObject *kwds) +deque_init(dequeobject *deque, PyObject *args, PyObject *kwdargs) { PyObject *iterable = NULL; + PyObject *maxlenobj = NULL; + int maxlen = -1; + char *kwlist[] = {"iterable", "maxlen", 0}; - if (!PyArg_UnpackTuple(args, "deque", 0, 1, &iterable)) + if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist, &iterable, &maxlenobj)) return -1; - + if (maxlenobj != NULL && maxlenobj != Py_None) { + maxlen = PyInt_AsLong(maxlenobj); + if (maxlen == -1 && PyErr_Occurred()) + return -1; + if (maxlen < 0) { + PyErr_SetString(PyExc_ValueError, "maxlen must be non-negative"); + return -1; + } + } + deque->maxlen = maxlen; if (iterable != NULL) { PyObject *rv = deque_extend(deque, iterable); if (rv == NULL) @@ -773,7 +818,7 @@ }; PyDoc_STRVAR(deque_doc, -"deque(iterable) --> deque object\n\ +"deque(iterable[, maxlen]) --> deque object\n\ \n\ Build an ordered collection accessible from endpoints only."); @@ -1063,7 +1108,7 @@ whose class constructor has the same signature. Subclasses that define a different constructor signature must override copy(). */ - return PyObject_CallFunctionObjArgs((PyObject *)Py_Type(dd), + return PyObject_CallFunctionObjArgs((PyObject*)Py_Type(dd), dd->default_factory, dd, NULL); } Modified: python/branches/py3k/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/cfield.c (original) +++ python/branches/py3k/Modules/_ctypes/cfield.c Thu Nov 1 20:42:39 2007 @@ -1631,17 +1631,21 @@ /* XXX Hm, sizeof(int) == sizeof(long) doesn't hold on every platform */ /* As soon as we can get rid of the type codes, this is no longer a problem */ #if SIZEOF_LONG == 4 - { 'l', l_set, l_get, &ffi_type_sint, l_set_sw, l_get_sw}, - { 'L', L_set, L_get, &ffi_type_uint, L_set_sw, L_get_sw}, + { 'l', l_set, l_get, &ffi_type_sint32, l_set_sw, l_get_sw}, + { 'L', L_set, L_get, &ffi_type_uint32, L_set_sw, L_get_sw}, #elif SIZEOF_LONG == 8 - { 'l', l_set, l_get, &ffi_type_slong, l_set_sw, l_get_sw}, - { 'L', L_set, L_get, &ffi_type_ulong, L_set_sw, L_get_sw}, + { 'l', l_set, l_get, &ffi_type_sint64, l_set_sw, l_get_sw}, + { 'L', L_set, L_get, &ffi_type_uint64, L_set_sw, L_get_sw}, #else # error #endif #ifdef HAVE_LONG_LONG - { 'q', q_set, q_get, &ffi_type_slong, q_set_sw, q_get_sw}, - { 'Q', Q_set, Q_get, &ffi_type_ulong, Q_set_sw, Q_get_sw}, +#if SIZEOF_LONG_LONG == 8 + { 'q', q_set, q_get, &ffi_type_sint64, q_set_sw, q_get_sw}, + { 'Q', Q_set, Q_get, &ffi_type_uint64, Q_set_sw, Q_get_sw}, +#else +# error +#endif #endif { 'P', P_set, P_get, &ffi_type_pointer}, { 'z', z_set, z_get, &ffi_type_pointer}, @@ -1764,11 +1768,13 @@ ffi_type ffi_type_float = { sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT }; ffi_type ffi_type_double = { sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE }; + +#ifdef ffi_type_longdouble +#undef ffi_type_longdouble +#endif ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN, FFI_TYPE_LONGDOUBLE }; -/* ffi_type ffi_type_longdouble */ - ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER }; /*---------------- EOF ----------------*/ Modified: python/branches/py3k/Modules/_ctypes/libffi/src/alpha/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/alpha/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/alpha/ffi.c Thu Nov 1 20:42:39 2007 @@ -28,7 +28,7 @@ #include -extern void ffi_call_osf(void *, unsigned long, unsigned, void *, void (*)()); +extern void ffi_call_osf(void *, unsigned long, unsigned, void *, void (*)(void)); extern void ffi_closure_osf(void); @@ -58,7 +58,7 @@ } void -ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue) +ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { unsigned long *stack, *argp; long i, avn; Modified: python/branches/py3k/Modules/_ctypes/libffi/src/ia64/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/ia64/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/ia64/ffi.c Thu Nov 1 20:42:39 2007 @@ -259,10 +259,10 @@ return FFI_OK; } -extern int ffi_call_unix (struct ia64_args *, PTR64, void (*)(), UINT64); +extern int ffi_call_unix (struct ia64_args *, PTR64, void (*)(void), UINT64); void -ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue) +ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { struct ia64_args *stack; long i, avn, gpcount, fpcount; @@ -387,7 +387,7 @@ gp pointer to the closure. This allows the function entry code to both retrieve the user data, and to restire the correct gp pointer. */ -extern void ffi_closure_unix (); +extern void ffi_closure_unix (void); ffi_status ffi_prep_closure (ffi_closure* closure, Modified: python/branches/py3k/Modules/_ctypes/libffi/src/mips/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/mips/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/mips/ffi.c Thu Nov 1 20:42:39 2007 @@ -445,14 +445,14 @@ /* Low level routine for calling O32 functions */ extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int), extended_cif *, unsigned, - unsigned, unsigned *, void (*)()); + unsigned, unsigned *, void (*)(void)); /* Low level routine for calling N32 functions */ extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int), extended_cif *, unsigned, - unsigned, unsigned *, void (*)()); + unsigned, unsigned *, void (*)(void)); -void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue) +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { extended_cif ecif; Modified: python/branches/py3k/Modules/_ctypes/libffi/src/pa/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/pa/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/pa/ffi.c Thu Nov 1 20:42:39 2007 @@ -345,12 +345,12 @@ /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ void ffi_call(/*@dependent@*/ ffi_cif *cif, - void (*fn)(), + void (*fn)(void), /*@out@*/ void *rvalue, /*@dependent@*/ void **avalue) { Modified: python/branches/py3k/Modules/_ctypes/libffi/src/powerpc/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/powerpc/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/powerpc/ffi.c Thu Nov 1 20:42:39 2007 @@ -756,17 +756,17 @@ extern void ffi_call_SYSV(/*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, - void (*fn)()); + void (*fn)(void)); extern void FFI_HIDDEN ffi_call_LINUX64(/*@out@*/ extended_cif *, unsigned long, unsigned long, /*@out@*/ unsigned long *, - void (*fn)()); + void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ void ffi_call(/*@dependent@*/ ffi_cif *cif, - void (*fn)(), + void (*fn)(void), /*@out@*/ void *rvalue, /*@dependent@*/ void **avalue) { Modified: python/branches/py3k/Modules/_ctypes/libffi/src/s390/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/s390/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/s390/ffi.c Thu Nov 1 20:42:39 2007 @@ -88,7 +88,7 @@ void (*)(unsigned char *, extended_cif *), unsigned, void *, - void (*fn)()); + void (*fn)(void)); extern void ffi_closure_SYSV(void); @@ -480,7 +480,7 @@ void ffi_call(ffi_cif *cif, - void (*fn)(), + void (*fn)(void), void *rvalue, void **avalue) { Modified: python/branches/py3k/Modules/_ctypes/libffi/src/sparc/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/sparc/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/sparc/ffi.c Thu Nov 1 20:42:39 2007 @@ -358,13 +358,13 @@ #ifdef SPARC64 extern int ffi_call_v9(void *, extended_cif *, unsigned, - unsigned, unsigned *, void (*fn)()); + unsigned, unsigned *, void (*fn)(void)); #else extern int ffi_call_v8(void *, extended_cif *, unsigned, - unsigned, unsigned *, void (*fn)()); + unsigned, unsigned *, void (*fn)(void)); #endif -void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue) +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { extended_cif ecif; void *rval = rvalue; Copied: python/branches/py3k/Modules/bsddb.h (from r58739, python/trunk/Modules/bsddb.h) ============================================================================== --- python/trunk/Modules/bsddb.h (original) +++ python/branches/py3k/Modules/bsddb.h Thu Nov 1 20:42:39 2007 @@ -176,7 +176,7 @@ DBObject* mydb; PyObject *in_weakreflist; /* List of weak references */ } DBSequenceObject; -staticforward PyTypeObject DBSequence_Type; +static PyTypeObject DBSequence_Type; #endif Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Thu Nov 1 20:42:39 2007 @@ -2032,6 +2032,7 @@ typedef struct { PyObject_HEAD Py_ssize_t cnt; + PyObject *long_cnt; /* Arbitrarily large count when cnt >= PY_SSIZE_T_MAX */ } countobject; static PyTypeObject count_type; @@ -2041,37 +2042,89 @@ { countobject *lz; Py_ssize_t cnt = 0; + PyObject *cnt_arg = NULL; + PyObject *long_cnt = NULL; if (type == &count_type && !_PyArg_NoKeywords("count()", kwds)) return NULL; - if (!PyArg_ParseTuple(args, "|n:count", &cnt)) + if (!PyArg_UnpackTuple(args, "count", 0, 1, &cnt_arg)) return NULL; + if (cnt_arg != NULL) { + cnt = PyInt_AsSsize_t(cnt_arg); + if (cnt == -1 && PyErr_Occurred()) { + PyErr_Clear(); + if (!PyLong_Check(cnt_arg)) { + PyErr_SetString(PyExc_TypeError, "an integer is required"); + return NULL; + } + long_cnt = cnt_arg; + Py_INCREF(long_cnt); + cnt = PY_SSIZE_T_MAX; + } + } + /* create countobject structure */ lz = (countobject *)PyObject_New(countobject, &count_type); - if (lz == NULL) + if (lz == NULL) { + Py_XDECREF(long_cnt); return NULL; + } lz->cnt = cnt; + lz->long_cnt = long_cnt; return (PyObject *)lz; } +static void +count_dealloc(countobject *lz) +{ + Py_XDECREF(lz->long_cnt); + PyObject_Del(lz); +} + +static PyObject * +count_nextlong(countobject *lz) +{ + static PyObject *one = NULL; + PyObject *cnt; + PyObject *stepped_up; + + if (lz->long_cnt == NULL) { + lz->long_cnt = PyInt_FromSsize_t(PY_SSIZE_T_MAX); + if (lz->long_cnt == NULL) + return NULL; + } + if (one == NULL) { + one = PyInt_FromLong(1); + if (one == NULL) + return NULL; + } + cnt = lz->long_cnt; + assert(cnt != NULL); + stepped_up = PyNumber_Add(cnt, one); + if (stepped_up == NULL) + return NULL; + lz->long_cnt = stepped_up; + return cnt; +} + static PyObject * count_next(countobject *lz) { - if (lz->cnt == PY_SSIZE_T_MAX) { - PyErr_SetString(PyExc_OverflowError, - "cannot count beyond PY_SSIZE_T_MAX"); - return NULL; - } + if (lz->cnt == PY_SSIZE_T_MAX) + return count_nextlong(lz); return PyInt_FromSsize_t(lz->cnt++); } static PyObject * count_repr(countobject *lz) { - return PyUnicode_FromFormat("count(%zd)", lz->cnt); + if (lz->cnt != PY_SSIZE_T_MAX) + return PyUnicode_FromFormat("count(%zd)", lz->cnt); + + return PyUnicode_FromFormat("count(%R)", lz->long_cnt); } PyDoc_STRVAR(count_doc, @@ -2086,7 +2139,7 @@ sizeof(countobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)PyObject_Del, /* tp_dealloc */ + (destructor)count_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ Modified: python/branches/py3k/Modules/main.c ============================================================================== --- python/branches/py3k/Modules/main.c (original) +++ python/branches/py3k/Modules/main.c Thu Nov 1 20:42:39 2007 @@ -367,6 +367,7 @@ if (fstat(fileno(fp), &sb) == 0 && S_ISDIR(sb.st_mode)) { fprintf(stderr, "%s: '%s' is a directory, cannot continue\n", argv[0], filename); + fclose(fp); return 1; } } Modified: python/branches/py3k/Modules/mmapmodule.c ============================================================================== --- python/branches/py3k/Modules/mmapmodule.c (original) +++ python/branches/py3k/Modules/mmapmodule.c Thu Nov 1 20:42:39 2007 @@ -3,6 +3,9 @@ / Hacked for Unix by AMK / $Id$ + / Modified to support mmap with offset - to map a 'window' of a file + / Author: Yotam Medini yotamm at mellanox.co.il + / / mmapmodule.cpp -- map a view of a file into memory / / todo: need permission flags, perhaps a 'chsize' analog @@ -31,6 +34,16 @@ GetSystemInfo(&si); return si.dwPageSize; } + +static int +my_getallocationgranularity (void) +{ + + SYSTEM_INFO si; + GetSystemInfo(&si); + return si.dwAllocationGranularity; +} + #endif #ifdef UNIX @@ -43,6 +56,8 @@ { return sysconf(_SC_PAGESIZE); } + +#define my_getallocationgranularity my_getpagesize #else #define my_getpagesize getpagesize #endif @@ -74,7 +89,8 @@ PyObject_HEAD char * data; size_t size; - size_t pos; + size_t pos; /* relative to offset */ + size_t offset; int exports; #ifdef MS_WINDOWS @@ -398,18 +414,22 @@ #ifdef MS_WINDOWS } else { DWORD dwErrCode = 0; - DWORD newSizeLow, newSizeHigh; + DWORD off_hi, off_lo, newSizeLow, newSizeHigh; /* First, unmap the file view */ UnmapViewOfFile(self->data); /* Close the mapping object */ CloseHandle(self->map_handle); /* Move to the desired EOF position */ #if SIZEOF_SIZE_T > 4 - newSizeHigh = (DWORD)(new_size >> 32); - newSizeLow = (DWORD)(new_size & 0xFFFFFFFF); + newSizeHigh = (DWORD)((self->offset + new_size) >> 32); + newSizeLow = (DWORD)((self->offset + new_size) & 0xFFFFFFFF); + off_hi = (DWORD)(self->offset >> 32); + off_lo = (DWORD)(self->offset & 0xFFFFFFFF); #else newSizeHigh = 0; newSizeLow = (DWORD)new_size; + off_hi = 0; + off_lo = (DWORD)self->offset; #endif SetFilePointer(self->file_handle, newSizeLow, &newSizeHigh, FILE_BEGIN); @@ -420,15 +440,15 @@ self->file_handle, NULL, PAGE_READWRITE, - newSizeHigh, - newSizeLow, + 0, + 0, self->tagname); if (self->map_handle != NULL) { self->data = (char *) MapViewOfFile(self->map_handle, FILE_MAP_WRITE, - 0, - 0, - 0); + off_hi, + off_lo, + new_size); if (self->data != NULL) { self->size = new_size; Py_INCREF(Py_None); @@ -651,7 +671,7 @@ return NULL; if (i < 0) i += self->size; - if (i < 0 || i > self->size) { + if (i < 0 || (size_t)i > self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return NULL; @@ -753,7 +773,7 @@ return -1; if (i < 0) i += self->size; - if (i < 0 || i > self->size) { + if (i < 0 || (size_t)i > self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return -1; @@ -882,15 +902,18 @@ Returns -1 on error, with an appropriate Python exception raised. On success, the map size is returned. */ static Py_ssize_t -_GetMapSize(PyObject *o) +_GetMapSize(PyObject *o, const char* param) { + if (o == NULL) + return 0; if (PyIndex_Check(o)) { Py_ssize_t i = PyNumber_AsSsize_t(o, PyExc_OverflowError); if (i==-1 && PyErr_Occurred()) return -1; if (i < 0) { - PyErr_SetString(PyExc_OverflowError, - "memory mapped size must be positive"); + PyErr_Format(PyExc_OverflowError, + "memory mapped %s must be positive", + param); return -1; } return i; @@ -908,22 +931,25 @@ struct stat st; #endif mmap_object *m_obj; - PyObject *map_size_obj = NULL; - Py_ssize_t map_size; + PyObject *map_size_obj = NULL, *offset_obj = NULL; + Py_ssize_t map_size, offset; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; int devzero = -1; int access = (int)ACCESS_DEFAULT; static char *keywords[] = {"fileno", "length", "flags", "prot", - "access", NULL}; + "access", "offset", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iiiO", keywords, &fd, &map_size_obj, &flags, &prot, - &access)) + &access, &offset_obj)) return NULL; - map_size = _GetMapSize(map_size_obj); + map_size = _GetMapSize(map_size_obj, "size"); if (map_size < 0) return NULL; + offset = _GetMapSize(offset_obj, "offset"); + if (offset < 0) + return NULL; if ((access != (int)ACCESS_DEFAULT) && ((flags != MAP_SHARED) || (prot != (PROT_WRITE | PROT_READ)))) @@ -958,7 +984,7 @@ if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { if (map_size == 0) { map_size = st.st_size; - } else if ((size_t)map_size > st.st_size) { + } else if ((size_t)offset + (size_t)map_size > st.st_size) { PyErr_SetString(PyExc_ValueError, "mmap length is greater than file size"); return NULL; @@ -971,6 +997,7 @@ m_obj->size = (size_t) map_size; m_obj->pos = (size_t) 0; m_obj->exports = 0; + m_obj->offset = offset; if (fd == -1) { m_obj->fd = -1; /* Assume the caller wants to map anonymous memory. @@ -997,10 +1024,10 @@ return NULL; } } - + m_obj->data = mmap(NULL, map_size, prot, flags, - fd, 0); + fd, offset); if (devzero != -1) { close(devzero); @@ -1022,10 +1049,12 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) { mmap_object *m_obj; - PyObject *map_size_obj = NULL; - Py_ssize_t map_size; - DWORD size_hi; /* upper 32 bits of m_obj->size */ - DWORD size_lo; /* lower 32 bits of m_obj->size */ + PyObject *map_size_obj = NULL, *offset_obj = NULL; + Py_ssize_t map_size, offset; + DWORD off_hi; /* upper 32 bits of offset */ + DWORD off_lo; /* lower 32 bits of offset */ + DWORD size_hi; /* upper 32 bits of size */ + DWORD size_lo; /* lower 32 bits of size */ char *tagname = ""; DWORD dwErr = 0; int fileno; @@ -1034,11 +1063,11 @@ DWORD flProtect, dwDesiredAccess; static char *keywords[] = { "fileno", "length", "tagname", - "access", NULL }; + "access", "offset", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zi", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|ziO", keywords, &fileno, &map_size_obj, - &tagname, &access)) { + &tagname, &access, &offset_obj)) { return NULL; } @@ -1060,9 +1089,12 @@ "mmap invalid access parameter."); } - map_size = _GetMapSize(map_size_obj); + map_size = _GetMapSize(map_size_obj, "size"); if (map_size < 0) return NULL; + offset = _GetMapSize(offset_obj, "offset"); + if (offset < 0) + return NULL; /* assume -1 and 0 both mean invalid filedescriptor to 'anonymously' map memory. @@ -1092,6 +1124,7 @@ m_obj->file_handle = INVALID_HANDLE_VALUE; m_obj->map_handle = INVALID_HANDLE_VALUE; m_obj->tagname = NULL; + m_obj->offset = offset; if (fh) { /* It is necessary to duplicate the handle, so the @@ -1161,12 +1194,18 @@ * right by 32, so we need different code. */ #if SIZEOF_SIZE_T > 4 - size_hi = (DWORD)(m_obj->size >> 32); - size_lo = (DWORD)(m_obj->size & 0xFFFFFFFF); + size_hi = (DWORD)((offset + m_obj->size) >> 32); + size_lo = (DWORD)((offset + m_obj->size) & 0xFFFFFFFF); + off_hi = (DWORD)(offset >> 32); + off_lo = (DWORD)(offset & 0xFFFFFFFF); #else size_hi = 0; - size_lo = (DWORD)m_obj->size; + size_lo = (DWORD)(offset + m_obj->size); + off_hi = 0; + off_lo = (DWORD)offset; #endif + /* For files, it would be sufficient to pass 0 as size. + For anonymous maps, we have to pass the size explicitly. */ m_obj->map_handle = CreateFileMapping(m_obj->file_handle, NULL, flProtect, @@ -1176,8 +1215,8 @@ if (m_obj->map_handle != NULL) { m_obj->data = (char *) MapViewOfFile(m_obj->map_handle, dwDesiredAccess, - 0, - 0, + off_hi, + off_lo, 0); if (m_obj->data != NULL) return (PyObject *)m_obj; @@ -1252,6 +1291,8 @@ setint(dict, "PAGESIZE", (long)my_getpagesize()); + setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity()); + setint(dict, "ACCESS_READ", ACCESS_READ); setint(dict, "ACCESS_WRITE", ACCESS_WRITE); setint(dict, "ACCESS_COPY", ACCESS_COPY); Modified: python/branches/py3k/Objects/dictobject.c ============================================================================== --- python/branches/py3k/Objects/dictobject.c (original) +++ python/branches/py3k/Objects/dictobject.c Thu Nov 1 20:42:39 2007 @@ -9,8 +9,6 @@ #include "Python.h" -typedef PyDictEntry dictentry; -typedef PyDictObject dictobject; /* Set a key error with the specified argument, wrapping it in a * tuple automatically so that tuple keys are not unpacked as the @@ -116,14 +114,14 @@ polynomial for each table size was chosen such that x was a primitive root. Christian Tismer later extended that to use division by x instead, as an efficient way to get the high bits of the hash code into play. This scheme -also gave excellent collision statistics, but was more expensive: two if-tests -were required inside the loop; computing "the next" index took about the same -number of operations but without as much potential parallelism (e.g., -computing 5*j can go on at the same time as computing 1+perturb in the above, -and then shifting perturb can be done while the table index is being masked); -and the dictobject struct required a member to hold the table's polynomial. -In Tim's experiments the current scheme ran faster, produced equally good -collision statistics, needed less code & used less memory. +also gave excellent collision statistics, but was more expensive: two +if-tests were required inside the loop; computing "the next" index took about +the same number of operations but without as much potential parallelism +(e.g., computing 5*j can go on at the same time as computing 1+perturb in the +above, and then shifting perturb can be done while the table index is being +masked); and the PyDictObject struct required a member to hold the table's +polynomial. In Tim's experiments the current scheme ran faster, produced +equally good collision statistics, needed less code & used less memory. Theoretical Python 2.5 headache: hash codes are only C "long", but sizeof(Py_ssize_t) > sizeof(long) may be possible. In that case, and if a @@ -137,7 +135,7 @@ */ /* Object used as dummy key to fill deleted entries */ -static PyObject *dummy = NULL; /* Initialized by first call to newdictobject() */ +static PyObject *dummy = NULL; /* Initialized by first call to newPyDictObject() */ #ifdef Py_REF_DEBUG PyObject * @@ -148,8 +146,8 @@ #endif /* forward declarations */ -static dictentry * -lookdict_unicode(dictobject *mp, PyObject *key, long hash); +static PyDictEntry * +lookdict_unicode(PyDictObject *mp, PyObject *key, long hash); #ifdef SHOW_CONVERSION_COUNTS static long created = 0L; @@ -192,7 +190,7 @@ PyObject * PyDict_New(void) { - register dictobject *mp; + register PyDictObject *mp; if (dummy == NULL) { /* Auto-initialize dummy */ dummy = PyUnicode_FromString(""); if (dummy == NULL) @@ -213,7 +211,7 @@ assert (mp->ma_table == mp->ma_smalltable); assert (mp->ma_mask == PyDict_MINSIZE - 1); } else { - mp = PyObject_GC_New(dictobject, &PyDict_Type); + mp = PyObject_GC_New(PyDictObject, &PyDict_Type); if (mp == NULL) return NULL; EMPTY_TO_MINSIZE(mp); @@ -245,20 +243,20 @@ comparison raises an exception (this was new in Python 2.5). lookdict_unicode() below is specialized to string keys, comparison of which can never raise an exception; that function can never return NULL. For both, when -the key isn't found a dictentry* is returned for which the me_value field is +the key isn't found a PyDictEntry* is returned for which the me_value field is NULL; this is the slot in the dict at which the key would have been found, and the caller can (if it wishes) add the pair to the returned -dictentry*. +PyDictEntry*. */ -static dictentry * -lookdict(dictobject *mp, PyObject *key, register long hash) +static PyDictEntry * +lookdict(PyDictObject *mp, PyObject *key, register long hash) { register size_t i; register size_t perturb; - register dictentry *freeslot; + register PyDictEntry *freeslot; register size_t mask = (size_t)mp->ma_mask; - dictentry *ep0 = mp->ma_table; - register dictentry *ep; + PyDictEntry *ep0 = mp->ma_table; + register PyDictEntry *ep; register int cmp; PyObject *startkey; @@ -354,15 +352,15 @@ * * This is valuable because dicts with only unicode keys are very common. */ -static dictentry * -lookdict_unicode(dictobject *mp, PyObject *key, register long hash) +static PyDictEntry * +lookdict_unicode(PyDictObject *mp, PyObject *key, register long hash) { register size_t i; register size_t perturb; - register dictentry *freeslot; + register PyDictEntry *freeslot; register size_t mask = (size_t)mp->ma_mask; - dictentry *ep0 = mp->ma_table; - register dictentry *ep; + PyDictEntry *ep0 = mp->ma_table; + register PyDictEntry *ep; /* Make sure this function doesn't have to handle non-unicode keys, including subclasses of str; e.g., one reason to subclass @@ -413,10 +411,10 @@ Returns -1 if an error occurred, or 0 on success. */ static int -insertdict(register dictobject *mp, PyObject *key, long hash, PyObject *value) +insertdict(register PyDictObject *mp, PyObject *key, long hash, PyObject *value) { PyObject *old_value; - register dictentry *ep; + register PyDictEntry *ep; typedef PyDictEntry *(*lookupfunc)(PyDictObject *, PyObject *, long); assert(mp->ma_lookup != NULL); @@ -456,14 +454,14 @@ is responsible for incref'ing `key` and `value`. */ static void -insertdict_clean(register dictobject *mp, PyObject *key, long hash, +insertdict_clean(register PyDictObject *mp, PyObject *key, long hash, PyObject *value) { register size_t i; register size_t perturb; register size_t mask = (size_t)mp->ma_mask; - dictentry *ep0 = mp->ma_table; - register dictentry *ep; + PyDictEntry *ep0 = mp->ma_table; + register PyDictEntry *ep; i = hash & mask; ep = &ep0[i]; @@ -485,13 +483,13 @@ actually be smaller than the old one. */ static int -dictresize(dictobject *mp, Py_ssize_t minused) +dictresize(PyDictObject *mp, Py_ssize_t minused) { Py_ssize_t newsize; - dictentry *oldtable, *newtable, *ep; + PyDictEntry *oldtable, *newtable, *ep; Py_ssize_t i; int is_oldtable_malloced; - dictentry small_copy[PyDict_MINSIZE]; + PyDictEntry small_copy[PyDict_MINSIZE]; assert(minused >= 0); @@ -530,7 +528,7 @@ } } else { - newtable = PyMem_NEW(dictentry, newsize); + newtable = PyMem_NEW(PyDictEntry, newsize); if (newtable == NULL) { PyErr_NoMemory(); return -1; @@ -541,7 +539,7 @@ assert(newtable != oldtable); mp->ma_table = newtable; mp->ma_mask = newsize - 1; - memset(newtable, 0, sizeof(dictentry) * newsize); + memset(newtable, 0, sizeof(PyDictEntry) * newsize); mp->ma_used = 0; i = mp->ma_fill; mp->ma_fill = 0; @@ -581,8 +579,8 @@ PyDict_GetItem(PyObject *op, PyObject *key) { long hash; - dictobject *mp = (dictobject *)op; - dictentry *ep; + PyDictObject *mp = (PyDictObject *)op; + PyDictEntry *ep; PyThreadState *tstate; if (!PyDict_Check(op)) return NULL; @@ -628,8 +626,8 @@ PyDict_GetItemWithError(PyObject *op, PyObject *key) { long hash; - dictobject *mp = (dictobject *)op; - dictentry *ep; + PyDictObject*mp = (PyDictObject *)op; + PyDictEntry *ep; if (!PyDict_Check(op)) { PyErr_BadInternalCall(); @@ -659,7 +657,7 @@ int PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) { - register dictobject *mp; + register PyDictObject *mp; register long hash; register Py_ssize_t n_used; @@ -669,7 +667,7 @@ } assert(key); assert(value); - mp = (dictobject *)op; + mp = (PyDictObject *)op; if (!PyUnicode_CheckExact(key) || (hash = ((PyUnicodeObject *) key)->hash) == -1) { @@ -705,9 +703,9 @@ int PyDict_DelItem(PyObject *op, PyObject *key) { - register dictobject *mp; + register PyDictObject *mp; register long hash; - register dictentry *ep; + register PyDictEntry *ep; PyObject *old_value, *old_key; if (!PyDict_Check(op)) { @@ -721,7 +719,7 @@ if (hash == -1) return -1; } - mp = (dictobject *)op; + mp = (PyDictObject *)op; ep = (mp->ma_lookup)(mp, key, hash); if (ep == NULL) return -1; @@ -743,18 +741,18 @@ void PyDict_Clear(PyObject *op) { - dictobject *mp; - dictentry *ep, *table; + PyDictObject *mp; + PyDictEntry *ep, *table; int table_is_malloced; Py_ssize_t fill; - dictentry small_copy[PyDict_MINSIZE]; + PyDictEntry small_copy[PyDict_MINSIZE]; #ifdef Py_DEBUG Py_ssize_t i, n; #endif if (!PyDict_Check(op)) return; - mp = (dictobject *)op; + mp = (PyDictObject *)op; #ifdef Py_DEBUG n = mp->ma_mask + 1; i = 0; @@ -829,15 +827,15 @@ { register Py_ssize_t i; register Py_ssize_t mask; - register dictentry *ep; + register PyDictEntry *ep; if (!PyDict_Check(op)) return 0; i = *ppos; if (i < 0) return 0; - ep = ((dictobject *)op)->ma_table; - mask = ((dictobject *)op)->ma_mask; + ep = ((PyDictObject *)op)->ma_table; + mask = ((PyDictObject *)op)->ma_mask; while (i <= mask && ep[i].me_value == NULL) i++; *ppos = i+1; @@ -856,15 +854,15 @@ { register Py_ssize_t i; register Py_ssize_t mask; - register dictentry *ep; + register PyDictEntry *ep; if (!PyDict_Check(op)) return 0; i = *ppos; if (i < 0) return 0; - ep = ((dictobject *)op)->ma_table; - mask = ((dictobject *)op)->ma_mask; + ep = ((PyDictObject *)op)->ma_table; + mask = ((PyDictObject *)op)->ma_mask; while (i <= mask && ep[i].me_value == NULL) i++; *ppos = i+1; @@ -881,9 +879,9 @@ /* Methods */ static void -dict_dealloc(register dictobject *mp) +dict_dealloc(register PyDictObject *mp) { - register dictentry *ep; + register PyDictEntry *ep; Py_ssize_t fill = mp->ma_fill; PyObject_GC_UnTrack(mp); Py_TRASHCAN_SAFE_BEGIN(mp) @@ -904,7 +902,7 @@ } static PyObject * -dict_repr(dictobject *mp) +dict_repr(PyDictObject *mp) { Py_ssize_t i; PyObject *s, *temp, *colon = NULL; @@ -983,17 +981,17 @@ } static Py_ssize_t -dict_length(dictobject *mp) +dict_length(PyDictObject *mp) { return mp->ma_used; } static PyObject * -dict_subscript(dictobject *mp, register PyObject *key) +dict_subscript(PyDictObject *mp, register PyObject *key) { PyObject *v; long hash; - dictentry *ep; + PyDictEntry *ep; assert(mp->ma_table != NULL); if (!PyUnicode_CheckExact(key) || (hash = ((PyUnicodeObject *) key)->hash) == -1) { @@ -1027,7 +1025,7 @@ } static int -dict_ass_sub(dictobject *mp, PyObject *v, PyObject *w) +dict_ass_sub(PyDictObject *mp, PyObject *v, PyObject *w) { if (w == NULL) return PyDict_DelItem((PyObject *)mp, v); @@ -1042,11 +1040,11 @@ }; static PyObject * -dict_keys(register dictobject *mp) +dict_keys(register PyDictObject *mp) { register PyObject *v; register Py_ssize_t i, j; - dictentry *ep; + PyDictEntry *ep; Py_ssize_t mask, n; again: @@ -1076,11 +1074,11 @@ } static PyObject * -dict_values(register dictobject *mp) +dict_values(register PyDictObject *mp) { register PyObject *v; register Py_ssize_t i, j; - dictentry *ep; + PyDictEntry *ep; Py_ssize_t mask, n; again: @@ -1110,13 +1108,13 @@ } static PyObject * -dict_items(register dictobject *mp) +dict_items(register PyDictObject *mp) { register PyObject *v; register Py_ssize_t i, j, n; Py_ssize_t mask; PyObject *item, *key, *value; - dictentry *ep; + PyDictEntry *ep; /* Preallocate the list of tuples, to avoid allocations during * the loop over the items, which could trigger GC, which @@ -1178,7 +1176,7 @@ return NULL; if (PyDict_CheckExact(d) && PyAnySet_CheckExact(seq)) { - dictobject *mp = (dictobject *)d; + PyDictObject *mp = (PyDictObject *)d; Py_ssize_t pos = 0; PyObject *key; long hash; @@ -1342,7 +1340,7 @@ { register PyDictObject *mp, *other; register Py_ssize_t i; - dictentry *entry; + PyDictEntry *entry; /* We accept for the argument either a concrete dictionary object, * or an abstract "mapping" object. For the former, we can do @@ -1353,9 +1351,9 @@ PyErr_BadInternalCall(); return -1; } - mp = (dictobject*)a; + mp = (PyDictObject*)a; if (PyDict_CheckExact(b)) { - other = (dictobject*)b; + other = (PyDictObject*)b; if (other == mp || other->ma_used == 0) /* a.update(a) or a.update({}); nothing to do */ return 0; @@ -1435,7 +1433,7 @@ } static PyObject * -dict_copy(register dictobject *mp) +dict_copy(register PyDictObject *mp) { return PyDict_Copy((PyObject*)mp); } @@ -1465,7 +1463,7 @@ PyErr_BadInternalCall(); return -1; } - return ((dictobject *)mp)->ma_used; + return ((PyDictObject *)mp)->ma_used; } PyObject * @@ -1475,7 +1473,7 @@ PyErr_BadInternalCall(); return NULL; } - return dict_keys((dictobject *)mp); + return dict_keys((PyDictObject *)mp); } PyObject * @@ -1485,7 +1483,7 @@ PyErr_BadInternalCall(); return NULL; } - return dict_values((dictobject *)mp); + return dict_values((PyDictObject *)mp); } PyObject * @@ -1495,7 +1493,7 @@ PyErr_BadInternalCall(); return NULL; } - return dict_items((dictobject *)mp); + return dict_items((PyDictObject *)mp); } /* Return 1 if dicts equal, 0 if not, -1 if error. @@ -1503,7 +1501,7 @@ * Uses only Py_EQ comparison. */ static int -dict_equal(dictobject *a, dictobject *b) +dict_equal(PyDictObject *a, PyDictObject *b) { Py_ssize_t i; @@ -1550,7 +1548,7 @@ res = Py_NotImplemented; } else if (op == Py_EQ || op == Py_NE) { - cmp = dict_equal((dictobject *)v, (dictobject *)w); + cmp = dict_equal((PyDictObject *)v, (PyDictObject *)w); if (cmp < 0) return NULL; res = (cmp == (op == Py_EQ)) ? Py_True : Py_False; @@ -1562,10 +1560,10 @@ } static PyObject * -dict_contains(register dictobject *mp, PyObject *key) +dict_contains(register PyDictObject *mp, PyObject *key) { long hash; - dictentry *ep; + PyDictEntry *ep; if (!PyUnicode_CheckExact(key) || (hash = ((PyUnicodeObject *) key)->hash) == -1) { @@ -1580,13 +1578,13 @@ } static PyObject * -dict_get(register dictobject *mp, PyObject *args) +dict_get(register PyDictObject *mp, PyObject *args) { PyObject *key; PyObject *failobj = Py_None; PyObject *val = NULL; long hash; - dictentry *ep; + PyDictEntry *ep; if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &failobj)) return NULL; @@ -1609,13 +1607,13 @@ static PyObject * -dict_setdefault(register dictobject *mp, PyObject *args) +dict_setdefault(register PyDictObject *mp, PyObject *args) { PyObject *key; PyObject *failobj = Py_None; PyObject *val = NULL; long hash; - dictentry *ep; + PyDictEntry *ep; if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &key, &failobj)) return NULL; @@ -1641,17 +1639,17 @@ static PyObject * -dict_clear(register dictobject *mp) +dict_clear(register PyDictObject *mp) { PyDict_Clear((PyObject *)mp); Py_RETURN_NONE; } static PyObject * -dict_pop(dictobject *mp, PyObject *args) +dict_pop(PyDictObject *mp, PyObject *args) { long hash; - dictentry *ep; + PyDictEntry *ep; PyObject *old_value, *old_key; PyObject *key, *deflt = NULL; @@ -1694,10 +1692,10 @@ } static PyObject * -dict_popitem(dictobject *mp) +dict_popitem(PyDictObject *mp) { Py_ssize_t i = 0; - dictentry *ep; + PyDictEntry *ep; PyObject *res; /* Allocate the result tuple before checking the size. Believe it @@ -1776,7 +1774,7 @@ extern PyTypeObject PyDictIterKey_Type; /* Forward */ extern PyTypeObject PyDictIterValue_Type; /* Forward */ extern PyTypeObject PyDictIterItem_Type; /* Forward */ -static PyObject *dictiter_new(dictobject *, PyTypeObject *); +static PyObject *dictiter_new(PyDictObject *, PyTypeObject *); PyDoc_STRVAR(contains__doc__, @@ -1859,8 +1857,8 @@ PyDict_Contains(PyObject *op, PyObject *key) { long hash; - dictobject *mp = (dictobject *)op; - dictentry *ep; + PyDictObject *mp = (PyDictObject *)op; + PyDictEntry *ep; if (!PyUnicode_CheckExact(key) || (hash = ((PyUnicodeObject *) key)->hash) == -1) { @@ -1876,8 +1874,8 @@ int _PyDict_Contains(PyObject *op, PyObject *key, long hash) { - dictobject *mp = (dictobject *)op; - dictentry *ep; + PyDictObject *mp = (PyDictObject *)op; + PyDictEntry *ep; ep = (mp->ma_lookup)(mp, key, hash); return ep == NULL ? -1 : (ep->me_value != NULL); @@ -1924,7 +1922,7 @@ } static PyObject * -dict_iter(dictobject *dict) +dict_iter(PyDictObject *dict) { return dictiter_new(dict, &PyDictIterKey_Type); } @@ -1943,7 +1941,7 @@ PyTypeObject PyDict_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "dict", - sizeof(dictobject), + sizeof(PyDictObject), 0, (destructor)dict_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -2028,7 +2026,7 @@ typedef struct { PyObject_HEAD - dictobject *di_dict; /* Set to NULL when iterator is exhausted */ + PyDictObject *di_dict; /* Set to NULL when iterator is exhausted */ Py_ssize_t di_used; Py_ssize_t di_pos; PyObject* di_result; /* reusable result tuple for iteritems */ @@ -2036,7 +2034,7 @@ } dictiterobject; static PyObject * -dictiter_new(dictobject *dict, PyTypeObject *itertype) +dictiter_new(PyDictObject *dict, PyTypeObject *itertype) { dictiterobject *di; di = PyObject_New(dictiterobject, itertype); @@ -2089,8 +2087,8 @@ { PyObject *key; register Py_ssize_t i, mask; - register dictentry *ep; - dictobject *d = di->di_dict; + register PyDictEntry *ep; + PyDictObject *d = di->di_dict; if (d == NULL) return NULL; @@ -2161,8 +2159,8 @@ { PyObject *value; register Py_ssize_t i, mask; - register dictentry *ep; - dictobject *d = di->di_dict; + register PyDictEntry *ep; + PyDictObject *d = di->di_dict; if (d == NULL) return NULL; @@ -2233,8 +2231,8 @@ { PyObject *key, *value, *result = di->di_result; register Py_ssize_t i, mask; - register dictentry *ep; - dictobject *d = di->di_dict; + register PyDictEntry *ep; + PyDictObject *d = di->di_dict; if (d == NULL) return NULL; @@ -2324,7 +2322,7 @@ typedef struct { PyObject_HEAD - dictobject *dv_dict; + PyDictObject *dv_dict; } dictviewobject; @@ -2363,7 +2361,7 @@ if (dv == NULL) return NULL; Py_INCREF(dict); - dv->dv_dict = (dictobject *)dict; + dv->dv_dict = (PyDictObject *)dict; return (PyObject *)dv; } Modified: python/branches/py3k/Objects/enumobject.c ============================================================================== --- python/branches/py3k/Objects/enumobject.c (original) +++ python/branches/py3k/Objects/enumobject.c Thu Nov 1 20:42:39 2007 @@ -7,6 +7,7 @@ long en_index; /* current index of enumeration */ PyObject* en_sit; /* secondary iterator of enumeration */ PyObject* en_result; /* result tuple */ + PyObject* en_longindex; /* index for sequences >= LONG_MAX */ } enumobject; static PyObject * @@ -25,6 +26,7 @@ return NULL; en->en_index = 0; en->en_sit = PyObject_GetIter(seq); + en->en_longindex = NULL; if (en->en_sit == NULL) { Py_DECREF(en); return NULL; @@ -43,6 +45,7 @@ PyObject_GC_UnTrack(en); Py_XDECREF(en->en_sit); Py_XDECREF(en->en_result); + Py_XDECREF(en->en_longindex); Py_Type(en)->tp_free(en); } @@ -51,10 +54,53 @@ { Py_VISIT(en->en_sit); Py_VISIT(en->en_result); + Py_VISIT(en->en_longindex); return 0; } static PyObject * +enum_next_long(enumobject *en, PyObject* next_item) +{ + static PyObject *one = NULL; + PyObject *result = en->en_result; + PyObject *next_index; + PyObject *stepped_up; + + if (en->en_longindex == NULL) { + en->en_longindex = PyInt_FromLong(LONG_MAX); + if (en->en_longindex == NULL) + return NULL; + } + if (one == NULL) { + one = PyInt_FromLong(1); + if (one == NULL) + return NULL; + } + next_index = en->en_longindex; + assert(next_index != NULL); + stepped_up = PyNumber_Add(next_index, one); + if (stepped_up == NULL) + return NULL; + en->en_longindex = stepped_up; + + if (result->ob_refcnt == 1) { + Py_INCREF(result); + Py_DECREF(PyTuple_GET_ITEM(result, 0)); + Py_DECREF(PyTuple_GET_ITEM(result, 1)); + } else { + result = PyTuple_New(2); + if (result == NULL) { + Py_DECREF(next_index); + Py_DECREF(next_item); + return NULL; + } + } + PyTuple_SET_ITEM(result, 0, next_index); + PyTuple_SET_ITEM(result, 1, next_item); + return result; +} + +static PyObject * enum_next(enumobject *en) { PyObject *next_index; @@ -62,16 +108,13 @@ PyObject *result = en->en_result; PyObject *it = en->en_sit; - if (en->en_index == LONG_MAX) { - PyErr_SetString(PyExc_OverflowError, - "enumerate() is limited to LONG_MAX items"); - return NULL; - } - next_item = (*Py_Type(it)->tp_iternext)(it); if (next_item == NULL) return NULL; + if (en->en_index == LONG_MAX) + return enum_next_long(en, next_item); + next_index = PyInt_FromLong(en->en_index); if (next_index == NULL) { Py_DECREF(next_item); Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Thu Nov 1 20:42:39 2007 @@ -463,10 +463,10 @@ if (n < 0) n = 0; size = Py_Size(a) * n; - if (size == 0) - return PyList_New(0); if (n && size/n != Py_Size(a)) return PyErr_NoMemory(); + if (size == 0) + return PyList_New(0); np = (PyListObject *) PyList_New(size); if (np == NULL) return NULL; @@ -633,7 +633,7 @@ list_inplace_repeat(PyListObject *self, Py_ssize_t n) { PyObject **items; - Py_ssize_t size, i, j, p; + Py_ssize_t size, i, j, p, newsize; size = PyList_GET_SIZE(self); @@ -648,7 +648,10 @@ return (PyObject *)self; } - if (list_resize(self, size*n) == -1) + newsize = size * n; + if (newsize/n != size) + return PyErr_NoMemory(); + if (list_resize(self, newsize) == -1) return NULL; p = size; Modified: python/branches/py3k/Objects/object.c ============================================================================== --- python/branches/py3k/Objects/object.c (original) +++ python/branches/py3k/Objects/object.c Thu Nov 1 20:42:39 2007 @@ -423,7 +423,12 @@ if (Py_Type(v)->tp_str == NULL) return PyObject_Repr(v); + /* It is possible for a type to have a tp_str representation that loops + infinitely. */ + if (Py_EnterRecursiveCall(" while getting the str of an object")) + return NULL; res = (*Py_Type(v)->tp_str)(v); + Py_LeaveRecursiveCall(); if (res == NULL) return NULL; if (!(PyString_Check(res) || PyUnicode_Check(res))) { Modified: python/branches/py3k/Objects/stringobject.c ============================================================================== --- python/branches/py3k/Objects/stringobject.c (original) +++ python/branches/py3k/Objects/stringobject.c Thu Nov 1 20:42:39 2007 @@ -598,15 +598,15 @@ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': c = s[-1] - '0'; - if ('0' <= *s && *s <= '7') { + if (s < end && '0' <= *s && *s <= '7') { c = (c<<3) + *s++ - '0'; - if ('0' <= *s && *s <= '7') + if (s < end && '0' <= *s && *s <= '7') c = (c<<3) + *s++ - '0'; } *p++ = c; break; case 'x': - if (ISXDIGIT(s[0]) && ISXDIGIT(s[1])) { + if (s+1 < end && ISXDIGIT(s[0]) && ISXDIGIT(s[1])) { unsigned int x = 0; c = Py_CHARMASK(*s); s++; Modified: python/branches/py3k/Objects/tupleobject.c ============================================================================== --- python/branches/py3k/Objects/tupleobject.c (original) +++ python/branches/py3k/Objects/tupleobject.c Thu Nov 1 20:42:39 2007 @@ -195,13 +195,25 @@ if (n == 0) return PyUnicode_FromString("()"); + /* While not mutable, it is still possible to end up with a cycle in a + tuple through an object that stores itself within a tuple (and thus + infinitely asks for the repr of itself). This should only be + possible within a type. */ + i = Py_ReprEnter((PyObject *)v); + if (i != 0) { + return i > 0 ? PyString_FromString("(...)") : NULL; + } + pieces = PyTuple_New(n); if (pieces == NULL) return NULL; /* Do repr() on each element. */ for (i = 0; i < n; ++i) { + if (Py_EnterRecursiveCall(" while getting the repr of a tuple")) + goto Done; s = PyObject_Repr(v->ob_item[i]); + Py_LeaveRecursiveCall(); if (s == NULL) goto Done; PyTuple_SET_ITEM(pieces, i, s); @@ -236,6 +248,7 @@ Done: Py_DECREF(pieces); + Py_ReprLeave((PyObject *)v); return result; } Modified: python/branches/py3k/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k/Objects/unicodeobject.c (original) +++ python/branches/py3k/Objects/unicodeobject.c Thu Nov 1 20:42:39 2007 @@ -2671,7 +2671,10 @@ startinpos = s-starts; /* \ - Escapes */ s++; - switch (*s++) { + c = *s++; + if (s > end) + c = '\0'; /* Invalid after \ */ + switch (c) { /* \x escapes */ case '\n': break; @@ -2690,9 +2693,9 @@ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': x = s[-1] - '0'; - if ('0' <= *s && *s <= '7') { + if (s < end && '0' <= *s && *s <= '7') { x = (x<<3) + *s++ - '0'; - if ('0' <= *s && *s <= '7') + if (s < end && '0' <= *s && *s <= '7') x = (x<<3) + *s++ - '0'; } *p++ = x; Modified: python/branches/py3k/PC/pyconfig.h ============================================================================== --- python/branches/py3k/PC/pyconfig.h (original) +++ python/branches/py3k/PC/pyconfig.h Thu Nov 1 20:42:39 2007 @@ -377,11 +377,11 @@ define these. If some compiler does not provide them, modify the #if appropriately. */ #if defined(_MSC_VER) -#if _MSC_VER > 1201 +#if _MSC_VER > 1300 #define HAVE_UINTPTR_T 1 #define HAVE_INTPTR_T 1 #else -/* VC6 & eVC4 don't support the C99 LL suffix for 64-bit integer literals */ +/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */ #define Py_LL(x) x##I64 #endif /* _MSC_VER > 1200 */ #endif /* _MSC_VER */ Modified: python/branches/py3k/Parser/pgen.c ============================================================================== --- python/branches/py3k/Parser/pgen.c (original) +++ python/branches/py3k/Parser/pgen.c Thu Nov 1 20:42:39 2007 @@ -124,7 +124,7 @@ nf = newnfa(name); gr->gr_nfa = (nfa **)PyObject_REALLOC(gr->gr_nfa, - sizeof(nfa) * (gr->gr_nnfas + 1)); + sizeof(nfa*) * (gr->gr_nnfas + 1)); if (gr->gr_nfa == NULL) Py_FatalError("out of mem"); gr->gr_nfa[gr->gr_nnfas++] = nf; @@ -487,6 +487,7 @@ convert(d, xx_nstates, xx_state); /* XXX cleanup */ + PyObject_FREE(xx_state); } static void Modified: python/branches/py3k/Python/ast.c ============================================================================== --- python/branches/py3k/Python/ast.c (original) +++ python/branches/py3k/Python/ast.c Thu Nov 1 20:42:39 2007 @@ -1539,7 +1539,7 @@ tmp_result = BinOp(result, newoperator, tmp, LINENO(next_oper), next_oper->n_col_offset, c->c_arena); - if (!tmp) + if (!tmp_result) return NULL; result = tmp_result; } Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Thu Nov 1 20:42:39 2007 @@ -1611,6 +1611,84 @@ Py_INCREF(result); } +#ifndef SLOW_SUM + /* Fast addition by keeping temporary sums in C instead of new Python objects. + Assumes all inputs are the same type. If the assumption fails, default + to the more general routine. + */ + if (PyInt_CheckExact(result)) { + long i_result = PyInt_AS_LONG(result); + Py_DECREF(result); + result = NULL; + while(result == NULL) { + item = PyIter_Next(iter); + if (item == NULL) { + Py_DECREF(iter); + if (PyErr_Occurred()) + return NULL; + return PyInt_FromLong(i_result); + } + if (PyInt_CheckExact(item)) { + long b = PyInt_AS_LONG(item); + long x = i_result + b; + if ((x^i_result) >= 0 || (x^b) >= 0) { + i_result = x; + Py_DECREF(item); + continue; + } + } + /* Either overflowed or is not an int. Restore real objects and process normally */ + result = PyInt_FromLong(i_result); + temp = PyNumber_Add(result, item); + Py_DECREF(result); + Py_DECREF(item); + result = temp; + if (result == NULL) { + Py_DECREF(iter); + return NULL; + } + } + } + + if (PyFloat_CheckExact(result)) { + double f_result = PyFloat_AS_DOUBLE(result); + Py_DECREF(result); + result = NULL; + while(result == NULL) { + item = PyIter_Next(iter); + if (item == NULL) { + Py_DECREF(iter); + if (PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(f_result); + } + if (PyFloat_CheckExact(item)) { + PyFPE_START_PROTECT("add", return 0) + f_result += PyFloat_AS_DOUBLE(item); + PyFPE_END_PROTECT(f_result) + Py_DECREF(item); + continue; + } + if (PyInt_CheckExact(item)) { + PyFPE_START_PROTECT("add", return 0) + f_result += (double)PyInt_AS_LONG(item); + PyFPE_END_PROTECT(f_result) + Py_DECREF(item); + continue; + } + result = PyFloat_FromDouble(f_result); + temp = PyNumber_Add(result, item); + Py_DECREF(result); + Py_DECREF(item); + result = temp; + if (result == NULL) { + Py_DECREF(iter); + return NULL; + } + } + } +#endif + for(;;) { item = PyIter_Next(iter); if (item == NULL) { Modified: python/branches/py3k/Python/marshal.c ============================================================================== --- python/branches/py3k/Python/marshal.c (original) +++ python/branches/py3k/Python/marshal.c Thu Nov 1 20:42:39 2007 @@ -1009,6 +1009,7 @@ RFILE rf; rf.fp = fp; rf.strings = NULL; + rf.ptr = rf.end = NULL; return r_long(&rf); } @@ -1082,6 +1083,7 @@ rf.fp = fp; rf.strings = PyList_New(0); rf.depth = 0; + rf.ptr = rf.end = NULL; result = r_object(&rf); Py_DECREF(rf.strings); return result; Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Thu Nov 1 20:42:39 2007 @@ -13172,6 +13172,138 @@ # Check for use of the system libffi library +if test "${ac_cv_header_ffi_h+set}" = set; then + { echo "$as_me:$LINENO: checking for ffi.h" >&5 +echo $ECHO_N "checking for ffi.h... $ECHO_C" >&6; } +if test "${ac_cv_header_ffi_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5 +echo "${ECHO_T}$ac_cv_header_ffi_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking ffi.h usability" >&5 +echo $ECHO_N "checking ffi.h usability... $ECHO_C" >&6; } +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 +_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_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +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 ffi.h presence" >&5 +echo $ECHO_N "checking ffi.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +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 && { + 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 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: ffi.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: ffi.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: ffi.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: ffi.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: ffi.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: ffi.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: ffi.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: ffi.h: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for ffi.h" >&5 +echo $ECHO_N "checking for ffi.h... $ECHO_C" >&6; } +if test "${ac_cv_header_ffi_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_ffi_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5 +echo "${ECHO_T}$ac_cv_header_ffi_h" >&6; } + +fi + + { echo "$as_me:$LINENO: checking for --with-system-ffi" >&5 echo $ECHO_N "checking for --with-system-ffi... $ECHO_C" >&6; } @@ -13181,8 +13313,11 @@ fi -if test -z "$with_system_ffi" -then with_system_ffi="no" +if test -z "$with_system_ffi" && test "$ac_cv_header_ffi_h" = yes; then + case "$ac_sys_system/`uname -m`" in + Linux/arm*) with_system_ffi="yes"; CONFIG_ARGS="$CONFIG_ARGS --with-system-ffi";; + *) with_system_ffi="no" + esac fi { echo "$as_me:$LINENO: result: $with_system_ffi" >&5 echo "${ECHO_T}$with_system_ffi" >&6; } Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Thu Nov 1 20:42:39 2007 @@ -1724,12 +1724,16 @@ [AC_MSG_RESULT(no)]) # Check for use of the system libffi library +AC_CHECK_HEADER(ffi.h) AC_MSG_CHECKING(for --with-system-ffi) AC_ARG_WITH(system_ffi, AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library)) -if test -z "$with_system_ffi" -then with_system_ffi="no" +if test -z "$with_system_ffi" && test "$ac_cv_header_ffi_h" = yes; then + case "$ac_sys_system/`uname -m`" in + Linux/arm*) with_system_ffi="yes"; CONFIG_ARGS="$CONFIG_ARGS --with-system-ffi";; + *) with_system_ffi="no" + esac fi AC_MSG_RESULT($with_system_ffi) Modified: python/branches/py3k/setup.py ============================================================================== --- python/branches/py3k/setup.py (original) +++ python/branches/py3k/setup.py Thu Nov 1 20:42:39 2007 @@ -773,6 +773,7 @@ # some unusual system configurations (e.g. the directory # is on an NFS server that goes away). exts.append(Extension('_bsddb', ['_bsddb.c'], + depends = ['bsddb.h'], library_dirs=dblib_dir, runtime_library_dirs=dblib_dir, include_dirs=db_incs, @@ -1091,7 +1092,7 @@ # Platform-specific libraries if platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', - 'freebsd7'): + 'freebsd7', 'freebsd8'): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) else: missing.append('ossaudiodev') From guido at python.org Thu Nov 1 20:44:37 2007 From: guido at python.org (Guido van Rossum) Date: Thu, 1 Nov 2007 12:44:37 -0700 Subject: [Python-3000-checkins] r58747 - python/branches/py3k/Lib/test/test_import.py python/branches/py3k/Lib/test/test_os.py In-Reply-To: <20071101190842.BBCF71E4005@bag.python.org> References: <20071101190842.BBCF71E4005@bag.python.org> Message-ID: Two things: (1) please don't use non-ASCII text in the standard library, even in test code. Instead, use \uXXXX escapes. (2) test_sys_path fails on my Ubuntu box: ====================================================================== ERROR: test_sys_path (__main__.UnicodePathsTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "Lib/test/test_import.py", line 183, in test_sys_path mod = __import__("testimport%i" % i) ImportError: No module named testimport1 On 11/1/07, christian.heimes wrote: > Author: christian.heimes > Date: Thu Nov 1 20:08:42 2007 > New Revision: 58747 > > Modified: > python/branches/py3k/Lib/test/test_import.py > python/branches/py3k/Lib/test/test_os.py > Log: > Fixed unit tests for os.environ. Some of the tests didn't test at all because os.environ was empty. > Added import test for sys.path entries with non ASCII characters. The tests are passing on my Ubuntu box with utf-8 locales but they aren't passing on Windows XP. > > Modified: python/branches/py3k/Lib/test/test_import.py > ============================================================================== > --- python/branches/py3k/Lib/test/test_import.py (original) > +++ python/branches/py3k/Lib/test/test_import.py Thu Nov 1 20:08:42 2007 > @@ -3,10 +3,11 @@ > import unittest > import os > import random > +import shutil > import sys > import py_compile > import warnings > -from test.test_support import unlink > +from test.test_support import unlink, TESTFN, unload > > > def remove_files(name): > @@ -157,8 +158,37 @@ > warnings.simplefilter('error', ImportWarning) > self.assertRaises(ImportWarning, __import__, "site-packages") > > +class UnicodePathsTests(unittest.TestCase): > + SAMPLES = ('test', 'test????', 'test??', 'test???') > + path = TESTFN > + > + def setUp(self): > + os.mkdir(self.path) > + self.syspath = sys.path[:] > + > + def tearDown(self): > + shutil.rmtree(self.path) > + sys.path = self.syspath > + > + def test_sys_path(self): > + for i, subpath in enumerate(self.SAMPLES): > + path = os.path.join(self.path, subpath) > + os.mkdir(path) > + self.failUnless(os.path.exists(path), os.listdir(self.path)) > + f = open(os.path.join(path, 'testimport%i.py' % i), 'w') > + f.write("testdata = 'unicode path %i'\n" % i) > + f.close() > + sys.path.append(path) > + try: > + mod = __import__("testimport%i" % i) > + except ImportError: > + print(path, file=sys.stderr) > + raise > + self.assertEqual(mod.testdata, 'unicode path %i' % i) > + unload("testimport%i" % i) > + > def test_main(verbose=None): > - run_unittest(ImportTest) > + run_unittest(ImportTest, UnicodePathsTests) > > if __name__ == '__main__': > test_main() > > Modified: python/branches/py3k/Lib/test/test_os.py > ============================================================================== > --- python/branches/py3k/Lib/test/test_os.py (original) > +++ python/branches/py3k/Lib/test/test_os.py Thu Nov 1 20:08:42 2007 > @@ -191,20 +191,26 @@ > class EnvironTests(mapping_tests.BasicTestMappingProtocol): > """check that os.environ object conform to mapping protocol""" > type2test = None > - def _reference(self): > - return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"} > - def _empty_mapping(self): > - os.environ.clear() > - return os.environ > + > def setUp(self): > self.__save = dict(os.environ) > - os.environ.clear() > + for key, value in self._reference().items(): > + os.environ[key] = value > + > def tearDown(self): > os.environ.clear() > os.environ.update(self.__save) > > + def _reference(self): > + return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"} > + > + def _empty_mapping(self): > + os.environ.clear() > + return os.environ > + > # Bug 1110478 > def test_update2(self): > + os.environ.clear() > if os.path.exists("/bin/sh"): > os.environ.update(HELLO="World") > value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() > @@ -217,6 +223,10 @@ > self.assertEquals(type(key), str) > self.assertEquals(type(val), str) > > + def test_items(self): > + for key, value in self._reference().items(): > + self.assertEqual(os.environ.get(key), value) > + > class WalkTests(unittest.TestCase): > """Tests for os.walk().""" > > _______________________________________________ > 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 Nov 1 21:32:33 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Thu, 1 Nov 2007 21:32:33 +0100 (CET) Subject: [Python-3000-checkins] r58752 - in python/branches/py3k/Doc: ACKS.txt README.txt c-api/abstract.rst c-api/index.rst c-api/newtypes.rst contents.rst distutils/apiref.rst distutils/builtdist.rst documenting/markup.rst extending/newtypes.rst glossary.rst howto/functional.rst howto/index.rst howto/pythonmac.rst howto/regex.rst includes/email-unpack.py library/_ast.rst library/asynchat.rst library/asyncore.rst library/autogil.rst library/codecs.rst library/collections.rst library/contextlib.rst library/cookielib.rst library/csv.rst library/ctypes.rst library/decimal.rst library/difflib.rst library/dis.rst library/exceptions.rst library/filecmp.rst library/functions.rst library/glob.rst library/heapq.rst library/inspect.rst library/itertools.rst library/logging.rst library/mailbox.rst library/marshal.rst library/mmap.rst library/optparse.rst library/os.path.rst library/os.rst library/parser.rst library/pdb.rst library/pickle.rst library/pickletools.rst library/pty.rst library/pyclbr.rst library/re.rst library/sqlite3.rst library/ssl.rst library/stdtypes.rst library/tokenize.rst library/types.rst library/urllib.rst library/weakref.rst library/wsgiref.rst library/xml.etree.elementtree.rst library/xmlrpclib.rst reference/compound_stmts.rst reference/datamodel.rst reference/expressions.rst tutorial/classes.rst tutorial/controlflow.rst tutorial/interactive.rst tutorial/modules.rst whatsnew/2.6.rst Message-ID: <20071101203233.496C61E400A@bag.python.org> Author: georg.brandl Date: Thu Nov 1 21:32:30 2007 New Revision: 58752 Modified: python/branches/py3k/Doc/ACKS.txt python/branches/py3k/Doc/README.txt python/branches/py3k/Doc/c-api/abstract.rst python/branches/py3k/Doc/c-api/index.rst python/branches/py3k/Doc/c-api/newtypes.rst python/branches/py3k/Doc/contents.rst python/branches/py3k/Doc/distutils/apiref.rst python/branches/py3k/Doc/distutils/builtdist.rst python/branches/py3k/Doc/documenting/markup.rst python/branches/py3k/Doc/extending/newtypes.rst python/branches/py3k/Doc/glossary.rst python/branches/py3k/Doc/howto/functional.rst python/branches/py3k/Doc/howto/index.rst python/branches/py3k/Doc/howto/pythonmac.rst python/branches/py3k/Doc/howto/regex.rst python/branches/py3k/Doc/includes/email-unpack.py python/branches/py3k/Doc/library/_ast.rst python/branches/py3k/Doc/library/asynchat.rst python/branches/py3k/Doc/library/asyncore.rst python/branches/py3k/Doc/library/autogil.rst python/branches/py3k/Doc/library/codecs.rst python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/contextlib.rst python/branches/py3k/Doc/library/cookielib.rst python/branches/py3k/Doc/library/csv.rst python/branches/py3k/Doc/library/ctypes.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/difflib.rst python/branches/py3k/Doc/library/dis.rst python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/library/filecmp.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/glob.rst python/branches/py3k/Doc/library/heapq.rst python/branches/py3k/Doc/library/inspect.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/mmap.rst python/branches/py3k/Doc/library/optparse.rst python/branches/py3k/Doc/library/os.path.rst python/branches/py3k/Doc/library/os.rst python/branches/py3k/Doc/library/parser.rst python/branches/py3k/Doc/library/pdb.rst python/branches/py3k/Doc/library/pickle.rst python/branches/py3k/Doc/library/pickletools.rst python/branches/py3k/Doc/library/pty.rst python/branches/py3k/Doc/library/pyclbr.rst python/branches/py3k/Doc/library/re.rst python/branches/py3k/Doc/library/sqlite3.rst python/branches/py3k/Doc/library/ssl.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Doc/library/tokenize.rst python/branches/py3k/Doc/library/types.rst python/branches/py3k/Doc/library/urllib.rst python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Doc/library/wsgiref.rst python/branches/py3k/Doc/library/xml.etree.elementtree.rst python/branches/py3k/Doc/library/xmlrpclib.rst python/branches/py3k/Doc/reference/compound_stmts.rst python/branches/py3k/Doc/reference/datamodel.rst python/branches/py3k/Doc/reference/expressions.rst python/branches/py3k/Doc/tutorial/classes.rst python/branches/py3k/Doc/tutorial/controlflow.rst python/branches/py3k/Doc/tutorial/interactive.rst python/branches/py3k/Doc/tutorial/modules.rst python/branches/py3k/Doc/whatsnew/2.6.rst Log: #1370: Finish the merge r58749, log below, by resolving all conflicts in Doc/. Merged revisions 58221-58741 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r58221 | georg.brandl | 2007-09-20 10:57:59 -0700 (Thu, 20 Sep 2007) | 2 lines Patch #1181: add os.environ.clear() method. ........ r58225 | sean.reifschneider | 2007-09-20 23:33:28 -0700 (Thu, 20 Sep 2007) | 3 lines Issue1704287: "make install" fails unless you do "make" first. Make oldsharedmods and sharedmods in "libinstall". ........ r58232 | guido.van.rossum | 2007-09-22 13:18:03 -0700 (Sat, 22 Sep 2007) | 4 lines Patch # 188 by Philip Jenvey. Make tell() mark CRLF as a newline. With unit test. ........ r58242 | georg.brandl | 2007-09-24 10:55:47 -0700 (Mon, 24 Sep 2007) | 2 lines Fix typo and double word. ........ r58245 | georg.brandl | 2007-09-24 10:59:28 -0700 (Mon, 24 Sep 2007) | 2 lines #1196: document default radix for int(). ........ r58247 | georg.brandl | 2007-09-24 11:08:24 -0700 (Mon, 24 Sep 2007) | 2 lines #1177: accept 2xx responses for https too, not only http. ........ r58249 | andrew.kuchling | 2007-09-24 16:45:51 -0700 (Mon, 24 Sep 2007) | 1 line Remove stray odd character; grammar fix ........ r58250 | andrew.kuchling | 2007-09-24 16:46:28 -0700 (Mon, 24 Sep 2007) | 1 line Typo fix ........ r58251 | andrew.kuchling | 2007-09-24 17:09:42 -0700 (Mon, 24 Sep 2007) | 1 line Add various items ........ r58268 | vinay.sajip | 2007-09-26 22:34:45 -0700 (Wed, 26 Sep 2007) | 1 line Change to flush and close logic to fix #1760556. ........ r58269 | vinay.sajip | 2007-09-26 22:38:51 -0700 (Wed, 26 Sep 2007) | 1 line Change to basicConfig() to fix #1021. ........ r58270 | georg.brandl | 2007-09-26 23:26:58 -0700 (Wed, 26 Sep 2007) | 2 lines #1208: document match object's boolean value. ........ r58271 | vinay.sajip | 2007-09-26 23:56:13 -0700 (Wed, 26 Sep 2007) | 1 line Minor date change. ........ r58272 | vinay.sajip | 2007-09-27 00:35:10 -0700 (Thu, 27 Sep 2007) | 1 line Change to LogRecord.__init__() to fix #1206. Note that archaic use of type(x) == types.DictType is because of keeping 1.5.2 compatibility. While this is much less relevant these days, there probably needs to be a separate commit for removing all archaic constructs at the same time. ........ r58288 | brett.cannon | 2007-09-30 12:45:10 -0700 (Sun, 30 Sep 2007) | 9 lines tuple.__repr__ did not consider a reference loop as it is not possible from Python code; but it is possible from C. object.__str__ had the issue of not expecting a type to doing something within it's tp_str implementation that could trigger an infinite recursion, but it could in C code.. Both found thanks to BaseException and how it handles its repr. Closes issue #1686386. Thanks to Thomas Herve for taking an initial stab at coming up with a solution. ........ r58289 | brett.cannon | 2007-09-30 13:37:19 -0700 (Sun, 30 Sep 2007) | 3 lines Fix error introduced by r58288; if a tuple is length 0 return its repr and don't worry about any self-referring tuples. ........ r58294 | facundo.batista | 2007-10-02 10:01:24 -0700 (Tue, 02 Oct 2007) | 11 lines Made the various is_* operations return booleans. This was discussed with Cawlishaw by mail, and he basically confirmed that to these is_* operations, there's no need to return Decimal(0) and Decimal(1) if the language supports the False and True booleans. Also added a few tests for the these functions in extra.decTest, since they are mostly untested (apart from the doctests). Thanks Mark Dickinson ........ r58295 | facundo.batista | 2007-10-02 11:21:18 -0700 (Tue, 02 Oct 2007) | 4 lines Added a class to store the digits of log(10), so that they can be made available when necessary without recomputing. Thanks Mark Dickinson ........ r58299 | mark.summerfield | 2007-10-03 01:53:21 -0700 (Wed, 03 Oct 2007) | 4 lines Added note in footnote about string comparisons about unicodedata.normalize(). ........ r58304 | raymond.hettinger | 2007-10-03 14:18:11 -0700 (Wed, 03 Oct 2007) | 1 line enumerate() is no longer bounded to using sequences shorter than LONG_MAX. The possibility of overflow was sending some newsgroup posters into a tizzy. ........ r58305 | raymond.hettinger | 2007-10-03 17:20:27 -0700 (Wed, 03 Oct 2007) | 1 line itertools.count() no longer limited to sys.maxint. ........ r58306 | kurt.kaiser | 2007-10-03 18:49:54 -0700 (Wed, 03 Oct 2007) | 3 lines Assume that the user knows when he wants to end the line; don't insert something he didn't select or complete. ........ r58307 | kurt.kaiser | 2007-10-03 19:07:50 -0700 (Wed, 03 Oct 2007) | 2 lines Remove unused theme that was causing a fault in p3k. ........ r58308 | kurt.kaiser | 2007-10-03 19:09:17 -0700 (Wed, 03 Oct 2007) | 2 lines Clean up EditorWindow close. ........ r58309 | kurt.kaiser | 2007-10-03 19:53:07 -0700 (Wed, 03 Oct 2007) | 7 lines textView cleanup. Patch 1718043 Tal Einat. M idlelib/EditorWindow.py M idlelib/aboutDialog.py M idlelib/textView.py M idlelib/NEWS.txt ........ r58310 | kurt.kaiser | 2007-10-03 20:11:12 -0700 (Wed, 03 Oct 2007) | 3 lines configDialog cleanup. Patch 1730217 Tal Einat. ........ r58311 | neal.norwitz | 2007-10-03 23:00:48 -0700 (Wed, 03 Oct 2007) | 4 lines Coverity #151: Remove deadcode. All this code already exists above starting at line 653. ........ r58325 | fred.drake | 2007-10-04 19:46:12 -0700 (Thu, 04 Oct 2007) | 1 line wrap lines to <80 characters before fixing errors ........ r58326 | raymond.hettinger | 2007-10-04 19:47:07 -0700 (Thu, 04 Oct 2007) | 6 lines Add __asdict__() to NamedTuple and refine the docs. Add maxlen support to deque() and fixup docs. Partially fix __reduce__(). The None as a third arg was no longer supported. Still needs work on __reduce__() to handle recursive inputs. ........ r58327 | fred.drake | 2007-10-04 19:48:32 -0700 (Thu, 04 Oct 2007) | 3 lines move descriptions of ac_(in|out)_buffer_size to the right place http://bugs.python.org/issue1053 ........ r58329 | neal.norwitz | 2007-10-04 20:39:17 -0700 (Thu, 04 Oct 2007) | 3 lines dict could be NULL, so we need to XDECREF. Fix a compiler warning about passing a PyTypeObject* instead of PyObject*. ........ r58330 | neal.norwitz | 2007-10-04 20:41:19 -0700 (Thu, 04 Oct 2007) | 2 lines Fix Coverity #158: Check the correct variable. ........ r58332 | neal.norwitz | 2007-10-04 22:01:38 -0700 (Thu, 04 Oct 2007) | 7 lines Fix Coverity #159. This code was broken if save() returned a negative number since i contained a boolean value and then we compared i < 0 which should never be true. Will backport (assuming it's necessary) ........ r58334 | neal.norwitz | 2007-10-04 22:29:17 -0700 (Thu, 04 Oct 2007) | 1 line Add a note about fixing some more warnings found by Coverity. ........ r58338 | raymond.hettinger | 2007-10-05 12:07:31 -0700 (Fri, 05 Oct 2007) | 1 line Restore BEGIN/END THREADS macros which were squashed in the previous checkin ........ r58343 | gregory.p.smith | 2007-10-06 00:48:10 -0700 (Sat, 06 Oct 2007) | 3 lines Stab in the dark attempt to fix the test_bsddb3 failure on sparc and S-390 ubuntu buildbots. ........ r58344 | gregory.p.smith | 2007-10-06 00:51:59 -0700 (Sat, 06 Oct 2007) | 2 lines Allows BerkeleyDB 4.6.x >= 4.6.21 for the bsddb module. ........ r58348 | gregory.p.smith | 2007-10-06 08:47:37 -0700 (Sat, 06 Oct 2007) | 3 lines Use the host the author likely meant in the first place. pop.gmail.com is reliable. gmail.org is someones personal domain. ........ r58351 | neal.norwitz | 2007-10-06 12:16:28 -0700 (Sat, 06 Oct 2007) | 3 lines Ensure that this test will pass even if another test left an unwritable TESTFN. Also use the safe unlink in test_support instead of rolling our own here. ........ r58368 | georg.brandl | 2007-10-08 00:50:24 -0700 (Mon, 08 Oct 2007) | 3 lines #1123: fix the docs for the str.split(None, sep) case. Also expand a few other methods' docs, which had more info in the deprecated string module docs. ........ r58369 | georg.brandl | 2007-10-08 01:06:05 -0700 (Mon, 08 Oct 2007) | 2 lines Update docstring of sched, also remove an unused assignment. ........ r58370 | raymond.hettinger | 2007-10-08 02:14:28 -0700 (Mon, 08 Oct 2007) | 5 lines Add comments to NamedTuple code. Let the field spec be either a string or a non-string sequence (suggested by Martin Blais with use cases). Improve the error message in the case of a SyntaxError (caused by a duplicate field name). ........ r58371 | raymond.hettinger | 2007-10-08 02:56:29 -0700 (Mon, 08 Oct 2007) | 1 line Missed a line in the docs ........ r58372 | raymond.hettinger | 2007-10-08 03:11:51 -0700 (Mon, 08 Oct 2007) | 1 line Better variable names ........ r58376 | georg.brandl | 2007-10-08 07:12:47 -0700 (Mon, 08 Oct 2007) | 3 lines #1199: docs for tp_as_{number,sequence,mapping}, by Amaury Forgeot d'Arc. No need to merge this to py3k! ........ r58380 | raymond.hettinger | 2007-10-08 14:26:58 -0700 (Mon, 08 Oct 2007) | 1 line Eliminate camelcase function name ........ r58381 | andrew.kuchling | 2007-10-08 16:23:03 -0700 (Mon, 08 Oct 2007) | 1 line Eliminate camelcase function name ........ r58382 | raymond.hettinger | 2007-10-08 18:36:23 -0700 (Mon, 08 Oct 2007) | 1 line Make the error messages more specific ........ r58384 | gregory.p.smith | 2007-10-08 23:02:21 -0700 (Mon, 08 Oct 2007) | 10 lines Splits Modules/_bsddb.c up into bsddb.h and _bsddb.c and adds a C API object available as bsddb.db.api. This is based on the patch submitted by Duncan Grisby here: http://sourceforge.net/tracker/index.php?func=detail&aid=1551895&group_id=13900&atid=313900 See this thread for additional info: http://sourceforge.net/mailarchive/forum.php?thread_name=E1GAVDK-0002rk-Iw%40apasphere.com&forum_name=pybsddb-users It also cleans up the code a little by removing some ifdef/endifs for python prior to 2.1 and for unsupported Berkeley DB <= 3.2. ........ r58385 | gregory.p.smith | 2007-10-08 23:50:43 -0700 (Mon, 08 Oct 2007) | 5 lines Fix a double free when positioning a database cursor to a non-existant string key (and probably a few other situations with string keys). This was reported with a patch as pybsddb sourceforge bug 1708868 by jjjhhhlll at gmail. ........ r58386 | gregory.p.smith | 2007-10-09 00:19:11 -0700 (Tue, 09 Oct 2007) | 3 lines Use the highest cPickle protocol in bsddb.dbshelve. This comes from sourceforge pybsddb patch 1551443 by w_barnes. ........ r58394 | gregory.p.smith | 2007-10-09 11:26:02 -0700 (Tue, 09 Oct 2007) | 2 lines remove another sleepycat reference ........ r58396 | kurt.kaiser | 2007-10-09 12:31:30 -0700 (Tue, 09 Oct 2007) | 3 lines Allow interrupt only when executing user code in subprocess Patch 1225 Tal Einat modified from IDLE-Spoon. ........ r58399 | brett.cannon | 2007-10-09 17:07:50 -0700 (Tue, 09 Oct 2007) | 5 lines Remove file-level typedefs that were inconsistently used throughout the file. Just move over to the public API names. Closes issue1238. ........ r58401 | raymond.hettinger | 2007-10-09 17:26:46 -0700 (Tue, 09 Oct 2007) | 1 line Accept Jim Jewett's api suggestion to use None instead of -1 to indicate unbounded deques. ........ r58403 | kurt.kaiser | 2007-10-09 17:55:40 -0700 (Tue, 09 Oct 2007) | 2 lines Allow cursor color change w/o restart. Patch 1725576 Tal Einat. ........ r58404 | kurt.kaiser | 2007-10-09 18:06:47 -0700 (Tue, 09 Oct 2007) | 2 lines show paste if > 80 columns. Patch 1659326 Tal Einat. ........ r58415 | thomas.heller | 2007-10-11 12:51:32 -0700 (Thu, 11 Oct 2007) | 5 lines On OS X, use os.uname() instead of gestalt.sysv(...) to get the operating system version. This allows to use ctypes when Python was configured with --disable-toolbox-glue. ........ r58419 | neal.norwitz | 2007-10-11 20:01:01 -0700 (Thu, 11 Oct 2007) | 1 line Get rid of warning about not being able to create an existing directory. ........ r58420 | neal.norwitz | 2007-10-11 20:01:30 -0700 (Thu, 11 Oct 2007) | 1 line Get rid of warnings on a bunch of platforms by using a proper prototype. ........ r58421 | neal.norwitz | 2007-10-11 20:01:54 -0700 (Thu, 11 Oct 2007) | 4 lines Get rid of compiler warning about retval being used (returned) without being initialized. (gcc warning and Coverity 202) ........ r58422 | neal.norwitz | 2007-10-11 20:03:23 -0700 (Thu, 11 Oct 2007) | 1 line Fix Coverity 168: Close the file before returning (exiting). ........ r58423 | neal.norwitz | 2007-10-11 20:04:18 -0700 (Thu, 11 Oct 2007) | 4 lines Fix Coverity 180: Don't overallocate. We don't need structs, but pointers. Also fix a memory leak. ........ r58424 | neal.norwitz | 2007-10-11 20:05:19 -0700 (Thu, 11 Oct 2007) | 5 lines Fix Coverity 185-186: If the passed in FILE is NULL, uninitialized memory would be accessed. Will backport. ........ r58425 | neal.norwitz | 2007-10-11 20:52:34 -0700 (Thu, 11 Oct 2007) | 1 line Get this module to compile with bsddb versions prior to 4.3 ........ r58430 | martin.v.loewis | 2007-10-12 01:56:52 -0700 (Fri, 12 Oct 2007) | 3 lines Bug #1216: Restore support for Visual Studio 2002. Will backport to 2.5. ........ r58433 | raymond.hettinger | 2007-10-12 10:53:11 -0700 (Fri, 12 Oct 2007) | 1 line Fix test of count.__repr__() to ignore the 'L' if the count is a long ........ r58434 | gregory.p.smith | 2007-10-12 11:44:06 -0700 (Fri, 12 Oct 2007) | 4 lines Fixes http://bugs.python.org/issue1233 - bsddb.dbshelve.DBShelf.append was useless due to inverted logic. Also adds a test case for RECNO dbs to test_dbshelve. ........ r58445 | georg.brandl | 2007-10-13 06:20:03 -0700 (Sat, 13 Oct 2007) | 2 lines Fix email example. ........ r58450 | gregory.p.smith | 2007-10-13 16:02:05 -0700 (Sat, 13 Oct 2007) | 2 lines Fix an uncollectable reference leak in bsddb.db.DBShelf.append ........ r58453 | neal.norwitz | 2007-10-13 17:18:40 -0700 (Sat, 13 Oct 2007) | 8 lines Let the O/S supply a port if none of the default ports can be used. This should make the tests more robust at the expense of allowing tests to be sloppier by not requiring them to cleanup after themselves. (It will legitamitely help when running two test suites simultaneously or if another process is already using one of the predefined ports.) Also simplifies (slightLy) the exception handling elsewhere. ........ r58459 | neal.norwitz | 2007-10-14 11:30:21 -0700 (Sun, 14 Oct 2007) | 2 lines Don't raise a string exception, they don't work anymore. ........ r58460 | neal.norwitz | 2007-10-14 11:40:37 -0700 (Sun, 14 Oct 2007) | 1 line Use unittest for assertions ........ r58468 | armin.rigo | 2007-10-15 00:48:35 -0700 (Mon, 15 Oct 2007) | 2 lines test_bigbits was not testing what it seemed to. ........ r58471 | guido.van.rossum | 2007-10-15 08:54:11 -0700 (Mon, 15 Oct 2007) | 3 lines Change a PyErr_Print() into a PyErr_Clear(), per discussion in issue 1031213. ........ r58500 | raymond.hettinger | 2007-10-16 12:18:30 -0700 (Tue, 16 Oct 2007) | 1 line Improve error messages ........ r58506 | raymond.hettinger | 2007-10-16 14:28:32 -0700 (Tue, 16 Oct 2007) | 1 line More docs, error messages, and tests ........ r58507 | andrew.kuchling | 2007-10-16 15:58:03 -0700 (Tue, 16 Oct 2007) | 1 line Add items ........ r58508 | brett.cannon | 2007-10-16 16:24:06 -0700 (Tue, 16 Oct 2007) | 3 lines Remove ``:const:`` notation on None in parameter list. Since the markup is not rendered for parameters it just showed up as ``:const:`None` `` in the output. ........ r58509 | brett.cannon | 2007-10-16 16:26:45 -0700 (Tue, 16 Oct 2007) | 3 lines Re-order some functions whose parameters differ between PyObject and const char * so that they are next to each other. ........ r58522 | armin.rigo | 2007-10-17 11:46:37 -0700 (Wed, 17 Oct 2007) | 5 lines Fix the overflow checking of list_repeat. Introduce overflow checking into list_inplace_repeat. Backport candidate, possibly. ........ r58530 | facundo.batista | 2007-10-17 20:16:03 -0700 (Wed, 17 Oct 2007) | 7 lines Issue #1580738. When HTTPConnection reads the whole stream with read(), it closes itself. When the stream is read in several calls to read(n), it should behave in the same way if HTTPConnection knows where the end of the stream is (through self.length). Added a test case for this behaviour. ........ r58531 | facundo.batista | 2007-10-17 20:44:48 -0700 (Wed, 17 Oct 2007) | 3 lines Issue 1289, just a typo. ........ r58532 | gregory.p.smith | 2007-10-18 00:56:54 -0700 (Thu, 18 Oct 2007) | 4 lines cleanup test_dbtables to use mkdtemp. cleanup dbtables to pass txn as a keyword argument whenever possible to avoid bugs and confusion. (dbtables.py line 447 self.db.get using txn as a non-keyword was an actual bug due to this) ........ r58533 | gregory.p.smith | 2007-10-18 01:34:20 -0700 (Thu, 18 Oct 2007) | 4 lines Fix a weird bug in dbtables: if it chose a random rowid string that contained NULL bytes it would cause the database all sorts of problems in the future leading to very strange random failures and corrupt dbtables.bsdTableDb dbs. ........ r58534 | gregory.p.smith | 2007-10-18 09:32:02 -0700 (Thu, 18 Oct 2007) | 3 lines A cleaner fix than the one committed last night. Generate random rowids that do not contain null bytes. ........ r58537 | gregory.p.smith | 2007-10-18 10:17:57 -0700 (Thu, 18 Oct 2007) | 2 lines mention bsddb fixes. ........ r58538 | raymond.hettinger | 2007-10-18 14:13:06 -0700 (Thu, 18 Oct 2007) | 1 line Remove useless warning ........ r58539 | gregory.p.smith | 2007-10-19 00:31:20 -0700 (Fri, 19 Oct 2007) | 2 lines squelch the warning that this test is supposed to trigger. ........ r58542 | georg.brandl | 2007-10-19 05:32:39 -0700 (Fri, 19 Oct 2007) | 2 lines Clarify wording for apply(). ........ r58544 | mark.summerfield | 2007-10-19 05:48:17 -0700 (Fri, 19 Oct 2007) | 3 lines Added a cross-ref to each other. ........ r58545 | georg.brandl | 2007-10-19 10:38:49 -0700 (Fri, 19 Oct 2007) | 2 lines #1284: "S" means "seen", not unread. ........ r58548 | thomas.heller | 2007-10-19 11:11:41 -0700 (Fri, 19 Oct 2007) | 4 lines Fix ctypes on 32-bit systems when Python is configured --with-system-ffi. See also https://bugs.launchpad.net/bugs/72505. Ported from release25-maint branch. ........ r58550 | facundo.batista | 2007-10-19 12:25:57 -0700 (Fri, 19 Oct 2007) | 8 lines The constructor from tuple was way too permissive: it allowed bad coefficient numbers, floats in the sign, and other details that generated directly the wrong number in the best case, or triggered misfunctionality in the alorithms. Test cases added for these issues. Thanks Mark Dickinson. ........ r58559 | georg.brandl | 2007-10-20 06:22:53 -0700 (Sat, 20 Oct 2007) | 2 lines Fix code being interpreted as a target. ........ r58561 | georg.brandl | 2007-10-20 06:36:24 -0700 (Sat, 20 Oct 2007) | 2 lines Document new "cmdoption" directive. ........ r58562 | georg.brandl | 2007-10-20 08:21:22 -0700 (Sat, 20 Oct 2007) | 2 lines Make a path more Unix-standardy. ........ r58564 | georg.brandl | 2007-10-20 10:51:39 -0700 (Sat, 20 Oct 2007) | 2 lines Document new directive "envvar". ........ r58567 | georg.brandl | 2007-10-20 11:08:14 -0700 (Sat, 20 Oct 2007) | 6 lines * Add new toplevel chapter, "Using Python." (how to install, configure and setup python on different platforms -- at least in theory.) * Move the Python on Mac docs in that chapter. * Add a new chapter about the command line invocation, by stargaming. ........ r58568 | georg.brandl | 2007-10-20 11:33:20 -0700 (Sat, 20 Oct 2007) | 2 lines Change title, for now. ........ r58569 | georg.brandl | 2007-10-20 11:39:25 -0700 (Sat, 20 Oct 2007) | 2 lines Add entry to ACKS. ........ r58570 | georg.brandl | 2007-10-20 12:05:45 -0700 (Sat, 20 Oct 2007) | 2 lines Clarify -E docs. ........ r58571 | georg.brandl | 2007-10-20 12:08:36 -0700 (Sat, 20 Oct 2007) | 2 lines Even more clarification. ........ r58572 | andrew.kuchling | 2007-10-20 12:25:37 -0700 (Sat, 20 Oct 2007) | 1 line Fix protocol name ........ r58573 | andrew.kuchling | 2007-10-20 12:35:18 -0700 (Sat, 20 Oct 2007) | 1 line Various items ........ r58574 | andrew.kuchling | 2007-10-20 12:39:35 -0700 (Sat, 20 Oct 2007) | 1 line Use correct header line ........ r58576 | armin.rigo | 2007-10-21 02:14:15 -0700 (Sun, 21 Oct 2007) | 3 lines Add a crasher for the long-standing issue with closing a file while another thread uses it. ........ r58577 | georg.brandl | 2007-10-21 03:01:56 -0700 (Sun, 21 Oct 2007) | 2 lines Remove duplicate crasher. ........ r58578 | georg.brandl | 2007-10-21 03:24:20 -0700 (Sun, 21 Oct 2007) | 2 lines Unify "byte code" to "bytecode". Also sprinkle :term: markup for it. ........ r58579 | georg.brandl | 2007-10-21 03:32:54 -0700 (Sun, 21 Oct 2007) | 2 lines Add markup to new function descriptions. ........ r58580 | georg.brandl | 2007-10-21 03:45:46 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term:s for descriptors. ........ r58581 | georg.brandl | 2007-10-21 03:46:24 -0700 (Sun, 21 Oct 2007) | 2 lines Unify "file-descriptor" to "file descriptor". ........ r58582 | georg.brandl | 2007-10-21 03:52:38 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term: for generators. ........ r58583 | georg.brandl | 2007-10-21 05:10:28 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term:s for iterator. ........ r58584 | georg.brandl | 2007-10-21 05:15:05 -0700 (Sun, 21 Oct 2007) | 2 lines Add :term:s for "new-style class". ........ r58588 | neal.norwitz | 2007-10-21 21:47:54 -0700 (Sun, 21 Oct 2007) | 1 line Add Chris Monson so he can edit PEPs. ........ r58594 | guido.van.rossum | 2007-10-22 09:27:19 -0700 (Mon, 22 Oct 2007) | 4 lines Issue #1307, patch by Derek Shockey. When "MAIL" is received without args, an exception happens instead of sending a 501 syntax error response. ........ r58598 | travis.oliphant | 2007-10-22 19:40:56 -0700 (Mon, 22 Oct 2007) | 1 line Add phuang patch from Issue 708374 which adds offset parameter to mmap module. ........ r58601 | neal.norwitz | 2007-10-22 22:44:27 -0700 (Mon, 22 Oct 2007) | 2 lines Bug #1313, fix typo (wrong variable name) in example. ........ r58609 | georg.brandl | 2007-10-23 11:21:35 -0700 (Tue, 23 Oct 2007) | 2 lines Update Pygments version from externals. ........ r58618 | guido.van.rossum | 2007-10-23 12:25:41 -0700 (Tue, 23 Oct 2007) | 3 lines Issue 1307 by Derek Shockey, fox the same bug for RCPT. Neal: please backport! ........ r58620 | raymond.hettinger | 2007-10-23 13:37:41 -0700 (Tue, 23 Oct 2007) | 1 line Shorter name for namedtuple() ........ r58621 | andrew.kuchling | 2007-10-23 13:55:47 -0700 (Tue, 23 Oct 2007) | 1 line Update name ........ r58622 | raymond.hettinger | 2007-10-23 14:23:07 -0700 (Tue, 23 Oct 2007) | 1 line Fixup news entry ........ r58623 | raymond.hettinger | 2007-10-23 18:28:33 -0700 (Tue, 23 Oct 2007) | 1 line Optimize sum() for integer and float inputs. ........ r58624 | raymond.hettinger | 2007-10-23 19:05:51 -0700 (Tue, 23 Oct 2007) | 1 line Fixup error return and add support for intermixed ints and floats/ ........ r58628 | vinay.sajip | 2007-10-24 03:47:06 -0700 (Wed, 24 Oct 2007) | 1 line Bug #1321: Fixed logic error in TimedRotatingFileHandler.__init__() ........ r58641 | facundo.batista | 2007-10-24 12:11:08 -0700 (Wed, 24 Oct 2007) | 4 lines Issue 1290. CharacterData.__repr__ was constructing a string in response that keeped having a non-ascii character. ........ r58643 | thomas.heller | 2007-10-24 12:50:45 -0700 (Wed, 24 Oct 2007) | 1 line Added unittest for calling a function with paramflags (backport from py3k branch). ........ r58645 | matthias.klose | 2007-10-24 13:00:44 -0700 (Wed, 24 Oct 2007) | 2 lines - Build using system ffi library on arm*-linux*. ........ r58651 | georg.brandl | 2007-10-24 14:40:38 -0700 (Wed, 24 Oct 2007) | 2 lines Bug #1287: make os.environ.pop() work as expected. ........ r58652 | raymond.hettinger | 2007-10-24 19:26:58 -0700 (Wed, 24 Oct 2007) | 1 line Missing DECREFs ........ r58653 | matthias.klose | 2007-10-24 23:37:24 -0700 (Wed, 24 Oct 2007) | 2 lines - Build using system ffi library on arm*-linux*, pass --with-system-ffi to CONFIG_ARGS ........ r58655 | thomas.heller | 2007-10-25 12:47:32 -0700 (Thu, 25 Oct 2007) | 2 lines ffi_type_longdouble may be already #defined. See issue 1324. ........ r58656 | kurt.kaiser | 2007-10-25 15:43:45 -0700 (Thu, 25 Oct 2007) | 3 lines Correct an ancient bug in an unused path by removing that path: register() is now idempotent. ........ r58660 | kurt.kaiser | 2007-10-25 17:10:09 -0700 (Thu, 25 Oct 2007) | 4 lines 1. Add comments to provide top-level documentation. 2. Refactor to use more descriptive names. 3. Enhance tests in main(). ........ r58675 | georg.brandl | 2007-10-26 11:30:41 -0700 (Fri, 26 Oct 2007) | 2 lines Fix new pop() method on os.environ on ignorecase-platforms. ........ r58696 | neal.norwitz | 2007-10-27 15:32:21 -0700 (Sat, 27 Oct 2007) | 1 line Update URL for Pygments. 0.8.1 is no longer available ........ r58697 | hyeshik.chang | 2007-10-28 04:19:02 -0700 (Sun, 28 Oct 2007) | 3 lines - Add support for FreeBSD 8 which is recently forked from FreeBSD 7. - Regenerate IN module for most recent maintenance tree of FreeBSD 6 and 7. ........ r58698 | hyeshik.chang | 2007-10-28 05:38:09 -0700 (Sun, 28 Oct 2007) | 2 lines Enable platform-specific tweaks for FreeBSD 8 (exactly same to FreeBSD 7's yet) ........ r58700 | kurt.kaiser | 2007-10-28 12:03:59 -0700 (Sun, 28 Oct 2007) | 2 lines Add confirmation dialog before printing. Patch 1717170 Tal Einat. ........ r58706 | guido.van.rossum | 2007-10-29 13:52:45 -0700 (Mon, 29 Oct 2007) | 3 lines Patch 1353 by Jacob Winther. Add mp4 mapping to mimetypes.py. ........ r58709 | guido.van.rossum | 2007-10-29 15:15:05 -0700 (Mon, 29 Oct 2007) | 6 lines Backport fixes for the code that decodes octal escapes (and for PyString also hex escapes) -- this was reaching beyond the end of the input string buffer, even though it is not supposed to be \0-terminated. This has no visible effect but is clearly the correct thing to do. (In 3.0 it had a visible effect after removing ob_sstate from PyString.) ........ r58710 | kurt.kaiser | 2007-10-29 19:38:54 -0700 (Mon, 29 Oct 2007) | 7 lines check in Tal Einat's update to tabpage.py Patch 1612746 M configDialog.py M NEWS.txt AM tabbedpages.py ........ r58715 | georg.brandl | 2007-10-30 10:51:18 -0700 (Tue, 30 Oct 2007) | 2 lines Use correct markup. ........ r58716 | georg.brandl | 2007-10-30 10:57:12 -0700 (Tue, 30 Oct 2007) | 2 lines Make example about hiding None return values at the prompt clearer. ........ r58728 | neal.norwitz | 2007-10-30 23:33:20 -0700 (Tue, 30 Oct 2007) | 1 line Fix some compiler warnings for signed comparisons on Unix and Windows. ........ r58731 | martin.v.loewis | 2007-10-31 10:19:33 -0700 (Wed, 31 Oct 2007) | 2 lines Adding Christian Heimes. ........ r58737 | raymond.hettinger | 2007-10-31 14:57:58 -0700 (Wed, 31 Oct 2007) | 1 line Clarify the reasons why pickle is almost always better than marshal ........ r58739 | raymond.hettinger | 2007-10-31 15:15:49 -0700 (Wed, 31 Oct 2007) | 1 line Sets are marshalable. ........ Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Thu Nov 1 21:32:30 2007 @@ -104,6 +104,7 @@ * Detlef Lannert * Piers Lauder * Glyph Lefkowitz +* Robert Lehmann * Marc-Andr? Lemburg * Ulf A. Lindgren * Everett Lipman Modified: python/branches/py3k/Doc/README.txt ============================================================================== --- python/branches/py3k/Doc/README.txt (original) +++ python/branches/py3k/Doc/README.txt Thu Nov 1 21:32:30 2007 @@ -72,7 +72,7 @@ You can optionally also install Pygments, either as a checkout via :: - svn co http://svn.python.org/projects/external/Pygments-0.8.1/pygments tools/pygments + svn co http://svn.python.org/projects/external/Pygments-0.9/pygments tools/pygments or from PyPI at http://pypi.python.org/pypi/Pygments. Modified: python/branches/py3k/Doc/c-api/abstract.rst ============================================================================== --- python/branches/py3k/Doc/c-api/abstract.rst (original) +++ python/branches/py3k/Doc/c-api/abstract.rst Thu Nov 1 21:32:30 2007 @@ -31,21 +31,14 @@ instead of the :func:`repr`. -.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name) +.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name) Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. This is equivalent to the Python expression ``hasattr(o, attr_name)``. This function always succeeds. -.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name) - - Retrieve an attribute named *attr_name* from object *o*. Returns the attribute - value on success, or *NULL* on failure. This is the equivalent of the Python - expression ``o.attr_name``. - - -.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name) +.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name) Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. This is equivalent to the Python expression ``hasattr(o, attr_name)``. This function @@ -59,27 +52,34 @@ expression ``o.attr_name``. -.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v) +.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name) + + Retrieve an attribute named *attr_name* from object *o*. Returns the attribute + value on success, or *NULL* on failure. This is the equivalent of the Python + expression ``o.attr_name``. + + +.. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o.attr_name = v``. -.. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v) +.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o.attr_name = v``. -.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name) +.. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name) Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure. - This is the equivalent of the Python statement: ``del o.attr_name``. + This is the equivalent of the Python statement ``del o.attr_name``. -.. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name) +.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name) Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``del o.attr_name``. @@ -327,7 +327,10 @@ .. cfunction:: int PyObject_AsFileDescriptor(PyObject *o) - Derives a file-descriptor from a Python object. + Derives a file descriptor from a Python object. If the object is an integer or + long integer, its value is returned. If not, the object's :meth:`fileno` method + is called if it exists; the method must return an integer or long integer, which + is returned as the file descriptor value. Returns ``-1`` on failure. .. cfunction:: PyObject* PyObject_Dir(PyObject *o) Modified: python/branches/py3k/Doc/c-api/index.rst ============================================================================== --- python/branches/py3k/Doc/c-api/index.rst (original) +++ python/branches/py3k/Doc/c-api/index.rst Thu Nov 1 21:32:30 2007 @@ -12,12 +12,6 @@ which describes the general principles of extension writing but does not document the API functions in detail. -.. warning:: - - The current version of this document is somewhat incomplete. However, most of - the important functions, types and structures are described. - - .. toctree:: :maxdepth: 2 Modified: python/branches/py3k/Doc/c-api/newtypes.rst ============================================================================== --- python/branches/py3k/Doc/c-api/newtypes.rst (original) +++ python/branches/py3k/Doc/c-api/newtypes.rst Thu Nov 1 21:32:30 2007 @@ -618,8 +618,8 @@ objects which implement the mapping protocol. These fields are documented in :ref:`mapping-structs`. - The :attr:`tp_as_mapping` field is not inherited, but the contained fields are - inherited individually. + The :attr:`tp_as_mapping` field is not inherited, but the contained fields + are inherited individually. .. cmember:: hashfunc PyTypeObject.tp_hash Modified: python/branches/py3k/Doc/contents.rst ============================================================================== --- python/branches/py3k/Doc/contents.rst (original) +++ python/branches/py3k/Doc/contents.rst Thu Nov 1 21:32:30 2007 @@ -6,6 +6,7 @@ whatsnew/3.0.rst tutorial/index.rst + using/index.rst reference/index.rst library/index.rst extending/index.rst Modified: python/branches/py3k/Doc/distutils/apiref.rst ============================================================================== --- python/branches/py3k/Doc/distutils/apiref.rst (original) +++ python/branches/py3k/Doc/distutils/apiref.rst Thu Nov 1 21:32:30 2007 @@ -1199,7 +1199,7 @@ If *force* is true, all files are recompiled regardless of timestamps. - The source filename encoded in each bytecode file defaults to the filenames + The source filename encoded in each :term:`bytecode` file defaults to the filenames listed in *py_files*; you can modify these with *prefix* and *basedir*. *prefix* is a string that will be stripped off of each source filename, and *base_dir* is a directory name that will be prepended (after *prefix* is Modified: python/branches/py3k/Doc/distutils/builtdist.rst ============================================================================== --- python/branches/py3k/Doc/distutils/builtdist.rst (original) +++ python/branches/py3k/Doc/distutils/builtdist.rst Thu Nov 1 21:32:30 2007 @@ -311,7 +311,7 @@ have to create a separate installer for every Python version you want to support. -The installer will try to compile pure modules into bytecode after installation +The installer will try to compile pure modules into :term:`bytecode` after installation on the target system in normal and optimizing mode. If you don't want this to happen for some reason, you can run the :command:`bdist_wininst` command with the :option:`--no-target-compile` and/or the :option:`--no-target-optimize` Modified: python/branches/py3k/Doc/documenting/markup.rst ============================================================================== --- python/branches/py3k/Doc/documenting/markup.rst (original) +++ python/branches/py3k/Doc/documenting/markup.rst Thu Nov 1 21:32:30 2007 @@ -210,7 +210,20 @@ .. describe:: opcode - Describes a Python bytecode instruction. + Describes a Python :term:`bytecode` instruction. + +.. describe:: cmdoption + + Describes a command line option or switch. Option argument names should be + enclosed in angle brackets. Example:: + + .. cmdoption:: -m + + Run a module as a script. + +.. describe:: envvar + + Describes an environment variable that Python uses or defines. There is also a generic version of these directives: Modified: python/branches/py3k/Doc/extending/newtypes.rst ============================================================================== --- python/branches/py3k/Doc/extending/newtypes.rst (original) +++ python/branches/py3k/Doc/extending/newtypes.rst Thu Nov 1 21:32:30 2007 @@ -1110,7 +1110,7 @@ attributes, when the values are computed, or how relevant data is stored. When :cfunc:`PyType_Ready` is called, it uses three tables referenced by the -type object to create *descriptors* which are placed in the dictionary of the +type object to create :term:`descriptor`\s which are placed in the dictionary of the type object. Each descriptor controls access to one attribute of the instance object. Each of the tables is optional; if all three are *NULL*, instances of the type will only have attributes that are inherited from their base type, and @@ -1154,7 +1154,7 @@ char *doc; } PyMemberDef; -For each entry in the table, a descriptor will be constructed and added to the +For each entry in the table, a :term:`descriptor` will be constructed and added to the type which will be able to extract a value from the instance structure. The :attr:`type` field should contain one of the type codes defined in the :file:`structmember.h` header; the value will be used to determine how to Modified: python/branches/py3k/Doc/glossary.rst ============================================================================== --- python/branches/py3k/Doc/glossary.rst (original) +++ python/branches/py3k/Doc/glossary.rst Thu Nov 1 21:32:30 2007 @@ -20,13 +20,13 @@ Benevolent Dictator For Life, a.k.a. `Guido van Rossum `_, Python's creator. - byte code - The internal representation of a Python program in the interpreter. The - byte code is also cached in ``.pyc`` and ``.pyo`` files so that executing - the same file is faster the second time (recompilation from source to byte - code can be avoided). This "intermediate language" is said to run on a - "virtual machine" that calls the subroutines corresponding to each - bytecode. + bytecode + Python source code is compiled into bytecode, the internal representation + of a Python program in the interpreter. The bytecode is also cached in + ``.pyc`` and ``.pyo`` files so that executing the same file is faster the + second time (recompilation from source to bytecode can be avoided). This + "intermediate language" is said to run on a "virtual machine" that calls + the subroutines corresponding to each bytecode. classic class One of the two flavors of classes in earlier Python versions. Since @@ -47,12 +47,15 @@ descriptor An object that defines the methods :meth:`__get__`, :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a descriptor, its special - binding behavior is triggered upon attribute lookup. Normally, writing - *a.b* looks up the object *b* in the class dictionary for *a*, but if *b* - is a descriptor, the defined method gets called. Understanding - descriptors is a key to a deep understanding of Python because they are - the basis for many features including functions, methods, properties, - class methods, static methods, and reference to super classes. + binding behavior is triggered upon attribute lookup. Normally, using + *a.b* to get, set or delete an attribute looks up the object named *b* in + the class dictionary for *a*, but if *b* is a descriptor, the respective + descriptor method gets called. Understanding descriptors is a key to a + deep understanding of Python because they are the basis for many features + including functions, methods, properties, class methods, static methods, + and reference to super classes. + + For more information about descriptors' methods, see :ref:`descriptors`. dictionary An associative array, where arbitrary keys are mapped to values. The use @@ -209,6 +212,8 @@ with an iterator will just return the same exhausted iterator object used in the previous iteration pass, making it appear like an empty container. + More information can be found in :ref:`typeiter`. + LBYL Look before you leap. This coding style explicitly tests for pre-conditions before making calls or lookups. This style contrasts with @@ -237,6 +242,8 @@ powerful, elegant solutions. They have been used for logging attribute access, adding thread-safety, tracking object creation, implementing singletons, and many other tasks. + + More information can be found in :ref:`metaclasses`. mutable Mutable objects can change their value but keep their :func:`id`. See @@ -267,6 +274,8 @@ earlier Python versions, only new-style classes could use Python's newer, versatile features like :attr:`__slots__`, descriptors, properties, :meth:`__getattribute__`, class methods, and static methods. + + More information can be found in :ref:`newstyle`. Python 3000 Nickname for the next major Python version, 3.0 (coined long ago when the Modified: python/branches/py3k/Doc/howto/functional.rst ============================================================================== --- python/branches/py3k/Doc/howto/functional.rst (original) +++ python/branches/py3k/Doc/howto/functional.rst Thu Nov 1 21:32:30 2007 @@ -13,8 +13,8 @@ In this document, we'll take a tour of Python's features suitable for implementing programs in a functional style. After an introduction to the concepts of functional programming, we'll look at language features such as -iterators and generators and relevant library modules such as :mod:`itertools` -and :mod:`functools`. +:term:`iterator`\s and :term:`generator`\s and relevant library modules such as +:mod:`itertools` and :mod:`functools`. Introduction @@ -448,8 +448,8 @@ yield i Any function containing a ``yield`` keyword is a generator function; this is -detected by Python's bytecode compiler which compiles the function specially as -a result. +detected by Python's :term:`bytecode` compiler which compiles the function +specially as a result. When you call a generator function, it doesn't return a single value; instead it returns a generator object that supports the iterator protocol. On executing Modified: python/branches/py3k/Doc/howto/index.rst ============================================================================== --- python/branches/py3k/Doc/howto/index.rst (original) +++ python/branches/py3k/Doc/howto/index.rst Thu Nov 1 21:32:30 2007 @@ -14,7 +14,6 @@ :maxdepth: 1 advocacy.rst - pythonmac.rst curses.rst doanddont.rst functional.rst Modified: python/branches/py3k/Doc/howto/pythonmac.rst ============================================================================== --- python/branches/py3k/Doc/howto/pythonmac.rst (original) +++ python/branches/py3k/Doc/howto/pythonmac.rst Thu Nov 1 21:32:30 2007 @@ -1,202 +0,0 @@ - -.. _using-on-mac: - -*************************** -Using Python on a Macintosh -*************************** - -:Author: Bob Savage - - -Python on a Macintosh running Mac OS X is in principle very similar to Python on -any other Unix platform, but there are a number of additional features such as -the IDE and the Package Manager that are worth pointing out. - -The Mac-specific modules are documented in :ref:`mac-specific-services`. - -Python on Mac OS 9 or earlier can be quite different from Python on Unix or -Windows, but is beyond the scope of this manual, as that platform is no longer -supported, starting with Python 2.4. See http://www.cwi.nl/~jack/macpython for -installers for the latest 2.3 release for Mac OS 9 and related documentation. - - -.. _getting-osx: - -Getting and Installing MacPython -================================ - -Mac OS X 10.4 comes with Python 2.3 pre-installed by Apple. However, you are -encouraged to install the most recent version of Python from the Python website -(http://www.python.org). A "universal binary" build of Python 2.5, which runs -natively on the Mac's new Intel and legacy PPC CPU's, is available there. - -What you get after installing is a number of things: - -* A :file:`MacPython 2.5` folder in your :file:`Applications` folder. In here - you find IDLE, the development environment that is a standard part of official - Python distributions; PythonLauncher, which handles double-clicking Python - scripts from the Finder; and the "Build Applet" tool, which allows you to - package Python scripts as standalone applications on your system. - -* A framework :file:`/Library/Frameworks/Python.framework`, which includes the - Python executable and libraries. The installer adds this location to your shell - path. To uninstall MacPython, you can simply remove these three things. A - symlink to the Python executable is placed in /usr/local/bin/. - -The Apple-provided build of Python is installed in -:file:`/System/Library/Frameworks/Python.framework` and :file:`/usr/bin/python`, -respectively. You should never modify or delete these, as they are -Apple-controlled and are used by Apple- or third-party software. - -IDLE includes a help menu that allows you to access Python documentation. If you -are completely new to Python you should start reading the tutorial introduction -in that document. - -If you are familiar with Python on other Unix platforms you should read the -section on running Python scripts from the Unix shell. - - -How to run a Python script --------------------------- - -Your best way to get started with Python on Mac OS X is through the IDLE -integrated development environment, see section :ref:`ide` and use the Help menu -when the IDE is running. - -If you want to run Python scripts from the Terminal window command line or from -the Finder you first need an editor to create your script. Mac OS X comes with a -number of standard Unix command line editors, :program:`vim` and -:program:`emacs` among them. If you want a more Mac-like editor, -:program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see -http://www.barebones.com/products/bbedit/index.shtml) are good choices, as is -:program:`TextMate` (see http://macromates.com/). Other editors include -:program:`Gvim` (http://macvim.org) and :program:`Aquamacs` -(http://aquamacs.org). - -To run your script from the Terminal window you must make sure that -:file:`/usr/local/bin` is in your shell search path. - -To run your script from the Finder you have two options: - -* Drag it to :program:`PythonLauncher` - -* Select :program:`PythonLauncher` as the default application to open your - script (or any .py script) through the finder Info window and double-click it. - :program:`PythonLauncher` has various preferences to control how your script is - launched. Option-dragging allows you to change these for one invocation, or use - its Preferences menu to change things globally. - - -.. _osx-gui-scripts: - -Running scripts with a GUI --------------------------- - -With older versions of Python, there is one Mac OS X quirk that you need to be -aware of: programs that talk to the Aqua window manager (in other words, -anything that has a GUI) need to be run in a special way. Use :program:`pythonw` -instead of :program:`python` to start such scripts. - -With Python 2.5, you can use either :program:`python` or :program:`pythonw`. - - -Configuration -------------- - -Python on OS X honors all standard Unix environment variables such as -:envvar:`PYTHONPATH`, but setting these variables for programs started from the -Finder is non-standard as the Finder does not read your :file:`.profile` or -:file:`.cshrc` at startup. You need to create a file :file:`~ -/.MacOSX/environment.plist`. See Apple's Technical Document QA1067 for details. - -For more information on installation Python packages in MacPython, see section -:ref:`mac-package-manager`. - - -.. _ide: - -The IDE -======= - -MacPython ships with the standard IDLE development environment. A good -introduction to using IDLE can be found at http://hkn.eecs.berkeley.edu/ -dyoo/python/idle_intro/index.html. - - -.. _mac-package-manager: - -Installing Additional Python Packages -===================================== - -There are several methods to install additional Python packages: - -* http://pythonmac.org/packages/ contains selected compiled packages for Python - 2.5, 2.4, and 2.3. - -* Packages can be installed via the standard Python distutils mode (``python - setup.py install``). - -* Many packages can also be installed via the :program:`setuptools` extension. - - -GUI Programming on the Mac -========================== - -There are several options for building GUI applications on the Mac with Python. - -*PyObjC* is a Python binding to Apple's Objective-C/Cocoa framework, which is -the foundation of most modern Mac development. Information on PyObjC is -available from http://pyobjc.sourceforge.net. - -The standard Python GUI toolkit is :mod:`Tkinter`, based on the cross-platform -Tk toolkit (http://www.tcl.tk). An Aqua-native version of Tk is bundled with OS -X by Apple, and the latest version can be downloaded and installed from -http://www.activestate.com; it can also be built from source. - -*wxPython* is another popular cross-platform GUI toolkit that runs natively on -Mac OS X. Packages and documentation are available from http://www.wxpython.org. - -*PyQt* is another popular cross-platform GUI toolkit that runs natively on Mac -OS X. More information can be found at -http://www.riverbankcomputing.co.uk/pyqt/. - - -Distributing Python Applications on the Mac -=========================================== - -The "Build Applet" tool that is placed in the MacPython 2.5 folder is fine for -packaging small Python scripts on your own machine to run as a standard Mac -application. This tool, however, is not robust enough to distribute Python -applications to other users. - -The standard tool for deploying standalone Python applications on the Mac is -:program:`py2app`. More information on installing and using py2app can be found -at http://undefined.org/python/#py2app. - - -Application Scripting -===================== - -Python can also be used to script other Mac applications via Apple's Open -Scripting Architecture (OSA); see http://appscript.sourceforge.net. Appscript is -a high-level, user-friendly Apple event bridge that allows you to control -scriptable Mac OS X applications using ordinary Python scripts. Appscript makes -Python a serious alternative to Apple's own *AppleScript* language for -automating your Mac. A related package, *PyOSA*, is an OSA language component -for the Python scripting language, allowing Python code to be executed by any -OSA-enabled application (Script Editor, Mail, iTunes, etc.). PyOSA makes Python -a full peer to AppleScript. - - -Other Resources -=============== - -The MacPython mailing list is an excellent support resource for Python users and -developers on the Mac: - -http://www.python.org/community/sigs/current/pythonmac-sig/ - -Another useful resource is the MacPython wiki: - -http://wiki.python.org/moin/MacPython - Modified: python/branches/py3k/Doc/howto/regex.rst ============================================================================== --- python/branches/py3k/Doc/howto/regex.rst (original) +++ python/branches/py3k/Doc/howto/regex.rst Thu Nov 1 21:32:30 2007 @@ -354,7 +354,7 @@ | | returns them as a list. | +------------------+-----------------------------------------------+ | ``finditer()`` | Find all substrings where the RE matches, and | -| | returns them as an iterator. | +| | returns them as an :term:`iterator`. | +------------------+-----------------------------------------------+ :meth:`match` and :meth:`search` return ``None`` if no match can be found. If @@ -460,7 +460,7 @@ :meth:`findall` has to create the entire list before it can be returned as the result. The :meth:`finditer` method returns a sequence of :class:`MatchObject` -instances as an iterator. [#]_ :: +instances as an :term:`iterator`. [#]_ :: >>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...') >>> iterator Modified: python/branches/py3k/Doc/includes/email-unpack.py ============================================================================== --- python/branches/py3k/Doc/includes/email-unpack.py (original) +++ python/branches/py3k/Doc/includes/email-unpack.py Thu Nov 1 21:32:30 2007 @@ -53,7 +53,7 @@ # email message can't be used to overwrite important files filename = part.get_filename() if not filename: - ext = mimetypes.guess_extension(part.get_type()) + ext = mimetypes.guess_extension(part.get_content_type()) if not ext: # Use a generic bag-of-bits extension ext = '.bin' Modified: python/branches/py3k/Doc/library/_ast.rst ============================================================================== --- python/branches/py3k/Doc/library/_ast.rst (original) +++ python/branches/py3k/Doc/library/_ast.rst Thu Nov 1 21:32:30 2007 @@ -12,7 +12,7 @@ The ``_ast`` module helps Python applications to process trees of the Python abstract syntax grammar. The Python compiler currently provides read-only access to such trees, meaning that applications can only create a tree for a given -piece of Python source code; generating byte code from a (potentially modified) +piece of Python source code; generating :term:`bytecode` from a (potentially modified) tree is not supported. The abstract syntax itself might change with each Python release; this module helps to find out programmatically what the current grammar looks like. Modified: python/branches/py3k/Doc/library/asynchat.rst ============================================================================== --- python/branches/py3k/Doc/library/asynchat.rst (original) +++ python/branches/py3k/Doc/library/asynchat.rst Thu Nov 1 21:32:30 2007 @@ -9,72 +9,90 @@ This module builds on the :mod:`asyncore` infrastructure, simplifying -asynchronous clients and servers and making it easier to handle protocols whose -elements are terminated by arbitrary strings, or are of variable length. +asynchronous clients and servers and making it easier to handle protocols +whose elements are terminated by arbitrary strings, or are of variable length. :mod:`asynchat` defines the abstract class :class:`async_chat` that you subclass, providing implementations of the :meth:`collect_incoming_data` and :meth:`found_terminator` methods. It uses the same asynchronous loop as -:mod:`asyncore`, and the two types of channel, :class:`asyncore.dispatcher` and -:class:`asynchat.async_chat`, can freely be mixed in the channel map. Typically -an :class:`asyncore.dispatcher` server channel generates new -:class:`asynchat.async_chat` channel objects as it receives incoming connection -requests. +:mod:`asyncore`, and the two types of channel, :class:`asyncore.dispatcher` +and :class:`asynchat.async_chat`, can freely be mixed in the channel map. +Typically an :class:`asyncore.dispatcher` server channel generates new +:class:`asynchat.async_chat` channel objects as it receives incoming +connection requests. .. class:: async_chat() This class is an abstract subclass of :class:`asyncore.dispatcher`. To make practical use of the code you must subclass :class:`async_chat`, providing - meaningful :meth:`collect_incoming_data` and :meth:`found_terminator` methods. + meaningful :meth:`collect_incoming_data` and :meth:`found_terminator` + methods. The :class:`asyncore.dispatcher` methods can be used, although not all make sense in a message/response context. - Like :class:`asyncore.dispatcher`, :class:`async_chat` defines a set of events - that are generated by an analysis of socket conditions after a :cfunc:`select` - call. Once the polling loop has been started the :class:`async_chat` object's - methods are called by the event-processing framework with no action on the part - of the programmer. - - Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to define a - first-in-first-out queue (fifo) of *producers*. A producer need have only one - method, :meth:`more`, which should return data to be transmitted on the channel. + Like :class:`asyncore.dispatcher`, :class:`async_chat` defines a set of + events that are generated by an analysis of socket conditions after a + :cfunc:`select` call. Once the polling loop has been started the + :class:`async_chat` object's methods are called by the event-processing + framework with no action on the part of the programmer. + + Two class attributes can be modified, to improve performance, or possibly + even to conserve memory. + + + .. data:: ac_in_buffer_size + + The asynchronous input buffer size (default ``4096``). + + + .. data:: ac_out_buffer_size + + The asynchronous output buffer size (default ``4096``). + + Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to + define a first-in-first-out queue (fifo) of *producers*. A producer need + have only one method, :meth:`more`, which should return data to be + transmitted on the channel. The producer indicates exhaustion (*i.e.* that it contains no more data) by having its :meth:`more` method return the empty string. At this point the - :class:`async_chat` object removes the producer from the fifo and starts using - the next producer, if any. When the producer fifo is empty the + :class:`async_chat` object removes the producer from the fifo and starts + using the next producer, if any. When the producer fifo is empty the :meth:`handle_write` method does nothing. You use the channel object's - :meth:`set_terminator` method to describe how to recognize the end of, or an - important breakpoint in, an incoming transmission from the remote endpoint. + :meth:`set_terminator` method to describe how to recognize the end of, or + an important breakpoint in, an incoming transmission from the remote + endpoint. To build a functioning :class:`async_chat` subclass your input methods - :meth:`collect_incoming_data` and :meth:`found_terminator` must handle the data - that the channel receives asynchronously. The methods are described below. + :meth:`collect_incoming_data` and :meth:`found_terminator` must handle the + data that the channel receives asynchronously. The methods are described + below. .. method:: async_chat.close_when_done() - Pushes a ``None`` on to the producer fifo. When this producer is popped off the - fifo it causes the channel to be closed. + Pushes a ``None`` on to the producer fifo. When this producer is popped off + the fifo it causes the channel to be closed. .. method:: async_chat.collect_incoming_data(data) - Called with *data* holding an arbitrary amount of received data. The default - method, which must be overridden, raises a :exc:`NotImplementedError` exception. + Called with *data* holding an arbitrary amount of received data. The + default method, which must be overridden, raises a + :exc:`NotImplementedError` exception. .. method:: async_chat.discard_buffers() - In emergencies this method will discard any data held in the input and/or output - buffers and the producer fifo. + In emergencies this method will discard any data held in the input and/or + output buffers and the producer fifo. .. method:: async_chat.found_terminator() - Called when the incoming data stream matches the termination condition set by - :meth:`set_terminator`. The default method, which must be overridden, raises a - :exc:`NotImplementedError` exception. The buffered input data should be - available via an instance attribute. + Called when the incoming data stream matches the termination condition set + by :meth:`set_terminator`. The default method, which must be overridden, + raises a :exc:`NotImplementedError` exception. The buffered input data + should be available via an instance attribute. .. method:: async_chat.get_terminator() @@ -90,59 +108,59 @@ .. method:: async_chat.handle_read() - Called when a read event fires on the channel's socket in the asynchronous loop. - The default method checks for the termination condition established by - :meth:`set_terminator`, which can be either the appearance of a particular - string in the input stream or the receipt of a particular number of characters. - When the terminator is found, :meth:`handle_read` calls the - :meth:`found_terminator` method after calling :meth:`collect_incoming_data` with - any data preceding the terminating condition. + Called when a read event fires on the channel's socket in the asynchronous + loop. The default method checks for the termination condition established + by :meth:`set_terminator`, which can be either the appearance of a + particular string in the input stream or the receipt of a particular number + of characters. When the terminator is found, :meth:`handle_read` calls the + :meth:`found_terminator` method after calling :meth:`collect_incoming_data` + with any data preceding the terminating condition. .. method:: async_chat.handle_write() - Called when the application may write data to the channel. The default method - calls the :meth:`initiate_send` method, which in turn will call - :meth:`refill_buffer` to collect data from the producer fifo associated with the - channel. + Called when the application may write data to the channel. The default + method calls the :meth:`initiate_send` method, which in turn will call + :meth:`refill_buffer` to collect data from the producer fifo associated + with the channel. .. method:: async_chat.push(data) - Creates a :class:`simple_producer` object (*see below*) containing the data and - pushes it on to the channel's ``producer_fifo`` to ensure its transmission. This - is all you need to do to have the channel write the data out to the network, - although it is possible to use your own producers in more complex schemes to - implement encryption and chunking, for example. + Creates a :class:`simple_producer` object (*see below*) containing the data + and pushes it on to the channel's ``producer_fifo`` to ensure its + transmission. This is all you need to do to have the channel write the + data out to the network, although it is possible to use your own producers + in more complex schemes to implement encryption and chunking, for example. .. method:: async_chat.push_with_producer(producer) - Takes a producer object and adds it to the producer fifo associated with the - channel. When all currently-pushed producers have been exhausted the channel - will consume this producer's data by calling its :meth:`more` method and send - the data to the remote endpoint. + Takes a producer object and adds it to the producer fifo associated with + the channel. When all currently-pushed producers have been exhausted the + channel will consume this producer's data by calling its :meth:`more` + method and send the data to the remote endpoint. .. method:: async_chat.readable() - Should return ``True`` for the channel to be included in the set of channels - tested by the :cfunc:`select` loop for readability. + Should return ``True`` for the channel to be included in the set of + channels tested by the :cfunc:`select` loop for readability. .. method:: async_chat.refill_buffer() - Refills the output buffer by calling the :meth:`more` method of the producer at - the head of the fifo. If it is exhausted then the producer is popped off the - fifo and the next producer is activated. If the current producer is, or becomes, - ``None`` then the channel is closed. + Refills the output buffer by calling the :meth:`more` method of the + producer at the head of the fifo. If it is exhausted then the producer is + popped off the fifo and the next producer is activated. If the current + producer is, or becomes, ``None`` then the channel is closed. .. method:: async_chat.set_terminator(term) - Sets the terminating condition to be recognised on the channel. ``term`` may be - any of three types of value, corresponding to three different ways to handle - incoming protocol data. + Sets the terminating condition to be recognized on the channel. ``term`` + may be any of three types of value, corresponding to three different ways + to handle incoming protocol data. +-----------+---------------------------------------------+ | term | Description | @@ -158,8 +176,8 @@ | | forever | +-----------+---------------------------------------------+ - Note that any data following the terminator will be available for reading by the - channel after :meth:`found_terminator` is called. + Note that any data following the terminator will be available for reading + by the channel after :meth:`found_terminator` is called. .. method:: async_chat.writable() @@ -174,29 +192,29 @@ .. class:: simple_producer(data[, buffer_size=512]) - A :class:`simple_producer` takes a chunk of data and an optional buffer size. - Repeated calls to its :meth:`more` method yield successive chunks of the data no - larger than *buffer_size*. + A :class:`simple_producer` takes a chunk of data and an optional buffer + size. Repeated calls to its :meth:`more` method yield successive chunks of + the data no larger than *buffer_size*. .. method:: simple_producer.more() - Produces the next chunk of information from the producer, or returns the empty - string. + Produces the next chunk of information from the producer, or returns the + empty string. .. class:: fifo([list=None]) - Each channel maintains a :class:`fifo` holding data which has been pushed by the - application but not yet popped for writing to the channel. A :class:`fifo` is a - list used to hold data and/or producers until they are required. If the *list* - argument is provided then it should contain producers or data items to be - written to the channel. + Each channel maintains a :class:`fifo` holding data which has been pushed + by the application but not yet popped for writing to the channel. A + :class:`fifo` is a list used to hold data and/or producers until they are + required. If the *list* argument is provided then it should contain + producers or data items to be written to the channel. .. method:: fifo.is_empty() - Returns ``True`` iff the fifo is empty. + Returns ``True`` if and only if the fifo is empty. .. method:: fifo.first() @@ -206,14 +224,14 @@ .. method:: fifo.push(data) - Adds the given data (which may be a string or a producer object) to the producer - fifo. + Adds the given data (which may be a string or a producer object) to the + producer fifo. .. method:: fifo.pop() - If the fifo is not empty, returns ``True, first()``, deleting the popped item. - Returns ``False, None`` for an empty fifo. + If the fifo is not empty, returns ``True, first()``, deleting the popped + item. Returns ``False, None`` for an empty fifo. The :mod:`asynchat` module also defines one utility function, which may be of use in network and textual analysis operations. @@ -221,8 +239,8 @@ .. function:: find_prefix_at_end(haystack, needle) - Returns ``True`` if string *haystack* ends with any non-empty prefix of string - *needle*. + Returns ``True`` if string *haystack* ends with any non-empty prefix of + string *needle*. .. _asynchat-example: @@ -231,19 +249,20 @@ ---------------- The following partial example shows how HTTP requests can be read with -:class:`async_chat`. A web server might create an :class:`http_request_handler` -object for each incoming client connection. Notice that initially the channel -terminator is set to match the blank line at the end of the HTTP headers, and a -flag indicates that the headers are being read. - -Once the headers have been read, if the request is of type POST (indicating that -further data are present in the input stream) then the ``Content-Length:`` -header is used to set a numeric terminator to read the right amount of data from -the channel. +:class:`async_chat`. A web server might create an +:class:`http_request_handler` object for each incoming client connection. +Notice that initially the channel terminator is set to match the blank line at +the end of the HTTP headers, and a flag indicates that the headers are being +read. + +Once the headers have been read, if the request is of type POST (indicating +that further data are present in the input stream) then the +``Content-Length:`` header is used to set a numeric terminator to read the +right amount of data from the channel. The :meth:`handle_request` method is called once all relevant input has been -marshalled, after setting the channel terminator to ``None`` to ensure that any -extraneous data sent by the web client are ignored. :: +marshalled, after setting the channel terminator to ``None`` to ensure that +any extraneous data sent by the web client are ignored. :: class http_request_handler(asynchat.async_chat): @@ -281,4 +300,3 @@ self.handling = True self.ibuffer = [] self.handle_request() - Modified: python/branches/py3k/Doc/library/asyncore.rst ============================================================================== --- python/branches/py3k/Doc/library/asyncore.rst (original) +++ python/branches/py3k/Doc/library/asyncore.rst Thu Nov 1 21:32:30 2007 @@ -3,7 +3,8 @@ =============================================== .. module:: asyncore - :synopsis: A base class for developing asynchronous socket handling services. + :synopsis: A base class for developing asynchronous socket handling + services. .. moduleauthor:: Sam Rushing .. sectionauthor:: Christopher Petrilli .. sectionauthor:: Steve Holden @@ -16,76 +17,67 @@ There are only two ways to have a program on a single processor do "more than one thing at a time." Multi-threaded programming is the simplest and most -popular way to do it, but there is another very different technique, that lets +popular way to do it, but there is another very different technique, that lets you have nearly all the advantages of multi-threading, without actually using multiple threads. It's really only practical if your program is largely I/O -bound. If your program is processor bound, then pre-emptive scheduled threads -are probably what you really need. Network servers are rarely processor bound, -however. +bound. If your program is processor bound, then pre-emptive scheduled threads +are probably what you really need. Network servers are rarely processor +bound, however. If your operating system supports the :cfunc:`select` system call in its I/O library (and nearly all do), then you can use it to juggle multiple -communication channels at once; doing other work while your I/O is taking place -in the "background." Although this strategy can seem strange and complex, -especially at first, it is in many ways easier to understand and control than -multi-threaded programming. The :mod:`asyncore` module solves many of the -difficult problems for you, making the task of building sophisticated -high-performance network servers and clients a snap. For "conversational" -applications and protocols the companion :mod:`asynchat` module is invaluable. - -The basic idea behind both modules is to create one or more network *channels*, -instances of class :class:`asyncore.dispatcher` and -:class:`asynchat.async_chat`. Creating the channels adds them to a global map, -used by the :func:`loop` function if you do not provide it with your own *map*. +communication channels at once; doing other work while your I/O is taking +place in the "background." Although this strategy can seem strange and +complex, especially at first, it is in many ways easier to understand and +control than multi-threaded programming. The :mod:`asyncore` module solves +many of the difficult problems for you, making the task of building +sophisticated high-performance network servers and clients a snap. For +"conversational" applications and protocols the companion :mod:`asynchat` +module is invaluable. + +The basic idea behind both modules is to create one or more network +*channels*, instances of class :class:`asyncore.dispatcher` and +:class:`asynchat.async_chat`. Creating the channels adds them to a global +map, used by the :func:`loop` function if you do not provide it with your own +*map*. Once the initial channel(s) is(are) created, calling the :func:`loop` function -activates channel service, which continues until the last channel (including any -that have been added to the map during asynchronous service) is closed. +activates channel service, which continues until the last channel (including +any that have been added to the map during asynchronous service) is closed. .. function:: loop([timeout[, use_poll[, map[,count]]]]) - Enter a polling loop that terminates after count passes or all open channels - have been closed. All arguments are optional. The *count* parameter defaults - to None, resulting in the loop terminating only when all channels have been - closed. The *timeout* argument sets the timeout parameter for the appropriate - :func:`select` or :func:`poll` call, measured in seconds; the default is 30 - seconds. The *use_poll* parameter, if true, indicates that :func:`poll` should - be used in preference to :func:`select` (the default is ``False``). - - The *map* parameter is a dictionary whose items are the channels to watch. As - channels are closed they are deleted from their map. If *map* is omitted, a - global map is used. Channels (instances of :class:`asyncore.dispatcher`, - :class:`asynchat.async_chat` and subclasses thereof) can freely be mixed in the - map. + Enter a polling loop that terminates after count passes or all open + channels have been closed. All arguments are optional. The *count* + parameter defaults to None, resulting in the loop terminating only when all + channels have been closed. The *timeout* argument sets the timeout + parameter for the appropriate :func:`select` or :func:`poll` call, measured + in seconds; the default is 30 seconds. The *use_poll* parameter, if true, + indicates that :func:`poll` should be used in preference to :func:`select` + (the default is ``False``). + + The *map* parameter is a dictionary whose items are the channels to watch. + As channels are closed they are deleted from their map. If *map* is + omitted, a global map is used. Channels (instances of + :class:`asyncore.dispatcher`, :class:`asynchat.async_chat` and subclasses + thereof) can freely be mixed in the map. .. class:: dispatcher() The :class:`dispatcher` class is a thin wrapper around a low-level socket - object. To make it more useful, it has a few methods for event-handling which - are called from the asynchronous loop. Otherwise, it can be treated as a - normal non-blocking socket object. - - Two class attributes can be modified, to improve performance, or possibly even - to conserve memory. - - - .. data:: ac_in_buffer_size - - The asynchronous input buffer size (default ``4096``). - - - .. data:: ac_out_buffer_size - - The asynchronous output buffer size (default ``4096``). - - The firing of low-level events at certain times or in certain connection states - tells the asynchronous loop that certain higher-level events have taken place. - For example, if we have asked for a socket to connect to another host, we know - that the connection has been made when the socket becomes writable for the first - time (at this point you know that you may write to it with the expectation of - success). The implied higher-level events are: + object. To make it more useful, it has a few methods for event-handling + which are called from the asynchronous loop. Otherwise, it can be treated + as a normal non-blocking socket object. + + The firing of low-level events at certain times or in certain connection + states tells the asynchronous loop that certain higher-level events have + taken place. For example, if we have asked for a socket to connect to + another host, we know that the connection has been made when the socket + becomes writable for the first time (at this point you know that you may + write to it with the expectation of success). The implied higher-level + events are: +----------------------+----------------------------------------+ | Event | Description | @@ -101,11 +93,11 @@ During asynchronous processing, each mapped channel's :meth:`readable` and :meth:`writable` methods are used to determine whether the channel's socket - should be added to the list of channels :cfunc:`select`\ ed or :cfunc:`poll`\ ed - for read and write events. + should be added to the list of channels :cfunc:`select`\ ed or + :cfunc:`poll`\ ed for read and write events. -Thus, the set of channel events is larger than the basic socket events. The full -set of methods that can be overridden in your subclass follows: +Thus, the set of channel events is larger than the basic socket events. The +full set of methods that can be overridden in your subclass follows: .. method:: dispatcher.handle_read() @@ -116,9 +108,9 @@ .. method:: dispatcher.handle_write() - Called when the asynchronous loop detects that a writable socket can be written. - Often this method will implement the necessary buffering for performance. For - example:: + Called when the asynchronous loop detects that a writable socket can be + written. Often this method will implement the necessary buffering for + performance. For example:: def handle_write(self): sent = self.send(self.buffer) @@ -127,15 +119,15 @@ .. method:: dispatcher.handle_expt() - Called when there is out of band (OOB) data for a socket connection. This will - almost never happen, as OOB is tenuously supported and rarely used. + Called when there is out of band (OOB) data for a socket connection. This + will almost never happen, as OOB is tenuously supported and rarely used. .. method:: dispatcher.handle_connect() - Called when the active opener's socket actually makes a connection. Might send a - "welcome" banner, or initiate a protocol negotiation with the remote endpoint, - for example. + Called when the active opener's socket actually makes a connection. Might + send a "welcome" banner, or initiate a protocol negotiation with the remote + endpoint, for example. .. method:: dispatcher.handle_close() @@ -152,40 +144,40 @@ .. method:: dispatcher.handle_accept() Called on listening channels (passive openers) when a connection can be - established with a new remote endpoint that has issued a :meth:`connect` call - for the local endpoint. + established with a new remote endpoint that has issued a :meth:`connect` + call for the local endpoint. .. method:: dispatcher.readable() - Called each time around the asynchronous loop to determine whether a channel's - socket should be added to the list on which read events can occur. The default - method simply returns ``True``, indicating that by default, all channels will - be interested in read events. + Called each time around the asynchronous loop to determine whether a + channel's socket should be added to the list on which read events can + occur. The default method simply returns ``True``, indicating that by + default, all channels will be interested in read events. .. method:: dispatcher.writable() - Called each time around the asynchronous loop to determine whether a channel's - socket should be added to the list on which write events can occur. The default - method simply returns ``True``, indicating that by default, all channels will - be interested in write events. + Called each time around the asynchronous loop to determine whether a + channel's socket should be added to the list on which write events can + occur. The default method simply returns ``True``, indicating that by + default, all channels will be interested in write events. -In addition, each channel delegates or extends many of the socket methods. Most -of these are nearly identical to their socket partners. +In addition, each channel delegates or extends many of the socket methods. +Most of these are nearly identical to their socket partners. .. method:: dispatcher.create_socket(family, type) - This is identical to the creation of a normal socket, and will use the same - options for creation. Refer to the :mod:`socket` documentation for information - on creating sockets. + This is identical to the creation of a normal socket, and will use the same + options for creation. Refer to the :mod:`socket` documentation for + information on creating sockets. .. method:: dispatcher.connect(address) - As with the normal socket object, *address* is a tuple with the first element - the host to connect to, and the second the port number. + As with the normal socket object, *address* is a tuple with the first + element the host to connect to, and the second the port number. .. method:: dispatcher.send(data) @@ -195,38 +187,41 @@ .. method:: dispatcher.recv(buffer_size) - Read at most *buffer_size* bytes from the socket's remote end-point. An empty - string implies that the channel has been closed from the other end. + Read at most *buffer_size* bytes from the socket's remote end-point. + An empty string implies that the channel has been closed from the other + end. .. method:: dispatcher.listen(backlog) - Listen for connections made to the socket. The *backlog* argument specifies the - maximum number of queued connections and should be at least 1; the maximum value - is system-dependent (usually 5). + Listen for connections made to the socket. The *backlog* argument + specifies the maximum number of queued connections and should be at least + 1; the maximum value is system-dependent (usually 5). .. method:: dispatcher.bind(address) Bind the socket to *address*. The socket must not already be bound. (The - format of *address* depends on the address family --- see above.) To mark the - socket as re-usable (setting the :const:`SO_REUSEADDR` option), call the - :class:`dispatcher` object's :meth:`set_reuse_addr` method. + format of *address* depends on the address family --- see above.) To mark + the socket as re-usable (setting the :const:`SO_REUSEADDR` option), call + the :class:`dispatcher` object's :meth:`set_reuse_addr` method. .. method:: dispatcher.accept() - Accept a connection. The socket must be bound to an address and listening for - connections. The return value is a pair ``(conn, address)`` where *conn* is a - *new* socket object usable to send and receive data on the connection, and - *address* is the address bound to the socket on the other end of the connection. + Accept a connection. The socket must be bound to an address and listening + for connections. The return value is a pair ``(conn, address)`` where + *conn* is a *new* socket object usable to send and receive data on the + connection, and *address* is the address bound to the socket on the other + end of the connection. .. method:: dispatcher.close() - Close the socket. All future operations on the socket object will fail. The - remote end-point will receive no more data (after queued data is flushed). - Sockets are automatically closed when they are garbage-collected. + Close the socket. All future operations on the socket object will fail. + The remote end-point will receive no more data (after queued data is + flushed). Sockets are automatically closed when they are + garbage-collected. .. _asyncore-example: @@ -266,4 +261,3 @@ c = http_client('www.python.org', '/') asyncore.loop() - Modified: python/branches/py3k/Doc/library/autogil.rst ============================================================================== --- python/branches/py3k/Doc/library/autogil.rst (original) +++ python/branches/py3k/Doc/library/autogil.rst Thu Nov 1 21:32:30 2007 @@ -9,8 +9,8 @@ The :mod:`autoGIL` module provides a function :func:`installAutoGIL` that -automatically locks and unlocks Python's Global Interpreter Lock when running an -event loop. +automatically locks and unlocks Python's :term:`Global Interpreter Lock` when +running an event loop. .. exception:: AutoGILError Modified: python/branches/py3k/Doc/library/codecs.rst ============================================================================== --- python/branches/py3k/Doc/library/codecs.rst (original) +++ python/branches/py3k/Doc/library/codecs.rst Thu Nov 1 21:32:30 2007 @@ -238,15 +238,15 @@ .. function:: iterencode(iterable, encoding[, errors]) Uses an incremental encoder to iteratively encode the input provided by - *iterable*. This function is a generator. *errors* (as well as any other keyword - argument) is passed through to the incremental encoder. + *iterable*. This function is a :term:`generator`. *errors* (as well as any + other keyword argument) is passed through to the incremental encoder. .. function:: iterdecode(iterable, encoding[, errors]) Uses an incremental decoder to iteratively decode the input provided by - *iterable*. This function is a generator. *errors* (as well as any other keyword - argument) is passed through to the incremental decoder. + *iterable*. This function is a :term:`generator`. *errors* (as well as any + other keyword argument) is passed through to the incremental decoder. The module also provides the following constants which are useful for reading and writing to platform dependent files: Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Thu Nov 1 21:32:30 2007 @@ -10,7 +10,7 @@ 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 +one datatype factory function, :func:`named_tuple`. 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 @@ -75,7 +75,7 @@ ---------------------- -.. class:: deque([iterable]) +.. class:: deque([iterable[, maxlen]]) Returns a new deque object initialized left-to-right (using :meth:`append`) with data from *iterable*. If *iterable* is not specified, the new deque is empty. @@ -91,6 +91,17 @@ position of the underlying data representation. + If *maxlen* is not specified or is *None*, deques may grow to an + arbitrary length. Otherwise, the deque is bounded to the specified maximum + length. Once a bounded length deque is full, when new items are added, a + corresponding number of items are discarded from the opposite end. Bounded + length deques provide functionality similar to the ``tail`` filter in + Unix. They are also useful for tracking transactions and other pools of data + where only the most recent activity is of interest. + + .. versionchanged:: 2.6 + Added *maxlen* + Deque objects support the following methods: .. method:: deque.append(x) @@ -205,8 +216,8 @@ .. _deque-recipes: -Recipes -^^^^^^^ +:class:`deque` Recipes +^^^^^^^^^^^^^^^^^^^^^^ This section shows various approaches to working with deques. @@ -223,42 +234,14 @@ :meth:`rotate` to bring a target element to the left side of the deque. Remove old entries with :meth:`popleft`, add new entries with :meth:`extend`, and then reverse the rotation. - With minor variations on that approach, it is easy to implement Forth style stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``, ``rot``, and ``roll``. -A roundrobin task server can be built from a :class:`deque` using -:meth:`popleft` to select the current task and :meth:`append` to add it back to -the tasklist if the input stream is not exhausted:: - - >>> def roundrobin(*iterables): - ... pending = deque(iter(i) for i in iterables) - ... while pending: - ... task = pending.popleft() - ... try: - ... yield next(task) - ... except StopIteration: - ... continue - ... pending.append(task) - ... - >>> for value in roundrobin('abc', 'd', 'efgh'): - ... print(value) - - a - d - e - b - f - c - g - h - - Multi-pass data reduction algorithms can be succinctly expressed and efficiently coded by extracting elements with multiple calls to :meth:`popleft`, applying -the reduction function, and calling :meth:`append` to add the result back to the -queue. +a reduction function, and calling :meth:`append` to add the result back to the +deque. For example, building a balanced binary tree of nested lists entails reducing two adjacent nodes into one by grouping them in a list:: @@ -273,7 +256,12 @@ >>> print(maketree('abcdefgh')) [[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]] +Bounded length deques provide functionality similar to the ``tail`` filter +in Unix:: + def tail(filename, n=10): + 'Return the last n lines of a file' + return deque(open(filename), n) .. _defaultdict-objects: @@ -395,14 +383,14 @@ .. _named-tuple-factory: -:func:`NamedTuple` Factory Function for Tuples with Named Fields ----------------------------------------------------------------- +:func:`named_tuple` Factory Function for Tuples with Named Fields +----------------------------------------------------------------- Named tuples assign meaning to each position in a tuple and allow for more readable, self-documenting code. They can be used wherever regular tuples are used, and they add the ability to access fields by name instead of position index. -.. function:: NamedTuple(typename, fieldnames, [verbose]) +.. function:: named_tuple(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 @@ -410,17 +398,24 @@ helpful docstring (with typename and fieldnames) and a helpful :meth:`__repr__` method which lists the tuple contents in a ``name=value`` format. - The *fieldnames* are specified in a single string with each fieldname separated by - a space and/or comma. Any valid Python identifier may be used for a fieldname. + The *fieldnames* are a single string with each fieldname separated by whitespace + and/or commas (for example 'x y' or 'x, y'). Alternatively, the *fieldnames* + can be specified as a list of strings (such as ['x', 'y']). + + Any valid Python identifier may be used for a fieldname except for names + starting and ending with double underscores. Valid identifiers consist of + letters, digits, and underscores but do not start with a digit and cannot be + a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, *print*, + or *raise*. If *verbose* is true, will print the class definition. - *NamedTuple* instances do not have per-instance dictionaries, so they are + Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples. Example:: - >>> Point = NamedTuple('Point', 'x y', True) + >>> Point = named_tuple('Point', 'x y', verbose=True) class Point(tuple): 'Point(x, y)' __slots__ = () @@ -429,6 +424,9 @@ return tuple.__new__(cls, (x, y)) def __repr__(self): return 'Point(x=%r, y=%r)' % self + def __asdict__(self): + 'Return a new dict mapping field names to their values' + return dict(zip(('x', 'y'), self)) def __replace__(self, field, value): 'Return a new Point object replacing one field with a new value' return Point(**dict(zip(('x', 'y'), self) + [(field, value)])) @@ -449,23 +447,46 @@ Named tuples are especially useful for assigning field names to result tuples returned by the :mod:`csv` or :mod:`sqlite3` modules:: + EmployeeRecord = named_tuple('EmployeeRecord', 'name, age, title, department, paygrade') + from itertools import starmap import csv - EmployeeRecord = NamedTuple('EmployeeRecord', 'name age title department paygrade') for record in starmap(EmployeeRecord, csv.reader(open("employees.csv", "rb"))): print(emp.name, emp.title) -When casting a single record to a *NamedTuple*, use the star-operator [#]_ to unpack + import sqlite3 + conn = sqlite3.connect('/companydata') + cursor = conn.cursor() + cursor.execute('SELECT name, age, title, department, paygrade FROM employees') + for emp in starmap(EmployeeRecord, cursor.fetchall()): + print emp.name, emp.title + +When casting a single record to a named tuple, use the star-operator [#]_ to unpack the values:: >>> t = [11, 22] >>> Point(*t) # the star-operator unpacks any iterable object Point(x=11, y=22) +When casting a dictionary to a named tuple, use the double-star-operator:: + + >>> d = {'x': 11, 'y': 22} + >>> Point(**d) + Point(x=11, y=22) + In addition to the methods inherited from tuples, named tuples support -an additonal method and an informational read-only attribute. +two additonal methods and a read-only attribute. + +.. method:: somenamedtuple.__asdict__() + + Return a new dict which maps field names to their corresponding values: + +:: -.. method:: somenamedtuple.replace(field, value) + >>> p.__asdict__() + {'x': 11, 'y': 22} + +.. method:: somenamedtuple.__replace__(field, value) Return a new instance of the named tuple replacing the named *field* with a new *value*: @@ -480,20 +501,16 @@ .. attribute:: somenamedtuple.__fields__ - Return a tuple of strings listing the field names. This is useful for introspection, - for converting a named tuple instance to a dictionary, and for combining named tuple - types to create new named tuple types: + Return a tuple of strings listing the field names. This is useful for introspection + and for creating new named tuple types from existing named tuples. :: - >>> p.__fields__ # view the field names + >>> p.__fields__ # view the field names ('x', 'y') - >>> dict(zip(p.__fields__, p)) # convert to a dictionary - {'y': 22, 'x': 11} - >>> Color = NamedTuple('Color', 'red green blue') - >>> pixel_fields = ' '.join(Point.__fields__ + Color.__fields__) # combine fields - >>> Pixel = NamedTuple('Pixel', pixel_fields) + >>> Color = named_tuple('Color', 'red green blue') + >>> Pixel = named_tuple('Pixel', Point.__fields__ + Color.__fields__) >>> Pixel(11, 22, 128, 255, 0) Pixel(x=11, y=22, red=128, green=255, blue=0)' Modified: python/branches/py3k/Doc/library/contextlib.rst ============================================================================== --- python/branches/py3k/Doc/library/contextlib.rst (original) +++ python/branches/py3k/Doc/library/contextlib.rst Thu Nov 1 21:32:30 2007 @@ -37,9 +37,9 @@ foo - The function being decorated must return a generator-iterator when called. This - iterator must yield exactly one value, which will be bound to the targets in the - :keyword:`with` statement's :keyword:`as` clause, if any. + The function being decorated must return a :term:`generator`-iterator when + called. This iterator must yield exactly one value, which will be bound to + the targets in the :keyword:`with` statement's :keyword:`as` clause, if any. At the point where the generator yields, the block nested in the :keyword:`with` statement is executed. The generator is then resumed after the block is exited. Modified: python/branches/py3k/Doc/library/cookielib.rst ============================================================================== --- python/branches/py3k/Doc/library/cookielib.rst (original) +++ python/branches/py3k/Doc/library/cookielib.rst Thu Nov 1 21:32:30 2007 @@ -140,7 +140,7 @@ CookieJar and FileCookieJar Objects ----------------------------------- -:class:`CookieJar` objects support the iterator protocol for iterating over +:class:`CookieJar` objects support the :term:`iterator` protocol for iterating over contained :class:`Cookie` objects. :class:`CookieJar` has the following methods: Modified: python/branches/py3k/Doc/library/csv.rst ============================================================================== --- python/branches/py3k/Doc/library/csv.rst (original) +++ python/branches/py3k/Doc/library/csv.rst Thu Nov 1 21:32:30 2007 @@ -60,7 +60,7 @@ .. function:: reader(csvfile[, dialect='excel'][, fmtparam]) Return a reader object which will iterate over lines in the given *csvfile*. - *csvfile* can be any object which supports the iterator protocol and returns a + *csvfile* can be any object which supports the :term:`iterator` protocol and returns a string each time its :meth:`next` method is called --- file objects and list objects are both suitable. If *csvfile* is a file object, it must be opened with the 'b' flag on platforms where that makes a difference. An optional @@ -138,7 +138,7 @@ The :mod:`csv` module defines the following classes: -.. class:: DictReader(csvfile[, fieldnames=:const:None,[, restkey=:const:None[, restval=None[, dialect='excel'[, *args, **kwds]]]]]) +.. class:: DictReader(csvfile[, fieldnames=None[, restkey=None[, restval=None[, dialect='excel'[, *args, **kwds]]]]]) Create an object which operates like a regular reader but maps the information read into a dict whose keys are given by the optional *fieldnames* parameter. @@ -436,9 +436,9 @@ write functions or classes that handle the encoding and decoding for you as long as you avoid encodings like UTF-16 that use NULs. UTF-8 is recommended. -:func:`unicode_csv_reader` below is a generator that wraps :class:`csv.reader` +:func:`unicode_csv_reader` below is a :term:`generator` that wraps :class:`csv.reader` to handle Unicode CSV data (a list of Unicode strings). :func:`utf_8_encoder` -is a generator that encodes the Unicode strings as UTF-8, one string (or row) at +is a :term:`generator` that encodes the Unicode strings as UTF-8, one string (or row) at a time. The encoded strings are parsed by the CSV reader, and :func:`unicode_csv_reader` decodes the UTF-8-encoded cells back into Unicode:: Modified: python/branches/py3k/Doc/library/ctypes.rst ============================================================================== --- python/branches/py3k/Doc/library/ctypes.rst (original) +++ python/branches/py3k/Doc/library/ctypes.rst Thu Nov 1 21:32:30 2007 @@ -584,8 +584,8 @@ >>> r = RECT(POINT(1, 2), POINT(3, 4)) >>> r = RECT((1, 2), (3, 4)) -Fields descriptors can be retrieved from the *class*, they are useful for -debugging because they can provide useful information:: +Field :term:`descriptor`\s can be retrieved from the *class*, they are useful +for debugging because they can provide useful information:: >>> print(POINT.x) @@ -1195,10 +1195,10 @@ >>> Why is it printing ``False``? ctypes instances are objects containing a memory -block plus some descriptors accessing the contents of the memory. Storing a -Python object in the memory block does not store the object itself, instead the -``contents`` of the object is stored. Accessing the contents again constructs a -new Python each time! +block plus some :term:`descriptor`\s accessing the contents of the memory. +Storing a Python object in the memory block does not store the object itself, +instead the ``contents`` of the object is stored. Accessing the contents again +constructs a new Python object each time! .. _ctypes-variable-sized-data-types: @@ -1366,8 +1366,8 @@ :class:`WinDLL` and :class:`OleDLL` use the standard calling convention on this platform. -The Python GIL is released before calling any function exported by these -libraries, and reacquired afterwards. +The Python :term:`global interpreter lock` is released before calling any +function exported by these libraries, and reacquired afterwards. .. class:: PyDLL(name, mode=DEFAULT_MODE, handle=None) @@ -1948,7 +1948,7 @@ in case the memory block contains pointers. Common methods of ctypes data types, these are all class methods (to be exact, -they are methods of the metaclass): +they are methods of the :term:`metaclass`): .. method:: _CData.from_address(address) @@ -2263,7 +2263,7 @@ Concrete structure and union types must be created by subclassing one of these types, and at least define a :attr:`_fields_` class variable. ``ctypes`` will -create descriptors which allow reading and writing the fields by direct +create :term:`descriptor`\s which allow reading and writing the fields by direct attribute accesses. These are the Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Thu Nov 1 21:32:30 2007 @@ -174,7 +174,7 @@ >>> c % a Decimal("0.77") -And some mathematic functions are also available to Decimal:: +And some mathematical functions are also available to Decimal:: >>> Decimal(2).sqrt() Decimal("1.414213562373095048801688724") Modified: python/branches/py3k/Doc/library/difflib.rst ============================================================================== --- python/branches/py3k/Doc/library/difflib.rst (original) +++ python/branches/py3k/Doc/library/difflib.rst Thu Nov 1 21:32:30 2007 @@ -10,6 +10,11 @@ .. % LaTeXification by Fred L. Drake, Jr. . +This module provides classes and functions for comparing sequences. It +can be used for example, for comparing files, and can produce difference +information in various formats, including HTML and context and unified +diffs. For comparing directories and files, see also, the :mod:`filecmp` module. + .. class:: SequenceMatcher This is a flexible class for comparing pairs of sequences of any type, so long @@ -117,8 +122,8 @@ .. function:: context_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm]) - Compare *a* and *b* (lists of strings); return a delta (a generator generating - the delta lines) in context diff format. + Compare *a* and *b* (lists of strings); return a delta (a :term:`generator` + generating the delta lines) in context diff format. Context diffs are a compact way of showing just the lines that have changed plus a few lines of context. The changes are shown in a before/after style. The @@ -170,8 +175,8 @@ .. function:: ndiff(a, b[, linejunk][, charjunk]) - Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style delta - (a generator generating the delta lines). + Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style + delta (a :term:`generator` generating the delta lines). Optional keyword parameters *linejunk* and *charjunk* are for filter functions (or ``None``): @@ -231,8 +236,8 @@ .. function:: unified_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm]) - Compare *a* and *b* (lists of strings); return a delta (a generator generating - the delta lines) in unified diff format. + Compare *a* and *b* (lists of strings); return a delta (a :term:`generator` + generating the delta lines) in unified diff format. Unified diffs are a compact way of showing just the lines that have changed plus a few lines of context. The changes are shown in a inline style (instead of @@ -423,7 +428,7 @@ .. method:: SequenceMatcher.get_grouped_opcodes([n]) - Return a generator of groups with up to *n* lines of context. + Return a :term:`generator` of groups with up to *n* lines of context. Starting with the groups returned by :meth:`get_opcodes`, this method splits out smaller change clusters and eliminates intervening ranges which have no changes. Modified: python/branches/py3k/Doc/library/dis.rst ============================================================================== --- python/branches/py3k/Doc/library/dis.rst (original) +++ python/branches/py3k/Doc/library/dis.rst Thu Nov 1 21:32:30 2007 @@ -1,14 +1,14 @@ -:mod:`dis` --- Disassembler for Python byte code -================================================ +:mod:`dis` --- Disassembler for Python bytecode +=============================================== .. module:: dis - :synopsis: Disassembler for Python byte code. + :synopsis: Disassembler for Python bytecode. -The :mod:`dis` module supports the analysis of Python byte code by disassembling +The :mod:`dis` module supports the analysis of Python :term:`bytecode` by disassembling it. Since there is no Python assembler, this module defines the Python assembly -language. The Python byte code which this module takes as an input is defined +language. The Python bytecode which this module takes as an input is defined in the file :file:`Include/opcode.h` and used by the compiler and the interpreter. @@ -35,7 +35,7 @@ Disassemble the *bytesource* object. *bytesource* can denote either a module, a class, a method, a function, or a code object. For a module, it disassembles all functions. For a class, it disassembles all methods. For a single code - sequence, it prints one line per byte code instruction. If no object is + sequence, it prints one line per bytecode instruction. If no object is provided, it disassembles the last traceback. @@ -70,12 +70,12 @@ .. data:: opname - Sequence of operation names, indexable using the byte code. + Sequence of operation names, indexable using the bytecode. .. data:: opmap - Dictionary mapping byte codes to operation names. + Dictionary mapping bytecodes to operation names. .. data:: cmp_op @@ -85,45 +85,45 @@ .. data:: hasconst - Sequence of byte codes that have a constant parameter. + Sequence of bytecodes that have a constant parameter. .. data:: hasfree - Sequence of byte codes that access a free variable. + Sequence of bytecodes that access a free variable. .. data:: hasname - Sequence of byte codes that access an attribute by name. + Sequence of bytecodes that access an attribute by name. .. data:: hasjrel - Sequence of byte codes that have a relative jump target. + Sequence of bytecodes that have a relative jump target. .. data:: hasjabs - Sequence of byte codes that have an absolute jump target. + Sequence of bytecodes that have an absolute jump target. .. data:: haslocal - Sequence of byte codes that access a local variable. + Sequence of bytecodes that access a local variable. .. data:: hascompare - Sequence of byte codes of Boolean operations. + Sequence of bytecodes of Boolean operations. .. _bytecodes: -Python Byte Code Instructions ------------------------------ +Python Bytecode Instructions +---------------------------- -The Python compiler currently generates the following byte code instructions. +The Python compiler currently generates the following bytecode instructions. .. opcode:: STOP_CODE () @@ -381,7 +381,7 @@ .. opcode:: YIELD_VALUE () - Pops ``TOS`` and yields it from a generator. + Pops ``TOS`` and yields it from a :term:`generator`. .. opcode:: IMPORT_STAR () @@ -416,9 +416,9 @@ context manager's :meth:`__exit__` bound method. Below that are 1--3 values indicating how/why the finally clause was entered: - * SECOND = None - * (SECOND, THIRD) = (WHY_{RETURN,CONTINUE}), retval - * SECOND = WHY_\*; no retval below it + * SECOND = ``None`` + * (SECOND, THIRD) = (``WHY_{RETURN,CONTINUE}``), retval + * SECOND = ``WHY_*``; no retval below it * (SECOND, THIRD, FOURTH) = exc_info() In the last case, ``TOS(SECOND, THIRD, FOURTH)`` is called, otherwise @@ -428,6 +428,8 @@ returns a 'true' value, this information is "zapped", to prevent ``END_FINALLY`` from re-raising the exception. (But non-local gotos should still be resumed.) + .. XXX explain the WHY stuff! + All of the following opcodes expect arguments. An argument is two bytes, with the more significant byte last. @@ -548,32 +550,32 @@ .. opcode:: JUMP_FORWARD (delta) - Increments byte code counter by *delta*. + Increments bytecode counter by *delta*. .. opcode:: JUMP_IF_TRUE (delta) - If TOS is true, increment the byte code counter by *delta*. TOS is left on the + If TOS is true, increment the bytecode counter by *delta*. TOS is left on the stack. .. opcode:: JUMP_IF_FALSE (delta) - If TOS is false, increment the byte code counter by *delta*. TOS is not + If TOS is false, increment the bytecode counter by *delta*. TOS is not changed. .. opcode:: JUMP_ABSOLUTE (target) - Set byte code counter to *target*. + Set bytecode counter to *target*. .. opcode:: FOR_ITER (delta) - ``TOS`` is an iterator. Call its :meth:`__next__` method. If this yields a new - value, push it on the stack (leaving the iterator below it). If the iterator - indicates it is exhausted ``TOS`` is popped, and the byte code counter is - incremented by *delta*. + ``TOS`` is an :term:`iterator`. Call its :meth:`__next__` method. If this + yields a new value, push it on the stack (leaving the iterator below it). If + the iterator indicates it is exhausted ``TOS`` is popped, and the byte code + counter is incremented by *delta*. .. % \begin{opcodedesc}{FOR_LOOP}{delta} .. % This opcode is obsolete. Modified: python/branches/py3k/Doc/library/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/library/exceptions.rst (original) +++ python/branches/py3k/Doc/library/exceptions.rst Thu Nov 1 21:32:30 2007 @@ -135,7 +135,7 @@ .. exception:: GeneratorExit - Raise when a generator's :meth:`close` method is called. + Raise when a :term:`generator`\'s :meth:`close` method is called. .. exception:: IOError @@ -241,8 +241,8 @@ .. exception:: StopIteration - Raised by builtin :func:`next` and an iterator's :meth:`__next__` method to - signal that there are no further values. + Raised by builtin :func:`next` and an :term:`iterator`\'s :meth:`__next__` + method to signal that there are no further values. .. exception:: SyntaxError Modified: python/branches/py3k/Doc/library/filecmp.rst ============================================================================== --- python/branches/py3k/Doc/library/filecmp.rst (original) +++ python/branches/py3k/Doc/library/filecmp.rst Thu Nov 1 21:32:30 2007 @@ -8,7 +8,8 @@ The :mod:`filecmp` module defines functions to compare files and directories, -with various optional time/correctness trade-offs. +with various optional time/correctness trade-offs. For comparing files, +see also the :mod:`difflib` module. The :mod:`filecmp` module defines the following functions: Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Thu Nov 1 21:32:30 2007 @@ -41,7 +41,7 @@ top-level package (the name up till the first dot) is returned, *not* the module named by *name*. However, when a non-empty *fromlist* argument is given, the module named by *name* is returned. This is done for - compatibility with the bytecode generated for the different kinds of import + compatibility with the :term:`bytecode` generated for the different kinds of import statement; when using ``import spam.ham.eggs``, the top-level package :mod:`spam` must be placed in the importing namespace, but when using ``from spam.ham import eggs``, the ``spam.ham`` subpackage must be used to find the @@ -317,7 +317,7 @@ .. function:: enumerate(iterable) - Return an enumerate object. *iterable* must be a sequence, an iterator, or some + Return an enumerate object. *iterable* must be a sequence, an :term:`iterator`, or some other object which supports iteration. The :meth:`__next__` method of the iterator returned by :func:`enumerate` returns a tuple containing a count (from zero) and the corresponding value obtained from iterating over *iterable*. @@ -340,7 +340,7 @@ The *expression* argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the *globals* and *locals* - dictionaries as global and local name space. If the *globals* dictionary is + dictionaries as global and local namespace. If the *globals* dictionary is present and lacks '__builtins__', the current globals are copied into *globals* before *expression* is parsed. This means that *expression* normally has full access to the standard :mod:`__builtin__` module and restricted environments are @@ -408,10 +408,9 @@ Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which - supports iteration, or an iterator, If *iterable* is a string or a tuple, the - result also has that type; otherwise it is always a list. If *function* is - ``None``, the identity function is assumed, that is, all elements of - *iterable* that are false are removed. + supports iteration, or an iterator. If *function* is ``None``, the identity + function is assumed, that is, all elements of *iterable* that are false are + removed. Note that ``filter(function, iterable)`` is equivalent to the generator expression ``(item for item in iterable if function(item))`` if function is @@ -543,15 +542,15 @@ .. function:: int([x[, radix]]) Convert a string or number to an integer. If the argument is a string, it - must contain a possibly signed number of arbitrary size, - possibly embedded in whitespace. The *radix* parameter gives the base for the - conversion and may be any integer in the range [2, 36], or zero. If *radix* is - zero, the interpretation is the same as for integer literals. If *radix* is - specified and *x* is not a string, :exc:`TypeError` is raised. Otherwise, the - argument may be another integer, a floating point number or any other object - that has an :meth:`__int__` method. Conversion - of floating point numbers to integers truncates (towards zero). If no - arguments are given, returns ``0``. + must contain a possibly signed number of arbitrary size, possibly embedded in + whitespace. The *radix* parameter gives the base for the conversion (which + is 10 by default) and may be any integer in the range [2, 36], or zero. If + *radix* is zero, the interpretation is the same as for integer literals. If + *radix* is specified and *x* is not a string, :exc:`TypeError` is raised. + Otherwise, the argument may be another integer, a floating point number or + any other object that has an :meth:`__int__` method. Conversion of floating + point numbers to integers truncates (towards zero). If no arguments are + given, returns ``0``. The integer type is described in :ref:`typesnumeric`. @@ -577,7 +576,7 @@ .. function:: iter(o[, sentinel]) - Return an iterator object. The first argument is interpreted very differently + Return an :term:`iterator` object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, *o* must be a collection object which supports the iteration protocol (the :meth:`__iter__` method), or it must support the sequence protocol (the @@ -857,9 +856,9 @@ .. function:: reversed(seq) - Return a reverse iterator. *seq* must be an object which supports the sequence - protocol (the :meth:`__len__` method and the :meth:`__getitem__` method with - integer arguments starting at ``0``). + Return a reverse :term:`iterator`. *seq* must be an object which supports + the sequence protocol (the :meth:`__len__` method and the :meth:`__getitem__` + method with integer arguments starting at ``0``). .. function:: round(x[, n]) Modified: python/branches/py3k/Doc/library/glob.rst ============================================================================== --- python/branches/py3k/Doc/library/glob.rst (original) +++ python/branches/py3k/Doc/library/glob.rst Thu Nov 1 21:32:30 2007 @@ -28,8 +28,8 @@ .. function:: iglob(pathname) - Return an iterator which yields the same values as :func:`glob` without actually - storing them all simultaneously. + Return an :term:`iterator` which yields the same values as :func:`glob` + without actually storing them all simultaneously. For example, consider a directory containing only the following files: Modified: python/branches/py3k/Doc/library/heapq.rst ============================================================================== --- python/branches/py3k/Doc/library/heapq.rst (original) +++ python/branches/py3k/Doc/library/heapq.rst Thu Nov 1 21:32:30 2007 @@ -90,8 +90,8 @@ .. function:: merge(*iterables) Merge multiple sorted inputs into a single sorted output (for example, merge - timestamped entries from multiple log files). Returns an iterator over over the - sorted values. + timestamped entries from multiple log files). Returns an :term:`iterator` + over over the sorted values. Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, does not pull the data into memory all at once, and assumes that each of the input Modified: python/branches/py3k/Doc/library/inspect.rst ============================================================================== --- python/branches/py3k/Doc/library/inspect.rst (original) +++ python/branches/py3k/Doc/library/inspect.rst Thu Nov 1 21:32:30 2007 @@ -67,7 +67,7 @@ +-----------+-----------------+---------------------------+ | | __code__ | code object containing | | | | compiled function | -| | | bytecode | +| | | :term:`bytecode` | +-----------+-----------------+---------------------------+ | | __defaults__ | tuple of any default | | | | values for arguments | @@ -253,30 +253,31 @@ .. function:: ismethoddescriptor(object) - Return true if the object is a method descriptor, but not if ismethod() or - isclass() or isfunction() are true. + Return true if the object is a method descriptor, but not if :func:`ismethod` + or :func:`isclass` or :func:`isfunction` are true. - This is new as of Python 2.2, and, for example, is true of int.__add__. An - object passing this test has a __get__ attribute but not a __set__ attribute, - but beyond that the set of attributes varies. __name__ is usually sensible, and - __doc__ often is. - - Methods implemented via descriptors that also pass one of the other tests return - false from the ismethoddescriptor() test, simply because the other tests promise - more -- you can, e.g., count on having the im_func attribute (etc) when an - object passes ismethod(). + This is new as of Python 2.2, and, for example, is true of + ``int.__add__``. An object passing this test has a :attr:`__get__` attribute + but not a :attr:`__set__` attribute, but beyond that the set of attributes + varies. :attr:`__name__` is usually sensible, and :attr:`__doc__` often is. + + Methods implemented via descriptors that also pass one of the other tests + return false from the :func:`ismethoddescriptor` test, simply because the + other tests promise more -- you can, e.g., count on having the + :attr:`im_func` attribute (etc) when an object passes :func:`ismethod`. .. function:: isdatadescriptor(object) Return true if the object is a data descriptor. - Data descriptors have both a __get__ and a __set__ attribute. Examples are - properties (defined in Python), getsets, and members. The latter two are - defined in C and there are more specific tests available for those types, which - is robust across Python implementations. Typically, data descriptors will also - have __name__ and __doc__ attributes (properties, getsets, and members have both - of these attributes), but this is not guaranteed. + Data descriptors have both a :attr:`__get__` and a :attr:`__set__` attribute. + Examples are properties (defined in Python), getsets, and members. The + latter two are defined in C and there are more specific tests available for + those types, which is robust across Python implementations. Typically, data + descriptors will also have :attr:`__name__` and :attr:`__doc__` attributes + (properties, getsets, and members have both of these attributes), but this is + not guaranteed. .. function:: isgetsetdescriptor(object) @@ -293,8 +294,8 @@ Return true if the object is a member descriptor. Member descriptors are attributes defined in extension modules via - ``PyMemberDef`` structures. For Python implementations without such types, this - method will always return ``False``. + ``PyMemberDef`` structures. For Python implementations without such types, + this method will always return ``False``. .. _inspect-source: Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Thu Nov 1 21:32:30 2007 @@ -8,7 +8,7 @@ .. sectionauthor:: Raymond Hettinger -This module implements a number of iterator building blocks inspired by +This module implements a number of :term:`iterator` building blocks inspired by constructs from the Haskell and SML programming languages. Each has been recast in a form suitable for Python. @@ -77,19 +77,15 @@ .. function:: count([n]) Make an iterator that returns consecutive integers starting with *n*. If not - specified *n* defaults to zero. Does not currently support python long - integers. Often used as an argument to :func:`imap` to generate consecutive - data points. Also, used with :func:`izip` to add sequence numbers. Equivalent - to:: + specified *n* defaults to zero. Often used as an argument to :func:`imap` to + generate consecutive data points. Also, used with :func:`izip` to add sequence + numbers. Equivalent to:: def count(n=0): while True: yield n n += 1 - Note, :func:`count` does not check for overflow and will return negative numbers - after exceeding ``sys.maxint``. This behavior may change in the future. - .. function:: cycle(iterable) @@ -451,8 +447,8 @@ rather than bringing the whole iterable into memory all at once. Code volume is kept small by linking the tools together in a functional style which helps eliminate temporary variables. High speed is retained by preferring -"vectorized" building blocks over the use of for-loops and generators which -incur interpreter overhead. :: +"vectorized" building blocks over the use of for-loops and :term:`generator`\s +which incur interpreter overhead. :: def take(n, seq): return list(islice(seq, n)) Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Thu Nov 1 21:32:30 2007 @@ -20,7 +20,7 @@ Logging is performed by calling methods on instances of the :class:`Logger` class (hereafter called :dfn:`loggers`). Each instance has a name, and they are -conceptually arranged in a name space hierarchy using dots (periods) as +conceptually arranged in a namespace hierarchy using dots (periods) as separators. For example, a logger named "scan" is the parent of loggers "scan.text", "scan.html" and "scan.pdf". Logger names can be anything you want, and indicate the area of an application in which a logged message originates. @@ -430,7 +430,7 @@ FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s" logging.basicConfig(format=FORMAT) - dict = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' } + d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' } logger = logging.getLogger("tcpserver") logger.warning("Protocol problem: %s", "connection reset", extra=d) Modified: python/branches/py3k/Doc/library/mailbox.rst ============================================================================== --- python/branches/py3k/Doc/library/mailbox.rst (original) +++ python/branches/py3k/Doc/library/mailbox.rst Thu Nov 1 21:32:30 2007 @@ -805,7 +805,7 @@ A message is typically moved from :file:`new` to :file:`cur` after its mailbox has been accessed, whether or not the message is has been read. A message - ``msg`` has been read if ``"S" not in msg.get_flags()`` is ``True``. + ``msg`` has been read if ``"S" in msg.get_flags()`` is ``True``. .. method:: MaildirMessage.set_subdir(subdir) Modified: python/branches/py3k/Doc/library/marshal.rst ============================================================================== --- python/branches/py3k/Doc/library/marshal.rst (original) +++ python/branches/py3k/Doc/library/marshal.rst Thu Nov 1 21:32:30 2007 @@ -25,7 +25,9 @@ writing the "pseudo-compiled" code for Python modules of :file:`.pyc` files. Therefore, the Python maintainers reserve the right to modify the marshal format in backward incompatible ways should the need arise. If you're serializing and -de-serializing Python objects, use the :mod:`pickle` module instead. +de-serializing Python objects, use the :mod:`pickle` module instead -- the +performance is comparable, version independence is guaranteed, and pickle +supports a substantially wider range of objects than marshal. .. warning:: @@ -36,13 +38,19 @@ 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, long -integers, floating point numbers, strings, Unicode objects, tuples, lists, +integers, floating point numbers, strings, Unicode objects, 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 (they will cause infinite loops). .. warning:: + + Some unsupported types such as subclasses of builtins will appear to marshal + and unmarshal correctly, but in fact, their type will change and the + additional subclass functionality and instance attributes will be lost. + +.. warning:: On machines where C's ``long int`` type has more than 32 bits (such as the DEC Alpha), it is possible to create plain Python integers that are longer Modified: python/branches/py3k/Doc/library/mmap.rst ============================================================================== --- python/branches/py3k/Doc/library/mmap.rst (original) +++ python/branches/py3k/Doc/library/mmap.rst Thu Nov 1 21:32:30 2007 @@ -38,7 +38,7 @@ To map anonymous memory, -1 should be passed as the fileno along with the length. -.. function:: mmap(fileno, length[, tagname[, access]]) +.. function:: mmap(fileno, length[, tagname[, access[, offset]]]) **(Windows version)** Maps *length* bytes from the file specified by the file handle *fileno*, and returns a mmap object. If *length* is larger than the @@ -54,8 +54,12 @@ the mapping is created without a name. Avoiding the use of the tag parameter will assist in keeping your code portable between Unix and Windows. + *offset* may be specified as a non-negative integer offset. mmap references will + be relative to the offset from the beginning of the file. *offset* defaults to 0. + *offset* must be a multiple of the ALLOCATIONGRANULARITY. -.. function:: mmap(fileno, length[, flags[, prot[, access]]]) + +.. function:: mmap(fileno, length[, flags[, prot[, access[, offset]]]]) :noindex: **(Unix version)** Maps *length* bytes from the file specified by the file @@ -77,6 +81,10 @@ parameter. It is an error to specify both *flags*, *prot* and *access*. See the description of *access* above for information on how to use this parameter. + *offset* may be specified as a non-negative integer offset. mmap references will + be relative to the offset from the beginning of the file. *offset* defaults to 0. + *offset* must be a multiple of the PAGESIZE or ALLOCATIONGRANULARITY. + Memory-mapped file objects support the following methods: @@ -169,3 +177,4 @@ created with :const:`ACCESS_READ`, then writing to it will throw a :exc:`TypeError` exception. + Modified: python/branches/py3k/Doc/library/optparse.rst ============================================================================== --- python/branches/py3k/Doc/library/optparse.rst (original) +++ python/branches/py3k/Doc/library/optparse.rst Thu Nov 1 21:32:30 2007 @@ -950,7 +950,7 @@ * ``append_const`` [required: ``const``; relevant: :attr:`dest`] Like ``store_const``, but the value ``const`` is appended to :attr:`dest`; as - with ``append``, :attr:`dest` defaults to ``None``, and an an empty list is + with ``append``, :attr:`dest` defaults to ``None``, and an empty list is automatically created the first time the option is encountered. * ``count`` [relevant: :attr:`dest`] @@ -1116,7 +1116,7 @@ * if the number starts with ``0``, it is parsed as an octal number -* if the number starts with ``0b``, is is parsed as a binary number +* if the number starts with ``0b``, it is parsed as a binary number * otherwise, the number is parsed as a decimal number 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 Thu Nov 1 21:32:30 2007 @@ -279,8 +279,8 @@ .. note:: - The newer :func:`os.walk` generator supplies similar functionality and can be - easier to use. + The newer :func:`os.walk` :term:`generator` supplies similar functionality + and can be easier to use. .. data:: supports_unicode_filenames Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Thu Nov 1 21:32:30 2007 @@ -107,9 +107,14 @@ passed to the appropriate process-creation functions to cause child processes to use a modified environment. - If the platform supports the :func:`unsetenv` function, you can delete items in + If the platform supports the :func:`unsetenv` function, you can delete items in this mapping to unset environment variables. :func:`unsetenv` will be called - automatically when an item is deleted from ``os.environ``. + automatically when an item is deleted from ``os.environ``, and when + one of the :meth:`pop` or :meth:`clear` methods is called. + + .. versionchanged:: 2.6 + Also unset environment variables when calling :meth:`os.environ.clear` + and :meth:`os.environ.pop`. .. function:: chdir(path) @@ -541,7 +546,7 @@ .. function:: ttyname(fd) Return a string which specifies the terminal device associated with - file-descriptor *fd*. If *fd* is not associated with a terminal device, an + file descriptor *fd*. If *fd* is not associated with a terminal device, an exception is raised. Availability:Macintosh, Unix. Modified: python/branches/py3k/Doc/library/parser.rst ============================================================================== --- python/branches/py3k/Doc/library/parser.rst (original) +++ python/branches/py3k/Doc/library/parser.rst Thu Nov 1 21:32:30 2007 @@ -321,7 +321,7 @@ .. index:: builtin: compile The parser modules allows operations to be performed on the parse tree of Python -source code before the bytecode is generated, and provides for inspection of the +source code before the :term:`bytecode` is generated, and provides for inspection of the parse tree for information gathering purposes. Two examples are presented. The simple example demonstrates emulation of the :func:`compile` built-in function and the complex example shows the use of a parse tree for information discovery. Modified: python/branches/py3k/Doc/library/pdb.rst ============================================================================== --- python/branches/py3k/Doc/library/pdb.rst (original) +++ python/branches/py3k/Doc/library/pdb.rst Thu Nov 1 21:32:30 2007 @@ -239,7 +239,7 @@ Specifying any command resuming execution (currently continue, step, next, return, jump, quit and their abbreviations) terminates the command list (as if that command was immediately followed by end). This is because any time you - resume execution (even with a simple next or step), you may encounter?? another + resume execution (even with a simple next or step), you may encounter another breakpoint--which could have its own command list, leading to ambiguities about which list to execute. @@ -323,7 +323,7 @@ (Pdb) run [*args* ...] - Restart the debugged python program. If an argument is supplied, it is splitted + Restart the debugged python program. If an argument is supplied, it is split with "shlex" and the result is used as the new sys.argv. History, breakpoints, actions and debugger options are preserved. "restart" is an alias for "run". Modified: python/branches/py3k/Doc/library/pickle.rst ============================================================================== --- python/branches/py3k/Doc/library/pickle.rst (original) +++ python/branches/py3k/Doc/library/pickle.rst Thu Nov 1 21:32:30 2007 @@ -122,7 +122,7 @@ earlier versions of Python. * Protocol version 2 was introduced in Python 2.3. It provides much more - efficient pickling of new-style classes. + efficient pickling of :term:`new-style class`\es. Refer to :pep:`307` for more information. @@ -418,8 +418,8 @@ protocol 2. Implementing this method is needed if the type establishes some internal invariants when the instance is created, or if the memory allocation is affected by the values passed to the :meth:`__new__` method for the type (as it -is for tuples and strings). Instances of a new-style type :class:`C` are -created using :: +is for tuples and strings). Instances of a :term:`new-style class` :class:`C` +are created using :: obj = C.__new__(C, *args) @@ -447,8 +447,8 @@ .. warning:: - For new-style classes, if :meth:`__getstate__` returns a false value, the - :meth:`__setstate__` method will not be called. + For :term:`new-style class`\es, if :meth:`__getstate__` returns a false + value, the :meth:`__setstate__` method will not be called. Pickling and unpickling extension types Modified: python/branches/py3k/Doc/library/pickletools.rst ============================================================================== --- python/branches/py3k/Doc/library/pickletools.rst (original) +++ python/branches/py3k/Doc/library/pickletools.rst Thu Nov 1 21:32:30 2007 @@ -27,9 +27,9 @@ .. function:: genops(pickle) - Provides an iterator over all of the opcodes in a pickle, returning a sequence - of ``(opcode, arg, pos)`` triples. *opcode* is an instance of an - :class:`OpcodeInfo` class; *arg* is the decoded value, as a Python object, of - the opcode's argument; *pos* is the position at which this opcode is located. + Provides an :term:`iterator` over all of the opcodes in a pickle, returning a + sequence of ``(opcode, arg, pos)`` triples. *opcode* is an instance of an + :class:`OpcodeInfo` class; *arg* is the decoded value, as a Python object, of + the opcode's argument; *pos* is the position at which this opcode is located. *pickle* can be a string or a file-like object. Modified: python/branches/py3k/Doc/library/pty.rst ============================================================================== --- python/branches/py3k/Doc/library/pty.rst (original) +++ python/branches/py3k/Doc/library/pty.rst Thu Nov 1 21:32:30 2007 @@ -43,6 +43,6 @@ reading from the controlling terminal. The functions *master_read* and *stdin_read* should be functions which read from - a file-descriptor. The defaults try to read 1024 bytes each time they are + a file descriptor. The defaults try to read 1024 bytes each time they are called. Modified: python/branches/py3k/Doc/library/pyclbr.rst ============================================================================== --- python/branches/py3k/Doc/library/pyclbr.rst (original) +++ python/branches/py3k/Doc/library/pyclbr.rst Thu Nov 1 21:32:30 2007 @@ -19,10 +19,10 @@ .. function:: readmodule(module[, path]) Read a module and return a dictionary mapping class names to class descriptor - objects. The parameter *module* should be the name of a module as a string; it - may be the name of a module within a package. The *path* parameter should be a - sequence, and is used to augment the value of ``sys.path``, which is used to - locate module source code. + objects. The parameter *module* should be the name of a module as a string; + it may be the name of a module within a package. The *path* parameter should + be a sequence, and is used to augment the value of ``sys.path``, which is + used to locate module source code. .. % The 'inpackage' parameter appears to be for internal use only.... Modified: python/branches/py3k/Doc/library/re.rst ============================================================================== --- python/branches/py3k/Doc/library/re.rst (original) +++ python/branches/py3k/Doc/library/re.rst Thu Nov 1 21:32:30 2007 @@ -28,14 +28,14 @@ patterns; backslashes are not handled in any special way in a string literal prefixed with ``'r'``. So ``r"\n"`` is a two-character string containing ``'\'`` and ``'n'``, while ``"\n"`` is a one-character string containing a -newline. Usually patterns will be expressed in Python code using this raw string -notation. +newline. Usually patterns will be expressed in Python code using this raw +string notation. .. seealso:: Mastering Regular Expressions Book on regular expressions by Jeffrey Friedl, published by O'Reilly. The - second edition of the book no longer covers Python at all, but the first + second edition of the book no longer covers Python at all, but the first edition covered writing good regular expression patterns in great detail. @@ -427,8 +427,8 @@ .. function:: compile(pattern[, flags]) - Compile a regular expression pattern into a regular expression object, which can - be used for matching using its :func:`match` and :func:`search` methods, + Compile a regular expression pattern into a regular expression object, which + can be used for matching using its :func:`match` and :func:`search` methods, described below. The expression's behaviour can be modified by specifying a *flags* value. @@ -444,8 +444,8 @@ result = re.match(pat, str) - but the version using :func:`compile` is more efficient when the expression will - be used several times in a single program. + but the version using :func:`compile` is more efficient when the expression + will be used several times in a single program. .. % (The compiled version of the last pattern passed to .. % \function{re.match()} or \function{re.search()} is cached, so @@ -463,8 +463,8 @@ .. data:: L LOCALE - Make ``\w``, ``\W``, ``\b``, ``\B``, ``\s`` and ``\S`` dependent on the current - locale. + Make ``\w``, ``\W``, ``\b``, ``\B``, ``\s`` and ``\S`` dependent on the + current locale. .. data:: M @@ -556,17 +556,18 @@ .. function:: findall(pattern, string[, flags]) - Return a list of all non-overlapping matches of *pattern* in *string*. If one - or more groups are present in the pattern, return a list of groups; this will be - a list of tuples if the pattern has more than one group. Empty matches are - included in the result unless they touch the beginning of another match. + Return all non-overlapping matches of *pattern* in *string*, as a list of + strings. If one or more groups are present in the pattern, return a list of + groups; this will be a list of tuples if the pattern has more than one group. + Empty matches are included in the result unless they touch the beginning of + another match. .. function:: finditer(pattern, string[, flags]) - Return an iterator over all non-overlapping matches for the RE *pattern* in - *string*. For each match, the iterator returns a match object. Empty matches - are included in the result unless they touch the beginning of another match. + Return an :term:`iterator` yielding :class:`MatchObject` instances over all + non-overlapping matches for the RE *pattern* in *string*. Empty matches are + included in the result unless they touch the beginning of another match. .. function:: sub(pattern, repl, string[, count]) @@ -729,7 +730,9 @@ Match Objects ------------- -:class:`MatchObject` instances support the following methods and attributes: +Match objects always have a boolean value of :const:`True`, so that you can test +whether e.g. :func:`match` resulted in a match with a simple if statement. They +support the following methods and attributes: .. method:: MatchObject.expand(template) Modified: python/branches/py3k/Doc/library/sqlite3.rst ============================================================================== --- python/branches/py3k/Doc/library/sqlite3.rst (original) +++ python/branches/py3k/Doc/library/sqlite3.rst Thu Nov 1 21:32:30 2007 @@ -69,10 +69,10 @@ ): c.execute('insert into stocks values (?,?,?,?,?)', t) -To retrieve data after executing a SELECT statement, you can either treat the -cursor as an iterator, call the cursor's :meth:`fetchone` method to retrieve a -single matching row, or call :meth:`fetchall` to get a list of the matching -rows. +To retrieve data after executing a SELECT statement, you can either treat the +cursor as an :term:`iterator`, call the cursor's :meth:`fetchone` method to +retrieve a single matching row, or call :meth:`fetchall` to get a list of the +matching rows. This example uses the iterator form:: @@ -408,13 +408,13 @@ .. method:: Cursor.executemany(sql, seq_of_parameters) - Executes a SQL command against all parameter sequences or mappings found in the - sequence *sql*. The :mod:`sqlite3` module also allows using an iterator yielding - parameters instead of a sequence. + Executes a SQL command against all parameter sequences or mappings found in + the sequence *sql*. The :mod:`sqlite3` module also allows using an + :term:`iterator` yielding parameters instead of a sequence. .. literalinclude:: ../includes/sqlite3/executemany_1.py - Here's a shorter example using a generator: + Here's a shorter example using a :term:`generator`: .. literalinclude:: ../includes/sqlite3/executemany_2.py Modified: python/branches/py3k/Doc/library/ssl.rst ============================================================================== --- python/branches/py3k/Doc/library/ssl.rst (original) +++ python/branches/py3k/Doc/library/ssl.rst Thu Nov 1 21:32:30 2007 @@ -223,7 +223,7 @@ .. data:: PROTOCOL_TLSv1 - Selects SSL version 2 as the channel encryption protocol. This is + Selects TLS version 1 as the channel encryption protocol. This is the most modern version, and probably the best choice for maximum protection, if both sides can speak it. Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Thu Nov 1 21:32:30 2007 @@ -449,10 +449,10 @@ continue to do so on subsequent calls. Implementations that do not obey this property are deemed broken. -Python's generators provide a convenient way to implement the iterator protocol. -If a container object's :meth:`__iter__` method is implemented as a generator, -it will automatically return an iterator object (technically, a generator -object) supplying the :meth:`__iter__` and :meth:`__next__` methods. +Python's :term:`generator`\s provide a convenient way to implement the iterator +protocol. If a container object's :meth:`__iter__` method is implemented as a +generator, it will automatically return an iterator object (technically, a +generator object) supplying the :meth:`__iter__` and :meth:`__next__` methods. .. _typesseq: @@ -655,9 +655,9 @@ .. method:: str.count(sub[, start[, end]]) - Return the number of occurrences of substring *sub* in string S\ - ``[start:end]``. Optional arguments *start* and *end* are interpreted as in - slice notation. + Return the number of occurrences of substring *sub* in the range [*start*, + *end*]. Optional arguments *start* and *end* are interpreted as in slice + notation. .. method:: str.encode([encoding[, errors]]) @@ -682,8 +682,11 @@ .. method:: str.expandtabs([tabsize]) - Return a copy of the string where all tab characters are expanded using spaces. - If *tabsize* is not given, a tab size of ``8`` characters is assumed. + Return a copy of the string where all tab characters are replaced by one or + more spaces, depending on the current column and the given tab size. The + column number is reset to zero after each newline occurring in the string. + If *tabsize* is not given, a tab size of ``8`` characters is assumed. This + doesn't understand other non-printing characters or escape sequences. .. method:: str.find(sub[, start[, end]]) @@ -869,19 +872,23 @@ string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most ``maxsplit+1`` elements). If *maxsplit* is not specified, then there is no limit on the number of splits (all possible - splits are made). Consecutive delimiters are not grouped together and are + splits are made). + + If *sep is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns ``['1', '', '2']``). The *sep* argument may consist of multiple characters - (for example, ``'1, 2, 3'.split(', ')`` returns ``['1', '2', '3']``). + (for example, ``'1<>2<>3'.split('<>')`` returns ``['1', '2', '3']``). Splitting an empty string with a specified separator returns ``['']``. If *sep* is not specified or is ``None``, a different splitting algorithm is - applied. First, whitespace characters (spaces, tabs, newlines, returns, and - formfeeds) are stripped from both ends. Then, words are separated by arbitrary - length strings of whitespace characters. Consecutive whitespace delimiters are - treated as a single delimiter (``'1 2 3'.split()`` returns ``['1', '2', - '3']``). Splitting an empty string or a string consisting of just whitespace - returns an empty list. + applied: runs of consecutive whitespace are regarded as a single separator, + and the result will contain no empty strings at the start or end if the + string has leading or trailing whitespace. Consequently, splitting an empty + string or a string consisting of just whitespace with a ``None`` separator + returns ``[]``. + + For example, ``' 1 2 3 '.split()`` returns ``['1', '2', '3']``, and + ``' 1 2 3 '.split(None, 1)`` returns ``['1', '2 3 ']``. .. method:: str.splitlines([keepends]) @@ -947,8 +954,10 @@ .. method:: str.zfill(width) - Return the numeric string left filled with zeros in a string of length *width*. - The original string is returned if *width* is less than ``len(s)``. + Return the numeric string left filled with zeros in a string of length + *width*. A sign prefix is handled correctly. The original string is + returned if *width* is less than ``len(s)``. + .. _old-string-formatting: @@ -1865,8 +1874,7 @@ .. method:: file.fileno() .. index:: - single: file descriptor - single: descriptor, file + pair: file; descriptor module: fcntl Return the integer "file descriptor" that is used by the underlying @@ -2091,7 +2099,7 @@ .. method:: contextmanager.__exit__(exc_type, exc_val, exc_tb) - Exit the runtime context and return a Boolean flag indicating if any expection + Exit the runtime context and return a Boolean flag indicating if any exception that occurred should be suppressed. If an exception occurred while executing the body of the :keyword:`with` statement, the arguments contain the exception type, value and traceback information. Otherwise, all three arguments are ``None``. @@ -2115,7 +2123,7 @@ their implementation of the context management protocol. See the :mod:`contextlib` module for some examples. -Python's generators and the ``contextlib.contextfactory`` decorator provide a +Python's :term:`generator`\s and the ``contextlib.contextfactory`` decorator provide a convenient way to implement these protocols. If a generator function is decorated with the ``contextlib.contextfactory`` decorator, it will return a context manager implementing the necessary :meth:`__enter__` and Modified: python/branches/py3k/Doc/library/tokenize.rst ============================================================================== --- python/branches/py3k/Doc/library/tokenize.rst (original) +++ python/branches/py3k/Doc/library/tokenize.rst Thu Nov 1 21:32:30 2007 @@ -13,7 +13,7 @@ well, making it useful for implementing "pretty-printers," including colorizers for on-screen displays. -The primary entry point is a generator: +The primary entry point is a :term:`generator`: .. function:: generate_tokens(readline) Modified: python/branches/py3k/Doc/library/types.rst ============================================================================== --- python/branches/py3k/Doc/library/types.rst (original) +++ python/branches/py3k/Doc/library/types.rst Thu Nov 1 21:32:30 2007 @@ -113,8 +113,8 @@ .. data:: GeneratorType - The type of generator-iterator objects, produced by calling a generator - function. + The type of :term:`generator`-iterator objects, produced by calling a + generator function. .. data:: CodeType Modified: python/branches/py3k/Doc/library/urllib.rst ============================================================================== --- python/branches/py3k/Doc/library/urllib.rst (original) +++ python/branches/py3k/Doc/library/urllib.rst Thu Nov 1 21:32:30 2007 @@ -29,7 +29,7 @@ :exc:`IOError` exception is raised. If all went well, a file-like object is returned. This supports the following methods: :meth:`read`, :meth:`readline`, :meth:`readlines`, :meth:`fileno`, :meth:`close`, :meth:`info` and - :meth:`geturl`. It also has proper support for the iterator protocol. One + :meth:`geturl`. It also has proper support for the :term:`iterator` protocol. One caveat: the :meth:`read` method, if the size argument is omitted or negative, may not read until the end of the data stream; there is no good way to determine that the entire stream from a socket has been read in the general case. Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Thu Nov 1 21:32:30 2007 @@ -51,9 +51,9 @@ Not all objects can be weakly referenced; those objects which can include class instances, functions written in Python (but not in C), methods (both bound and -unbound), sets, frozensets, file objects, generators, type objects, DBcursor -objects from the :mod:`bsddb` module, sockets, arrays, deques, and regular -expression pattern objects. +unbound), sets, frozensets, file objects, :term:`generator`\s, type objects, +:class:`DBcursor` objects from the :mod:`bsddb` module, sockets, arrays, deques, +and regular expression pattern objects. Several builtin types such as :class:`list` and :class:`dict` do not directly support weak references but can add support through subclassing:: @@ -146,7 +146,7 @@ .. method:: WeakKeyDictionary.iterkeyrefs() - Return an iterator that yields the weak references to the keys. + Return an :term:`iterator` that yields the weak references to the keys. .. method:: WeakKeyDictionary.keyrefs() @@ -174,7 +174,7 @@ .. method:: WeakValueDictionary.itervaluerefs() - Return an iterator that yields the weak references to the values. + Return an :term:`iterator` that yields the weak references to the values. .. method:: WeakValueDictionary.valuerefs() Modified: python/branches/py3k/Doc/library/wsgiref.rst ============================================================================== --- python/branches/py3k/Doc/library/wsgiref.rst (original) +++ python/branches/py3k/Doc/library/wsgiref.rst Thu Nov 1 21:32:30 2007 @@ -124,7 +124,7 @@ .. class:: FileWrapper(filelike [, blksize=8192]) - A wrapper to convert a file-like object to an iterator. The resulting objects + A wrapper to convert a file-like object to an :term:`iterator`. The resulting objects support both :meth:`__getitem__` and :meth:`__iter__` iteration styles, for compatibility with Python 2.1 and Jython. As the object is iterated over, the optional *blksize* parameter will be repeatedly passed to the *filelike* 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 Thu Nov 1 21:32:30 2007 @@ -87,7 +87,7 @@ Parses an XML section into an element tree incrementally, and reports what's going on to the user. *source* is a filename or file object containing XML data. *events* is a list of events to report back. If omitted, only "end" events are - reported. Returns an iterator providing ``(event, elem)`` pairs. + reported. Returns an :term:`iterator` providing ``(event, elem)`` pairs. .. function:: parse(source[, parser]) @@ -316,7 +316,7 @@ .. method:: ElementTree.findall(path) Finds all toplevel elements with the given tag. Same as getroot().findall(path). - *path* is the element to look for. Returns a list or iterator containing all + *path* is the element to look for. Returns a list or :term:`iterator` containing all matching elements, in document order. Modified: python/branches/py3k/Doc/library/xmlrpclib.rst ============================================================================== --- python/branches/py3k/Doc/library/xmlrpclib.rst (original) +++ python/branches/py3k/Doc/library/xmlrpclib.rst Thu Nov 1 21:32:30 2007 @@ -314,7 +314,8 @@ return ``None``, and only store the call name and parameters in the :class:`MultiCall` object. Calling the object itself causes all stored calls to be transmitted as a single ``system.multicall`` request. The result of this call - is a generator; iterating over this generator yields the individual results. + is a :term:`generator`; iterating over this generator yields the individual + results. A usage example of this class is :: 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 Thu Nov 1 21:32:30 2007 @@ -553,7 +553,7 @@ class and instance variables are accessible through the notation "``self.name``", and an instance variable hides a class variable with the same name when accessed in this way. Class variables with immutable values can be -used as defaults for instance variables. Descriptors can be used to create +used as defaults for instance variables. Descriptors can be used to create instance variables with different implementation details. .. XXX add link to descriptor docs above Modified: python/branches/py3k/Doc/reference/datamodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/datamodel.rst (original) +++ python/branches/py3k/Doc/reference/datamodel.rst Thu Nov 1 21:32:30 2007 @@ -852,7 +852,7 @@ single: bytecode object: code - Code objects represent *byte-compiled* executable Python code, or *bytecode*. + Code objects represent *byte-compiled* executable Python code, or :term:`bytecode`. The difference between a code object and a function object is that the function object contains an explicit reference to the function's globals (the module in which it was defined), while a code object contains no context; also the default @@ -873,7 +873,7 @@ used by the bytecode; :attr:`co_names` is a tuple containing the names used by the bytecode; :attr:`co_filename` is the filename from which the code was compiled; :attr:`co_firstlineno` is the first line number of the function; - :attr:`co_lnotab` is a string encoding the mapping from byte code offsets to + :attr:`co_lnotab` is a string encoding the mapping from bytecode offsets to line numbers (for details see the source code of the interpreter); :attr:`co_stacksize` is the required stack size (including local variables); :attr:`co_flags` is an integer encoding a number of flags for the interpreter. @@ -1039,6 +1039,7 @@ .. % ========================================================================= +.. _newstyle: .. _specialnames: Modified: python/branches/py3k/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k/Doc/reference/expressions.rst (original) +++ python/branches/py3k/Doc/reference/expressions.rst Thu Nov 1 21:32:30 2007 @@ -1273,7 +1273,9 @@ .. [#] While comparisons between strings make sense at the byte level, they may be counter-intuitive to users. For example, the strings ``"\u00C7"`` and ``"\u0327\u0043"`` compare differently, even though they both represent the - same unicode character (LATIN CAPTITAL LETTER C WITH CEDILLA). + same unicode character (LATIN CAPTITAL LETTER C WITH CEDILLA). To compare + strings in a human recognizable way, compare using + :func:`unicodedata.normalize`. .. [#] The implementation computes this efficiently, without constructing lists or sorting. Modified: python/branches/py3k/Doc/tutorial/classes.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/classes.rst (original) +++ python/branches/py3k/Doc/tutorial/classes.rst Thu Nov 1 21:32:30 2007 @@ -497,7 +497,7 @@ single-inheritance languages. Dynamic ordering is necessary because all cases of multiple inheritance exhibit -one or more diamond relationships (where one at least one of the parent classes +one or more diamond relationships (where at least one of the parent classes can be accessed through multiple paths from the bottommost class). For example, all classes inherit from :class:`object`, so any case of multiple inheritance provides more than one path to reach :class:`object`. To keep the base classes @@ -707,12 +707,12 @@ Generators ========== -Generators are a simple and powerful tool for creating iterators. They are -written like regular functions but use the :keyword:`yield` statement whenever -they want to return data. Each time :func:`next` is called on it, the generator -resumes where it left-off (it remembers all the data values and which statement -was last executed). An example shows that generators can be trivially easy to -create:: +:term:`Generator`\s are a simple and powerful tool for creating iterators. They +are written like regular functions but use the :keyword:`yield` statement +whenever they want to return data. Each time :func:`next` is called on it, the +generator resumes where it left-off (it remembers all the data values and which +statement was last executed). An example shows that generators can be trivially +easy to create:: def reverse(data): for index in range(len(data)-1, -1, -1): Modified: python/branches/py3k/Doc/tutorial/controlflow.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/controlflow.rst (original) +++ python/branches/py3k/Doc/tutorial/controlflow.rst Thu Nov 1 21:32:30 2007 @@ -266,8 +266,9 @@ technically speaking, procedures do return a value, albeit a rather boring one. This value is called ``None`` (it's a built-in name). Writing the value ``None`` is normally suppressed by the interpreter if it would be the only value -written. You can see it if you really want to:: +written. You can see it if you really want to using :keyword:`print`:: + >>> fib(0) >>> print(fib(0)) None Modified: python/branches/py3k/Doc/tutorial/interactive.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/interactive.rst (original) +++ python/branches/py3k/Doc/tutorial/interactive.rst Thu Nov 1 21:32:30 2007 @@ -123,7 +123,7 @@ # bound to the Esc key by default (you can change it - see readline docs). # # Store the file in ~/.pystartup, and set an environment variable to point - # to it: "export PYTHONSTARTUP=/max/home/itamar/.pystartup" in bash. + # to it: "export PYTHONSTARTUP=/home/user/.pystartup" in bash. # # Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the # full path to your home directory. Modified: python/branches/py3k/Doc/tutorial/modules.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/modules.rst (original) +++ python/branches/py3k/Doc/tutorial/modules.rst Thu Nov 1 21:32:30 2007 @@ -191,8 +191,8 @@ * When the Python interpreter is invoked with the :option:`-O` flag, optimized code is generated and stored in :file:`.pyo` files. The optimizer currently doesn't help much; it only removes :keyword:`assert` statements. When - :option:`-O` is used, *all* bytecode is optimized; ``.pyc`` files are ignored - and ``.py`` files are compiled to optimized bytecode. + :option:`-O` is used, *all* :term:`bytecode` is optimized; ``.pyc`` files are + ignored and ``.py`` files are compiled to optimized bytecode. * Passing two :option:`-O` flags to the Python interpreter (:option:`-OO`) will cause the bytecode compiler to perform optimizations that could in some rare 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 Thu Nov 1 21:32:30 2007 @@ -67,7 +67,6 @@ .. % Large, PEP-level features and changes should be described here. .. % Should there be a new section here for 3k migration? .. % Or perhaps a more general section describing module changes/deprecation? -.. % sets module deprecated .. % ====================================================================== Python 3.0 @@ -75,7 +74,23 @@ .. % XXX add general comment about Python 3.0 features in 2.6 -.. % XXX mention -3 switch +The development cycle for Python 2.6 also saw the release of the first +alphas of Python 3.0, and the development of 3.0 has influenced +a number of features in 2.6. + +Python 3.0 is a far-ranging redesign of Python that breaks +compatibility with the 2.x series. This means that existing Python +code will need a certain amount of conversion in order to run on +Python 3.0. However, not all the changes in 3.0 necessarily break +compatibility. In cases where new features won't cause existing code +to break, they've been backported to 2.6 and are described in this +document in the appropriate place. Some of the 3.0-derived features +are: + +* A :meth:`__complex__` method for converting objects to a complex number. +* Alternate syntax for catching exceptions: ``except TypeError as exc``. +* The addition of :func:`functools.reduce` as a synonym for the built-in + :func:`reduce` function. A new command-line switch, :option:`-3`, enables warnings about features that will be removed in Python 3.0. You can run code @@ -406,11 +421,6 @@ Here are all of the changes that Python 2.6 makes to the core Python language. -* Changes to the :class:`Exception` interface - as dictated by :pep:`352` continue to be made. For 2.6, - the :attr:`message` attribute is being deprecated in favor of the - :attr:`args` attribute. - * When calling a function using the ``**`` syntax to provide keyword arguments, you are no longer required to use a Python dictionary; any mapping will now work:: @@ -426,8 +436,29 @@ .. % Patch 1686487 +* The built-in types now have improved support for extended slicing syntax, + where various combinations of ``(start, stop, step)`` are supplied. + Previously, the support was partial and certain corner cases wouldn't work. + (Implemented by Thomas Wouters.) + + .. % Revision 57619 + +* C functions and methods that use + :cfunc:`PyComplex_AsCComplex` will now accept arguments that + have a :meth:`__complex__` method. In particular, the functions in the + :mod:`cmath` module will now accept objects with this method. + This is a backport of a Python 3.0 change. + (Contributed by Mark Dickinson.) + + .. % Patch #1675423 + +* Changes to the :class:`Exception` interface + as dictated by :pep:`352` continue to be made. For 2.6, + the :attr:`message` attribute is being deprecated in favor of the + :attr:`args` attribute. + * The :func:`compile` built-in function now accepts keyword arguments - as well as positional parameters. (Contributed by XXX.) + as well as positional parameters. (Contributed by Thomas Wouters.) .. % Patch 1444529 @@ -483,21 +514,73 @@ by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more complete list of changes, or look through the CVS logs for all the details. -* A new data type in the :mod:`collections` module: :class:`NamedTuple(typename, +* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol + available, instead of restricting itself to protocol 1. + (Contributed by W. Barnes.) + + .. % Patch 1551443 + +* A new data type in the :mod:`collections` module: :class:`namedtuple(typename, fieldnames)` is a factory function that creates subclasses of the standard tuple whose fields are accessible by name as well as index. For example:: - var_type = collections.NamedTuple('variable', - 'id name type size') - var = var_type(1, 'frequency', 'int', 4) + >>> var_type = collections.namedtuple('variable', + ... 'id name type size') + # Names are separated by spaces or commas. + # 'id, name, type, size' would also work. + >>> var_type.__fields__ + ('id', 'name', 'type', 'size') + + >>> var = var_type(1, 'frequency', 'int', 4) + >>> print var[0], var.id # Equivalent + 1 1 + >>> print var[2], var.type # Equivalent + int int + >>> var.__asdict__() + {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'} + >>> v2 = var.__replace__('name', 'amplitude') + >>> v2 + variable(id=1, name='amplitude', type='int', size=4) + + (Contributed by Raymond Hettinger.) - print var[0], var.id # Equivalent - print var[2], var.type # Equivalent +* Another change to the :mod:`collections` module is that the + :class:`deque` type now supports an optional `maxlen` parameter; + if supplied, the deque's size will be restricted to no more + than ``maxlen`` items. Adding more items to a full deque causes + old items to be discarded. + + :: + + >>> from collections import deque + >>> dq=deque(maxlen=3) + >>> dq + deque([], maxlen=3) + >>> dq.append(1) ; dq.append(2) ; dq.append(3) + >>> dq + deque([1, 2, 3], maxlen=3) + >>> dq.append(4) + >>> dq + deque([2, 3, 4], maxlen=3) (Contributed by Raymond Hettinger.) +* The :mod:`ctypes` module now supports a :class:`c_bool` datatype + that represents the C99 ``bool`` type. (Contributed by David Remahl.) + + .. % Patch 1649190 + + The :mod:`ctypes` string, buffer and array types also have improved + support for extended slicing syntax, + where various combinations of ``(start, stop, step)`` are supplied. + (Implemented by Thomas Wouters.) + + .. % Revision 57769 + + * A new method in the :mod:`curses` module: for a window, :meth:`chgat` changes - the display characters for a certain number of characters on a single line. :: + the display characters for a certain number of characters on a single line. + :: # Boldface text starting at y=0,x=21 # and affecting the rest of the line. @@ -505,11 +588,33 @@ (Contributed by Fabian Kreutz.) +* The :mod:`decimal` module was updated to version 1.66 of + `the General Decimal Specification `__. New features + include some methods for some basic mathematical functions such as + :meth:`exp` and :meth:`log10`:: + + >>> Decimal(1).exp() + Decimal("2.718281828459045235360287471") + >>> Decimal("2.7182818").ln() + Decimal("0.9999999895305022877376682436") + >>> Decimal(1000).log10() + Decimal("3") + + (Implemented by Facundo Batista and Mark Dickinson.) + * An optional ``timeout`` parameter was added to the :class:`ftplib.FTP` class constructor as well as the :meth:`connect` method, specifying a timeout measured in seconds. (Added by Facundo Batista.) +* The :func:`reduce` built-in function is also available in the + :mod:`functools` module. In Python 3.0, the built-in is dropped and it's + only available from :mod:`functools`; currently there are no plans + to drop the built-in in the 2.x series. (Patched by + Christian Heimes.) + + .. % Patch 1739906 + * The :func:`glob.glob` function can now return Unicode filenames if a Unicode path was used and Unicode filenames are matched within the directory. @@ -548,7 +653,7 @@ .. % Patch #1490190 -* The :func:`os.walk` function now has a "followlinks" parameter. If +* The :func:`os.walk` function now has a ``followlinks`` parameter. If set to True, it will follow symlinks pointing to directories and visit the directory's contents. For backward compatibility, the parameter's default value is false. Note that the function can fall @@ -557,6 +662,12 @@ .. % Patch 1273829 +* The ``os.environ`` object's :meth:`clear` method will now unset the + environment variables using :func:`os.unsetenv` in addition to clearing + the object's keys. (Contributed by Martin Horcicka.) + + .. % Patch #1181 + * In the :mod:`os.path` module, the :func:`splitext` function has been changed to not split on leading period characters. This produces better results when operating on Unix's dot-files. @@ -574,10 +685,17 @@ On Windows, :func:`os.path.expandvars` will now expand environment variables in the form "%var%", and "~user" will be expanded into the - user's home directory path. (Contributed by XXX.) + user's home directory path. (Contributed by Josiah Carlson.) .. % Patch 957650 +* The Python debugger provided by the :mod:`pdb` module + gained a new command: "run" restarts the Python program being debugged, + and can optionally take new command-line arguments for the program. + (Contributed by Rocky Bernstein.) + + .. % Patch #1393667 + * New functions in the :mod:`posix` module: :func:`chflags` and :func:`lchflags` are wrappers for the corresponding system calls (where they're available). Constants for the flag values are defined in the :mod:`stat` module; some @@ -587,6 +705,9 @@ * The :mod:`rgbimg` module has been removed. +* The :mod:`sets` module has been deprecated; it's better to + use the built-in :class:`set` and :class:`frozenset` types. + * The :mod:`smtplib` module now supports SMTP over SSL thanks to the addition of the :class:`SMTP_SSL` class. This class supports an interface identical to the existing :class:`SMTP` class. Both @@ -701,8 +822,47 @@ (Added by Facundo Batista.) +* The XML-RPC classes :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer` + classes can now be prevented from immediately opening and binding to + their socket by passing True as the ``bind_and_activate`` + constructor parameter. This can be used to modify the instance's + :attr:`allow_reuse_address` attribute before calling the + :meth:`server_bind` and :meth:`server_activate` methods to + open the socket and begin listening for connections. + (Contributed by Peter Parente.) + + .. % Patch 1599845 + + :class:`SimpleXMLRPCServer` also has a :attr:`_send_traceback_header` + attribute; if true, the exception and formatted traceback are returned + as HTTP headers "X-Exception" and "X-Traceback". This feature is + for debugging purposes only and should not be used on production servers + because the tracebacks could possibly reveal passwords or other sensitive + information. (Contributed by Alan McIntyre as part of his + project for Google's Summer of Code 2007.) + .. % ====================================================================== -.. % whole new modules get described in \subsections here +.. % whole new modules get described in subsections here + +Improved SSL Support +-------------------------------------------------- + +Bill Janssen made extensive improvements to Python 2.6's support for +SSL. + +XXX use ssl.sslsocket - subclass of socket.socket. + +XXX Can specify if certificate is required, and obtain certificate info +by calling getpeercert method. + +XXX sslwrap() behaves like socket.ssl + +XXX Certain features require the OpenSSL package to be installed, notably + the 'openssl' binary. + +.. seealso:: + + SSL module documentation. .. % ====================================================================== @@ -712,7 +872,13 @@ Changes to Python's build process and to the C API include: -* Detailed changes are listed here. +* The BerkeleyDB module now has a C API object, available as + ``bsddb.db.api``. This object can be used by other C extensions + that wish to use the :mod:`bsddb` module for their own purposes. + (Contributed by Duncan Grisby.) + + .. % Patch 1551895 + .. % ====================================================================== @@ -737,7 +903,7 @@ Some of the more notable changes are: -* Details go here. +* Details will go here. .. % ====================================================================== @@ -748,8 +914,12 @@ This section lists previously described changes that may require changes to your code: -* The :mod:`socket` module exception :exc:`socket.error` now inherits from - :exc:`IOError`. +* The :mod:`socket` module exception :exc:`socket.error` now inherits + from :exc:`IOError`. Previously it wasn't a subclass of + :exc:`StandardError` but now it is, through :exc:`IOError`. + (Implemented by Gregory P. Smith.) + + .. % http://bugs.python.org/issue1706815 .. % ====================================================================== From python-3000-checkins at python.org Thu Nov 1 21:55:44 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Thu, 1 Nov 2007 21:55:44 +0100 (CET) Subject: [Python-3000-checkins] r58754 - python/branches/py3k/Doc/c-api/abstract.rst Message-ID: <20071101205544.096541E400D@bag.python.org> Author: georg.brandl Date: Thu Nov 1 21:55:43 2007 New Revision: 58754 Modified: python/branches/py3k/Doc/c-api/abstract.rst Log: Remove duplicate entry for PyObject_AsFileDescriptor. (Really, this time.) Modified: python/branches/py3k/Doc/c-api/abstract.rst ============================================================================== --- python/branches/py3k/Doc/c-api/abstract.rst (original) +++ python/branches/py3k/Doc/c-api/abstract.rst Thu Nov 1 21:55:43 2007 @@ -325,14 +325,6 @@ equivalent of the Python statement ``del o[key]``. -.. cfunction:: int PyObject_AsFileDescriptor(PyObject *o) - - Derives a file descriptor from a Python object. If the object is an integer or - long integer, its value is returned. If not, the object's :meth:`fileno` method - is called if it exists; the method must return an integer or long integer, which - is returned as the file descriptor value. Returns ``-1`` on failure. - - .. cfunction:: PyObject* PyObject_Dir(PyObject *o) This is equivalent to the Python expression ``dir(o)``, returning a (possibly From python-3000-checkins at python.org Thu Nov 1 21:58:09 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Thu, 1 Nov 2007 21:58:09 +0100 (CET) Subject: [Python-3000-checkins] r58755 - python/branches/py3k/Doc/using python/branches/py3k/Doc/using/cmdline.rst python/branches/py3k/Doc/using/index.rst python/branches/py3k/Doc/using/mac.rst Message-ID: <20071101205809.36ABA1E401E@bag.python.org> Author: georg.brandl Date: Thu Nov 1 21:58:08 2007 New Revision: 58755 Added: python/branches/py3k/Doc/using/ python/branches/py3k/Doc/using/cmdline.rst python/branches/py3k/Doc/using/index.rst python/branches/py3k/Doc/using/mac.rst Log: Add new directory "using". This should have been in the merge patch, but it was probably generated with "svn diff" so that new files that weren't added first weren't included. Added: python/branches/py3k/Doc/using/cmdline.rst ============================================================================== --- (empty file) +++ python/branches/py3k/Doc/using/cmdline.rst Thu Nov 1 21:58:08 2007 @@ -0,0 +1,409 @@ +.. highlightlang:: none + +Command line and environment +============================ + +The CPython interpreter scans the command line and the environment for various +settings. + +.. note:: + + Other implementation's command line schemes may differ. See + :ref:`implementations` for further resources. + + +Command line +------------ + +When invoking Python, you may specify any of these options:: + + python [-dEiOQStuUvxX?] [-c command | -m module-name | script | - ] [args] + +The most common use case is, of course, a simple invocation of a script:: + + python myscript.py + + +Interface options +~~~~~~~~~~~~~~~~~ + +The interpreter interface resembles that of the UNIX shell: + +* When called with standard input connected to a tty device, it prompts for + commands and executes them until an EOF (an end-of-file character, you can + produce that with *Ctrl-D* on UNIX or *Ctrl-Z, Enter* on Windows) is read. +* When called with a file name argument or with a file as standard input, it + reads and executes a script from that file. +* When called with ``-c command``, it executes the Python statement(s) given as + *command*. Here *command* may contain multiple statements separated by + newlines. Leading whitespace is significant in Python statements! +* When called with ``-m module-name``, the given module is searched on the + Python module path and executed as a script. + +In non-interactive mode, the entire input is parsed before it is executed. + +An interface option terminates the list of options consumed by the interpreter, +all consecutive arguments will end up in :data:`sys.argv` -- note that the first +element, subscript zero (``sys.argv[0]``), is a string reflecting the program's +source. + +.. cmdoption:: -c + + Execute the Python code in *command*. *command* can be one ore more + statements separated by newlines, with significant leading whitespace as in + normal module code. + + If this option is given, the first element of :data:`sys.argv` will be + ``"-c"``. + + +.. cmdoption:: -m + + Search :data:`sys.path` for the named module and run the corresponding module + file as if it were executed with ``python modulefile.py`` as a script. + + Since the argument is a *module* name, you must not give a file extension + (``.py``). However, the ``module-name`` does not have to be a valid Python + identifer (e.g. you can use a file name including a hyphen). + + .. note:: + + This option cannot be used with builtin modules and extension modules + written in C, since they do not have Python module files. + + If this option is given, the first element of :data:`sys.argv` will be the + full path to the module file. + + Many standard library modules contain code that is invoked on their execution + as a script. An example is the :mod:`timeit` module:: + + python -mtimeit -s 'setup here' 'benchmarked code here' + python -mtimeit -h # for details + + .. seealso:: + :func:`runpy.run_module` + The actual implementation of this feature. + + :pep:`338` -- Executing modules as scripts + + +.. describe::