From python-checkins at python.org Mon Feb 1 00:12:30 2010 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 31 Jan 2010 23:12:30 -0000 Subject: [Python-checkins] r77896 - python/branches/py3k/Lib/doctest.py Message-ID: Author: antoine.pitrou Date: Mon Feb 1 00:12:29 2010 New Revision: 77896 Log: r77895 broke doctest. Modified: python/branches/py3k/Lib/doctest.py Modified: python/branches/py3k/Lib/doctest.py ============================================================================== --- python/branches/py3k/Lib/doctest.py (original) +++ python/branches/py3k/Lib/doctest.py Mon Feb 1 00:12:29 2010 @@ -247,7 +247,8 @@ return result def truncate(self, size=None): - StringIO.truncate(self, size) + self.seek(size) + StringIO.truncate(self) # Worst-case linear-time ellipsis matching. def _ellipsis_match(want, got): From python-checkins at python.org Mon Feb 1 00:20:27 2010 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 31 Jan 2010 23:20:27 -0000 Subject: [Python-checkins] r77897 - in python/branches/release31-maint: Lib/_pyio.py Lib/doctest.py Lib/test/test_fileio.py Lib/test/test_io.py Lib/test/test_largefile.py Lib/test/test_memoryio.py Misc/ACKS Misc/NEWS Modules/_io/bytesio.c Modules/_io/fileio.c Modules/_io/iobase.c Modules/_io/stringio.c Modules/_io/textio.c Message-ID: Author: antoine.pitrou Date: Mon Feb 1 00:20:26 2010 New Revision: 77897 Log: Merged revisions 77895-77896 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r77895 | antoine.pitrou | 2010-01-31 23:47:27 +0100 (dim., 31 janv. 2010) | 12 lines Merged revisions 77890 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77890 | antoine.pitrou | 2010-01-31 23:26:04 +0100 (dim., 31 janv. 2010) | 7 lines - Issue #6939: Fix file I/O objects in the `io` module to keep the original file position when calling `truncate()`. It would previously change the file position to the given argument, which goes against the tradition of ftruncate() and other truncation APIs. Patch by Pascal Chambon. ........ ................ r77896 | antoine.pitrou | 2010-02-01 00:12:29 +0100 (lun., 01 f?vr. 2010) | 3 lines r77895 broke doctest. ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/_pyio.py python/branches/release31-maint/Lib/doctest.py python/branches/release31-maint/Lib/test/test_fileio.py python/branches/release31-maint/Lib/test/test_io.py python/branches/release31-maint/Lib/test/test_largefile.py python/branches/release31-maint/Lib/test/test_memoryio.py python/branches/release31-maint/Misc/ACKS python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/_io/bytesio.c python/branches/release31-maint/Modules/_io/fileio.c python/branches/release31-maint/Modules/_io/iobase.c python/branches/release31-maint/Modules/_io/stringio.c python/branches/release31-maint/Modules/_io/textio.c Modified: python/branches/release31-maint/Lib/_pyio.py ============================================================================== --- python/branches/release31-maint/Lib/_pyio.py (original) +++ python/branches/release31-maint/Lib/_pyio.py Mon Feb 1 00:20:26 2010 @@ -851,7 +851,7 @@ elif pos < 0: raise ValueError("negative truncate position %r" % (pos,)) del self._buffer[pos:] - return self.seek(pos) + return pos def readable(self): return True @@ -1210,8 +1210,7 @@ if pos is None: pos = self.tell() # Use seek to flush the read buffer. - self.seek(pos) - return BufferedWriter.truncate(self) + return BufferedWriter.truncate(self, pos) def read(self, n=None): if n is None: @@ -1712,8 +1711,7 @@ self.flush() if pos is None: pos = self.tell() - self.seek(pos) - return self.buffer.truncate() + return self.buffer.truncate(pos) def detach(self): if self.buffer is None: Modified: python/branches/release31-maint/Lib/doctest.py ============================================================================== --- python/branches/release31-maint/Lib/doctest.py (original) +++ python/branches/release31-maint/Lib/doctest.py Mon Feb 1 00:20:26 2010 @@ -247,7 +247,8 @@ return result def truncate(self, size=None): - StringIO.truncate(self, size) + self.seek(size) + StringIO.truncate(self) # Worst-case linear-time ellipsis matching. def _ellipsis_match(want, got): Modified: python/branches/release31-maint/Lib/test/test_fileio.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_fileio.py (original) +++ python/branches/release31-maint/Lib/test/test_fileio.py Mon Feb 1 00:20:26 2010 @@ -330,6 +330,17 @@ f.close() self.fail("no error for invalid mode: %s" % bad_mode) + def testTruncate(self): + f = _FileIO(TESTFN, 'w') + f.write(bytes(bytearray(range(10)))) + self.assertEqual(f.tell(), 10) + f.truncate(5) + self.assertEqual(f.tell(), 10) + self.assertEqual(f.seek(0, os.SEEK_END), 5) + f.truncate(15) + self.assertEqual(f.tell(), 5) + self.assertEqual(f.seek(0, os.SEEK_END), 15) + def testTruncateOnWindows(self): def bug801631(): # SF bug Modified: python/branches/release31-maint/Lib/test/test_io.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_io.py (original) +++ python/branches/release31-maint/Lib/test/test_io.py Mon Feb 1 00:20:26 2010 @@ -229,6 +229,11 @@ def write_ops(self, f): self.assertEqual(f.write(b"blah."), 5) + f.truncate(0) + self.assertEqual(f.tell(), 5) + f.seek(0) + + self.assertEqual(f.write(b"blah."), 5) self.assertEqual(f.seek(0), 0) self.assertEqual(f.write(b"Hello."), 6) self.assertEqual(f.tell(), 6) @@ -239,8 +244,9 @@ self.assertEqual(f.write(b"h"), 1) self.assertEqual(f.seek(-1, 2), 13) self.assertEqual(f.tell(), 13) + self.assertEqual(f.truncate(12), 12) - self.assertEqual(f.tell(), 12) + self.assertEqual(f.tell(), 13) self.assertRaises(TypeError, f.seek, 0.0) def read_ops(self, f, buffered=False): @@ -285,7 +291,7 @@ self.assertEqual(f.tell(), self.LARGE + 2) self.assertEqual(f.seek(0, 2), self.LARGE + 2) self.assertEqual(f.truncate(self.LARGE + 1), self.LARGE + 1) - self.assertEqual(f.tell(), self.LARGE + 1) + self.assertEqual(f.tell(), self.LARGE + 2) self.assertEqual(f.seek(0, 2), self.LARGE + 1) self.assertEqual(f.seek(-1, 2), self.LARGE) self.assertEqual(f.read(2), b"x") @@ -980,7 +986,7 @@ bufio = self.tp(raw, 8) bufio.write(b"abcdef") self.assertEqual(bufio.truncate(3), 3) - self.assertEqual(bufio.tell(), 3) + self.assertEqual(bufio.tell(), 6) with self.open(support.TESTFN, "rb", buffering=0) as f: self.assertEqual(f.read(), b"abc") @@ -1366,6 +1372,14 @@ self.assertEqual(s, b"A" + b"B" * overwrite_size + b"A" * (9 - overwrite_size)) + def test_truncate_after_read_or_write(self): + raw = self.BytesIO(b"A" * 10) + bufio = self.tp(raw, 100) + self.assertEqual(bufio.read(2), b"AA") # the read buffer gets filled + self.assertEqual(bufio.truncate(), 2) + self.assertEqual(bufio.write(b"BB"), 2) # the write buffer increases + self.assertEqual(bufio.truncate(), 4) + def test_misbehaved_io(self): BufferedReaderTest.test_misbehaved_io(self) BufferedWriterTest.test_misbehaved_io(self) Modified: python/branches/release31-maint/Lib/test/test_largefile.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_largefile.py (original) +++ python/branches/release31-maint/Lib/test/test_largefile.py Mon Feb 1 00:20:26 2010 @@ -122,14 +122,14 @@ newsize -= 1 f.seek(42) f.truncate(newsize) - self.assertEqual(f.tell(), newsize) # else wasn't truncated + self.assertEqual(f.tell(), 42) f.seek(0, 2) self.assertEqual(f.tell(), newsize) # XXX truncate(larger than true size) is ill-defined # across platform; cut it waaaaay back f.seek(0) f.truncate(1) - self.assertEqual(f.tell(), 1) # else pointer moved + self.assertEqual(f.tell(), 0) # else pointer moved f.seek(0) self.assertEqual(len(f.read()), 1) # else wasn't truncated Modified: python/branches/release31-maint/Lib/test/test_memoryio.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_memoryio.py (original) +++ python/branches/release31-maint/Lib/test/test_memoryio.py Mon Feb 1 00:20:26 2010 @@ -72,7 +72,7 @@ self.assertEqual(f.seek(0), 0) self.assertEqual(f.write(t("h")), 1) self.assertEqual(f.truncate(12), 12) - self.assertEqual(f.tell(), 12) + self.assertEqual(f.tell(), 1) def test_write(self): buf = self.buftype("hello world\n") @@ -120,7 +120,8 @@ self.assertEqual(memio.getvalue(), buf[:6]) self.assertEqual(memio.truncate(4), 4) self.assertEqual(memio.getvalue(), buf[:4]) - self.assertEqual(memio.tell(), 4) + self.assertEqual(memio.tell(), 6) + memio.seek(0, 2) memio.write(buf) self.assertEqual(memio.getvalue(), buf[:4] + buf) pos = memio.tell() Modified: python/branches/release31-maint/Misc/ACKS ============================================================================== --- python/branches/release31-maint/Misc/ACKS (original) +++ python/branches/release31-maint/Misc/ACKS Mon Feb 1 00:20:26 2010 @@ -118,6 +118,7 @@ Donn Cave Per Cederqvist Octavian Cerna +Pascal Chambon Hye-Shik Chang Jeffrey Chang Mitch Chapman Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Mon Feb 1 00:20:26 2010 @@ -76,6 +76,11 @@ Library ------- +- Issue #6939: Fix file I/O objects in the `io` module to keep the original + file position when calling `truncate()`. It would previously change the + file position to the given argument, which goes against the tradition of + ftruncate() and other truncation APIs. Patch by Pascal Chambon. + - Issue #7792: Registering non-classes to ABCs raised an obscure error. - Issue #7785: Don't accept bytes in FileIO.write(). Modified: python/branches/release31-maint/Modules/_io/bytesio.c ============================================================================== --- python/branches/release31-maint/Modules/_io/bytesio.c (original) +++ python/branches/release31-maint/Modules/_io/bytesio.c Mon Feb 1 00:20:26 2010 @@ -412,7 +412,7 @@ "truncate([size]) -> int. Truncate the file to at most size bytes.\n" "\n" "Size defaults to the current file position, as returned by tell().\n" -"Returns the new size. Imply an absolute seek to the position size."); +"The current file position is unchanged. Returns the new size.\n"); static PyObject * bytesio_truncate(bytesio *self, PyObject *args) @@ -451,7 +451,6 @@ if (resize_buffer(self, size) < 0) return NULL; } - self->pos = size; return PyLong_FromSsize_t(size); } Modified: python/branches/release31-maint/Modules/_io/fileio.c ============================================================================== --- python/branches/release31-maint/Modules/_io/fileio.c (original) +++ python/branches/release31-maint/Modules/_io/fileio.c Mon Feb 1 00:20:26 2010 @@ -761,8 +761,10 @@ static PyObject * fileio_truncate(fileio *self, PyObject *args) { - PyObject *posobj = NULL; + PyObject *posobj = NULL; /* the new size wanted by the user */ +#ifndef MS_WINDOWS Py_off_t pos; +#endif int ret; int fd; @@ -777,58 +779,86 @@ if (posobj == Py_None || posobj == NULL) { /* Get the current position. */ - posobj = portable_lseek(fd, NULL, 1); - if (posobj == NULL) + posobj = portable_lseek(fd, NULL, 1); + if (posobj == NULL) return NULL; - } - else { - /* Move to the position to be truncated. */ - posobj = portable_lseek(fd, posobj, 0); - } - if (posobj == NULL) - return NULL; - -#if defined(HAVE_LARGEFILE_SUPPORT) - pos = PyLong_AsLongLong(posobj); -#else - pos = PyLong_AsLong(posobj); -#endif - if (pos == -1 && PyErr_Occurred()) - return NULL; + } + else { + Py_INCREF(posobj); + } #ifdef MS_WINDOWS /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, so don't even try using it. */ { + PyObject *oldposobj, *tempposobj; HANDLE hFile; + + /* we save the file pointer position */ + oldposobj = portable_lseek(fd, NULL, 1); + if (oldposobj == NULL) { + Py_DECREF(posobj); + return NULL; + } + + /* we then move to the truncation position */ + tempposobj = portable_lseek(fd, posobj, 0); + if (tempposobj == NULL) { + Py_DECREF(oldposobj); + Py_DECREF(posobj); + return NULL; + } + Py_DECREF(tempposobj); /* Truncate. Note that this may grow the file! */ Py_BEGIN_ALLOW_THREADS errno = 0; hFile = (HANDLE)_get_osfhandle(fd); - ret = hFile == (HANDLE)-1; + ret = hFile == (HANDLE)-1; /* testing for INVALID_HANDLE value */ if (ret == 0) { ret = SetEndOfFile(hFile) == 0; if (ret) errno = EACCES; } Py_END_ALLOW_THREADS + + /* we restore the file pointer position in any case */ + tempposobj = portable_lseek(fd, oldposobj, 0); + Py_DECREF(oldposobj); + if (tempposobj == NULL) { + Py_DECREF(posobj); + return NULL; + } + Py_DECREF(tempposobj); } #else + +#if defined(HAVE_LARGEFILE_SUPPORT) + pos = PyLong_AsLongLong(posobj); +#else + pos = PyLong_AsLong(posobj); +#endif + if (PyErr_Occurred()){ + Py_DECREF(posobj); + return NULL; + } + Py_BEGIN_ALLOW_THREADS errno = 0; ret = ftruncate(fd, pos); Py_END_ALLOW_THREADS + #endif /* !MS_WINDOWS */ if (ret != 0) { + Py_DECREF(posobj); PyErr_SetFromErrno(PyExc_IOError); return NULL; } return posobj; } -#endif +#endif /* HAVE_FTRUNCATE */ static char * mode_string(fileio *self) Modified: python/branches/release31-maint/Modules/_io/iobase.c ============================================================================== --- python/branches/release31-maint/Modules/_io/iobase.c (original) +++ python/branches/release31-maint/Modules/_io/iobase.c Mon Feb 1 00:20:26 2010 @@ -102,8 +102,8 @@ PyDoc_STRVAR(iobase_truncate_doc, "Truncate file to size bytes.\n" "\n" - "Size defaults to the current IO position as reported by tell(). Return\n" - "the new size."); + "File pointer is left unchanged. Size defaults to the current IO\n" + "position as reported by tell(). Returns the new size."); static PyObject * iobase_truncate(PyObject *self, PyObject *args) Modified: python/branches/release31-maint/Modules/_io/stringio.c ============================================================================== --- python/branches/release31-maint/Modules/_io/stringio.c (original) +++ python/branches/release31-maint/Modules/_io/stringio.c Mon Feb 1 00:20:26 2010 @@ -350,7 +350,7 @@ "Truncate size to pos.\n" "\n" "The pos argument defaults to the current file position, as\n" - "returned by tell(). Imply an absolute seek to pos.\n" + "returned by tell(). The current file position is unchanged.\n" "Returns the new absolute position.\n"); static PyObject * @@ -390,7 +390,6 @@ return NULL; self->string_size = size; } - self->pos = size; return PyLong_FromSsize_t(size); } Modified: python/branches/release31-maint/Modules/_io/textio.c ============================================================================== --- python/branches/release31-maint/Modules/_io/textio.c (original) +++ python/branches/release31-maint/Modules/_io/textio.c Mon Feb 1 00:20:26 2010 @@ -2318,15 +2318,7 @@ return NULL; Py_DECREF(res); - if (pos != Py_None) { - res = PyObject_CallMethodObjArgs((PyObject *) self, - _PyIO_str_seek, pos, NULL); - if (res == NULL) - return NULL; - Py_DECREF(res); - } - - return PyObject_CallMethodObjArgs(self->buffer, _PyIO_str_truncate, NULL); + return PyObject_CallMethodObjArgs(self->buffer, _PyIO_str_truncate, pos, NULL); } static PyObject * From solipsis at pitrou.net Mon Feb 1 01:04:18 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 1 Feb 2010 01:04:18 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r77888): sum=0 Message-ID: <20100201000418.929E21770C@ns6635.ovh.net> py3k results for svn r77888 (hg cset c3eb2b5badd1) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflog4FHt4m', '-x', 'test_httpservers'] From python-checkins at python.org Mon Feb 1 02:15:40 2010 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 01 Feb 2010 01:15:40 -0000 Subject: [Python-checkins] r77898 - in python/trunk/Lib/lib2to3: fixes/fix_import.py fixes/fix_itertools_imports.py fixes/fix_metaclass.py fixes/fix_tuple_params.py fixes/fix_xrange.py Message-ID: Author: martin.v.loewis Date: Mon Feb 1 02:15:39 2010 New Revision: 77898 Log: Merged revisions 77855-77856,77870 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r77855 | benjamin.peterson | 2010-01-30 17:32:05 +0100 (Sa, 30 Jan 2010) | 1 line don't return node if it is not changed ........ r77856 | benjamin.peterson | 2010-01-30 17:35:29 +0100 (Sa, 30 Jan 2010) | 1 line return None to indicate no change ........ r77870 | benjamin.peterson | 2010-01-31 02:21:26 +0100 (So, 31 Jan 2010) | 1 line never return the original node given to transform() ........ Modified: python/trunk/Lib/lib2to3/ (props changed) python/trunk/Lib/lib2to3/fixes/fix_import.py python/trunk/Lib/lib2to3/fixes/fix_itertools_imports.py python/trunk/Lib/lib2to3/fixes/fix_metaclass.py python/trunk/Lib/lib2to3/fixes/fix_tuple_params.py python/trunk/Lib/lib2to3/fixes/fix_xrange.py Modified: python/trunk/Lib/lib2to3/fixes/fix_import.py ============================================================================== --- python/trunk/Lib/lib2to3/fixes/fix_import.py (original) +++ python/trunk/Lib/lib2to3/fixes/fix_import.py Mon Feb 1 02:15:39 2010 @@ -56,7 +56,6 @@ if self.probably_a_local_import(imp.value): imp.value = u"." + imp.value imp.changed() - return node else: have_local = False have_absolute = False Modified: python/trunk/Lib/lib2to3/fixes/fix_itertools_imports.py ============================================================================== --- python/trunk/Lib/lib2to3/fixes/fix_itertools_imports.py (original) +++ python/trunk/Lib/lib2to3/fixes/fix_itertools_imports.py Mon Feb 1 02:15:39 2010 @@ -49,4 +49,4 @@ p = node.prefix node = BlankLine() node.prefix = p - return node + return node Modified: python/trunk/Lib/lib2to3/fixes/fix_metaclass.py ============================================================================== --- python/trunk/Lib/lib2to3/fixes/fix_metaclass.py (original) +++ python/trunk/Lib/lib2to3/fixes/fix_metaclass.py Mon Feb 1 02:15:39 2010 @@ -150,7 +150,7 @@ def transform(self, node, results): if not has_metaclass(node): - return node + return fixup_parse_tree(node) Modified: python/trunk/Lib/lib2to3/fixes/fix_tuple_params.py ============================================================================== --- python/trunk/Lib/lib2to3/fixes/fix_tuple_params.py (original) +++ python/trunk/Lib/lib2to3/fixes/fix_tuple_params.py Mon Feb 1 02:15:39 2010 @@ -81,7 +81,7 @@ handle_tuple(arg, add_prefix=(i > 0)) if not new_lines: - return node + return # This isn't strictly necessary, but it plays nicely with other fixers. # TODO(cwinter) get rid of this when children becomes a smart list Modified: python/trunk/Lib/lib2to3/fixes/fix_xrange.py ============================================================================== --- python/trunk/Lib/lib2to3/fixes/fix_xrange.py (original) +++ python/trunk/Lib/lib2to3/fixes/fix_xrange.py Mon Feb 1 02:15:39 2010 @@ -40,7 +40,6 @@ for n in results["rest"]: list_call.append_child(n) return list_call - return node P1 = "power< func=NAME trailer< '(' node=any ')' > any* >" p1 = patcomp.compile_pattern(P1) From python-checkins at python.org Mon Feb 1 02:17:43 2010 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 01 Feb 2010 01:17:43 -0000 Subject: [Python-checkins] r77899 - in python/branches/release26-maint: Lib/lib2to3/fixes/fix_import.py Lib/lib2to3/fixes/fix_itertools_imports.py Lib/lib2to3/fixes/fix_metaclass.py Lib/lib2to3/fixes/fix_tuple_params.py Lib/lib2to3/fixes/fix_xrange.py Message-ID: Author: martin.v.loewis Date: Mon Feb 1 02:17:43 2010 New Revision: 77899 Log: Merged revisions 77898 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r77898 | martin.v.loewis | 2010-02-01 02:15:39 +0100 (Mo, 01 Feb 2010) | 17 lines Merged revisions 77855-77856,77870 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r77855 | benjamin.peterson | 2010-01-30 17:32:05 +0100 (Sa, 30 Jan 2010) | 1 line don't return node if it is not changed ........ r77856 | benjamin.peterson | 2010-01-30 17:35:29 +0100 (Sa, 30 Jan 2010) | 1 line return None to indicate no change ........ r77870 | benjamin.peterson | 2010-01-31 02:21:26 +0100 (So, 31 Jan 2010) | 1 line never return the original node given to transform() ........ ................ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/lib2to3/fixes/fix_import.py python/branches/release26-maint/Lib/lib2to3/fixes/fix_itertools_imports.py python/branches/release26-maint/Lib/lib2to3/fixes/fix_metaclass.py python/branches/release26-maint/Lib/lib2to3/fixes/fix_tuple_params.py python/branches/release26-maint/Lib/lib2to3/fixes/fix_xrange.py Modified: python/branches/release26-maint/Lib/lib2to3/fixes/fix_import.py ============================================================================== --- python/branches/release26-maint/Lib/lib2to3/fixes/fix_import.py (original) +++ python/branches/release26-maint/Lib/lib2to3/fixes/fix_import.py Mon Feb 1 02:17:43 2010 @@ -56,7 +56,6 @@ if self.probably_a_local_import(imp.value): imp.value = "." + imp.value imp.changed() - return node else: have_local = False have_absolute = False Modified: python/branches/release26-maint/Lib/lib2to3/fixes/fix_itertools_imports.py ============================================================================== --- python/branches/release26-maint/Lib/lib2to3/fixes/fix_itertools_imports.py (original) +++ python/branches/release26-maint/Lib/lib2to3/fixes/fix_itertools_imports.py Mon Feb 1 02:17:43 2010 @@ -42,4 +42,4 @@ p = node.get_prefix() node = BlankLine() node.prefix = p - return node + return node Modified: python/branches/release26-maint/Lib/lib2to3/fixes/fix_metaclass.py ============================================================================== --- python/branches/release26-maint/Lib/lib2to3/fixes/fix_metaclass.py (original) +++ python/branches/release26-maint/Lib/lib2to3/fixes/fix_metaclass.py Mon Feb 1 02:17:43 2010 @@ -150,7 +150,7 @@ def transform(self, node, results): if not has_metaclass(node): - return node + return fixup_parse_tree(node) Modified: python/branches/release26-maint/Lib/lib2to3/fixes/fix_tuple_params.py ============================================================================== --- python/branches/release26-maint/Lib/lib2to3/fixes/fix_tuple_params.py (original) +++ python/branches/release26-maint/Lib/lib2to3/fixes/fix_tuple_params.py Mon Feb 1 02:17:43 2010 @@ -81,7 +81,7 @@ handle_tuple(arg, add_prefix=(i > 0)) if not new_lines: - return node + return # This isn't strictly necessary, but it plays nicely with other fixers. # TODO(cwinter) get rid of this when children becomes a smart list Modified: python/branches/release26-maint/Lib/lib2to3/fixes/fix_xrange.py ============================================================================== --- python/branches/release26-maint/Lib/lib2to3/fixes/fix_xrange.py (original) +++ python/branches/release26-maint/Lib/lib2to3/fixes/fix_xrange.py Mon Feb 1 02:17:43 2010 @@ -40,7 +40,6 @@ for n in results["rest"]: list_call.append_child(n) return list_call - return node P1 = "power< func=NAME trailer< '(' node=any ')' > any* >" p1 = patcomp.compile_pattern(P1) From python-checkins at python.org Mon Feb 1 02:18:51 2010 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 01 Feb 2010 01:18:51 -0000 Subject: [Python-checkins] r77900 - in python/branches/py3k: Lib/lib2to3/fixes/fix_import.py Lib/lib2to3/fixes/fix_itertools_imports.py Lib/lib2to3/fixes/fix_metaclass.py Lib/lib2to3/fixes/fix_tuple_params.py Lib/lib2to3/fixes/fix_xrange.py Message-ID: Author: martin.v.loewis Date: Mon Feb 1 02:18:51 2010 New Revision: 77900 Log: Merged revisions 77898 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r77898 | martin.v.loewis | 2010-02-01 02:15:39 +0100 (Mo, 01 Feb 2010) | 17 lines Merged revisions 77855-77856,77870 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r77855 | benjamin.peterson | 2010-01-30 17:32:05 +0100 (Sa, 30 Jan 2010) | 1 line don't return node if it is not changed ........ r77856 | benjamin.peterson | 2010-01-30 17:35:29 +0100 (Sa, 30 Jan 2010) | 1 line return None to indicate no change ........ r77870 | benjamin.peterson | 2010-01-31 02:21:26 +0100 (So, 31 Jan 2010) | 1 line never return the original node given to transform() ........ ................ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/lib2to3/fixes/fix_import.py python/branches/py3k/Lib/lib2to3/fixes/fix_itertools_imports.py python/branches/py3k/Lib/lib2to3/fixes/fix_metaclass.py python/branches/py3k/Lib/lib2to3/fixes/fix_tuple_params.py python/branches/py3k/Lib/lib2to3/fixes/fix_xrange.py Modified: python/branches/py3k/Lib/lib2to3/fixes/fix_import.py ============================================================================== --- python/branches/py3k/Lib/lib2to3/fixes/fix_import.py (original) +++ python/branches/py3k/Lib/lib2to3/fixes/fix_import.py Mon Feb 1 02:18:51 2010 @@ -56,7 +56,6 @@ if self.probably_a_local_import(imp.value): imp.value = "." + imp.value imp.changed() - return node else: have_local = False have_absolute = False Modified: python/branches/py3k/Lib/lib2to3/fixes/fix_itertools_imports.py ============================================================================== --- python/branches/py3k/Lib/lib2to3/fixes/fix_itertools_imports.py (original) +++ python/branches/py3k/Lib/lib2to3/fixes/fix_itertools_imports.py Mon Feb 1 02:18:51 2010 @@ -49,4 +49,4 @@ p = node.prefix node = BlankLine() node.prefix = p - return node + return node Modified: python/branches/py3k/Lib/lib2to3/fixes/fix_metaclass.py ============================================================================== --- python/branches/py3k/Lib/lib2to3/fixes/fix_metaclass.py (original) +++ python/branches/py3k/Lib/lib2to3/fixes/fix_metaclass.py Mon Feb 1 02:18:51 2010 @@ -150,7 +150,7 @@ def transform(self, node, results): if not has_metaclass(node): - return node + return fixup_parse_tree(node) Modified: python/branches/py3k/Lib/lib2to3/fixes/fix_tuple_params.py ============================================================================== --- python/branches/py3k/Lib/lib2to3/fixes/fix_tuple_params.py (original) +++ python/branches/py3k/Lib/lib2to3/fixes/fix_tuple_params.py Mon Feb 1 02:18:51 2010 @@ -81,7 +81,7 @@ handle_tuple(arg, add_prefix=(i > 0)) if not new_lines: - return node + return # This isn't strictly necessary, but it plays nicely with other fixers. # TODO(cwinter) get rid of this when children becomes a smart list Modified: python/branches/py3k/Lib/lib2to3/fixes/fix_xrange.py ============================================================================== --- python/branches/py3k/Lib/lib2to3/fixes/fix_xrange.py (original) +++ python/branches/py3k/Lib/lib2to3/fixes/fix_xrange.py Mon Feb 1 02:18:51 2010 @@ -40,7 +40,6 @@ for n in results["rest"]: list_call.append_child(n) return list_call - return node P1 = "power< func=NAME trailer< '(' node=any ')' > any* >" p1 = patcomp.compile_pattern(P1) From python-checkins at python.org Mon Feb 1 02:20:17 2010 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 01 Feb 2010 01:20:17 -0000 Subject: [Python-checkins] r77901 - in python/branches/release31-maint: Lib/lib2to3/fixes/fix_import.py Lib/lib2to3/fixes/fix_itertools_imports.py Lib/lib2to3/fixes/fix_metaclass.py Lib/lib2to3/fixes/fix_tuple_params.py Lib/lib2to3/fixes/fix_xrange.py Message-ID: Author: martin.v.loewis Date: Mon Feb 1 02:20:16 2010 New Revision: 77901 Log: Merged revisions 77900 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r77900 | martin.v.loewis | 2010-02-01 02:18:51 +0100 (Mo, 01 Feb 2010) | 24 lines Merged revisions 77898 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ................ r77898 | martin.v.loewis | 2010-02-01 02:15:39 +0100 (Mo, 01 Feb 2010) | 17 lines Merged revisions 77855-77856,77870 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r77855 | benjamin.peterson | 2010-01-30 17:32:05 +0100 (Sa, 30 Jan 2010) | 1 line don't return node if it is not changed ........ r77856 | benjamin.peterson | 2010-01-30 17:35:29 +0100 (Sa, 30 Jan 2010) | 1 line return None to indicate no change ........ r77870 | benjamin.peterson | 2010-01-31 02:21:26 +0100 (So, 31 Jan 2010) | 1 line never return the original node given to transform() ........ ................ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/lib2to3/fixes/fix_import.py python/branches/release31-maint/Lib/lib2to3/fixes/fix_itertools_imports.py python/branches/release31-maint/Lib/lib2to3/fixes/fix_metaclass.py python/branches/release31-maint/Lib/lib2to3/fixes/fix_tuple_params.py python/branches/release31-maint/Lib/lib2to3/fixes/fix_xrange.py Modified: python/branches/release31-maint/Lib/lib2to3/fixes/fix_import.py ============================================================================== --- python/branches/release31-maint/Lib/lib2to3/fixes/fix_import.py (original) +++ python/branches/release31-maint/Lib/lib2to3/fixes/fix_import.py Mon Feb 1 02:20:16 2010 @@ -56,7 +56,6 @@ if self.probably_a_local_import(imp.value): imp.value = "." + imp.value imp.changed() - return node else: have_local = False have_absolute = False Modified: python/branches/release31-maint/Lib/lib2to3/fixes/fix_itertools_imports.py ============================================================================== --- python/branches/release31-maint/Lib/lib2to3/fixes/fix_itertools_imports.py (original) +++ python/branches/release31-maint/Lib/lib2to3/fixes/fix_itertools_imports.py Mon Feb 1 02:20:16 2010 @@ -49,4 +49,4 @@ p = node.prefix node = BlankLine() node.prefix = p - return node + return node Modified: python/branches/release31-maint/Lib/lib2to3/fixes/fix_metaclass.py ============================================================================== --- python/branches/release31-maint/Lib/lib2to3/fixes/fix_metaclass.py (original) +++ python/branches/release31-maint/Lib/lib2to3/fixes/fix_metaclass.py Mon Feb 1 02:20:16 2010 @@ -150,7 +150,7 @@ def transform(self, node, results): if not has_metaclass(node): - return node + return fixup_parse_tree(node) Modified: python/branches/release31-maint/Lib/lib2to3/fixes/fix_tuple_params.py ============================================================================== --- python/branches/release31-maint/Lib/lib2to3/fixes/fix_tuple_params.py (original) +++ python/branches/release31-maint/Lib/lib2to3/fixes/fix_tuple_params.py Mon Feb 1 02:20:16 2010 @@ -81,7 +81,7 @@ handle_tuple(arg, add_prefix=(i > 0)) if not new_lines: - return node + return # This isn't strictly necessary, but it plays nicely with other fixers. # TODO(cwinter) get rid of this when children becomes a smart list Modified: python/branches/release31-maint/Lib/lib2to3/fixes/fix_xrange.py ============================================================================== --- python/branches/release31-maint/Lib/lib2to3/fixes/fix_xrange.py (original) +++ python/branches/release31-maint/Lib/lib2to3/fixes/fix_xrange.py Mon Feb 1 02:20:16 2010 @@ -40,7 +40,6 @@ for n in results["rest"]: list_call.append_child(n) return list_call - return node P1 = "power< func=NAME trailer< '(' node=any ')' > any* >" p1 = patcomp.compile_pattern(P1) From python-checkins at python.org Mon Feb 1 03:04:27 2010 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 01 Feb 2010 02:04:27 -0000 Subject: [Python-checkins] r77902 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: andrew.kuchling Date: Mon Feb 1 03:04:26 2010 New Revision: 77902 Log: Add various items Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Mon Feb 1 03:04:26 2010 @@ -6,7 +6,7 @@ :Release: |release| :Date: |today| -.. Fix accents on Kristjan Valur Jonsson, Fuerstenau, Tarek Ziade. +.. Fix accents on Kristjan Valur Jonsson, Fuerstenau .. $Id$ Rules for maintenance: @@ -585,11 +585,16 @@ left-alignment. This has been changed to right-alignment, which seems more sensible for numeric types. (Changed by Mark Dickinson; :issue:`6857`.) -* Distutils is being more actively developed, thanks to Tarek Ziade - who has taken over maintenance of the package. A new - :file:`setup.py` subcommand, ``check``, will - check that the arguments being passed to the :func:`setup` function - are complete and correct (:issue:`5732`). +* Distutils is being more actively developed, thanks to Tarek Ziad? + who has taken over maintenance of the package, so there are a number + of fixes and improvments. + + A new :file:`setup.py` subcommand, ``check``, will check that the + arguments being passed to the :func:`setup` function are complete + and correct (:issue:`5732`). + + Byte-compilation by the ``install_lib`` subcommand is now only done + if the ``sys.dont_write_bytecode`` setting allows it (:issue:`7071`). :func:`distutils.sdist.add_defaults` now uses *package_dir* and *data_files* to create the MANIFEST file. @@ -601,7 +606,7 @@ It is no longer mandatory to store clear-text passwords in the :file:`.pypirc` file when registering and uploading packages to PyPI. As long as the username is present in that file, the :mod:`distutils` package will - prompt for the password if not present. (Added by Tarek Ziade, + prompt for the password if not present. (Added by Tarek Ziad?, based on an initial contribution by Nathan Van Gheem; :issue:`4394`.) A Distutils setup can now specify that a C extension is optional by @@ -614,7 +619,7 @@ :meth:`read_pkg_file` method will read the contents of a package's :file:`PKG-INFO` metadata file. For an example of its use, see :ref:`reading-metadata`. - (Contributed by Tarek Ziade; :issue:`7457`.) + (Contributed by Tarek Ziad?; :issue:`7457`.) :file:`setup.py` files will now accept a :option:`--no-user-cfg` switch to skip reading the :file:`~/.pydistutils.cfg` file. (Suggested by @@ -753,7 +758,7 @@ :func:`getuserbase` returns the value of the :envvar:`USER_BASE` environment variable, giving the path to a directory that can be used to store data. - (Contributed by Tarek Ziade; :issue:`6693`.) + (Contributed by Tarek Ziad?; :issue:`6693`.) * The :mod:`socket` module's :class:`SSL` objects now support the buffer API, which fixed a test suite failure. (Fixed by Antoine Pitrou; @@ -798,7 +803,15 @@ named ``major``, ``minor``, ``micro``, ``releaselevel``, and ``serial``. (Contributed by Ross Light; :issue:`4285`.) -* The :mod:`tarfile` module now supports filtering the :class:`TarInfo` +* The :mod:`tarfile` module's default error handling has changed, to + no longer suppress fatal errors. The default error level was previously 0, + which meant that errors would only result in a message being written to the + debug log, but because the debug log is not activated by default, + these errors go unnoticed. The default error level is now 1, + which raises an exception if there's an error. + (Changed by Lars Gust?bel; :issue:`7357`.) + + :mod:`tarfile` now supports filtering the :class:`TarInfo` objects being added to a tar file. When you call :meth:`TarFile.add`, instance, you may supply an optional *filter* argument that's a callable. The *filter* callable will be passed the @@ -806,7 +819,7 @@ If the callable returns ``None``, the file will be excluded from the resulting archive. This is more powerful than the existing *exclude* argument, which has therefore been deprecated. - (Added by Lars Gustaebel; :issue:`6856`.) + (Added by Lars Gust?bel; :issue:`6856`.) * The :mod:`threading` module's :meth:`Event.wait` method now returns the internal flag on exit. This means the method will usually @@ -815,13 +828,17 @@ a timeout was provided and the operation timed out. (Contributed by Tim Lesher; :issue:`1674032`.) -* The :func:`is_zipfile` function in the :mod:`zipfile` module now - accepts a file object, in addition to the path names accepted in earlier - versions. (Contributed by Gabriel Genellina; :issue:`4756`.) +* The :mod:`zipfile` module's :class:`ZipFile` now supports the context + management protocol, so you can write ``with zipfile.ZipFile(...) as f: ...``. + (Contributed by Brian Curtin; :issue:`5511`.) :mod:`zipfile` now supports archiving empty directories and extracts them correctly. (Fixed by Kuba Wieczorek; :issue:`4710`.) + The :func:`is_zipfile` function in the :mod:`zipfile` module now + accepts a file object, in addition to the path names accepted in earlier + versions. (Contributed by Gabriel Genellina; :issue:`4756`.) + .. ====================================================================== .. whole new modules get described in subsections here From python-checkins at python.org Mon Feb 1 17:38:18 2010 From: python-checkins at python.org (phillip.eby) Date: Mon, 01 Feb 2010 16:38:18 -0000 Subject: [Python-checkins] r77903 - sandbox/trunk/setuptools/setuptools/package_index.py Message-ID: Author: phillip.eby Date: Mon Feb 1 17:38:17 2010 New Revision: 77903 Log: Yet another Sourceforge download fix Modified: sandbox/trunk/setuptools/setuptools/package_index.py Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Mon Feb 1 17:38:17 2010 @@ -590,9 +590,8 @@ def _download_url(self, scheme, url, tmpdir): # Determine download filename # - name = filter(None,urlparse.urlparse(url)[2].split('/')) + name, fragment = egg_info_for_url(url) if name: - name = name[-1] while '..' in name: name = name.replace('..','.').replace('\\','_') else: @@ -613,6 +612,7 @@ self.url_ok(url, True) # raises error if not allowed return self._attempt_download(url, filename) + def scan_url(self, url): self.process_url(url, True) From python-checkins at python.org Mon Feb 1 17:42:04 2010 From: python-checkins at python.org (phillip.eby) Date: Mon, 01 Feb 2010 16:42:04 -0000 Subject: [Python-checkins] r77904 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/package_index.py Message-ID: Author: phillip.eby Date: Mon Feb 1 17:42:04 2010 New Revision: 77904 Log: Backport SF download fix Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/package_index.py Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Mon Feb 1 17:42:04 2010 @@ -1224,6 +1224,8 @@ * Fixed bogus AttributeError when no local or downloadable packages are available + * Fix for recent Sourceforge downloading changes + 0.6c11 * Fix installed script .exe files not working with 64-bit Python on Windows (wasn't actually released in 0.6c10 due to a lost checkin) Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Mon Feb 1 17:42:04 2010 @@ -590,9 +590,8 @@ def _download_url(self, scheme, url, tmpdir): # Determine download filename # - name = filter(None,urlparse.urlparse(url)[2].split('/')) + name, fragment = egg_info_for_url(url) if name: - name = name[-1] while '..' in name: name = name.replace('..','.').replace('\\','_') else: @@ -613,6 +612,7 @@ self.url_ok(url, True) # raises error if not allowed return self._attempt_download(url, filename) + def scan_url(self, url): self.process_url(url, True) From solipsis at pitrou.net Tue Feb 2 01:03:27 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 2 Feb 2010 01:03:27 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r77900): sum=0 Message-ID: <20100202000327.EFF461770C@ns6635.ovh.net> py3k results for svn r77900 (hg cset cf2753a0a46a) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogN8-DN7', '-x', 'test_httpservers'] From python-checkins at python.org Tue Feb 2 09:37:35 2010 From: python-checkins at python.org (ezio.melotti) Date: Tue, 02 Feb 2010 08:37:35 -0000 Subject: [Python-checkins] r77910 - in python/trunk/Lib: bsddb/dbtables.py bsddb/test/test_basics.py bsddb/test/test_compare.py bsddb/test/test_dbobj.py bsddb/test/test_dbshelve.py bsddb/test/test_join.py bsddb/test/test_recno.py test/test_bsddb3.py Message-ID: Author: ezio.melotti Date: Tue Feb 2 09:37:35 2010 New Revision: 77910 Log: #7092: silence py3k warnings for bsddb. Patch by Florent Xicluna. Modified: python/trunk/Lib/bsddb/dbtables.py python/trunk/Lib/bsddb/test/test_basics.py python/trunk/Lib/bsddb/test/test_compare.py python/trunk/Lib/bsddb/test/test_dbobj.py python/trunk/Lib/bsddb/test/test_dbshelve.py python/trunk/Lib/bsddb/test/test_join.py python/trunk/Lib/bsddb/test/test_recno.py python/trunk/Lib/test/test_bsddb3.py Modified: python/trunk/Lib/bsddb/dbtables.py ============================================================================== --- python/trunk/Lib/bsddb/dbtables.py (original) +++ python/trunk/Lib/bsddb/dbtables.py Tue Feb 2 09:37:35 2010 @@ -332,7 +332,7 @@ except db.DBError, dberror: if txn: txn.abort() - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : raise TableDBError, dberror[1] else : raise TableDBError, dberror.args[1] @@ -416,7 +416,7 @@ except db.DBError, dberror: if txn: txn.abort() - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : raise TableDBError, dberror[1] else : raise TableDBError, dberror.args[1] @@ -499,7 +499,7 @@ if txn: txn.abort() self.db.delete(_rowid_key(table, rowid)) - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : raise TableDBError, dberror[1], info[2] else : raise TableDBError, dberror.args[1], info[2] @@ -554,7 +554,7 @@ raise except db.DBError, dberror: - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : raise TableDBError, dberror[1] else : raise TableDBError, dberror.args[1] @@ -598,7 +598,7 @@ txn.abort() raise except db.DBError, dberror: - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : raise TableDBError, dberror[1] else : raise TableDBError, dberror.args[1] @@ -621,7 +621,7 @@ columns = self.__tablecolumns[table] matching_rowids = self.__Select(table, columns, conditions) except db.DBError, dberror: - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : raise TableDBError, dberror[1] else : raise TableDBError, dberror.args[1] @@ -677,7 +677,7 @@ # leave all unknown condition callables alone as equals return 0 - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : conditionlist = conditions.items() conditionlist.sort(cmp_conditions) else : # Insertion Sort. Please, improve @@ -745,7 +745,7 @@ rowdata[column] = self.db.get( _data_key(table, column, rowid)) except db.DBError, dberror: - if sys.version_info[0] < 3 : + if sys.version_info < (2, 6) : if dberror[0] != db.DB_NOTFOUND: raise else : Modified: python/trunk/Lib/bsddb/test/test_basics.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_basics.py (original) +++ python/trunk/Lib/bsddb/test/test_basics.py Tue Feb 2 09:37:35 2010 @@ -139,11 +139,7 @@ try: d.delete('abcd') except db.DBNotFoundError, val: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.DB_NOTFOUND) - else : - self.assertEqual(val.args[0], db.DB_NOTFOUND) + self.assertEqual(val.args[0], db.DB_NOTFOUND) if verbose: print val else: self.fail("expected exception") @@ -162,11 +158,7 @@ try: d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE) except db.DBKeyExistError, val: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.DB_KEYEXIST) - else : - self.assertEqual(val.args[0], db.DB_KEYEXIST) + self.assertEqual(val.args[0], db.DB_KEYEXIST) if verbose: print val else: self.fail("expected exception") @@ -301,11 +293,7 @@ rec = c.next() except db.DBNotFoundError, val: if get_raises_error: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.DB_NOTFOUND) - else : - self.assertEqual(val.args[0], db.DB_NOTFOUND) + self.assertEqual(val.args[0], db.DB_NOTFOUND) if verbose: print val rec = None else: @@ -326,11 +314,7 @@ rec = c.prev() except db.DBNotFoundError, val: if get_raises_error: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.DB_NOTFOUND) - else : - self.assertEqual(val.args[0], db.DB_NOTFOUND) + self.assertEqual(val.args[0], db.DB_NOTFOUND) if verbose: print val rec = None else: @@ -353,11 +337,7 @@ try: n = c.set('bad key') except db.DBNotFoundError, val: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.DB_NOTFOUND) - else : - self.assertEqual(val.args[0], db.DB_NOTFOUND) + self.assertEqual(val.args[0], db.DB_NOTFOUND) if verbose: print val else: if set_raises_error: @@ -371,11 +351,7 @@ try: n = c.get_both('0404', 'bad data') except db.DBNotFoundError, val: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.DB_NOTFOUND) - else : - self.assertEqual(val.args[0], db.DB_NOTFOUND) + self.assertEqual(val.args[0], db.DB_NOTFOUND) if verbose: print val else: if get_raises_error: @@ -404,11 +380,7 @@ rec = c.current() except db.DBKeyEmptyError, val: if get_raises_error: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.DB_KEYEMPTY) - else : - self.assertEqual(val.args[0], db.DB_KEYEMPTY) + self.assertEqual(val.args[0], db.DB_KEYEMPTY) if verbose: print val else: self.fail("unexpected DBKeyEmptyError") @@ -451,13 +423,9 @@ print "attempting to use a closed cursor's %s method" % \ method # a bug may cause a NULL pointer dereference... - apply(getattr(c, method), args) + getattr(c, method)(*args) except db.DBError, val: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], 0) - else : - self.assertEqual(val.args[0], 0) + self.assertEqual(val.args[0], 0) if verbose: print val else: self.fail("no exception raised when using a buggy cursor's" @@ -710,10 +678,10 @@ pass statDict = self.env.log_stat(0); - self.assert_(statDict.has_key('magic')) - self.assert_(statDict.has_key('version')) - self.assert_(statDict.has_key('cur_file')) - self.assert_(statDict.has_key('region_nowait')) + self.assertIn('magic', statDict) + self.assertIn('version', statDict) + self.assertIn('cur_file', statDict) + self.assertIn('region_nowait', statDict) # must have at least one log file present: logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG) Modified: python/trunk/Lib/bsddb/test/test_compare.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_compare.py (original) +++ python/trunk/Lib/bsddb/test/test_compare.py Tue Feb 2 09:37:35 2010 @@ -30,7 +30,7 @@ data = expected_data[:] import sys - if sys.version_info[0] < 3 : + if sys.version_info[:3] < (2, 6, 0): if sys.version_info[:3] < (2, 4, 0): data.sort(comparator) else : @@ -47,7 +47,7 @@ data2.append(i) data = data2 - self.failUnless (data == expected_data, + self.assertEqual (data, expected_data, "comparator `%s' is not right: %s vs. %s" % (comparator, expected_data, data)) def test_lexical_comparator (self): @@ -115,14 +115,14 @@ rec = curs.first () while rec: key, ignore = rec - self.failUnless (index < len (expected), + self.assertLess (index, len (expected), "to many values returned from cursor") - self.failUnless (expected[index] == key, + self.assertEqual (expected[index], key, "expected value `%s' at %d but got `%s'" % (expected[index], index, key)) index = index + 1 rec = curs.next () - self.failUnless (index == len (expected), + self.assertEqual (index, len (expected), "not enough values returned from cursor") finally: curs.close () Modified: python/trunk/Lib/bsddb/test/test_dbobj.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_dbobj.py (original) +++ python/trunk/Lib/bsddb/test/test_dbobj.py Tue Feb 2 09:37:35 2010 @@ -27,7 +27,7 @@ def put(self, key, *args, **kwargs): key = key.upper() # call our parent classes put method with an upper case key - return apply(dbobj.DB.put, (self, key) + args, kwargs) + return dbobj.DB.put(self, key, *args, **kwargs) self.env = TestDBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL) self.db = TestDB(self.env) Modified: python/trunk/Lib/bsddb/test/test_dbshelve.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_dbshelve.py (original) +++ python/trunk/Lib/bsddb/test/test_dbshelve.py Tue Feb 2 09:37:35 2010 @@ -5,6 +5,7 @@ import os, string import random import unittest +import warnings from test_all import db, dbshelve, test_support, verbose, \ @@ -117,15 +118,11 @@ dbvalues = d.values() self.assertEqual(len(dbvalues), len(d.keys())) - import sys - if sys.version_info[0] < 3 : - values.sort() - dbvalues.sort() - self.assertEqual(values, dbvalues) - else : # XXX: Convert all to strings. Please, improve - values.sort(key=lambda x : str(x)) - dbvalues.sort(key=lambda x : str(x)) - self.assertEqual(repr(values), repr(dbvalues)) + with warnings.catch_warnings(): + warnings.filterwarnings('ignore', + 'comparing unequal types not supported', + DeprecationWarning) + self.assertEqual(sorted(values), sorted(dbvalues)) items = d.items() self.assertEqual(len(items), len(values)) Modified: python/trunk/Lib/bsddb/test/test_join.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_join.py (original) +++ python/trunk/Lib/bsddb/test/test_join.py Tue Feb 2 09:37:35 2010 @@ -51,13 +51,13 @@ # create and populate primary index priDB = db.DB(self.env) priDB.open(self.filename, "primary", db.DB_BTREE, db.DB_CREATE) - map(lambda t, priDB=priDB: apply(priDB.put, t), ProductIndex) + map(lambda t, priDB=priDB: priDB.put(*t), ProductIndex) # create and populate secondary index secDB = db.DB(self.env) secDB.set_flags(db.DB_DUP | db.DB_DUPSORT) secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE) - map(lambda t, secDB=secDB: apply(secDB.put, t), ColorIndex) + map(lambda t, secDB=secDB: secDB.put(*t), ColorIndex) sCursor = None jCursor = None Modified: python/trunk/Lib/bsddb/test/test_recno.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_recno.py (original) +++ python/trunk/Lib/bsddb/test/test_recno.py Tue Feb 2 09:37:35 2010 @@ -60,11 +60,7 @@ try: data = d[0] # This should raise a KeyError!?!?! except db.DBInvalidArgError, val: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.EINVAL) - else : - self.assertEqual(val.args[0], db.EINVAL) + self.assertEqual(val.args[0], db.EINVAL) if verbose: print val else: self.fail("expected exception") @@ -269,11 +265,7 @@ try: # this one will fail d.append('bad' * 20) except db.DBInvalidArgError, val: - import sys - if sys.version_info[0] < 3 : - self.assertEqual(val[0], db.EINVAL) - else : - self.assertEqual(val.args[0], db.EINVAL) + self.assertEqual(val.args[0], db.EINVAL) if verbose: print val else: self.fail("expected exception") Modified: python/trunk/Lib/test/test_bsddb3.py ============================================================================== --- python/trunk/Lib/test/test_bsddb3.py (original) +++ python/trunk/Lib/test/test_bsddb3.py Tue Feb 2 09:37:35 2010 @@ -12,6 +12,8 @@ # Skip test if _bsddb module was not built. import_module('_bsddb') +# Silence Py3k warning +import_module('bsddb', deprecated=True) # When running as a script instead of within the regrtest framework, skip the # requires test, since it's obvious we want to run them. From python-checkins at python.org Tue Feb 2 16:12:42 2010 From: python-checkins at python.org (ezio.melotti) Date: Tue, 02 Feb 2010 15:12:42 -0000 Subject: [Python-checkins] r77911 - python/trunk/Lib/test/test_unittest.py Message-ID: Author: ezio.melotti Date: Tue Feb 2 16:12:42 2010 New Revision: 77911 Log: Silence a couple of -3 warnings Modified: python/trunk/Lib/test/test_unittest.py Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Tue Feb 2 16:12:42 2010 @@ -3056,7 +3056,7 @@ try: self.assertRaises(KeyError, lambda: None) except self.failureException as e: - self.assertIn("KeyError not raised", e) + self.assertIn("KeyError not raised", e.args) else: self.fail("assertRaises() didn't fail") try: @@ -3073,7 +3073,7 @@ with self.assertRaises(KeyError): pass except self.failureException as e: - self.assertIn("KeyError not raised", e) + self.assertIn("KeyError not raised", e.args) else: self.fail("assertRaises() didn't fail") try: @@ -3591,6 +3591,9 @@ def __eq__(self, other): return self.path == other.path + # Silence py3k warning + __hash__ = None + loader._get_module_from_name = lambda name: Module(name) def loadTestsFromModule(module, use_load_tests): if use_load_tests: From python-checkins at python.org Tue Feb 2 16:57:45 2010 From: python-checkins at python.org (ezio.melotti) Date: Tue, 02 Feb 2010 15:57:45 -0000 Subject: [Python-checkins] r77912 - in python/trunk/Lib: bsddb/dbshelve.py bsddb/dbtables.py bsddb/test/test_all.py bsddb/test/test_basics.py bsddb/test/test_compare.py bsddb/test/test_dbtables.py bsddb/test/test_recno.py bsddb/test/test_replication.py bsddb/test/test_thread.py test/test_bsddb3.py Message-ID: Author: ezio.melotti Date: Tue Feb 2 16:57:45 2010 New Revision: 77912 Log: Fix idioms and a couple of py3k warnings. Patch by Florent Xicluna. Modified: python/trunk/Lib/bsddb/dbshelve.py python/trunk/Lib/bsddb/dbtables.py python/trunk/Lib/bsddb/test/test_all.py python/trunk/Lib/bsddb/test/test_basics.py python/trunk/Lib/bsddb/test/test_compare.py python/trunk/Lib/bsddb/test/test_dbtables.py python/trunk/Lib/bsddb/test/test_recno.py python/trunk/Lib/bsddb/test/test_replication.py python/trunk/Lib/bsddb/test/test_thread.py python/trunk/Lib/test/test_bsddb3.py Modified: python/trunk/Lib/bsddb/dbshelve.py ============================================================================== --- python/trunk/Lib/bsddb/dbshelve.py (original) +++ python/trunk/Lib/bsddb/dbshelve.py Tue Feb 2 16:57:45 2010 @@ -157,7 +157,7 @@ def keys(self, txn=None): - if txn != None: + if txn is not None: return self.db.keys(txn) else: return self.db.keys() @@ -185,7 +185,7 @@ def items(self, txn=None): - if txn != None: + if txn is not None: items = self.db.items(txn) else: items = self.db.items() @@ -196,7 +196,7 @@ return newitems def values(self, txn=None): - if txn != None: + if txn is not None: values = self.db.values(txn) else: values = self.db.values() Modified: python/trunk/Lib/bsddb/dbtables.py ============================================================================== --- python/trunk/Lib/bsddb/dbtables.py (original) +++ python/trunk/Lib/bsddb/dbtables.py Tue Feb 2 16:57:45 2010 @@ -179,14 +179,14 @@ def set_range(self, search) : v = self._dbcursor.set_range(bytes(search, "iso8859-1")) - if v != None : + if v is not None : v = (v[0].decode("iso8859-1"), v[1].decode("iso8859-1")) return v def __next__(self) : v = getattr(self._dbcursor, "next")() - if v != None : + if v is not None : v = (v[0].decode("iso8859-1"), v[1].decode("iso8859-1")) return v @@ -204,7 +204,7 @@ def put(self, key, value, flags=0, txn=None) : key = bytes(key, "iso8859-1") - if value != None : + if value is not None : value = bytes(value, "iso8859-1") return self._db.put(key, value, flags=flags, txn=txn) @@ -215,7 +215,7 @@ def get(self, key, txn=None, flags=0) : key = bytes(key, "iso8859-1") v = self._db.get(key, txn=txn, flags=flags) - if v != None : + if v is not None : v = v.decode("iso8859-1") return v @@ -540,7 +540,7 @@ # error dataitem = None dataitem = mappings[column](dataitem) - if dataitem != None: + if dataitem is not None: self.db.put( _data_key(table, column, rowid), dataitem, txn=txn) Modified: python/trunk/Lib/bsddb/test/test_all.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_all.py (original) +++ python/trunk/Lib/bsddb/test/test_all.py Tue Feb 2 16:57:45 2010 @@ -23,7 +23,7 @@ return getattr(self._dbcursor, v) def _fix(self, v) : - if v == None : return None + if v is None : return None key, value = v if isinstance(key, bytes) : key = key.decode(charset) @@ -90,7 +90,7 @@ def pget(self, key=None, data=None, flags=0) : # Incorrect because key can be a bare number, # but enough to pass testsuite - if isinstance(key, int) and (data==None) and (flags==0) : + if isinstance(key, int) and (data is None) and (flags == 0) : flags = key key = None if isinstance(key, str) : @@ -101,7 +101,7 @@ if isinstance(data, str) : data = bytes(data, charset) v=self._dbcursor.pget(key=key, data=data, flags=flags) - if v != None : + if v is not None : v1, v2, v3 = v if isinstance(v1, bytes) : v1 = v1.decode(charset) @@ -114,7 +114,7 @@ def join_item(self) : v = self._dbcursor.join_item() - if v != None : + if v is not None : v = v.decode(charset) return v @@ -134,7 +134,7 @@ args =(k, d, f) v = self._dbcursor.get(*args, **kwargs) - if v != None : + if v is not None : k, v = v if isinstance(k, bytes) : k = k.decode(charset) @@ -176,7 +176,7 @@ if isinstance(k, str) : k = bytes(k, charset) v = self._db[k] - if v != None : + if v is not None : v = v.decode(charset) return v @@ -230,7 +230,7 @@ else : v=self._db.get(key, txn=txn, flags=flags, dlen=dlen, doff=doff) - if (v != None) and isinstance(v, bytes) : + if (v is not None) and isinstance(v, bytes) : v = v.decode(charset) return v @@ -238,7 +238,7 @@ if isinstance(key, str) : key = bytes(key, charset) v=self._db.pget(key, txn=txn) - if v != None : + if v is not None : v1, v2 = v if isinstance(v1, bytes) : v1 = v1.decode(charset) @@ -252,7 +252,7 @@ if isinstance(value, str) : value = bytes(value, charset) v=self._db.get_both(key, value, txn=txn, flags=flags) - if v != None : + if v is not None : v = v.decode(charset) return v Modified: python/trunk/Lib/bsddb/test/test_basics.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_basics.py (original) +++ python/trunk/Lib/bsddb/test/test_basics.py Tue Feb 2 16:57:45 2010 @@ -342,7 +342,7 @@ else: if set_raises_error: self.fail("expected exception") - if n != None: + if n is not None: self.fail("expected None: %r" % (n,)) rec = c.get_both('0404', self.makeData('0404')) @@ -356,7 +356,7 @@ else: if get_raises_error: self.fail("expected exception") - if n != None: + if n is not None: self.fail("expected None: %r" % (n,)) if self.d.get_type() == db.DB_BTREE: Modified: python/trunk/Lib/bsddb/test/test_compare.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_compare.py (original) +++ python/trunk/Lib/bsddb/test/test_compare.py Tue Feb 2 16:57:45 2010 @@ -238,12 +238,7 @@ self.startTest () self.createDB (my_compare) - try: - self.db.set_bt_compare (my_compare) - self.assert_(0, "this set should fail") - - except RuntimeError, msg: - pass + self.assertRaises (RuntimeError, self.db.set_bt_compare, my_compare) def test_suite (): res = unittest.TestSuite () Modified: python/trunk/Lib/bsddb/test/test_dbtables.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_dbtables.py (original) +++ python/trunk/Lib/bsddb/test/test_dbtables.py Tue Feb 2 16:57:45 2010 @@ -341,7 +341,7 @@ self.tdb.Insert(tabname, {'Type': 'Unknown', 'Access': '0'}) def set_type(type): - if type == None: + if type is None: return 'MP3' return type Modified: python/trunk/Lib/bsddb/test/test_recno.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_recno.py (original) +++ python/trunk/Lib/bsddb/test/test_recno.py Tue Feb 2 16:57:45 2010 @@ -38,8 +38,8 @@ for x in letters: recno = d.append(x * 60) - self.assertEqual(type(recno), type(0)) - self.assert_(recno >= 1) + self.assertIsInstance(recno, int) + self.assertGreaterEqual(recno, 1) if verbose: print recno, @@ -54,7 +54,7 @@ if verbose: print data - self.assertEqual(type(data), type("")) + self.assertIsInstance(data, str) self.assertEqual(data, d.get(recno)) try: @@ -91,21 +91,21 @@ keys = d.keys() if verbose: print keys - self.assertEqual(type(keys), type([])) - self.assertEqual(type(keys[0]), type(123)) + self.assertIsInstance(keys, list) + self.assertIsInstance(keys[0], int) self.assertEqual(len(keys), len(d)) items = d.items() if verbose: pprint(items) - self.assertEqual(type(items), type([])) - self.assertEqual(type(items[0]), type(())) + self.assertIsInstance(items, list) + self.assertIsInstance(items[0], tuple) self.assertEqual(len(items[0]), 2) - self.assertEqual(type(items[0][0]), type(123)) - self.assertEqual(type(items[0][1]), type("")) + self.assertIsInstance(items[0][0], int) + self.assertIsInstance(items[0][1], str) self.assertEqual(len(items), len(d)) - self.assert_(d.has_key(25)) + self.assertTrue(d.has_key(25)) del d[25] self.assertFalse(d.has_key(25)) @@ -177,7 +177,7 @@ if get_returns_none: self.fail("unexpected DBKeyEmptyError exception") else: - self.assertEqual(val[0], db.DB_KEYEMPTY) + self.assertEqual(val.args[0], db.DB_KEYEMPTY) if verbose: print val else: if not get_returns_none: Modified: python/trunk/Lib/bsddb/test/test_replication.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_replication.py (original) +++ python/trunk/Lib/bsddb/test/test_replication.py Tue Feb 2 16:57:45 2010 @@ -188,11 +188,11 @@ import time timeout=time.time()+10 v=None - while (time.time() Author: ezio.melotti Date: Tue Feb 2 18:34:37 2010 New Revision: 77913 Log: #7092: Silence py3k warnings in test_exceptions and test_pep352. Patch by Florent Xicluna. Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Lib/test/test_pep352.py Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Tue Feb 2 18:34:37 2010 @@ -7,7 +7,7 @@ import warnings from test.test_support import TESTFN, unlink, run_unittest, captured_output -from test.test_pep352 import ignore_message_warning +from test.test_pep352 import ignore_deprecation_warnings # XXX This is not really enough, each *operation* should be tested! @@ -17,6 +17,7 @@ # Reloading the built-in exceptions module failed prior to Py2.2, while it # should act the same as reloading built-in sys. try: + from imp import reload import exceptions reload(exceptions) except ImportError, e: @@ -108,11 +109,11 @@ self.assertRaises(ValueError, chr, 10000) self.raise_catch(ZeroDivisionError, "ZeroDivisionError") - try: x = 1/0 + try: x = 1 // 0 except ZeroDivisionError: pass self.raise_catch(Exception, "Exception") - try: x = 1/0 + try: x = 1 // 0 except Exception, e: pass def testSyntaxErrorMessage(self): @@ -197,6 +198,7 @@ self.assertEqual(WindowsError(1001, "message").errno, 22) self.assertEqual(WindowsError(1001, "message").winerror, 1001) + @ignore_deprecation_warnings def testAttributes(self): # test that exception attributes are happy @@ -274,34 +276,32 @@ except NameError: pass - with warnings.catch_warnings(): - ignore_message_warning() - for exc, args, expected in exceptionList: - try: - raise exc(*args) - except BaseException, e: - if type(e) is not exc: - raise - # Verify module name - self.assertEquals(type(e).__module__, 'exceptions') - # Verify no ref leaks in Exc_str() - s = str(e) - for checkArgName in expected: - self.assertEquals(repr(getattr(e, checkArgName)), - repr(expected[checkArgName]), - 'exception "%s", attribute "%s"' % - (repr(e), checkArgName)) - - # test for pickling support - for p in pickle, cPickle: - for protocol in range(p.HIGHEST_PROTOCOL + 1): - new = p.loads(p.dumps(e, protocol)) - for checkArgName in expected: - got = repr(getattr(new, checkArgName)) - want = repr(expected[checkArgName]) - self.assertEquals(got, want, - 'pickled "%r", attribute "%s"' % - (e, checkArgName)) + for exc, args, expected in exceptionList: + try: + raise exc(*args) + except BaseException, e: + if type(e) is not exc: + raise + # Verify module name + self.assertEquals(type(e).__module__, 'exceptions') + # Verify no ref leaks in Exc_str() + s = str(e) + for checkArgName in expected: + self.assertEquals(repr(getattr(e, checkArgName)), + repr(expected[checkArgName]), + 'exception "%s", attribute "%s"' % + (repr(e), checkArgName)) + + # test for pickling support + for p in pickle, cPickle: + for protocol in range(p.HIGHEST_PROTOCOL + 1): + new = p.loads(p.dumps(e, protocol)) + for checkArgName in expected: + got = repr(getattr(new, checkArgName)) + want = repr(expected[checkArgName]) + self.assertEquals(got, want, + 'pickled "%r", attribute "%s"' % + (e, checkArgName)) def testDeprecatedMessageAttribute(self): @@ -331,6 +331,7 @@ with self.assertRaises(AttributeError): exc.message + @ignore_deprecation_warnings def testPickleMessageAttribute(self): # Pickling with message attribute must work, as well. e = Exception("foo") @@ -338,18 +339,18 @@ f.message = "bar" for p in pickle, cPickle: ep = p.loads(p.dumps(e)) - with warnings.catch_warnings(): - ignore_message_warning() - self.assertEqual(ep.message, "foo") + self.assertEqual(ep.message, "foo") fp = p.loads(p.dumps(f)) self.assertEqual(fp.message, "bar") + @ignore_deprecation_warnings def testSlicing(self): # Test that you can slice an exception directly instead of requiring # going through the 'args' attribute. args = (1, 2, 3) exc = BaseException(*args) self.assertEqual(exc[:], args) + self.assertEqual(exc.args[:], args) def testKeywordArgs(self): # test that builtin exception don't take keyword args, Modified: python/trunk/Lib/test/test_pep352.py ============================================================================== --- python/trunk/Lib/test/test_pep352.py (original) +++ python/trunk/Lib/test/test_pep352.py Tue Feb 2 18:34:37 2010 @@ -4,14 +4,27 @@ import warnings from test.test_support import run_unittest import os +import sys from platform import system as platform_system -def ignore_message_warning(): - """Ignore the DeprecationWarning for BaseException.message.""" - warnings.resetwarnings() - warnings.filterwarnings("ignore", "BaseException.message", - DeprecationWarning) +DEPRECATION_WARNINGS = ["BaseException.message has been deprecated"] +if sys.py3kwarning: + DEPRECATION_WARNINGS.extend( + ["exceptions must derive from BaseException", + "catching classes that don't inherit from BaseException is not allowed", + "__get(item|slice)__ not supported for exception classes"]) + +# Silence Py3k and other deprecation warnings +def ignore_deprecation_warnings(func): + """Ignore the known DeprecationWarnings.""" + def wrapper(*args, **kw): + with warnings.catch_warnings(): + warnings.resetwarnings() + for text in DEPRECATION_WARNINGS: + warnings.filterwarnings("ignore", text, DeprecationWarning) + return func(*args, **kw) + return wrapper class ExceptionClassTests(unittest.TestCase): @@ -21,13 +34,11 @@ def test_builtins_new_style(self): self.assertTrue(issubclass(Exception, object)) + @ignore_deprecation_warnings def verify_instance_interface(self, ins): - with warnings.catch_warnings(): - ignore_message_warning() - for attr in ("args", "message", "__str__", "__repr__", - "__getitem__"): - self.assertTrue(hasattr(ins, attr), - "%s missing %s attribute" % + for attr in ("args", "message", "__str__", "__repr__", "__getitem__"): + self.assertTrue(hasattr(ins, attr), + "%s missing %s attribute" % (ins.__class__.__name__, attr)) def test_inheritance(self): @@ -91,43 +102,39 @@ self.assertEqual(given, expected, "%s: %s != %s" % (test_name, given, expected)) + @ignore_deprecation_warnings def test_interface_single_arg(self): # Make sure interface works properly when given a single argument arg = "spam" exc = Exception(arg) - with warnings.catch_warnings(): - ignore_message_warning() - results = ([len(exc.args), 1], [exc.args[0], arg], - [exc.message, arg], - [str(exc), str(arg)], [unicode(exc), unicode(arg)], - [repr(exc), exc.__class__.__name__ + repr(exc.args)], [exc[0], - arg]) - self.interface_test_driver(results) + results = ([len(exc.args), 1], [exc.args[0], arg], [exc.message, arg], + [str(exc), str(arg)], [unicode(exc), unicode(arg)], + [repr(exc), exc.__class__.__name__ + repr(exc.args)], + [exc[0], arg]) + self.interface_test_driver(results) + @ignore_deprecation_warnings def test_interface_multi_arg(self): # Make sure interface correct when multiple arguments given arg_count = 3 args = tuple(range(arg_count)) exc = Exception(*args) - with warnings.catch_warnings(): - ignore_message_warning() - results = ([len(exc.args), arg_count], [exc.args, args], - [exc.message, ''], [str(exc), str(args)], - [unicode(exc), unicode(args)], - [repr(exc), exc.__class__.__name__ + repr(exc.args)], - [exc[-1], args[-1]]) - self.interface_test_driver(results) + results = ([len(exc.args), arg_count], [exc.args, args], + [exc.message, ''], [str(exc), str(args)], + [unicode(exc), unicode(args)], + [repr(exc), exc.__class__.__name__ + repr(exc.args)], + [exc[-1], args[-1]]) + self.interface_test_driver(results) + @ignore_deprecation_warnings def test_interface_no_arg(self): # Make sure that with no args that interface is correct exc = Exception() - with warnings.catch_warnings(): - ignore_message_warning() - results = ([len(exc.args), 0], [exc.args, tuple()], - [exc.message, ''], - [str(exc), ''], [unicode(exc), u''], - [repr(exc), exc.__class__.__name__ + '()'], [True, True]) - self.interface_test_driver(results) + results = ([len(exc.args), 0], [exc.args, tuple()], + [exc.message, ''], + [str(exc), ''], [unicode(exc), u''], + [repr(exc), exc.__class__.__name__ + '()'], [True, True]) + self.interface_test_driver(results) def test_message_deprecation(self): @@ -179,6 +186,7 @@ self.fail("TypeError expected when catching %s as specified in a " "tuple" % type(object_)) + @ignore_deprecation_warnings def test_raise_classic(self): # Raising a classic class is okay (for now). class ClassicClass: @@ -194,7 +202,7 @@ except ClassicClass: pass except: - self.fail("unable to raise class class instance") + self.fail("unable to raise classic class instance") def test_raise_new_style_non_exception(self): # You cannot raise a new-style class that does not inherit from From python-checkins at python.org Tue Feb 2 23:27:59 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 22:27:59 -0000 Subject: [Python-checkins] r77914 - in python/trunk/Doc/library: python.rst sysconfig.rst Message-ID: Author: tarek.ziade Date: Tue Feb 2 23:27:58 2010 New Revision: 77914 Log: first version of the sysconfig module documentation Added: python/trunk/Doc/library/sysconfig.rst Modified: python/trunk/Doc/library/python.rst Modified: python/trunk/Doc/library/python.rst ============================================================================== --- python/trunk/Doc/library/python.rst (original) +++ python/trunk/Doc/library/python.rst Tue Feb 2 23:27:58 2010 @@ -13,6 +13,7 @@ .. toctree:: sys.rst + sysconfig.rst __builtin__.rst future_builtins.rst __main__.rst Added: python/trunk/Doc/library/sysconfig.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/library/sysconfig.rst Tue Feb 2 23:27:58 2010 @@ -0,0 +1,218 @@ +:mod:`sysconfig` --- Provide access to Python's configuration information +========================================================================= + +.. module:: sysconfig + :synopsis: Python's configuration information +.. moduleauthor:: Tarek Ziade +.. sectionauthor:: Tarek Ziade +.. versionadded:: 2.7 +.. index:: + single: configuration information + +The :mod:`sysconfig` module provides access to Python's configuration +information like the list of installation paths and the configuration +variables relevant for the current platform. + +Configuration variables +----------------------- + +A Python distribution contains a :file:`Makefile` file and a :file:`python.h` +that are used to build the Python binary itself, but also any C extension +created in a third party project and compiled using :mod:`distutils`. + +:mod:`sysconfig` put all variables found in these files in a dictionnary +that can be accessed using :func:`get_config_vars` or :func:`get_config_var`. + +Notice that on Windows, it's a much smaller set. + +.. function:: get_config_vars(\*args) + + With no arguments, return a dictionary of all configuration + variables relevant for the current platform. + + With arguments, return a list of values that result from looking up + each argument in the configuration variable dictionary. + + For each argument, if the value is not found, returns None. + +.. function:: get_config_var(name) + + Return the value of a single variable *name*. Equivalent to + get_config_vars().get(name). + + If *name* is not found, return None. + +Example of usage:: + + >>> import sysconfig + >>> sysconfig.get_config_var('Py_ENABLE_SHARED') + 0 + >>> sysconfig.get_config_var('LIBDIR') + '/usr/local/lib' + >>> sysconfig.get_config_vars('AR', 'CXX') + ['ar', 'g++'] + + +Installation paths +------------------ + +Python uses an installation scheme that differs depending on the platform +and on the installation options. These schemes are stored in :mod:`sysconfig` +under unique identifiers based on the value returned by :const:`os.name`. + +Every new component that is installed using :mod:`distutils` or a +Distutils-based system will follow the same scheme to copy its file in the +right places. + +Python currently supports seven schemes: + +- *posix_prefix*: scheme for posix platforms like Linux or Mac OS X. This is the + default scheme used when Python or a component is installed. +- *posix_home*: scheme for posix platform used when a *home* option is used + upon installation. This scheme is used when a component is installed through + Distutils with a specific home prefix. +- *posix_user*: scheme for posix platform used when a component is installed + through Distutils and the *user* option is used. This scheme defines paths + located under the user home directory. +- *nt*: scheme for nt platforms like Windows. +- *nt_user*: scheme for nt platforms, when the *user* option is used. +- *os2*: scheme for OS2 platforms. +- *os2_home*: scheme for OS2 patforms, when the *user* option is used. + +Each scheme is itself composed of a series of paths and each path has a unique +identifier. Python currently uses eight paths: + +- *stdlib*: directory containing the standard Python library files that are + not platform-specific. +- *platstdlib*: directory containing the standard Python library files that + are platform-specific files. +- *platlib*: directory for the site-specific, platform-specific files. +- *purelib*: directory for the site-specific, non platform-specific files. +- *include*: directory containing the non-platform-specific header files. +- *platinclude*: directory containing the platform-specific header files. +- *scripts*: directory containing the script files. +- *data*: directory containing the data files. + +:mod:`sysconfig` provides some functions to read these paths. + +.. function:: get_scheme_names() + + Return a tuple containing all schemes currently supported in + :mod:`sysconfig`. + +.. function:: get_path_names() + + Return a tuple containing all path names currently supported in + :mod:`sysconfig`. + + +.. function:: get_path(name, [scheme, [vars, [expand]]]) + + Return an installation path corresponding to the path *name*, from the + install scheme named *scheme*. + + *name* has to be a value from the list returned by :func:`get_path_names`. + + :mod:`sysconfig` stores installation paths corresponding to the each + path name, for each platform, with variables to be expanded. For instance + the `stdlib` path for the `nt` scheme is: `{base}/Lib`. + + :func:`get_path` will use the variables returned by :func:`get_config_vars` + to expand the path. All variables have default values for each platform + so one may call this function and get the default value. + + If *scheme* is provided, it must be a value from the list returned by + :func:`get_path_names`. Otherwise, the default scheme for the current + platform is used. + + If *vars* is provided, it must be a dictionnary of variables that will + update the dictionnary return by :func:`get_config_vars`. + + If *expand* is set to False, the path will not be expanded using + the variables. + + If *name* is not found, return None. + + +.. function:: get_paths([scheme, [vars, [expand]]]) + + Return a dictionnary containing all installation paths corresponding to an + installation scheme. See :func:`get_path` for more information. + + If *scheme* is not provided, will use the default scheme for the current + platform. + + If *vars* is provided, it must be a dictionnary of variables that will + update the dictionnary used to expand the paths. + + If *expand* is set to False, the paths will not be expanded. + + If *scheme* is not an existing scheme, :func:`get_paths` will raise a + :exc:`KeyError`. + + +Other functions +--------------- + +.. function:: get_python_version() + + Return the MAJOR.MINOR Python version number as a string. Similar to + ``sys.version[:3]``. + +.. function:: get_platform() + + Return a string that identifies the current platform. + + This is used mainly to distinguish platform-specific build directories and + platform-specific built distributions. Typically includes the OS name + and version and the architecture (as supplied by 'os.uname()'), + although the exact information included depends on the OS; eg. for IRIX + the architecture isn't particularly important (IRIX only runs on SGI + hardware), but for Linux the kernel version isn't particularly + important. + + Examples of returned values: + + - linux-i586 + - linux-alpha (?) + - solaris-2.6-sun4u + - irix-5.3 + - irix64-6.2 + + Windows will return one of: + + - win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) + - win-ia64 (64bit Windows on Itanium) + - win32 (all others - specifically, sys.platform is returned) + + Mac OS X can return : + + - macosx-10.6-ppc + - macosx-10.4-ppc64 + - macosx-10.3-i386 + - macosx-10.4-fat + + For other non-POSIX platforms, currently just returns 'sys.platform'. + + +.. function:: is_python_build(): + + Returns True if the current Python installation was built from source. + + +.. function:: parse_config_h(fp[, vars]): + + Parse a config.h-style file. + + *fp* is a file-like object pointing to the config.h-like file. + + A dictionary containing name/value pairs is returned. If an optional + dictionary is passed in as the second argument, it is used instead of a + new dictionary, and updated with the values read in the file. + + +.. function:: get_config_h_filename(): + + Returns the path of pyconfig.h + + From python-checkins at python.org Tue Feb 2 23:29:36 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 22:29:36 -0000 Subject: [Python-checkins] r77915 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Tue Feb 2 23:29:36 2010 New Revision: 77915 Log: Blocked revisions 77914 via svnmerge ........ r77914 | tarek.ziade | 2010-02-02 23:27:58 +0100 (Tue, 02 Feb 2010) | 1 line first version of the sysconfig module documentation ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Feb 2 23:36:18 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 02 Feb 2010 22:36:18 -0000 Subject: [Python-checkins] r77916 - in python/trunk: Misc/NEWS Modules/_testcapimodule.c Objects/memoryobject.c Message-ID: Author: antoine.pitrou Date: Tue Feb 2 23:36:17 2010 New Revision: 77916 Log: Issue #7385: Fix a crash in `MemoryView_FromObject` when `PyObject_GetBuffer` fails. Patch by Florent Xicluna. Modified: python/trunk/Misc/NEWS python/trunk/Modules/_testcapimodule.c python/trunk/Objects/memoryobject.c Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Feb 2 23:36:17 2010 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7385: Fix a crash in `MemoryView_FromObject` when + `PyObject_GetBuffer` fails. Patch by Florent Xicluna. + - Issue #7819: Check sys.call_tracing() arguments types. - Issue #7788: Fix an interpreter crash produced by deleting a list Modified: python/trunk/Modules/_testcapimodule.c ============================================================================== --- python/trunk/Modules/_testcapimodule.c (original) +++ python/trunk/Modules/_testcapimodule.c Tue Feb 2 23:36:17 2010 @@ -283,6 +283,100 @@ } +/* Issue #7385: Check that memoryview() does not crash + * when bf_getbuffer returns an error + */ + +static int +broken_buffer_getbuffer(PyObject *self, Py_buffer *view, int flags) +{ + PyErr_SetString( + TestError, + "test_broken_memoryview: expected error in bf_getbuffer"); + return -1; +} + +static PyBufferProcs memoryviewtester_as_buffer = { + 0, /* bf_getreadbuffer */ + 0, /* bf_getwritebuffer */ + 0, /* bf_getsegcount */ + 0, /* bf_getcharbuffer */ + (getbufferproc)broken_buffer_getbuffer, /* bf_getbuffer */ + 0, /* bf_releasebuffer */ +}; + +static PyTypeObject _MemoryViewTester_Type = { + PyObject_HEAD_INIT(NULL) + 0, /* Number of items for varobject */ + "memoryviewtester", /* Name of this type */ + sizeof(PyObject), /* Basic object size */ + 0, /* Item size for varobject */ + (destructor)PyObject_Del, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + &memoryviewtester_as_buffer, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_NEWBUFFER, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +static PyObject* +test_broken_memoryview(PyObject* self) +{ + PyObject *obj = PyObject_New(PyObject, &_MemoryViewTester_Type); + PyObject *res; + + if (obj == NULL) { + PyErr_Clear(); + PyErr_SetString( + TestError, + "test_broken_memoryview: failed to create object"); + return NULL; + } + + res = PyMemoryView_FromObject(obj); + if (res || !PyErr_Occurred()){ + PyErr_SetString( + TestError, + "test_broken_memoryview: memoryview() didn't raise an Exception"); + Py_XDECREF(res); + Py_DECREF(obj); + return NULL; + } + + PyErr_Clear(); + Py_DECREF(obj); + Py_RETURN_NONE; +} + + /* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG) PyLong_{As, From}{Unsigned,}LongLong(). @@ -1401,6 +1495,7 @@ {"test_list_api", (PyCFunction)test_list_api, METH_NOARGS}, {"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS}, {"test_lazy_hash_inheritance", (PyCFunction)test_lazy_hash_inheritance,METH_NOARGS}, + {"test_broken_memoryview", (PyCFunction)test_broken_memoryview,METH_NOARGS}, {"test_long_api", (PyCFunction)test_long_api, METH_NOARGS}, {"test_long_and_overflow", (PyCFunction)test_long_and_overflow, METH_NOARGS}, Modified: python/trunk/Objects/memoryobject.c ============================================================================== --- python/trunk/Objects/memoryobject.c (original) +++ python/trunk/Objects/memoryobject.c Tue Feb 2 23:36:17 2010 @@ -76,6 +76,7 @@ PyMemoryView_FromObject(PyObject *base) { PyMemoryViewObject *mview; + Py_buffer view; if (!PyObject_CheckBuffer(base)) { PyErr_SetString(PyExc_TypeError, @@ -84,20 +85,17 @@ return NULL; } - mview = (PyMemoryViewObject *) - PyObject_GC_New(PyMemoryViewObject, &PyMemoryView_Type); - if (mview == NULL) + if (PyObject_GetBuffer(base, &view, PyBUF_FULL_RO) < 0) return NULL; - mview->base = NULL; - if (PyObject_GetBuffer(base, &(mview->view), PyBUF_FULL_RO) < 0) { - Py_DECREF(mview); + mview = (PyMemoryViewObject *)PyMemoryView_FromBuffer(&view); + if (mview == NULL) { + PyBuffer_Release(&view); return NULL; } mview->base = base; Py_INCREF(base); - _PyObject_GC_TRACK(mview); return (PyObject *)mview; } From python-checkins at python.org Tue Feb 2 23:41:41 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 02 Feb 2010 22:41:41 -0000 Subject: [Python-checkins] r77917 - python/branches/release26-maint Message-ID: Author: antoine.pitrou Date: Tue Feb 2 23:41:41 2010 New Revision: 77917 Log: Blocked revisions 77916 via svnmerge ........ r77916 | antoine.pitrou | 2010-02-02 23:36:17 +0100 (mar., 02 f?vr. 2010) | 4 lines Issue #7385: Fix a crash in `MemoryView_FromObject` when `PyObject_GetBuffer` fails. Patch by Florent Xicluna. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Feb 2 23:47:00 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 02 Feb 2010 22:47:00 -0000 Subject: [Python-checkins] r77918 - in python/branches/py3k: Misc/NEWS Modules/_testcapimodule.c Objects/memoryobject.c Message-ID: Author: antoine.pitrou Date: Tue Feb 2 23:47:00 2010 New Revision: 77918 Log: Merged revisions 77916 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77916 | antoine.pitrou | 2010-02-02 23:36:17 +0100 (mar., 02 f?vr. 2010) | 4 lines Issue #7385: Fix a crash in `MemoryView_FromObject` when `PyObject_GetBuffer` fails. Patch by Florent Xicluna. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/_testcapimodule.c python/branches/py3k/Objects/memoryobject.c Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Feb 2 23:47:00 2010 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7385: Fix a crash in `MemoryView_FromObject` when + `PyObject_GetBuffer` fails. Patch by Florent Xicluna. + - Issue #7788: Fix an interpreter crash produced by deleting a list slice with very large step value. Modified: python/branches/py3k/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k/Modules/_testcapimodule.c (original) +++ python/branches/py3k/Modules/_testcapimodule.c Tue Feb 2 23:47:00 2010 @@ -284,6 +284,95 @@ } +/* Issue #7385: Check that memoryview() does not crash + * when bf_getbuffer returns an error + */ + +static int +broken_buffer_getbuffer(PyObject *self, Py_buffer *view, int flags) +{ + PyErr_SetString( + TestError, + "test_broken_memoryview: expected error in bf_getbuffer"); + return -1; +} + +static PyBufferProcs memoryviewtester_as_buffer = { + (getbufferproc)broken_buffer_getbuffer, /* bf_getbuffer */ + 0, /* bf_releasebuffer */ +}; + +static PyTypeObject _MemoryViewTester_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "memoryviewtester", /* Name of this type */ + sizeof(PyObject), /* Basic object size */ + 0, /* Item size for varobject */ + (destructor)PyObject_Del, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + &memoryviewtester_as_buffer, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +static PyObject* +test_broken_memoryview(PyObject* self) +{ + PyObject *obj = PyObject_New(PyObject, &_MemoryViewTester_Type); + PyObject *res; + + if (obj == NULL) { + PyErr_Clear(); + PyErr_SetString( + TestError, + "test_broken_memoryview: failed to create object"); + return NULL; + } + + res = PyMemoryView_FromObject(obj); + if (res || !PyErr_Occurred()){ + PyErr_SetString( + TestError, + "test_broken_memoryview: memoryview() didn't raise an Exception"); + Py_XDECREF(res); + Py_DECREF(obj); + return NULL; + } + + PyErr_Clear(); + Py_DECREF(obj); + Py_RETURN_NONE; +} + + /* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG) PyLong_{As, From}{Unsigned,}LongLong(). @@ -1926,6 +2015,7 @@ {"test_list_api", (PyCFunction)test_list_api, METH_NOARGS}, {"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS}, {"test_lazy_hash_inheritance", (PyCFunction)test_lazy_hash_inheritance,METH_NOARGS}, + {"test_broken_memoryview", (PyCFunction)test_broken_memoryview,METH_NOARGS}, {"test_long_api", (PyCFunction)test_long_api, METH_NOARGS}, {"test_long_and_overflow", (PyCFunction)test_long_and_overflow, METH_NOARGS}, Modified: python/branches/py3k/Objects/memoryobject.c ============================================================================== --- python/branches/py3k/Objects/memoryobject.c (original) +++ python/branches/py3k/Objects/memoryobject.c Tue Feb 2 23:47:00 2010 @@ -76,6 +76,7 @@ PyMemoryView_FromObject(PyObject *base) { PyMemoryViewObject *mview; + Py_buffer view; if (!PyObject_CheckBuffer(base)) { PyErr_SetString(PyExc_TypeError, @@ -84,20 +85,17 @@ return NULL; } - mview = (PyMemoryViewObject *) - PyObject_GC_New(PyMemoryViewObject, &PyMemoryView_Type); - if (mview == NULL) + if (PyObject_GetBuffer(base, &view, PyBUF_FULL_RO) < 0) return NULL; - mview->base = NULL; - if (PyObject_GetBuffer(base, &(mview->view), PyBUF_FULL_RO) < 0) { - Py_DECREF(mview); + mview = (PyMemoryViewObject *)PyMemoryView_FromBuffer(&view); + if (mview == NULL) { + PyBuffer_Release(&view); return NULL; } mview->base = base; Py_INCREF(base); - _PyObject_GC_TRACK(mview); return (PyObject *)mview; } From python-checkins at python.org Tue Feb 2 23:50:24 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 22:50:24 -0000 Subject: [Python-checkins] r77919 - python/trunk/Lib/sysconfig.py Message-ID: Author: tarek.ziade Date: Tue Feb 2 23:50:23 2010 New Revision: 77919 Log: module reorganization + missing doctests Modified: python/trunk/Lib/sysconfig.py Modified: python/trunk/Lib/sysconfig.py ============================================================================== --- python/trunk/Lib/sysconfig.py (original) +++ python/trunk/Lib/sysconfig.py Tue Feb 2 23:50:23 2010 @@ -235,49 +235,12 @@ vars.update(done) return vars -def parse_config_h(fp, vars=None): - """Parse a config.h-style file. - - A dictionary containing name/value pairs is returned. If an - optional dictionary is passed in as the second argument, it is - used instead of a new dictionary. - """ - import re - if vars is None: - vars = {} - define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n") - undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n") - - while True: - line = fp.readline() - if not line: - break - m = define_rx.match(line) - if m: - n, v = m.group(1, 2) - try: v = int(v) - except ValueError: pass - vars[n] = v - else: - m = undef_rx.match(line) - if m: - vars[m.group(1)] = 0 - return vars def _get_makefile_filename(): if _PYTHON_BUILD: return os.path.join(_PROJECT_BASE, "Makefile") return os.path.join(get_path('stdlib'), "config", "Makefile") -def get_config_h_filename(): - if _PYTHON_BUILD: - if os.name == "nt": - inc_dir = os.path.join(_PROJECT_BASE, "PC") - else: - inc_dir = _PROJECT_BASE - else: - inc_dir = get_path('platinclude') - return os.path.join(inc_dir, 'pyconfig.h') def _init_posix(vars): """Initialize the module as appropriate for POSIX systems.""" @@ -337,10 +300,53 @@ # public APIs # + +def parse_config_h(fp, vars=None): + """Parse a config.h-style file. + + A dictionary containing name/value pairs is returned. If an + optional dictionary is passed in as the second argument, it is + used instead of a new dictionary. + """ + import re + if vars is None: + vars = {} + define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n") + undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n") + + while True: + line = fp.readline() + if not line: + break + m = define_rx.match(line) + if m: + n, v = m.group(1, 2) + try: v = int(v) + except ValueError: pass + vars[n] = v + else: + m = undef_rx.match(line) + if m: + vars[m.group(1)] = 0 + return vars + +def get_config_h_filename(): + """Returns the path of pyconfig.h.""" + if _PYTHON_BUILD: + if os.name == "nt": + inc_dir = os.path.join(_PROJECT_BASE, "PC") + else: + inc_dir = _PROJECT_BASE + else: + inc_dir = get_path('platinclude') + return os.path.join(inc_dir, 'pyconfig.h') + def get_scheme_names(): + """Returns a tuple containing the schemes names.""" return _INSTALL_SCHEMES.keys() def get_path_names(): + """Returns a tuple containing the paths names.""" return _SCHEME_KEYS def get_paths(scheme=_get_default_scheme(), vars=None, expand=True): From python-checkins at python.org Tue Feb 2 23:51:34 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 02 Feb 2010 22:51:34 -0000 Subject: [Python-checkins] r77920 - in python/branches/release31-maint: Misc/NEWS Modules/_testcapimodule.c Objects/memoryobject.c Message-ID: Author: antoine.pitrou Date: Tue Feb 2 23:51:34 2010 New Revision: 77920 Log: Merged revisions 77918 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r77918 | antoine.pitrou | 2010-02-02 23:47:00 +0100 (mar., 02 f?vr. 2010) | 10 lines Merged revisions 77916 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77916 | antoine.pitrou | 2010-02-02 23:36:17 +0100 (mar., 02 f?vr. 2010) | 4 lines Issue #7385: Fix a crash in `MemoryView_FromObject` when `PyObject_GetBuffer` fails. Patch by Florent Xicluna. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/_testcapimodule.c python/branches/release31-maint/Objects/memoryobject.c Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Tue Feb 2 23:51:34 2010 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7385: Fix a crash in `MemoryView_FromObject` when + `PyObject_GetBuffer` fails. Patch by Florent Xicluna. + - Issue #7788: Fix an interpreter crash produced by deleting a list slice with very large step value. Modified: python/branches/release31-maint/Modules/_testcapimodule.c ============================================================================== --- python/branches/release31-maint/Modules/_testcapimodule.c (original) +++ python/branches/release31-maint/Modules/_testcapimodule.c Tue Feb 2 23:51:34 2010 @@ -283,6 +283,95 @@ } +/* Issue #7385: Check that memoryview() does not crash + * when bf_getbuffer returns an error + */ + +static int +broken_buffer_getbuffer(PyObject *self, Py_buffer *view, int flags) +{ + PyErr_SetString( + TestError, + "test_broken_memoryview: expected error in bf_getbuffer"); + return -1; +} + +static PyBufferProcs memoryviewtester_as_buffer = { + (getbufferproc)broken_buffer_getbuffer, /* bf_getbuffer */ + 0, /* bf_releasebuffer */ +}; + +static PyTypeObject _MemoryViewTester_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "memoryviewtester", /* Name of this type */ + sizeof(PyObject), /* Basic object size */ + 0, /* Item size for varobject */ + (destructor)PyObject_Del, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + &memoryviewtester_as_buffer, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +static PyObject* +test_broken_memoryview(PyObject* self) +{ + PyObject *obj = PyObject_New(PyObject, &_MemoryViewTester_Type); + PyObject *res; + + if (obj == NULL) { + PyErr_Clear(); + PyErr_SetString( + TestError, + "test_broken_memoryview: failed to create object"); + return NULL; + } + + res = PyMemoryView_FromObject(obj); + if (res || !PyErr_Occurred()){ + PyErr_SetString( + TestError, + "test_broken_memoryview: memoryview() didn't raise an Exception"); + Py_XDECREF(res); + Py_DECREF(obj); + return NULL; + } + + PyErr_Clear(); + Py_DECREF(obj); + Py_RETURN_NONE; +} + + /* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG) PyLong_{As, From}{Unsigned,}LongLong(). @@ -1531,6 +1620,7 @@ {"test_list_api", (PyCFunction)test_list_api, METH_NOARGS}, {"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS}, {"test_lazy_hash_inheritance", (PyCFunction)test_lazy_hash_inheritance,METH_NOARGS}, + {"test_broken_memoryview", (PyCFunction)test_broken_memoryview,METH_NOARGS}, {"test_long_api", (PyCFunction)test_long_api, METH_NOARGS}, {"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS}, {"test_k_code", (PyCFunction)test_k_code, METH_NOARGS}, Modified: python/branches/release31-maint/Objects/memoryobject.c ============================================================================== --- python/branches/release31-maint/Objects/memoryobject.c (original) +++ python/branches/release31-maint/Objects/memoryobject.c Tue Feb 2 23:51:34 2010 @@ -76,6 +76,7 @@ PyMemoryView_FromObject(PyObject *base) { PyMemoryViewObject *mview; + Py_buffer view; if (!PyObject_CheckBuffer(base)) { PyErr_SetString(PyExc_TypeError, @@ -84,20 +85,17 @@ return NULL; } - mview = (PyMemoryViewObject *) - PyObject_GC_New(PyMemoryViewObject, &PyMemoryView_Type); - if (mview == NULL) + if (PyObject_GetBuffer(base, &view, PyBUF_FULL_RO) < 0) return NULL; - mview->base = NULL; - if (PyObject_GetBuffer(base, &(mview->view), PyBUF_FULL_RO) < 0) { - Py_DECREF(mview); + mview = (PyMemoryViewObject *)PyMemoryView_FromBuffer(&view); + if (mview == NULL) { + PyBuffer_Release(&view); return NULL; } mview->base = base; Py_INCREF(base); - _PyObject_GC_TRACK(mview); return (PyObject *)mview; } From python-checkins at python.org Tue Feb 2 23:54:28 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 22:54:28 -0000 Subject: [Python-checkins] r77921 - in python/trunk/Lib: sysconfig.py test/test_sysconfig.py Message-ID: Author: tarek.ziade Date: Tue Feb 2 23:54:28 2010 New Revision: 77921 Log: sysconfig.get_scheme_names now returns a sorted tuple Modified: python/trunk/Lib/sysconfig.py python/trunk/Lib/test/test_sysconfig.py Modified: python/trunk/Lib/sysconfig.py ============================================================================== --- python/trunk/Lib/sysconfig.py (original) +++ python/trunk/Lib/sysconfig.py Tue Feb 2 23:54:28 2010 @@ -343,7 +343,9 @@ def get_scheme_names(): """Returns a tuple containing the schemes names.""" - return _INSTALL_SCHEMES.keys() + schemes = _INSTALL_SCHEMES.keys() + schemes.sort() + return tuple(schemes) def get_path_names(): """Returns a tuple containing the paths names.""" Modified: python/trunk/Lib/test/test_sysconfig.py ============================================================================== --- python/trunk/Lib/test/test_sysconfig.py (original) +++ python/trunk/Lib/test/test_sysconfig.py Tue Feb 2 23:54:28 2010 @@ -15,7 +15,8 @@ import sysconfig from sysconfig import (get_paths, get_platform, get_config_vars, get_path, get_path_names, _INSTALL_SCHEMES, - _get_default_scheme, _expand_vars) + _get_default_scheme, _expand_vars, + get_scheme_names) class TestSysConfig(unittest.TestCase): @@ -232,6 +233,11 @@ config_h = sysconfig.get_config_h_filename() self.assertTrue(os.path.isfile(config_h), config_h) + def test_get_scheme_names(self): + wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'posix_home', + 'posix_prefix', 'posix_user') + self.assertEquals(get_scheme_names(), wanted) + def test_main(): run_unittest(TestSysConfig) From python-checkins at python.org Tue Feb 2 23:55:00 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 22:55:00 -0000 Subject: [Python-checkins] r77922 - python/trunk/Lib/distutils/sysconfig.py Message-ID: Author: tarek.ziade Date: Tue Feb 2 23:55:00 2010 New Revision: 77922 Log: fixed a typo on distutils.sysconfig. thanks arfever Modified: python/trunk/Lib/distutils/sysconfig.py Modified: python/trunk/Lib/distutils/sysconfig.py ============================================================================== --- python/trunk/Lib/distutils/sysconfig.py (original) +++ python/trunk/Lib/distutils/sysconfig.py Tue Feb 2 23:55:00 2010 @@ -9,7 +9,7 @@ Email: **This module has been moved out of Distutils and will be removed from -Python in the next version (3.2)** +Python in the next version (3.3)** """ __revision__ = "$Id$" From python-checkins at python.org Wed Feb 3 00:00:29 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 02 Feb 2010 23:00:29 -0000 Subject: [Python-checkins] r77923 - python/branches/py3k/Doc/library/sqlite3.rst Message-ID: Author: antoine.pitrou Date: Wed Feb 3 00:00:29 2010 New Revision: 77923 Log: Fix sqlite3 docs. `buffer` is gone, `bytes` objects are returned for BLOBs instead. Patch by Pablo Mouzo. Modified: python/branches/py3k/Doc/library/sqlite3.rst Modified: python/branches/py3k/Doc/library/sqlite3.rst ============================================================================== --- python/branches/py3k/Doc/library/sqlite3.rst (original) +++ python/branches/py3k/Doc/library/sqlite3.rst Wed Feb 3 00:00:29 2010 @@ -187,7 +187,7 @@ Registers a callable to convert the custom Python type *type* into one of SQLite's supported types. The callable *callable* accepts as single parameter the Python value, and must return a value of the following types: int, - float, str, bytes (UTF-8 encoded) or buffer. + float, str or bytes. .. function:: complete_statement(sql) @@ -282,7 +282,7 @@ as the SQL function. The function can return any of the types supported by SQLite: bytes, str, int, - float, buffer and None. + float and None. Example: @@ -298,7 +298,7 @@ final result of the aggregate. The ``finalize`` method can return any of the types supported by SQLite: - bytes, str, int, float, buffer and None. + bytes, str, int, float and None. Example: @@ -633,11 +633,9 @@ +-------------------------------+-------------+ | :class:`float` | ``REAL`` | +-------------------------------+-------------+ -| :class:`bytes` (UTF8-encoded) | ``TEXT`` | -+-------------------------------+-------------+ | :class:`str` | ``TEXT`` | +-------------------------------+-------------+ -| :class:`buffer` | ``BLOB`` | +| :class:`bytes` | ``BLOB`` | +-------------------------------+-------------+ @@ -654,7 +652,7 @@ +-------------+---------------------------------------------+ | ``TEXT`` | depends on text_factory, str by default | +-------------+---------------------------------------------+ -| ``BLOB`` | buffer | +| ``BLOB`` | :class:`bytes` | +-------------+---------------------------------------------+ The type system of the :mod:`sqlite3` module is extensible in two ways: you can @@ -669,7 +667,7 @@ As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must **adapt** them to one of the sqlite3 module's supported types for SQLite: one of NoneType, int, float, -str, bytes, buffer. +str, bytes. The :mod:`sqlite3` module uses Python object adaptation, as described in :pep:`246` for this. The protocol to use is :class:`PrepareProtocol`. From python-checkins at python.org Wed Feb 3 00:01:36 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 02 Feb 2010 23:01:36 -0000 Subject: [Python-checkins] r77924 - in python/branches/release31-maint: Doc/library/sqlite3.rst Message-ID: Author: antoine.pitrou Date: Wed Feb 3 00:01:36 2010 New Revision: 77924 Log: Merged revisions 77923 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r77923 | antoine.pitrou | 2010-02-03 00:00:29 +0100 (mer., 03 f?vr. 2010) | 4 lines Fix sqlite3 docs. `buffer` is gone, `bytes` objects are returned for BLOBs instead. Patch by Pablo Mouzo. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/sqlite3.rst Modified: python/branches/release31-maint/Doc/library/sqlite3.rst ============================================================================== --- python/branches/release31-maint/Doc/library/sqlite3.rst (original) +++ python/branches/release31-maint/Doc/library/sqlite3.rst Wed Feb 3 00:01:36 2010 @@ -187,7 +187,7 @@ Registers a callable to convert the custom Python type *type* into one of SQLite's supported types. The callable *callable* accepts as single parameter the Python value, and must return a value of the following types: int, - float, str, bytes (UTF-8 encoded) or buffer. + float, str or bytes. .. function:: complete_statement(sql) @@ -282,7 +282,7 @@ as the SQL function. The function can return any of the types supported by SQLite: bytes, str, int, - float, buffer and None. + float and None. Example: @@ -298,7 +298,7 @@ final result of the aggregate. The ``finalize`` method can return any of the types supported by SQLite: - bytes, str, int, float, buffer and None. + bytes, str, int, float and None. Example: @@ -633,11 +633,9 @@ +-------------------------------+-------------+ | :class:`float` | ``REAL`` | +-------------------------------+-------------+ -| :class:`bytes` (UTF8-encoded) | ``TEXT`` | -+-------------------------------+-------------+ | :class:`str` | ``TEXT`` | +-------------------------------+-------------+ -| :class:`buffer` | ``BLOB`` | +| :class:`bytes` | ``BLOB`` | +-------------------------------+-------------+ @@ -654,7 +652,7 @@ +-------------+---------------------------------------------+ | ``TEXT`` | depends on text_factory, str by default | +-------------+---------------------------------------------+ -| ``BLOB`` | buffer | +| ``BLOB`` | :class:`bytes` | +-------------+---------------------------------------------+ The type system of the :mod:`sqlite3` module is extensible in two ways: you can @@ -669,7 +667,7 @@ As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must **adapt** them to one of the sqlite3 module's supported types for SQLite: one of NoneType, int, float, -str, bytes, buffer. +str, bytes. The :mod:`sqlite3` module uses Python object adaptation, as described in :pep:`246` for this. The protocol to use is :class:`PrepareProtocol`. From python-checkins at python.org Wed Feb 3 00:16:14 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:16:14 -0000 Subject: [Python-checkins] r77925 - in python/branches/py3k: Lib/distutils/sysconfig.py Lib/sysconfig.py Lib/test/test_sysconfig.py Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:16:13 2010 New Revision: 77925 Log: Merged revisions 77919,77921-77922 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77919 | tarek.ziade | 2010-02-02 23:50:23 +0100 (Tue, 02 Feb 2010) | 1 line module reorganization + missing doctests ........ r77921 | tarek.ziade | 2010-02-02 23:54:28 +0100 (Tue, 02 Feb 2010) | 1 line sysconfig.get_scheme_names now returns a sorted tuple ........ r77922 | tarek.ziade | 2010-02-02 23:55:00 +0100 (Tue, 02 Feb 2010) | 1 line fixed a typo on distutils.sysconfig. thanks arfever ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/sysconfig.py python/branches/py3k/Lib/sysconfig.py python/branches/py3k/Lib/test/test_sysconfig.py Modified: python/branches/py3k/Lib/distutils/sysconfig.py ============================================================================== --- python/branches/py3k/Lib/distutils/sysconfig.py (original) +++ python/branches/py3k/Lib/distutils/sysconfig.py Wed Feb 3 00:16:13 2010 @@ -9,7 +9,7 @@ Email: **This module has been moved out of Distutils and will be removed from -Python in the next version (3.2)** +Python in the next version (3.3)** """ __revision__ = "$Id$" Modified: python/branches/py3k/Lib/sysconfig.py ============================================================================== --- python/branches/py3k/Lib/sysconfig.py (original) +++ python/branches/py3k/Lib/sysconfig.py Wed Feb 3 00:16:13 2010 @@ -239,49 +239,12 @@ vars.update(done) return vars -def parse_config_h(fp, vars=None): - """Parse a config.h-style file. - - A dictionary containing name/value pairs is returned. If an - optional dictionary is passed in as the second argument, it is - used instead of a new dictionary. - """ - import re - if vars is None: - vars = {} - define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n") - undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n") - - while True: - line = fp.readline() - if not line: - break - m = define_rx.match(line) - if m: - n, v = m.group(1, 2) - try: v = int(v) - except ValueError: pass - vars[n] = v - else: - m = undef_rx.match(line) - if m: - vars[m.group(1)] = 0 - return vars def _get_makefile_filename(): if _PYTHON_BUILD: return os.path.join(_PROJECT_BASE, "Makefile") return os.path.join(get_path('stdlib'), "config", "Makefile") -def get_config_h_filename(): - if _PYTHON_BUILD: - if os.name == "nt": - inc_dir = os.path.join(_PROJECT_BASE, "PC") - else: - inc_dir = _PROJECT_BASE - else: - inc_dir = get_path('platinclude') - return os.path.join(inc_dir, 'pyconfig.h') def _init_posix(vars): """Initialize the module as appropriate for POSIX systems.""" @@ -339,10 +302,55 @@ # public APIs # + +def parse_config_h(fp, vars=None): + """Parse a config.h-style file. + + A dictionary containing name/value pairs is returned. If an + optional dictionary is passed in as the second argument, it is + used instead of a new dictionary. + """ + import re + if vars is None: + vars = {} + define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n") + undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n") + + while True: + line = fp.readline() + if not line: + break + m = define_rx.match(line) + if m: + n, v = m.group(1, 2) + try: v = int(v) + except ValueError: pass + vars[n] = v + else: + m = undef_rx.match(line) + if m: + vars[m.group(1)] = 0 + return vars + +def get_config_h_filename(): + """Returns the path of pyconfig.h.""" + if _PYTHON_BUILD: + if os.name == "nt": + inc_dir = os.path.join(_PROJECT_BASE, "PC") + else: + inc_dir = _PROJECT_BASE + else: + inc_dir = get_path('platinclude') + return os.path.join(inc_dir, 'pyconfig.h') + def get_scheme_names(): - return _INSTALL_SCHEMES.keys() + """Returns a tuple containing the schemes names.""" + schemes = list(_INSTALL_SCHEMES.keys()) + schemes.sort() + return tuple(schemes) def get_path_names(): + """Returns a tuple containing the paths names.""" return _SCHEME_KEYS def get_paths(scheme=_get_default_scheme(), vars=None, expand=True): Modified: python/branches/py3k/Lib/test/test_sysconfig.py ============================================================================== --- python/branches/py3k/Lib/test/test_sysconfig.py (original) +++ python/branches/py3k/Lib/test/test_sysconfig.py Wed Feb 3 00:16:13 2010 @@ -15,7 +15,8 @@ import sysconfig from sysconfig import (get_paths, get_platform, get_config_vars, get_path, get_path_names, _INSTALL_SCHEMES, - _get_default_scheme, _expand_vars) + _get_default_scheme, _expand_vars, + get_scheme_names) class TestSysConfig(unittest.TestCase): @@ -232,6 +233,11 @@ config_h = sysconfig.get_config_h_filename() self.assertTrue(os.path.isfile(config_h), config_h) + def test_get_scheme_names(self): + wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'posix_home', + 'posix_prefix', 'posix_user') + self.assertEquals(get_scheme_names(), wanted) + def test_main(): run_unittest(TestSysConfig) From python-checkins at python.org Wed Feb 3 00:17:47 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:17:47 -0000 Subject: [Python-checkins] r77926 - in python/branches/py3k: Doc/library/python.rst Doc/library/sysconfig.rst Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:17:47 2010 New Revision: 77926 Log: Merged revisions 77914 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77914 | tarek.ziade | 2010-02-02 23:27:58 +0100 (Tue, 02 Feb 2010) | 1 line first version of the sysconfig module documentation ........ Added: python/branches/py3k/Doc/library/sysconfig.rst - copied unchanged from r77914, /python/trunk/Doc/library/sysconfig.rst Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/python.rst Modified: python/branches/py3k/Doc/library/python.rst ============================================================================== --- python/branches/py3k/Doc/library/python.rst (original) +++ python/branches/py3k/Doc/library/python.rst Wed Feb 3 00:17:47 2010 @@ -12,6 +12,7 @@ .. toctree:: sys.rst + sysconfig.rst builtins.rst __main__.rst warnings.rst From python-checkins at python.org Wed Feb 3 00:26:30 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:26:30 -0000 Subject: [Python-checkins] r77927 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:26:30 2010 New Revision: 77927 Log: Blocked revisions 77925-77926 via svnmerge ................ r77925 | tarek.ziade | 2010-02-03 00:16:13 +0100 (Wed, 03 Feb 2010) | 17 lines Merged revisions 77919,77921-77922 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77919 | tarek.ziade | 2010-02-02 23:50:23 +0100 (Tue, 02 Feb 2010) | 1 line module reorganization + missing doctests ........ r77921 | tarek.ziade | 2010-02-02 23:54:28 +0100 (Tue, 02 Feb 2010) | 1 line sysconfig.get_scheme_names now returns a sorted tuple ........ r77922 | tarek.ziade | 2010-02-02 23:55:00 +0100 (Tue, 02 Feb 2010) | 1 line fixed a typo on distutils.sysconfig. thanks arfever ........ ................ r77926 | tarek.ziade | 2010-02-03 00:17:47 +0100 (Wed, 03 Feb 2010) | 9 lines Merged revisions 77914 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77914 | tarek.ziade | 2010-02-02 23:27:58 +0100 (Tue, 02 Feb 2010) | 1 line first version of the sysconfig module documentation ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Wed Feb 3 00:31:01 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:31:01 -0000 Subject: [Python-checkins] r77928 - python/branches/py3k/Misc/maintainers.rst Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:31:01 2010 New Revision: 77928 Log: added myself as the maintainer for sysconfig and shutil Modified: python/branches/py3k/Misc/maintainers.rst Modified: python/branches/py3k/Misc/maintainers.rst ============================================================================== --- python/branches/py3k/Misc/maintainers.rst (original) +++ python/branches/py3k/Misc/maintainers.rst Wed Feb 3 00:31:01 2010 @@ -176,7 +176,7 @@ select shelve shlex -shutil +shutil tarek signal site smtpd @@ -196,6 +196,7 @@ symbol symtable benjamin.peterson sys +sysconfig tarek syslog tabnanny tim_one tarfile lars.gustaebel From python-checkins at python.org Wed Feb 3 00:32:39 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:32:39 -0000 Subject: [Python-checkins] r77929 - python/branches/release31-maint/Misc/maintainers.rst Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:32:39 2010 New Revision: 77929 Log: added myself as the maintainer for shutil Modified: python/branches/release31-maint/Misc/maintainers.rst Modified: python/branches/release31-maint/Misc/maintainers.rst ============================================================================== --- python/branches/release31-maint/Misc/maintainers.rst (original) +++ python/branches/release31-maint/Misc/maintainers.rst Wed Feb 3 00:32:39 2010 @@ -178,7 +178,7 @@ select shelve shlex -shutil +shutil tarek signal site smtpd From python-checkins at python.org Wed Feb 3 00:39:40 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:39:40 -0000 Subject: [Python-checkins] r77930 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:39:40 2010 New Revision: 77930 Log: added a note in the whatsnew file for sysconfig Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Wed Feb 3 00:39:40 2010 @@ -842,6 +842,14 @@ .. ====================================================================== .. whole new modules get described in subsections here +* XXX A new :mod:`sysconfig` module has been extracted from :mod:`distutils` + and put in the standard library. + + The :mod:`sysconfig` module provides access to Python's configuration + information like the list of installation paths and the configuration + variables relevant for the current platform. + + Unit Testing Enhancements --------------------------------- From python-checkins at python.org Wed Feb 3 00:40:55 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:40:55 -0000 Subject: [Python-checkins] r77931 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:40:54 2010 New Revision: 77931 Log: Blocked revisions 77930 via svnmerge ........ r77930 | tarek.ziade | 2010-02-03 00:39:40 +0100 (Wed, 03 Feb 2010) | 1 line added a note in the whatsnew file for sysconfig ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Feb 3 00:43:21 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:43:21 -0000 Subject: [Python-checkins] r77932 - in python/branches/py3k: Doc/whatsnew/2.7.rst Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:43:21 2010 New Revision: 77932 Log: Merged revisions 77930 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77930 | tarek.ziade | 2010-02-03 00:39:40 +0100 (Wed, 03 Feb 2010) | 1 line added a note in the whatsnew file for sysconfig ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/whatsnew/2.7.rst Modified: python/branches/py3k/Doc/whatsnew/2.7.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.7.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.7.rst Wed Feb 3 00:43:21 2010 @@ -825,6 +825,14 @@ .. ====================================================================== .. whole new modules get described in subsections here +* XXX A new :mod:`sysconfig` module has been extracted from :mod:`distutils` + and put in the standard library. + + The :mod:`sysconfig` module provides access to Python's configuration + information like the list of installation paths and the configuration + variables relevant for the current platform. + + Unit Testing Enhancements --------------------------------- From python-checkins at python.org Wed Feb 3 00:44:14 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 02 Feb 2010 23:44:14 -0000 Subject: [Python-checkins] r77933 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Wed Feb 3 00:44:14 2010 New Revision: 77933 Log: Blocked revisions 77932 via svnmerge ................ r77932 | tarek.ziade | 2010-02-03 00:43:21 +0100 (Wed, 03 Feb 2010) | 9 lines Merged revisions 77930 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77930 | tarek.ziade | 2010-02-03 00:39:40 +0100 (Wed, 03 Feb 2010) | 1 line added a note in the whatsnew file for sysconfig ........ ................ Modified: python/branches/release31-maint/ (props changed) From solipsis at pitrou.net Wed Feb 3 01:04:39 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 3 Feb 2010 01:04:39 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r77900): sum=0 Message-ID: <20100203000439.2F0961770C@ns6635.ovh.net> py3k results for svn r77900 (hg cset cf2753a0a46a) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogBezUXy', '-x', 'test_httpservers'] From python-checkins at python.org Wed Feb 3 02:13:41 2010 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 03 Feb 2010 01:13:41 -0000 Subject: [Python-checkins] r77934 - in python/branches/py3k: Modules/_testcapimodule.c Message-ID: Author: benjamin.peterson Date: Wed Feb 3 02:13:41 2010 New Revision: 77934 Log: Merged revisions 77866-77867 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77866 | benjamin.peterson | 2010-01-30 17:26:05 -0600 (Sat, 30 Jan 2010) | 1 line move test outside WITH_THREAD section ........ r77867 | benjamin.peterson | 2010-01-30 17:28:38 -0600 (Sat, 30 Jan 2010) | 1 line be robust against test being run over and over (such as -R) ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/_testcapimodule.c Modified: python/branches/py3k/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k/Modules/_testcapimodule.c (original) +++ python/branches/py3k/Modules/_testcapimodule.c Wed Feb 3 02:13:41 2010 @@ -1362,15 +1362,23 @@ return NULL; } -#ifdef WITH_THREAD + +static int test_run_counter = 0; static PyObject * test_datetime_capi(PyObject *self, PyObject *args) { if (PyDateTimeAPI) { - PyErr_SetString(PyExc_AssertionError, - "PyDateTime_CAPI somehow initialized"); - return NULL; + if (test_run_counter) { + /* Probably regrtest.py -R */ + Py_RETURN_NONE; + } + else { + PyErr_SetString(PyExc_AssertionError, + "PyDateTime_CAPI somehow initialized"); + return NULL; + } } + test_run_counter++; PyDateTime_IMPORT; if (PyDateTimeAPI) Py_RETURN_NONE; @@ -1378,6 +1386,9 @@ return NULL; } + +#ifdef WITH_THREAD + /* test_thread_state spawns a thread of its own, and that thread releases * `thread_done` when it's finished. The driver code has to know when the * thread finishes, because the thread uses a PyObject (the callable) that From python-checkins at python.org Wed Feb 3 02:57:04 2010 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 03 Feb 2010 01:57:04 -0000 Subject: [Python-checkins] r77935 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Wed Feb 3 02:57:04 2010 New Revision: 77935 Log: Blocked revisions 77401,77420,77423,77426,77486,77511,77513,77515,77544,77733,77755,77841,77871,77885,77910-77913 via svnmerge ........ r77401 | brett.cannon | 2010-01-09 20:48:50 -0600 (Sat, 09 Jan 2010) | 3 lines Update the version # of Python-ast.c based on the backport of set literals from r77400. ........ r77420 | benjamin.peterson | 2010-01-10 14:42:03 -0600 (Sun, 10 Jan 2010) | 1 line fix test_popen when the path to python has spaces #7671 ........ r77423 | alexandre.vassalotti | 2010-01-11 16:46:43 -0600 (Mon, 11 Jan 2010) | 2 lines Update version information for AST changes in r77422. ........ r77426 | alexandre.vassalotti | 2010-01-11 17:13:49 -0600 (Mon, 11 Jan 2010) | 2 lines Add missing NEWS entry for r77422. ........ r77486 | benjamin.peterson | 2010-01-13 20:40:10 -0600 (Wed, 13 Jan 2010) | 1 line use more robust quoting ........ r77511 | benjamin.peterson | 2010-01-14 20:26:07 -0600 (Thu, 14 Jan 2010) | 1 line try to fix for windows ........ r77513 | vinay.sajip | 2010-01-15 17:27:05 -0600 (Fri, 15 Jan 2010) | 1 line Fixed issue-number mistake in NEWS update. ........ r77515 | sean.reifschneider | 2010-01-15 22:27:58 -0600 (Fri, 15 Jan 2010) | 1 line issue5063: Fixes for building RPM on CentOS plus misc .spec file enhancements. ........ r77544 | ezio.melotti | 2010-01-16 12:38:01 -0600 (Sat, 16 Jan 2010) | 1 line typo: use one instead instead of two ........ r77733 | ezio.melotti | 2010-01-24 15:47:59 -0600 (Sun, 24 Jan 2010) | 1 line #7269: fix failures in test_bsddb3. Patch by Florent Xicluna. ........ r77755 | ezio.melotti | 2010-01-26 09:57:21 -0600 (Tue, 26 Jan 2010) | 1 line #7092: fix DeprecationWarnings for json when the tests are run with -3 -Wd. ........ r77841 | ezio.melotti | 2010-01-30 01:22:54 -0600 (Sat, 30 Jan 2010) | 1 line #7092: silence py3k warnings for deprecated modules ........ r77871 | ezio.melotti | 2010-01-31 05:46:54 -0600 (Sun, 31 Jan 2010) | 1 line #7092: silence more -3 and -Wd warnings ........ r77885 | benjamin.peterson | 2010-01-31 12:02:35 -0600 (Sun, 31 Jan 2010) | 1 line fix windows buildbot ........ r77910 | ezio.melotti | 2010-02-02 02:37:35 -0600 (Tue, 02 Feb 2010) | 1 line #7092: silence py3k warnings for bsddb. Patch by Florent Xicluna. ........ r77911 | ezio.melotti | 2010-02-02 09:12:42 -0600 (Tue, 02 Feb 2010) | 1 line Silence a couple of -3 warnings ........ r77912 | ezio.melotti | 2010-02-02 09:57:45 -0600 (Tue, 02 Feb 2010) | 1 line Fix idioms and a couple of py3k warnings. Patch by Florent Xicluna. ........ r77913 | ezio.melotti | 2010-02-02 11:34:37 -0600 (Tue, 02 Feb 2010) | 1 line #7092: Silence py3k warnings in test_exceptions and test_pep352. Patch by Florent Xicluna. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Wed Feb 3 03:19:14 2010 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 03 Feb 2010 02:19:14 -0000 Subject: [Python-checkins] r77936 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: andrew.kuchling Date: Wed Feb 3 03:19:14 2010 New Revision: 77936 Log: Add various items Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Wed Feb 3 03:19:14 2010 @@ -53,6 +53,11 @@ release of 2.7 is currently scheduled for June 2010; the detailed schedule is described in :pep:`373`. +Python 2.7 is planned to be the last major release in the 2.x series. +Though more major releases have not been absolutely ruled out, it's +likely that the 2.7 release will have an extended period of +maintenance compared to earlier 2.x versions. + .. Compare with previous release in 2 - 3 sentences here. add hyperlink when the documentation becomes available online. @@ -458,10 +463,12 @@ conversion function that supports arbitrary bases. (Patch by Gawain Bolton; :issue:`6713`.) -* The :meth:`rindex`, :meth:`rpartition`, and :meth:`rsplit` methods - of string objects now uses a fast reverse-search algorithm instead of - a character-by-character scan. This is often faster by a factor of 10. - (Added by Florent Xicluna; :issue:`7462`.) +* The :meth:`split`, :meth:`replace`, :meth:`rindex`, + :meth:`rpartition`, and :meth:`rsplit` methods of string-like types + (strings, Unicode strings, and :class:`bytearray` objects) now use a + fast reverse-search algorithm instead of a character-by-character + scan. This is sometimes faster by a factor of 10. (Added by + Florent Xicluna; :issue:`7462` and :issue:`7622`.) * The :mod:`pickle` and :mod:`cPickle` modules now automatically intern the strings used for attribute names, reducing memory usage @@ -648,6 +655,10 @@ recorded in a gzipped file by providing an optional timestamp to the constructor. (Contributed by Jacques Frechet; :issue:`4272`.) + Files in gzip format can be padded with trailing zero bytes; the + :mod:`gzip` module will now consume these trailing bytes. (Fixed by + Tadek Pietraszek and Brian Curtin; :issue:`2846`.) + * The default :class:`HTTPResponse` class used by the :mod:`httplib` module now supports buffering, resulting in much faster reading of HTTP responses. (Contributed by Kristjan Valur Jonsson; :issue:`4879`.) @@ -667,7 +678,9 @@ The :class:`io.FileIO` class now raises an :exc:`OSError` when passed an invalid file descriptor. (Implemented by Benjamin Peterson; - :issue:`4991`.) + :issue:`4991`.) The :meth:`truncate` method now preserves the + file position; previously it would change the file position to the + end of the new file. (Fixed by Pascal Chambon; :issue:`6939`.) * New function: ``itertools.compress(data, selectors)`` takes two iterators. Elements of *data* are returned if the corresponding @@ -723,6 +736,14 @@ passed to the callable. (Contributed by lekma; :issue:`5585`.) + The :class:`Pool` class, which controls a pool of worker processes, + now has an optional *maxtasksperchild* parameter. Worker processes + will perform the specified number of tasks and then exit, causing the + :class:`Pool` to start a new worker. This is useful if tasks may leak + memory or other resources, or if some tasks will cause the worker to + become very large. + (Contributed by Charles Cazabon; :issue:`6963`.) + * The :mod:`nntplib` module now supports IPv6 addresses. (Contributed by Derek Morr; :issue:`1664`.) @@ -735,6 +756,10 @@ contributed by Travis H.; :issue:`6508`. Support for initgroups added by Jean-Paul Calderone; :issue:`7333`.) + The :func:`normpath` function now preserves Unicode; if its input path + is a Unicode string, the return value is also a Unicode string. + (Fixed by Matt Giuca; :issue:`5827`.) + * The :mod:`pydoc` module now has help for the various symbols that Python uses. You can now do ``help('<<')`` or ``help('@')``, for example. (Contributed by David Laban; :issue:`4739`.) @@ -800,8 +825,15 @@ (Contributed by Jeremy Hylton.) * The ``sys.version_info`` value is now a named tuple, with attributes - named ``major``, ``minor``, ``micro``, ``releaselevel``, and ``serial``. - (Contributed by Ross Light; :issue:`4285`.) + named :attr:`major`, :attr:`minor`, :attr:`micro`, + :attr:`releaselevel`, and :attr:`serial`. (Contributed by Ross + Light; :issue:`4285`.) + + :func:`sys.getwindowsversion` also returns a named tuple, + with attributes named :attr:`service_pack_major`, + :attr:`service_pack_minor`, + :attr:`suite_mask`, and :attr:`product_type`. (Contributed by + Brian Curtin; :issue:`7766`.) * The :mod:`tarfile` module's default error handling has changed, to no longer suppress fatal errors. The default error level was previously 0, @@ -828,14 +860,20 @@ a timeout was provided and the operation timed out. (Contributed by Tim Lesher; :issue:`1674032`.) +* The :class:`UserDict` class is now a new-style class. (Changed by + Benjamin Peterson.) + * The :mod:`zipfile` module's :class:`ZipFile` now supports the context management protocol, so you can write ``with zipfile.ZipFile(...) as f: ...``. (Contributed by Brian Curtin; :issue:`5511`.) :mod:`zipfile` now supports archiving empty directories and extracts them correctly. (Fixed by Kuba Wieczorek; :issue:`4710`.) + Reading files out of an archive is now faster, and interleaving + :meth:`read` and :meth:`readline` now works correctly. + (Contributed by Nir Aides; :issue:`7610`.) - The :func:`is_zipfile` function in the :mod:`zipfile` module now + The :func:`is_zipfile` function in the module now accepts a file object, in addition to the path names accepted in earlier versions. (Contributed by Gabriel Genellina; :issue:`4756`.) @@ -1063,10 +1101,12 @@ instruction currently executing, and then look up the line number corresponding to that address. (Added by Jeffrey Yasskin.) -* New function: :cfunc:`PyLong_AsLongAndOverflow` approximates a Python long - integer as a C :ctype:`long`. If the number is too large to fit into - a :ctype:`long`, an *overflow* flag is set and returned to the caller. - (Contributed by Case Van Horsen; :issue:`7528`.) +* New functions: :cfunc:`PyLong_AsLongAndOverflow` and + :cfunc:`PyLong_AsLongLongAndOverflow` approximates a Python long + integer as a C :ctype:`long` or :ctype:`long long`. + If the number is too large to fit into + the output type, an *overflow* flag is set and returned to the caller. + (Contributed by Case Van Horsen; :issue:`7528` and :issue:`7767`.) * New function: stemming from the rewrite of string-to-float conversion, a new :cfunc:`PyOS_string_to_double` function was added. The old From python-checkins at python.org Wed Feb 3 03:35:46 2010 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 03 Feb 2010 02:35:46 -0000 Subject: [Python-checkins] r77937 - in python/branches/py3k: Doc/data/refcounts.dat Doc/distutils/examples.rst Doc/library/datetime.rst Doc/library/ftplib.rst Doc/library/profile.rst Doc/library/unittest.rst Doc/library/xmlrpc.client.rst Doc/reference/datamodel.rst Doc/whatsnew/2.7.rst Lib/decimal.py Lib/test/test_descr.py Lib/test/test_strtod.py Modules/_hashopenssl.c Objects/stringlib/README.txt Message-ID: Author: benjamin.peterson Date: Wed Feb 3 03:35:45 2010 New Revision: 77937 Log: Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines Update PyEval_EvalFrame to PyEval_EvalFrameEx. This looks to have been done partially before. Also add a comment describing how this might have to work with different versions of the interpreter. ........ r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line Fixed typo ........ r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line #7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such. ........ r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line Add note about usage of STRINGLIB_EMPTY. ........ r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line Fix internal reference. ........ r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines data descriptors do not override the class dictionary if __get__ is not defined Adjust documentation and add a test to verify this behavior. See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for discussion. ........ r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines Do not compile stubs for the sha2 series hashes in the openssl hashlib module when the openssl version is too old to support them. That leads both compiled code bloat and to unittests attempting to test implementations that don't exist for comparison purposes on such platforms. ........ r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line Add two more test_strtod test values. ........ r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line #7762: fix refcount annotation of PyUnicode_Tailmatch(). ........ r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line #7725: fix referencing issue. ........ r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line mention from_float() in error message ........ r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line #7802: fix invalid example (heh). ........ r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines Fix-up ftplib documentation: move exception descriptions to toplevel, not inside a class remove attribution in "versionadded" spell and grammar check docstring of FTP_TLS ........ r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line Minor modification to unittest documentation. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/data/refcounts.dat python/branches/py3k/Doc/distutils/examples.rst python/branches/py3k/Doc/library/datetime.rst python/branches/py3k/Doc/library/ftplib.rst python/branches/py3k/Doc/library/profile.rst python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Doc/library/xmlrpc.client.rst python/branches/py3k/Doc/reference/datamodel.rst python/branches/py3k/Doc/whatsnew/2.7.rst python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/test/test_descr.py python/branches/py3k/Lib/test/test_strtod.py python/branches/py3k/Modules/_hashopenssl.c python/branches/py3k/Objects/stringlib/README.txt Modified: python/branches/py3k/Doc/data/refcounts.dat ============================================================================== --- python/branches/py3k/Doc/data/refcounts.dat (original) +++ python/branches/py3k/Doc/data/refcounts.dat Wed Feb 3 03:35:45 2010 @@ -1637,7 +1637,7 @@ PyUnicode_Join:PyObject*:separator:0: PyUnicode_Join:PyObject*:seq:0: -PyUnicode_Tailmatch:PyObject*::+1: +PyUnicode_Tailmatch:int::: PyUnicode_Tailmatch:PyObject*:str:0: PyUnicode_Tailmatch:PyObject*:substr:0: PyUnicode_Tailmatch:int:start:: Modified: python/branches/py3k/Doc/distutils/examples.rst ============================================================================== --- python/branches/py3k/Doc/distutils/examples.rst (original) +++ python/branches/py3k/Doc/distutils/examples.rst Wed Feb 3 03:35:45 2010 @@ -285,8 +285,11 @@ warning: check: Title underline too short. (line 2) warning: check: Could not finish the parsing. + +.. _reading-metadata: + Reading the metadata -===================== +==================== The :func:`distutils.core.setup` function provides a command-line interface that allows you to query the metadata fields of a project through the Modified: python/branches/py3k/Doc/library/datetime.rst ============================================================================== --- python/branches/py3k/Doc/library/datetime.rst (original) +++ python/branches/py3k/Doc/library/datetime.rst Wed Feb 3 03:35:45 2010 @@ -36,7 +36,6 @@ The :mod:`datetime` module exports the following constants: - .. data:: MINYEAR The smallest year number allowed in a :class:`date` or :class:`datetime` object. @@ -61,7 +60,6 @@ Available Types --------------- - .. class:: date :noindex: @@ -131,7 +129,6 @@ A :class:`timedelta` object represents a duration, the difference between two dates or times. - .. class:: timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0) All arguments are optional and default to ``0``. Arguments may be integers @@ -168,8 +165,8 @@ >>> (d.days, d.seconds, d.microseconds) (-1, 86399, 999999) -Class attributes are: +Class attributes are: .. attribute:: timedelta.min @@ -326,16 +323,16 @@ If an argument outside those ranges is given, :exc:`ValueError` is raised. -Other constructors, all class methods: +Other constructors, all class methods: -.. method:: date.today() +.. classmethod:: date.today() Return the current local date. This is equivalent to ``date.fromtimestamp(time.time())``. -.. method:: date.fromtimestamp(timestamp) +.. classmethod:: date.fromtimestamp(timestamp) Return the local date corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. This may raise :exc:`ValueError`, if the timestamp is out @@ -345,15 +342,15 @@ timestamp, leap seconds are ignored by :meth:`fromtimestamp`. -.. method:: date.fromordinal(ordinal) +.. classmethod:: date.fromordinal(ordinal) Return the date corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 <= ordinal <= date.max.toordinal()``. For any date *d*, ``date.fromordinal(d.toordinal()) == d``. -Class attributes: +Class attributes: .. attribute:: date.min @@ -370,8 +367,8 @@ The smallest possible difference between non-equal date objects, ``timedelta(days=1)``. -Instance attributes (read-only): +Instance attributes (read-only): .. attribute:: date.year @@ -387,6 +384,7 @@ Between 1 and the number of days in the given month of the given year. + Supported operations: +-------------------------------+----------------------------------------------+ @@ -439,7 +437,6 @@ Instance methods: - .. method:: date.replace(year, month, day) Return a date with the same value, except for those members given new values by @@ -519,7 +516,8 @@ Return a string representing the date, controlled by an explicit format string. Format codes referring to hours, minutes or seconds will see 0 values. See - section :ref:`strftime-behavior`. + section :ref:`strftime-strptime-behavior`. + Example of counting days to an event:: @@ -586,7 +584,6 @@ Constructor: - .. class:: datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None) The year, month and day arguments are required. *tzinfo* may be ``None``, or an @@ -605,15 +602,14 @@ Other constructors, all class methods: - -.. method:: datetime.today() +.. classmethod:: datetime.today() Return the current local datetime, with :attr:`tzinfo` ``None``. This is equivalent to ``datetime.fromtimestamp(time.time())``. See also :meth:`now`, :meth:`fromtimestamp`. -.. method:: datetime.now(tz=None) +.. classmethod:: datetime.now(tz=None) Return the current local date and time. If optional argument *tz* is ``None`` or not specified, this is like :meth:`today`, but, if possible, supplies more @@ -627,14 +623,14 @@ See also :meth:`today`, :meth:`utcnow`. -.. method:: datetime.utcnow() +.. classmethod:: datetime.utcnow() Return the current UTC date and time, with :attr:`tzinfo` ``None``. This is like :meth:`now`, but returns the current UTC date and time, as a naive :class:`datetime` object. See also :meth:`now`. -.. method:: datetime.fromtimestamp(timestamp, tz=None) +.. classmethod:: datetime.fromtimestamp(timestamp, tz=None) Return the local date and time corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. If optional argument *tz* is ``None`` or not @@ -655,7 +651,7 @@ identical :class:`datetime` objects. See also :meth:`utcfromtimestamp`. -.. method:: datetime.utcfromtimestamp(timestamp) +.. classmethod:: datetime.utcfromtimestamp(timestamp) Return the UTC :class:`datetime` corresponding to the POSIX timestamp, with :attr:`tzinfo` ``None``. This may raise :exc:`ValueError`, if the timestamp is @@ -664,7 +660,7 @@ :meth:`fromtimestamp`. -.. method:: datetime.fromordinal(ordinal) +.. classmethod:: datetime.fromordinal(ordinal) Return the :class:`datetime` corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 @@ -672,7 +668,7 @@ microsecond of the result are all 0, and :attr:`tzinfo` is ``None``. -.. method:: datetime.combine(date, time) +.. classmethod:: datetime.combine(date, time) Return a new :class:`datetime` object whose date members are equal to the given :class:`date` object's, and whose time and :attr:`tzinfo` members are equal to @@ -681,17 +677,17 @@ object, its time and :attr:`tzinfo` members are ignored. -.. method:: datetime.strptime(date_string, format) +.. classmethod:: datetime.strptime(date_string, format) Return a :class:`datetime` corresponding to *date_string*, parsed according to *format*. This is equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. :exc:`ValueError` is raised if the date_string and format can't be parsed by :func:`time.strptime` or if it returns a value which isn't a - time tuple. + time tuple. See section :ref:`strftime-strptime-behavior`. -Class attributes: +Class attributes: .. attribute:: datetime.min @@ -710,8 +706,8 @@ The smallest possible difference between non-equal :class:`datetime` objects, ``timedelta(microseconds=1)``. -Instance attributes (read-only): +Instance attributes (read-only): .. attribute:: datetime.year @@ -753,6 +749,7 @@ The object passed as the *tzinfo* argument to the :class:`datetime` constructor, or ``None`` if none was passed. + Supported operations: +---------------------------------------+-------------------------------+ @@ -826,7 +823,6 @@ Instance methods: - .. method:: datetime.date() Return :class:`date` object with same year, month and day. @@ -1004,7 +1000,8 @@ .. method:: datetime.strftime(format) Return a string representing the date and time, controlled by an explicit format - string. See section :ref:`strftime-behavior`. + string. See section :ref:`strftime-strptime-behavior`. + Examples of working with datetime objects: @@ -1117,7 +1114,6 @@ A time object represents a (local) time of day, independent of any particular day, and subject to adjustment via a :class:`tzinfo` object. - .. class:: time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None) All arguments are optional. *tzinfo* may be ``None``, or an instance of a @@ -1151,8 +1147,8 @@ ``timedelta(microseconds=1)``, although note that arithmetic on :class:`time` objects is not supported. -Instance attributes (read-only): +Instance attributes (read-only): .. attribute:: time.hour @@ -1179,6 +1175,7 @@ The object passed as the tzinfo argument to the :class:`time` constructor, or ``None`` if none was passed. + Supported operations: * comparison of :class:`time` to :class:`time`, where *a* is considered less @@ -1201,8 +1198,8 @@ only if, after converting it to minutes and subtracting :meth:`utcoffset` (or ``0`` if that's ``None``), the result is non-zero. -Instance methods: +Instance methods: .. method:: time.replace([hour[, minute[, second[, microsecond[, tzinfo]]]]]) @@ -1228,7 +1225,7 @@ .. method:: time.strftime(format) Return a string representing the time, controlled by an explicit format string. - See section :ref:`strftime-behavior`. + See section :ref:`strftime-strptime-behavior`. .. method:: time.utcoffset() @@ -1253,6 +1250,7 @@ ``self.tzinfo.tzname(None)``, or raises an exception if the latter doesn't return ``None`` or a string object. + Example: >>> from datetime import time, tzinfo @@ -1389,6 +1387,7 @@ The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`. + These methods are called by a :class:`datetime` or :class:`time` object, in response to their methods of the same names. A :class:`datetime` object passes itself as the argument, and a :class:`time` object passes ``None`` as the @@ -1492,10 +1491,10 @@ EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). -.. _strftime-behavior: +.. _strftime-strptime-behavior: -:meth:`strftime` Behavior -------------------------- +:meth:`strftime` and :meth:`strptime` Behavior +---------------------------------------------- :class:`date`, :class:`datetime`, and :class:`time` objects all support a ``strftime(format)`` method, to create a string representing the time under the @@ -1503,9 +1502,14 @@ acts like the :mod:`time` module's ``time.strftime(fmt, d.timetuple())`` although not all objects support a :meth:`timetuple` method. +Conversely, the :meth:`datetime.strptime` class method creates a +:class:`datetime` object from a string representing a date and time and a +corresponding format string. ``datetime.strptime(date_string, format)`` is +equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. + For :class:`time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900`` -is substituted for the year, and ``0`` for the month and day. +is substituted for the year, and ``1`` for the month and day. For :class:`date` objects, the format codes for hours, minutes, seconds, and microseconds should not be used, as :class:`date` objects have no such @@ -1627,14 +1631,14 @@ Notes: (1) - When used with the :func:`strptime` function, the ``%f`` directive + When used with the :meth:`strptime` method, the ``%f`` directive accepts from one to six digits and zero pads on the right. ``%f`` is an extension to the set of format characters in the C standard (but implemented separately in datetime objects, and therefore always available). (2) - When used with the :func:`strptime` function, the ``%p`` directive only affects + When used with the :meth:`strptime` method, the ``%p`` directive only affects the output hour field if the ``%I`` directive is used to parse the hour. (3) @@ -1642,11 +1646,11 @@ accounts for leap seconds and the (very rare) double leap seconds. The :mod:`time` module may produce and does accept leap seconds since it is based on the Posix standard, but the :mod:`datetime` module - does not accept leap seconds in :func:`strptime` input nor will it + does not accept leap seconds in :meth:`strptime` input nor will it produce them in :func:`strftime` output. (4) - When used with the :func:`strptime` function, ``%U`` and ``%W`` are only used in + When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used in calculations when the day of the week and the year are specified. (5) Modified: python/branches/py3k/Doc/library/ftplib.rst ============================================================================== --- python/branches/py3k/Doc/library/ftplib.rst (original) +++ python/branches/py3k/Doc/library/ftplib.rst Wed Feb 3 03:35:45 2010 @@ -33,8 +33,8 @@ '226 Transfer complete.' >>> ftp.quit() -The module defines the following items: +The module defines the following items: .. class:: FTP(host='', user='', passwd='', acct=''[, timeout]) @@ -51,21 +51,20 @@ A :class:`FTP` subclass which adds TLS support to FTP as described in :rfc:`4217`. Connect as usual to port 21 implicitly securing the FTP control connection - before authenticating. Securing the data connection requires user to - explicitly ask for it by calling :exc:`prot_p()` method. - *keyfile* and *certfile* are optional - they can contain a PEM formatted - private key and certificate chain file for the SSL connection. - - .. versionadded:: 3.2 Contributed by Giampaolo Rodola' + before authenticating. Securing the data connection requires the user to + explicitly ask for it by calling the :meth:`prot_p` method. + *keyfile* and *certfile* are optional -- they can contain a PEM formatted + private key and certificate chain file name for the SSL connection. + .. versionadded:: 3.2 - Here's a sample session using :class:`FTP_TLS` class: + Here's a sample session using the :class:`FTP_TLS` class: >>> from ftplib import FTP_TLS >>> ftps = FTP_TLS('ftp.python.org') - >>> ftps.login() # login anonimously previously securing control channel - >>> ftps.prot_p() # switch to secure data connection - >>> ftps.retrlines('LIST') # list directory content securely + >>> ftps.login() # login anonymously before securing control channel + >>> ftps.prot_p() # switch to secure data connection + >>> ftps.retrlines('LIST') # list directory content securely total 9 drwxr-xr-x 8 root wheel 1024 Jan 3 1994 . drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .. @@ -81,16 +80,6 @@ >>> - - .. attribute:: all_errors - - The set of all exceptions (as a tuple) that methods of :class:`FTP` - instances may raise as a result of problems with the FTP connection (as - opposed to programming errors made by the caller). This set includes the - four exceptions listed below as well as :exc:`socket.error` and - :exc:`IOError`. - - .. exception:: error_reply Exception raised when an unexpected reply is received from the server. @@ -98,19 +87,24 @@ .. exception:: error_temp - Exception raised when an error code in the range 400--499 is received. - + Exception raised when an unexpected reply is received from the server. .. exception:: error_perm Exception raised when an error code in the range 500--599 is received. - .. exception:: error_proto - Exception raised when a reply is received from the server that does not begin - with a digit in the range 1--5. + Exception raised when a reply is received from the server that does not + begin with a digit in the range 1--5. + +.. data:: all_errors + The set of all exceptions (as a tuple) that methods of :class:`FTP` + instances may raise as a result of problems with the FTP connection (as + opposed to programming errors made by the caller). This set includes the + four exceptions listed below as well as :exc:`socket.error` and + :exc:`IOError`. .. seealso:: Modified: python/branches/py3k/Doc/library/profile.rst ============================================================================== --- python/branches/py3k/Doc/library/profile.rst (original) +++ python/branches/py3k/Doc/library/profile.rst Wed Feb 3 03:35:45 2010 @@ -107,7 +107,7 @@ cProfile.py [-o output_file] [-s sort_order] -:option:`-s` only applies to standard output (:option:`-o` is not supplied). +``-s`` only applies to standard output (``-o`` is not supplied). Look in the :class:`Stats` documentation for valid sort values. When you wish to review the profile, you should use the methods in the Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Wed Feb 3 03:35:45 2010 @@ -803,9 +803,9 @@ .. method:: assertSameElements(expected, actual, msg=None) - Test that sequence *expected* contains the same elements as *actual*. - When they don't an error message listing the differences between the - sequences will be generated. + Test that sequence *expected* contains the same elements as *actual*, + regardless of their order. When they don't, an error message listing + the differences between the sequences will be generated. If specified *msg* will be used as the error message on failure. Modified: python/branches/py3k/Doc/library/xmlrpc.client.rst ============================================================================== --- python/branches/py3k/Doc/library/xmlrpc.client.rst (original) +++ python/branches/py3k/Doc/library/xmlrpc.client.rst Wed Feb 3 03:35:45 2010 @@ -383,8 +383,8 @@ import xmlrpc.client - # create a ServerProxy with an invalid URI - proxy = xmlrpc.client.ServerProxy("http://invalidaddress/") + # create a ServerProxy with an URI that doesn't respond to XMLRPC requests + proxy = xmlrpc.client.ServerProxy("http://google.com/") try: proxy.some_method() Modified: python/branches/py3k/Doc/reference/datamodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/datamodel.rst (original) +++ python/branches/py3k/Doc/reference/datamodel.rst Wed Feb 3 03:35:45 2010 @@ -1413,11 +1413,17 @@ ``A.__dict__['m'].__get__(obj, A)``. For instance bindings, the precedence of descriptor invocation depends on the -which descriptor methods are defined. Normally, data descriptors define both -:meth:`__get__` and :meth:`__set__`, while non-data descriptors have just the -:meth:`__get__` method. Data descriptors always override a redefinition in an +which descriptor methods are defined. A descriptor can define any combination +of :meth:`__get__`, :meth:`__set__` and :meth:`__delete__`. If it does not +define :meth:`__get__`, then accessing the attribute will return the descriptor +object itself unless there is a value in the object's instance dictionary. If +the descriptor defines :meth:`__set__` and/or :meth:`__delete__`, it is a data +descriptor; if it defines neither, it is a non-data descriptor. Normally, data +descriptors define both :meth:`__get__` and :meth:`__set__`, while non-data +descriptors have just the :meth:`__get__` method. Data descriptors with +:meth:`__set__` and :meth:`__get__` defined always override a redefinition in an instance dictionary. In contrast, non-data descriptors can be overridden by -instances. [#]_ +instances. Python methods (including :func:`staticmethod` and :func:`classmethod`) are implemented as non-data descriptors. Accordingly, instances can redefine and @@ -2006,13 +2012,6 @@ controlled conditions. It generally isn't a good idea though, since it can lead to some very strange behaviour if it is handled incorrectly. -.. [#] A descriptor can define any combination of :meth:`__get__`, - :meth:`__set__` and :meth:`__delete__`. If it does not define :meth:`__get__`, - then accessing the attribute even on an instance will return the descriptor - object itself. If the descriptor defines :meth:`__set__` and/or - :meth:`__delete__`, it is a data descriptor; if it defines neither, it is a - non-data descriptor. - .. [#] For operands of the same type, it is assumed that if the non-reflected method (such as :meth:`__add__`) fails the operation is not supported, which is why the reflected method is not called. Modified: python/branches/py3k/Doc/whatsnew/2.7.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.7.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.7.rst Wed Feb 3 03:35:45 2010 @@ -612,8 +612,8 @@ The :class:`distutils.dist.DistributionMetadata` class' :meth:`read_pkg_file` method will read the contents of a package's - :file:`PKG-INFO` metadata file. For an example of its use, - XXX link to file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata + :file:`PKG-INFO` metadata file. For an example of its use, see + :ref:`reading-metadata`. (Contributed by Tarek Ziade; :issue:`7457`.) :file:`setup.py` files will now accept a :option:`--no-user-cfg` switch Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Wed Feb 3 03:35:45 2010 @@ -648,8 +648,8 @@ return self if isinstance(value, float): - raise TypeError("Cannot convert float to Decimal. " + - "First convert the float to a string") + raise TypeError("Cannot convert float in Decimal constructor. " + "Use from_float class method.") raise TypeError("Cannot convert %r to Decimal" % value) Modified: python/branches/py3k/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k/Lib/test/test_descr.py (original) +++ python/branches/py3k/Lib/test/test_descr.py Wed Feb 3 03:35:45 2010 @@ -4147,6 +4147,26 @@ c[1:2] = 3 self.assertEqual(c.value, 3) + def test_set_and_no_get(self): + # See + # http://mail.python.org/pipermail/python-dev/2010-January/095637.html + class Descr(object): + + def __init__(self, name): + self.name = name + + def __set__(self, obj, value): + obj.__dict__[self.name] = value + descr = Descr("a") + + class X(object): + a = descr + + x = X() + self.assertIs(x.a, descr) + x.a = 42 + self.assertEqual(x.a, 42) + def test_getattr_hooks(self): # issue 4230 Modified: python/branches/py3k/Lib/test/test_strtod.py ============================================================================== --- python/branches/py3k/Lib/test/test_strtod.py (original) +++ python/branches/py3k/Lib/test/test_strtod.py Wed Feb 3 03:35:45 2010 @@ -313,6 +313,42 @@ '4106250198039490000000000000000000000000000000000000000e-38', # issue 7632 bug 8: the following produced 10.0 '10.900000000000000012345678912345678912345', + + # two humongous values from issue 7743 + '116512874940594195638617907092569881519034793229385' #... + '228569165191541890846564669771714896916084883987920' #... + '473321268100296857636200926065340769682863349205363' #... + '349247637660671783209907949273683040397979984107806' #... + '461822693332712828397617946036239581632976585100633' #... + '520260770761060725403904123144384571612073732754774' #... + '588211944406465572591022081973828448927338602556287' #... + '851831745419397433012491884869454462440536895047499' #... + '436551974649731917170099387762871020403582994193439' #... + '761933412166821484015883631622539314203799034497982' #... + '130038741741727907429575673302461380386596501187482' #... + '006257527709842179336488381672818798450229339123527' #... + '858844448336815912020452294624916993546388956561522' #... + '161875352572590420823607478788399460162228308693742' #... + '05287663441403533948204085390898399055004119873046875e-1075', + + '525440653352955266109661060358202819561258984964913' #... + '892256527849758956045218257059713765874251436193619' #... + '443248205998870001633865657517447355992225852945912' #... + '016668660000210283807209850662224417504752264995360' #... + '631512007753855801075373057632157738752800840302596' #... + '237050247910530538250008682272783660778181628040733' #... + '653121492436408812668023478001208529190359254322340' #... + '397575185248844788515410722958784640926528544043090' #... + '115352513640884988017342469275006999104519620946430' #... + '818767147966495485406577703972687838176778993472989' #... + '561959000047036638938396333146685137903018376496408' #... + '319705333868476925297317136513970189073693314710318' #... + '991252811050501448326875232850600451776091303043715' #... + '157191292827614046876950225714743118291034780466325' #... + '085141343734564915193426994587206432697337118211527' #... + '278968731294639353354774788602467795167875117481660' #... + '4738791256853675690543663283782215866825e-1180', + # exercise exit conditions in bigcomp comparison loop '2602129298404963083833853479113577253105939995688e2', '260212929840496308383385347911357725310593999568896e0', Modified: python/branches/py3k/Modules/_hashopenssl.c ============================================================================== --- python/branches/py3k/Modules/_hashopenssl.c (original) +++ python/branches/py3k/Modules/_hashopenssl.c Wed Feb 3 03:35:45 2010 @@ -49,6 +49,10 @@ #define HASH_OBJ_CONSTRUCTOR 0 #endif +/* Minimum OpenSSL version needed to support sha224 and higher. */ +#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x00908000) +#define _OPENSSL_SUPPORTS_SHA2 +#endif typedef struct { PyObject_HEAD @@ -70,10 +74,12 @@ DEFINE_CONSTS_FOR_NEW(md5) DEFINE_CONSTS_FOR_NEW(sha1) +#ifdef _OPENSSL_SUPPORTS_SHA2 DEFINE_CONSTS_FOR_NEW(sha224) DEFINE_CONSTS_FOR_NEW(sha256) DEFINE_CONSTS_FOR_NEW(sha384) DEFINE_CONSTS_FOR_NEW(sha512) +#endif static EVPobject * @@ -537,10 +543,12 @@ GEN_CONSTRUCTOR(md5) GEN_CONSTRUCTOR(sha1) +#ifdef _OPENSSL_SUPPORTS_SHA2 GEN_CONSTRUCTOR(sha224) GEN_CONSTRUCTOR(sha256) GEN_CONSTRUCTOR(sha384) GEN_CONSTRUCTOR(sha512) +#endif /* List of functions exported by this module */ @@ -548,11 +556,13 @@ {"new", (PyCFunction)EVP_new, METH_VARARGS|METH_KEYWORDS, EVP_new__doc__}, CONSTRUCTOR_METH_DEF(md5), CONSTRUCTOR_METH_DEF(sha1), +#ifdef _OPENSSL_SUPPORTS_SHA2 CONSTRUCTOR_METH_DEF(sha224), CONSTRUCTOR_METH_DEF(sha256), CONSTRUCTOR_METH_DEF(sha384), CONSTRUCTOR_METH_DEF(sha512), - {NULL, NULL} /* Sentinel */ +#endif + {NULL, NULL} /* Sentinel */ }; @@ -599,9 +609,11 @@ /* these constants are used by the convenience constructors */ INIT_CONSTRUCTOR_CONSTANTS(md5); INIT_CONSTRUCTOR_CONSTANTS(sha1); +#ifdef _OPENSSL_SUPPORTS_SHA2 INIT_CONSTRUCTOR_CONSTANTS(sha224); INIT_CONSTRUCTOR_CONSTANTS(sha256); INIT_CONSTRUCTOR_CONSTANTS(sha384); INIT_CONSTRUCTOR_CONSTANTS(sha512); +#endif return m; } Modified: python/branches/py3k/Objects/stringlib/README.txt ============================================================================== --- python/branches/py3k/Objects/stringlib/README.txt (original) +++ python/branches/py3k/Objects/stringlib/README.txt Wed Feb 3 03:35:45 2010 @@ -13,7 +13,8 @@ STRINGLIB_EMPTY - a PyObject representing the empty string + a PyObject representing the empty string, only to be used if + STRINGLIB_MUTABLE is 0 Py_ssize_t STRINGLIB_LEN(PyObject*) @@ -31,9 +32,9 @@ int STRINGLIB_CHECK_EXACT(PyObject *) - returns true if the object is an instance of our type, not a subclass. + returns true if the object is an instance of our type, not a subclass STRINGLIB_MUTABLE - Must be 0 or 1 to tell the cpp macros in stringlib code if the object - being operated on is mutable or not. + must be 0 or 1 to tell the cpp macros in stringlib code if the object + being operated on is mutable or not From python-checkins at python.org Wed Feb 3 03:43:38 2010 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 03 Feb 2010 02:43:38 -0000 Subject: [Python-checkins] r77938 - in python/branches/release31-maint: Doc/data/refcounts.dat Doc/library/datetime.rst Doc/library/profile.rst Doc/library/unittest.rst Doc/library/xmlrpc.client.rst Doc/reference/datamodel.rst Lib/decimal.py Lib/test/test_descr.py Lib/test/test_strtod.py Modules/_hashopenssl.c Objects/stringlib/README.txt Message-ID: Author: benjamin.peterson Date: Wed Feb 3 03:43:37 2010 New Revision: 77938 Log: Merged revisions 77937 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r77937 | benjamin.peterson | 2010-02-02 20:35:45 -0600 (Tue, 02 Feb 2010) | 75 lines Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines Update PyEval_EvalFrame to PyEval_EvalFrameEx. This looks to have been done partially before. Also add a comment describing how this might have to work with different versions of the interpreter. ........ r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line Fixed typo ........ r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line #7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such. ........ r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line Add note about usage of STRINGLIB_EMPTY. ........ r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line Fix internal reference. ........ r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines data descriptors do not override the class dictionary if __get__ is not defined Adjust documentation and add a test to verify this behavior. See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for discussion. ........ r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines Do not compile stubs for the sha2 series hashes in the openssl hashlib module when the openssl version is too old to support them. That leads both compiled code bloat and to unittests attempting to test implementations that don't exist for comparison purposes on such platforms. ........ r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line Add two more test_strtod test values. ........ r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line #7762: fix refcount annotation of PyUnicode_Tailmatch(). ........ r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line #7725: fix referencing issue. ........ r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line mention from_float() in error message ........ r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line #7802: fix invalid example (heh). ........ r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines Fix-up ftplib documentation: move exception descriptions to toplevel, not inside a class remove attribution in "versionadded" spell and grammar check docstring of FTP_TLS ........ r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line Minor modification to unittest documentation. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/data/refcounts.dat python/branches/release31-maint/Doc/library/datetime.rst python/branches/release31-maint/Doc/library/profile.rst python/branches/release31-maint/Doc/library/unittest.rst python/branches/release31-maint/Doc/library/xmlrpc.client.rst python/branches/release31-maint/Doc/reference/datamodel.rst python/branches/release31-maint/Lib/decimal.py python/branches/release31-maint/Lib/test/test_descr.py python/branches/release31-maint/Lib/test/test_strtod.py python/branches/release31-maint/Modules/_hashopenssl.c python/branches/release31-maint/Objects/stringlib/README.txt Modified: python/branches/release31-maint/Doc/data/refcounts.dat ============================================================================== --- python/branches/release31-maint/Doc/data/refcounts.dat (original) +++ python/branches/release31-maint/Doc/data/refcounts.dat Wed Feb 3 03:43:37 2010 @@ -1631,7 +1631,7 @@ PyUnicode_Join:PyObject*:separator:0: PyUnicode_Join:PyObject*:seq:0: -PyUnicode_Tailmatch:PyObject*::+1: +PyUnicode_Tailmatch:int::: PyUnicode_Tailmatch:PyObject*:str:0: PyUnicode_Tailmatch:PyObject*:substr:0: PyUnicode_Tailmatch:int:start:: Modified: python/branches/release31-maint/Doc/library/datetime.rst ============================================================================== --- python/branches/release31-maint/Doc/library/datetime.rst (original) +++ python/branches/release31-maint/Doc/library/datetime.rst Wed Feb 3 03:43:37 2010 @@ -36,7 +36,6 @@ The :mod:`datetime` module exports the following constants: - .. data:: MINYEAR The smallest year number allowed in a :class:`date` or :class:`datetime` object. @@ -61,7 +60,6 @@ Available Types --------------- - .. class:: date :noindex: @@ -131,7 +129,6 @@ A :class:`timedelta` object represents a duration, the difference between two dates or times. - .. class:: timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0) All arguments are optional and default to ``0``. Arguments may be integers @@ -168,8 +165,8 @@ >>> (d.days, d.seconds, d.microseconds) (-1, 86399, 999999) -Class attributes are: +Class attributes are: .. attribute:: timedelta.min @@ -314,16 +311,16 @@ If an argument outside those ranges is given, :exc:`ValueError` is raised. -Other constructors, all class methods: +Other constructors, all class methods: -.. method:: date.today() +.. classmethod:: date.today() Return the current local date. This is equivalent to ``date.fromtimestamp(time.time())``. -.. method:: date.fromtimestamp(timestamp) +.. classmethod:: date.fromtimestamp(timestamp) Return the local date corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. This may raise :exc:`ValueError`, if the timestamp is out @@ -333,15 +330,15 @@ timestamp, leap seconds are ignored by :meth:`fromtimestamp`. -.. method:: date.fromordinal(ordinal) +.. classmethod:: date.fromordinal(ordinal) Return the date corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 <= ordinal <= date.max.toordinal()``. For any date *d*, ``date.fromordinal(d.toordinal()) == d``. -Class attributes: +Class attributes: .. attribute:: date.min @@ -358,8 +355,8 @@ The smallest possible difference between non-equal date objects, ``timedelta(days=1)``. -Instance attributes (read-only): +Instance attributes (read-only): .. attribute:: date.year @@ -375,6 +372,7 @@ Between 1 and the number of days in the given month of the given year. + Supported operations: +-------------------------------+----------------------------------------------+ @@ -427,7 +425,6 @@ Instance methods: - .. method:: date.replace(year, month, day) Return a date with the same value, except for those members given new values by @@ -507,7 +504,8 @@ Return a string representing the date, controlled by an explicit format string. Format codes referring to hours, minutes or seconds will see 0 values. See - section :ref:`strftime-behavior`. + section :ref:`strftime-strptime-behavior`. + Example of counting days to an event:: @@ -574,7 +572,6 @@ Constructor: - .. class:: datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None) The year, month and day arguments are required. *tzinfo* may be ``None``, or an @@ -593,15 +590,14 @@ Other constructors, all class methods: - -.. method:: datetime.today() +.. classmethod:: datetime.today() Return the current local datetime, with :attr:`tzinfo` ``None``. This is equivalent to ``datetime.fromtimestamp(time.time())``. See also :meth:`now`, :meth:`fromtimestamp`. -.. method:: datetime.now(tz=None) +.. classmethod:: datetime.now(tz=None) Return the current local date and time. If optional argument *tz* is ``None`` or not specified, this is like :meth:`today`, but, if possible, supplies more @@ -615,14 +611,14 @@ See also :meth:`today`, :meth:`utcnow`. -.. method:: datetime.utcnow() +.. classmethod:: datetime.utcnow() Return the current UTC date and time, with :attr:`tzinfo` ``None``. This is like :meth:`now`, but returns the current UTC date and time, as a naive :class:`datetime` object. See also :meth:`now`. -.. method:: datetime.fromtimestamp(timestamp, tz=None) +.. classmethod:: datetime.fromtimestamp(timestamp, tz=None) Return the local date and time corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. If optional argument *tz* is ``None`` or not @@ -643,7 +639,7 @@ identical :class:`datetime` objects. See also :meth:`utcfromtimestamp`. -.. method:: datetime.utcfromtimestamp(timestamp) +.. classmethod:: datetime.utcfromtimestamp(timestamp) Return the UTC :class:`datetime` corresponding to the POSIX timestamp, with :attr:`tzinfo` ``None``. This may raise :exc:`ValueError`, if the timestamp is @@ -652,7 +648,7 @@ :meth:`fromtimestamp`. -.. method:: datetime.fromordinal(ordinal) +.. classmethod:: datetime.fromordinal(ordinal) Return the :class:`datetime` corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 @@ -660,7 +656,7 @@ microsecond of the result are all 0, and :attr:`tzinfo` is ``None``. -.. method:: datetime.combine(date, time) +.. classmethod:: datetime.combine(date, time) Return a new :class:`datetime` object whose date members are equal to the given :class:`date` object's, and whose time and :attr:`tzinfo` members are equal to @@ -669,17 +665,17 @@ object, its time and :attr:`tzinfo` members are ignored. -.. method:: datetime.strptime(date_string, format) +.. classmethod:: datetime.strptime(date_string, format) Return a :class:`datetime` corresponding to *date_string*, parsed according to *format*. This is equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. :exc:`ValueError` is raised if the date_string and format can't be parsed by :func:`time.strptime` or if it returns a value which isn't a - time tuple. + time tuple. See section :ref:`strftime-strptime-behavior`. -Class attributes: +Class attributes: .. attribute:: datetime.min @@ -698,8 +694,8 @@ The smallest possible difference between non-equal :class:`datetime` objects, ``timedelta(microseconds=1)``. -Instance attributes (read-only): +Instance attributes (read-only): .. attribute:: datetime.year @@ -741,6 +737,7 @@ The object passed as the *tzinfo* argument to the :class:`datetime` constructor, or ``None`` if none was passed. + Supported operations: +---------------------------------------+-------------------------------+ @@ -814,7 +811,6 @@ Instance methods: - .. method:: datetime.date() Return :class:`date` object with same year, month and day. @@ -992,7 +988,8 @@ .. method:: datetime.strftime(format) Return a string representing the date and time, controlled by an explicit format - string. See section :ref:`strftime-behavior`. + string. See section :ref:`strftime-strptime-behavior`. + Examples of working with datetime objects: @@ -1105,7 +1102,6 @@ A time object represents a (local) time of day, independent of any particular day, and subject to adjustment via a :class:`tzinfo` object. - .. class:: time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None) All arguments are optional. *tzinfo* may be ``None``, or an instance of a @@ -1139,8 +1135,8 @@ ``timedelta(microseconds=1)``, although note that arithmetic on :class:`time` objects is not supported. -Instance attributes (read-only): +Instance attributes (read-only): .. attribute:: time.hour @@ -1167,6 +1163,7 @@ The object passed as the tzinfo argument to the :class:`time` constructor, or ``None`` if none was passed. + Supported operations: * comparison of :class:`time` to :class:`time`, where *a* is considered less @@ -1189,8 +1186,8 @@ only if, after converting it to minutes and subtracting :meth:`utcoffset` (or ``0`` if that's ``None``), the result is non-zero. -Instance methods: +Instance methods: .. method:: time.replace([hour[, minute[, second[, microsecond[, tzinfo]]]]]) @@ -1216,7 +1213,7 @@ .. method:: time.strftime(format) Return a string representing the time, controlled by an explicit format string. - See section :ref:`strftime-behavior`. + See section :ref:`strftime-strptime-behavior`. .. method:: time.utcoffset() @@ -1241,6 +1238,7 @@ ``self.tzinfo.tzname(None)``, or raises an exception if the latter doesn't return ``None`` or a string object. + Example: >>> from datetime import time, tzinfo @@ -1377,6 +1375,7 @@ The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`. + These methods are called by a :class:`datetime` or :class:`time` object, in response to their methods of the same names. A :class:`datetime` object passes itself as the argument, and a :class:`time` object passes ``None`` as the @@ -1480,10 +1479,10 @@ EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). -.. _strftime-behavior: +.. _strftime-strptime-behavior: -:meth:`strftime` Behavior -------------------------- +:meth:`strftime` and :meth:`strptime` Behavior +---------------------------------------------- :class:`date`, :class:`datetime`, and :class:`time` objects all support a ``strftime(format)`` method, to create a string representing the time under the @@ -1491,9 +1490,14 @@ acts like the :mod:`time` module's ``time.strftime(fmt, d.timetuple())`` although not all objects support a :meth:`timetuple` method. +Conversely, the :meth:`datetime.strptime` class method creates a +:class:`datetime` object from a string representing a date and time and a +corresponding format string. ``datetime.strptime(date_string, format)`` is +equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. + For :class:`time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900`` -is substituted for the year, and ``0`` for the month and day. +is substituted for the year, and ``1`` for the month and day. For :class:`date` objects, the format codes for hours, minutes, seconds, and microseconds should not be used, as :class:`date` objects have no such @@ -1615,14 +1619,14 @@ Notes: (1) - When used with the :func:`strptime` function, the ``%f`` directive + When used with the :meth:`strptime` method, the ``%f`` directive accepts from one to six digits and zero pads on the right. ``%f`` is an extension to the set of format characters in the C standard (but implemented separately in datetime objects, and therefore always available). (2) - When used with the :func:`strptime` function, the ``%p`` directive only affects + When used with the :meth:`strptime` method, the ``%p`` directive only affects the output hour field if the ``%I`` directive is used to parse the hour. (3) @@ -1630,11 +1634,11 @@ accounts for leap seconds and the (very rare) double leap seconds. The :mod:`time` module may produce and does accept leap seconds since it is based on the Posix standard, but the :mod:`datetime` module - does not accept leap seconds in :func:`strptime` input nor will it + does not accept leap seconds in :meth:`strptime` input nor will it produce them in :func:`strftime` output. (4) - When used with the :func:`strptime` function, ``%U`` and ``%W`` are only used in + When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used in calculations when the day of the week and the year are specified. (5) Modified: python/branches/release31-maint/Doc/library/profile.rst ============================================================================== --- python/branches/release31-maint/Doc/library/profile.rst (original) +++ python/branches/release31-maint/Doc/library/profile.rst Wed Feb 3 03:43:37 2010 @@ -108,7 +108,7 @@ cProfile.py [-o output_file] [-s sort_order] -:option:`-s` only applies to standard output (:option:`-o` is not supplied). +``-s`` only applies to standard output (``-o`` is not supplied). Look in the :class:`Stats` documentation for valid sort values. When you wish to review the profile, you should use the methods in the Modified: python/branches/release31-maint/Doc/library/unittest.rst ============================================================================== --- python/branches/release31-maint/Doc/library/unittest.rst (original) +++ python/branches/release31-maint/Doc/library/unittest.rst Wed Feb 3 03:43:37 2010 @@ -731,9 +731,9 @@ .. method:: assertSameElements(expected, actual, msg=None) - Test that sequence *expected* contains the same elements as *actual*. - When they don't an error message listing the differences between the - sequences will be generated. + Test that sequence *expected* contains the same elements as *actual*, + regardless of their order. When they don't, an error message listing + the differences between the sequences will be generated. If specified *msg* will be used as the error message on failure. Modified: python/branches/release31-maint/Doc/library/xmlrpc.client.rst ============================================================================== --- python/branches/release31-maint/Doc/library/xmlrpc.client.rst (original) +++ python/branches/release31-maint/Doc/library/xmlrpc.client.rst Wed Feb 3 03:43:37 2010 @@ -383,8 +383,8 @@ import xmlrpc.client - # create a ServerProxy with an invalid URI - proxy = xmlrpc.client.ServerProxy("http://invalidaddress/") + # create a ServerProxy with an URI that doesn't respond to XMLRPC requests + proxy = xmlrpc.client.ServerProxy("http://google.com/") try: proxy.some_method() Modified: python/branches/release31-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release31-maint/Doc/reference/datamodel.rst Wed Feb 3 03:43:37 2010 @@ -1413,11 +1413,17 @@ ``A.__dict__['m'].__get__(obj, A)``. For instance bindings, the precedence of descriptor invocation depends on the -which descriptor methods are defined. Normally, data descriptors define both -:meth:`__get__` and :meth:`__set__`, while non-data descriptors have just the -:meth:`__get__` method. Data descriptors always override a redefinition in an +which descriptor methods are defined. A descriptor can define any combination +of :meth:`__get__`, :meth:`__set__` and :meth:`__delete__`. If it does not +define :meth:`__get__`, then accessing the attribute will return the descriptor +object itself unless there is a value in the object's instance dictionary. If +the descriptor defines :meth:`__set__` and/or :meth:`__delete__`, it is a data +descriptor; if it defines neither, it is a non-data descriptor. Normally, data +descriptors define both :meth:`__get__` and :meth:`__set__`, while non-data +descriptors have just the :meth:`__get__` method. Data descriptors with +:meth:`__set__` and :meth:`__get__` defined always override a redefinition in an instance dictionary. In contrast, non-data descriptors can be overridden by -instances. [#]_ +instances. Python methods (including :func:`staticmethod` and :func:`classmethod`) are implemented as non-data descriptors. Accordingly, instances can redefine and @@ -2006,13 +2012,6 @@ controlled conditions. It generally isn't a good idea though, since it can lead to some very strange behaviour if it is handled incorrectly. -.. [#] A descriptor can define any combination of :meth:`__get__`, - :meth:`__set__` and :meth:`__delete__`. If it does not define :meth:`__get__`, - then accessing the attribute even on an instance will return the descriptor - object itself. If the descriptor defines :meth:`__set__` and/or - :meth:`__delete__`, it is a data descriptor; if it defines neither, it is a - non-data descriptor. - .. [#] For operands of the same type, it is assumed that if the non-reflected method (such as :meth:`__add__`) fails the operation is not supported, which is why the reflected method is not called. Modified: python/branches/release31-maint/Lib/decimal.py ============================================================================== --- python/branches/release31-maint/Lib/decimal.py (original) +++ python/branches/release31-maint/Lib/decimal.py Wed Feb 3 03:43:37 2010 @@ -648,8 +648,8 @@ return self if isinstance(value, float): - raise TypeError("Cannot convert float to Decimal. " + - "First convert the float to a string") + raise TypeError("Cannot convert float in Decimal constructor. " + "Use from_float class method.") raise TypeError("Cannot convert %r to Decimal" % value) Modified: python/branches/release31-maint/Lib/test/test_descr.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_descr.py (original) +++ python/branches/release31-maint/Lib/test/test_descr.py Wed Feb 3 03:43:37 2010 @@ -4159,6 +4159,26 @@ c[1:2] = 3 self.assertEqual(c.value, 3) + def test_set_and_no_get(self): + # See + # http://mail.python.org/pipermail/python-dev/2010-January/095637.html + class Descr(object): + + def __init__(self, name): + self.name = name + + def __set__(self, obj, value): + obj.__dict__[self.name] = value + descr = Descr("a") + + class X(object): + a = descr + + x = X() + self.assertIs(x.a, descr) + x.a = 42 + self.assertEqual(x.a, 42) + def test_getattr_hooks(self): # issue 4230 Modified: python/branches/release31-maint/Lib/test/test_strtod.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_strtod.py (original) +++ python/branches/release31-maint/Lib/test/test_strtod.py Wed Feb 3 03:43:37 2010 @@ -313,6 +313,42 @@ '4106250198039490000000000000000000000000000000000000000e-38', # issue 7632 bug 8: the following produced 10.0 '10.900000000000000012345678912345678912345', + + # two humongous values from issue 7743 + '116512874940594195638617907092569881519034793229385' #... + '228569165191541890846564669771714896916084883987920' #... + '473321268100296857636200926065340769682863349205363' #... + '349247637660671783209907949273683040397979984107806' #... + '461822693332712828397617946036239581632976585100633' #... + '520260770761060725403904123144384571612073732754774' #... + '588211944406465572591022081973828448927338602556287' #... + '851831745419397433012491884869454462440536895047499' #... + '436551974649731917170099387762871020403582994193439' #... + '761933412166821484015883631622539314203799034497982' #... + '130038741741727907429575673302461380386596501187482' #... + '006257527709842179336488381672818798450229339123527' #... + '858844448336815912020452294624916993546388956561522' #... + '161875352572590420823607478788399460162228308693742' #... + '05287663441403533948204085390898399055004119873046875e-1075', + + '525440653352955266109661060358202819561258984964913' #... + '892256527849758956045218257059713765874251436193619' #... + '443248205998870001633865657517447355992225852945912' #... + '016668660000210283807209850662224417504752264995360' #... + '631512007753855801075373057632157738752800840302596' #... + '237050247910530538250008682272783660778181628040733' #... + '653121492436408812668023478001208529190359254322340' #... + '397575185248844788515410722958784640926528544043090' #... + '115352513640884988017342469275006999104519620946430' #... + '818767147966495485406577703972687838176778993472989' #... + '561959000047036638938396333146685137903018376496408' #... + '319705333868476925297317136513970189073693314710318' #... + '991252811050501448326875232850600451776091303043715' #... + '157191292827614046876950225714743118291034780466325' #... + '085141343734564915193426994587206432697337118211527' #... + '278968731294639353354774788602467795167875117481660' #... + '4738791256853675690543663283782215866825e-1180', + # exercise exit conditions in bigcomp comparison loop '2602129298404963083833853479113577253105939995688e2', '260212929840496308383385347911357725310593999568896e0', Modified: python/branches/release31-maint/Modules/_hashopenssl.c ============================================================================== --- python/branches/release31-maint/Modules/_hashopenssl.c (original) +++ python/branches/release31-maint/Modules/_hashopenssl.c Wed Feb 3 03:43:37 2010 @@ -49,6 +49,10 @@ #define HASH_OBJ_CONSTRUCTOR 0 #endif +/* Minimum OpenSSL version needed to support sha224 and higher. */ +#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x00908000) +#define _OPENSSL_SUPPORTS_SHA2 +#endif typedef struct { PyObject_HEAD @@ -70,10 +74,12 @@ DEFINE_CONSTS_FOR_NEW(md5) DEFINE_CONSTS_FOR_NEW(sha1) +#ifdef _OPENSSL_SUPPORTS_SHA2 DEFINE_CONSTS_FOR_NEW(sha224) DEFINE_CONSTS_FOR_NEW(sha256) DEFINE_CONSTS_FOR_NEW(sha384) DEFINE_CONSTS_FOR_NEW(sha512) +#endif static EVPobject * @@ -537,10 +543,12 @@ GEN_CONSTRUCTOR(md5) GEN_CONSTRUCTOR(sha1) +#ifdef _OPENSSL_SUPPORTS_SHA2 GEN_CONSTRUCTOR(sha224) GEN_CONSTRUCTOR(sha256) GEN_CONSTRUCTOR(sha384) GEN_CONSTRUCTOR(sha512) +#endif /* List of functions exported by this module */ @@ -548,11 +556,13 @@ {"new", (PyCFunction)EVP_new, METH_VARARGS|METH_KEYWORDS, EVP_new__doc__}, CONSTRUCTOR_METH_DEF(md5), CONSTRUCTOR_METH_DEF(sha1), +#ifdef _OPENSSL_SUPPORTS_SHA2 CONSTRUCTOR_METH_DEF(sha224), CONSTRUCTOR_METH_DEF(sha256), CONSTRUCTOR_METH_DEF(sha384), CONSTRUCTOR_METH_DEF(sha512), - {NULL, NULL} /* Sentinel */ +#endif + {NULL, NULL} /* Sentinel */ }; @@ -599,9 +609,11 @@ /* these constants are used by the convenience constructors */ INIT_CONSTRUCTOR_CONSTANTS(md5); INIT_CONSTRUCTOR_CONSTANTS(sha1); +#ifdef _OPENSSL_SUPPORTS_SHA2 INIT_CONSTRUCTOR_CONSTANTS(sha224); INIT_CONSTRUCTOR_CONSTANTS(sha256); INIT_CONSTRUCTOR_CONSTANTS(sha384); INIT_CONSTRUCTOR_CONSTANTS(sha512); +#endif return m; } Modified: python/branches/release31-maint/Objects/stringlib/README.txt ============================================================================== --- python/branches/release31-maint/Objects/stringlib/README.txt (original) +++ python/branches/release31-maint/Objects/stringlib/README.txt Wed Feb 3 03:43:37 2010 @@ -13,7 +13,8 @@ STRINGLIB_EMPTY - a PyObject representing the empty string + a PyObject representing the empty string, only to be used if + STRINGLIB_MUTABLE is 0 int STRINGLIB_CMP(STRINGLIB_CHAR*, STRINGLIB_CHAR*, Py_ssize_t) @@ -35,9 +36,9 @@ int STRINGLIB_CHECK_EXACT(PyObject *) - returns true if the object is an instance of our type, not a subclass. + returns true if the object is an instance of our type, not a subclass STRINGLIB_MUTABLE - Must be 0 or 1 to tell the cpp macros in stringlib code if the object - being operated on is mutable or not. + must be 0 or 1 to tell the cpp macros in stringlib code if the object + being operated on is mutable or not From python-checkins at python.org Wed Feb 3 03:46:38 2010 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 03 Feb 2010 02:46:38 -0000 Subject: [Python-checkins] r77939 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Wed Feb 3 03:46:37 2010 New Revision: 77939 Log: Blocked revisions 77607,77609,77679 via svnmerge ........ r77607 | gregory.p.smith | 2010-01-19 02:01:00 -0600 (Tue, 19 Jan 2010) | 6 lines Add a pydebug mode only debug print to help debug the errors in http://www.python.org/dev/buildbot/all/builders/x86%20gentoo%20trunk/builds/5700/ Will be removed shortly. ........ r77609 | gregory.p.smith | 2010-01-19 02:25:26 -0600 (Tue, 19 Jan 2010) | 2 lines Revert debugprint code in r77607. ........ r77679 | matthias.klose | 2010-01-21 18:34:48 -0600 (Thu, 21 Jan 2010) | 2 lines - Mention CVE-2009-3720 for change in r74429. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Wed Feb 3 03:53:11 2010 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 03 Feb 2010 02:53:11 -0000 Subject: [Python-checkins] r77940 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Wed Feb 3 03:53:11 2010 New Revision: 77940 Log: Blocked revisions 77575,77585,77587-77588 via svnmerge ........ r77575 | ronald.oussoren | 2010-01-17 06:38:11 -0600 (Sun, 17 Jan 2010) | 3 lines Add text to Mac/README to warn about non-universal libraries when building a universal Python. Based on issue7679. ........ r77585 | ronald.oussoren | 2010-01-17 10:25:57 -0600 (Sun, 17 Jan 2010) | 12 lines - Issue #7658: Ensure that the new pythonw executable works on OSX 10.4 - Issue #7714: Use ``gcc -dumpversion`` to detect the version of GCC on MacOSX. - Make configure look for util.h as well as libutil.h. The former is the header file that on OSX contains the defition of openpty. (Needed to compile for OSX 10.4 on OSX 10.6) - Use the correct definition of CC to compile the pythonw executable ........ r77587 | ronald.oussoren | 2010-01-17 13:27:57 -0600 (Sun, 17 Jan 2010) | 8 lines This patch ensures that the configure-script mentions checking for --enable-universalsdk and that it doesn't default to the 10.4u SDK when that SDK does not exist. (This affects OSX) This patch should fix most of issue 4834, although I haven't gotten enough information from the user to be sure. ........ r77588 | ronald.oussoren | 2010-01-17 13:32:00 -0600 (Sun, 17 Jan 2010) | 2 lines Explicitly use /usr/bin/arch on OSX, fixes issue 7715 ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Wed Feb 3 03:59:43 2010 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 03 Feb 2010 02:59:43 -0000 Subject: [Python-checkins] r77941 - in python/branches/py3k: Doc/library/language.rst Doc/library/python.rst Doc/library/threading.rst Doc/whatsnew/2.7.rst Lib/decimal.py Lib/distutils/command/bdist_msi.py Lib/distutils/tests/test_bdist_msi.py Lib/test/test_sysconfig.py Message-ID: Author: benjamin.peterson Date: Wed Feb 3 03:59:43 2010 New Revision: 77941 Log: Merged revisions 77712,77740-77741,77756,77886,77902,77936 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77712 | tarek.ziade | 2010-01-23 11:52:57 -0600 (Sat, 23 Jan 2010) | 1 line fixed the 64bits tests for get_platform() - mac osx ........ r77740 | benjamin.peterson | 2010-01-24 21:58:21 -0600 (Sun, 24 Jan 2010) | 1 line compare types with is not == ........ r77741 | facundo.batista | 2010-01-25 00:15:01 -0600 (Mon, 25 Jan 2010) | 3 lines Added a note about Event.is_set() syntax being new to 2.6 ........ r77756 | tarek.ziade | 2010-01-26 11:20:37 -0600 (Tue, 26 Jan 2010) | 1 line fixed bdist_msi imports and added a test module for distutils.command.bdist_msi ........ r77886 | benjamin.peterson | 2010-01-31 12:09:34 -0600 (Sun, 31 Jan 2010) | 1 line move distutils.rst to different toc ........ r77902 | andrew.kuchling | 2010-01-31 20:04:26 -0600 (Sun, 31 Jan 2010) | 1 line Add various items ........ r77936 | andrew.kuchling | 2010-02-02 20:19:14 -0600 (Tue, 02 Feb 2010) | 1 line Add various items ........ Added: python/branches/py3k/Lib/distutils/tests/test_bdist_msi.py - copied unchanged from r77756, /python/trunk/Lib/distutils/tests/test_bdist_msi.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/language.rst python/branches/py3k/Doc/library/python.rst python/branches/py3k/Doc/library/threading.rst python/branches/py3k/Doc/whatsnew/2.7.rst python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/distutils/command/bdist_msi.py python/branches/py3k/Lib/test/test_sysconfig.py Modified: python/branches/py3k/Doc/library/language.rst ============================================================================== --- python/branches/py3k/Doc/library/language.rst (original) +++ python/branches/py3k/Doc/library/language.rst Wed Feb 3 03:59:43 2010 @@ -26,4 +26,3 @@ compileall.rst dis.rst pickletools.rst - distutils.rst Modified: python/branches/py3k/Doc/library/python.rst ============================================================================== --- python/branches/py3k/Doc/library/python.rst (original) +++ python/branches/py3k/Doc/library/python.rst Wed Feb 3 03:59:43 2010 @@ -25,3 +25,4 @@ inspect.rst site.rst fpectl.rst + distutils.rst Modified: python/branches/py3k/Doc/library/threading.rst ============================================================================== --- python/branches/py3k/Doc/library/threading.rst (original) +++ python/branches/py3k/Doc/library/threading.rst Wed Feb 3 03:59:43 2010 @@ -647,6 +647,9 @@ Return true if and only if the internal flag is true. + .. versionchanged:: 2.6 + The ``is_set()`` syntax is new. + .. method:: set() Set the internal flag to true. All threads waiting for it to become true Modified: python/branches/py3k/Doc/whatsnew/2.7.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.7.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.7.rst Wed Feb 3 03:59:43 2010 @@ -6,7 +6,7 @@ :Release: |release| :Date: |today| -.. Fix accents on Kristjan Valur Jonsson, Fuerstenau, Tarek Ziade. +.. Fix accents on Kristjan Valur Jonsson, Fuerstenau .. $Id$ Rules for maintenance: @@ -53,6 +53,11 @@ release of 2.7 is currently scheduled for June 2010; the detailed schedule is described in :pep:`373`. +Python 2.7 is planned to be the last major release in the 2.x series. +Though more major releases have not been absolutely ruled out, it's +likely that the 2.7 release will have an extended period of +maintenance compared to earlier 2.x versions. + .. Compare with previous release in 2 - 3 sentences here. add hyperlink when the documentation becomes available online. @@ -458,10 +463,12 @@ conversion function that supports arbitrary bases. (Patch by Gawain Bolton; :issue:`6713`.) -* The :meth:`rindex`, :meth:`rpartition`, and :meth:`rsplit` methods - of string objects now uses a fast reverse-search algorithm instead of - a character-by-character scan. This is often faster by a factor of 10. - (Added by Florent Xicluna; :issue:`7462`.) +* The :meth:`split`, :meth:`replace`, :meth:`rindex`, + :meth:`rpartition`, and :meth:`rsplit` methods of string-like types + (strings, Unicode strings, and :class:`bytearray` objects) now use a + fast reverse-search algorithm instead of a character-by-character + scan. This is sometimes faster by a factor of 10. (Added by + Florent Xicluna; :issue:`7462` and :issue:`7622`.) * The :mod:`pickle` and :mod:`cPickle` modules now automatically intern the strings used for attribute names, reducing memory usage @@ -585,11 +592,16 @@ left-alignment. This has been changed to right-alignment, which seems more sensible for numeric types. (Changed by Mark Dickinson; :issue:`6857`.) -* Distutils is being more actively developed, thanks to Tarek Ziade - who has taken over maintenance of the package. A new - :file:`setup.py` subcommand, ``check``, will - check that the arguments being passed to the :func:`setup` function - are complete and correct (:issue:`5732`). +* Distutils is being more actively developed, thanks to Tarek Ziad? + who has taken over maintenance of the package, so there are a number + of fixes and improvments. + + A new :file:`setup.py` subcommand, ``check``, will check that the + arguments being passed to the :func:`setup` function are complete + and correct (:issue:`5732`). + + Byte-compilation by the ``install_lib`` subcommand is now only done + if the ``sys.dont_write_bytecode`` setting allows it (:issue:`7071`). :func:`distutils.sdist.add_defaults` now uses *package_dir* and *data_files* to create the MANIFEST file. @@ -601,7 +613,7 @@ It is no longer mandatory to store clear-text passwords in the :file:`.pypirc` file when registering and uploading packages to PyPI. As long as the username is present in that file, the :mod:`distutils` package will - prompt for the password if not present. (Added by Tarek Ziade, + prompt for the password if not present. (Added by Tarek Ziad?, based on an initial contribution by Nathan Van Gheem; :issue:`4394`.) A Distutils setup can now specify that a C extension is optional by @@ -614,7 +626,7 @@ :meth:`read_pkg_file` method will read the contents of a package's :file:`PKG-INFO` metadata file. For an example of its use, see :ref:`reading-metadata`. - (Contributed by Tarek Ziade; :issue:`7457`.) + (Contributed by Tarek Ziad?; :issue:`7457`.) :file:`setup.py` files will now accept a :option:`--no-user-cfg` switch to skip reading the :file:`~/.pydistutils.cfg` file. (Suggested by @@ -643,6 +655,10 @@ recorded in a gzipped file by providing an optional timestamp to the constructor. (Contributed by Jacques Frechet; :issue:`4272`.) + Files in gzip format can be padded with trailing zero bytes; the + :mod:`gzip` module will now consume these trailing bytes. (Fixed by + Tadek Pietraszek and Brian Curtin; :issue:`2846`.) + * The default :class:`HTTPResponse` class used by the :mod:`httplib` module now supports buffering, resulting in much faster reading of HTTP responses. (Contributed by Kristjan Valur Jonsson; :issue:`4879`.) @@ -662,7 +678,9 @@ The :class:`io.FileIO` class now raises an :exc:`OSError` when passed an invalid file descriptor. (Implemented by Benjamin Peterson; - :issue:`4991`.) + :issue:`4991`.) The :meth:`truncate` method now preserves the + file position; previously it would change the file position to the + end of the new file. (Fixed by Pascal Chambon; :issue:`6939`.) * New function: ``itertools.compress(data, selectors)`` takes two iterators. Elements of *data* are returned if the corresponding @@ -718,6 +736,14 @@ passed to the callable. (Contributed by lekma; :issue:`5585`.) + The :class:`Pool` class, which controls a pool of worker processes, + now has an optional *maxtasksperchild* parameter. Worker processes + will perform the specified number of tasks and then exit, causing the + :class:`Pool` to start a new worker. This is useful if tasks may leak + memory or other resources, or if some tasks will cause the worker to + become very large. + (Contributed by Charles Cazabon; :issue:`6963`.) + * The :mod:`nntplib` module now supports IPv6 addresses. (Contributed by Derek Morr; :issue:`1664`.) @@ -730,6 +756,10 @@ contributed by Travis H.; :issue:`6508`. Support for initgroups added by Jean-Paul Calderone; :issue:`7333`.) + The :func:`normpath` function now preserves Unicode; if its input path + is a Unicode string, the return value is also a Unicode string. + (Fixed by Matt Giuca; :issue:`5827`.) + * The :mod:`pydoc` module now has help for the various symbols that Python uses. You can now do ``help('<<')`` or ``help('@')``, for example. (Contributed by David Laban; :issue:`4739`.) @@ -753,7 +783,7 @@ :func:`getuserbase` returns the value of the :envvar:`USER_BASE` environment variable, giving the path to a directory that can be used to store data. - (Contributed by Tarek Ziade; :issue:`6693`.) + (Contributed by Tarek Ziad?; :issue:`6693`.) * The :mod:`socket` module's :class:`SSL` objects now support the buffer API, which fixed a test suite failure. (Fixed by Antoine Pitrou; @@ -795,10 +825,25 @@ (Contributed by Jeremy Hylton.) * The ``sys.version_info`` value is now a named tuple, with attributes - named ``major``, ``minor``, ``micro``, ``releaselevel``, and ``serial``. - (Contributed by Ross Light; :issue:`4285`.) + named :attr:`major`, :attr:`minor`, :attr:`micro`, + :attr:`releaselevel`, and :attr:`serial`. (Contributed by Ross + Light; :issue:`4285`.) + + :func:`sys.getwindowsversion` also returns a named tuple, + with attributes named :attr:`service_pack_major`, + :attr:`service_pack_minor`, + :attr:`suite_mask`, and :attr:`product_type`. (Contributed by + Brian Curtin; :issue:`7766`.) + +* The :mod:`tarfile` module's default error handling has changed, to + no longer suppress fatal errors. The default error level was previously 0, + which meant that errors would only result in a message being written to the + debug log, but because the debug log is not activated by default, + these errors go unnoticed. The default error level is now 1, + which raises an exception if there's an error. + (Changed by Lars Gust?bel; :issue:`7357`.) -* The :mod:`tarfile` module now supports filtering the :class:`TarInfo` + :mod:`tarfile` now supports filtering the :class:`TarInfo` objects being added to a tar file. When you call :meth:`TarFile.add`, instance, you may supply an optional *filter* argument that's a callable. The *filter* callable will be passed the @@ -806,7 +851,7 @@ If the callable returns ``None``, the file will be excluded from the resulting archive. This is more powerful than the existing *exclude* argument, which has therefore been deprecated. - (Added by Lars Gustaebel; :issue:`6856`.) + (Added by Lars Gust?bel; :issue:`6856`.) * The :mod:`threading` module's :meth:`Event.wait` method now returns the internal flag on exit. This means the method will usually @@ -815,12 +860,22 @@ a timeout was provided and the operation timed out. (Contributed by Tim Lesher; :issue:`1674032`.) -* The :func:`is_zipfile` function in the :mod:`zipfile` module now - accepts a file object, in addition to the path names accepted in earlier - versions. (Contributed by Gabriel Genellina; :issue:`4756`.) +* The :class:`UserDict` class is now a new-style class. (Changed by + Benjamin Peterson.) + +* The :mod:`zipfile` module's :class:`ZipFile` now supports the context + management protocol, so you can write ``with zipfile.ZipFile(...) as f: ...``. + (Contributed by Brian Curtin; :issue:`5511`.) :mod:`zipfile` now supports archiving empty directories and extracts them correctly. (Fixed by Kuba Wieczorek; :issue:`4710`.) + Reading files out of an archive is now faster, and interleaving + :meth:`read` and :meth:`readline` now works correctly. + (Contributed by Nir Aides; :issue:`7610`.) + + The :func:`is_zipfile` function in the module now + accepts a file object, in addition to the path names accepted in earlier + versions. (Contributed by Gabriel Genellina; :issue:`4756`.) .. ====================================================================== .. whole new modules get described in subsections here @@ -1046,10 +1101,12 @@ instruction currently executing, and then look up the line number corresponding to that address. (Added by Jeffrey Yasskin.) -* New function: :cfunc:`PyLong_AsLongAndOverflow` approximates a Python long - integer as a C :ctype:`long`. If the number is too large to fit into - a :ctype:`long`, an *overflow* flag is set and returned to the caller. - (Contributed by Case Van Horsen; :issue:`7528`.) +* New functions: :cfunc:`PyLong_AsLongAndOverflow` and + :cfunc:`PyLong_AsLongLongAndOverflow` approximates a Python long + integer as a C :ctype:`long` or :ctype:`long long`. + If the number is too large to fit into + the output type, an *overflow* flag is set and returned to the caller. + (Contributed by Case Van Horsen; :issue:`7528` and :issue:`7767`.) * New function: stemming from the rewrite of string-to-float conversion, a new :cfunc:`PyOS_string_to_double` function was added. The old Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Wed Feb 3 03:59:43 2010 @@ -3600,12 +3600,12 @@ return (self.__class__, (str(self),)) def __copy__(self): - if type(self) == Decimal: + if type(self) is Decimal: return self # I'm immutable; therefore I am my own clone return self.__class__(str(self)) def __deepcopy__(self, memo): - if type(self) == Decimal: + if type(self) is Decimal: return self # My components are also immutable return self.__class__(str(self)) Modified: python/branches/py3k/Lib/distutils/command/bdist_msi.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/bdist_msi.py (original) +++ python/branches/py3k/Lib/distutils/command/bdist_msi.py Wed Feb 3 03:59:43 2010 @@ -7,15 +7,12 @@ Implements the bdist_msi command. """ import sys, os -from sysconfig import get_python_version +from sysconfig import get_python_version, get_platform -import sys, os from distutils.core import Command from distutils.dir_util import remove_tree -from distutils.sysconfig import get_python_version from distutils.version import StrictVersion from distutils.errors import DistutilsOptionError -from distutils.util import get_platform from distutils import log import msilib Modified: python/branches/py3k/Lib/test/test_sysconfig.py ============================================================================== --- python/branches/py3k/Lib/test/test_sysconfig.py (original) +++ python/branches/py3k/Lib/test/test_sysconfig.py Wed Feb 3 03:59:43 2010 @@ -145,14 +145,14 @@ get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' '-fwrapv -O3 -Wall -Wstrict-prototypes') - maxsize = sys.maxsize + maxint = sys.maxsize try: sys.maxsize = 2147483647 self.assertEquals(get_platform(), 'macosx-10.3-ppc') sys.maxsize = 9223372036854775807 self.assertEquals(get_platform(), 'macosx-10.3-ppc64') finally: - sys.maxsize = maxsize + sys.maxsize = maxint self._set_uname(('Darwin', 'macziade', '8.11.1', @@ -164,15 +164,14 @@ get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' '-fwrapv -O3 -Wall -Wstrict-prototypes') - - maxsize = sys.maxsize + maxint = sys.maxsize try: sys.maxsize = 2147483647 self.assertEquals(get_platform(), 'macosx-10.3-i386') sys.maxsize = 9223372036854775807 self.assertEquals(get_platform(), 'macosx-10.3-x86_64') finally: - sys.maxsize = maxsize + sys.maxsize = maxint # macbook with fat binaries (fat, universal or fat64) os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4' From python-checkins at python.org Wed Feb 3 06:37:27 2010 From: python-checkins at python.org (ezio.melotti) Date: Wed, 03 Feb 2010 05:37:27 -0000 Subject: [Python-checkins] r77942 - in python/trunk/Lib: ctypes/test/test_structures.py email/test/test_email.py email/test/test_email_renamed.py sqlite3/test/types.py sqlite3/test/userfunctions.py test/infinite_reload.py test/inspect_fodder.py test/regrtest.py test/test_binop.py test/test_capi.py test/test_compiler.py test/test_copy.py test/test_descrtut.py test/test_file.py test/test_fractions.py test/test_ftplib.py test/test_functools.py test/test_gzip.py test/test_import.py test/test_io.py test/test_itertools.py test/test_multibytecodec_support.py test/test_mutants.py test/test_optparse.py test/test_ossaudiodev.py test/test_pkgimport.py test/test_pyexpat.py test/test_queue.py test/test_random.py test/test_rfc822.py test/test_site.py test/test_threadsignals.py test/test_trace.py test/test_traceback.py test/test_with.py test/test_wsgiref.py test/test_xml_etree.py test/test_xml_etree_c.py test/test_xpickle.py Message-ID: Author: ezio.melotti Date: Wed Feb 3 06:37:26 2010 New Revision: 77942 Log: #7092: Silence more py3k warnings. Patch by Florent Xicluna. Modified: python/trunk/Lib/ctypes/test/test_structures.py python/trunk/Lib/email/test/test_email.py python/trunk/Lib/email/test/test_email_renamed.py python/trunk/Lib/sqlite3/test/types.py python/trunk/Lib/sqlite3/test/userfunctions.py python/trunk/Lib/test/infinite_reload.py python/trunk/Lib/test/inspect_fodder.py python/trunk/Lib/test/regrtest.py python/trunk/Lib/test/test_binop.py python/trunk/Lib/test/test_capi.py python/trunk/Lib/test/test_compiler.py python/trunk/Lib/test/test_copy.py python/trunk/Lib/test/test_descrtut.py python/trunk/Lib/test/test_file.py python/trunk/Lib/test/test_fractions.py python/trunk/Lib/test/test_ftplib.py python/trunk/Lib/test/test_functools.py python/trunk/Lib/test/test_gzip.py python/trunk/Lib/test/test_import.py python/trunk/Lib/test/test_io.py python/trunk/Lib/test/test_itertools.py python/trunk/Lib/test/test_multibytecodec_support.py python/trunk/Lib/test/test_mutants.py python/trunk/Lib/test/test_optparse.py python/trunk/Lib/test/test_ossaudiodev.py python/trunk/Lib/test/test_pkgimport.py python/trunk/Lib/test/test_pyexpat.py python/trunk/Lib/test/test_queue.py python/trunk/Lib/test/test_random.py python/trunk/Lib/test/test_rfc822.py python/trunk/Lib/test/test_site.py python/trunk/Lib/test/test_threadsignals.py python/trunk/Lib/test/test_trace.py python/trunk/Lib/test/test_traceback.py python/trunk/Lib/test/test_with.py python/trunk/Lib/test/test_wsgiref.py python/trunk/Lib/test/test_xml_etree.py python/trunk/Lib/test/test_xml_etree_c.py python/trunk/Lib/test/test_xpickle.py Modified: python/trunk/Lib/ctypes/test/test_structures.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_structures.py (original) +++ python/trunk/Lib/ctypes/test/test_structures.py Wed Feb 3 06:37:26 2010 @@ -367,11 +367,11 @@ _fields_ = [("d", c_int), ("e", c_int), ("f", c_int)] z = Z(1, 2, 3, 4, 5, 6) - self.failUnlessEqual((z.a, z.b, z.c, z.d, z.e, z.f), - (1, 2, 3, 4, 5, 6)) + self.assertEqual((z.a, z.b, z.c, z.d, z.e, z.f), + (1, 2, 3, 4, 5, 6)) z = Z(1) - self.failUnlessEqual((z.a, z.b, z.c, z.d, z.e, z.f), - (1, 0, 0, 0, 0, 0)) + self.assertEqual((z.a, z.b, z.c, z.d, z.e, z.f), + (1, 0, 0, 0, 0, 0)) self.assertRaises(TypeError, lambda: Z(1, 2, 3, 4, 5, 6, 7)) class PointerMemberTestCase(unittest.TestCase): Modified: python/trunk/Lib/email/test/test_email.py ============================================================================== --- python/trunk/Lib/email/test/test_email.py (original) +++ python/trunk/Lib/email/test/test_email.py Wed Feb 3 06:37:26 2010 @@ -1055,7 +1055,7 @@ sign = '-' else: sign = '+' - tzoffset = ' %s%04d' % (sign, tzsecs / 36) + tzoffset = ' %s%04d' % (sign, tzsecs // 36) container['Date'] = time.strftime( '%a, %d %b %Y %H:%M:%S', time.localtime(now)) + tzoffset Modified: python/trunk/Lib/email/test/test_email_renamed.py ============================================================================== --- python/trunk/Lib/email/test/test_email_renamed.py (original) +++ python/trunk/Lib/email/test/test_email_renamed.py Wed Feb 3 06:37:26 2010 @@ -1053,7 +1053,7 @@ sign = '-' else: sign = '+' - tzoffset = ' %s%04d' % (sign, tzsecs / 36) + tzoffset = ' %s%04d' % (sign, tzsecs // 36) container['Date'] = time.strftime( '%a, %d %b %Y %H:%M:%S', time.localtime(now)) + tzoffset Modified: python/trunk/Lib/sqlite3/test/types.py ============================================================================== --- python/trunk/Lib/sqlite3/test/types.py (original) +++ python/trunk/Lib/sqlite3/test/types.py Wed Feb 3 06:37:26 2010 @@ -231,7 +231,7 @@ sqlite.converters["FOO"] = lambda x: "[%s]" % x sqlite.converters["BAR"] = lambda x: "<%s>" % x - sqlite.converters["EXC"] = lambda x: 5/0 + sqlite.converters["EXC"] = lambda x: 5 // 0 sqlite.converters["B1B1"] = lambda x: "MARKER" def tearDown(self): Modified: python/trunk/Lib/sqlite3/test/userfunctions.py ============================================================================== --- python/trunk/Lib/sqlite3/test/userfunctions.py (original) +++ python/trunk/Lib/sqlite3/test/userfunctions.py Wed Feb 3 06:37:26 2010 @@ -38,7 +38,7 @@ def func_returnblob(): return buffer("blob") def func_raiseexception(): - 5/0 + 5 // 0 def func_isstring(v): return type(v) is unicode @@ -67,7 +67,7 @@ class AggrExceptionInInit: def __init__(self): - 5/0 + 5 // 0 def step(self, x): pass @@ -80,7 +80,7 @@ pass def step(self, x): - 5/0 + 5 // 0 def finalize(self): return 42 @@ -93,7 +93,7 @@ pass def finalize(self): - 5/0 + 5 // 0 class AggrCheckType: def __init__(self): Modified: python/trunk/Lib/test/infinite_reload.py ============================================================================== --- python/trunk/Lib/test/infinite_reload.py (original) +++ python/trunk/Lib/test/infinite_reload.py Wed Feb 3 06:37:26 2010 @@ -3,5 +3,6 @@ # reload()ing. This module is imported by test_import.py:test_infinite_reload # to make sure this doesn't happen any more. +import imp import infinite_reload -reload(infinite_reload) +imp.reload(infinite_reload) Modified: python/trunk/Lib/test/inspect_fodder.py ============================================================================== --- python/trunk/Lib/test/inspect_fodder.py (original) +++ python/trunk/Lib/test/inspect_fodder.py Wed Feb 3 06:37:26 2010 @@ -15,7 +15,7 @@ fr = inspect.currentframe() st = inspect.stack() p = x - q = y / 0 + q = y // 0 # line 20 class StupidGit: Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Wed Feb 3 06:37:26 2010 @@ -159,6 +159,7 @@ import traceback import warnings import unittest +import imp # Ignore ImportWarnings that only occur in the source tree, @@ -955,7 +956,7 @@ indirect_test() else: def run_the_test(): - reload(the_module) + imp.reload(the_module) deltas = [] nwarmup, ntracked, fname = huntrleaks Modified: python/trunk/Lib/test/test_binop.py ============================================================================== --- python/trunk/Lib/test/test_binop.py (original) +++ python/trunk/Lib/test/test_binop.py Wed Feb 3 06:37:26 2010 @@ -207,6 +207,9 @@ """Compare two Rats for inequality.""" return not self == other + # Silence Py3k warning + __hash__ = None + class RatTestCase(unittest.TestCase): """Unit tests for Rat class and its support utilities.""" Modified: python/trunk/Lib/test/test_capi.py ============================================================================== --- python/trunk/Lib/test/test_capi.py (original) +++ python/trunk/Lib/test/test_capi.py Wed Feb 3 06:37:26 2010 @@ -55,7 +55,7 @@ context = foo() context.l = [] context.n = 2 #submits per thread - context.nThreads = n / context.n + context.nThreads = n // context.n context.nFinished = 0 context.lock = threading.Lock() context.event = threading.Event() Modified: python/trunk/Lib/test/test_compiler.py ============================================================================== --- python/trunk/Lib/test/test_compiler.py (original) +++ python/trunk/Lib/test/test_compiler.py Wed Feb 3 06:37:26 2010 @@ -75,7 +75,7 @@ def testTryExceptFinally(self): # Test that except and finally clauses in one try stmt are recognized - c = compiler.compile("try:\n 1/0\nexcept:\n e = 1\nfinally:\n f = 1", + c = compiler.compile("try:\n 1//0\nexcept:\n e = 1\nfinally:\n f = 1", "", "exec") dct = {} exec c in dct Modified: python/trunk/Lib/test/test_copy.py ============================================================================== --- python/trunk/Lib/test/test_copy.py (original) +++ python/trunk/Lib/test/test_copy.py Wed Feb 3 06:37:26 2010 @@ -661,7 +661,7 @@ v = copy.deepcopy(u) self.assertNotEqual(v, u) self.assertEqual(len(v), 2) - (x, y), (z, t) = sorted(v.items(), key=lambda (k, v): k.i) + (x, y), (z, t) = sorted(v.items(), key=lambda pair: pair[0].i) self.assertFalse(x is a) self.assertEqual(x.i, a.i) self.assertTrue(y is b) Modified: python/trunk/Lib/test/test_descrtut.py ============================================================================== --- python/trunk/Lib/test/test_descrtut.py (original) +++ python/trunk/Lib/test/test_descrtut.py Wed Feb 3 06:37:26 2010 @@ -66,7 +66,7 @@ statement or the built-in function eval(): >>> def sorted(seq): - ... seq.sort() + ... seq.sort(key=str) ... return seq >>> print sorted(a.keys()) [1, 2] Modified: python/trunk/Lib/test/test_file.py ============================================================================== --- python/trunk/Lib/test/test_file.py (original) +++ python/trunk/Lib/test/test_file.py Wed Feb 3 06:37:26 2010 @@ -127,7 +127,7 @@ self.assertEquals(self.f.__exit__(None, None, None), None) # it must also return None if an exception was given try: - 1/0 + 1 // 0 except: self.assertEquals(self.f.__exit__(*sys.exc_info()), None) Modified: python/trunk/Lib/test/test_fractions.py ============================================================================== --- python/trunk/Lib/test/test_fractions.py (original) +++ python/trunk/Lib/test/test_fractions.py Wed Feb 3 06:37:26 2010 @@ -43,6 +43,9 @@ assert False, "__sub__ should not be invoked for comparisons" __rsub__ = __sub__ + # Silence Py3k warning + __hash__ = None + class DummyRational(object): """Test comparison of Fraction with a naive rational implementation.""" @@ -76,6 +79,10 @@ def __float__(self): assert False, "__float__ should not be invoked" + # Silence Py3k warning + __hash__ = None + + class GcdTest(unittest.TestCase): def testMisc(self): Modified: python/trunk/Lib/test/test_ftplib.py ============================================================================== --- python/trunk/Lib/test/test_ftplib.py (original) +++ python/trunk/Lib/test/test_ftplib.py Wed Feb 3 06:37:26 2010 @@ -100,7 +100,8 @@ sock.listen(5) sock.settimeout(2) ip, port = sock.getsockname()[:2] - ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256 + ip = ip.replace('.', ',') + p1, p2 = divmod(port, 256) self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2)) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) Modified: python/trunk/Lib/test/test_functools.py ============================================================================== --- python/trunk/Lib/test/test_functools.py (original) +++ python/trunk/Lib/test/test_functools.py Wed Feb 3 06:37:26 2010 @@ -116,7 +116,7 @@ def test_error_propagation(self): def f(x, y): - x / y + x // y self.assertRaises(ZeroDivisionError, self.thetype(f, 1, 0)) self.assertRaises(ZeroDivisionError, self.thetype(f, 1), 0) self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0) Modified: python/trunk/Lib/test/test_gzip.py ============================================================================== --- python/trunk/Lib/test/test_gzip.py (original) +++ python/trunk/Lib/test/test_gzip.py Wed Feb 3 06:37:26 2010 @@ -246,11 +246,11 @@ self.fail("__enter__ on a closed file didn't raise an exception") try: with gzip.GzipFile(self.filename, "wb") as f: - 1/0 + 1 // 0 except ZeroDivisionError: pass else: - self.fail("1/0 didn't raise an exception") + self.fail("1 // 0 didn't raise an exception") def test_zero_padded_file(self): with gzip.GzipFile(self.filename, "wb") as f: Modified: python/trunk/Lib/test/test_import.py ============================================================================== --- python/trunk/Lib/test/test_import.py (original) +++ python/trunk/Lib/test/test_import.py Wed Feb 3 06:37:26 2010 @@ -7,6 +7,7 @@ import py_compile import warnings import marshal +import imp from test.test_support import (unlink, TESTFN, unload, run_unittest, check_warnings, TestFailed, EnvironmentVarGuard) @@ -56,11 +57,10 @@ f.close() try: - try: - mod = __import__(TESTFN) - except ImportError, err: - self.fail("import from %s failed: %s" % (ext, err)) - + mod = __import__(TESTFN) + except ImportError, err: + self.fail("import from %s failed: %s" % (ext, err)) + else: self.assertEquals(mod.a, a, "module loaded (%s) but contents invalid" % mod) self.assertEquals(mod.b, b, @@ -69,10 +69,9 @@ os.unlink(source) try: - try: - reload(mod) - except ImportError, err: - self.fail("import from .pyc/.pyo failed: %s" % err) + imp.reload(mod) + except ImportError, err: + self.fail("import from .pyc/.pyo failed: %s" % err) finally: try: os.unlink(pyc) @@ -121,7 +120,7 @@ def testImpModule(self): # Verify that the imp module can correctly load and find .py files - import imp, os + # XXX (ncoghlan): It would be nice to use test_support.CleanImport # here, but that breaks because the os module registers some # handlers in copy_reg on import. Since CleanImport doesn't @@ -172,7 +171,7 @@ def test_failing_import_sticks(self): source = TESTFN + os.extsep + "py" f = open(source, "w") - print >> f, "a = 1/0" + print >> f, "a = 1 // 0" f.close() # New in 2.4, we shouldn't be able to import that no matter how often @@ -218,7 +217,7 @@ print >> f, "b = 20//0" f.close() - self.assertRaises(ZeroDivisionError, reload, mod) + self.assertRaises(ZeroDivisionError, imp.reload, mod) # But we still expect the module to be in sys.modules. mod = sys.modules.get(TESTFN) Modified: python/trunk/Lib/test/test_io.py ============================================================================== --- python/trunk/Lib/test/test_io.py (original) +++ python/trunk/Lib/test/test_io.py Wed Feb 3 06:37:26 2010 @@ -387,11 +387,11 @@ f = None try: with self.open(support.TESTFN, "wb", bufsize) as f: - 1/0 + 1 // 0 except ZeroDivisionError: self.assertEqual(f.closed, True) else: - self.fail("1/0 didn't raise an exception") + self.fail("1 // 0 didn't raise an exception") # issue 5008 def test_append_mode_tell(self): Modified: python/trunk/Lib/test/test_itertools.py ============================================================================== --- python/trunk/Lib/test/test_itertools.py (original) +++ python/trunk/Lib/test/test_itertools.py Wed Feb 3 06:37:26 2010 @@ -9,6 +9,7 @@ import random import copy import pickle +from functools import reduce maxsize = test_support.MAX_Py_ssize_t minsize = -maxsize-1 @@ -122,7 +123,7 @@ values = [5*x-12 for x in range(n)] for r in range(n+2): result = list(combinations(values, r)) - self.assertEqual(len(result), 0 if r>n else fact(n) / fact(r) / fact(n-r)) # right number of combs + self.assertEqual(len(result), 0 if r>n else fact(n) // fact(r) // fact(n-r)) # right number of combs self.assertEqual(len(result), len(set(result))) # no repeats self.assertEqual(result, sorted(result)) # lexicographic order for c in result: @@ -178,7 +179,7 @@ def numcombs(n, r): if not n: return 0 if r else 1 - return fact(n+r-1) / fact(r)/ fact(n-1) + return fact(n+r-1) // fact(r) // fact(n-1) for n in range(7): values = [5*x-12 for x in range(n)] @@ -257,7 +258,7 @@ values = [5*x-12 for x in range(n)] for r in range(n+2): result = list(permutations(values, r)) - self.assertEqual(len(result), 0 if r>n else fact(n) / fact(n-r)) # right number of perms + self.assertEqual(len(result), 0 if r>n else fact(n) // fact(n-r)) # right number of perms self.assertEqual(len(result), len(set(result))) # no repeats self.assertEqual(result, sorted(result)) # lexicographic order for p in result: @@ -288,9 +289,9 @@ # Check size self.assertEquals(len(prod), n**r) - self.assertEquals(len(cwr), (fact(n+r-1) / fact(r)/ fact(n-1)) if n else (not r)) - self.assertEquals(len(perm), 0 if r>n else fact(n) / fact(n-r)) - self.assertEquals(len(comb), 0 if r>n else fact(n) / fact(r) / fact(n-r)) + self.assertEquals(len(cwr), (fact(n+r-1) // fact(r) // fact(n-1)) if n else (not r)) + self.assertEquals(len(perm), 0 if r>n else fact(n) // fact(n-r)) + self.assertEquals(len(comb), 0 if r>n else fact(n) // fact(r) // fact(n-r)) # Check lexicographic order without repeated tuples self.assertEquals(prod, sorted(set(prod))) @@ -543,7 +544,10 @@ [range(1000), range(0), range(3000,3050), range(1200), range(1500)], [range(1000), range(0), range(3000,3050), range(1200), range(1500), range(0)], ]: - target = map(None, *args) + # target = map(None, *args) <- this raises a py3k warning + # this is the replacement: + target = [tuple([arg[i] if i < len(arg) else None for arg in args]) + for i in range(max(map(len, args)))] self.assertEqual(list(izip_longest(*args)), target) self.assertEqual(list(izip_longest(*args, **{})), target) target = [tuple((e is None and 'X' or e) for e in t) for t in target] # Replace None fills with 'X' @@ -555,7 +559,8 @@ self.assertEqual(list(izip_longest([])), zip([])) self.assertEqual(list(izip_longest('abcdef')), zip('abcdef')) - self.assertEqual(list(izip_longest('abc', 'defg', **{})), map(None, 'abc', 'defg')) # empty keyword dict + self.assertEqual(list(izip_longest('abc', 'defg', **{})), + zip(list('abc') + [None], 'defg')) # empty keyword dict self.assertRaises(TypeError, izip_longest, 3) self.assertRaises(TypeError, izip_longest, range(3), 3) @@ -1431,7 +1436,7 @@ # is differencing with a range so that consecutive numbers all appear in # same group. >>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28] ->>> for k, g in groupby(enumerate(data), lambda (i,x):i-x): +>>> for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]): ... print map(operator.itemgetter(1), g) ... [1] Modified: python/trunk/Lib/test/test_multibytecodec_support.py ============================================================================== --- python/trunk/Lib/test/test_multibytecodec_support.py (original) +++ python/trunk/Lib/test/test_multibytecodec_support.py Wed Feb 3 06:37:26 2010 @@ -307,7 +307,7 @@ continue unich = unichrs(data[1]) - if ord(unich) == 0xfffd or urt_wa.has_key(unich): + if ord(unich) == 0xfffd or unich in urt_wa: continue urt_wa[unich] = csetch Modified: python/trunk/Lib/test/test_mutants.py ============================================================================== --- python/trunk/Lib/test/test_mutants.py (original) +++ python/trunk/Lib/test/test_mutants.py Wed Feb 3 06:37:26 2010 @@ -210,7 +210,7 @@ # Tim sez: "luck of the draw; crashes with or without for me." print >> f - return `"machiavelli"` + return repr("machiavelli") def __hash__(self): return 0 Modified: python/trunk/Lib/test/test_optparse.py ============================================================================== --- python/trunk/Lib/test/test_optparse.py (original) +++ python/trunk/Lib/test/test_optparse.py Wed Feb 3 06:37:26 2010 @@ -26,12 +26,6 @@ from optparse import _match_abbrev from optparse import _parse_num -# Do the right thing with boolean values for all known Python versions. -try: - True, False -except NameError: - (True, False) = (1, 0) - retype = type(re.compile('')) class InterceptedError(Exception): Modified: python/trunk/Lib/test/test_ossaudiodev.py ============================================================================== --- python/trunk/Lib/test/test_ossaudiodev.py (original) +++ python/trunk/Lib/test/test_ossaudiodev.py Wed Feb 3 06:37:26 2010 @@ -45,7 +45,8 @@ try: dsp = ossaudiodev.open('w') except IOError, msg: - if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY): + if msg.args[0] in (errno.EACCES, errno.ENOENT, + errno.ENODEV, errno.EBUSY): raise unittest.SkipTest(msg) raise @@ -71,7 +72,7 @@ self.fail("dsp.%s not read-only" % attr) # Compute expected running time of sound sample (in seconds). - expected_time = float(len(data)) / (ssize/8) / nchannels / rate + expected_time = float(len(data)) / (ssize//8) / nchannels / rate # set parameters based on .au file headers dsp.setparameters(AFMT_S16_NE, nchannels, rate) @@ -162,7 +163,8 @@ try: dsp = ossaudiodev.open('w') except (ossaudiodev.error, IOError), msg: - if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY): + if msg.args[0] in (errno.EACCES, errno.ENOENT, + errno.ENODEV, errno.EBUSY): raise unittest.SkipTest(msg) raise dsp.close() Modified: python/trunk/Lib/test/test_pkgimport.py ============================================================================== --- python/trunk/Lib/test/test_pkgimport.py (original) +++ python/trunk/Lib/test/test_pkgimport.py Wed Feb 3 06:37:26 2010 @@ -6,14 +6,14 @@ def __init__(self, *args, **kw): self.package_name = 'PACKAGE_' - while sys.modules.has_key(self.package_name): + while self.package_name in sys.modules: self.package_name += random.choose(string.letters) self.module_name = self.package_name + '.foo' unittest.TestCase.__init__(self, *args, **kw) def remove_modules(self): for module_name in (self.package_name, self.module_name): - if sys.modules.has_key(module_name): + if module_name in sys.modules: del sys.modules[module_name] def setUp(self): @@ -52,8 +52,8 @@ try: __import__(self.module_name) except SyntaxError: pass else: raise RuntimeError, 'Failed to induce SyntaxError' - self.assertTrue(not sys.modules.has_key(self.module_name) and - not hasattr(sys.modules[self.package_name], 'foo')) + self.assertNotIn(self.module_name, sys.modules) + self.assertFalse(hasattr(sys.modules[self.package_name], 'foo')) # ...make up a variable name that isn't bound in __builtins__ var = 'a' Modified: python/trunk/Lib/test/test_pyexpat.py ============================================================================== --- python/trunk/Lib/test/test_pyexpat.py (original) +++ python/trunk/Lib/test/test_pyexpat.py Wed Feb 3 06:37:26 2010 @@ -554,7 +554,7 @@ self.n=0 parser.Parse(xml1, 0) - parser.buffer_size /= 2 + parser.buffer_size //= 2 self.assertEquals(parser.buffer_size, 1024) parser.Parse(xml2, 1) self.assertEquals(self.n, 4) Modified: python/trunk/Lib/test/test_queue.py ============================================================================== --- python/trunk/Lib/test/test_queue.py (original) +++ python/trunk/Lib/test/test_queue.py Wed Feb 3 06:37:26 2010 @@ -102,21 +102,23 @@ q.put(i) self.assertTrue(not q.empty(), "Queue should not be empty") self.assertTrue(not q.full(), "Queue should not be full") - q.put("last") + last = 2 * QUEUE_SIZE + full = 3 * 2 * QUEUE_SIZE + q.put(last) self.assertTrue(q.full(), "Queue should be full") try: - q.put("full", block=0) + q.put(full, block=0) self.fail("Didn't appear to block with a full queue") except Queue.Full: pass try: - q.put("full", timeout=0.01) + q.put(full, timeout=0.01) self.fail("Didn't appear to time-out with a full queue") except Queue.Full: pass # Test a blocking put - self.do_blocking_test(q.put, ("full",), q.get, ()) - self.do_blocking_test(q.put, ("full", True, 10), q.get, ()) + self.do_blocking_test(q.put, (full,), q.get, ()) + self.do_blocking_test(q.put, (full, True, 10), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() Modified: python/trunk/Lib/test/test_random.py ============================================================================== --- python/trunk/Lib/test/test_random.py (original) +++ python/trunk/Lib/test/test_random.py Wed Feb 3 06:37:26 2010 @@ -6,6 +6,7 @@ import pickle import warnings from math import log, exp, sqrt, pi, fsum, sin +from functools import reduce from test import test_support class TestBasicOps(unittest.TestCase): Modified: python/trunk/Lib/test/test_rfc822.py ============================================================================== --- python/trunk/Lib/test/test_rfc822.py (original) +++ python/trunk/Lib/test/test_rfc822.py Wed Feb 3 06:37:26 2010 @@ -46,9 +46,9 @@ continue i = i + 1 self.assertEqual(mn, n, - "Un-expected name: %s != %s" % (`mn`, `n`)) + "Un-expected name: %r != %r" % (mn, n)) self.assertEqual(ma, a, - "Un-expected address: %s != %s" % (`ma`, `a`)) + "Un-expected address: %r != %r" % (ma, a)) if mn == n and ma == a: pass else: Modified: python/trunk/Lib/test/test_site.py ============================================================================== --- python/trunk/Lib/test/test_site.py (original) +++ python/trunk/Lib/test/test_site.py Wed Feb 3 06:37:26 2010 @@ -266,7 +266,7 @@ site.abs__file__() for module in (sys, os, __builtin__): try: - self.assertTrue(os.path.isabs(module.__file__), `module`) + self.assertTrue(os.path.isabs(module.__file__), repr(module)) except AttributeError: continue # We could try everything in sys.modules; however, when regrtest.py @@ -318,7 +318,7 @@ def test_sitecustomize_executed(self): # If sitecustomize is available, it should have been imported. - if not sys.modules.has_key("sitecustomize"): + if "sitecustomize" not in sys.modules: try: import sitecustomize except ImportError: Modified: python/trunk/Lib/test/test_threadsignals.py ============================================================================== --- python/trunk/Lib/test/test_threadsignals.py (original) +++ python/trunk/Lib/test/test_threadsignals.py Wed Feb 3 06:37:26 2010 @@ -14,7 +14,7 @@ signalled_all=thread.allocate_lock() -def registerSignals((for_usr1, for_usr2, for_alrm)): +def registerSignals(for_usr1, for_usr2, for_alrm): usr1 = signal.signal(signal.SIGUSR1, for_usr1) usr2 = signal.signal(signal.SIGUSR2, for_usr2) alrm = signal.signal(signal.SIGALRM, for_alrm) @@ -74,11 +74,11 @@ signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } - oldsigs = registerSignals((handle_signals, handle_signals, handle_signals)) + oldsigs = registerSignals(handle_signals, handle_signals, handle_signals) try: run_unittest(ThreadSignals) finally: - registerSignals(oldsigs) + registerSignals(*oldsigs) if __name__ == '__main__': test_main() Modified: python/trunk/Lib/test/test_trace.py ============================================================================== --- python/trunk/Lib/test/test_trace.py (original) +++ python/trunk/Lib/test/test_trace.py Wed Feb 3 06:37:26 2010 @@ -401,7 +401,7 @@ we're testing, so that the 'exception' trace event fires.""" if self.raiseOnEvent == 'exception': x = 0 - y = 1/x + y = 1 // x else: return 1 Modified: python/trunk/Lib/test/test_traceback.py ============================================================================== --- python/trunk/Lib/test/test_traceback.py (original) +++ python/trunk/Lib/test/test_traceback.py Wed Feb 3 06:37:26 2010 @@ -4,6 +4,7 @@ from StringIO import StringIO import sys import unittest +from imp import reload from test.test_support import run_unittest, is_jython, Error import traceback @@ -148,7 +149,7 @@ def test_format_exception_only_bad__str__(self): class X(Exception): def __str__(self): - 1/0 + 1 // 0 err = traceback.format_exception_only(X, X()) self.assertEqual(len(err), 1) str_value = '' % X.__name__ Modified: python/trunk/Lib/test/test_with.py ============================================================================== --- python/trunk/Lib/test/test_with.py (original) +++ python/trunk/Lib/test/test_with.py Wed Feb 3 06:37:26 2010 @@ -520,7 +520,7 @@ self.assertRaises(AssertionError, falseAsBool) def failAsBool(): - with cm(lambda: 1//0): + with cm(lambda: 1 // 0): self.fail("Should NOT see this") self.assertRaises(ZeroDivisionError, failAsBool) @@ -628,7 +628,7 @@ def __exit__(self, t, v, tb): return True try: with AfricanSwallow(): - 1/0 + 1 // 0 except ZeroDivisionError: self.fail("ZeroDivisionError should have been swallowed") @@ -638,7 +638,7 @@ def __exit__(self, t, v, tb): return False try: with EuropeanSwallow(): - 1/0 + 1 // 0 except ZeroDivisionError: pass else: Modified: python/trunk/Lib/test/test_wsgiref.py ============================================================================== --- python/trunk/Lib/test/test_wsgiref.py (original) +++ python/trunk/Lib/test/test_wsgiref.py Wed Feb 3 06:37:26 2010 @@ -432,10 +432,10 @@ env = handler.environ from os import environ for k,v in environ.items(): - if not empty.has_key(k): + if k not in empty: self.assertEqual(env[k],v) for k,v in empty.items(): - self.assertTrue(env.has_key(k)) + self.assertIn(k, env) def testEnviron(self): h = TestHandler(X="Y") @@ -448,7 +448,7 @@ h = BaseCGIHandler(None,None,None,{}) h.setup_environ() for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors': - self.assertTrue(h.environ.has_key(key)) + self.assertIn(key, h.environ) def testScheme(self): h=TestHandler(HTTPS="on"); h.setup_environ() Modified: python/trunk/Lib/test/test_xml_etree.py ============================================================================== --- python/trunk/Lib/test/test_xml_etree.py (original) +++ python/trunk/Lib/test/test_xml_etree.py Wed Feb 3 06:37:26 2010 @@ -37,7 +37,7 @@ """ def check_method(method): - if not callable(method): + if not hasattr(method, '__call__'): print method, "not callable" def serialize(ET, elem, encoding=None): Modified: python/trunk/Lib/test/test_xml_etree_c.py ============================================================================== --- python/trunk/Lib/test/test_xml_etree_c.py (original) +++ python/trunk/Lib/test/test_xml_etree_c.py Wed Feb 3 06:37:26 2010 @@ -35,7 +35,7 @@ """ def check_method(method): - if not callable(method): + if not hasattr(method, '__call__'): print method, "not callable" def serialize(ET, elem, encoding=None): Modified: python/trunk/Lib/test/test_xpickle.py ============================================================================== --- python/trunk/Lib/test/test_xpickle.py (original) +++ python/trunk/Lib/test/test_xpickle.py Wed Feb 3 06:37:26 2010 @@ -25,7 +25,7 @@ mod_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "pickletester.py")) pickletester = types.ModuleType("test.pickletester") -execfile(mod_path, pickletester.__dict__, pickletester.__dict__) +exec compile(open(mod_path).read(), mod_path, 'exec') in pickletester.__dict__ AbstractPickleTests = pickletester.AbstractPickleTests if pickletester.__name__ in sys.modules: raise RuntimeError("Did not expect to find test.pickletester loaded") From nnorwitz at gmail.com Wed Feb 3 10:17:10 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 3 Feb 2010 04:17:10 -0500 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20100203091710.GA16243@kbk-i386-bb.psfb.org> 344 tests OK. 1 test failed: test_inspect 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn fetching http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml ... fetching http://people.freebsd.org/~perky/i18n/EUC-CN.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT ... test_codecmaps_hk fetching http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT ... test_codecmaps_jp fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JP.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT ... fetching http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT ... test_codecmaps_kr fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-KR.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT ... test_codecmaps_tw fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT ... test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictcomps test_dictviews test_difflib test_dircache test_dis test_distutils [20687 refs] test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [16680 refs] [16680 refs] [16680 refs] [28264 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test test_inspect failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) Re-running test 'test_inspect' in verbose mode test_replacing_decorator (test.test_inspect.TestDecorators) ... ok test_wrapped_decorator (test.test_inspect.TestDecorators) ... ok test_cleandoc (test.test_inspect.TestRetrievingSourceCode) ... ok test_getclasses (test.test_inspect.TestRetrievingSourceCode) ... ok test_getcomments (test.test_inspect.TestRetrievingSourceCode) ... ok test_getdoc (test.test_inspect.TestRetrievingSourceCode) ... ok test_getfile (test.test_inspect.TestRetrievingSourceCode) ... ok test_getfunctions (test.test_inspect.TestRetrievingSourceCode) ... ok test_getmodule (test.test_inspect.TestRetrievingSourceCode) ... ok test_getmodule_recursion (test.test_inspect.TestRetrievingSourceCode) ... ok test_getsource (test.test_inspect.TestRetrievingSourceCode) ... ok test_getsourcefile (test.test_inspect.TestRetrievingSourceCode) ... ok test_anonymous (test.test_inspect.TestOneliners) ... ok test_lambda_in_list (test.test_inspect.TestOneliners) ... ok test_manyargs (test.test_inspect.TestOneliners) ... ok test_oneline_lambda (test.test_inspect.TestOneliners) ... ok test_onelinefunc (test.test_inspect.TestOneliners) ... ok test_threeline_lambda (test.test_inspect.TestOneliners) ... ok test_twoline_indented_lambda (test.test_inspect.TestOneliners) ... ok test_twolinefunc (test.test_inspect.TestOneliners) ... ok test_findsource_binary (test.test_inspect.TestBuggyCases) ... ok test_method_in_dynamic_class (test.test_inspect.TestBuggyCases) ... ok test_multiline_sig (test.test_inspect.TestBuggyCases) ... ok test_nested_class (test.test_inspect.TestBuggyCases) ... ok test_one_liner_dedent_non_name (test.test_inspect.TestBuggyCases) ... ok test_one_liner_followed_by_non_name (test.test_inspect.TestBuggyCases) ... ok test_with_comment (test.test_inspect.TestBuggyCases) ... ok test_with_comment_instead_of_docstring (test.test_inspect.TestBuggyCases) ... ok test_abuse_done (test.test_inspect.TestInterpreterStack) ... ok test_frame (test.test_inspect.TestInterpreterStack) ... ok test_previous_frame (test.test_inspect.TestInterpreterStack) ... ok test_stack (test.test_inspect.TestInterpreterStack) ... ok test_trace (test.test_inspect.TestInterpreterStack) ... FAIL test_classic_mro (test.test_inspect.TestClassesAndFunctions) ... ok test_classify_newstyle (test.test_inspect.TestClassesAndFunctions) ... ok test_classify_oldstyle (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec_method (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec_sublistofone (test.test_inspect.TestClassesAndFunctions) ... ok test_newstyle_mro (test.test_inspect.TestClassesAndFunctions) ... ok test_excluding_predicates (test.test_inspect.TestPredicates) ... ok test_get_slot_members (test.test_inspect.TestPredicates) ... ok test_isabstract (test.test_inspect.TestPredicates) ... ok test_isclass (test.test_inspect.TestPredicates) ... ok test_isroutine (test.test_inspect.TestPredicates) ... ok test_sixteen (test.test_inspect.TestPredicates) ... ok ====================================================================== FAIL: test_trace (test.test_inspect.TestInterpreterStack) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) ---------------------------------------------------------------------- Ran 46 tests in 0.053s FAILED (failures=1) test test_inspect failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770. test_mutants test_mutex test_netrc test_new test_nis test_normalization fetching http://www.unicode.org/Public/5.1.0/ucd/NormalizationTest.txt ... test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [18076 refs] [18076 refs] test_plistlib test_poll test_popen [16685 refs] [16685 refs] [16685 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23125 refs] [23125 refs] test_pyexpat test_queue test_quopri [19508 refs] [19508 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [16680 refs] [16680 refs] [16680 refs] [16680 refs] test_slice test_smtplib test_smtpnet test_smtpnet skipped -- Use of the `network' resource not enabled test_socket test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_strtod test_struct test_structmembers test_structseq test_subprocess [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [16680 refs] [16680 refs] [16909 refs] [16703 refs] test_sysconfig test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [16680 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [19974 refs] [23450 refs] [22364 refs] [22364 refs] [22364 refs] [22364 refs] test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xpickle -- skipping backwards compat tests. Use 'regrtest.py -u xpickle' to run them. test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 344 tests OK. 1 test failed: test_inspect 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [875356 refs] From nnorwitz at gmail.com Wed Feb 3 10:30:12 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 3 Feb 2010 04:30:12 -0500 Subject: [Python-checkins] Python Regression Test Failures opt (1) Message-ID: <20100203093012.GA20351@kbk-i386-bb.psfb.org> 344 tests OK. 1 test failed: test_inspect 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictcomps test_dictviews test_difflib test_dircache test_dis test_distutils [20690 refs] [20690 refs] [20690 refs] [20687 refs] test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [16680 refs] [16680 refs] [16680 refs] [28264 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test test_inspect failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) Re-running test 'test_inspect' in verbose mode test_replacing_decorator (test.test_inspect.TestDecorators) ... ok test_wrapped_decorator (test.test_inspect.TestDecorators) ... ok test_cleandoc (test.test_inspect.TestRetrievingSourceCode) ... ok test_getclasses (test.test_inspect.TestRetrievingSourceCode) ... ok test_getcomments (test.test_inspect.TestRetrievingSourceCode) ... ok test_getdoc (test.test_inspect.TestRetrievingSourceCode) ... ok test_getfile (test.test_inspect.TestRetrievingSourceCode) ... ok test_getfunctions (test.test_inspect.TestRetrievingSourceCode) ... ok test_getmodule (test.test_inspect.TestRetrievingSourceCode) ... ok test_getmodule_recursion (test.test_inspect.TestRetrievingSourceCode) ... ok test_getsource (test.test_inspect.TestRetrievingSourceCode) ... ok test_getsourcefile (test.test_inspect.TestRetrievingSourceCode) ... ok test_anonymous (test.test_inspect.TestOneliners) ... ok test_lambda_in_list (test.test_inspect.TestOneliners) ... ok test_manyargs (test.test_inspect.TestOneliners) ... ok test_oneline_lambda (test.test_inspect.TestOneliners) ... ok test_onelinefunc (test.test_inspect.TestOneliners) ... ok test_threeline_lambda (test.test_inspect.TestOneliners) ... ok test_twoline_indented_lambda (test.test_inspect.TestOneliners) ... ok test_twolinefunc (test.test_inspect.TestOneliners) ... ok test_findsource_binary (test.test_inspect.TestBuggyCases) ... ok test_method_in_dynamic_class (test.test_inspect.TestBuggyCases) ... ok test_multiline_sig (test.test_inspect.TestBuggyCases) ... ok test_nested_class (test.test_inspect.TestBuggyCases) ... ok test_one_liner_dedent_non_name (test.test_inspect.TestBuggyCases) ... ok test_one_liner_followed_by_non_name (test.test_inspect.TestBuggyCases) ... ok test_with_comment (test.test_inspect.TestBuggyCases) ... ok test_with_comment_instead_of_docstring (test.test_inspect.TestBuggyCases) ... ok test_abuse_done (test.test_inspect.TestInterpreterStack) ... ok test_frame (test.test_inspect.TestInterpreterStack) ... ok test_previous_frame (test.test_inspect.TestInterpreterStack) ... ok test_stack (test.test_inspect.TestInterpreterStack) ... ok test_trace (test.test_inspect.TestInterpreterStack) ... FAIL test_classic_mro (test.test_inspect.TestClassesAndFunctions) ... ok test_classify_newstyle (test.test_inspect.TestClassesAndFunctions) ... ok test_classify_oldstyle (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec_method (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec_sublistofone (test.test_inspect.TestClassesAndFunctions) ... ok test_newstyle_mro (test.test_inspect.TestClassesAndFunctions) ... ok test_excluding_predicates (test.test_inspect.TestPredicates) ... ok test_get_slot_members (test.test_inspect.TestPredicates) ... ok test_isabstract (test.test_inspect.TestPredicates) ... ok test_isclass (test.test_inspect.TestPredicates) ... ok test_isroutine (test.test_inspect.TestPredicates) ... ok test_sixteen (test.test_inspect.TestPredicates) ... ok ====================================================================== FAIL: test_trace (test.test_inspect.TestInterpreterStack) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) ---------------------------------------------------------------------- Ran 46 tests in 0.054s FAILED (failures=1) test test_inspect failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770. test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [18076 refs] [18076 refs] test_plistlib test_poll test_popen [16685 refs] [16685 refs] [16685 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23125 refs] [23125 refs] test_pyexpat test_queue test_quopri [19508 refs] [19508 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [16680 refs] [16680 refs] [16680 refs] [16680 refs] test_slice test_smtplib test_smtpnet test_smtpnet skipped -- Use of the `network' resource not enabled test_socket test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_strtod test_struct test_structmembers test_structseq test_subprocess [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [16680 refs] [16680 refs] [16909 refs] [16703 refs] test_sysconfig test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [16680 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [19974 refs] [23450 refs] [22364 refs] [22364 refs] [22364 refs] [22364 refs] test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xpickle -- skipping backwards compat tests. Use 'regrtest.py -u xpickle' to run them. test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 344 tests OK. 1 test failed: test_inspect 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [874245 refs] From nnorwitz at gmail.com Wed Feb 3 13:20:30 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 3 Feb 2010 07:20:30 -0500 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20100203122030.GA27487@kbk-i386-bb.psfb.org> 350 tests OK. 1 test failed: test_inspect 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-20115 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictcomps test_dictviews test_difflib test_dircache test_dis test_distutils [20687 refs] test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [16680 refs] [16680 refs] [16680 refs] [28264 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test test_inspect failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) Re-running test 'test_inspect' in verbose mode test_replacing_decorator (test.test_inspect.TestDecorators) ... ok test_wrapped_decorator (test.test_inspect.TestDecorators) ... ok test_cleandoc (test.test_inspect.TestRetrievingSourceCode) ... ok test_getclasses (test.test_inspect.TestRetrievingSourceCode) ... ok test_getcomments (test.test_inspect.TestRetrievingSourceCode) ... ok test_getdoc (test.test_inspect.TestRetrievingSourceCode) ... ok test_getfile (test.test_inspect.TestRetrievingSourceCode) ... ok test_getfunctions (test.test_inspect.TestRetrievingSourceCode) ... ok test_getmodule (test.test_inspect.TestRetrievingSourceCode) ... ok test_getmodule_recursion (test.test_inspect.TestRetrievingSourceCode) ... ok test_getsource (test.test_inspect.TestRetrievingSourceCode) ... ok test_getsourcefile (test.test_inspect.TestRetrievingSourceCode) ... ok test_anonymous (test.test_inspect.TestOneliners) ... ok test_lambda_in_list (test.test_inspect.TestOneliners) ... ok test_manyargs (test.test_inspect.TestOneliners) ... ok test_oneline_lambda (test.test_inspect.TestOneliners) ... ok test_onelinefunc (test.test_inspect.TestOneliners) ... ok test_threeline_lambda (test.test_inspect.TestOneliners) ... ok test_twoline_indented_lambda (test.test_inspect.TestOneliners) ... ok test_twolinefunc (test.test_inspect.TestOneliners) ... ok test_findsource_binary (test.test_inspect.TestBuggyCases) ... ok test_method_in_dynamic_class (test.test_inspect.TestBuggyCases) ... ok test_multiline_sig (test.test_inspect.TestBuggyCases) ... ok test_nested_class (test.test_inspect.TestBuggyCases) ... ok test_one_liner_dedent_non_name (test.test_inspect.TestBuggyCases) ... ok test_one_liner_followed_by_non_name (test.test_inspect.TestBuggyCases) ... ok test_with_comment (test.test_inspect.TestBuggyCases) ... ok test_with_comment_instead_of_docstring (test.test_inspect.TestBuggyCases) ... ok test_abuse_done (test.test_inspect.TestInterpreterStack) ... ok test_frame (test.test_inspect.TestInterpreterStack) ... ok test_previous_frame (test.test_inspect.TestInterpreterStack) ... ok test_stack (test.test_inspect.TestInterpreterStack) ... ok test_trace (test.test_inspect.TestInterpreterStack) ... FAIL test_classic_mro (test.test_inspect.TestClassesAndFunctions) ... ok test_classify_newstyle (test.test_inspect.TestClassesAndFunctions) ... ok test_classify_oldstyle (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec_method (test.test_inspect.TestClassesAndFunctions) ... ok test_getargspec_sublistofone (test.test_inspect.TestClassesAndFunctions) ... ok test_newstyle_mro (test.test_inspect.TestClassesAndFunctions) ... ok test_excluding_predicates (test.test_inspect.TestPredicates) ... ok test_get_slot_members (test.test_inspect.TestPredicates) ... ok test_isabstract (test.test_inspect.TestPredicates) ... ok test_isclass (test.test_inspect.TestPredicates) ... ok test_isroutine (test.test_inspect.TestPredicates) ... ok test_sixteen (test.test_inspect.TestPredicates) ... ok ====================================================================== FAIL: test_trace (test.test_inspect.TestInterpreterStack) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) ---------------------------------------------------------------------- Ran 46 tests in 0.054s FAILED (failures=1) test test_inspect failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_inspect.py", line 170, in test_trace [' q = y / 0\n'], 0)) AssertionError: Tuples differ: ('/tmp/python-test/local/lib/p... != ('/tmp/python-test/local/lib/p... First differing element 3: [' q = y // 0\n'] [' q = y / 0\n'] ('/tmp/python-test/local/lib/python2.7/test/inspect_fodder.py', 18, 'eggs', - [' q = y // 0\n'], ? - + [' q = y / 0\n'], 0) test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770. test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [18076 refs] [18076 refs] test_plistlib test_poll test_popen [16685 refs] [16685 refs] [16685 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23125 refs] [23125 refs] test_pyexpat test_queue test_quopri [19508 refs] [19508 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [16680 refs] [16680 refs] [16680 refs] [16680 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_strtod test_struct test_structmembers test_structseq test_subprocess [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [16680 refs] [16680 refs] [16909 refs] [16703 refs] test_sysconfig test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [16680 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [19974 refs] [22548 refs] [22364 refs] [22364 refs] [22364 refs] [22364 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 350 tests OK. 1 test failed: test_inspect 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [891824 refs] From python-checkins at python.org Wed Feb 3 14:36:23 2010 From: python-checkins at python.org (r.david.murray) Date: Wed, 03 Feb 2010 13:36:23 -0000 Subject: [Python-checkins] r77943 - python/trunk/Doc/library/email.util.rst Message-ID: Author: r.david.murray Date: Wed Feb 3 14:36:23 2010 New Revision: 77943 Log: Explicitly mention the default value for formatdate's usegmt parameter. Modified: python/trunk/Doc/library/email.util.rst Modified: python/trunk/Doc/library/email.util.rst ============================================================================== --- python/trunk/Doc/library/email.util.rst (original) +++ python/trunk/Doc/library/email.util.rst Wed Feb 3 14:36:23 2010 @@ -102,7 +102,7 @@ Optional *usegmt* is a flag that when ``True``, outputs a date string with the timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. This is needed for some protocols (such as HTTP). This only applies when *localtime* is - ``False``. + ``False``. The default is ``False``. .. versionadded:: 2.4 From python-checkins at python.org Wed Feb 3 15:17:51 2010 From: python-checkins at python.org (eric.smith) Date: Wed, 03 Feb 2010 14:17:51 -0000 Subject: [Python-checkins] r77944 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: eric.smith Date: Wed Feb 3 15:17:50 2010 New Revision: 77944 Log: Corrected list of attributes exposed by sys.getwindowsversion. Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Wed Feb 3 15:17:50 2010 @@ -830,10 +830,10 @@ Light; :issue:`4285`.) :func:`sys.getwindowsversion` also returns a named tuple, - with attributes named :attr:`service_pack_major`, - :attr:`service_pack_minor`, - :attr:`suite_mask`, and :attr:`product_type`. (Contributed by - Brian Curtin; :issue:`7766`.) + with attributes named :attr:`major`, :attr:`minor`, :attr:`build`, + :attr:`platform`:, :attr:`service_pack`, :attr:`service_pack_major`, + :attr:`service_pack_minor`, :attr:`suite_mask`, and + :attr:`product_type`. (Contributed by Brian Curtin; :issue:`7766`.) * The :mod:`tarfile` module's default error handling has changed, to no longer suppress fatal errors. The default error level was previously 0, From python-checkins at python.org Wed Feb 3 15:18:16 2010 From: python-checkins at python.org (eric.smith) Date: Wed, 03 Feb 2010 14:18:16 -0000 Subject: [Python-checkins] r77945 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Wed Feb 3 15:18:16 2010 New Revision: 77945 Log: Blocked revisions 77944 via svnmerge ........ r77944 | eric.smith | 2010-02-03 09:17:50 -0500 (Wed, 03 Feb 2010) | 1 line Corrected list of attributes exposed by sys.getwindowsversion. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Feb 3 15:19:28 2010 From: python-checkins at python.org (eric.smith) Date: Wed, 03 Feb 2010 14:19:28 -0000 Subject: [Python-checkins] r77946 - python/branches/py3k Message-ID: Author: eric.smith Date: Wed Feb 3 15:19:27 2010 New Revision: 77946 Log: Blocked revisions 77944 via svnmerge ........ r77944 | eric.smith | 2010-02-03 09:17:50 -0500 (Wed, 03 Feb 2010) | 1 line Corrected list of attributes exposed by sys.getwindowsversion. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Wed Feb 3 15:20:51 2010 From: python-checkins at python.org (eric.smith) Date: Wed, 03 Feb 2010 14:20:51 -0000 Subject: [Python-checkins] r77947 - python/branches/release31-maint Message-ID: Author: eric.smith Date: Wed Feb 3 15:20:51 2010 New Revision: 77947 Log: Blocked revisions 77946 via svnmerge ................ r77946 | eric.smith | 2010-02-03 09:19:27 -0500 (Wed, 03 Feb 2010) | 8 lines Blocked revisions 77944 via svnmerge ........ r77944 | eric.smith | 2010-02-03 09:17:50 -0500 (Wed, 03 Feb 2010) | 1 line Corrected list of attributes exposed by sys.getwindowsversion. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Wed Feb 3 15:25:11 2010 From: python-checkins at python.org (eric.smith) Date: Wed, 03 Feb 2010 14:25:11 -0000 Subject: [Python-checkins] r77948 - python/branches/py3k/Doc/whatsnew/2.7.rst Message-ID: Author: eric.smith Date: Wed Feb 3 15:25:10 2010 New Revision: 77948 Log: Fixed accidental block of r77944. Modified: python/branches/py3k/Doc/whatsnew/2.7.rst Modified: python/branches/py3k/Doc/whatsnew/2.7.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.7.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.7.rst Wed Feb 3 15:25:10 2010 @@ -830,10 +830,10 @@ Light; :issue:`4285`.) :func:`sys.getwindowsversion` also returns a named tuple, - with attributes named :attr:`service_pack_major`, - :attr:`service_pack_minor`, - :attr:`suite_mask`, and :attr:`product_type`. (Contributed by - Brian Curtin; :issue:`7766`.) + with attributes named :attr:`major`, :attr:`minor`, :attr:`build`, + :attr:`platform`:, :attr:`service_pack`, :attr:`service_pack_major`, + :attr:`service_pack_minor`, :attr:`suite_mask`, and + :attr:`product_type`. (Contributed by Brian Curtin; :issue:`7766`.) * The :mod:`tarfile` module's default error handling has changed, to no longer suppress fatal errors. The default error level was previously 0, From python-checkins at python.org Wed Feb 3 16:38:12 2010 From: python-checkins at python.org (tarek.ziade) Date: Wed, 03 Feb 2010 15:38:12 -0000 Subject: [Python-checkins] r77949 - python/trunk/Lib/distutils/command/install.py Message-ID: Author: tarek.ziade Date: Wed Feb 3 16:38:12 2010 New Revision: 77949 Log: leaving global attributes for backward compat Modified: python/trunk/Lib/distutils/command/install.py Modified: python/trunk/Lib/distutils/command/install.py ============================================================================== --- python/trunk/Lib/distutils/command/install.py (original) +++ python/trunk/Lib/distutils/command/install.py Wed Feb 3 16:38:12 2010 @@ -17,6 +17,87 @@ from distutils.util import convert_path, change_root, get_platform from distutils.errors import DistutilsOptionError +# kept for backward compat, will be removed in 3.2 +if sys.version < "2.2": + WINDOWS_SCHEME = { + 'purelib': '$base', + 'platlib': '$base', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + } +else: + WINDOWS_SCHEME = { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + } + +INSTALL_SCHEMES = { + 'unix_prefix': { + 'purelib': '$base/lib/python$py_version_short/site-packages', + 'platlib': '$platbase/lib/python$py_version_short/site-packages', + 'headers': '$base/include/python$py_version_short/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, + 'unix_home': { + 'purelib': '$base/lib/python', + 'platlib': '$base/lib/python', + 'headers': '$base/include/python/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, + 'unix_user': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/include/python$py_version_short/$dist_name', + 'scripts': '$userbase/bin', + 'data' : '$userbase', + }, + 'nt': WINDOWS_SCHEME, + 'nt_user': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name', + 'scripts': '$userbase/Scripts', + 'data' : '$userbase', + }, + 'mac': { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + }, + 'mac_user': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/$py_version_short/include/$dist_name', + 'scripts': '$userbase/bin', + 'data' : '$userbase', + }, + 'os2': { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + }, + 'os2_home': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/include/python$py_version_short/$dist_name', + 'scripts': '$userbase/bin', + 'data' : '$userbase', + }, + } + +SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data') +# end of backward compat + def _subst_vars(s, local_vars): try: return s.format(**local_vars) From python-checkins at python.org Wed Feb 3 17:10:34 2010 From: python-checkins at python.org (tarek.ziade) Date: Wed, 03 Feb 2010 16:10:34 -0000 Subject: [Python-checkins] r77950 - in python/branches/py3k: Lib/distutils/command/install.py Message-ID: Author: tarek.ziade Date: Wed Feb 3 17:10:34 2010 New Revision: 77950 Log: Merged revisions 77949 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77949 | tarek.ziade | 2010-02-03 16:38:12 +0100 (Wed, 03 Feb 2010) | 1 line leaving global attributes for backward compat ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/command/install.py Modified: python/branches/py3k/Lib/distutils/command/install.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/install.py (original) +++ python/branches/py3k/Lib/distutils/command/install.py Wed Feb 3 17:10:34 2010 @@ -17,6 +17,87 @@ from distutils.util import convert_path, change_root, get_platform from distutils.errors import DistutilsOptionError +# kept for backward compat, will be removed in 3.2 +if sys.version < "2.2": + WINDOWS_SCHEME = { + 'purelib': '$base', + 'platlib': '$base', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + } +else: + WINDOWS_SCHEME = { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + } + +INSTALL_SCHEMES = { + 'unix_prefix': { + 'purelib': '$base/lib/python$py_version_short/site-packages', + 'platlib': '$platbase/lib/python$py_version_short/site-packages', + 'headers': '$base/include/python$py_version_short/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, + 'unix_home': { + 'purelib': '$base/lib/python', + 'platlib': '$base/lib/python', + 'headers': '$base/include/python/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, + 'unix_user': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/include/python$py_version_short/$dist_name', + 'scripts': '$userbase/bin', + 'data' : '$userbase', + }, + 'nt': WINDOWS_SCHEME, + 'nt_user': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name', + 'scripts': '$userbase/Scripts', + 'data' : '$userbase', + }, + 'mac': { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + }, + 'mac_user': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/$py_version_short/include/$dist_name', + 'scripts': '$userbase/bin', + 'data' : '$userbase', + }, + 'os2': { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + }, + 'os2_home': { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/include/python$py_version_short/$dist_name', + 'scripts': '$userbase/bin', + 'data' : '$userbase', + }, + } + +SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data') +# end of backward compat + def _subst_vars(s, local_vars): try: return s.format(**local_vars) From python-checkins at python.org Wed Feb 3 17:11:15 2010 From: python-checkins at python.org (tarek.ziade) Date: Wed, 03 Feb 2010 16:11:15 -0000 Subject: [Python-checkins] r77951 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Wed Feb 3 17:11:15 2010 New Revision: 77951 Log: Blocked revisions 77950 via svnmerge ................ r77950 | tarek.ziade | 2010-02-03 17:10:34 +0100 (Wed, 03 Feb 2010) | 9 lines Merged revisions 77949 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77949 | tarek.ziade | 2010-02-03 16:38:12 +0100 (Wed, 03 Feb 2010) | 1 line leaving global attributes for backward compat ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Wed Feb 3 17:50:15 2010 From: python-checkins at python.org (mark.dickinson) Date: Wed, 03 Feb 2010 16:50:15 -0000 Subject: [Python-checkins] r77952 - python/trunk/Lib/test/test_inspect.py Message-ID: Author: mark.dickinson Date: Wed Feb 3 17:50:14 2010 New Revision: 77952 Log: Fix test_inspect.py data to match recent change to inspect_fodder.py (r77942). Modified: python/trunk/Lib/test/test_inspect.py Modified: python/trunk/Lib/test/test_inspect.py ============================================================================== --- python/trunk/Lib/test/test_inspect.py (original) +++ python/trunk/Lib/test/test_inspect.py Wed Feb 3 17:50:14 2010 @@ -167,7 +167,7 @@ self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0)) self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs', - [' q = y / 0\n'], 0)) + [' q = y // 0\n'], 0)) def test_frame(self): args, varargs, varkw, locals = inspect.getargvalues(mod.fr) From python-checkins at python.org Wed Feb 3 18:46:29 2010 From: python-checkins at python.org (barry.warsaw) Date: Wed, 03 Feb 2010 17:46:29 -0000 Subject: [Python-checkins] r77953 - peps/trunk/pep-3147.txt Message-ID: Author: barry.warsaw Date: Wed Feb 3 18:46:28 2010 New Revision: 77953 Log: Add some notes based on python-dev discussion. Needs reconciling with the body of the PEP. Modified: peps/trunk/pep-3147.txt Modified: peps/trunk/pep-3147.txt ============================================================================== --- peps/trunk/pep-3147.txt (original) +++ peps/trunk/pep-3147.txt Wed Feb 3 18:46:28 2010 @@ -368,6 +368,26 @@ This document has been placed in the public domain. +Notes from python-dev +===================== + +The python-dev discussion has been very fruitful. Here are some +in-progress notes from that thread which still needs to be reconciled +into the body of the PEP. + +* Rarity of the use of this feature. Important for distros but + probably much less so for individual users (who may never even see + these things). +* Sibling vs folder-per-folder. Do performance measurements. Do stat + calls outweigh everything else? We need to do an analysis of the + current implementation as a baseline. +* Magic numbers in file names are magical; no one really knows the + mappings. Maybe we should use magic strings (with a lookup table?), + e.g. 'foo.cython-27.py' +* Modules should unambiguously name their __source__ and __cache__ + file names. __file__ is ambiguous. + + .. Local Variables: From python-checkins at python.org Wed Feb 3 21:29:11 2010 From: python-checkins at python.org (collin.winter) Date: Wed, 03 Feb 2010 20:29:11 -0000 Subject: [Python-checkins] r77954 - in python/branches/release26-maint: Modules/_testcapimodule.c Message-ID: Author: collin.winter Date: Wed Feb 3 21:29:10 2010 New Revision: 77954 Log: Merged revisions 72357,72367 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r72357 | benjamin.peterson | 2009-05-05 14:09:21 -0700 (Tue, 05 May 2009) | 4 lines fix running test_capi with -R :: Also, fix a refleak in the test that was preventing running. :) ........ r72367 | benjamin.peterson | 2009-05-05 16:00:48 -0700 (Tue, 05 May 2009) | 1 line tabify :( ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Modules/_testcapimodule.c Modified: python/branches/release26-maint/Modules/_testcapimodule.c ============================================================================== --- python/branches/release26-maint/Modules/_testcapimodule.c (original) +++ python/branches/release26-maint/Modules/_testcapimodule.c Wed Feb 3 21:29:10 2010 @@ -226,6 +226,13 @@ long hash; type = &_HashInheritanceTester_Type; + + if (type->tp_dict != NULL) + /* The type has already been initialized. This probably means + -R is being used. */ + Py_RETURN_NONE; + + obj = PyObject_New(PyObject, type); if (obj == NULL) { PyErr_Clear(); @@ -269,6 +276,8 @@ return NULL; } + Py_DECREF(obj); + Py_RETURN_NONE; } From collinw at gmail.com Wed Feb 3 22:43:38 2010 From: collinw at gmail.com (Collin Winter) Date: Wed, 3 Feb 2010 13:43:38 -0800 Subject: [Python-checkins] r75199 - in python/branches/release26-maint: Lib/distutils/tests/test_sysconfig.py Misc/NEWS In-Reply-To: <4ac6a728.1167f10a.1830.38f0SMTPIN_ADDED@mx.google.com> References: <4ac6a728.1167f10a.1830.38f0SMTPIN_ADDED@mx.google.com> Message-ID: <43aa6ff71002031343w1c23b479p1e5ad3c535847be1@mail.gmail.com> Hey Tarek, On Fri, Oct 2, 2009 at 5:21 PM, tarek.ziade wrote: > Author: tarek.ziade > Date: Sat Oct ?3 03:21:38 2009 > New Revision: 75199 > > Log: > Issue #7039: Fixed test_distutils when running tests on an installation with no build > > Modified: > ? python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py > ? python/branches/release26-maint/Misc/NEWS > > Modified: python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py > ============================================================================== > --- python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py ? ? ? (original) > +++ python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py ? ? ? Sat Oct ?3 03:21:38 2009 > @@ -30,30 +30,13 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? sysconfig.get_python_lib(prefix=TESTFN)) > > ? ? def test_get_python_inc(self): > - ? ? ? ?# The check for srcdir is copied from Python's setup.py, > - ? ? ? ?# and is necessary to make this test pass when building > - ? ? ? ?# Python in a directory other than the source directory. > - ? ? ? ?(srcdir,) = sysconfig.get_config_vars('srcdir') > - ? ? ? ?if not srcdir: > - ? ? ? ? ? ?inc_dir = sysconfig.get_python_inc() > - ? ? ? ?else: Why did you remove this section? This test no longer passes if Python was built with src directory != obj directory. Can this be added back, or if the test doesn't make sense in that configuration, can it be skipped instead of failing? Thanks, Collin Winter > - ? ? ? ? ? ?# This test is not really a proper test: when building > - ? ? ? ? ? ?# Python from source, even in the same directory, > - ? ? ? ? ? ?# we won't be testing the same thing as when running > - ? ? ? ? ? ?# distutils' tests on an installed Python. Nevertheless, > - ? ? ? ? ? ?# let's try to do our best: if we are running Python's > - ? ? ? ? ? ?# unittests from a build directory that is not the source > - ? ? ? ? ? ?# directory, the normal inc_dir will exist, it will just not > - ? ? ? ? ? ?# contain anything of interest. > - ? ? ? ? ? ?inc_dir = sysconfig.get_python_inc() > - ? ? ? ? ? ?self.assert_(os.path.isdir(inc_dir)) > - ? ? ? ? ? ?# Now test the source location, to make sure Python.h does > - ? ? ? ? ? ?# exist. > - ? ? ? ? ? ?inc_dir = os.path.join(os.getcwd(), srcdir, 'Include') > - ? ? ? ? ? ?inc_dir = os.path.normpath(inc_dir) > - ? ? ? ?self.assert_(os.path.isdir(inc_dir), inc_dir) > + ? ? ? ?inc_dir = sysconfig.get_python_inc() > + ? ? ? ?# This is not much of a test. ?We make sure Python.h exists > + ? ? ? ?# in the directory returned by get_python_inc() but we don't know > + ? ? ? ?# it is the correct file. > + ? ? ? ?self.assertTrue(os.path.isdir(inc_dir), inc_dir) > ? ? ? ? python_h = os.path.join(inc_dir, "Python.h") > - ? ? ? ?self.assert_(os.path.isfile(python_h), python_h) > + ? ? ? ?self.assertTrue(os.path.isfile(python_h), python_h) > > ? ? def test_get_config_vars(self): > ? ? ? ? cvars = sysconfig.get_config_vars() > > Modified: python/branches/release26-maint/Misc/NEWS > ============================================================================== > --- python/branches/release26-maint/Misc/NEWS ? (original) > +++ python/branches/release26-maint/Misc/NEWS ? Sat Oct ?3 03:21:38 2009 > @@ -15,6 +15,8 @@ > ?Library > ?------- > > +- Issue #7039: Fixed distutils.tests.test_sysconfig when running on > + ?installation with no build. > > ?What's New in Python 2.6.3 > ?========================== > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Wed Feb 3 23:06:03 2010 From: python-checkins at python.org (collin.winter) Date: Wed, 03 Feb 2010 22:06:03 -0000 Subject: [Python-checkins] r77955 - in python/branches/release26-maint: Lib/distutils/tests/test_build_ext.py Message-ID: Author: collin.winter Date: Wed Feb 3 23:06:03 2010 New Revision: 77955 Log: Merged revisions 69304 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r69304 | neil.schemenauer | 2009-02-05 08:25:16 -0800 (Thu, 05 Feb 2009) | 4 lines Fix test_build_ext.py to work when building in a separate directory. Since "srcdir" should now be defined on all platforms, use it to find the module source. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py Modified: python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py Wed Feb 3 23:06:03 2010 @@ -13,11 +13,14 @@ import unittest from test import test_support - # http://bugs.python.org/issue4373 # Don't load the xx module more than once. ALREADY_TESTED = False +def _get_source_filename(): + srcdir = sysconfig.get_config_var('srcdir') + return os.path.join(srcdir, 'Modules', 'xxmodule.c') + class BuildExtTestCase(support.TempdirManager, support.LoggingSilencer, unittest.TestCase): @@ -28,9 +31,7 @@ self.tmp_dir = tempfile.mkdtemp(prefix="pythontest_") self.sys_path = sys.path[:] sys.path.append(self.tmp_dir) - - xx_c = os.path.join(sysconfig.project_base, 'Modules', 'xxmodule.c') - shutil.copy(xx_c, self.tmp_dir) + shutil.copy(_get_source_filename(), self.tmp_dir) def test_build_ext(self): global ALREADY_TESTED @@ -387,9 +388,11 @@ self.assertEquals(ext_path, wanted) def test_suite(): - if not sysconfig.python_build: + src = _get_source_filename() + if not os.path.exists(src): if test_support.verbose: - print 'test_build_ext: The test must be run in a python build dir' + print ('test_build_ext: Cannot find source code (test' + ' must run in python build dir)') return unittest.TestSuite() else: return unittest.makeSuite(BuildExtTestCase) From python-checkins at python.org Wed Feb 3 23:11:54 2010 From: python-checkins at python.org (brett.cannon) Date: Wed, 03 Feb 2010 22:11:54 -0000 Subject: [Python-checkins] r77956 - python/trunk/Lib/test/test_support.py Message-ID: Author: brett.cannon Date: Wed Feb 3 23:11:54 2010 New Revision: 77956 Log: Update a docstring to suggest using importlib.import_module instead of calling __import__ directly. Modified: python/trunk/Lib/test/test_support.py Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Wed Feb 3 23:11:54 2010 @@ -493,7 +493,7 @@ Use like this: with CleanImport("foo"): - __import__("foo") # new reference + importlib.import_modulefoo") # new reference """ def __init__(self, *module_names): From python-checkins at python.org Wed Feb 3 23:13:45 2010 From: python-checkins at python.org (brett.cannon) Date: Wed, 03 Feb 2010 22:13:45 -0000 Subject: [Python-checkins] r77957 - python/trunk/Lib/test/test_support.py Message-ID: Author: brett.cannon Date: Wed Feb 3 23:13:44 2010 New Revision: 77957 Log: Fix a typo in a docstring introduced in r77956. Modified: python/trunk/Lib/test/test_support.py Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Wed Feb 3 23:13:44 2010 @@ -493,7 +493,7 @@ Use like this: with CleanImport("foo"): - importlib.import_modulefoo") # new reference + importlib.import_module("foo") # new reference """ def __init__(self, *module_names): From python-checkins at python.org Wed Feb 3 23:16:12 2010 From: python-checkins at python.org (brett.cannon) Date: Wed, 03 Feb 2010 22:16:12 -0000 Subject: [Python-checkins] r77958 - in python/branches/py3k: Lib/test/support.py Message-ID: Author: brett.cannon Date: Wed Feb 3 23:16:11 2010 New Revision: 77958 Log: Merged revisions 77956-77957 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77956 | brett.cannon | 2010-02-03 14:11:54 -0800 (Wed, 03 Feb 2010) | 1 line Update a docstring to suggest using importlib.import_module instead of calling __import__ directly. ........ r77957 | brett.cannon | 2010-02-03 14:13:44 -0800 (Wed, 03 Feb 2010) | 1 line Fix a typo in a docstring introduced in r77956. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/support.py Modified: python/branches/py3k/Lib/test/support.py ============================================================================== --- python/branches/py3k/Lib/test/support.py (original) +++ python/branches/py3k/Lib/test/support.py Wed Feb 3 23:16:11 2010 @@ -477,7 +477,7 @@ Use like this: with CleanImport("foo"): - __import__("foo") # new reference + importlib.import_module("foo") # new reference """ def __init__(self, *module_names): From solipsis at pitrou.net Thu Feb 4 01:04:39 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 4 Feb 2010 01:04:39 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r77950): sum=-23 Message-ID: <20100204000439.13DA21770C@ns6635.ovh.net> py3k results for svn r77950 (hg cset 9c2b81cffd48) -------------------------------------------------- test_os leaked [-23, 0, 0] references, sum=-23 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogS6914k', '-x', 'test_httpservers'] From python-checkins at python.org Thu Feb 4 13:43:59 2010 From: python-checkins at python.org (nick.coghlan) Date: Thu, 04 Feb 2010 12:43:59 -0000 Subject: [Python-checkins] r77959 - python/trunk/Doc/library/subprocess.rst Message-ID: Author: nick.coghlan Date: Thu Feb 4 13:43:58 2010 New Revision: 77959 Log: Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert Modified: python/trunk/Doc/library/subprocess.rst Modified: python/trunk/Doc/library/subprocess.rst ============================================================================== --- python/trunk/Doc/library/subprocess.rst (original) +++ python/trunk/Doc/library/subprocess.rst Thu Feb 4 13:43:58 2010 @@ -48,13 +48,38 @@ On Unix, with *shell=False* (default): In this case, the Popen class uses :meth:`os.execvp` to execute the child program. *args* should normally be a - sequence. A string will be treated as a sequence with the string as the only - item (the program to execute). + sequence. If a string is specified for *args*, it will be used as the name + or path of the program to execute; this will only work if the program is + being given no arguments. - On Unix, with *shell=True*: If args is a string, it specifies the command string - to execute through the shell. If *args* is a sequence, the first item specifies - the command string, and any additional items will be treated as additional shell - arguments. + .. note:: + + :meth:`shlex.split` can be useful when determining the correct + tokenization for *args*, especially in complex cases:: + + >>> import shlex, subprocess + >>> command_line = raw_input() + /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" + >>> args = shlex.split(command_line) + >>> print args + ['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"] + >>> p = subprocess.Popen(args) # Success! + + Note in particular that options (such as *-input*) and arguments (such + as *eggs.txt*) that are separated by whitespace in the shell go in separate + list elements, while arguments that need quoting or backslash escaping when + used in the shell (such as filenames containing spaces or the *echo* command + shown above) are single list elements. + + On Unix, with *shell=True*: If args is a string, it specifies the command + string to execute through the shell. This means that the string must be + formatted exactly as it would be when typed at the shell prompt. This + includes, for example, quoting or backslash escaping filenames with spaces in + them. If *args* is a sequence, the first item specifies the command string, and + any additional items will be treated as additional arguments to the shell + itself. That is to say, *Popen* does the equivalent of:: + + Popen(['/bin/sh', '-c', args[0], args[1], ...]) On Windows: the :class:`Popen` class uses CreateProcess() to execute the child program, which operates on strings. If *args* is a sequence, it will be From python-checkins at python.org Thu Feb 4 17:33:32 2010 From: python-checkins at python.org (r.david.murray) Date: Thu, 04 Feb 2010 16:33:32 -0000 Subject: [Python-checkins] r77960 - python/trunk/Misc/ACKS Message-ID: Author: r.david.murray Date: Thu Feb 4 17:33:31 2010 New Revision: 77960 Log: Add Chris Rebert to ACKS for issue 6760 Popen doc improvements. Modified: python/trunk/Misc/ACKS Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Thu Feb 4 17:33:31 2010 @@ -612,6 +612,7 @@ Antti Rasinen Eric Raymond Edward K. Ream +Chris Rebert Marc Recht John Redford Terry Reedy From python-checkins at python.org Thu Feb 4 17:35:34 2010 From: python-checkins at python.org (r.david.murray) Date: Thu, 04 Feb 2010 16:35:34 -0000 Subject: [Python-checkins] r77961 - in python/branches/release26-maint: Doc/library/email.util.rst Doc/library/subprocess.rst Misc/ACKS Message-ID: Author: r.david.murray Date: Thu Feb 4 17:35:33 2010 New Revision: 77961 Log: Merged revisions 77943,77959-77960 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77943 | r.david.murray | 2010-02-03 08:36:23 -0500 (Wed, 03 Feb 2010) | 2 lines Explicitly mention the default value for formatdate's usegmt parameter. ........ r77959 | nick.coghlan | 2010-02-04 07:43:58 -0500 (Thu, 04 Feb 2010) | 1 line Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert ........ r77960 | r.david.murray | 2010-02-04 11:33:31 -0500 (Thu, 04 Feb 2010) | 2 lines Add Chris Rebert to ACKS for issue 6760 Popen doc improvements. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/email.util.rst python/branches/release26-maint/Doc/library/subprocess.rst python/branches/release26-maint/Misc/ACKS Modified: python/branches/release26-maint/Doc/library/email.util.rst ============================================================================== --- python/branches/release26-maint/Doc/library/email.util.rst (original) +++ python/branches/release26-maint/Doc/library/email.util.rst Thu Feb 4 17:35:33 2010 @@ -102,7 +102,7 @@ Optional *usegmt* is a flag that when ``True``, outputs a date string with the timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. This is needed for some protocols (such as HTTP). This only applies when *localtime* is - ``False``. + ``False``. The default is ``False``. .. versionadded:: 2.4 Modified: python/branches/release26-maint/Doc/library/subprocess.rst ============================================================================== --- python/branches/release26-maint/Doc/library/subprocess.rst (original) +++ python/branches/release26-maint/Doc/library/subprocess.rst Thu Feb 4 17:35:33 2010 @@ -48,13 +48,38 @@ On Unix, with *shell=False* (default): In this case, the Popen class uses :meth:`os.execvp` to execute the child program. *args* should normally be a - sequence. A string will be treated as a sequence with the string as the only - item (the program to execute). + sequence. If a string is specified for *args*, it will be used as the name + or path of the program to execute; this will only work if the program is + being given no arguments. - On Unix, with *shell=True*: If args is a string, it specifies the command string - to execute through the shell. If *args* is a sequence, the first item specifies - the command string, and any additional items will be treated as additional shell - arguments. + .. note:: + + :meth:`shlex.split` can be useful when determining the correct + tokenization for *args*, especially in complex cases:: + + >>> import shlex, subprocess + >>> command_line = raw_input() + /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" + >>> args = shlex.split(command_line) + >>> print args + ['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"] + >>> p = subprocess.Popen(args) # Success! + + Note in particular that options (such as *-input*) and arguments (such + as *eggs.txt*) that are separated by whitespace in the shell go in separate + list elements, while arguments that need quoting or backslash escaping when + used in the shell (such as filenames containing spaces or the *echo* command + shown above) are single list elements. + + On Unix, with *shell=True*: If args is a string, it specifies the command + string to execute through the shell. This means that the string must be + formatted exactly as it would be when typed at the shell prompt. This + includes, for example, quoting or backslash escaping filenames with spaces in + them. If *args* is a sequence, the first item specifies the command string, and + any additional items will be treated as additional arguments to the shell + itself. That is to say, *Popen* does the equivalent of:: + + Popen(['/bin/sh', '-c', args[0], args[1], ...]) On Windows: the :class:`Popen` class uses CreateProcess() to execute the child program, which operates on strings. If *args* is a sequence, it will be Modified: python/branches/release26-maint/Misc/ACKS ============================================================================== --- python/branches/release26-maint/Misc/ACKS (original) +++ python/branches/release26-maint/Misc/ACKS Thu Feb 4 17:35:33 2010 @@ -580,6 +580,7 @@ Antti Rasinen Eric Raymond Edward K. Ream +Chris Rebert Marc Recht John Redford Terry Reedy From python-checkins at python.org Thu Feb 4 17:41:58 2010 From: python-checkins at python.org (r.david.murray) Date: Thu, 04 Feb 2010 16:41:58 -0000 Subject: [Python-checkins] r77962 - in python/branches/py3k: Doc/library/email.util.rst Doc/library/subprocess.rst Misc/ACKS Message-ID: Author: r.david.murray Date: Thu Feb 4 17:41:57 2010 New Revision: 77962 Log: Merged revisions 77943,77959-77960 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77943 | r.david.murray | 2010-02-03 08:36:23 -0500 (Wed, 03 Feb 2010) | 2 lines Explicitly mention the default value for formatdate's usegmt parameter. ........ r77959 | nick.coghlan | 2010-02-04 07:43:58 -0500 (Thu, 04 Feb 2010) | 1 line Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert ........ r77960 | r.david.murray | 2010-02-04 11:33:31 -0500 (Thu, 04 Feb 2010) | 2 lines Add Chris Rebert to ACKS for issue 6760 Popen doc improvements. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/email.util.rst python/branches/py3k/Doc/library/subprocess.rst python/branches/py3k/Misc/ACKS Modified: python/branches/py3k/Doc/library/email.util.rst ============================================================================== --- python/branches/py3k/Doc/library/email.util.rst (original) +++ python/branches/py3k/Doc/library/email.util.rst Thu Feb 4 17:41:57 2010 @@ -102,7 +102,7 @@ Optional *usegmt* is a flag that when ``True``, outputs a date string with the timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. This is needed for some protocols (such as HTTP). This only applies when *localtime* is - ``False``. + ``False``. The default is ``False``. .. function:: make_msgid(idstring=None) Modified: python/branches/py3k/Doc/library/subprocess.rst ============================================================================== --- python/branches/py3k/Doc/library/subprocess.rst (original) +++ python/branches/py3k/Doc/library/subprocess.rst Thu Feb 4 17:41:57 2010 @@ -42,13 +42,38 @@ On Unix, with *shell=False* (default): In this case, the Popen class uses :meth:`os.execvp` to execute the child program. *args* should normally be a - sequence. A string will be treated as a sequence with the string as the only - item (the program to execute). + sequence. If a string is specified for *args*, it will be used as the name + or path of the program to execute; this will only work if the program is + being given no arguments. - On Unix, with *shell=True*: If args is a string, it specifies the command string - to execute through the shell. If *args* is a sequence, the first item specifies - the command string, and any additional items will be treated as additional shell - arguments. + .. note:: + + :meth:`shlex.split` can be useful when determining the correct + tokenization for *args*, especially in complex cases:: + + >>> import shlex, subprocess + >>> command_line = raw_input() + /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" + >>> args = shlex.split(command_line) + >>> print(args) + ['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"] + >>> p = subprocess.Popen(args) # Success! + + Note in particular that options (such as *-input*) and arguments (such + as *eggs.txt*) that are separated by whitespace in the shell go in separate + list elements, while arguments that need quoting or backslash escaping when + used in the shell (such as filenames containing spaces or the *echo* command + shown above) are single list elements. + + On Unix, with *shell=True*: If args is a string, it specifies the command + string to execute through the shell. This means that the string must be + formatted exactly as it would be when typed at the shell prompt. This + includes, for example, quoting or backslash escaping filenames with spaces in + them. If *args* is a sequence, the first item specifies the command string, and + any additional items will be treated as additional arguments to the shell + itself. That is to say, *Popen* does the equivalent of:: + + Popen(['/bin/sh', '-c', args[0], args[1], ...]) On Windows: the :class:`Popen` class uses CreateProcess() to execute the child program, which operates on strings. If *args* is a sequence, it will be Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Thu Feb 4 17:41:57 2010 @@ -616,6 +616,7 @@ Antti Rasinen Eric Raymond Edward K. Ream +Chris Rebert Marc Recht John Redford Terry Reedy From python-checkins at python.org Thu Feb 4 17:44:31 2010 From: python-checkins at python.org (r.david.murray) Date: Thu, 04 Feb 2010 16:44:31 -0000 Subject: [Python-checkins] r77963 - in python/branches/release31-maint: Doc/library/email.util.rst Doc/library/subprocess.rst Misc/ACKS Message-ID: Author: r.david.murray Date: Thu Feb 4 17:44:31 2010 New Revision: 77963 Log: Merged revisions 77962 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r77962 | r.david.murray | 2010-02-04 11:41:57 -0500 (Thu, 04 Feb 2010) | 17 lines Merged revisions 77943,77959-77960 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77943 | r.david.murray | 2010-02-03 08:36:23 -0500 (Wed, 03 Feb 2010) | 2 lines Explicitly mention the default value for formatdate's usegmt parameter. ........ r77959 | nick.coghlan | 2010-02-04 07:43:58 -0500 (Thu, 04 Feb 2010) | 1 line Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert ........ r77960 | r.david.murray | 2010-02-04 11:33:31 -0500 (Thu, 04 Feb 2010) | 2 lines Add Chris Rebert to ACKS for issue 6760 Popen doc improvements. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/email.util.rst python/branches/release31-maint/Doc/library/subprocess.rst python/branches/release31-maint/Misc/ACKS Modified: python/branches/release31-maint/Doc/library/email.util.rst ============================================================================== --- python/branches/release31-maint/Doc/library/email.util.rst (original) +++ python/branches/release31-maint/Doc/library/email.util.rst Thu Feb 4 17:44:31 2010 @@ -102,7 +102,7 @@ Optional *usegmt* is a flag that when ``True``, outputs a date string with the timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. This is needed for some protocols (such as HTTP). This only applies when *localtime* is - ``False``. + ``False``. The default is ``False``. .. function:: make_msgid(idstring=None) Modified: python/branches/release31-maint/Doc/library/subprocess.rst ============================================================================== --- python/branches/release31-maint/Doc/library/subprocess.rst (original) +++ python/branches/release31-maint/Doc/library/subprocess.rst Thu Feb 4 17:44:31 2010 @@ -42,13 +42,38 @@ On Unix, with *shell=False* (default): In this case, the Popen class uses :meth:`os.execvp` to execute the child program. *args* should normally be a - sequence. A string will be treated as a sequence with the string as the only - item (the program to execute). + sequence. If a string is specified for *args*, it will be used as the name + or path of the program to execute; this will only work if the program is + being given no arguments. - On Unix, with *shell=True*: If args is a string, it specifies the command string - to execute through the shell. If *args* is a sequence, the first item specifies - the command string, and any additional items will be treated as additional shell - arguments. + .. note:: + + :meth:`shlex.split` can be useful when determining the correct + tokenization for *args*, especially in complex cases:: + + >>> import shlex, subprocess + >>> command_line = raw_input() + /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" + >>> args = shlex.split(command_line) + >>> print(args) + ['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"] + >>> p = subprocess.Popen(args) # Success! + + Note in particular that options (such as *-input*) and arguments (such + as *eggs.txt*) that are separated by whitespace in the shell go in separate + list elements, while arguments that need quoting or backslash escaping when + used in the shell (such as filenames containing spaces or the *echo* command + shown above) are single list elements. + + On Unix, with *shell=True*: If args is a string, it specifies the command + string to execute through the shell. This means that the string must be + formatted exactly as it would be when typed at the shell prompt. This + includes, for example, quoting or backslash escaping filenames with spaces in + them. If *args* is a sequence, the first item specifies the command string, and + any additional items will be treated as additional arguments to the shell + itself. That is to say, *Popen* does the equivalent of:: + + Popen(['/bin/sh', '-c', args[0], args[1], ...]) On Windows: the :class:`Popen` class uses CreateProcess() to execute the child program, which operates on strings. If *args* is a sequence, it will be Modified: python/branches/release31-maint/Misc/ACKS ============================================================================== --- python/branches/release31-maint/Misc/ACKS (original) +++ python/branches/release31-maint/Misc/ACKS Thu Feb 4 17:44:31 2010 @@ -603,6 +603,7 @@ Antti Rasinen Eric Raymond Edward K. Ream +Chris Rebert Marc Recht John Redford Terry Reedy From python-checkins at python.org Thu Feb 4 17:56:45 2010 From: python-checkins at python.org (tarek.ziade) Date: Thu, 04 Feb 2010 16:56:45 -0000 Subject: [Python-checkins] r77964 - in peps/trunk: pep-0345.txt pep-0386.txt Message-ID: Author: tarek.ziade Date: Thu Feb 4 17:56:45 2010 New Revision: 77964 Log: added David Lyon to the contributors list Modified: peps/trunk/pep-0345.txt peps/trunk/pep-0386.txt Modified: peps/trunk/pep-0345.txt ============================================================================== --- peps/trunk/pep-0345.txt (original) +++ peps/trunk/pep-0345.txt Thu Feb 4 17:56:45 2010 @@ -561,8 +561,9 @@ Fred Drake, Anthony Baxter and Matthias Klose have all contributed to the ideas presented in this PEP. -Tres Seaver, Jim Fulton, Marc-Andr? Lemburg, Martin von L?wis, Tarek Ziad? and -other people at the Distutils-SIG have contributed to the new updated version. +Tres Seaver, Jim Fulton, Marc-Andr? Lemburg, Martin von L?wis, Tarek Ziad?, +David Lyon and other people at the Distutils-SIG have contributed to the +new updated version. .. Modified: peps/trunk/pep-0386.txt ============================================================================== --- peps/trunk/pep-0386.txt (original) +++ peps/trunk/pep-0386.txt Thu Feb 4 17:56:45 2010 @@ -350,6 +350,8 @@ ... < V('1.0')) True +Note that ``c`` is the preferred marker for third party projects. + ``verlib`` provides a ``NormalizedVersion`` class and a ``suggest_normalized_version`` function. @@ -501,8 +503,8 @@ Acknowledgments =============== -Trent Mick, Matthias Klose, Phillip Eby, and many people at Pycon and -Distutils-SIG. +Trent Mick, Matthias Klose, Phillip Eby, David Lyon, and many people at Pycon +and Distutils-SIG. Copyright ========= From python-checkins at python.org Thu Feb 4 18:02:07 2010 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 04 Feb 2010 17:02:07 -0000 Subject: [Python-checkins] r77965 - python/branches/py3k/Modules/_testcapimodule.c Message-ID: Author: antoine.pitrou Date: Thu Feb 4 18:02:07 2010 New Revision: 77965 Log: Followup to r77918: fix build under Windows. Modified: python/branches/py3k/Modules/_testcapimodule.c Modified: python/branches/py3k/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k/Modules/_testcapimodule.c (original) +++ python/branches/py3k/Modules/_testcapimodule.c Thu Feb 4 18:02:07 2010 @@ -303,7 +303,7 @@ }; static PyTypeObject _MemoryViewTester_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) + PyVarObject_HEAD_INIT(NULL, 0) "memoryviewtester", /* Name of this type */ sizeof(PyObject), /* Basic object size */ 0, /* Item size for varobject */ @@ -2245,6 +2245,7 @@ return NULL; Py_TYPE(&_HashInheritanceTester_Type)=&PyType_Type; + Py_TYPE(&_MemoryViewTester_Type)=&PyType_Type; Py_TYPE(&test_structmembersType)=&PyType_Type; Py_INCREF(&test_structmembersType); From python-checkins at python.org Thu Feb 4 18:03:40 2010 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 04 Feb 2010 17:03:40 -0000 Subject: [Python-checkins] r77966 - in python/branches/release31-maint: Modules/_testcapimodule.c Message-ID: Author: antoine.pitrou Date: Thu Feb 4 18:03:40 2010 New Revision: 77966 Log: Merged revisions 77965 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r77965 | antoine.pitrou | 2010-02-04 18:02:07 +0100 (jeu., 04 f?vr. 2010) | 3 lines Followup to r77918: fix build under Windows. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/_testcapimodule.c Modified: python/branches/release31-maint/Modules/_testcapimodule.c ============================================================================== --- python/branches/release31-maint/Modules/_testcapimodule.c (original) +++ python/branches/release31-maint/Modules/_testcapimodule.c Thu Feb 4 18:03:40 2010 @@ -302,7 +302,7 @@ }; static PyTypeObject _MemoryViewTester_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) + PyVarObject_HEAD_INIT(NULL, 0) "memoryviewtester", /* Name of this type */ sizeof(PyObject), /* Basic object size */ 0, /* Item size for varobject */ @@ -1831,6 +1831,7 @@ return NULL; Py_TYPE(&_HashInheritanceTester_Type)=&PyType_Type; + Py_TYPE(&_MemoryViewTester_Type)=&PyType_Type; Py_TYPE(&test_structmembersType)=&PyType_Type; Py_INCREF(&test_structmembersType); From python-checkins at python.org Thu Feb 4 19:48:54 2010 From: python-checkins at python.org (vinay.sajip) Date: Thu, 04 Feb 2010 18:48:54 -0000 Subject: [Python-checkins] r77967 - in python/trunk: Lib/logging/config.py Lib/test/test_logging.py Misc/NEWS Message-ID: Author: vinay.sajip Date: Thu Feb 4 19:48:53 2010 New Revision: 77967 Log: Logging: Implemented PEP 391. Modified: python/trunk/Lib/logging/config.py python/trunk/Lib/test/test_logging.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/logging/config.py ============================================================================== --- python/trunk/Lib/logging/config.py (original) +++ python/trunk/Lib/logging/config.py Thu Feb 4 19:48:53 2010 @@ -1,4 +1,4 @@ -# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -19,12 +19,13 @@ is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. -Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, socket, struct, os, traceback +import sys, logging, logging.handlers, socket, struct, os, traceback, re +import types, cStringIO try: import thread @@ -64,6 +65,7 @@ """ import ConfigParser + print >> open('/tmp/tmp.txt', 'w'), fname.getvalue() cp = ConfigParser.ConfigParser(defaults) if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): cp.readfp(fname) @@ -264,6 +266,496 @@ logger.disabled = 1 + +IDENTIFIER = re.compile('^[a-z_][a-z0-9_]*$', re.I) + + +def valid_ident(s): + m = IDENTIFIER.match(s) + if not m: + raise ValueError('Not a valid Python identifier: %r' % s) + return True + + +# The ConvertingXXX classes are wrappers around standard Python containers, +# and they serve to convert any suitable values in the container. The +# conversion converts base dicts, lists and tuples to their wrapped +# equivalents, whereas strings which match a conversion format are converted +# appropriately. +# +# Each wrapper should have a configurator attribute holding the actual +# configurator to use for conversion. + +class ConvertingDict(dict): + """A converting dictionary wrapper.""" + + def __getitem__(self, key): + value = dict.__getitem__(self, key) + result = self.configurator.convert(value) + #If the converted value is different, save for next time + if value is not result: + self[key] = result + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + + def get(self, key, default=None): + value = dict.get(self, key, default) + result = self.configurator.convert(value) + #If the converted value is different, save for next time + if value is not result: + self[key] = result + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + + def pop(self, key, default=None): + value = dict.pop(self, key, default) + result = self.configurator.convert(value) + if value is not result: + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + +class ConvertingList(list): + """A converting list wrapper.""" + def __getitem__(self, key): + value = list.__getitem__(self, key) + result = self.configurator.convert(value) + #If the converted value is different, save for next time + if value is not result: + self[key] = result + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + + def pop(self, idx=-1): + value = list.pop(self, idx) + result = self.configurator.convert(value) + if value is not result: + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + return result + +class ConvertingTuple(tuple): + """A converting tuple wrapper.""" + def __getitem__(self, key): + value = tuple.__getitem__(self, key) + result = self.configurator.convert(value) + if value is not result: + if type(result) in (ConvertingDict, ConvertingList, + ConvertingTuple): + result.parent = self + result.key = key + return result + +class BaseConfigurator(object): + """ + The configurator base class which defines some useful defaults. + """ + + CONVERT_PATTERN = re.compile(r'^(?P[a-z]+)://(?P.*)$') + + WORD_PATTERN = re.compile(r'^\s*(\w+)\s*') + DOT_PATTERN = re.compile(r'^\.\s*(\w+)\s*') + INDEX_PATTERN = re.compile(r'^\[\s*(\w+)\s*\]\s*') + DIGIT_PATTERN = re.compile(r'^\d+$') + + value_converters = { + 'ext' : 'ext_convert', + 'cfg' : 'cfg_convert', + } + + # We might want to use a different one, e.g. importlib + importer = __import__ + + def __init__(self, config): + self.config = ConvertingDict(config) + self.config.configurator = self + + def resolve(self, s): + """ + Resolve strings to objects using standard import and attribute + syntax. + """ + name = s.split('.') + used = name.pop(0) + found = self.importer(used) + for frag in name: + used += '.' + frag + try: + found = getattr(found, frag) + except AttributeError: + self.importer(used) + found = getattr(found, frag) + return found + + def ext_convert(self, value): + """Default converter for the ext:// protocol.""" + return self.resolve(value) + + def cfg_convert(self, value): + """Default converter for the cfg:// protocol.""" + rest = value + m = self.WORD_PATTERN.match(rest) + if m is None: + raise ValueError("Unable to convert %r" % value) + else: + rest = rest[m.end():] + d = self.config[m.groups()[0]] + #print d, rest + while rest: + m = self.DOT_PATTERN.match(rest) + if m: + d = d[m.groups()[0]] + else: + m = self.INDEX_PATTERN.match(rest) + if m: + idx = m.groups()[0] + if not self.DIGIT_PATTERN.match(idx): + d = d[idx] + else: + try: + n = int(idx) # try as number first (most likely) + d = d[n] + except TypeError: + d = d[idx] + if m: + rest = rest[m.end():] + else: + raise ValueError('Unable to convert ' + '%r at %r' % (value, rest)) + #rest should be empty + return d + + def convert(self, value): + """ + Convert values to an appropriate type. dicts, lists and tuples are + replaced by their converting alternatives. Strings are checked to + see if they have a conversion format and are converted if they do. + """ + if not isinstance(value, ConvertingDict) and isinstance(value, dict): + value = ConvertingDict(value) + value.configurator = self + elif not isinstance(value, ConvertingList) and isinstance(value, list): + value = ConvertingList(value) + value.configurator = self + elif not isinstance(value, ConvertingTuple) and\ + isinstance(value, tuple): + value = ConvertingTuple(value) + value.configurator = self + elif isinstance(value, basestring): # str for py3k + m = self.CONVERT_PATTERN.match(value) + if m: + d = m.groupdict() + prefix = d['prefix'] + converter = self.value_converters.get(prefix, None) + if converter: + suffix = d['suffix'] + converter = getattr(self, converter) + value = converter(suffix) + return value + + def configure_custom(self, config): + """Configure an object with a user-supplied factory.""" + c = config.pop('()') + if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType: + c = self.resolve(c) + props = config.pop('.', None) + # Check for valid identifiers + kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) + result = c(**kwargs) + if props: + for name, value in props.items(): + setattr(result, name, value) + return result + +class DictConfigurator(BaseConfigurator): + """ + Configure logging using a dictionary-like object to describe the + configuration. + """ + + def configure(self): + """Do the configuration.""" + + config = self.config + incremental = config.pop('incremental', False) + EMPTY_DICT = {} + logging._acquireLock() + try: + if incremental: + handlers = config.get('handlers', EMPTY_DICT) + for name in handlers: + if name not in logging._handlers: + raise ValueError('No handler found with ' + 'name %r' % name) + else: + try: + handler = logging._handlers[name] + handler_config = handlers[name] + level = handler_config.get('level', None) + if level: + handler.setLevel(logging._checkLevel(level)) + except StandardError, e: + raise ValueError('Unable to configure handler ' + '%r: %s' % (name, e)) + loggers = config.get('loggers', EMPTY_DICT) + for name in loggers: + try: + self.configure_logger(name, loggers[name], True) + except StandardError, e: + raise ValueError('Unable to configure logger ' + '%r: %s' % (name, e)) + root = config.get('root', None) + if root: + try: + self.configure_root(root, True) + except StandardError, e: + raise ValueError('Unable to configure root ' + 'logger: %s' % e) + else: + disable_existing = config.pop('disable_existing_loggers', True) + + logging._handlers.clear() + del logging._handlerList[:] + + # Do formatters first - they don't refer to anything else + formatters = config.get('formatters', EMPTY_DICT) + for name in formatters: + try: + formatters[name] = self.configure_formatter( + formatters[name]) + except StandardError, e: + raise ValueError('Unable to configure ' + 'formatter %r: %s' % (name, e)) + # Next, do filters - they don't refer to anything else, either + filters = config.get('filters', EMPTY_DICT) + for name in filters: + try: + filters[name] = self.configure_filter(filters[name]) + except StandardError, e: + raise ValueError('Unable to configure ' + 'filter %r: %s' % (name, e)) + + # Next, do handlers - they refer to formatters and filters + # As handlers can refer to other handlers, sort the keys + # to allow a deterministic order of configuration + handlers = config.get('handlers', EMPTY_DICT) + for name in sorted(handlers): + try: + handler = self.configure_handler(handlers[name]) + handler.name = name + handlers[name] = handler + except StandardError, e: + raise ValueError('Unable to configure handler ' + '%r: %s' % (name, e)) + # Next, do loggers - they refer to handlers and filters + + #we don't want to lose the existing loggers, + #since other threads may have pointers to them. + #existing is set to contain all existing loggers, + #and as we go through the new configuration we + #remove any which are configured. At the end, + #what's left in existing is the set of loggers + #which were in the previous configuration but + #which are not in the new configuration. + root = logging.root + existing = root.manager.loggerDict.keys() + #The list needs to be sorted so that we can + #avoid disabling child loggers of explicitly + #named loggers. With a sorted list it is easier + #to find the child loggers. + existing.sort() + #We'll keep the list of existing loggers + #which are children of named loggers here... + child_loggers = [] + #now set up the new ones... + loggers = config.get('loggers', EMPTY_DICT) + for name in loggers: + if name in existing: + i = existing.index(name) + prefixed = name + "." + pflen = len(prefixed) + num_existing = len(existing) + i = i + 1 # look at the entry after name + while (i < num_existing) and\ + (existing[i][:pflen] == prefixed): + child_loggers.append(existing[i]) + i = i + 1 + existing.remove(name) + try: + self.configure_logger(name, loggers[name]) + except StandardError, e: + raise ValueError('Unable to configure logger ' + '%r: %s' % (name, e)) + + #Disable any old loggers. There's no point deleting + #them as other threads may continue to hold references + #and by disabling them, you stop them doing any logging. + #However, don't disable children of named loggers, as that's + #probably not what was intended by the user. + for log in existing: + logger = root.manager.loggerDict[log] + if log in child_loggers: + logger.level = logging.NOTSET + logger.handlers = [] + logger.propagate = True + elif disable_existing: + logger.disabled = True + + # And finally, do the root logger + root = config.get('root', None) + if root: + try: + self.configure_root(root) + except StandardError, e: + raise ValueError('Unable to configure root ' + 'logger: %s' % e) + finally: + logging._releaseLock() + + def configure_formatter(self, config): + """Configure a formatter from a dictionary.""" + if '()' in config: + factory = config['()'] # for use in exception handler + try: + result = self.configure_custom(config) + except TypeError, te: + if "'format'" not in str(te): + raise + #Name of parameter changed from fmt to format. + #Retry with old name. + #This is so that code can be used with older Python versions + #(e.g. by Django) + config['fmt'] = config.pop('format') + config['()'] = factory + result = self.configure_custom(config) + else: + fmt = config.get('format', None) + dfmt = config.get('datefmt', None) + result = logging.Formatter(fmt, dfmt) + return result + + def configure_filter(self, config): + """Configure a filter from a dictionary.""" + if '()' in config: + result = self.configure_custom(config) + else: + name = config.get('name', '') + result = logging.Filter(name) + return result + + def add_filters(self, filterer, filters): + """Add filters to a filterer from a list of names.""" + for f in filters: + try: + filterer.addFilter(self.config['filters'][f]) + except StandardError, e: + raise ValueError('Unable to add filter %r: %s' % (f, e)) + + def configure_handler(self, config): + """Configure a handler from a dictionary.""" + formatter = config.pop('formatter', None) + if formatter: + try: + formatter = self.config['formatters'][formatter] + except StandardError, e: + raise ValueError('Unable to set formatter ' + '%r: %s' % (formatter, e)) + level = config.pop('level', None) + filters = config.pop('filters', None) + if '()' in config: + c = config.pop('()') + if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType: + c = self.resolve(c) + factory = c + else: + klass = self.resolve(config.pop('class')) + #Special case for handler which refers to another handler + if issubclass(klass, logging.handlers.MemoryHandler) and\ + 'target' in config: + try: + config['target'] = self.config['handlers'][config['target']] + except StandardError, e: + raise ValueError('Unable to set target handler ' + '%r: %s' % (config['target'], e)) + factory = klass + kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) + try: + result = factory(**kwargs) + except TypeError, te: + if "'stream'" not in str(te): + raise + #The argument name changed from strm to stream + #Retry with old name. + #This is so that code can be used with older Python versions + #(e.g. by Django) + kwargs['strm'] = kwargs.pop('stream') + result = factory(**kwargs) + if formatter: + result.setFormatter(formatter) + if level is not None: + result.setLevel(logging._checkLevel(level)) + if filters: + self.add_filters(result, filters) + return result + + def add_handlers(self, logger, handlers): + """Add handlers to a logger from a list of names.""" + for h in handlers: + try: + logger.addHandler(self.config['handlers'][h]) + except StandardError, e: + raise ValueError('Unable to add handler %r: %s' % (h, e)) + + def common_logger_config(self, logger, config, incremental=False): + """ + Perform configuration which is common to root and non-root loggers. + """ + level = config.get('level', None) + if level is not None: + logger.setLevel(logging._checkLevel(level)) + if not incremental: + #Remove any existing handlers + for h in logger.handlers[:]: + logger.removeHandler(h) + handlers = config.get('handlers', None) + if handlers: + self.add_handlers(logger, handlers) + filters = config.get('filters', None) + if filters: + self.add_filters(logger, filters) + + def configure_logger(self, name, config, incremental=False): + """Configure a non-root logger from a dictionary.""" + logger = logging.getLogger(name) + self.common_logger_config(logger, config, incremental) + propagate = config.get('propagate', None) + if propagate is not None: + logger.propagate = propagate + + def configure_root(self, config, incremental=False): + """Configure a root logger from a dictionary.""" + root = logging.getLogger() + self.common_logger_config(root, config, incremental) + +dictConfigClass = DictConfigurator + +def dictConfig(config): + """Configure logging using a dictionary.""" + dictConfigClass(config).configure() + + def listen(port=DEFAULT_LOGGING_CONFIG_PORT): """ Start up a socket server on the specified port, and listen for new @@ -301,22 +793,21 @@ chunk = self.connection.recv(slen) while len(chunk) < slen: chunk = chunk + conn.recv(slen - len(chunk)) - #Apply new configuration. We'd like to be able to - #create a StringIO and pass that in, but unfortunately - #1.5.2 ConfigParser does not support reading file - #objects, only actual files. So we create a temporary - #file and remove it later. - file = tempfile.mktemp(".ini") - f = open(file, "w") - f.write(chunk) - f.close() try: - fileConfig(file) - except (KeyboardInterrupt, SystemExit): - raise + import json + d =json.loads(chunk) + assert isinstance(d, dict) + dictConfig(d) except: - traceback.print_exc() - os.remove(file) + #Apply new configuration. + + file = cStringIO.StringIO(chunk) + try: + fileConfig(file) + except (KeyboardInterrupt, SystemExit): + raise + except: + traceback.print_exc() except socket.error, e: if not isinstance(e.args, tuple): raise Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Thu Feb 4 19:48:53 2010 @@ -30,6 +30,7 @@ import cPickle import cStringIO import gc +import json import os import re import select @@ -85,6 +86,10 @@ level.""" self.stream.close() self.root_logger.removeHandler(self.root_hdlr) + while self.root_logger.handlers: + h = self.root_logger.handlers[0] + self.root_logger.removeHandler(h) + h.close() self.root_logger.setLevel(self.original_logging_level) logging._acquireLock() try: @@ -632,14 +637,8 @@ """ def apply_config(self, conf): - try: - fn = tempfile.mktemp(".ini") - f = open(fn, "w") - f.write(textwrap.dedent(conf)) - f.close() - logging.config.fileConfig(fn) - finally: - os.remove(fn) + file = cStringIO.StringIO(textwrap.dedent(conf)) + logging.config.fileConfig(file) def test_config0_ok(self): # A simple config file which overrides the default settings. @@ -938,6 +937,662 @@ finally: logging.captureWarnings(False) + +def formatFunc(format, datefmt=None): + return logging.Formatter(format, datefmt) + +def handlerFunc(): + return logging.StreamHandler() + +class CustomHandler(logging.StreamHandler): + pass + +class ConfigDictTest(BaseTest): + + """Reading logging config from a dictionary.""" + + expected_log_pat = r"^([\w]+) \+\+ ([\w]+)$" + + # config0 is a standard configuration. + config0 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'root' : { + 'level' : 'WARNING', + 'handlers' : ['hand1'], + }, + } + + # config1 adds a little to the standard configuration. + config1 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + # config2 has a subtle configuration error that should be reported + config2 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdbout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + #As config1 but with a misspelt level on a handler + config2a = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NTOSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + + #As config1 but with a misspelt level on a logger + config2b = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WRANING', + }, + } + + # config3 has a less subtle configuration error + config3 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'misspelled_name', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + # config4 specifies a custom formatter class to be loaded + config4 = { + 'formatters': { + 'form1' : { + '()' : __name__ + '.ExceptionFormatter', + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'root' : { + 'level' : 'NOTSET', + 'handlers' : ['hand1'], + }, + } + + # As config4 but using an actual callable rather than a string + config4a = { + 'formatters': { + 'form1' : { + '()' : ExceptionFormatter, + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + 'form2' : { + '()' : __name__ + '.formatFunc', + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + 'form3' : { + '()' : formatFunc, + 'format' : '%(levelname)s:%(name)s:%(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + 'hand2' : { + '()' : handlerFunc, + }, + }, + 'root' : { + 'level' : 'NOTSET', + 'handlers' : ['hand1'], + }, + } + + # config5 specifies a custom handler class to be loaded + config5 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : __name__ + '.CustomHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + # config6 specifies a custom handler class to be loaded + # but has bad arguments + config6 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : __name__ + '.CustomHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + '9' : 'invalid parameter name', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + #config 7 does not define compiler.parser but defines compiler.lexer + #so compiler.parser should be disabled after applying it + config7 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.lexer' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + config8 = { + 'disable_existing_loggers' : False, + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + 'compiler.lexer' : { + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + + config9 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'WARNING', + 'stream' : 'ext://sys.stdout', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'WARNING', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'NOTSET', + }, + } + + config9a = { + 'incremental' : True, + 'handlers' : { + 'hand1' : { + 'level' : 'WARNING', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'INFO', + }, + }, + } + + config9b = { + 'incremental' : True, + 'handlers' : { + 'hand1' : { + 'level' : 'INFO', + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'INFO', + }, + }, + } + + #As config1 but with a filter added + config10 = { + 'formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'filters' : { + 'filt1' : { + 'name' : 'compiler.parser', + }, + }, + 'handlers' : { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + 'filters' : ['filt1'], + }, + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'filters' : ['filt1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + 'handlers' : ['hand1'], + }, + } + + def apply_config(self, conf): + logging.config.dictConfig(conf) + + def test_config0_ok(self): + # A simple config which overrides the default settings. + with captured_stdout() as output: + self.apply_config(self.config0) + logger = logging.getLogger() + # Won't output anything + logger.info(self.next_message()) + # Outputs a message + logger.error(self.next_message()) + self.assert_log_lines([ + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + def test_config1_ok(self, config=config1): + # A config defining a sub-parser as well. + with captured_stdout() as output: + self.apply_config(config) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + def test_config2_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(StandardError, self.apply_config, self.config2) + + def test_config2a_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(StandardError, self.apply_config, self.config2a) + + def test_config2b_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(StandardError, self.apply_config, self.config2b) + + def test_config3_failure(self): + # A simple config which overrides the default settings. + self.assertRaises(StandardError, self.apply_config, self.config3) + + def test_config4_ok(self): + # A config specifying a custom formatter class. + with captured_stdout() as output: + self.apply_config(self.config4) + #logger = logging.getLogger() + try: + raise RuntimeError() + except RuntimeError: + logging.exception("just testing") + sys.stdout.seek(0) + self.assertEquals(output.getvalue(), + "ERROR:root:just testing\nGot a [RuntimeError]\n") + # Original logger output is empty + self.assert_log_lines([]) + + def test_config4a_ok(self): + # A config specifying a custom formatter class. + with captured_stdout() as output: + self.apply_config(self.config4a) + #logger = logging.getLogger() + try: + raise RuntimeError() + except RuntimeError: + logging.exception("just testing") + sys.stdout.seek(0) + self.assertEquals(output.getvalue(), + "ERROR:root:just testing\nGot a [RuntimeError]\n") + # Original logger output is empty + self.assert_log_lines([]) + + def test_config5_ok(self): + self.test_config1_ok(config=self.config5) + + def test_config6_failure(self): + self.assertRaises(StandardError, self.apply_config, self.config6) + + def test_config7_ok(self): + with captured_stdout() as output: + self.apply_config(self.config1) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + with captured_stdout() as output: + self.apply_config(self.config7) + logger = logging.getLogger("compiler.parser") + self.assertTrue(logger.disabled) + logger = logging.getLogger("compiler.lexer") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '3'), + ('ERROR', '4'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + #Same as test_config_7_ok but don't disable old loggers. + def test_config_8_ok(self): + with captured_stdout() as output: + self.apply_config(self.config1) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + with captured_stdout() as output: + self.apply_config(self.config8) + logger = logging.getLogger("compiler.parser") + self.assertFalse(logger.disabled) + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + logger = logging.getLogger("compiler.lexer") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '3'), + ('ERROR', '4'), + ('INFO', '5'), + ('ERROR', '6'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + def test_config_9_ok(self): + with captured_stdout() as output: + self.apply_config(self.config9) + logger = logging.getLogger("compiler.parser") + #Nothing will be output since both handler and logger are set to WARNING + logger.info(self.next_message()) + self.assert_log_lines([], stream=output) + self.apply_config(self.config9a) + #Nothing will be output since both handler is still set to WARNING + logger.info(self.next_message()) + self.assert_log_lines([], stream=output) + self.apply_config(self.config9b) + #Message should now be output + logger.info(self.next_message()) + self.assert_log_lines([ + ('INFO', '3'), + ], stream=output) + + def test_config_10_ok(self): + with captured_stdout() as output: + self.apply_config(self.config10) + logger = logging.getLogger("compiler.parser") + logger.warning(self.next_message()) + logger = logging.getLogger('compiler') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger('compiler.lexer') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger("compiler.parser.codegen") + #Output, as not filtered + logger.error(self.next_message()) + self.assert_log_lines([ + ('WARNING', '1'), + ('ERROR', '4'), + ], stream=output) + + def setup_via_listener(self, text): + PORT = 9030 + t = logging.config.listen(PORT) + t.start() + + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect(('localhost', PORT)) + + slen = struct.pack('>L', len(text)) + s = slen + text + sentsofar = 0 + left = len(s) + while left > 0: + sent = sock.send(s[sentsofar:]) + sentsofar += sent + left -= sent + sock.close() + logging.config.stopListening() + t.join() + + def test_listen_config_10_ok(self): + with captured_stdout() as output: + self.setup_via_listener(json.dumps(self.config10)) + logger = logging.getLogger("compiler.parser") + logger.warning(self.next_message()) + logger = logging.getLogger('compiler') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger('compiler.lexer') + #Not output, because filtered + logger.warning(self.next_message()) + logger = logging.getLogger("compiler.parser.codegen") + #Output, as not filtered + logger.error(self.next_message()) + self.assert_log_lines([ + ('WARNING', '1'), + ('ERROR', '4'), + ], stream=output) + + def test_listen_config_1_ok(self): + with captured_stdout() as output: + self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) + logger = logging.getLogger("compiler.parser") + # Both will output a message + logger.info(self.next_message()) + logger.error(self.next_message()) + self.assert_log_lines([ + ('INFO', '1'), + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + + # Set the locale to the platform-dependent default. I have no idea # why the test does this, but in any case we save the current locale # first and restore it at the end. @@ -946,7 +1601,7 @@ run_unittest(BuiltinLevelsTest, BasicFilterTest, CustomLevelsAndFiltersTest, MemoryHandlerTest, ConfigFileTest, SocketHandlerTest, MemoryTest, - EncodingTest, WarningsTest) + EncodingTest, WarningsTest, ConfigDictTest) if __name__ == "__main__": test_main() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Feb 4 19:48:53 2010 @@ -55,6 +55,8 @@ Library ------- +- logging: Implemented PEP 391. + - Issue #6939: Fix file I/O objects in the `io` module to keep the original file position when calling `truncate()`. It would previously change the file position to the given argument, which goes against the tradition of From amk at amk.ca Thu Feb 4 20:25:14 2010 From: amk at amk.ca (A.M. Kuchling) Date: Thu, 4 Feb 2010 14:25:14 -0500 Subject: [Python-checkins] r77967 - in python/trunk: Lib/logging/config.py Lib/test/test_logging.py Misc/NEWS In-Reply-To: <20100204184906.DBF4A2C980D7@connor.dreamhost.com> References: <20100204184906.DBF4A2C980D7@connor.dreamhost.com> Message-ID: <20100204192514.GA13768@amk-desktop.matrixgroup.net> On Thu, Feb 04, 2010 at 10:49:06AM -0800, vinay.sajip wrote: > @@ -64,6 +65,7 @@ > """ > import ConfigParser > > + print >> open('/tmp/tmp.txt', 'w'), fname.getvalue() > cp = ConfigParser.ConfigParser(defaults) > if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): > cp.readfp(fname) This looks like debugging code. > + if type(result) in (ConvertingDict, ConvertingList, > + ConvertingTuple): Can you use isinstance() here, or does Python version compatibility rule that out? (I don't remember what logging tries to support.) --amk From eric at trueblade.com Wed Feb 3 15:21:34 2010 From: eric at trueblade.com (Eric Smith) Date: Wed, 03 Feb 2010 09:21:34 -0500 Subject: [Python-checkins] r77946 - python/branches/py3k In-Reply-To: <20100203141931.1AC13181818C@tok.trueblade.com> References: <20100203141931.1AC13181818C@tok.trueblade.com> Message-ID: <4B69866E.50802@trueblade.com> Oops, I realize I shouldn't have blocked this. I'll forward port the change. eric.smith wrote: > Author: eric.smith > Date: Wed Feb 3 15:19:27 2010 > New Revision: 77946 > > Log: > Blocked revisions 77944 via svnmerge > > ........ > r77944 | eric.smith | 2010-02-03 09:17:50 -0500 (Wed, 03 Feb 2010) | 1 line > > Corrected list of attributes exposed by sys.getwindowsversion. > ........ > > > Modified: > python/branches/py3k/ (props changed) > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Thu Feb 4 21:06:39 2010 From: python-checkins at python.org (ezio.melotti) Date: Thu, 04 Feb 2010 20:06:39 -0000 Subject: [Python-checkins] r77968 - python/trunk/Doc/library/unittest.rst Message-ID: Author: ezio.melotti Date: Thu Feb 4 21:06:38 2010 New Revision: 77968 Log: Use correct assert* methods in the examples. Modified: python/trunk/Doc/library/unittest.rst Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Thu Feb 4 21:06:38 2010 @@ -121,12 +121,12 @@ def test_choice(self): element = random.choice(self.seq) - self.assert_(element in self.seq) + self.assertIn(element, self.seq) def test_sample(self): self.assertRaises(ValueError, random.sample, self.seq, 20) for element in random.sample(self.seq, 5): - self.assert_(element in self.seq) + self.assertIn(element, self.seq) if __name__ == '__main__': unittest.main() @@ -307,14 +307,14 @@ class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): - self.assertTrue(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') class WidgetResizeTestCase(SimpleWidgetTestCase): def runTest(self): self.widget.resize(100,150) - self.assertTrue(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') If the :meth:`~TestCase.setUp` method raises an exception while the test is running, the framework will consider the test to have suffered an error, and the @@ -355,13 +355,13 @@ self.widget = None def testDefaultSize(self): - self.assertTrue(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') def testResize(self): self.widget.resize(100,150) - self.assertTrue(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') Here we have not provided a :meth:`~TestCase.runTest` method, but have instead provided two different test methods. Class instances will now each run one of From python-checkins at python.org Thu Feb 4 21:18:29 2010 From: python-checkins at python.org (vinay.sajip) Date: Thu, 04 Feb 2010 20:18:29 -0000 Subject: [Python-checkins] r77969 - python/trunk/Lib/logging/config.py Message-ID: Author: vinay.sajip Date: Thu Feb 4 21:18:28 2010 New Revision: 77969 Log: Removed spurious print statement. Modified: python/trunk/Lib/logging/config.py Modified: python/trunk/Lib/logging/config.py ============================================================================== --- python/trunk/Lib/logging/config.py (original) +++ python/trunk/Lib/logging/config.py Thu Feb 4 21:18:28 2010 @@ -65,7 +65,6 @@ """ import ConfigParser - print >> open('/tmp/tmp.txt', 'w'), fname.getvalue() cp = ConfigParser.ConfigParser(defaults) if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): cp.readfp(fname) From python-checkins at python.org Thu Feb 4 21:20:18 2010 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 04 Feb 2010 20:20:18 -0000 Subject: [Python-checkins] r77970 - in python/trunk: Misc/NEWS Modules/socketmodule.c Message-ID: Author: antoine.pitrou Date: Thu Feb 4 21:20:18 2010 New Revision: 77970 Log: Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is specified, rather than fall through to AF_PACKET (in the `socket` module). Also, raise ValueError rather than TypeError when an unknown TIPC address type is specified. Patch by Brian Curtin. Modified: python/trunk/Misc/NEWS python/trunk/Modules/socketmodule.c Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Feb 4 21:20:18 2010 @@ -55,6 +55,11 @@ Library ------- +- Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is + specified, rather than fall through to AF_PACKET (in the `socket` module). + Also, raise ValueError rather than TypeError when an unknown TIPC address + type is specified. Patch by Brian Curtin. + - logging: Implemented PEP 391. - Issue #6939: Fix file I/O objects in the `io` module to keep the original Modified: python/trunk/Modules/socketmodule.c ============================================================================== --- python/trunk/Modules/socketmodule.c (original) +++ python/trunk/Modules/socketmodule.c Thu Feb 4 21:20:18 2010 @@ -1089,6 +1089,10 @@ } #endif + default: + PyErr_SetString(PyExc_ValueError, + "Unknown Bluetooth protocol"); + return NULL; } #endif @@ -1140,7 +1144,7 @@ 0, a->scope); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "Invalid address type"); return NULL; } From python-checkins at python.org Thu Feb 4 21:22:44 2010 From: python-checkins at python.org (ezio.melotti) Date: Thu, 04 Feb 2010 20:22:44 -0000 Subject: [Python-checkins] r77971 - in python/branches/release26-maint: Doc/library/unittest.rst Message-ID: Author: ezio.melotti Date: Thu Feb 4 21:22:44 2010 New Revision: 77971 Log: Merged revisions 77968 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77968 | ezio.melotti | 2010-02-04 22:06:38 +0200 (Thu, 04 Feb 2010) | 1 line Use correct assert* methods in the examples. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/unittest.rst Modified: python/branches/release26-maint/Doc/library/unittest.rst ============================================================================== --- python/branches/release26-maint/Doc/library/unittest.rst (original) +++ python/branches/release26-maint/Doc/library/unittest.rst Thu Feb 4 21:22:44 2010 @@ -114,12 +114,12 @@ def testchoice(self): element = random.choice(self.seq) - self.assert_(element in self.seq) + self.assertTrue(element in self.seq) def testsample(self): self.assertRaises(ValueError, random.sample, self.seq, 20) for element in random.sample(self.seq, 5): - self.assert_(element in self.seq) + self.assertTrue(element in self.seq) if __name__ == '__main__': unittest.main() @@ -234,14 +234,14 @@ class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): - self.failUnless(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') class WidgetResizeTestCase(SimpleWidgetTestCase): def runTest(self): self.widget.resize(100,150) - self.failUnless(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') If the :meth:`setUp` method raises an exception while the test is running, the framework will consider the test to have suffered an error, and the @@ -282,13 +282,13 @@ self.widget = None def testDefaultSize(self): - self.failUnless(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') def testResize(self): self.widget.resize(100,150) - self.failUnless(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') Here we have not provided a :meth:`runTest` method, but have instead provided two different test methods. Class instances will now each run one of the From python-checkins at python.org Thu Feb 4 21:23:24 2010 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 04 Feb 2010 20:23:24 -0000 Subject: [Python-checkins] r77972 - in python/branches/py3k: Misc/NEWS Modules/socketmodule.c Message-ID: Author: antoine.pitrou Date: Thu Feb 4 21:23:24 2010 New Revision: 77972 Log: Merged revisions 77970 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77970 | antoine.pitrou | 2010-02-04 21:20:18 +0100 (jeu., 04 f?vr. 2010) | 6 lines Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is specified, rather than fall through to AF_PACKET (in the `socket` module). Also, raise ValueError rather than TypeError when an unknown TIPC address type is specified. Patch by Brian Curtin. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/socketmodule.c Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Feb 4 21:23:24 2010 @@ -242,6 +242,11 @@ Library ------- +- Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is + specified, rather than fall through to AF_PACKET (in the `socket` module). + Also, raise ValueError rather than TypeError when an unknown TIPC address + type is specified. Patch by Brian Curtin. + - Issue #6939: Fix file I/O objects in the `io` module to keep the original file position when calling `truncate()`. It would previously change the file position to the given argument, which goes against the tradition of Modified: python/branches/py3k/Modules/socketmodule.c ============================================================================== --- python/branches/py3k/Modules/socketmodule.c (original) +++ python/branches/py3k/Modules/socketmodule.c Thu Feb 4 21:23:24 2010 @@ -1053,6 +1053,10 @@ } #endif + default: + PyErr_SetString(PyExc_ValueError, + "Unknown Bluetooth protocol"); + return NULL; } #endif @@ -1104,7 +1108,7 @@ 0, a->scope); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "Invalid address type"); return NULL; } From python-checkins at python.org Thu Feb 4 21:23:45 2010 From: python-checkins at python.org (vinay.sajip) Date: Thu, 04 Feb 2010 20:23:45 -0000 Subject: [Python-checkins] r77973 - in python/trunk: Doc/library/logging.rst Misc/NEWS Message-ID: Author: vinay.sajip Date: Thu Feb 4 21:23:45 2010 New Revision: 77973 Log: Issue #7851: logging: clarification on logging configuration files. Modified: python/trunk/Doc/library/logging.rst python/trunk/Misc/NEWS Modified: python/trunk/Doc/library/logging.rst ============================================================================== --- python/trunk/Doc/library/logging.rst (original) +++ python/trunk/Doc/library/logging.rst Thu Feb 4 21:23:45 2010 @@ -422,6 +422,13 @@ code approach, mainly separation of configuration and code and the ability of noncoders to easily modify the logging properties. +Note that the class names referenced in config files need to be either relative +to the logging module, or absolute values which can be resolved using normal +import mechanisms. Thus, you could use either `handlers.WatchedFileHandler` +(relative to the logging module) or `mypackage.mymodule.MyHandler` (for a +class defined in package `mypackage` and module `mymodule`, where `mypackage` +is available on the Python import path). + .. _library-config: Configuring Logging for a Library Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Feb 4 21:23:45 2010 @@ -55,6 +55,8 @@ Library ------- +- Issue #7851: logging: clarification on logging configuration files. + - Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is specified, rather than fall through to AF_PACKET (in the `socket` module). Also, raise ValueError rather than TypeError when an unknown TIPC address From python-checkins at python.org Thu Feb 4 21:26:18 2010 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 04 Feb 2010 20:26:18 -0000 Subject: [Python-checkins] r77974 - in python/branches/release31-maint: Misc/NEWS Modules/socketmodule.c Message-ID: Author: antoine.pitrou Date: Thu Feb 4 21:26:18 2010 New Revision: 77974 Log: Merged revisions 77972 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r77972 | antoine.pitrou | 2010-02-04 21:23:24 +0100 (jeu., 04 f?vr. 2010) | 12 lines Merged revisions 77970 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77970 | antoine.pitrou | 2010-02-04 21:20:18 +0100 (jeu., 04 f?vr. 2010) | 6 lines Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is specified, rather than fall through to AF_PACKET (in the `socket` module). Also, raise ValueError rather than TypeError when an unknown TIPC address type is specified. Patch by Brian Curtin. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/socketmodule.c Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Thu Feb 4 21:26:18 2010 @@ -79,6 +79,11 @@ Library ------- +- Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is + specified, rather than fall through to AF_PACKET (in the `socket` module). + Also, raise ValueError rather than TypeError when an unknown TIPC address + type is specified. Patch by Brian Curtin. + - Issue #6939: Fix file I/O objects in the `io` module to keep the original file position when calling `truncate()`. It would previously change the file position to the given argument, which goes against the tradition of Modified: python/branches/release31-maint/Modules/socketmodule.c ============================================================================== --- python/branches/release31-maint/Modules/socketmodule.c (original) +++ python/branches/release31-maint/Modules/socketmodule.c Thu Feb 4 21:26:18 2010 @@ -1053,6 +1053,10 @@ } #endif + default: + PyErr_SetString(PyExc_ValueError, + "Unknown Bluetooth protocol"); + return NULL; } #endif @@ -1104,7 +1108,7 @@ 0, a->scope); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "Invalid address type"); return NULL; } From python-checkins at python.org Thu Feb 4 21:26:35 2010 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 04 Feb 2010 20:26:35 -0000 Subject: [Python-checkins] r77975 - in python/branches/release26-maint: Misc/NEWS Modules/socketmodule.c Message-ID: Author: antoine.pitrou Date: Thu Feb 4 21:26:34 2010 New Revision: 77975 Log: Merged revisions 77970 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77970 | antoine.pitrou | 2010-02-04 21:20:18 +0100 (jeu., 04 f?vr. 2010) | 6 lines Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is specified, rather than fall through to AF_PACKET (in the `socket` module). Also, raise ValueError rather than TypeError when an unknown TIPC address type is specified. Patch by Brian Curtin. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Modules/socketmodule.c Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Thu Feb 4 21:26:34 2010 @@ -58,6 +58,11 @@ Library ------- +- Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is + specified, rather than fall through to AF_PACKET (in the `socket` module). + Also, raise ValueError rather than TypeError when an unknown TIPC address + type is specified. Patch by Brian Curtin. + - Issue #6939: Fix file I/O objects in the `io` module to keep the original file position when calling `truncate()`. It would previously change the file position to the given argument, which goes against the tradition of Modified: python/branches/release26-maint/Modules/socketmodule.c ============================================================================== --- python/branches/release26-maint/Modules/socketmodule.c (original) +++ python/branches/release26-maint/Modules/socketmodule.c Thu Feb 4 21:26:34 2010 @@ -1089,6 +1089,10 @@ } #endif + default: + PyErr_SetString(PyExc_ValueError, + "Unknown Bluetooth protocol"); + return NULL; } #endif @@ -1140,7 +1144,7 @@ 0, a->scope); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "Invalid address type"); return NULL; } From python-checkins at python.org Thu Feb 4 21:27:41 2010 From: python-checkins at python.org (ezio.melotti) Date: Thu, 04 Feb 2010 20:27:41 -0000 Subject: [Python-checkins] r77976 - in python/branches/py3k: Doc/library/unittest.rst Message-ID: Author: ezio.melotti Date: Thu Feb 4 21:27:41 2010 New Revision: 77976 Log: Merged revisions 77968 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77968 | ezio.melotti | 2010-02-04 22:06:38 +0200 (Thu, 04 Feb 2010) | 1 line Use correct assert* methods in the examples. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Thu Feb 4 21:27:41 2010 @@ -182,12 +182,12 @@ def test_choice(self): element = random.choice(self.seq) - self.assert_(element in self.seq) + self.assertIn(element, self.seq) def test_sample(self): self.assertRaises(ValueError, random.sample, self.seq, 20) for element in random.sample(self.seq, 5): - self.assert_(element in self.seq) + self.assertIn(element, self.seq) if __name__ == '__main__': unittest.main() @@ -301,14 +301,14 @@ class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): - self.assertTrue(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') class WidgetResizeTestCase(SimpleWidgetTestCase): def runTest(self): self.widget.resize(100,150) - self.assertTrue(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') If the :meth:`~TestCase.setUp` method raises an exception while the test is running, the framework will consider the test to have suffered an error, and the @@ -349,13 +349,13 @@ self.widget = None def testDefaultSize(self): - self.assertTrue(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') def testResize(self): self.widget.resize(100,150) - self.assertTrue(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') Here we have not provided a :meth:`~TestCase.runTest` method, but have instead provided two different test methods. Class instances will now each run one of From python-checkins at python.org Thu Feb 4 21:29:01 2010 From: python-checkins at python.org (ezio.melotti) Date: Thu, 04 Feb 2010 20:29:01 -0000 Subject: [Python-checkins] r77977 - in python/branches/release31-maint: Doc/library/unittest.rst Message-ID: Author: ezio.melotti Date: Thu Feb 4 21:29:01 2010 New Revision: 77977 Log: Merged revisions 77976 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r77976 | ezio.melotti | 2010-02-04 22:27:41 +0200 (Thu, 04 Feb 2010) | 9 lines Merged revisions 77968 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77968 | ezio.melotti | 2010-02-04 22:06:38 +0200 (Thu, 04 Feb 2010) | 1 line Use correct assert* methods in the examples. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/unittest.rst Modified: python/branches/release31-maint/Doc/library/unittest.rst ============================================================================== --- python/branches/release31-maint/Doc/library/unittest.rst (original) +++ python/branches/release31-maint/Doc/library/unittest.rst Thu Feb 4 21:29:01 2010 @@ -115,12 +115,12 @@ def test_choice(self): element = random.choice(self.seq) - self.assert_(element in self.seq) + self.assertIn(element, self.seq) def test_sample(self): self.assertRaises(ValueError, random.sample, self.seq, 20) for element in random.sample(self.seq, 5): - self.assert_(element in self.seq) + self.assertIn(element, self.seq) if __name__ == '__main__': unittest.main() @@ -236,14 +236,14 @@ class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): - self.assertTrue(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') class WidgetResizeTestCase(SimpleWidgetTestCase): def runTest(self): self.widget.resize(100,150) - self.assertTrue(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') If the :meth:`~TestCase.setUp` method raises an exception while the test is running, the framework will consider the test to have suffered an error, and the @@ -284,13 +284,13 @@ self.widget = None def testDefaultSize(self): - self.assertTrue(self.widget.size() == (50,50), - 'incorrect default size') + self.assertEqual(self.widget.size(), (50,50), + 'incorrect default size') def testResize(self): self.widget.resize(100,150) - self.assertTrue(self.widget.size() == (100,150), - 'wrong size after resize') + self.assertEqual(self.widget.size(), (100,150), + 'wrong size after resize') Here we have not provided a :meth:`~TestCase.runTest` method, but have instead provided two different test methods. Class instances will now each run one of From python-checkins at python.org Thu Feb 4 21:39:43 2010 From: python-checkins at python.org (vinay.sajip) Date: Thu, 04 Feb 2010 20:39:43 -0000 Subject: [Python-checkins] r77978 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Thu Feb 4 21:39:43 2010 New Revision: 77978 Log: Marked PEP 391 as Accepted. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Thu Feb 4 21:39:43 2010 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Vinay Sajip -Status: Draft +Status: Accepted Type: Standards Track Content-Type: text/x-rst Created: 15-Oct-2009 From benjamin at python.org Thu Feb 4 22:21:00 2010 From: benjamin at python.org (Benjamin Peterson) Date: Thu, 4 Feb 2010 15:21:00 -0600 Subject: [Python-checkins] r77946 - python/branches/py3k In-Reply-To: <4B69866E.50802@trueblade.com> References: <20100203141931.1AC13181818C@tok.trueblade.com> <4B69866E.50802@trueblade.com> Message-ID: <1afaf6161002041321u3df455b8x9d762028b82cdce1@mail.gmail.com> 2010/2/3 Eric Smith : > Oops, I realize I shouldn't have blocked this. I'll forward port the change. There's always svnmerge unblock. -- Regards, Benjamin From nnorwitz at gmail.com Thu Feb 4 22:22:03 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 4 Feb 2010 16:22:03 -0500 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20100204212203.GA4685@kbk-i386-bb.psfb.org> 344 tests OK. 1 test failed: test_logging 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn fetching http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml ... fetching http://people.freebsd.org/~perky/i18n/EUC-CN.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT ... test_codecmaps_hk fetching http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT ... test_codecmaps_jp fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JP.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT ... fetching http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT ... test_codecmaps_kr fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-KR.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT ... test_codecmaps_tw fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT ... test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictcomps test_dictviews test_difflib test_dircache test_dis test_distutils [20687 refs] test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [16680 refs] [16680 refs] [16680 refs] [28264 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging Exception in thread Thread-436: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/threading.py", line 526, in __bootstrap_inner self.run() File "/tmp/python-test/local/lib/python2.7/threading.py", line 479, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 847, in serve server = rcvr(port=port, handler=hdlr) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 827, in __init__ ThreadingTCPServer.__init__(self, (host, port), handler) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 406, in __init__ self.server_bind() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 417, in server_bind self.socket.bind(self.server_address) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 98] Address already in use test test_logging failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1579, in test_listen_config_10_ok ], stream=output) File "/tmp/python-test/local/lib/python2.7/contextlib.py", line 35, in __exit__ self.gen.throw(type, value, traceback) File "/tmp/python-test/local/lib/python2.7/test/test_support.py", line 642, in captured_output yield getattr(sys, stream_name) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1564, in test_listen_config_10_ok self.setup_via_listener(json.dumps(self.config10)) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1548, in setup_via_listener sock.connect(('localhost', PORT)) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 111] Connection refused Re-running test 'test_logging' in verbose mode test_flat (test.test_logging.BuiltinLevelsTest) ... ok test_nested_explicit (test.test_logging.BuiltinLevelsTest) ... ok test_nested_inherited (test.test_logging.BuiltinLevelsTest) ... ok test_nested_with_virtual_parent (test.test_logging.BuiltinLevelsTest) ... ok test_filter (test.test_logging.BasicFilterTest) ... ok test_handler_filter (test.test_logging.CustomLevelsAndFiltersTest) ... ok test_logger_filter (test.test_logging.CustomLevelsAndFiltersTest) ... ok test_specific_filters (test.test_logging.CustomLevelsAndFiltersTest) ... ok test_flush (test.test_logging.MemoryHandlerTest) ... ok test_config0_ok (test.test_logging.ConfigFileTest) ... ok test_config1_ok (test.test_logging.ConfigFileTest) ... ok test_config2_failure (test.test_logging.ConfigFileTest) ... ok test_config3_failure (test.test_logging.ConfigFileTest) ... ok test_config4_ok (test.test_logging.ConfigFileTest) ... ok test_config5_ok (test.test_logging.ConfigFileTest) ... ok test_config6_ok (test.test_logging.ConfigFileTest) ... ok test_output (test.test_logging.SocketHandlerTest) ... ok test_persistent_loggers (test.test_logging.MemoryTest) ... ok test_encoding_cyrillic_unicode (test.test_logging.EncodingTest) ... ok test_encoding_plain_file (test.test_logging.EncodingTest) ... ok test_warnings (test.test_logging.WarningsTest) ... ok test_config0_ok (test.test_logging.ConfigDictTest) ... ok test_config1_ok (test.test_logging.ConfigDictTest) ... ok test_config2_failure (test.test_logging.ConfigDictTest) ... ok test_config2a_failure (test.test_logging.ConfigDictTest) ... ok test_config2b_failure (test.test_logging.ConfigDictTest) ... ok test_config3_failure (test.test_logging.ConfigDictTest) ... ok test_config4_ok (test.test_logging.ConfigDictTest) ... ok test_config4a_ok (test.test_logging.ConfigDictTest) ... ok test_config5_ok (test.test_logging.ConfigDictTest) ... ok test_config6_failure (test.test_logging.ConfigDictTest) ... ok test_config7_ok (test.test_logging.ConfigDictTest) ... ok test_config_10_ok (test.test_logging.ConfigDictTest) ... ok test_config_8_ok (test.test_logging.ConfigDictTest) ... ok test_config_9_ok (test.test_logging.ConfigDictTest) ... ok test_listen_config_10_ok (test.test_logging.ConfigDictTest) ... ERROR test_listen_config_1_ok (test.test_logging.ConfigDictTest) ... Exception in thread Thread-441: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/threading.py", line 526, in __bootstrap_inner self.run() File "/tmp/python-test/local/lib/python2.7/threading.py", line 479, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 847, in serve server = rcvr(port=port, handler=hdlr) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 827, in __init__ ThreadingTCPServer.__init__(self, (host, port), handler) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 406, in __init__ self.server_bind() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 417, in server_bind self.socket.bind(self.server_address) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 98] Address already in use FAIL ====================================================================== ERROR: test_listen_config_10_ok (test.test_logging.ConfigDictTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1579, in test_listen_config_10_ok ], stream=output) File "/tmp/python-test/local/lib/python2.7/contextlib.py", line 35, in __exit__ self.gen.throw(type, value, traceback) File "/tmp/python-test/local/lib/python2.7/test/test_support.py", line 642, in captured_output yield getattr(sys, stream_name) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1564, in test_listen_config_10_ok self.setup_via_listener(json.dumps(self.config10)) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1548, in setup_via_listener sock.connect(('localhost', PORT)) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 111] Connection refused ====================================================================== FAIL: test_listen_config_1_ok (test.test_logging.ConfigDictTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1591, in test_listen_config_1_ok ], stream=output) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 119, in assert_log_lines self.assertEquals(len(actual_lines), len(expected_values)) AssertionError: 0 != 2 ---------------------------------------------------------------------- Ran 37 tests in 0.340s FAILED (failures=1, errors=1) test test_logging failed -- multiple errors occurred test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770. test_mutants test_mutex test_netrc test_new test_nis test_normalization fetching http://www.unicode.org/Public/5.1.0/ucd/NormalizationTest.txt ... test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [18076 refs] [18076 refs] test_plistlib test_poll test_popen [16685 refs] [16685 refs] [16685 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23125 refs] [23125 refs] test_pyexpat test_queue test_quopri [19508 refs] [19508 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [16680 refs] [16680 refs] [16680 refs] [16680 refs] test_slice test_smtplib test_smtpnet test_smtpnet skipped -- Use of the `network' resource not enabled test_socket test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_strtod test_struct test_structmembers test_structseq test_subprocess [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [16680 refs] [16680 refs] [16909 refs] [16703 refs] test_sysconfig test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [16680 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [19974 refs] [23450 refs] [22364 refs] [22364 refs] [22364 refs] [22364 refs] test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xpickle -- skipping backwards compat tests. Use 'regrtest.py -u xpickle' to run them. test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 344 tests OK. 1 test failed: test_logging 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [877651 refs] From python-checkins at python.org Thu Feb 4 22:40:56 2010 From: python-checkins at python.org (vinay.sajip) Date: Thu, 04 Feb 2010 21:40:56 -0000 Subject: [Python-checkins] r77979 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Thu Feb 4 22:40:56 2010 New Revision: 77979 Log: Added unit test for cfg:// resolution. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Thu Feb 4 22:40:56 2010 @@ -1355,6 +1355,36 @@ }, } + #As config1 but using cfg:// references + config11 = { + 'true_formatters': { + 'form1' : { + 'format' : '%(levelname)s ++ %(message)s', + }, + }, + 'handler_configs': { + 'hand1' : { + 'class' : 'logging.StreamHandler', + 'formatter' : 'form1', + 'level' : 'NOTSET', + 'stream' : 'ext://sys.stdout', + }, + }, + 'formatters' : 'cfg://true_formatters', + 'handlers' : { + 'hand1' : 'cfg://handler_configs[hand1]', + }, + 'loggers' : { + 'compiler.parser' : { + 'level' : 'DEBUG', + 'handlers' : ['hand1'], + }, + }, + 'root' : { + 'level' : 'WARNING', + }, + } + def apply_config(self, conf): logging.config.dictConfig(conf) @@ -1539,6 +1569,9 @@ ('ERROR', '4'), ], stream=output) + def test_config11_ok(self): + self.test_config1_ok(self.config11) + def setup_via_listener(self, text): PORT = 9030 t = logging.config.listen(PORT) From raymond.hettinger at gmail.com Thu Feb 4 22:52:30 2010 From: raymond.hettinger at gmail.com (Raymond Hettinger) Date: Thu, 4 Feb 2010 13:52:30 -0800 Subject: [Python-checkins] r73367 - python/trunk/Doc/library/bisect.rst In-Reply-To: <1263910798.3785.21.camel@joop-desktop> References: <1263910798.3785.21.camel@joop-desktop> Message-ID: Hello Joop, To get bisect to work, the underlying list needs to be in sorted order. The one in your example is not in sorted order because the for-loops are in opposite order of the joined string (f needs to be first and r second). Swapping the two will fix the "oddities" you've observed: >>> squares = [f + r for f in 'abcdefgh' for r in '12345678'] >>> squares ['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'g1', 'g2', 'g3', 'g4', 'g5', 'g6', 'g7', 'g8', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8'] >>> squares.index('e4') 35 >>> bisect_left( squares,'e4') 35 Feel free to email me directly if you have more questions. No need to cc the checkins list. Raymond On Jan 19, 2010, at 6:19 AM, joop renes wrote: > hi raymond, > i am trying to develop an efficient dropin replacement for dict() in the > use case: few updates( which are linear in time complexity) and many > lookups(which can be made of logarithmic time complexity,provided binary > search is applicable). some experimentation revealed unexpected results > as the attached example shows. I have developed a class assoc_vector > that maintains a sorted list of (key,value) tuples, where key "must" be > an int. 'I would have expected any type with logical comparison > semantics to work as it does in C++ > Part of the trick is that the insertion_point can be found by > bisect( __tuples,(key,) ), where __tuples is a private variable that > holds the standard python list of (key,value) tuples. > best regards > joop renes > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins From solipsis at pitrou.net Fri Feb 5 01:04:05 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 5 Feb 2010 01:04:05 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r77976): sum=0 Message-ID: <20100205000405.4A2F81770A@ns6635.ovh.net> py3k results for svn r77976 (hg cset 98548e5e68bc) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflog9uWO_b', '-x', 'test_httpservers'] From python-checkins at python.org Fri Feb 5 02:53:28 2010 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 05 Feb 2010 01:53:28 -0000 Subject: [Python-checkins] r77980 - python/trunk/Lib/test/test_with.py Message-ID: Author: benjamin.peterson Date: Fri Feb 5 02:53:27 2010 New Revision: 77980 Log: add a test for #7853; the exception must be normalized for with Modified: python/trunk/Lib/test/test_with.py Modified: python/trunk/Lib/test/test_with.py ============================================================================== --- python/trunk/Lib/test/test_with.py (original) +++ python/trunk/Lib/test/test_with.py Fri Feb 5 02:53:27 2010 @@ -213,11 +213,17 @@ def raiseTestException(self): raise self.TEST_EXCEPTION - def assertAfterWithManagerInvariantsWithError(self, mock_manager): + def assertAfterWithManagerInvariantsWithError(self, mock_manager, + exc_type=None): self.assertTrue(mock_manager.enter_called) self.assertTrue(mock_manager.exit_called) - self.assertEqual(mock_manager.exit_args[0], RuntimeError) - self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION) + if exc_type is None: + self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION) + exc_type = type(self.TEST_EXCEPTION) + self.assertEqual(mock_manager.exit_args[0], exc_type) + # Test the __exit__ arguments. Issue #7853 + self.assertIsInstance(mock_manager.exit_args[1], exc_type) + self.assertIsNot(mock_manager.exit_args[2], None) def assertAfterWithGeneratorInvariantsWithError(self, mock_generator): self.assertTrue(mock_generator.yielded) @@ -355,6 +361,17 @@ self.assertAfterWithManagerInvariantsWithError(cm) self.assertAfterWithGeneratorInvariantsWithError(self.resource) + @unittest.expectedFailure + def testExceptionNormalized(self): + cm = mock_contextmanager_generator() + def shouldThrow(): + with cm as self.resource: + # Note this relies on the fact that 1 // 0 produces an exception + # that is not normalized immediately. + 1 // 0 + self.assertRaises(ZeroDivisionError, shouldThrow) + self.assertAfterWithManagerInvariantsWithError(cm, ZeroDivisionError) + def testNestedSingleStatements(self): mock_a = mock_contextmanager_generator() mock_b = mock_contextmanager_generator() From python-checkins at python.org Fri Feb 5 03:07:05 2010 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 05 Feb 2010 02:07:05 -0000 Subject: [Python-checkins] r77981 - in python/branches/py3k: Lib/test/test_with.py Message-ID: Author: benjamin.peterson Date: Fri Feb 5 03:07:05 2010 New Revision: 77981 Log: Merged revisions 77980 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77980 | benjamin.peterson | 2010-02-04 19:53:27 -0600 (Thu, 04 Feb 2010) | 1 line add a test for #7853; the exception must be normalized for with ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_with.py Modified: python/branches/py3k/Lib/test/test_with.py ============================================================================== --- python/branches/py3k/Lib/test/test_with.py (original) +++ python/branches/py3k/Lib/test/test_with.py Fri Feb 5 03:07:05 2010 @@ -215,11 +215,17 @@ def raiseTestException(self): raise self.TEST_EXCEPTION - def assertAfterWithManagerInvariantsWithError(self, mock_manager): + def assertAfterWithManagerInvariantsWithError(self, mock_manager, + exc_type=None): self.assertTrue(mock_manager.enter_called) self.assertTrue(mock_manager.exit_called) - self.assertEqual(mock_manager.exit_args[0], RuntimeError) - self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION) + if exc_type is None: + self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION) + exc_type = type(self.TEST_EXCEPTION) + self.assertEqual(mock_manager.exit_args[0], exc_type) + # Test the __exit__ arguments. Issue #7853 + self.assertIsInstance(mock_manager.exit_args[1], exc_type) + self.assertIsNot(mock_manager.exit_args[2], None) def assertAfterWithGeneratorInvariantsWithError(self, mock_generator): self.assertTrue(mock_generator.yielded) @@ -357,6 +363,17 @@ self.assertAfterWithManagerInvariantsWithError(cm) self.assertAfterWithGeneratorInvariantsWithError(self.resource) + @unittest.expectedFailure + def testExceptionNormalized(self): + cm = mock_contextmanager_generator() + def shouldThrow(): + with cm as self.resource: + # Note this relies on the fact that 1 // 0 produces an exception + # that is not normalized immediately. + 1 // 0 + self.assertRaises(ZeroDivisionError, shouldThrow) + self.assertAfterWithManagerInvariantsWithError(cm, ZeroDivisionError) + def testNestedSingleStatements(self): mock_a = mock_contextmanager_generator() mock_b = mock_contextmanager_generator() From python-checkins at python.org Fri Feb 5 03:07:20 2010 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 05 Feb 2010 02:07:20 -0000 Subject: [Python-checkins] r77982 - python/branches/py3k/Lib/test/test_with.py Message-ID: Author: benjamin.peterson Date: Fri Feb 5 03:07:20 2010 New Revision: 77982 Log: this works correctly in py3 already Modified: python/branches/py3k/Lib/test/test_with.py Modified: python/branches/py3k/Lib/test/test_with.py ============================================================================== --- python/branches/py3k/Lib/test/test_with.py (original) +++ python/branches/py3k/Lib/test/test_with.py Fri Feb 5 03:07:20 2010 @@ -363,7 +363,6 @@ self.assertAfterWithManagerInvariantsWithError(cm) self.assertAfterWithGeneratorInvariantsWithError(self.resource) - @unittest.expectedFailure def testExceptionNormalized(self): cm = mock_contextmanager_generator() def shouldThrow(): From python-checkins at python.org Fri Feb 5 03:12:14 2010 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 05 Feb 2010 02:12:14 -0000 Subject: [Python-checkins] r77983 - in python/trunk: Lib/test/test_generators.py Lib/test/test_with.py Misc/NEWS Python/ceval.c Python/compile.c Message-ID: Author: benjamin.peterson Date: Fri Feb 5 03:12:14 2010 New Revision: 77983 Log: normalize exceptions passed to the __exit__ method #7853 In Python 2.x, exceptions in finally blocks are not normalized. Since with statements are implemented using finally blocks, ceval.c had to be tweaked to distinguish between with finally blocks and normal ones. A test for the finalization of generators containing with statements was also added. Modified: python/trunk/Lib/test/test_generators.py python/trunk/Lib/test/test_with.py python/trunk/Misc/NEWS python/trunk/Python/ceval.c python/trunk/Python/compile.c Modified: python/trunk/Lib/test/test_generators.py ============================================================================== --- python/trunk/Lib/test/test_generators.py (original) +++ python/trunk/Lib/test/test_generators.py Fri Feb 5 03:12:14 2010 @@ -1700,6 +1700,17 @@ >>> del g exiting +>>> class context(object): +... def __enter__(self): pass +... def __exit__(self, *args): print 'exiting' +>>> def f(): +... with context(): +... yield +>>> g = f() +>>> g.next() +>>> del g +exiting + GeneratorExit is not caught by except Exception: Modified: python/trunk/Lib/test/test_with.py ============================================================================== --- python/trunk/Lib/test/test_with.py (original) +++ python/trunk/Lib/test/test_with.py Fri Feb 5 03:12:14 2010 @@ -361,7 +361,6 @@ self.assertAfterWithManagerInvariantsWithError(cm) self.assertAfterWithGeneratorInvariantsWithError(self.resource) - @unittest.expectedFailure def testExceptionNormalized(self): cm = mock_contextmanager_generator() def shouldThrow(): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Feb 5 03:12:14 2010 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7853: Normalize exceptions before they are passed to a context managers + __exit__ method. + - Issue #7385: Fix a crash in `MemoryView_FromObject` when `PyObject_GetBuffer` fails. Patch by Florent Xicluna. Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Fri Feb 5 03:12:14 2010 @@ -2555,9 +2555,11 @@ Py_DECREF(u); if (!x) break; - /* Setup the finally block before pushing the result - of __enter__ on the stack. */ - PyFrame_BlockSetup(f, SETUP_FINALLY, INSTR_OFFSET() + oparg, + /* Setup a finally block (SETUP_WITH as a block is + equivalent to SETUP_FINALLY except it normalizes + the exception) before pushing the result of + __enter__ on the stack. */ + PyFrame_BlockSetup(f, SETUP_WITH, INSTR_OFFSET() + oparg, STACK_LEVEL()); PUSH(x); @@ -2898,7 +2900,8 @@ } if (b->b_type == SETUP_FINALLY || (b->b_type == SETUP_EXCEPT && - why == WHY_EXCEPTION)) { + why == WHY_EXCEPTION) || + b->b_type == SETUP_WITH) { if (why == WHY_EXCEPTION) { PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); @@ -2911,7 +2914,8 @@ so a program can emulate the Python main loop. Don't do this for 'finally'. */ - if (b->b_type == SETUP_EXCEPT) { + if (b->b_type == SETUP_EXCEPT || + b->b_type == SETUP_WITH) { PyErr_NormalizeException( &exc, &val, &tb); set_exc_info(tstate, Modified: python/trunk/Python/compile.c ============================================================================== --- python/trunk/Python/compile.c (original) +++ python/trunk/Python/compile.c Fri Feb 5 03:12:14 2010 @@ -2927,6 +2927,9 @@ /* SETUP_WITH pushes a finally block. */ compiler_use_next_block(c, block); + /* Note that the block is actually called SETUP_WITH in ceval.c, but + functions the same as SETUP_FINALLY except that exceptions are + normalized. */ if (!compiler_push_fblock(c, FINALLY_TRY, block)) { return 0; } From python-checkins at python.org Fri Feb 5 03:14:20 2010 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 05 Feb 2010 02:14:20 -0000 Subject: [Python-checkins] r77984 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Fri Feb 5 03:14:20 2010 New Revision: 77984 Log: Blocked revisions 77983 via svnmerge ........ r77983 | benjamin.peterson | 2010-02-04 20:12:14 -0600 (Thu, 04 Feb 2010) | 9 lines normalize exceptions passed to the __exit__ method #7853 In Python 2.x, exceptions in finally blocks are not normalized. Since with statements are implemented using finally blocks, ceval.c had to be tweaked to distinguish between with finally blocks and normal ones. A test for the finalization of generators containing with statements was also added. ........ Modified: python/branches/py3k/ (props changed) From nnorwitz at gmail.com Fri Feb 5 10:17:33 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 5 Feb 2010 04:17:33 -0500 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20100205091733.GA25507@kbk-i386-bb.psfb.org> 344 tests OK. 1 test failed: test_logging 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn fetching http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml ... fetching http://people.freebsd.org/~perky/i18n/EUC-CN.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT ... test_codecmaps_hk fetching http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT ... test_codecmaps_jp fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JP.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT ... fetching http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT ... test_codecmaps_kr fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-KR.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT ... test_codecmaps_tw fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT ... test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dictcomps test_dictviews test_difflib test_dircache test_dis test_distutils [20687 refs] test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [16680 refs] [16680 refs] [16680 refs] [28264 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging Exception in thread Thread-436: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/threading.py", line 526, in __bootstrap_inner self.run() File "/tmp/python-test/local/lib/python2.7/threading.py", line 479, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 847, in serve server = rcvr(port=port, handler=hdlr) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 827, in __init__ ThreadingTCPServer.__init__(self, (host, port), handler) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 406, in __init__ self.server_bind() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 417, in server_bind self.socket.bind(self.server_address) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 98] Address already in use test test_logging failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1597, in test_listen_config_10_ok self.setup_via_listener(json.dumps(self.config10)) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1581, in setup_via_listener sock.connect(('localhost', PORT)) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 111] Connection refused Re-running test 'test_logging' in verbose mode test_flat (test.test_logging.BuiltinLevelsTest) ... ok test_nested_explicit (test.test_logging.BuiltinLevelsTest) ... ok test_nested_inherited (test.test_logging.BuiltinLevelsTest) ... ok test_nested_with_virtual_parent (test.test_logging.BuiltinLevelsTest) ... ok test_filter (test.test_logging.BasicFilterTest) ... ok test_handler_filter (test.test_logging.CustomLevelsAndFiltersTest) ... ok test_logger_filter (test.test_logging.CustomLevelsAndFiltersTest) ... ok test_specific_filters (test.test_logging.CustomLevelsAndFiltersTest) ... ok test_flush (test.test_logging.MemoryHandlerTest) ... ok test_config0_ok (test.test_logging.ConfigFileTest) ... ok test_config1_ok (test.test_logging.ConfigFileTest) ... ok test_config2_failure (test.test_logging.ConfigFileTest) ... ok test_config3_failure (test.test_logging.ConfigFileTest) ... ok test_config4_ok (test.test_logging.ConfigFileTest) ... ok test_config5_ok (test.test_logging.ConfigFileTest) ... ok test_config6_ok (test.test_logging.ConfigFileTest) ... ok test_output (test.test_logging.SocketHandlerTest) ... ok test_persistent_loggers (test.test_logging.MemoryTest) ... ok test_encoding_cyrillic_unicode (test.test_logging.EncodingTest) ... ok test_encoding_plain_file (test.test_logging.EncodingTest) ... ok test_warnings (test.test_logging.WarningsTest) ... ok test_config0_ok (test.test_logging.ConfigDictTest) ... ok test_config11_ok (test.test_logging.ConfigDictTest) ... ok test_config1_ok (test.test_logging.ConfigDictTest) ... ok test_config2_failure (test.test_logging.ConfigDictTest) ... ok test_config2a_failure (test.test_logging.ConfigDictTest) ... ok test_config2b_failure (test.test_logging.ConfigDictTest) ... ok test_config3_failure (test.test_logging.ConfigDictTest) ... ok test_config4_ok (test.test_logging.ConfigDictTest) ... ok test_config4a_ok (test.test_logging.ConfigDictTest) ... ok test_config5_ok (test.test_logging.ConfigDictTest) ... ok test_config6_failure (test.test_logging.ConfigDictTest) ... ok test_config7_ok (test.test_logging.ConfigDictTest) ... ok test_config_10_ok (test.test_logging.ConfigDictTest) ... ok test_config_8_ok (test.test_logging.ConfigDictTest) ... ok test_config_9_ok (test.test_logging.ConfigDictTest) ... ok test_listen_config_10_ok (test.test_logging.ConfigDictTest) ... ERROR test_listen_config_1_ok (test.test_logging.ConfigDictTest) ... Exception in thread Thread-441: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/threading.py", line 526, in __bootstrap_inner self.run() File "/tmp/python-test/local/lib/python2.7/threading.py", line 479, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 847, in serve server = rcvr(port=port, handler=hdlr) File "/tmp/python-test/local/lib/python2.7/logging/config.py", line 827, in __init__ ThreadingTCPServer.__init__(self, (host, port), handler) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 406, in __init__ self.server_bind() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 417, in server_bind self.socket.bind(self.server_address) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 98] Address already in use FAIL ====================================================================== ERROR: test_listen_config_10_ok (test.test_logging.ConfigDictTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1597, in test_listen_config_10_ok self.setup_via_listener(json.dumps(self.config10)) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1581, in setup_via_listener sock.connect(('localhost', PORT)) File "/tmp/python-test/local/lib/python2.7/socket.py", line 222, in meth return getattr(self._sock,name)(*args) error: [Errno 111] Connection refused ====================================================================== FAIL: test_listen_config_1_ok (test.test_logging.ConfigDictTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 1624, in test_listen_config_1_ok ], stream=output) File "/tmp/python-test/local/lib/python2.7/test/test_logging.py", line 119, in assert_log_lines self.assertEquals(len(actual_lines), len(expected_values)) AssertionError: 0 != 2 ---------------------------------------------------------------------- Ran 38 tests in 0.343s FAILED (failures=1, errors=1) test test_logging failed -- multiple errors occurred test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770. test_mutants test_mutex test_netrc test_new test_nis test_normalization fetching http://www.unicode.org/Public/5.1.0/ucd/NormalizationTest.txt ... test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [18076 refs] [18076 refs] test_plistlib test_poll test_popen [16685 refs] [16685 refs] [16685 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23126 refs] [23125 refs] [23125 refs] test_pyexpat test_queue test_quopri [19508 refs] [19508 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_setcomps test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [16680 refs] [16680 refs] [16680 refs] [16680 refs] test_slice test_smtplib test_smtpnet test_smtpnet skipped -- Use of the `network' resource not enabled test_socket test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_strtod test_struct test_structmembers test_structseq test_subprocess [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16895 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] [16680 refs] . [16680 refs] [16680 refs] this bit of output is from a test of stdout in a different process ... [16680 refs] [16680 refs] [16895 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [16680 refs] [16680 refs] [16909 refs] [16703 refs] test_sysconfig test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [16680 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [19974 refs] [22548 refs] [22364 refs] [22364 refs] [22364 refs] [22364 refs] test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xpickle -- skipping backwards compat tests. Use 'regrtest.py -u xpickle' to run them. test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 344 tests OK. 1 test failed: test_logging 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [877781 refs] From python-checkins at python.org Fri Feb 5 15:52:05 2010 From: python-checkins at python.org (vinay.sajip) Date: Fri, 05 Feb 2010 14:52:05 -0000 Subject: [Python-checkins] r77985 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Fri Feb 5 15:52:05 2010 New Revision: 77985 Log: Issue #7857: test_logging: listener test now uses find_unused_port(). Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Fri Feb 5 15:52:05 2010 @@ -40,7 +40,8 @@ import struct import sys import tempfile -from test.test_support import captured_stdout, run_with_locale, run_unittest +from test.test_support import captured_stdout, run_with_locale, run_unittest,\ + find_unused_port import textwrap import threading import time @@ -1573,24 +1574,25 @@ self.test_config1_ok(self.config11) def setup_via_listener(self, text): - PORT = 9030 - t = logging.config.listen(PORT) + port = find_unused_port() + t = logging.config.listen(port) t.start() + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect(('localhost', port)) - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect(('localhost', PORT)) - - slen = struct.pack('>L', len(text)) - s = slen + text - sentsofar = 0 - left = len(s) - while left > 0: - sent = sock.send(s[sentsofar:]) - sentsofar += sent - left -= sent - sock.close() - logging.config.stopListening() - t.join() + slen = struct.pack('>L', len(text)) + s = slen + text + sentsofar = 0 + left = len(s) + while left > 0: + sent = sock.send(s[sentsofar:]) + sentsofar += sent + left -= sent + sock.close() + finally: + logging.config.stopListening() + t.join() def test_listen_config_10_ok(self): with captured_stdout() as output: From python-checkins at python.org Fri Feb 5 16:40:20 2010 From: python-checkins at python.org (vinay.sajip) Date: Fri, 05 Feb 2010 15:40:20 -0000 Subject: [Python-checkins] r77986 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Fri Feb 5 16:40:20 2010 New Revision: 77986 Log: Issue #7857: test_logging: listener tests disabled for now. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Fri Feb 5 16:40:20 2010 @@ -1594,7 +1594,7 @@ logging.config.stopListening() t.join() - def test_listen_config_10_ok(self): + def notest_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) logger = logging.getLogger("compiler.parser") @@ -1613,7 +1613,7 @@ ('ERROR', '4'), ], stream=output) - def test_listen_config_1_ok(self): + def notest_listen_config_1_ok(self): with captured_stdout() as output: self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) logger = logging.getLogger("compiler.parser") From python-checkins at python.org Fri Feb 5 17:25:12 2010 From: python-checkins at python.org (r.david.murray) Date: Fri, 05 Feb 2010 16:25:12 -0000 Subject: [Python-checkins] r77987 - python/branches/py3k/Doc/library/subprocess.rst Message-ID: Author: r.david.murray Date: Fri Feb 5 17:25:12 2010 New Revision: 77987 Log: Fix raw_input->input in Popen doc patch. Modified: python/branches/py3k/Doc/library/subprocess.rst Modified: python/branches/py3k/Doc/library/subprocess.rst ============================================================================== --- python/branches/py3k/Doc/library/subprocess.rst (original) +++ python/branches/py3k/Doc/library/subprocess.rst Fri Feb 5 17:25:12 2010 @@ -52,7 +52,7 @@ tokenization for *args*, especially in complex cases:: >>> import shlex, subprocess - >>> command_line = raw_input() + >>> command_line = input() /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" >>> args = shlex.split(command_line) >>> print(args) From python-checkins at python.org Fri Feb 5 17:26:37 2010 From: python-checkins at python.org (r.david.murray) Date: Fri, 05 Feb 2010 16:26:37 -0000 Subject: [Python-checkins] r77988 - in python/branches/release31-maint: Doc/library/subprocess.rst Message-ID: Author: r.david.murray Date: Fri Feb 5 17:26:37 2010 New Revision: 77988 Log: Merged revisions 77987 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r77987 | r.david.murray | 2010-02-05 11:25:12 -0500 (Fri, 05 Feb 2010) | 2 lines Fix raw_input->input in Popen doc patch. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/subprocess.rst Modified: python/branches/release31-maint/Doc/library/subprocess.rst ============================================================================== --- python/branches/release31-maint/Doc/library/subprocess.rst (original) +++ python/branches/release31-maint/Doc/library/subprocess.rst Fri Feb 5 17:26:37 2010 @@ -52,7 +52,7 @@ tokenization for *args*, especially in complex cases:: >>> import shlex, subprocess - >>> command_line = raw_input() + >>> command_line = input() /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" >>> args = shlex.split(command_line) >>> print(args) From python-checkins at python.org Fri Feb 5 18:05:54 2010 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 05 Feb 2010 17:05:54 -0000 Subject: [Python-checkins] r77989 - in python/trunk: Include/fileobject.h Lib/test/test_file2k.py Lib/test/test_sys.py Misc/ACKS Misc/NEWS Objects/fileobject.c Message-ID: Author: antoine.pitrou Date: Fri Feb 5 18:05:54 2010 New Revision: 77989 Log: Issue #5677: Explicitly forbid write operations on read-only file objects, and read operations on write-only file objects. On Windows, the system C library would return a bogus result; on Solaris, it was possible to crash the interpreter. Patch by Stefan Krah. Modified: python/trunk/Include/fileobject.h python/trunk/Lib/test/test_file2k.py python/trunk/Lib/test/test_sys.py python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Objects/fileobject.c Modified: python/trunk/Include/fileobject.h ============================================================================== --- python/trunk/Include/fileobject.h (original) +++ python/trunk/Include/fileobject.h Fri Feb 5 18:05:54 2010 @@ -28,6 +28,8 @@ PyObject *weakreflist; /* List of weak references */ int unlocked_count; /* Num. currently running sections of code using f_fp with the GIL released. */ + int readable; + int writable; } PyFileObject; PyAPI_DATA(PyTypeObject) PyFile_Type; Modified: python/trunk/Lib/test/test_file2k.py ============================================================================== --- python/trunk/Lib/test/test_file2k.py (original) +++ python/trunk/Lib/test/test_file2k.py Fri Feb 5 18:05:54 2010 @@ -86,6 +86,8 @@ self.assertTrue(repr(self.f).startswith("f_encoding = Py_None; Py_INCREF(Py_None); f->f_errors = Py_None; + f->readable = f->writable = 0; + if (strchr(mode, 'r') != NULL || f->f_univ_newline) + f->readable = 1; + if (strchr(mode, 'w') != NULL || strchr(mode, 'a') != NULL) + f->writable = 1; + if (strchr(mode, '+') != NULL) + f->readable = f->writable = 1; if (f->f_mode == NULL) return NULL; @@ -568,6 +575,13 @@ return NULL; } +static PyObject * +err_mode(char *action) +{ + PyErr_Format(PyExc_IOError, "File not open for %s", action); + return NULL; +} + /* Refuse regular file I/O if there's data in the iteration-buffer. * Mixing them would cause data to arrive out of order, as the read* * methods don't use the iteration buffer. */ @@ -782,6 +796,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->writable) + return err_mode("writing"); if (!PyArg_UnpackTuple(args, "truncate", 0, 1, &newsizeobj)) return NULL; @@ -1030,6 +1046,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1099,6 +1117,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1470,6 +1490,8 @@ PyFileObject *fo = (PyFileObject *)f; if (fo->f_fp == NULL) return err_closed(); + if (!fo->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (fo->f_buf != NULL && (fo->f_bufend - fo->f_bufptr) > 0 && @@ -1558,6 +1580,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1591,6 +1615,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1709,6 +1735,8 @@ Py_ssize_t n, n2; if (f->f_fp == NULL) return err_closed(); + if (!f->writable) + return err_mode("writing"); if (f->f_binary) { if (!PyArg_ParseTuple(args, "s*", &pbuf)) return NULL; @@ -1746,6 +1774,8 @@ assert(seq != NULL); if (f->f_fp == NULL) return err_closed(); + if (!f->writable) + return err_mode("writing"); result = NULL; list = NULL; @@ -2186,6 +2216,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); l = readahead_get_line_skip(f, 0, READAHEAD_BUFSIZE); if (l == NULL || PyString_GET_SIZE(l) == 0) { From python-checkins at python.org Fri Feb 5 18:11:33 2010 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 05 Feb 2010 17:11:33 -0000 Subject: [Python-checkins] r77990 - in python/branches/release26-maint: Include/fileobject.h Lib/test/test_file.py Lib/test/test_sys.py Misc/ACKS Misc/NEWS Objects/fileobject.c Message-ID: Author: antoine.pitrou Date: Fri Feb 5 18:11:32 2010 New Revision: 77990 Log: Merged revisions 77989 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77989 | antoine.pitrou | 2010-02-05 18:05:54 +0100 (ven., 05 f?vr. 2010) | 6 lines Issue #5677: Explicitly forbid write operations on read-only file objects, and read operations on write-only file objects. On Windows, the system C library would return a bogus result; on Solaris, it was possible to crash the interpreter. Patch by Stefan Krah. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Include/fileobject.h python/branches/release26-maint/Lib/test/test_file.py python/branches/release26-maint/Lib/test/test_sys.py python/branches/release26-maint/Misc/ACKS python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Objects/fileobject.c Modified: python/branches/release26-maint/Include/fileobject.h ============================================================================== --- python/branches/release26-maint/Include/fileobject.h (original) +++ python/branches/release26-maint/Include/fileobject.h Fri Feb 5 18:11:32 2010 @@ -28,6 +28,8 @@ PyObject *weakreflist; /* List of weak references */ int unlocked_count; /* Num. currently running sections of code using f_fp with the GIL released. */ + int readable; + int writable; } PyFileObject; PyAPI_DATA(PyTypeObject) PyFile_Type; Modified: python/branches/release26-maint/Lib/test/test_file.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_file.py (original) +++ python/branches/release26-maint/Lib/test/test_file.py Fri Feb 5 18:11:32 2010 @@ -86,6 +86,8 @@ self.assert_(repr(self.f).startswith("f_encoding = Py_None; Py_INCREF(Py_None); f->f_errors = Py_None; + f->readable = f->writable = 0; + if (strchr(mode, 'r') != NULL || f->f_univ_newline) + f->readable = 1; + if (strchr(mode, 'w') != NULL || strchr(mode, 'a') != NULL) + f->writable = 1; + if (strchr(mode, '+') != NULL) + f->readable = f->writable = 1; if (f->f_mode == NULL) return NULL; @@ -487,6 +494,13 @@ return NULL; } +static PyObject * +err_mode(char *action) +{ + PyErr_Format(PyExc_IOError, "File not open for %s", action); + return NULL; +} + /* Refuse regular file I/O if there's data in the iteration-buffer. * Mixing them would cause data to arrive out of order, as the read* * methods don't use the iteration buffer. */ @@ -701,6 +715,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->writable) + return err_mode("writing"); if (!PyArg_UnpackTuple(args, "truncate", 0, 1, &newsizeobj)) return NULL; @@ -949,6 +965,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1018,6 +1036,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1389,6 +1409,8 @@ PyFileObject *fo = (PyFileObject *)f; if (fo->f_fp == NULL) return err_closed(); + if (!fo->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (fo->f_buf != NULL && (fo->f_bufend - fo->f_bufptr) > 0 && @@ -1477,6 +1499,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1510,6 +1534,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); /* refuse to mix with f.next() */ if (f->f_buf != NULL && (f->f_bufend - f->f_bufptr) > 0 && @@ -1628,6 +1654,8 @@ Py_ssize_t n, n2; if (f->f_fp == NULL) return err_closed(); + if (!f->writable) + return err_mode("writing"); if (f->f_binary) { if (!PyArg_ParseTuple(args, "s*", &pbuf)) return NULL; @@ -1665,6 +1693,8 @@ assert(seq != NULL); if (f->f_fp == NULL) return err_closed(); + if (!f->writable) + return err_mode("writing"); result = NULL; list = NULL; @@ -2105,6 +2135,8 @@ if (f->f_fp == NULL) return err_closed(); + if (!f->readable) + return err_mode("reading"); l = readahead_get_line_skip(f, 0, READAHEAD_BUFSIZE); if (l == NULL || PyString_GET_SIZE(l) == 0) { From python-checkins at python.org Fri Feb 5 18:14:05 2010 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 05 Feb 2010 17:14:05 -0000 Subject: [Python-checkins] r77991 - python/branches/py3k Message-ID: Author: antoine.pitrou Date: Fri Feb 5 18:14:05 2010 New Revision: 77991 Log: Blocked revisions 77989 via svnmerge ........ r77989 | antoine.pitrou | 2010-02-05 18:05:54 +0100 (ven., 05 f?vr. 2010) | 6 lines Issue #5677: Explicitly forbid write operations on read-only file objects, and read operations on write-only file objects. On Windows, the system C library would return a bogus result; on Solaris, it was possible to crash the interpreter. Patch by Stefan Krah. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Fri Feb 5 19:45:26 2010 From: python-checkins at python.org (barry.warsaw) Date: Fri, 05 Feb 2010 18:45:26 -0000 Subject: [Python-checkins] r77992 - in python/trunk: Doc/using/cmdline.rst Misc/NEWS Message-ID: Author: barry.warsaw Date: Fri Feb 5 19:45:25 2010 New Revision: 77992 Log: Resolve bug 7847 by including documentation for -J, -U, and -X under "Options you shouldn't use". Modified: python/trunk/Doc/using/cmdline.rst python/trunk/Misc/NEWS Modified: python/trunk/Doc/using/cmdline.rst ============================================================================== --- python/trunk/Doc/using/cmdline.rst (original) +++ python/trunk/Doc/using/cmdline.rst Fri Feb 5 19:45:25 2010 @@ -285,8 +285,6 @@ See also :envvar:`PYTHONUNBUFFERED`. -.. XXX should the -U option be documented? - .. cmdoption:: -v Print a message each time a module is initialized, showing the place @@ -362,9 +360,6 @@ .. note:: The line numbers in error messages will be off by one. -.. XXX document -X? - - .. cmdoption:: -3 Warn about Python 3.x incompatibilities which cannot be fixed trivially by @@ -382,7 +377,30 @@ .. versionadded:: 2.6 +Options you shouldn't use +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. cmdoption:: -J + + Reserved for use by Jython_. + +.. _Jython: http://jython.org + +.. cmdoption:: -U + + Turns all string literals into unicodes globally. Do not be tempted to use + this option as it will probably break your world. It also produces + ``.pyc`` files with a different magic number than normal. Instead, you can + enable unicode literals on a per-module basis by using:: + + from __future__ import unicode_literals + + at the top of the file. See :mod:`__future__` for details. + +.. cmdoption:: -X + Reserved for alternative implementations of Python to use for their own + purposes. .. _using-on-envvars: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Feb 5 19:45:25 2010 @@ -17,8 +17,8 @@ library would return a bogus result; on Solaris, it was possible to crash the interpreter. Patch by Stefan Krah. -- Issue #7853: Normalize exceptions before they are passed to a context managers - __exit__ method. +- Issue #7853: Normalize exceptions before they are passed to a context + managers __exit__ method. - Issue #7385: Fix a crash in `MemoryView_FromObject` when `PyObject_GetBuffer` fails. Patch by Florent Xicluna. @@ -153,6 +153,9 @@ Documentation ------------- +- Updating `Using Python` documentation to include description of CPython's + -J, -U and -X options. + - Update python manual page (options -B, -O0, -s, environment variables PYTHONDONTWRITEBYTECODE, PYTHONNOUSERSITE). From python-checkins at python.org Fri Feb 5 19:52:05 2010 From: python-checkins at python.org (barry.warsaw) Date: Fri, 05 Feb 2010 18:52:05 -0000 Subject: [Python-checkins] r77993 - in python/branches/release26-maint: Doc/using/cmdline.rst Misc/NEWS Message-ID: Author: barry.warsaw Date: Fri Feb 5 19:52:05 2010 New Revision: 77993 Log: Merged revisions 77992 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77992 | barry.warsaw | 2010-02-05 13:45:25 -0500 (Fri, 05 Feb 2010) | 4 lines Resolve bug 7847 by including documentation for -J, -U, and -X under "Options you shouldn't use". ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/using/cmdline.rst python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Doc/using/cmdline.rst ============================================================================== --- python/branches/release26-maint/Doc/using/cmdline.rst (original) +++ python/branches/release26-maint/Doc/using/cmdline.rst Fri Feb 5 19:52:05 2010 @@ -276,8 +276,6 @@ See also :envvar:`PYTHONUNBUFFERED`. -.. XXX should the -U option be documented? - .. cmdoption:: -v Print a message each time a module is initialized, showing the place @@ -353,9 +351,6 @@ .. note:: The line numbers in error messages will be off by one. -.. XXX document -X? - - .. cmdoption:: -3 Warn about Python 3.x incompatibilities which cannot be fixed trivially by @@ -373,7 +368,30 @@ .. versionadded:: 2.6 +Options you shouldn't use +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. cmdoption:: -J + + Reserved for use by Jython_. + +.. _Jython: http://jython.org + +.. cmdoption:: -U + + Turns all string literals into unicodes globally. Do not be tempted to use + this option as it will probably break your world. It also produces + ``.pyc`` files with a different magic number than normal. Instead, you can + enable unicode literals on a per-module basis by using:: + + from __future__ import unicode_literals + + at the top of the file. See :mod:`__future__` for details. + +.. cmdoption:: -X + Reserved for alternative implementations of Python to use for their own + purposes. .. _using-on-envvars: Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Fri Feb 5 19:52:05 2010 @@ -34,7 +34,8 @@ used to drop the time part of the result. - Issue #6108: unicode(exception) and str(exception) should return the same - message when only __str__ (and not __unicode__) is overridden in the subclass. + message when only __str__ (and not __unicode__) is overridden in the + subclass. - Issue #7491: Metaclass's __cmp__ method was ignored. @@ -134,8 +135,8 @@ - Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is generated in Distutils. Patch by Stephen Emslie. -- Issue #4120: Drop reference to CRT from manifest when building extensions with - msvc9compiler. +- Issue #4120: Drop reference to CRT from manifest when building extensions + with msvc9compiler. - Issue #7410: deepcopy of itertools.count() erroneously reset the count. @@ -222,12 +223,15 @@ binary distribution on OSX 10.6 even when the user does not have the 10.4u SDK installed. -- Issue #7541: when using ``python-config`` with a framework install the compiler might - use the wrong library. +- Issue #7541: when using ``python-config`` with a framework install the + compiler might use the wrong library. Documentation ------------- +- Updating `Using Python` documentation to include description of CPython's + -J, -U and -X options. + - Update python manual page (options -B, -O0, -s, environment variables PYTHONDONTWRITEBYTECODE, PYTHONNOUSERSITE). From python-checkins at python.org Fri Feb 5 20:01:59 2010 From: python-checkins at python.org (barry.warsaw) Date: Fri, 05 Feb 2010 19:01:59 -0000 Subject: [Python-checkins] r77994 - python/branches/py3k Message-ID: Author: barry.warsaw Date: Fri Feb 5 20:01:58 2010 New Revision: 77994 Log: Blocked revisions 77992 via svnmerge ........ r77992 | barry.warsaw | 2010-02-05 13:45:25 -0500 (Fri, 05 Feb 2010) | 4 lines Resolve bug 7847 by including documentation for -J, -U, and -X under "Options you shouldn't use". ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Fri Feb 5 20:12:30 2010 From: python-checkins at python.org (barry.warsaw) Date: Fri, 05 Feb 2010 19:12:30 -0000 Subject: [Python-checkins] r77995 - in python/branches/py3k: Doc/using/cmdline.rst Misc/NEWS Message-ID: Author: barry.warsaw Date: Fri Feb 5 20:12:30 2010 New Revision: 77995 Log: Document the -J and -X options for CPython. Note that unlike for py2k, we don't need to document -U becuase it's gone in py3k. Modified: python/branches/py3k/Doc/using/cmdline.rst python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Doc/using/cmdline.rst ============================================================================== --- python/branches/py3k/Doc/using/cmdline.rst (original) +++ python/branches/py3k/Doc/using/cmdline.rst Fri Feb 5 20:12:30 2010 @@ -238,8 +238,6 @@ See also :envvar:`PYTHONUNBUFFERED`. -.. XXX should the -U option be documented? - .. cmdoption:: -v Print a message each time a module is initialized, showing the place @@ -315,6 +313,20 @@ .. note:: The line numbers in error messages will be off by one. +Options you shouldn't use +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. cmdoption:: -J + + Reserved for use by Jython_. + +.. _Jython: http://jython.org + +.. cmdoption:: -X + + Reserved for alternative implementations of Python to use for their own + purposes. + .. _using-on-envvars: Environment variables Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Fri Feb 5 20:12:30 2010 @@ -701,6 +701,9 @@ Documentation ------------ +- Updating `Using Python` documentation to include description of CPython's + -J and -X options. + - Document that importing a module that has None in sys.modules triggers an ImportError. From python-checkins at python.org Fri Feb 5 20:21:12 2010 From: python-checkins at python.org (barry.warsaw) Date: Fri, 05 Feb 2010 19:21:12 -0000 Subject: [Python-checkins] r77996 - in python/branches/release31-maint: Doc/using/cmdline.rst Misc/NEWS Message-ID: Author: barry.warsaw Date: Fri Feb 5 20:21:12 2010 New Revision: 77996 Log: Merged revisions 77995 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r77995 | barry.warsaw | 2010-02-05 14:12:30 -0500 (Fri, 05 Feb 2010) | 3 lines Document the -J and -X options for CPython. Note that unlike for py2k, we don't need to document -U becuase it's gone in py3k. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/using/cmdline.rst python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Doc/using/cmdline.rst ============================================================================== --- python/branches/release31-maint/Doc/using/cmdline.rst (original) +++ python/branches/release31-maint/Doc/using/cmdline.rst Fri Feb 5 20:21:12 2010 @@ -238,8 +238,6 @@ See also :envvar:`PYTHONUNBUFFERED`. -.. XXX should the -U option be documented? - .. cmdoption:: -v Print a message each time a module is initialized, showing the place @@ -315,6 +313,20 @@ .. note:: The line numbers in error messages will be off by one. +Options you shouldn't use +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. cmdoption:: -J + + Reserved for use by Jython_. + +.. _Jython: http://jython.org + +.. cmdoption:: -X + + Reserved for alternative implementations of Python to use for their own + purposes. + .. _using-on-envvars: Environment variables Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Fri Feb 5 20:21:12 2010 @@ -378,6 +378,9 @@ Documentation ------------- +- Updating `Using Python` documentation to include description of CPython's + -J and -X options. + - Issue #6556: Fixed the Distutils configuration files location explanation for Windows. From python-checkins at python.org Fri Feb 5 21:52:14 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 20:52:14 -0000 Subject: [Python-checkins] r77997 - python/trunk/Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Fri Feb 5 21:52:14 2010 New Revision: 77997 Log: Closes issue 7030. Modified: python/trunk/Doc/library/unittest.rst Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Fri Feb 5 21:52:14 2010 @@ -806,12 +806,16 @@ .. versionadded:: 2.7 - .. method:: assertSameElements(expected, actual, msg=None) + .. method:: assertSameElements(actual, expected, msg=None) Test that sequence *expected* contains the same elements as *actual*, regardless of their order. When they don't, an error message listing the differences between the sequences will be generated. + Duplicate elements are ignored when comparing *actual* and *expected*. + It is the equivalent of ``assertEqual(set(expected), set(actual))`` + but it works with sequences of unhashable objects as well. + If specified *msg* will be used as the error message on failure. .. versionadded:: 2.7 From python-checkins at python.org Fri Feb 5 21:54:27 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 20:54:27 -0000 Subject: [Python-checkins] r77998 - in python/branches/py3k: Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Fri Feb 5 21:54:27 2010 New Revision: 77998 Log: Merged revisions 77997 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77997 | michael.foord | 2010-02-05 20:52:14 +0000 (Fri, 05 Feb 2010) | 1 line Closes issue 7030. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Fri Feb 5 21:54:27 2010 @@ -801,12 +801,16 @@ .. versionadded:: 3.1 - .. method:: assertSameElements(expected, actual, msg=None) + .. method:: assertSameElements(actual, expected, msg=None) Test that sequence *expected* contains the same elements as *actual*, regardless of their order. When they don't, an error message listing the differences between the sequences will be generated. + Duplicate elements are ignored when comparing *actual* and *expected*. + It is the equivalent of ``assertEqual(set(expected), set(actual))`` + but it works with sequences of unhashable objects as well. + If specified *msg* will be used as the error message on failure. .. versionadded:: 3.1 From python-checkins at python.org Fri Feb 5 22:07:39 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 21:07:39 -0000 Subject: [Python-checkins] r77999 - python/trunk/Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Fri Feb 5 22:07:38 2010 New Revision: 77999 Log: Example of using assertRaises as a context manager in the unittest documentation. Modified: python/trunk/Doc/library/unittest.rst Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Fri Feb 5 22:07:38 2010 @@ -895,12 +895,18 @@ If *callable* is omitted or None, returns a context manager so that the code under test can be written inline rather than as a function:: - with self.failUnlessRaises(some_error_class): + with self.assertRaises(SomeException): do_something() The context manager will store the caught exception object in its :attr:`exc_value` attribute. This can be useful if the intention - is to perform additional checks on the exception raised. + is to perform additional checks on the exception raised:: + + with self.assertRaises(SomeException) as cm: + do_something() + + the_exception = cm.exc_value + self.assertEquals(the_exception.error_code, 3) .. versionchanged:: 2.7 Added the ability to use :meth:`assertRaises` as a context manager. From python-checkins at python.org Fri Feb 5 22:13:40 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 21:13:40 -0000 Subject: [Python-checkins] r78000 - in python/branches/py3k: Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Fri Feb 5 22:13:40 2010 New Revision: 78000 Log: Merged revisions 77999 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77999 | michael.foord | 2010-02-05 21:07:38 +0000 (Fri, 05 Feb 2010) | 1 line Example of using assertRaises as a context manager in the unittest documentation. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Fri Feb 5 22:13:40 2010 @@ -892,14 +892,20 @@ If only the *exception* argument is given, returns a context manager so that the code under test can be written inline rather than as a function:: - with self.failUnlessRaises(some_error_class): + with self.assertRaises(SomeException): do_something() The context manager will store the caught exception object in its :attr:`exc_value` attribute. This can be useful if the intention - is to perform additional checks on the exception raised. + is to perform additional checks on the exception raised:: - .. versionchanged:: 3.1 + with self.assertRaises(SomeException) as cm: + do_something() + + the_exception = cm.exc_value + self.assertEquals(the_exception.error_code, 3) + + .. versionchanged:: 3.1 Added the ability to use :meth:`assertRaises` as a context manager. .. deprecated:: 3.1 From python-checkins at python.org Fri Feb 5 22:45:12 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 21:45:12 -0000 Subject: [Python-checkins] r78001 - python/trunk/Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Fri Feb 5 22:45:12 2010 New Revision: 78001 Log: Adding versionadded to test skipping section of unittest documentation. Modified: python/trunk/Doc/library/unittest.rst Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Fri Feb 5 22:45:12 2010 @@ -11,9 +11,6 @@ .. versionadded:: 2.1 -.. versionchanged:: 2.7 - Added test :ref:`skipping and expected failures `. - The Python unit testing framework, sometimes referred to as "PyUnit," is a Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in turn, a Java version of Kent's Smalltalk testing framework. Each is the de @@ -498,6 +495,8 @@ Skipping tests and expected failures ------------------------------------ +.. versionadded:: 2.7 + Unittest supports skipping individual test methods and even whole classes of tests. In addition, it supports marking a test as a "expected failure," a test that is broken and will fail, but shouldn't be counted as a failure on a From python-checkins at python.org Fri Feb 5 22:48:03 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 21:48:03 -0000 Subject: [Python-checkins] r78002 - in python/branches/py3k: Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Fri Feb 5 22:48:03 2010 New Revision: 78002 Log: Adding versionadded to the test skipping section of the unittest doc. Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Fri Feb 5 22:48:03 2010 @@ -9,9 +9,6 @@ .. sectionauthor:: Raymond Hettinger -.. versionchanged:: 3.1 - Added test :ref:`skipping and expected failures `. - The Python unit testing framework, sometimes referred to as "PyUnit," is a Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in turn, a Java version of Kent's Smalltalk testing framework. Each is the de @@ -493,6 +490,8 @@ Skipping tests and expected failures ------------------------------------ +.. versionadded:: 3.1 + Unittest supports skipping individual test methods and even whole classes of tests. In addition, it supports marking a test as a "expected failure," a test that is broken and will fail, but shouldn't be counted as a failure on a From python-checkins at python.org Fri Feb 5 23:55:10 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 22:55:10 -0000 Subject: [Python-checkins] r78003 - python/trunk/Lib/unittest/case.py Message-ID: Author: michael.foord Date: Fri Feb 5 23:55:09 2010 New Revision: 78003 Log: Improving docstrings in unittest.TestCase Modified: python/trunk/Lib/unittest/case.py Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Fri Feb 5 23:55:09 2010 @@ -218,10 +218,6 @@ """Returns both the test method name and first line of its docstring. If no docstring is given, only returns the method name. - - This method overrides unittest.TestCase.shortDescription(), which - only returns the first line of the docstring, obscuring the name - of the test upon failure. """ desc = str(self) doc_first_line = None @@ -384,8 +380,17 @@ If called with callableObj omitted or None, will return a context object used like this:: - with self.assertRaises(some_error_class): + with self.assertRaises(SomeException): do_something() + + The context manager keeps a reference to the exception as + the exc_value attribute. This allows you to inspect the + exception after the assertion:: + + with self.assertRaises(SomeException) as cm: + do_something() + the_exception = cm.exc_value + self.assertEquals(the_exception.error_code, 3) """ context = _AssertRaisesContext(excClass, self) if callableObj is None: @@ -733,6 +738,11 @@ Raises with an error message listing which elements of expected_seq are missing from actual_seq and vice versa if any. + + Duplicate elements are ignored when comparing *expected_seq* and + *actual_seq*. It is the equivalent of ``assertEqual(set(expected), + set(actual))`` but it works with sequences of unhashable objects as + well. """ try: expected = set(expected_seq) From python-checkins at python.org Fri Feb 5 23:58:21 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 22:58:21 -0000 Subject: [Python-checkins] r78004 - in python/branches/py3k: Lib/unittest/case.py Message-ID: Author: michael.foord Date: Fri Feb 5 23:58:21 2010 New Revision: 78004 Log: Merged revisions 78003 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78003 | michael.foord | 2010-02-05 22:55:09 +0000 (Fri, 05 Feb 2010) | 1 line Improving docstrings in unittest.TestCase ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/unittest/case.py Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Fri Feb 5 23:58:21 2010 @@ -231,10 +231,6 @@ """Returns both the test method name and first line of its docstring. If no docstring is given, only returns the method name. - - This method overrides unittest.TestCase.shortDescription(), which - only returns the first line of the docstring, obscuring the name - of the test upon failure. """ desc = str(self) doc_first_line = None @@ -397,8 +393,17 @@ If called with callableObj omitted or None, will return a context object used like this:: - with self.assertRaises(some_error_class): + with self.assertRaises(SomeException): do_something() + + The context manager keeps a reference to the exception as + the exc_value attribute. This allows you to inspect the + exception after the assertion:: + + with self.assertRaises(SomeException) as cm: + do_something() + the_exception = cm.exc_value + self.assertEquals(the_exception.error_code, 3) """ context = _AssertRaisesContext(excClass, self, callableObj) if callableObj is None: @@ -746,6 +751,11 @@ Raises with an error message listing which elements of expected_seq are missing from actual_seq and vice versa if any. + + Duplicate elements are ignored when comparing *expected_seq* and + *actual_seq*. It is the equivalent of ``assertEqual(set(expected), + set(actual))`` but it works with sequences of unhashable objects as + well. """ try: expected = set(expected_seq) From python-checkins at python.org Sat Feb 6 00:22:37 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 23:22:37 -0000 Subject: [Python-checkins] r78005 - python/trunk/Lib/unittest/case.py Message-ID: Author: michael.foord Date: Sat Feb 6 00:22:37 2010 New Revision: 78005 Log: Correction to docstring correction. Modified: python/trunk/Lib/unittest/case.py Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Sat Feb 6 00:22:37 2010 @@ -390,7 +390,7 @@ with self.assertRaises(SomeException) as cm: do_something() the_exception = cm.exc_value - self.assertEquals(the_exception.error_code, 3) + self.assertEqual(the_exception.error_code, 3) """ context = _AssertRaisesContext(excClass, self) if callableObj is None: From python-checkins at python.org Sat Feb 6 00:26:29 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 23:26:29 -0000 Subject: [Python-checkins] r78006 - in python/branches/py3k: Lib/unittest/case.py Message-ID: Author: michael.foord Date: Sat Feb 6 00:26:29 2010 New Revision: 78006 Log: Merged revisions 78005 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78005 | michael.foord | 2010-02-05 23:22:37 +0000 (Fri, 05 Feb 2010) | 1 line Correction to docstring correction. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/unittest/case.py Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Sat Feb 6 00:26:29 2010 @@ -403,7 +403,7 @@ with self.assertRaises(SomeException) as cm: do_something() the_exception = cm.exc_value - self.assertEquals(the_exception.error_code, 3) + self.assertEqual(the_exception.error_code, 3) """ context = _AssertRaisesContext(excClass, self, callableObj) if callableObj is None: From python-checkins at python.org Sat Feb 6 00:28:12 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 23:28:12 -0000 Subject: [Python-checkins] r78007 - python/trunk/Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Sat Feb 6 00:28:12 2010 New Revision: 78007 Log: Minor doc change. Modified: python/trunk/Doc/library/unittest.rst Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Sat Feb 6 00:28:12 2010 @@ -905,7 +905,7 @@ do_something() the_exception = cm.exc_value - self.assertEquals(the_exception.error_code, 3) + self.assertEqual(the_exception.error_code, 3) .. versionchanged:: 2.7 Added the ability to use :meth:`assertRaises` as a context manager. From python-checkins at python.org Sat Feb 6 00:32:33 2010 From: python-checkins at python.org (michael.foord) Date: Fri, 05 Feb 2010 23:32:33 -0000 Subject: [Python-checkins] r78008 - in python/branches/py3k: Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Sat Feb 6 00:32:33 2010 New Revision: 78008 Log: Merged revisions 78007 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78007 | michael.foord | 2010-02-05 23:28:12 +0000 (Fri, 05 Feb 2010) | 1 line Minor doc change. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Sat Feb 6 00:32:33 2010 @@ -902,7 +902,7 @@ do_something() the_exception = cm.exc_value - self.assertEquals(the_exception.error_code, 3) + self.assertEqual(the_exception.error_code, 3) .. versionchanged:: 3.1 Added the ability to use :meth:`assertRaises` as a context manager. From python-checkins at python.org Sat Feb 6 00:43:12 2010 From: python-checkins at python.org (vinay.sajip) Date: Fri, 05 Feb 2010 23:43:12 -0000 Subject: [Python-checkins] r78009 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Sat Feb 6 00:43:11 2010 New Revision: 78009 Log: test_logging: minor tweaks to timeouts, listening tests marked as skipped. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Sat Feb 6 00:43:11 2010 @@ -1579,6 +1579,7 @@ t.start() try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(2.0) sock.connect(('localhost', port)) slen = struct.pack('>L', len(text)) @@ -1592,9 +1593,10 @@ sock.close() finally: logging.config.stopListening() - t.join() + t.join(2.0) - def notest_listen_config_10_ok(self): + @unittest.skip("See issue #7857") + def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) logger = logging.getLogger("compiler.parser") @@ -1613,7 +1615,8 @@ ('ERROR', '4'), ], stream=output) - def notest_listen_config_1_ok(self): + @unittest.skip("See issue #7857") + def test_listen_config_1_ok(self): with captured_stdout() as output: self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) logger = logging.getLogger("compiler.parser") From solipsis at pitrou.net Sat Feb 6 01:04:49 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 6 Feb 2010 01:04:49 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r78002): sum=0 Message-ID: <20100206000449.47FCE1770A@ns6635.ovh.net> py3k results for svn r78002 (hg cset 9dc542cb4e34) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogYBJbdC', '-x', 'test_httpservers'] From python-checkins at python.org Sat Feb 6 01:22:27 2010 From: python-checkins at python.org (michael.foord) Date: Sat, 06 Feb 2010 00:22:27 -0000 Subject: [Python-checkins] r78010 - in python/trunk/Lib: test/test_unittest.py unittest/loader.py Message-ID: Author: michael.foord Date: Sat Feb 6 01:22:26 2010 New Revision: 78010 Log: unittest.TestLoader creates a TestSuite before calling load_tests. Issue 7799. Modified: python/trunk/Lib/test/test_unittest.py python/trunk/Lib/unittest/loader.py Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Sat Feb 6 01:22:26 2010 @@ -272,12 +272,14 @@ load_tests_args = [] def load_tests(loader, tests, pattern): + self.assertIsInstance(tests, unittest.TestSuite) load_tests_args.extend((loader, tests, pattern)) return tests m.load_tests = load_tests loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) + self.assertIsInstance(suite, unittest.TestSuite) self.assertEquals(load_tests_args, [loader, suite, None]) load_tests_args = [] Modified: python/trunk/Lib/unittest/loader.py ============================================================================== --- python/trunk/Lib/unittest/loader.py (original) +++ python/trunk/Lib/unittest/loader.py Sat Feb 6 01:22:26 2010 @@ -71,9 +71,10 @@ tests.append(self.loadTestsFromTestCase(obj)) load_tests = getattr(module, 'load_tests', None) + tests = self.suiteClass(tests) if use_load_tests and load_tests is not None: return load_tests(self, tests, None) - return self.suiteClass(tests) + return tests def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier. From python-checkins at python.org Sat Feb 6 01:26:13 2010 From: python-checkins at python.org (michael.foord) Date: Sat, 06 Feb 2010 00:26:13 -0000 Subject: [Python-checkins] r78011 - in python/branches/py3k: Lib/test/test_unittest.py Lib/unittest/loader.py Message-ID: Author: michael.foord Date: Sat Feb 6 01:26:13 2010 New Revision: 78011 Log: Merged revisions 78010 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78010 | michael.foord | 2010-02-06 00:22:26 +0000 (Sat, 06 Feb 2010) | 1 line unittest.TestLoader creates a TestSuite before calling load_tests. Issue 7799. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/unittest/loader.py Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Sat Feb 6 01:26:13 2010 @@ -272,12 +272,14 @@ load_tests_args = [] def load_tests(loader, tests, pattern): + self.assertIsInstance(tests, unittest.TestSuite) load_tests_args.extend((loader, tests, pattern)) return tests m.load_tests = load_tests loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) + self.assertIsInstance(suite, unittest.TestSuite) self.assertEquals(load_tests_args, [loader, suite, None]) load_tests_args = [] Modified: python/branches/py3k/Lib/unittest/loader.py ============================================================================== --- python/branches/py3k/Lib/unittest/loader.py (original) +++ python/branches/py3k/Lib/unittest/loader.py Sat Feb 6 01:26:13 2010 @@ -61,9 +61,10 @@ tests.append(self.loadTestsFromTestCase(obj)) load_tests = getattr(module, 'load_tests', None) + tests = self.suiteClass(tests) if use_load_tests and load_tests is not None: return load_tests(self, tests, None) - return self.suiteClass(tests) + return tests def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier. From nnorwitz at gmail.com Sat Feb 6 02:05:24 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 5 Feb 2010 20:05:24 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20100206010524.GA25609@kbk-i386-bb.psfb.org> More important issues: ---------------------- test_bz2 leaked [0, 0, 91] references, sum=91 test_distutils leaked [0, -25, 0] references, sum=-25 Less important issues: ---------------------- From python-checkins at python.org Sat Feb 6 03:38:10 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 02:38:10 -0000 Subject: [Python-checkins] r78012 - python/branches/release26-maint/Lib/lib2to3 Message-ID: Author: benjamin.peterson Date: Sat Feb 6 03:38:09 2010 New Revision: 78012 Log: remove lib2to3 to update Removed: python/branches/release26-maint/Lib/lib2to3/ From python-checkins at python.org Sat Feb 6 03:40:03 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 02:40:03 -0000 Subject: [Python-checkins] r78013 - python/branches/release26-maint/Lib/lib2to3 Message-ID: Author: benjamin.peterson Date: Sat Feb 6 03:40:03 2010 New Revision: 78013 Log: copy lib2to3 from the trunk Added: python/branches/release26-maint/Lib/lib2to3/ - copied from r78012, /python/trunk/Lib/lib2to3/ From python-checkins at python.org Sat Feb 6 05:27:22 2010 From: python-checkins at python.org (r.david.murray) Date: Sat, 06 Feb 2010 04:27:22 -0000 Subject: [Python-checkins] r78014 - in python/trunk: Lib/test/test_timeout.py Misc/NEWS Message-ID: Author: r.david.murray Date: Sat Feb 6 05:27:21 2010 New Revision: 78014 Log: issue #7728: test_timeout was using a hardcoded port, which was causing buildbot failures. Changed to use test_support.bind_port. Patch by Florent Xicluna. Modified: python/trunk/Lib/test/test_timeout.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/test_timeout.py ============================================================================== --- python/trunk/Lib/test/test_timeout.py (original) +++ python/trunk/Lib/test/test_timeout.py Sat Feb 6 05:27:21 2010 @@ -101,7 +101,7 @@ def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addr_remote = ('www.python.org.', 80) - self.addr_local = ('127.0.0.1', 25339) + self.localhost = '127.0.0.1' def tearDown(self): self.sock.close() @@ -146,7 +146,8 @@ # Test accept() timeout _timeout = 2 self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + test_support.bind_port(self.sock, self.localhost) self.sock.listen(5) _t1 = time.time() @@ -163,7 +164,8 @@ _timeout = 2 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + test_support.bind_port(self.sock, self.localhost) _t1 = time.time() self.assertRaises(socket.error, self.sock.recvfrom, 8192) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Feb 6 05:27:21 2010 @@ -150,6 +150,14 @@ added to the `Tools/` directory. They were previously living in the sandbox. + +Tests +----- + +- issue #7728: test_timeout was changed to use test_support.bind_port + instead of a hard coded port. + + Documentation ------------- From python-checkins at python.org Sat Feb 6 05:56:33 2010 From: python-checkins at python.org (r.david.murray) Date: Sat, 06 Feb 2010 04:56:33 -0000 Subject: [Python-checkins] r78015 - in python/branches/release26-maint: Lib/test/test_timeout.py Misc/NEWS Message-ID: Author: r.david.murray Date: Sat Feb 6 05:56:33 2010 New Revision: 78015 Log: Merged revisions 78014 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78014 | r.david.murray | 2010-02-05 23:27:21 -0500 (Fri, 05 Feb 2010) | 5 lines issue #7728: test_timeout was using a hardcoded port, which was causing buildbot failures. Changed to use test_support.bind_port. Patch by Florent Xicluna. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_timeout.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/test/test_timeout.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_timeout.py (original) +++ python/branches/release26-maint/Lib/test/test_timeout.py Sat Feb 6 05:56:33 2010 @@ -101,7 +101,7 @@ def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addr_remote = ('www.python.org.', 80) - self.addr_local = ('127.0.0.1', 25339) + self.localhost = '127.0.0.1' def tearDown(self): self.sock.close() @@ -146,7 +146,8 @@ # Test accept() timeout _timeout = 2 self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + test_support.bind_port(self.sock, self.localhost) self.sock.listen(5) _t1 = time.time() @@ -163,7 +164,8 @@ _timeout = 2 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + test_support.bind_port(self.sock, self.localhost) _t1 = time.time() self.failUnlessRaises(socket.error, self.sock.recvfrom, 8192) Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sat Feb 6 05:56:33 2010 @@ -238,6 +238,9 @@ Tests ----- +- issue #7728: test_timeout was changed to use test_support.bind_port + instead of a hard coded port. + - Issue #7498: test_multiprocessing now uses test_support.find_unused_port instead of a hardcoded port number in test_rapid_restart. From python-checkins at python.org Sat Feb 6 06:00:15 2010 From: python-checkins at python.org (r.david.murray) Date: Sat, 06 Feb 2010 05:00:15 -0000 Subject: [Python-checkins] r78016 - in python/branches/py3k: Lib/test/test_timeout.py Misc/NEWS Message-ID: Author: r.david.murray Date: Sat Feb 6 06:00:15 2010 New Revision: 78016 Log: Merged revisions 78014 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78014 | r.david.murray | 2010-02-05 23:27:21 -0500 (Fri, 05 Feb 2010) | 5 lines issue #7728: test_timeout was using a hardcoded port, which was causing buildbot failures. Changed to use test_support.bind_port. Patch by Florent Xicluna. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_timeout.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/test_timeout.py ============================================================================== --- python/branches/py3k/Lib/test/test_timeout.py (original) +++ python/branches/py3k/Lib/test/test_timeout.py Sat Feb 6 06:00:15 2010 @@ -101,7 +101,7 @@ def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addr_remote = ('www.python.org.', 80) - self.addr_local = ('127.0.0.1', 25339) + self.localhost = '127.0.0.1' def tearDown(self): self.sock.close() @@ -146,7 +146,8 @@ # Test accept() timeout _timeout = 2 self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + support.bind_port(self.sock, self.localhost) self.sock.listen(5) _t1 = time.time() @@ -163,7 +164,8 @@ _timeout = 2 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + support.bind_port(self.sock, self.localhost) _t1 = time.time() self.assertRaises(socket.error, self.sock.recvfrom, 8192) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Feb 6 06:00:15 2010 @@ -716,6 +716,9 @@ Tests ----- +- issue #7728: test_timeout was changed to use test_support.bind_port + instead of a hard coded port. + - Issue #7376: instead of running a self-test (which was failing) when called with no arguments, doctest.py now gives a usage message. From python-checkins at python.org Sat Feb 6 06:09:09 2010 From: python-checkins at python.org (r.david.murray) Date: Sat, 06 Feb 2010 05:09:09 -0000 Subject: [Python-checkins] r78017 - in python/branches/release31-maint: Lib/test/test_timeout.py Misc/NEWS Message-ID: Author: r.david.murray Date: Sat Feb 6 06:09:09 2010 New Revision: 78017 Log: Merged revisions 78016 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r78016 | r.david.murray | 2010-02-06 00:00:15 -0500 (Sat, 06 Feb 2010) | 11 lines Merged revisions 78014 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78014 | r.david.murray | 2010-02-05 23:27:21 -0500 (Fri, 05 Feb 2010) | 5 lines issue #7728: test_timeout was using a hardcoded port, which was causing buildbot failures. Changed to use test_support.bind_port. Patch by Florent Xicluna. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_timeout.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/test/test_timeout.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_timeout.py (original) +++ python/branches/release31-maint/Lib/test/test_timeout.py Sat Feb 6 06:09:09 2010 @@ -101,7 +101,7 @@ def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addr_remote = ('www.python.org.', 80) - self.addr_local = ('127.0.0.1', 25339) + self.localhost = '127.0.0.1' def tearDown(self): self.sock.close() @@ -146,7 +146,8 @@ # Test accept() timeout _timeout = 2 self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + support.bind_port(self.sock, self.localhost) self.sock.listen(5) _t1 = time.time() @@ -163,7 +164,8 @@ _timeout = 2 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(_timeout) - self.sock.bind(self.addr_local) + # Prevent "Address already in use" socket exceptions + support.bind_port(self.sock, self.localhost) _t1 = time.time() self.assertRaises(socket.error, self.sock.recvfrom, 8192) Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Sat Feb 6 06:09:09 2010 @@ -301,6 +301,9 @@ Tests ----- +- issue #7728: test_timeout was changed to use test_support.bind_port + instead of a hard coded port. + - Issue #7376: instead of running a self-test (which was failing) when called with no arguments, doctest.py now gives a usage message. From python-checkins at python.org Sat Feb 6 11:08:22 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 10:08:22 -0000 Subject: [Python-checkins] r78018 - python/trunk/Doc/library/unittest.rst Message-ID: Author: georg.brandl Date: Sat Feb 6 11:08:21 2010 New Revision: 78018 Log: #7864: make deprecation notices a bit clearer. Modified: python/trunk/Doc/library/unittest.rst Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Sat Feb 6 11:08:21 2010 @@ -681,7 +681,7 @@ will be *msg* if given, otherwise it will be :const:`None`. .. deprecated:: 2.7 - :meth:`failUnless`. + :meth:`failUnless`; use one of the ``assert`` variants. .. method:: assertEqual(first, second[, msg]) @@ -703,7 +703,7 @@ Added the automatic calling of type specific equality function. .. deprecated:: 2.7 - :meth:`failUnlessEqual`. + :meth:`failUnlessEqual`; use :meth:`assertEqual`. .. method:: assertNotEqual(first, second[, msg]) @@ -717,7 +717,7 @@ *first* and *second*. .. deprecated:: 2.7 - :meth:`failIfEqual`. + :meth:`failIfEqual`; use :meth:`assertNotEqual`. .. method:: assertAlmostEqual(first, second[, places[, msg]]) @@ -736,7 +736,7 @@ Objects that compare equal are automatically almost equal. .. deprecated:: 2.7 - :meth:`failUnlessAlmostEqual`. + :meth:`failUnlessAlmostEqual`; use :meth:`assertAlmostEqual`. .. method:: assertNotAlmostEqual(first, second[, places[, msg]]) @@ -755,7 +755,7 @@ Objects that compare equal automatically fail. .. deprecated:: 2.7 - :meth:`failIfAlmostEqual`. + :meth:`failIfAlmostEqual`; use :meth:`assertNotAlmostEqual`. .. method:: assertGreater(first, second, msg=None) @@ -911,7 +911,7 @@ Added the ability to use :meth:`assertRaises` as a context manager. .. deprecated:: 2.7 - :meth:`failUnlessRaises`. + :meth:`failUnlessRaises`; use :meth:`assertRaises`. .. method:: assertRaisesRegexp(exception, regexp[, callable, ...]) @@ -988,7 +988,7 @@ for the error message. .. deprecated:: 2.7 - :meth:`failIf`. + :meth:`failIf`; use :meth:`assertFalse`. .. method:: fail([msg]) From python-checkins at python.org Sat Feb 6 11:23:16 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 10:23:16 -0000 Subject: [Python-checkins] r78019 - python/trunk/Doc/library/sysconfig.rst Message-ID: Author: georg.brandl Date: Sat Feb 6 11:23:16 2010 New Revision: 78019 Log: Review sysconfig docs. Modified: python/trunk/Doc/library/sysconfig.rst Modified: python/trunk/Doc/library/sysconfig.rst ============================================================================== --- python/trunk/Doc/library/sysconfig.rst (original) +++ python/trunk/Doc/library/sysconfig.rst Sat Feb 6 11:23:16 2010 @@ -10,96 +10,98 @@ single: configuration information The :mod:`sysconfig` module provides access to Python's configuration -information like the list of installation paths and the configuration -variables relevant for the current platform. +information like the list of installation paths and the configuration variables +relevant for the current platform. Configuration variables ----------------------- A Python distribution contains a :file:`Makefile` file and a :file:`python.h` -that are used to build the Python binary itself, but also any C extension +that are necessary to build the Python binary itself, but also any C extension created in a third party project and compiled using :mod:`distutils`. -:mod:`sysconfig` put all variables found in these files in a dictionnary -that can be accessed using :func:`get_config_vars` or :func:`get_config_var`. +:mod:`sysconfig` puts all variables found in these files in a dictionary that +can be accessed using :func:`get_config_vars` or :func:`get_config_var`. Notice that on Windows, it's a much smaller set. .. function:: get_config_vars(\*args) - With no arguments, return a dictionary of all configuration - variables relevant for the current platform. + With no arguments, return a dictionary of all configuration variables + relevant for the current platform. - With arguments, return a list of values that result from looking up - each argument in the configuration variable dictionary. + With arguments, return a list of values that result from looking up each + argument in the configuration variable dictionary. + + For each argument, if the value is not found, return ``None``. - For each argument, if the value is not found, returns None. .. function:: get_config_var(name) Return the value of a single variable *name*. Equivalent to - get_config_vars().get(name). + ``get_config_vars().get(name)``. - If *name* is not found, return None. + If *name* is not found, return ``None``. Example of usage:: - >>> import sysconfig - >>> sysconfig.get_config_var('Py_ENABLE_SHARED') - 0 - >>> sysconfig.get_config_var('LIBDIR') - '/usr/local/lib' - >>> sysconfig.get_config_vars('AR', 'CXX') - ['ar', 'g++'] + >>> import sysconfig + >>> sysconfig.get_config_var('Py_ENABLE_SHARED') + 0 + >>> sysconfig.get_config_var('LIBDIR') + '/usr/local/lib' + >>> sysconfig.get_config_vars('AR', 'CXX') + ['ar', 'g++'] Installation paths ------------------ -Python uses an installation scheme that differs depending on the platform -and on the installation options. These schemes are stored in :mod:`sysconfig` -under unique identifiers based on the value returned by :const:`os.name`. +Python uses an installation scheme that differs depending on the platform and on +the installation options. These schemes are stored in :mod:`sysconfig` under +unique identifiers based on the value returned by :const:`os.name`. Every new component that is installed using :mod:`distutils` or a -Distutils-based system will follow the same scheme to copy its file in the -right places. +Distutils-based system will follow the same scheme to copy its file in the right +places. Python currently supports seven schemes: -- *posix_prefix*: scheme for posix platforms like Linux or Mac OS X. This is the - default scheme used when Python or a component is installed. -- *posix_home*: scheme for posix platform used when a *home* option is used - upon installation. This scheme is used when a component is installed through +- *posix_prefix*: scheme for Posix platforms like Linux or Mac OS X. This is + the default scheme used when Python or a component is installed. +- *posix_home*: scheme for Posix platforms used when a *home* option is used + upon installation. This scheme is used when a component is installed through Distutils with a specific home prefix. -- *posix_user*: scheme for posix platform used when a component is installed - through Distutils and the *user* option is used. This scheme defines paths +- *posix_user*: scheme for Posix platforms used when a component is installed + through Distutils and the *user* option is used. This scheme defines paths located under the user home directory. -- *nt*: scheme for nt platforms like Windows. -- *nt_user*: scheme for nt platforms, when the *user* option is used. -- *os2*: scheme for OS2 platforms. -- *os2_home*: scheme for OS2 patforms, when the *user* option is used. +- *nt*: scheme for NT platforms like Windows. +- *nt_user*: scheme for NT platforms, when the *user* option is used. +- *os2*: scheme for OS/2 platforms. +- *os2_home*: scheme for OS/2 patforms, when the *user* option is used. Each scheme is itself composed of a series of paths and each path has a unique -identifier. Python currently uses eight paths: +identifier. Python currently uses eight paths: -- *stdlib*: directory containing the standard Python library files that are - not platform-specific. -- *platstdlib*: directory containing the standard Python library files that - are platform-specific files. -- *platlib*: directory for the site-specific, platform-specific files. -- *purelib*: directory for the site-specific, non platform-specific files. -- *include*: directory containing the non-platform-specific header files. -- *platinclude*: directory containing the platform-specific header files. -- *scripts*: directory containing the script files. -- *data*: directory containing the data files. +- *stdlib*: directory containing the standard Python library files that are not + platform-specific. +- *platstdlib*: directory containing the standard Python library files that are + platform-specific. +- *platlib*: directory for site-specific, platform-specific files. +- *purelib*: directory for site-specific, non-platform-specific files. +- *include*: directory for non-platform-specific header files. +- *platinclude*: directory for platform-specific header files. +- *scripts*: directory for script files. +- *data*: directory for data files. -:mod:`sysconfig` provides some functions to read these paths. +:mod:`sysconfig` provides some functions to determine these paths. .. function:: get_scheme_names() Return a tuple containing all schemes currently supported in :mod:`sysconfig`. + .. function:: get_path_names() Return a tuple containing all path names currently supported in @@ -113,37 +115,37 @@ *name* has to be a value from the list returned by :func:`get_path_names`. - :mod:`sysconfig` stores installation paths corresponding to the each - path name, for each platform, with variables to be expanded. For instance - the `stdlib` path for the `nt` scheme is: `{base}/Lib`. + :mod:`sysconfig` stores installation paths corresponding to each path name, + for each platform, with variables to be expanded. For instance the *stdlib* + path for the *nt* scheme is: ``{base}/Lib``. :func:`get_path` will use the variables returned by :func:`get_config_vars` - to expand the path. All variables have default values for each platform - so one may call this function and get the default value. + to expand the path. All variables have default values for each platform so + one may call this function and get the default value. If *scheme* is provided, it must be a value from the list returned by - :func:`get_path_names`. Otherwise, the default scheme for the current + :func:`get_path_names`. Otherwise, the default scheme for the current platform is used. - If *vars* is provided, it must be a dictionnary of variables that will - update the dictionnary return by :func:`get_config_vars`. + If *vars* is provided, it must be a dictionary of variables that will update + the dictionary return by :func:`get_config_vars`. - If *expand* is set to False, the path will not be expanded using - the variables. + If *expand* is set to ``False``, the path will not be expanded using the + variables. - If *name* is not found, return None. + If *name* is not found, return ``None``. .. function:: get_paths([scheme, [vars, [expand]]]) - Return a dictionnary containing all installation paths corresponding to an + Return a dictionary containing all installation paths corresponding to an installation scheme. See :func:`get_path` for more information. If *scheme* is not provided, will use the default scheme for the current platform. - If *vars* is provided, it must be a dictionnary of variables that will - update the dictionnary used to expand the paths. + If *vars* is provided, it must be a dictionary of variables that will + update the dictionary used to expand the paths. If *expand* is set to False, the paths will not be expanded. @@ -156,20 +158,20 @@ .. function:: get_python_version() - Return the MAJOR.MINOR Python version number as a string. Similar to + Return the ``MAJOR.MINOR`` Python version number as a string. Similar to ``sys.version[:3]``. + .. function:: get_platform() Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and - platform-specific built distributions. Typically includes the OS name - and version and the architecture (as supplied by 'os.uname()'), - although the exact information included depends on the OS; eg. for IRIX - the architecture isn't particularly important (IRIX only runs on SGI - hardware), but for Linux the kernel version isn't particularly - important. + platform-specific built distributions. Typically includes the OS name and + version and the architecture (as supplied by :func:`os.uname`), although the + exact information included depends on the OS; e.g. for IRIX the architecture + isn't particularly important (IRIX only runs on SGI hardware), but for Linux + the kernel version isn't particularly important. Examples of returned values: @@ -185,34 +187,32 @@ - win-ia64 (64bit Windows on Itanium) - win32 (all others - specifically, sys.platform is returned) - Mac OS X can return : + Mac OS X can return: - macosx-10.6-ppc - macosx-10.4-ppc64 - macosx-10.3-i386 - macosx-10.4-fat - For other non-POSIX platforms, currently just returns 'sys.platform'. + For other non-POSIX platforms, currently just returns :data:`sys.platform`. -.. function:: is_python_build(): +.. function:: is_python_build() - Returns True if the current Python installation was built from source. + Return ``True`` if the current Python installation was built from source. -.. function:: parse_config_h(fp[, vars]): +.. function:: parse_config_h(fp[, vars]) - Parse a config.h-style file. + Parse a :file:`config.h`\-style file. - *fp* is a file-like object pointing to the config.h-like file. + *fp* is a file-like object pointing to the :file:`config.h`\-like file. A dictionary containing name/value pairs is returned. If an optional - dictionary is passed in as the second argument, it is used instead of a - new dictionary, and updated with the values read in the file. - - -.. function:: get_config_h_filename(): + dictionary is passed in as the second argument, it is used instead of a new + dictionary, and updated with the values read in the file. - Returns the path of pyconfig.h +.. function:: get_config_h_filename() + Return the path of :file:`pyconfig.h`. From python-checkins at python.org Sat Feb 6 17:37:33 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 16:37:33 -0000 Subject: [Python-checkins] r78020 - in python/trunk: Include/patchlevel.h Lib/distutils/__init__.py Lib/idlelib/idlever.py Misc/NEWS Misc/RPM/python-2.7.spec README Message-ID: Author: benjamin.peterson Date: Sat Feb 6 17:37:32 2010 New Revision: 78020 Log: bump version to 2.7a3 Modified: python/trunk/Include/patchlevel.h python/trunk/Lib/distutils/__init__.py python/trunk/Lib/idlelib/idlever.py python/trunk/Misc/NEWS python/trunk/Misc/RPM/python-2.7.spec python/trunk/README Modified: python/trunk/Include/patchlevel.h ============================================================================== --- python/trunk/Include/patchlevel.h (original) +++ python/trunk/Include/patchlevel.h Sat Feb 6 17:37:32 2010 @@ -24,10 +24,10 @@ #define PY_MINOR_VERSION 7 #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA -#define PY_RELEASE_SERIAL 2 +#define PY_RELEASE_SERIAL 3 /* Version as a string */ -#define PY_VERSION "2.7a2+" +#define PY_VERSION "2.7a3" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/trunk/Lib/distutils/__init__.py ============================================================================== --- python/trunk/Lib/distutils/__init__.py (original) +++ python/trunk/Lib/distutils/__init__.py Sat Feb 6 17:37:32 2010 @@ -15,5 +15,5 @@ # Updated automatically by the Python release process. # #--start constants-- -__version__ = "2.7a2" +__version__ = "2.7a3" #--end constants-- Modified: python/trunk/Lib/idlelib/idlever.py ============================================================================== --- python/trunk/Lib/idlelib/idlever.py (original) +++ python/trunk/Lib/idlelib/idlever.py Sat Feb 6 17:37:32 2010 @@ -1 +1 @@ -IDLE_VERSION = "2.7a2" +IDLE_VERSION = "2.7a3" Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Feb 6 17:37:32 2010 @@ -7,7 +7,7 @@ What's New in Python 2.7 alpha 3? ================================= -*Release date: XXXX-XX-XX* +*Release date: 2010-02-06* Core and Builtins ----------------- Modified: python/trunk/Misc/RPM/python-2.7.spec ============================================================================== --- python/trunk/Misc/RPM/python-2.7.spec (original) +++ python/trunk/Misc/RPM/python-2.7.spec Sat Feb 6 17:37:32 2010 @@ -39,8 +39,8 @@ %define name python #--start constants-- -%define version 2.7a2 -%define libvers 2.7 +%define version 2.7a3 +%define libver 2.7 #--end constants-- %define release 1pydotorg %define __prefix /usr Modified: python/trunk/README ============================================================================== --- python/trunk/README (original) +++ python/trunk/README Sat Feb 6 17:37:32 2010 @@ -1,4 +1,4 @@ -This is Python version 2.7 alpha 2 +This is Python version 2.7 alpha 3 ================================== Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 From python-checkins at python.org Sat Feb 6 17:41:20 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 16:41:20 -0000 Subject: [Python-checkins] r78021 - python/tags/r27a3 Message-ID: Author: benjamin.peterson Date: Sat Feb 6 17:41:20 2010 New Revision: 78021 Log: tag 2.7 alpha 3 Added: python/tags/r27a3/ - copied from r78020, /python/trunk/ From python-checkins at python.org Sat Feb 6 19:26:27 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 18:26:27 -0000 Subject: [Python-checkins] r78022 - in python/trunk: Include/patchlevel.h Misc/NEWS Message-ID: Author: benjamin.peterson Date: Sat Feb 6 19:26:27 2010 New Revision: 78022 Log: post release updates Modified: python/trunk/Include/patchlevel.h python/trunk/Misc/NEWS Modified: python/trunk/Include/patchlevel.h ============================================================================== --- python/trunk/Include/patchlevel.h (original) +++ python/trunk/Include/patchlevel.h Sat Feb 6 19:26:27 2010 @@ -27,7 +27,7 @@ #define PY_RELEASE_SERIAL 3 /* Version as a string */ -#define PY_VERSION "2.7a3" +#define PY_VERSION "2.7a3+" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Feb 6 19:26:27 2010 @@ -4,6 +4,18 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.7 alpha 4? +================================= + +*Release date: XXXX-XX-XX* + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 2.7 alpha 3? ================================= From python-checkins at python.org Sat Feb 6 19:29:29 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 18:29:29 -0000 Subject: [Python-checkins] r78023 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Sat Feb 6 19:29:29 2010 New Revision: 78023 Log: Blocked revisions 78020,78022 via svnmerge ........ r78020 | benjamin.peterson | 2010-02-06 10:37:32 -0600 (Sat, 06 Feb 2010) | 1 line bump version to 2.7a3 ........ r78022 | benjamin.peterson | 2010-02-06 12:26:27 -0600 (Sat, 06 Feb 2010) | 1 line post release updates ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Feb 6 19:44:45 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 18:44:45 -0000 Subject: [Python-checkins] r78024 - in python/trunk/Doc: faq/design.rst faq/extending.rst faq/library.rst faq/programming.rst howto/doanddont.rst library/inspect.rst Message-ID: Author: georg.brandl Date: Sat Feb 6 19:44:44 2010 New Revision: 78024 Log: #5341: fix "builtin" where used as an adjective ("built-in" is correct). Modified: python/trunk/Doc/faq/design.rst python/trunk/Doc/faq/extending.rst python/trunk/Doc/faq/library.rst python/trunk/Doc/faq/programming.rst python/trunk/Doc/howto/doanddont.rst python/trunk/Doc/library/inspect.rst Modified: python/trunk/Doc/faq/design.rst ============================================================================== --- python/trunk/Doc/faq/design.rst (original) +++ python/trunk/Doc/faq/design.rst Sat Feb 6 19:44:44 2010 @@ -664,9 +664,10 @@ you won't be fooled into accidentally overwriting a list when you need a sorted copy but also need to keep the unsorted version around. -In Python 2.4 a new builtin -- :func:`sorted` -- has been added. This function -creates a new list from a provided iterable, sorts it and returns it. For -example, here's how to iterate over the keys of a dictionary in sorted order:: +In Python 2.4 a new built-in function -- :func:`sorted` -- has been added. +This function creates a new list from a provided iterable, sorts it and returns +it. For example, here's how to iterate over the keys of a dictionary in sorted +order:: for key in sorted(mydict): ... # do whatever with mydict[key]... Modified: python/trunk/Doc/faq/extending.rst ============================================================================== --- python/trunk/Doc/faq/extending.rst (original) +++ python/trunk/Doc/faq/extending.rst Sat Feb 6 19:44:44 2010 @@ -439,7 +439,7 @@ Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ---------------------------------------------------------------------------------------------------------------- -In Python 2.2, you can inherit from builtin classes such as :class:`int`, +In Python 2.2, you can inherit from built-in classes such as :class:`int`, :class:`list`, :class:`dict`, etc. The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html) Modified: python/trunk/Doc/faq/library.rst ============================================================================== --- python/trunk/Doc/faq/library.rst (original) +++ python/trunk/Doc/faq/library.rst Sat Feb 6 19:44:44 2010 @@ -25,10 +25,10 @@ Where is the math.py (socket.py, regex.py, etc.) source file? ------------------------------------------------------------- -If you can't find a source file for a module it may be a builtin or dynamically -loaded module implemented in C, C++ or other compiled language. In this case -you may not have the source file or it may be something like mathmodule.c, -somewhere in a C source directory (not on the Python Path). +If you can't find a source file for a module it may be a built-in or +dynamically loaded module implemented in C, C++ or other compiled language. +In this case you may not have the source file or it may be something like +mathmodule.c, somewhere in a C source directory (not on the Python Path). There are (at least) three kinds of modules in Python: @@ -359,7 +359,7 @@ In theory, this means an exact accounting requires an exact understanding of the PVM bytecode implementation. In practice, it means that operations on shared -variables of builtin data types (ints, lists, dicts, etc) that "look atomic" +variables of built-in data types (ints, lists, dicts, etc) that "look atomic" really are. For example, the following operations are all atomic (L, L1, L2 are lists, D, @@ -502,9 +502,9 @@ :func:`os.read` is a low-level function which takes a file descriptor, a small integer representing the opened file. :func:`os.popen` creates a high-level -file object, the same type returned by the builtin :func:`open` function. Thus, -to read n bytes from a pipe p created with :func:`os.popen`, you need to use -``p.read(n)``. +file object, the same type returned by the built-in :func:`open` function. +Thus, to read n bytes from a pipe p created with :func:`os.popen`, you need to +use ``p.read(n)``. How do I run a subprocess with pipes connected to both input and output? @@ -603,10 +603,11 @@ which in turn are a medium-level layer of abstraction on top of (among other things) low-level C file descriptors. -For most file objects you create in Python via the builtin ``file`` constructor, -``f.close()`` marks the Python file object as being closed from Python's point -of view, and also arranges to close the underlying C stream. This also happens -automatically in f's destructor, when f becomes garbage. +For most file objects you create in Python via the built-in ``file`` +constructor, ``f.close()`` marks the Python file object as being closed from +Python's point of view, and also arranges to close the underlying C stream. +This also happens automatically in ``f``'s destructor, when ``f`` becomes +garbage. But stdin, stdout and stderr are treated specially by Python, because of the special status also given to them by C. Running ``sys.stdout.close()`` marks Modified: python/trunk/Doc/faq/programming.rst ============================================================================== --- python/trunk/Doc/faq/programming.rst (original) +++ python/trunk/Doc/faq/programming.rst Sat Feb 6 19:44:44 2010 @@ -178,9 +178,10 @@ L2 = list(L1[:3]) # "list" is redundant if L1 is a list. -Note that the functionally-oriented builtins such as :func:`map`, :func:`zip`, -and friends can be a convenient accelerator for loops that perform a single -task. For example to pair the elements of two lists together:: +Note that the functionally-oriented built-in functions such as :func:`map`, +:func:`zip`, and friends can be a convenient accelerator for loops that +perform a single task. For example to pair the elements of two lists +together:: >>> zip([1, 2, 3], [4, 5, 6]) [(1, 4), (2, 5), (3, 6)] @@ -203,7 +204,7 @@ not dealing with constant string patterns. You may still use :ref:`the old % operations ` ``string % tuple`` and ``string % dictionary``. -Be sure to use the :meth:`list.sort` builtin method to do sorting, and see the +Be sure to use the :meth:`list.sort` built-in method to do sorting, and see the `sorting mini-HOWTO `_ for examples of moderately advanced usage. :meth:`list.sort` beats other techniques for sorting in all but the most extreme circumstances. @@ -346,7 +347,7 @@ one hand, requiring :keyword:`global` for assigned variables provides a bar against unintended side-effects. On the other hand, if ``global`` was required for all global references, you'd be using ``global`` all the time. You'd have -to declare as global every reference to a builtin function or to a component of +to declare as global every reference to a built-in function or to a component of an imported module. This clutter would defeat the usefulness of the ``global`` declaration for identifying side-effects. @@ -1059,7 +1060,7 @@ How do I iterate over a sequence in reverse order? -------------------------------------------------- -Use the :func:`reversed` builtin function, which is new in Python 2.4:: +Use the :func:`reversed` built-in function, which is new in Python 2.4:: for x in reversed(sequence): ... # do something with x... Modified: python/trunk/Doc/howto/doanddont.rst ============================================================================== --- python/trunk/Doc/howto/doanddont.rst (original) +++ python/trunk/Doc/howto/doanddont.rst Sat Feb 6 19:44:44 2010 @@ -52,10 +52,10 @@ f.read() does not work. Of course, it works just fine (assuming you have a file called -"www".) But it does not work if somewhere in the module, the statement ``from os -import *`` is present. The :mod:`os` module has a function called :func:`open` -which returns an integer. While it is very useful, shadowing builtins is one of -its least useful properties. +"www".) But it does not work if somewhere in the module, the statement ``from +os import *`` is present. The :mod:`os` module has a function called +:func:`open` which returns an integer. While it is very useful, shadowing a +builtin is one of its least useful properties. Remember, you can never know for sure what names a module exports, so either take what you need --- ``from module import name1, name2``, or keep them in the Modified: python/trunk/Doc/library/inspect.rst ============================================================================== --- python/trunk/Doc/library/inspect.rst (original) +++ python/trunk/Doc/library/inspect.rst Sat Feb 6 19:44:44 2010 @@ -126,7 +126,7 @@ | frame | f_back | next outer frame object | | | | | (this frame's caller) | | +-----------+-----------------+---------------------------+-------+ -| | f_builtins | built-in namespace seen | | +| | f_builtins | builtins namespace seen | | | | | by this frame | | +-----------+-----------------+---------------------------+-------+ | | f_code | code object being | | From python-checkins at python.org Sat Feb 6 19:46:57 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 18:46:57 -0000 Subject: [Python-checkins] r78025 - in python/branches/py3k: Doc/extending/extending.rst Doc/faq/design.rst Doc/faq/extending.rst Doc/faq/library.rst Doc/faq/programming.rst Doc/glossary.rst Doc/howto/doanddont.rst Doc/library/exceptions.rst Doc/library/gc.rst Doc/library/inspect.rst Doc/reference/simple_stmts.rst Doc/tutorial/classes.rst Doc/whatsnew/3.0.rst Doc/whatsnew/3.1.rst Message-ID: Author: georg.brandl Date: Sat Feb 6 19:46:57 2010 New Revision: 78025 Log: Recorded merge of revisions 78024 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78024 | georg.brandl | 2010-02-06 19:44:44 +0100 (Sa, 06 Feb 2010) | 1 line #5341: fix "builtin" where used as an adjective ("built-in" is correct). ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/extending/extending.rst python/branches/py3k/Doc/faq/design.rst python/branches/py3k/Doc/faq/extending.rst python/branches/py3k/Doc/faq/library.rst python/branches/py3k/Doc/faq/programming.rst python/branches/py3k/Doc/glossary.rst python/branches/py3k/Doc/howto/doanddont.rst python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/library/gc.rst python/branches/py3k/Doc/library/inspect.rst python/branches/py3k/Doc/reference/simple_stmts.rst python/branches/py3k/Doc/tutorial/classes.rst python/branches/py3k/Doc/whatsnew/3.0.rst python/branches/py3k/Doc/whatsnew/3.1.rst Modified: python/branches/py3k/Doc/extending/extending.rst ============================================================================== --- python/branches/py3k/Doc/extending/extending.rst (original) +++ python/branches/py3k/Doc/extending/extending.rst Sat Feb 6 19:46:57 2010 @@ -354,7 +354,7 @@ int main(int argc, char *argv[]) { - /* Add a builtin module, before Py_Initialize */ + /* Add a built-in module, before Py_Initialize */ PyImport_AppendInittab("spam", PyInit_spam); /* Pass argv[0] to the Python interpreter */ Modified: python/branches/py3k/Doc/faq/design.rst ============================================================================== --- python/branches/py3k/Doc/faq/design.rst (original) +++ python/branches/py3k/Doc/faq/design.rst Sat Feb 6 19:46:57 2010 @@ -649,9 +649,10 @@ you won't be fooled into accidentally overwriting a list when you need a sorted copy but also need to keep the unsorted version around. -In Python 2.4 a new builtin -- :func:`sorted` -- has been added. This function -creates a new list from a provided iterable, sorts it and returns it. For -example, here's how to iterate over the keys of a dictionary in sorted order:: +In Python 2.4 a new built-in function -- :func:`sorted` -- has been added. +This function creates a new list from a provided iterable, sorts it and returns +it. For example, here's how to iterate over the keys of a dictionary in sorted +order:: for key in sorted(mydict): ... # do whatever with mydict[key]... Modified: python/branches/py3k/Doc/faq/extending.rst ============================================================================== --- python/branches/py3k/Doc/faq/extending.rst (original) +++ python/branches/py3k/Doc/faq/extending.rst Sat Feb 6 19:46:57 2010 @@ -441,7 +441,7 @@ Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ---------------------------------------------------------------------------------------------------------------- -In Python 2.2, you can inherit from builtin classes such as :class:`int`, +In Python 2.2, you can inherit from built-in classes such as :class:`int`, :class:`list`, :class:`dict`, etc. The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html) Modified: python/branches/py3k/Doc/faq/library.rst ============================================================================== --- python/branches/py3k/Doc/faq/library.rst (original) +++ python/branches/py3k/Doc/faq/library.rst Sat Feb 6 19:46:57 2010 @@ -25,10 +25,10 @@ Where is the math.py (socket.py, regex.py, etc.) source file? ------------------------------------------------------------- -If you can't find a source file for a module it may be a builtin or dynamically -loaded module implemented in C, C++ or other compiled language. In this case -you may not have the source file or it may be something like mathmodule.c, -somewhere in a C source directory (not on the Python Path). +If you can't find a source file for a module it may be a built-in or +dynamically loaded module implemented in C, C++ or other compiled language. +In this case you may not have the source file or it may be something like +mathmodule.c, somewhere in a C source directory (not on the Python Path). There are (at least) three kinds of modules in Python: @@ -361,7 +361,7 @@ In theory, this means an exact accounting requires an exact understanding of the PVM bytecode implementation. In practice, it means that operations on shared -variables of builtin data types (ints, lists, dicts, etc) that "look atomic" +variables of built-in data types (ints, lists, dicts, etc) that "look atomic" really are. For example, the following operations are all atomic (L, L1, L2 are lists, D, @@ -504,9 +504,9 @@ :func:`os.read` is a low-level function which takes a file descriptor, a small integer representing the opened file. :func:`os.popen` creates a high-level -file object, the same type returned by the builtin :func:`open` function. Thus, -to read n bytes from a pipe p created with :func:`os.popen`, you need to use -``p.read(n)``. +file object, the same type returned by the built-in :func:`open` function. +Thus, to read n bytes from a pipe p created with :func:`os.popen`, you need to +use ``p.read(n)``. .. XXX update to use subprocess. See the :ref:`subprocess-replacements` section. @@ -607,10 +607,11 @@ which in turn are a medium-level layer of abstraction on top of (among other things) low-level C file descriptors. -For most file objects you create in Python via the builtin ``open`` constructor, -``f.close()`` marks the Python file object as being closed from Python's point -of view, and also arranges to close the underlying C stream. This also happens -automatically in f's destructor, when f becomes garbage. +For most file objects you create in Python via the built-in ``open`` +constructor, ``f.close()`` marks the Python file object as being closed from +Python's point of view, and also arranges to close the underlying C stream. +This also happens automatically in ``f``'s destructor, when ``f`` becomes +garbage. But stdin, stdout and stderr are treated specially by Python, because of the special status also given to them by C. Running ``sys.stdout.close()`` marks Modified: python/branches/py3k/Doc/faq/programming.rst ============================================================================== --- python/branches/py3k/Doc/faq/programming.rst (original) +++ python/branches/py3k/Doc/faq/programming.rst Sat Feb 6 19:46:57 2010 @@ -178,9 +178,10 @@ L2 = list(L1[:3]) # "list" is redundant if L1 is a list. -Note that the functionally-oriented builtins such as :func:`map`, :func:`zip`, -and friends can be a convenient accelerator for loops that perform a single -task. For example to pair the elements of two lists together:: +Note that the functionally-oriented built-in functions such as :func:`map`, +:func:`zip`, and friends can be a convenient accelerator for loops that +perform a single task. For example to pair the elements of two lists +together:: >>> list(zip([1, 2, 3], [4, 5, 6])) [(1, 4), (2, 5), (3, 6)] @@ -203,7 +204,7 @@ on string objects `. Use regular expressions only when you're not dealing with constant string patterns. -Be sure to use the :meth:`list.sort` builtin method to do sorting, and see the +Be sure to use the :meth:`list.sort` built-in method to do sorting, and see the `sorting mini-HOWTO `_ for examples of moderately advanced usage. :meth:`list.sort` beats other techniques for sorting in all but the most extreme circumstances. @@ -361,7 +362,7 @@ one hand, requiring :keyword:`global` for assigned variables provides a bar against unintended side-effects. On the other hand, if ``global`` was required for all global references, you'd be using ``global`` all the time. You'd have -to declare as global every reference to a builtin function or to a component of +to declare as global every reference to a built-in function or to a component of an imported module. This clutter would defeat the usefulness of the ``global`` declaration for identifying side-effects. @@ -1033,7 +1034,7 @@ How do I iterate over a sequence in reverse order? -------------------------------------------------- -Use the :func:`reversed` builtin function, which is new in Python 2.4:: +Use the :func:`reversed` built-in function, which is new in Python 2.4:: for x in reversed(sequence): ... # do something with x... Modified: python/branches/py3k/Doc/glossary.rst ============================================================================== --- python/branches/py3k/Doc/glossary.rst (original) +++ python/branches/py3k/Doc/glossary.rst Sat Feb 6 19:46:57 2010 @@ -315,7 +315,7 @@ iterator An object representing a stream of data. Repeated calls to the iterator's - :meth:`__next__` (or passing it to the builtin function) :func:`next` + :meth:`__next__` (or passing it to the built-in function) :func:`next` method return successive items in the stream. When no more data are available a :exc:`StopIteration` exception is raised instead. At this point, the iterator object is exhausted and any further calls to its Modified: python/branches/py3k/Doc/howto/doanddont.rst ============================================================================== --- python/branches/py3k/Doc/howto/doanddont.rst (original) +++ python/branches/py3k/Doc/howto/doanddont.rst Sat Feb 6 19:46:57 2010 @@ -52,10 +52,10 @@ f.read() does not work. Of course, it works just fine (assuming you have a file called -"www".) But it does not work if somewhere in the module, the statement ``from os -import *`` is present. The :mod:`os` module has a function called :func:`open` -which returns an integer. While it is very useful, shadowing builtins is one of -its least useful properties. +"www".) But it does not work if somewhere in the module, the statement ``from +os import *`` is present. The :mod:`os` module has a function called +:func:`open` which returns an integer. While it is very useful, shadowing a +builtin is one of its least useful properties. Remember, you can never know for sure what names a module exports, so either take what you need --- ``from module import name1, name2``, or keep them in the Modified: python/branches/py3k/Doc/library/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/library/exceptions.rst (original) +++ python/branches/py3k/Doc/library/exceptions.rst Sat Feb 6 19:46:57 2010 @@ -241,8 +241,8 @@ .. exception:: StopIteration - Raised by builtin :func:`next` and an :term:`iterator`\'s :meth:`__next__` - method to signal that there are no further values. + Raised by built-in function :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/gc.rst ============================================================================== --- python/branches/py3k/Doc/library/gc.rst (original) +++ python/branches/py3k/Doc/library/gc.rst Sat Feb 6 19:46:57 2010 @@ -43,7 +43,7 @@ :exc:`ValueError` is raised if the generation number is invalid. The number of unreachable objects found is returned. - The free lists maintained for a number of builtin types are cleared + The free lists maintained for a number of built-in types are cleared whenever a full collection or collection of the highest generation (2) is run. Not all items in some free lists may be freed due to the particular implementation, in particular :class:`float`. Modified: python/branches/py3k/Doc/library/inspect.rst ============================================================================== --- python/branches/py3k/Doc/library/inspect.rst (original) +++ python/branches/py3k/Doc/library/inspect.rst Sat Feb 6 19:46:57 2010 @@ -87,7 +87,7 @@ | frame | f_back | next outer frame object | | | | (this frame's caller) | +-----------+-----------------+---------------------------+ -| | f_builtins | built-in namespace seen | +| | f_builtins | builtins namespace seen | | | | by this frame | +-----------+-----------------+---------------------------+ | | f_code | code object being | Modified: python/branches/py3k/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/simple_stmts.rst (original) +++ python/branches/py3k/Doc/reference/simple_stmts.rst Sat Feb 6 19:46:57 2010 @@ -953,7 +953,7 @@ **Programmer's note:** the :keyword:`global` is a directive to the parser. It applies only to code parsed at the same time as the :keyword:`global` statement. In particular, a :keyword:`global` statement contained in a string or code -object supplied to the builtin :func:`exec` function does not affect the code +object supplied to the built-in :func:`exec` function does not affect the code block *containing* the function call, and code contained in such a string is unaffected by :keyword:`global` statements in the code containing the function call. The same applies to the :func:`eval` and :func:`compile` functions. Modified: python/branches/py3k/Doc/tutorial/classes.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/classes.rst (original) +++ python/branches/py3k/Doc/tutorial/classes.rst Sat Feb 6 19:46:57 2010 @@ -717,7 +717,7 @@ container one at a time. When there are no more elements, :meth:`__next__` raises a :exc:`StopIteration` exception which tells the :keyword:`for` loop to terminate. You can call the :meth:`__next__` method using the :func:`next` -builtin; this example shows how it all works:: +built-in function; this example shows how it all works:: >>> s = 'abc' >>> it = iter(s) Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Sat Feb 6 19:46:57 2010 @@ -270,7 +270,7 @@ single "euro" character. (Of course, this change only affects raw string literals; the euro character is ``'\u20ac'`` in Python 3.0.) -* The builtin :class:`basestring` abstract type was removed. Use +* The built-in :class:`basestring` abstract type was removed. Use :class:`str` instead. The :class:`str` and :class:`bytes` types don't have functionality enough in common to warrant a shared base class. The ``2to3`` tool (see below) replaces every occurrence of @@ -383,10 +383,10 @@ literals (``0720``) are gone. * New binary literals, e.g. ``0b1010`` (already in 2.6), and - there is a new corresponding builtin function, :func:`bin`. + there is a new corresponding built-in function, :func:`bin`. * Bytes literals are introduced with a leading ``b`` or ``B``, and - there is a new corresponding builtin function, :func:`bytes`. + there is a new corresponding built-in function, :func:`bytes`. Changed Syntax -------------- @@ -506,7 +506,7 @@ * :ref:`pep-3116`. The :mod:`io` module is now the standard way of doing file I/O, and the initial values of :data:`sys.stdin`, :data:`sys.stdout` and :data:`sys.stderr` are now instances of - :class:`io.TextIOBase`. The builtin :func:`open` function is now an + :class:`io.TextIOBase`. The built-in :func:`open` function is now an alias for :func:`io.open` and has additional keyword arguments *encoding*, *errors*, *newline* and *closefd*. Also note that an invalid *mode* argument now raises :exc:`ValueError`, not @@ -521,7 +521,7 @@ * :ref:`pep-3119`. The :mod:`abc` module and the ABCs defined in the :mod:`collections` module plays a somewhat more prominent role in - the language now, and builtin collection types like :class:`dict` + the language now, and built-in collection types like :class:`dict` and :class:`list` conform to the :class:`collections.MutableMapping` and :class:`collections.MutableSequence` ABCs, respectively. @@ -615,7 +615,7 @@ Some other changes to standard library modules, not covered by :pep:`3108`: -* Killed :mod:`sets`. Use the builtin :func:`set` function. +* Killed :mod:`sets`. Use the built-in :func:`set` class. * Cleanup of the :mod:`sys` module: removed :func:`sys.exitfunc`, :func:`sys.exc_clear`, :data:`sys.exc_type`, :data:`sys.exc_value`, @@ -795,8 +795,8 @@ It raises :exc:`EOFError` if the input is terminated prematurely. To get the old behavior of :func:`input`, use ``eval(input())``. -* A new builtin :func:`next` was added to call the :meth:`__next__` - method on an object. +* A new built-in function :func:`next` was added to call the + :meth:`__next__` method on an object. * Moved :func:`intern` to :func:`sys.intern`. Modified: python/branches/py3k/Doc/whatsnew/3.1.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.1.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.1.rst Sat Feb 6 19:46:57 2010 @@ -85,7 +85,7 @@ PEP 378: Format Specifier for Thousands Separator ================================================= -The builtin :func:`format` function and the :meth:`str.format` method use +The built-in :func:`format` function and the :meth:`str.format` method use a mini-language that now includes a simple, non-locale aware way to format a number with a thousands separator. That provides a way to humanize a program's output, improving its professional appearance and readability:: From python-checkins at python.org Sat Feb 6 20:11:31 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 19:11:31 -0000 Subject: [Python-checkins] r78026 - python/branches/release26-maint Message-ID: Author: benjamin.peterson Date: Sat Feb 6 20:11:31 2010 New Revision: 78026 Log: Unblocked revisions 68805 via svnmerge ........ r68805 | benjamin.peterson | 2009-01-20 08:21:16 -0600 (Tue, 20 Jan 2009) | 1 line allow unicode keyword arguments for the ** syntax #4978 ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Feb 6 20:16:34 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 19:16:34 -0000 Subject: [Python-checkins] r78027 - in python/branches/release26-maint: Lib/test/test_extcall.py Misc/NEWS Python/ceval.c Message-ID: Author: benjamin.peterson Date: Sat Feb 6 20:16:33 2010 New Revision: 78027 Log: Merged revisions 68805 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68805 | benjamin.peterson | 2009-01-20 08:21:16 -0600 (Tue, 20 Jan 2009) | 1 line allow unicode keyword arguments for the ** syntax #4978 ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_extcall.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Python/ceval.c Modified: python/branches/release26-maint/Lib/test/test_extcall.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_extcall.py (original) +++ python/branches/release26-maint/Lib/test/test_extcall.py Sat Feb 6 20:16:33 2010 @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Doctest for method/function calls. We're going the use these types for extra testing @@ -252,11 +253,30 @@ """ +import unittest from test import test_support + +class UnicodeKeywordArgsTest(unittest.TestCase): + + def test_unicode_keywords(self): + def f(a): + return a + self.assertEqual(f(**{u'a': 4}), 4) + self.assertRaises(TypeError, f, **{u'st?ren': 4}) + self.assertRaises(TypeError, f, **{u'someLongString':2}) + try: + f(a=4, **{u'a': 4}) + except TypeError: + pass + else: + self.fail("duplicate arguments didn't raise") + + def test_main(): from test import test_extcall # self import test_support.run_doctest(test_extcall, True) + test_support.run_unittest(UnicodeKeywordArgsTest) if __name__ == '__main__': test_main() Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sat Feb 6 20:16:33 2010 @@ -17,6 +17,8 @@ library would return a bogus result; on Solaris, it was possible to crash the interpreter. Patch by Stefan Krah. +- Issue #4978: Passing keyword arguments as unicode strings is now allowed. + - Issue #7819: Check sys.call_tracing() arguments types. - Issue #7788: Fix an interpreter crash produced by deleting a list Modified: python/branches/release26-maint/Python/ceval.c ============================================================================== --- python/branches/release26-maint/Python/ceval.c (original) +++ python/branches/release26-maint/Python/ceval.c Sat Feb 6 20:16:33 2010 @@ -145,6 +145,7 @@ static void format_exc_check_arg(PyObject *, char *, PyObject *); static PyObject * string_concatenate(PyObject *, PyObject *, PyFrameObject *, unsigned char *); +static PyObject * kwd_as_string(PyObject *); #define NAME_ERROR_MSG \ "name '%.200s' is not defined" @@ -2831,7 +2832,8 @@ PyObject *keyword = kws[2*i]; PyObject *value = kws[2*i + 1]; int j; - if (keyword == NULL || !PyString_Check(keyword)) { + if (keyword == NULL || !(PyString_Check(keyword) || + PyUnicode_Check(keyword))) { PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", PyString_AsString(co->co_name)); @@ -2860,11 +2862,15 @@ goto fail; if (j >= co->co_argcount) { if (kwdict == NULL) { - PyErr_Format(PyExc_TypeError, - "%.200s() got an unexpected " - "keyword argument '%.400s'", - PyString_AsString(co->co_name), - PyString_AsString(keyword)); + PyObject *kwd_str = kwd_as_string(keyword); + if (kwd_str) { + PyErr_Format(PyExc_TypeError, + "%.200s() got an unexpected " + "keyword argument '%.400s'", + PyString_AsString(co->co_name), + PyString_AsString(kwd_str)); + Py_DECREF(kwd_str); + } goto fail; } PyDict_SetItem(kwdict, keyword, value); @@ -2872,12 +2878,16 @@ } kw_found: if (GETLOCAL(j) != NULL) { - PyErr_Format(PyExc_TypeError, - "%.200s() got multiple " - "values for keyword " - "argument '%.400s'", - PyString_AsString(co->co_name), - PyString_AsString(keyword)); + PyObject *kwd_str = kwd_as_string(keyword); + if (kwd_str) { + PyErr_Format(PyExc_TypeError, + "%.200s() got multiple " + "values for keyword " + "argument '%.400s'", + PyString_AsString(co->co_name), + PyString_AsString(kwd_str)); + Py_DECREF(kwd_str); + } goto fail; } Py_INCREF(value); @@ -3004,6 +3014,17 @@ } +static PyObject * +kwd_as_string(PyObject *kwd) { + if (PyString_Check(kwd)) { + Py_INCREF(kwd); + return kwd; + } + else + return _PyUnicode_AsDefaultEncodedString(kwd, "replace"); +} + + /* Implementation notes for set_exc_info() and reset_exc_info(): - Below, 'exc_ZZZ' stands for 'exc_type', 'exc_value' and From python-checkins at python.org Sat Feb 6 20:40:18 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 19:40:18 -0000 Subject: [Python-checkins] r78028 - python/trunk/Python/ceval.c Message-ID: Author: benjamin.peterson Date: Sat Feb 6 20:40:18 2010 New Revision: 78028 Log: remove pointless error checking Modified: python/trunk/Python/ceval.c Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Sat Feb 6 20:40:18 2010 @@ -3115,9 +3115,6 @@ else if (cmp < 0) goto fail; } - /* Check errors from Compare */ - if (PyErr_Occurred()) - goto fail; if (j >= co->co_argcount) { if (kwdict == NULL) { PyObject *kwd_str = kwd_as_string(keyword); From python-checkins at python.org Sat Feb 6 21:00:43 2010 From: python-checkins at python.org (vinay.sajip) Date: Sat, 06 Feb 2010 20:00:43 -0000 Subject: [Python-checkins] r78029 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Sat Feb 6 21:00:43 2010 New Revision: 78029 Log: Issue #7857: Tentatively re-enabling one test to see effect on buildbots. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Sat Feb 6 21:00:43 2010 @@ -1595,7 +1595,7 @@ logging.config.stopListening() t.join(2.0) - @unittest.skip("See issue #7857") + #@unittest.skip("See issue #7857") def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) From python-checkins at python.org Sat Feb 6 21:14:10 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 20:14:10 -0000 Subject: [Python-checkins] r78030 - python/trunk/Lib/test/test_descr.py Message-ID: Author: benjamin.peterson Date: Sat Feb 6 21:14:10 2010 New Revision: 78030 Log: check type_getattro for correctness in a descriptor corner case Modified: python/trunk/Lib/test/test_descr.py Modified: python/trunk/Lib/test/test_descr.py ============================================================================== --- python/trunk/Lib/test/test_descr.py (original) +++ python/trunk/Lib/test/test_descr.py Sat Feb 6 21:14:10 2010 @@ -4516,6 +4516,15 @@ x.a = 42 self.assertEqual(x.a, 42) + # Also check type_getattro for correctness. + class Meta(type): + pass + class X(object): + __metaclass__ = Meta + X.a = 42 + Meta.a = Descr("a") + self.assertEqual(X.a, 42) + def test_getattr_hooks(self): # issue 4230 From python-checkins at python.org Sat Feb 6 21:28:36 2010 From: python-checkins at python.org (vinay.sajip) Date: Sat, 06 Feb 2010 20:28:36 -0000 Subject: [Python-checkins] r78031 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Sat Feb 6 21:28:36 2010 New Revision: 78031 Log: Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Sat Feb 6 21:28:36 2010 @@ -1577,6 +1577,7 @@ port = find_unused_port() t = logging.config.listen(port) t.start() + time.sleep(0.5) # give server thread some time to get ready try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2.0) @@ -1615,7 +1616,7 @@ ('ERROR', '4'), ], stream=output) - @unittest.skip("See issue #7857") + #@unittest.skip("See issue #7857") def test_listen_config_1_ok(self): with captured_stdout() as output: self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) From python-checkins at python.org Sat Feb 6 22:54:40 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 21:54:40 -0000 Subject: [Python-checkins] r78032 - python/trunk/Lib/test/test_logging.py Message-ID: Author: georg.brandl Date: Sat Feb 6 22:54:40 2010 New Revision: 78032 Log: Remove unused imports from test_logging. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Sat Feb 6 22:54:40 2010 @@ -26,7 +26,6 @@ import logging.config import codecs -import copy import cPickle import cStringIO import gc @@ -36,7 +35,6 @@ import select import socket from SocketServer import ThreadingTCPServer, StreamRequestHandler -import string import struct import sys import tempfile @@ -45,7 +43,6 @@ import textwrap import threading import time -import types import unittest import warnings import weakref From python-checkins at python.org Sat Feb 6 23:08:15 2010 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 06 Feb 2010 22:08:15 -0000 Subject: [Python-checkins] r78033 - in python/trunk/Lib: logging/config.py test/test_logging.py Message-ID: Author: benjamin.peterson Date: Sat Feb 6 23:08:15 2010 New Revision: 78033 Log: make waiting for the server to start robust Modified: python/trunk/Lib/logging/config.py python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/logging/config.py ============================================================================== --- python/trunk/Lib/logging/config.py (original) +++ python/trunk/Lib/logging/config.py Sat Feb 6 23:08:15 2010 @@ -843,17 +843,25 @@ abort = self.abort logging._releaseLock() - def serve(rcvr, hdlr, port): - server = rcvr(port=port, handler=hdlr) - global _listener - logging._acquireLock() - _listener = server - logging._releaseLock() - server.serve_until_stopped() + class Server(threading.Thread): + + def __init__(self, rcvr, hdlr, port): + super(Server, self).__init__() + self.rcvr = rcvr + self.hdlr = hdlr + self.port = port + self.ready = threading.Event() + + def run(self): + server = self.rcvr(port=self.port, handler=self.hdlr) + self.ready.set() + global _listener + logging._acquireLock() + _listener = server + logging._releaseLock() + server.serve_until_stopped() - return threading.Thread(target=serve, - args=(ConfigSocketReceiver, - ConfigStreamHandler, port)) + return Server(ConfigSocketReceiver, ConfigStreamHandler, port) def stopListening(): """ Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Sat Feb 6 23:08:15 2010 @@ -1574,7 +1574,7 @@ port = find_unused_port() t = logging.config.listen(port) t.start() - time.sleep(0.5) # give server thread some time to get ready + t.ready.wait() try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2.0) From g.brandl at gmx.net Sat Feb 6 23:20:08 2010 From: g.brandl at gmx.net (Georg Brandl) Date: Sat, 06 Feb 2010 23:20:08 +0100 Subject: [Python-checkins] r77978 - peps/trunk/pep-0391.txt In-Reply-To: <7442.36536925218$1265316106@news.gmane.org> References: <7442.36536925218$1265316106@news.gmane.org> Message-ID: Am 04.02.2010 21:41, schrieb vinay.sajip: > Author: vinay.sajip > Date: Thu Feb 4 21:39:43 2010 > New Revision: 77978 > > Log: > Marked PEP 391 as Accepted. The PEP should also be updated to mention that the PEP has been implemented in which branch, and which revision(s). Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. From python-checkins at python.org Sat Feb 6 23:27:52 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 22:27:52 -0000 Subject: [Python-checkins] r78034 - in python/branches/py3k/Lib/logging: __init__.py config.py Message-ID: Author: georg.brandl Date: Sat Feb 6 23:27:51 2010 New Revision: 78034 Log: Remove Python 1.x or 2.x compatibility code. Modified: python/branches/py3k/Lib/logging/__init__.py python/branches/py3k/Lib/logging/config.py Modified: python/branches/py3k/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k/Lib/logging/__init__.py (original) +++ python/branches/py3k/Lib/logging/__init__.py Sat Feb 6 23:27:51 2010 @@ -1559,17 +1559,8 @@ #else, swallow #Let's try and shutdown automatically on application exit... -try: - import atexit - atexit.register(shutdown) -except ImportError: # for Python versions < 2.0 - def exithook(status, old_exit=sys.exit): - try: - shutdown() - finally: - old_exit(status) - - sys.exit = exithook +import atexit +atexit.register(shutdown) # Null handler Modified: python/branches/py3k/Lib/logging/config.py ============================================================================== --- python/branches/py3k/Lib/logging/config.py (original) +++ python/branches/py3k/Lib/logging/config.py Sat Feb 6 23:27:51 2010 @@ -65,7 +65,7 @@ import configparser cp = configparser.ConfigParser(defaults) - if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): + if hasattr(fname, 'readline'): cp.readfp(fname) else: cp.read(fname) From python-checkins at python.org Sat Feb 6 23:44:17 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 22:44:17 -0000 Subject: [Python-checkins] r78035 - python/trunk/Lib/urllib.py Message-ID: Author: georg.brandl Date: Sat Feb 6 23:44:17 2010 New Revision: 78035 Log: Fix duplicate import. Modified: python/trunk/Lib/urllib.py Modified: python/trunk/Lib/urllib.py ============================================================================== --- python/trunk/Lib/urllib.py (original) +++ python/trunk/Lib/urllib.py Sat Feb 6 23:44:17 2010 @@ -28,7 +28,6 @@ import time import sys from urlparse import urljoin as basejoin -import warnings __all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve", "urlcleanup", "quote", "quote_plus", "unquote", "unquote_plus", @@ -72,8 +71,8 @@ def urlopen(url, data=None, proxies=None): """Create a file-like object for the specified URL to read from.""" from warnings import warnpy3k - warnings.warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " - "favor of urllib2.urlopen()", stacklevel=2) + warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " + "favor of urllib2.urlopen()", stacklevel=2) global _urlopener if proxies is not None: From python-checkins at python.org Sat Feb 6 23:49:47 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 22:49:47 -0000 Subject: [Python-checkins] r78036 - python/trunk/Lib/collections.py Message-ID: Author: georg.brandl Date: Sat Feb 6 23:49:47 2010 New Revision: 78036 Log: Remove unused import. Modified: python/trunk/Lib/collections.py Modified: python/trunk/Lib/collections.py ============================================================================== --- python/trunk/Lib/collections.py (original) +++ python/trunk/Lib/collections.py Sat Feb 6 23:49:47 2010 @@ -12,7 +12,7 @@ import heapq as _heapq from weakref import proxy as _proxy from itertools import repeat as _repeat, chain as _chain, starmap as _starmap, \ - ifilter as _ifilter, imap as _imap, izip as _izip + ifilter as _ifilter, imap as _imap ################################################################################ ### OrderedDict From python-checkins at python.org Sat Feb 6 23:59:16 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 22:59:16 -0000 Subject: [Python-checkins] r78037 - in python/trunk/Lib: UserDict.py genericpath.py mimetypes.py posixpath.py rexec.py subprocess.py threading.py urllib.py Message-ID: Author: georg.brandl Date: Sat Feb 6 23:59:15 2010 New Revision: 78037 Log: No need to assign the results of expressions used only for side effects. Modified: python/trunk/Lib/UserDict.py python/trunk/Lib/genericpath.py python/trunk/Lib/mimetypes.py python/trunk/Lib/posixpath.py python/trunk/Lib/rexec.py python/trunk/Lib/subprocess.py python/trunk/Lib/threading.py python/trunk/Lib/urllib.py Modified: python/trunk/Lib/UserDict.py ============================================================================== --- python/trunk/Lib/UserDict.py (original) +++ python/trunk/Lib/UserDict.py Sat Feb 6 23:59:15 2010 @@ -98,7 +98,7 @@ yield k def has_key(self, key): try: - value = self[key] + self[key] except KeyError: return False return True Modified: python/trunk/Lib/genericpath.py ============================================================================== --- python/trunk/Lib/genericpath.py (original) +++ python/trunk/Lib/genericpath.py Sat Feb 6 23:59:15 2010 @@ -15,7 +15,7 @@ def exists(path): """Test whether a path exists. Returns False for broken symbolic links""" try: - st = os.stat(path) + os.stat(path) except os.error: return False return True Modified: python/trunk/Lib/mimetypes.py ============================================================================== --- python/trunk/Lib/mimetypes.py (original) +++ python/trunk/Lib/mimetypes.py Sat Feb 6 23:59:15 2010 @@ -546,7 +546,6 @@ if __name__ == '__main__': - import sys import getopt USAGE = """\ Modified: python/trunk/Lib/posixpath.py ============================================================================== --- python/trunk/Lib/posixpath.py (original) +++ python/trunk/Lib/posixpath.py Sat Feb 6 23:59:15 2010 @@ -139,7 +139,7 @@ def lexists(path): """Test whether a path exists. Returns True for broken symbolic links""" try: - st = os.lstat(path) + os.lstat(path) except os.error: return False return True Modified: python/trunk/Lib/rexec.py ============================================================================== --- python/trunk/Lib/rexec.py (original) +++ python/trunk/Lib/rexec.py Sat Feb 6 23:59:15 2010 @@ -244,7 +244,7 @@ m.open = m.file = self.r_open def make_main(self): - m = self.add_module('__main__') + self.add_module('__main__') def make_osname(self): osname = os.name Modified: python/trunk/Lib/subprocess.py ============================================================================== --- python/trunk/Lib/subprocess.py (original) +++ python/trunk/Lib/subprocess.py Sat Feb 6 23:59:15 2010 @@ -920,7 +920,7 @@ """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: - obj = WaitForSingleObject(self._handle, INFINITE) + WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) return self.returncode Modified: python/trunk/Lib/threading.py ============================================================================== --- python/trunk/Lib/threading.py (original) +++ python/trunk/Lib/threading.py Sat Feb 6 23:59:15 2010 @@ -10,7 +10,6 @@ import warnings -from functools import wraps from time import time as _time, sleep as _sleep from traceback import format_exc as _format_exc from collections import deque Modified: python/trunk/Lib/urllib.py ============================================================================== --- python/trunk/Lib/urllib.py (original) +++ python/trunk/Lib/urllib.py Sat Feb 6 23:59:15 2010 @@ -234,7 +234,7 @@ hdrs = fp.info() fp.close() return url2pathname(splithost(url1)[1]), hdrs - except IOError, msg: + except IOError: pass fp = self.open(url, data) try: @@ -1277,7 +1277,7 @@ else: try: # is this a sufficient test for sequence-ness? - x = len(v) + len(v) except TypeError: # not a sequence v = quote_plus(str(v)) From python-checkins at python.org Sun Feb 7 00:02:29 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:02:29 -0000 Subject: [Python-checkins] r78038 - python/trunk/Lib/test/test_dl.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:02:29 2010 New Revision: 78038 Log: Add a missing import. Modified: python/trunk/Lib/test/test_dl.py Modified: python/trunk/Lib/test/test_dl.py ============================================================================== --- python/trunk/Lib/test/test_dl.py (original) +++ python/trunk/Lib/test/test_dl.py Sun Feb 7 00:02:29 2010 @@ -2,6 +2,7 @@ """Test dlmodule.c Roger E. Masse revised strategy by Barry Warsaw """ +import unittest from test.test_support import verbose, import_module dl = import_module('dl', deprecated=True) From python-checkins at python.org Sun Feb 7 00:06:24 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:06:24 -0000 Subject: [Python-checkins] r78039 - in python/trunk/Lib/test: test_gl.py test_imageop.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:06:24 2010 New Revision: 78039 Log: Add missing imports. Modified: python/trunk/Lib/test/test_gl.py python/trunk/Lib/test/test_imageop.py Modified: python/trunk/Lib/test/test_gl.py ============================================================================== --- python/trunk/Lib/test/test_gl.py (original) +++ python/trunk/Lib/test/test_gl.py Sun Feb 7 00:06:24 2010 @@ -3,6 +3,7 @@ taken mostly from the documentation. Roger E. Masse """ +import unittest from test.test_support import verbose, import_module import time gl = import_module('gl') Modified: python/trunk/Lib/test/test_imageop.py ============================================================================== --- python/trunk/Lib/test/test_imageop.py (original) +++ python/trunk/Lib/test/test_imageop.py Sun Feb 7 00:06:24 2010 @@ -180,6 +180,7 @@ """return a tuple consisting of image (in 'imgfile' format) width and height """ + import imgfile try: sizes = imgfile.getsizes(name) except imgfile.error: From python-checkins at python.org Sun Feb 7 00:08:01 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:08:01 -0000 Subject: [Python-checkins] r78040 - python/trunk/Lib/test/test_long.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:08:00 2010 New Revision: 78040 Log: Fix a few UnboundLocalErrors in test_long. Modified: python/trunk/Lib/test/test_long.py Modified: python/trunk/Lib/test/test_long.py ============================================================================== --- python/trunk/Lib/test/test_long.py (original) +++ python/trunk/Lib/test/test_long.py Sun Feb 7 00:08:00 2010 @@ -536,7 +536,7 @@ except OverflowError: self.fail("int(long(sys.maxint)) overflowed!") if not isinstance(x, int): - raise TestFailed("int(long(sys.maxint)) should have returned int") + self.fail("int(long(sys.maxint)) should have returned int") x = int(hugeneg_aslong) try: self.assertEqual(x, hugeneg, @@ -544,8 +544,7 @@ except OverflowError: self.fail("int(long(-sys.maxint-1)) overflowed!") if not isinstance(x, int): - raise TestFailed("int(long(-sys.maxint-1)) should have " - "returned int") + self.fail("int(long(-sys.maxint-1)) should have returned int") # but long -> int should overflow for hugepos+1 and hugeneg-1 x = hugepos_aslong + 1 try: @@ -803,7 +802,7 @@ self.d = d assert float(n) / float(d) == value else: - raise TypeError("can't deal with %r" % val) + raise TypeError("can't deal with %r" % value) def __cmp__(self, other): if not isinstance(other, Rat): From python-checkins at python.org Sun Feb 7 00:11:26 2010 From: python-checkins at python.org (mark.dickinson) Date: Sat, 06 Feb 2010 23:11:26 -0000 Subject: [Python-checkins] r78041 - python/trunk/Lib/test/test_math.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 00:11:25 2010 New Revision: 78041 Log: testCopysign was defined twice in test_math; combine the definitions Modified: python/trunk/Lib/test/test_math.py Modified: python/trunk/Lib/test/test_math.py ============================================================================== --- python/trunk/Lib/test/test_math.py (original) +++ python/trunk/Lib/test/test_math.py Sun Feb 7 00:11:25 2010 @@ -292,31 +292,37 @@ @requires_IEEE_754 def testCopysign(self): + self.assertEqual(math.copysign(1, 42), 1.0) + self.assertEqual(math.copysign(0., 42), 0.0) + self.assertEqual(math.copysign(1., -42), -1.0) + self.assertEqual(math.copysign(3, 0.), 3.0) + self.assertEqual(math.copysign(4., -0.), -4.0) + self.assertRaises(TypeError, math.copysign) # copysign should let us distinguish signs of zeros - self.assertEquals(copysign(1., 0.), 1.) - self.assertEquals(copysign(1., -0.), -1.) - self.assertEquals(copysign(INF, 0.), INF) - self.assertEquals(copysign(INF, -0.), NINF) - self.assertEquals(copysign(NINF, 0.), INF) - self.assertEquals(copysign(NINF, -0.), NINF) + self.assertEquals(math.copysign(1., 0.), 1.) + self.assertEquals(math.copysign(1., -0.), -1.) + self.assertEquals(math.copysign(INF, 0.), INF) + self.assertEquals(math.copysign(INF, -0.), NINF) + self.assertEquals(math.copysign(NINF, 0.), INF) + self.assertEquals(math.copysign(NINF, -0.), NINF) # and of infinities - self.assertEquals(copysign(1., INF), 1.) - self.assertEquals(copysign(1., NINF), -1.) - self.assertEquals(copysign(INF, INF), INF) - self.assertEquals(copysign(INF, NINF), NINF) - self.assertEquals(copysign(NINF, INF), INF) - self.assertEquals(copysign(NINF, NINF), NINF) - self.assertTrue(math.isnan(copysign(NAN, 1.))) - self.assertTrue(math.isnan(copysign(NAN, INF))) - self.assertTrue(math.isnan(copysign(NAN, NINF))) - self.assertTrue(math.isnan(copysign(NAN, NAN))) + self.assertEquals(math.copysign(1., INF), 1.) + self.assertEquals(math.copysign(1., NINF), -1.) + self.assertEquals(math.copysign(INF, INF), INF) + self.assertEquals(math.copysign(INF, NINF), NINF) + self.assertEquals(math.copysign(NINF, INF), INF) + self.assertEquals(math.copysign(NINF, NINF), NINF) + self.assertTrue(math.isnan(math.copysign(NAN, 1.))) + self.assertTrue(math.isnan(math.copysign(NAN, INF))) + self.assertTrue(math.isnan(math.copysign(NAN, NINF))) + self.assertTrue(math.isnan(math.copysign(NAN, NAN))) # copysign(INF, NAN) may be INF or it may be NINF, since # we don't know whether the sign bit of NAN is set on any # given platform. - self.assertTrue(math.isinf(copysign(INF, NAN))) + self.assertTrue(math.isinf(math.copysign(INF, NAN))) # similarly, copysign(2., NAN) could be 2. or -2. - self.assertEquals(abs(copysign(2., NAN)), 2.) + self.assertEquals(abs(math.copysign(2., NAN)), 2.) def testCos(self): self.assertRaises(TypeError, math.cos) @@ -878,13 +884,6 @@ self.assertEquals((), math.trunc(t)) self.assertRaises(TypeError, math.trunc, t, 0) - def testCopysign(self): - self.assertEqual(math.copysign(1, 42), 1.0) - self.assertEqual(math.copysign(0., 42), 0.0) - self.assertEqual(math.copysign(1., -42), -1.0) - self.assertEqual(math.copysign(3, 0.), 3.0) - self.assertEqual(math.copysign(4., -0.), -4.0) - def testIsnan(self): self.assertTrue(math.isnan(float("nan"))) self.assertTrue(math.isnan(float("inf")* 0.)) From python-checkins at python.org Sun Feb 7 00:12:12 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:12:12 -0000 Subject: [Python-checkins] r78042 - python/trunk/Lib/test/test_sysconfig.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:12:12 2010 New Revision: 78042 Log: Add missing import. Modified: python/trunk/Lib/test/test_sysconfig.py Modified: python/trunk/Lib/test/test_sysconfig.py ============================================================================== --- python/trunk/Lib/test/test_sysconfig.py (original) +++ python/trunk/Lib/test/test_sysconfig.py Sun Feb 7 00:12:12 2010 @@ -8,6 +8,7 @@ import sys import test import os +import shutil from copy import copy, deepcopy from test.test_support import run_unittest, TESTFN From python-checkins at python.org Sun Feb 7 00:12:19 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:12:19 -0000 Subject: [Python-checkins] r78043 - python/trunk/Lib/test/test_sgmllib.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:12:19 2010 New Revision: 78043 Log: Remove duplicate test method. Modified: python/trunk/Lib/test/test_sgmllib.py Modified: python/trunk/Lib/test/test_sgmllib.py ============================================================================== --- python/trunk/Lib/test/test_sgmllib.py (original) +++ python/trunk/Lib/test/test_sgmllib.py Sun Feb 7 00:12:19 2010 @@ -298,14 +298,6 @@ ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]), ]) - def test_illegal_declarations(self): - s = 'abcdef' - self.check_events(s, [ - ("data", "abc"), - ("unknown decl", 'spacer type="block" height="25"'), - ("data", "def"), - ]) - def test_weird_starttags(self): self.check_events("", [ ("starttag", "a", []), From python-checkins at python.org Sun Feb 7 00:14:50 2010 From: python-checkins at python.org (mark.dickinson) Date: Sat, 06 Feb 2010 23:14:50 -0000 Subject: [Python-checkins] r78044 - in python/branches/release26-maint: Lib/test/test_math.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 00:14:49 2010 New Revision: 78044 Log: Merged revisions 78041 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78041 | mark.dickinson | 2010-02-06 23:11:25 +0000 (Sat, 06 Feb 2010) | 1 line testCopysign was defined twice in test_math; combine the definitions ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_math.py Modified: python/branches/release26-maint/Lib/test/test_math.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_math.py (original) +++ python/branches/release26-maint/Lib/test/test_math.py Sun Feb 7 00:14:49 2010 @@ -209,31 +209,37 @@ if float.__getformat__("double").startswith("IEEE"): def testCopysign(self): + self.assertEqual(math.copysign(1, 42), 1.0) + self.assertEqual(math.copysign(0., 42), 0.0) + self.assertEqual(math.copysign(1., -42), -1.0) + self.assertEqual(math.copysign(3, 0.), 3.0) + self.assertEqual(math.copysign(4., -0.), -4.0) + self.assertRaises(TypeError, math.copysign) # copysign should let us distinguish signs of zeros - self.assertEquals(copysign(1., 0.), 1.) - self.assertEquals(copysign(1., -0.), -1.) - self.assertEquals(copysign(INF, 0.), INF) - self.assertEquals(copysign(INF, -0.), NINF) - self.assertEquals(copysign(NINF, 0.), INF) - self.assertEquals(copysign(NINF, -0.), NINF) + self.assertEquals(math.copysign(1., 0.), 1.) + self.assertEquals(math.copysign(1., -0.), -1.) + self.assertEquals(math.copysign(INF, 0.), INF) + self.assertEquals(math.copysign(INF, -0.), NINF) + self.assertEquals(math.copysign(NINF, 0.), INF) + self.assertEquals(math.copysign(NINF, -0.), NINF) # and of infinities - self.assertEquals(copysign(1., INF), 1.) - self.assertEquals(copysign(1., NINF), -1.) - self.assertEquals(copysign(INF, INF), INF) - self.assertEquals(copysign(INF, NINF), NINF) - self.assertEquals(copysign(NINF, INF), INF) - self.assertEquals(copysign(NINF, NINF), NINF) - self.assert_(math.isnan(copysign(NAN, 1.))) - self.assert_(math.isnan(copysign(NAN, INF))) - self.assert_(math.isnan(copysign(NAN, NINF))) - self.assert_(math.isnan(copysign(NAN, NAN))) + self.assertEquals(math.copysign(1., INF), 1.) + self.assertEquals(math.copysign(1., NINF), -1.) + self.assertEquals(math.copysign(INF, INF), INF) + self.assertEquals(math.copysign(INF, NINF), NINF) + self.assertEquals(math.copysign(NINF, INF), INF) + self.assertEquals(math.copysign(NINF, NINF), NINF) + self.assertTrue(math.isnan(math.copysign(NAN, 1.))) + self.assertTrue(math.isnan(math.copysign(NAN, INF))) + self.assertTrue(math.isnan(math.copysign(NAN, NINF))) + self.assertTrue(math.isnan(math.copysign(NAN, NAN))) # copysign(INF, NAN) may be INF or it may be NINF, since # we don't know whether the sign bit of NAN is set on any # given platform. - self.assert_(math.isinf(copysign(INF, NAN))) + self.assertTrue(math.isinf(math.copysign(INF, NAN))) # similarly, copysign(2., NAN) could be 2. or -2. - self.assertEquals(abs(copysign(2., NAN)), 2.) + self.assertEquals(abs(math.copysign(2., NAN)), 2.) def testCos(self): self.assertRaises(TypeError, math.cos) @@ -800,13 +806,6 @@ self.assertEquals((), math.trunc(t)) self.assertRaises(TypeError, math.trunc, t, 0) - def testCopysign(self): - self.assertEqual(math.copysign(1, 42), 1.0) - self.assertEqual(math.copysign(0., 42), 0.0) - self.assertEqual(math.copysign(1., -42), -1.0) - self.assertEqual(math.copysign(3, 0.), 3.0) - self.assertEqual(math.copysign(4., -0.), -4.0) - def testIsnan(self): self.assert_(math.isnan(float("nan"))) self.assert_(math.isnan(float("inf")* 0.)) From python-checkins at python.org Sun Feb 7 00:16:50 2010 From: python-checkins at python.org (mark.dickinson) Date: Sat, 06 Feb 2010 23:16:50 -0000 Subject: [Python-checkins] r78045 - in python/branches/py3k: Lib/test/test_math.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 00:16:50 2010 New Revision: 78045 Log: Merged revisions 78041 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78041 | mark.dickinson | 2010-02-06 23:11:25 +0000 (Sat, 06 Feb 2010) | 1 line testCopysign was defined twice in test_math; combine the definitions ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_math.py Modified: python/branches/py3k/Lib/test/test_math.py ============================================================================== --- python/branches/py3k/Lib/test/test_math.py (original) +++ python/branches/py3k/Lib/test/test_math.py Sun Feb 7 00:16:50 2010 @@ -289,31 +289,37 @@ @requires_IEEE_754 def testCopysign(self): + self.assertEqual(math.copysign(1, 42), 1.0) + self.assertEqual(math.copysign(0., 42), 0.0) + self.assertEqual(math.copysign(1., -42), -1.0) + self.assertEqual(math.copysign(3, 0.), 3.0) + self.assertEqual(math.copysign(4., -0.), -4.0) + self.assertRaises(TypeError, math.copysign) # copysign should let us distinguish signs of zeros - self.assertEquals(copysign(1., 0.), 1.) - self.assertEquals(copysign(1., -0.), -1.) - self.assertEquals(copysign(INF, 0.), INF) - self.assertEquals(copysign(INF, -0.), NINF) - self.assertEquals(copysign(NINF, 0.), INF) - self.assertEquals(copysign(NINF, -0.), NINF) + self.assertEquals(math.copysign(1., 0.), 1.) + self.assertEquals(math.copysign(1., -0.), -1.) + self.assertEquals(math.copysign(INF, 0.), INF) + self.assertEquals(math.copysign(INF, -0.), NINF) + self.assertEquals(math.copysign(NINF, 0.), INF) + self.assertEquals(math.copysign(NINF, -0.), NINF) # and of infinities - self.assertEquals(copysign(1., INF), 1.) - self.assertEquals(copysign(1., NINF), -1.) - self.assertEquals(copysign(INF, INF), INF) - self.assertEquals(copysign(INF, NINF), NINF) - self.assertEquals(copysign(NINF, INF), INF) - self.assertEquals(copysign(NINF, NINF), NINF) - self.assertTrue(math.isnan(copysign(NAN, 1.))) - self.assertTrue(math.isnan(copysign(NAN, INF))) - self.assertTrue(math.isnan(copysign(NAN, NINF))) - self.assertTrue(math.isnan(copysign(NAN, NAN))) + self.assertEquals(math.copysign(1., INF), 1.) + self.assertEquals(math.copysign(1., NINF), -1.) + self.assertEquals(math.copysign(INF, INF), INF) + self.assertEquals(math.copysign(INF, NINF), NINF) + self.assertEquals(math.copysign(NINF, INF), INF) + self.assertEquals(math.copysign(NINF, NINF), NINF) + self.assertTrue(math.isnan(math.copysign(NAN, 1.))) + self.assertTrue(math.isnan(math.copysign(NAN, INF))) + self.assertTrue(math.isnan(math.copysign(NAN, NINF))) + self.assertTrue(math.isnan(math.copysign(NAN, NAN))) # copysign(INF, NAN) may be INF or it may be NINF, since # we don't know whether the sign bit of NAN is set on any # given platform. - self.assertTrue(math.isinf(copysign(INF, NAN))) + self.assertTrue(math.isinf(math.copysign(INF, NAN))) # similarly, copysign(2., NAN) could be 2. or -2. - self.assertEquals(abs(copysign(2., NAN)), 2.) + self.assertEquals(abs(math.copysign(2., NAN)), 2.) def testCos(self): self.assertRaises(TypeError, math.cos) @@ -873,13 +879,6 @@ #self.assertEquals((), math.trunc(t)) #self.assertRaises(TypeError, math.trunc, t, 0) - def testCopysign(self): - self.assertEqual(math.copysign(1, 42), 1.0) - self.assertEqual(math.copysign(0., 42), 0.0) - self.assertEqual(math.copysign(1., -42), -1.0) - self.assertEqual(math.copysign(3, 0.), 3.0) - self.assertEqual(math.copysign(4., -0.), -4.0) - def testIsnan(self): self.assertTrue(math.isnan(float("nan"))) self.assertTrue(math.isnan(float("inf")* 0.)) From python-checkins at python.org Sun Feb 7 00:18:00 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:18:00 -0000 Subject: [Python-checkins] r78046 - in python/trunk/Lib/test: test_richcmp.py test_tempfile.py test_threaded_import.py test_zipimport.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:18:00 2010 New Revision: 78046 Log: Fix various missing import/unbound name errors. Modified: python/trunk/Lib/test/test_richcmp.py python/trunk/Lib/test/test_tempfile.py python/trunk/Lib/test/test_threaded_import.py python/trunk/Lib/test/test_zipimport.py Modified: python/trunk/Lib/test/test_richcmp.py ============================================================================== --- python/trunk/Lib/test/test_richcmp.py (original) +++ python/trunk/Lib/test/test_richcmp.py Sun Feb 7 00:18:00 2010 @@ -192,13 +192,13 @@ def test_misbehavin(self): class Misb: - def __lt__(self, other): return 0 - def __gt__(self, other): return 0 - def __eq__(self, other): return 0 - def __le__(self, other): raise TestFailed, "This shouldn't happen" - def __ge__(self, other): raise TestFailed, "This shouldn't happen" - def __ne__(self, other): raise TestFailed, "This shouldn't happen" - def __cmp__(self, other): raise RuntimeError, "expected" + def __lt__(self_, other): return 0 + def __gt__(self_, other): return 0 + def __eq__(self_, other): return 0 + def __le__(self_, other): self.fail("This shouldn't happen") + def __ge__(self_, other): self.fail("This shouldn't happen") + def __ne__(self_, other): self.fail("This shouldn't happen") + def __cmp__(self_, other): raise RuntimeError, "expected" a = Misb() b = Misb() self.assertEqual(a Author: mark.dickinson Date: Sun Feb 7 00:18:37 2010 New Revision: 78047 Log: Merged revisions 78045 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r78045 | mark.dickinson | 2010-02-06 23:16:50 +0000 (Sat, 06 Feb 2010) | 9 lines Merged revisions 78041 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78041 | mark.dickinson | 2010-02-06 23:11:25 +0000 (Sat, 06 Feb 2010) | 1 line testCopysign was defined twice in test_math; combine the definitions ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_math.py Modified: python/branches/release31-maint/Lib/test/test_math.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_math.py (original) +++ python/branches/release31-maint/Lib/test/test_math.py Sun Feb 7 00:18:37 2010 @@ -211,31 +211,37 @@ if float.__getformat__("double").startswith("IEEE"): def testCopysign(self): + self.assertEqual(math.copysign(1, 42), 1.0) + self.assertEqual(math.copysign(0., 42), 0.0) + self.assertEqual(math.copysign(1., -42), -1.0) + self.assertEqual(math.copysign(3, 0.), 3.0) + self.assertEqual(math.copysign(4., -0.), -4.0) + self.assertRaises(TypeError, math.copysign) # copysign should let us distinguish signs of zeros - self.assertEquals(copysign(1., 0.), 1.) - self.assertEquals(copysign(1., -0.), -1.) - self.assertEquals(copysign(INF, 0.), INF) - self.assertEquals(copysign(INF, -0.), NINF) - self.assertEquals(copysign(NINF, 0.), INF) - self.assertEquals(copysign(NINF, -0.), NINF) + self.assertEquals(math.copysign(1., 0.), 1.) + self.assertEquals(math.copysign(1., -0.), -1.) + self.assertEquals(math.copysign(INF, 0.), INF) + self.assertEquals(math.copysign(INF, -0.), NINF) + self.assertEquals(math.copysign(NINF, 0.), INF) + self.assertEquals(math.copysign(NINF, -0.), NINF) # and of infinities - self.assertEquals(copysign(1., INF), 1.) - self.assertEquals(copysign(1., NINF), -1.) - self.assertEquals(copysign(INF, INF), INF) - self.assertEquals(copysign(INF, NINF), NINF) - self.assertEquals(copysign(NINF, INF), INF) - self.assertEquals(copysign(NINF, NINF), NINF) - self.assertTrue(math.isnan(copysign(NAN, 1.))) - self.assertTrue(math.isnan(copysign(NAN, INF))) - self.assertTrue(math.isnan(copysign(NAN, NINF))) - self.assertTrue(math.isnan(copysign(NAN, NAN))) + self.assertEquals(math.copysign(1., INF), 1.) + self.assertEquals(math.copysign(1., NINF), -1.) + self.assertEquals(math.copysign(INF, INF), INF) + self.assertEquals(math.copysign(INF, NINF), NINF) + self.assertEquals(math.copysign(NINF, INF), INF) + self.assertEquals(math.copysign(NINF, NINF), NINF) + self.assertTrue(math.isnan(math.copysign(NAN, 1.))) + self.assertTrue(math.isnan(math.copysign(NAN, INF))) + self.assertTrue(math.isnan(math.copysign(NAN, NINF))) + self.assertTrue(math.isnan(math.copysign(NAN, NAN))) # copysign(INF, NAN) may be INF or it may be NINF, since # we don't know whether the sign bit of NAN is set on any # given platform. - self.assertTrue(math.isinf(copysign(INF, NAN))) + self.assertTrue(math.isinf(math.copysign(INF, NAN))) # similarly, copysign(2., NAN) could be 2. or -2. - self.assertEquals(abs(copysign(2., NAN)), 2.) + self.assertEquals(abs(math.copysign(2., NAN)), 2.) def testCos(self): self.assertRaises(TypeError, math.cos) @@ -796,13 +802,6 @@ #self.assertEquals((), math.trunc(t)) #self.assertRaises(TypeError, math.trunc, t, 0) - def testCopysign(self): - self.assertEqual(math.copysign(1, 42), 1.0) - self.assertEqual(math.copysign(0., 42), 0.0) - self.assertEqual(math.copysign(1., -42), -1.0) - self.assertEqual(math.copysign(3, 0.), 3.0) - self.assertEqual(math.copysign(4., -0.), -4.0) - def testIsnan(self): self.assertTrue(math.isnan(float("nan"))) self.assertTrue(math.isnan(float("inf")* 0.)) From python-checkins at python.org Sun Feb 7 00:23:45 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:23:45 -0000 Subject: [Python-checkins] r78048 - python/trunk/Lib/test/test_ssl.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:23:45 2010 New Revision: 78048 Log: We heard you like test failures so we put unbound locals in your test so that you can fail while you fail. Modified: python/trunk/Lib/test/test_ssl.py Modified: python/trunk/Lib/test/test_ssl.py ============================================================================== --- python/trunk/Lib/test/test_ssl.py (original) +++ python/trunk/Lib/test/test_ssl.py Sun Feb 7 00:23:45 2010 @@ -1070,9 +1070,9 @@ ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) except ssl.SSLError as x: - raise support.TestFailed("Unexpected SSL error: " + str(x)) + self.fail("Unexpected SSL error: " + str(x)) except Exception as x: - raise support.TestFailed("Unexpected exception: " + str(x)) + self.fail("Unexpected exception: " + str(x)) else: # helper methods for standardising recv* method signatures def _recv_into(): @@ -1106,7 +1106,7 @@ outdata = s.read() outdata = outdata.decode('ASCII', 'strict') if outdata != indata.lower(): - raise support.TestFailed( + self.fail( "While sending with <<%s>> bad data " "<<%r>> (%d) received; " "expected <<%r>> (%d)\n" % ( @@ -1116,12 +1116,12 @@ ) except ValueError as e: if expect_success: - raise support.TestFailed( + self.fail( "Failed to send with method <<%s>>; " "expected to succeed.\n" % (meth_name,) ) if not str(e).startswith(meth_name): - raise support.TestFailed( + self.fail( "Method <<%s>> failed with unexpected " "exception message: %s\n" % ( meth_name, e @@ -1135,7 +1135,7 @@ outdata = recv_meth(*args) outdata = outdata.decode('ASCII', 'strict') if outdata != indata.lower(): - raise support.TestFailed( + self.fail( "While receiving with <<%s>> bad data " "<<%r>> (%d) received; " "expected <<%r>> (%d)\n" % ( @@ -1145,12 +1145,12 @@ ) except ValueError as e: if expect_success: - raise support.TestFailed( + self.fail( "Failed to receive with method <<%s>>; " "expected to succeed.\n" % (meth_name,) ) if not str(e).startswith(meth_name): - raise support.TestFailed( + self.fail( "Method <<%s>> failed with unexpected " "exception message: %s\n" % ( meth_name, e From python-checkins at python.org Sun Feb 7 00:33:33 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:33:33 -0000 Subject: [Python-checkins] r78049 - python/trunk/Lib/test/test_multiprocessing.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:33:33 2010 New Revision: 78049 Log: Fix import/access for some identifiers. _TestSharedCTypes does not seem to be executed? Modified: python/trunk/Lib/test/test_multiprocessing.py Modified: python/trunk/Lib/test/test_multiprocessing.py ============================================================================== --- python/trunk/Lib/test/test_multiprocessing.py (original) +++ python/trunk/Lib/test/test_multiprocessing.py Sun Feb 7 00:33:33 2010 @@ -1591,10 +1591,10 @@ return x = Value('i', 7, lock=lock) - y = Value(ctypes.c_double, 1.0/3.0, lock=lock) + y = Value(c_double, 1.0/3.0, lock=lock) foo = Value(_Foo, 3, 2, lock=lock) - arr = Array('d', range(10), lock=lock) - string = Array('c', 20, lock=lock) + arr = self.Array('d', range(10), lock=lock) + string = self.Array('c', 20, lock=lock) string.value = 'hello' p = self.Process(target=self._double, args=(x, y, foo, arr, string)) From python-checkins at python.org Sun Feb 7 00:34:10 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:34:10 -0000 Subject: [Python-checkins] r78050 - in python/trunk/Lib/test: test_cfgparser.py test_minidom.py test_platform.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:34:10 2010 New Revision: 78050 Log: Fix more unbound locals in code paths that do not seem to be used. Modified: python/trunk/Lib/test/test_cfgparser.py python/trunk/Lib/test/test_minidom.py python/trunk/Lib/test/test_platform.py Modified: python/trunk/Lib/test/test_cfgparser.py ============================================================================== --- python/trunk/Lib/test/test_cfgparser.py (original) +++ python/trunk/Lib/test/test_cfgparser.py Sun Feb 7 00:34:10 2010 @@ -17,8 +17,9 @@ return result def values(self): + # XXX never used? result = self.items() - return [i[1] for i in values] + return [i[1] for i in result] def iteritems(self): return iter(self.items()) def iterkeys(self): return iter(self.keys()) Modified: python/trunk/Lib/test/test_minidom.py ============================================================================== --- python/trunk/Lib/test/test_minidom.py (original) +++ python/trunk/Lib/test/test_minidom.py Sun Feb 7 00:34:10 2010 @@ -1456,12 +1456,13 @@ self.confirm(len(n1.entities) == len(n2.entities) and len(n1.notations) == len(n2.notations)) for i in range(len(n1.notations)): + # XXX this loop body doesn't seem to be executed? no1 = n1.notations.item(i) no2 = n1.notations.item(i) self.confirm(no1.name == no2.name and no1.publicId == no2.publicId and no1.systemId == no2.systemId) - statck.append((no1, no2)) + stack.append((no1, no2)) for i in range(len(n1.entities)): e1 = n1.entities.item(i) e2 = n2.entities.item(i) Modified: python/trunk/Lib/test/test_platform.py ============================================================================== --- python/trunk/Lib/test/test_platform.py (original) +++ python/trunk/Lib/test/test_platform.py Sun Feb 7 00:34:10 2010 @@ -182,8 +182,10 @@ if os.path.isdir(sys.executable) and \ os.path.exists(sys.executable+'.exe'): # Cygwin horror - executable = executable + '.exe' - res = platform.libc_ver(sys.executable) + executable = sys.executable + '.exe' + else: + executable = sys.executable + res = platform.libc_ver(executable) def test_parse_release_file(self): From python-checkins at python.org Sun Feb 7 00:53:52 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:53:52 -0000 Subject: [Python-checkins] r78051 - in python/trunk/Lib/distutils/tests: test_bdist.py test_bdist_dumb.py test_bdist_msi.py test_bdist_rpm.py test_bdist_wininst.py test_cmd.py test_cygwinccompiler.py test_emxccompiler.py test_sysconfig.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:53:52 2010 New Revision: 78051 Log: Add missing import when running these tests standalone. Modified: python/trunk/Lib/distutils/tests/test_bdist.py python/trunk/Lib/distutils/tests/test_bdist_dumb.py python/trunk/Lib/distutils/tests/test_bdist_msi.py python/trunk/Lib/distutils/tests/test_bdist_rpm.py python/trunk/Lib/distutils/tests/test_bdist_wininst.py python/trunk/Lib/distutils/tests/test_cmd.py python/trunk/Lib/distutils/tests/test_cygwinccompiler.py python/trunk/Lib/distutils/tests/test_emxccompiler.py python/trunk/Lib/distutils/tests/test_sysconfig.py Modified: python/trunk/Lib/distutils/tests/test_bdist.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_bdist.py (original) +++ python/trunk/Lib/distutils/tests/test_bdist.py Sun Feb 7 00:53:52 2010 @@ -5,6 +5,8 @@ import tempfile import shutil +from test.test_support import run_unittest + from distutils.core import Distribution from distutils.command.bdist import bdist from distutils.tests import support @@ -40,4 +42,4 @@ return unittest.makeSuite(BuildTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_bdist_dumb.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_bdist_dumb.py (original) +++ python/trunk/Lib/distutils/tests/test_bdist_dumb.py Sun Feb 7 00:53:52 2010 @@ -11,6 +11,8 @@ except ImportError: zlib = None +from test.test_support import run_unittest + from distutils.core import Distribution from distutils.command.bdist_dumb import bdist_dumb from distutils.tests import support @@ -100,4 +102,4 @@ return unittest.makeSuite(BuildDumbTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_bdist_msi.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_bdist_msi.py (original) +++ python/trunk/Lib/distutils/tests/test_bdist_msi.py Sun Feb 7 00:53:52 2010 @@ -2,6 +2,8 @@ import unittest import sys +from test.test_support import run_unittest + from distutils.tests import support @unittest.skipUnless(sys.platform=="win32", "These tests are only for win32") @@ -20,4 +22,4 @@ return unittest.makeSuite(BDistMSITestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_bdist_rpm.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_bdist_rpm.py (original) +++ python/trunk/Lib/distutils/tests/test_bdist_rpm.py Sun Feb 7 00:53:52 2010 @@ -6,6 +6,8 @@ import tempfile import shutil +from test.test_support import run_unittest + from distutils.core import Distribution from distutils.command.bdist_rpm import bdist_rpm from distutils.tests import support @@ -122,4 +124,4 @@ return unittest.makeSuite(BuildRpmTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_bdist_wininst.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_bdist_wininst.py (original) +++ python/trunk/Lib/distutils/tests/test_bdist_wininst.py Sun Feb 7 00:53:52 2010 @@ -1,6 +1,8 @@ """Tests for distutils.command.bdist_wininst.""" import unittest +from test.test_support import run_unittest + from distutils.command.bdist_wininst import bdist_wininst from distutils.tests import support @@ -27,4 +29,4 @@ return unittest.makeSuite(BuildWinInstTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_cmd.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_cmd.py (original) +++ python/trunk/Lib/distutils/tests/test_cmd.py Sun Feb 7 00:53:52 2010 @@ -1,7 +1,7 @@ """Tests for distutils.cmd.""" import unittest import os -from test.test_support import captured_stdout +from test.test_support import captured_stdout, run_unittest from distutils.cmd import Command from distutils.dist import Distribution @@ -124,4 +124,4 @@ return unittest.makeSuite(CommandTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_cygwinccompiler.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_cygwinccompiler.py (original) +++ python/trunk/Lib/distutils/tests/test_cygwinccompiler.py Sun Feb 7 00:53:52 2010 @@ -5,7 +5,7 @@ import warnings import sysconfig -from test.test_support import check_warnings +from test.test_support import check_warnings, run_unittest from test.test_support import captured_stdout from distutils import cygwinccompiler @@ -108,4 +108,4 @@ return unittest.makeSuite(CygwinCCompilerTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_emxccompiler.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_emxccompiler.py (original) +++ python/trunk/Lib/distutils/tests/test_emxccompiler.py Sun Feb 7 00:53:52 2010 @@ -4,7 +4,7 @@ import os import warnings -from test.test_support import check_warnings +from test.test_support import check_warnings, run_unittest from test.test_support import captured_stdout from distutils.emxccompiler import get_versions @@ -30,4 +30,4 @@ return unittest.makeSuite(EmxCCompilerTestCase) if __name__ == '__main__': - test_support.run_unittest(test_suite()) + run_unittest(test_suite()) Modified: python/trunk/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_sysconfig.py (original) +++ python/trunk/Lib/distutils/tests/test_sysconfig.py Sun Feb 7 00:53:52 2010 @@ -2,6 +2,7 @@ import os import test import unittest +import shutil from distutils import sysconfig from distutils.tests import support From python-checkins at python.org Sun Feb 7 00:54:04 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:54:04 -0000 Subject: [Python-checkins] r78052 - python/trunk/Lib/email/test/test_email_torture.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:54:04 2010 New Revision: 78052 Log: Add missing import when running these tests standalone. Modified: python/trunk/Lib/email/test/test_email_torture.py Modified: python/trunk/Lib/email/test/test_email_torture.py ============================================================================== --- python/trunk/Lib/email/test/test_email_torture.py (original) +++ python/trunk/Lib/email/test/test_email_torture.py Sun Feb 7 00:54:04 2010 @@ -13,7 +13,7 @@ from types import ListType from email.test.test_email import TestEmailBase -from test.test_support import TestSkipped +from test.test_support import TestSkipped, run_unittest import email from email import __file__ as testfile @@ -128,7 +128,7 @@ def test_main(): for testclass in _testclasses(): - test_support.run_unittest(testclass) + run_unittest(testclass) From python-checkins at python.org Sun Feb 7 00:54:43 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:54:43 -0000 Subject: [Python-checkins] r78053 - in python/trunk/Lib/plat-mac: Carbon/MediaDescr.py bundlebuilder.py macostools.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:54:43 2010 New Revision: 78053 Log: Fix some name errors in Mac modules. Modified: python/trunk/Lib/plat-mac/Carbon/MediaDescr.py python/trunk/Lib/plat-mac/bundlebuilder.py python/trunk/Lib/plat-mac/macostools.py Modified: python/trunk/Lib/plat-mac/Carbon/MediaDescr.py ============================================================================== --- python/trunk/Lib/plat-mac/Carbon/MediaDescr.py (original) +++ python/trunk/Lib/plat-mac/Carbon/MediaDescr.py Sun Feb 7 00:54:43 2010 @@ -15,7 +15,7 @@ data = data[:self.size] values = struct.unpack(self.fmt, data) if len(values) != len(self.names): - raise Error, ('Format length does not match number of names', descr) + raise Error, ('Format length does not match number of names') rv = {} for i in range(len(values)): name = self.names[i] @@ -26,7 +26,7 @@ rv[name] = value return rv - def encode(dict): + def encode(self, dict): list = [self.fmt] for name in self.names: if type(name) == type(()): Modified: python/trunk/Lib/plat-mac/bundlebuilder.py ============================================================================== --- python/trunk/Lib/plat-mac/bundlebuilder.py (original) +++ python/trunk/Lib/plat-mac/bundlebuilder.py Sun Feb 7 00:54:43 2010 @@ -432,7 +432,7 @@ pass elif self.mainprogram is not None: self.name = os.path.splitext(os.path.basename(self.mainprogram))[0] - elif executable is not None: + elif self.executable is not None: self.name = os.path.splitext(os.path.basename(self.executable))[0] if self.name[-4:] != ".app": self.name += ".app" Modified: python/trunk/Lib/plat-mac/macostools.py ============================================================================== --- python/trunk/Lib/plat-mac/macostools.py (original) +++ python/trunk/Lib/plat-mac/macostools.py Sun Feb 7 00:54:43 2010 @@ -10,6 +10,7 @@ from Carbon import Res from Carbon import File, Files import os +import errno import MacOS try: openrf = MacOS.openrf From python-checkins at python.org Sun Feb 7 00:58:26 2010 From: python-checkins at python.org (georg.brandl) Date: Sat, 06 Feb 2010 23:58:26 -0000 Subject: [Python-checkins] r78054 - python/trunk/Lib/test/test_docxmlrpc.py Message-ID: Author: georg.brandl Date: Sun Feb 7 00:58:25 2010 New Revision: 78054 Log: Add missing import. Modified: python/trunk/Lib/test/test_docxmlrpc.py Modified: python/trunk/Lib/test/test_docxmlrpc.py ============================================================================== --- python/trunk/Lib/test/test_docxmlrpc.py (original) +++ python/trunk/Lib/test/test_docxmlrpc.py Sun Feb 7 00:58:25 2010 @@ -3,6 +3,7 @@ from test import test_support import threading import time +import socket import unittest import xmlrpclib From solipsis at pitrou.net Sun Feb 7 01:05:20 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 7 Feb 2010 01:05:20 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r78025): sum=0 Message-ID: <20100207000520.A17711770D@ns6635.ovh.net> py3k results for svn r78025 (hg cset c3590e6b23ae) -------------------------------------------------- test_logging leaked [230, -230, 0] references, sum=0 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogp7QS1V', '-x', 'test_httpservers'] From python-checkins at python.org Sun Feb 7 02:37:08 2010 From: python-checkins at python.org (vinay.sajip) Date: Sun, 07 Feb 2010 01:37:08 -0000 Subject: [Python-checkins] r78055 - in python/trunk: Lib/logging/__init__.py Lib/test/test_logging.py Misc/NEWS Message-ID: Author: vinay.sajip Date: Sun Feb 7 02:37:08 2010 New Revision: 78055 Log: Issue #7868: logging: added loggerClass attribute to Manager. Modified: python/trunk/Lib/logging/__init__.py python/trunk/Lib/test/test_logging.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/logging/__init__.py ============================================================================== --- python/trunk/Lib/logging/__init__.py (original) +++ python/trunk/Lib/logging/__init__.py Sun Feb 7 02:37:08 2010 @@ -1,4 +1,4 @@ -# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -46,8 +46,8 @@ __author__ = "Vinay Sajip " __status__ = "production" -__version__ = "0.5.1.1" -__date__ = "25 November 2009" +__version__ = "0.5.1.2" +__date__ = "07 February 2010" #--------------------------------------------------------------------------- # Miscellaneous module data @@ -962,6 +962,7 @@ self.disable = 0 self.emittedNoHandlerWarning = 0 self.loggerDict = {} + self.loggerClass = None def getLogger(self, name): """ @@ -981,13 +982,13 @@ rv = self.loggerDict[name] if isinstance(rv, PlaceHolder): ph = rv - rv = _loggerClass(name) + rv = (self.loggerClass or _loggerClass)(name) rv.manager = self self.loggerDict[name] = rv self._fixupChildren(ph, rv) self._fixupParents(rv) else: - rv = _loggerClass(name) + rv = (self.loggerClass or _loggerClass)(name) rv.manager = self self.loggerDict[name] = rv self._fixupParents(rv) @@ -995,6 +996,16 @@ _releaseLock() return rv + def setLoggerClass(self, klass): + """ + Set the class to be used when instantiating a logger with this Manager. + """ + if klass != Logger: + if not issubclass(klass, Logger): + raise TypeError("logger not derived from logging.Logger: " + + klass.__name__) + self.loggerClass = klass + def _fixupParents(self, alogger): """ Ensure that there are either loggers or placeholders all the way Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Sun Feb 7 02:37:08 2010 @@ -1593,7 +1593,6 @@ logging.config.stopListening() t.join(2.0) - #@unittest.skip("See issue #7857") def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) @@ -1613,7 +1612,6 @@ ('ERROR', '4'), ], stream=output) - #@unittest.skip("See issue #7857") def test_listen_config_1_ok(self): with captured_stdout() as output: self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) @@ -1629,15 +1627,34 @@ self.assert_log_lines([]) +class ManagerTest(BaseTest): + def test_manager_loggerclass(self): + logged = [] + + class MyLogger(logging.Logger): + def _log(self, level, msg, args, exc_info=None, extra=None): + logged.append(msg) + + man = logging.Manager(None) + self.assertRaises(TypeError, man.setLoggerClass, int) + man.setLoggerClass(MyLogger) + logger = man.getLogger('test') + print >> open('/tmp/tmp.txt', 'w'), type(logger) + logger.warning('should appear in logged') + logging.warning('should not appear in logged') + + self.assertEqual(logged, ['should appear in logged']) + + # Set the locale to the platform-dependent default. I have no idea # why the test does this, but in any case we save the current locale # first and restore it at the end. @run_with_locale('LC_ALL', '') def test_main(): run_unittest(BuiltinLevelsTest, BasicFilterTest, - CustomLevelsAndFiltersTest, MemoryHandlerTest, - ConfigFileTest, SocketHandlerTest, MemoryTest, - EncodingTest, WarningsTest, ConfigDictTest) + CustomLevelsAndFiltersTest, MemoryHandlerTest, + ConfigFileTest, SocketHandlerTest, MemoryTest, + EncodingTest, WarningsTest, ConfigDictTest, ManagerTest) if __name__ == "__main__": test_main() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Feb 7 02:37:08 2010 @@ -75,6 +75,8 @@ Library ------- +- Issue #7868: logging: added loggerClass attribute to Manager. + - Issue #7851: logging: clarification on logging configuration files. - Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is From python-checkins at python.org Sun Feb 7 12:29:31 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:29:31 -0000 Subject: [Python-checkins] r78056 - python/trunk/Lib/platform.py Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:29:31 2010 New Revision: 78056 Log: Remove call to gestalt('sysu') from platform.py. This gestalt call is not available on OSX an appearently causes problems for some users. Fixes issue 7812 Modified: python/trunk/Lib/platform.py Modified: python/trunk/Lib/platform.py ============================================================================== --- python/trunk/Lib/platform.py (original) +++ python/trunk/Lib/platform.py Sun Feb 7 12:29:31 2010 @@ -733,7 +733,7 @@ except ImportError: return release,versioninfo,machine # Get the infos - sysv,sysu,sysa = _mac_ver_lookup(('sysv','sysu','sysa')) + sysv,sysa = _mac_ver_lookup(('sysv','sysa')) # Decode the infos if sysv: major = (sysv & 0xFF00) >> 8 @@ -751,24 +751,6 @@ else: release = '%s.%i.%i' % (_bcd2str(major),minor,patch) - if sysu: - # NOTE: this block is left as documentation of the - # intention of this function, the 'sysu' gestalt is no - # longer available and there are no alternatives. - major = int((sysu & 0xFF000000L) >> 24) - minor = (sysu & 0x00F00000) >> 20 - bugfix = (sysu & 0x000F0000) >> 16 - stage = (sysu & 0x0000FF00) >> 8 - nonrel = (sysu & 0x000000FF) - version = '%s.%i.%i' % (_bcd2str(major),minor,bugfix) - nonrel = _bcd2str(nonrel) - stage = {0x20:'development', - 0x40:'alpha', - 0x60:'beta', - 0x80:'final'}.get(stage,'') - versioninfo = (version,stage,nonrel) - - if sysa: machine = {0x1: '68k', 0x2: 'PowerPC', From python-checkins at python.org Sun Feb 7 12:30:54 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:30:54 -0000 Subject: [Python-checkins] r78057 - in python/branches/release26-maint: Lib/platform.py Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:30:54 2010 New Revision: 78057 Log: Merged revisions 78056 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78056 | ronald.oussoren | 2010-02-07 12:29:31 +0100 (Sun, 07 Feb 2010) | 5 lines Remove call to gestalt('sysu') from platform.py. This gestalt call is not available on OSX an appearently causes problems for some users. Fixes issue 7812 ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/platform.py Modified: python/branches/release26-maint/Lib/platform.py ============================================================================== --- python/branches/release26-maint/Lib/platform.py (original) +++ python/branches/release26-maint/Lib/platform.py Sun Feb 7 12:30:54 2010 @@ -720,7 +720,7 @@ except ImportError: return release,versioninfo,machine # Get the infos - sysv,sysu,sysa = _mac_ver_lookup(('sysv','sysu','sysa')) + sysv,sysa = _mac_ver_lookup(('sysv','sysa')) # Decode the infos if sysv: major = (sysv & 0xFF00) >> 8 @@ -738,24 +738,6 @@ else: release = '%s.%i.%i' % (_bcd2str(major),minor,patch) - if sysu: - # NOTE: this block is left as documentation of the - # intention of this function, the 'sysu' gestalt is no - # longer available and there are no alternatives. - major = int((sysu & 0xFF000000L) >> 24) - minor = (sysu & 0x00F00000) >> 20 - bugfix = (sysu & 0x000F0000) >> 16 - stage = (sysu & 0x0000FF00) >> 8 - nonrel = (sysu & 0x000000FF) - version = '%s.%i.%i' % (_bcd2str(major),minor,bugfix) - nonrel = _bcd2str(nonrel) - stage = {0x20:'development', - 0x40:'alpha', - 0x60:'beta', - 0x80:'final'}.get(stage,'') - versioninfo = (version,stage,nonrel) - - if sysa: machine = {0x1: '68k', 0x2: 'PowerPC', From python-checkins at python.org Sun Feb 7 12:33:34 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:33:34 -0000 Subject: [Python-checkins] r78058 - in python/branches/py3k: Lib/platform.py Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:33:33 2010 New Revision: 78058 Log: Merged revisions 78056 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78056 | ronald.oussoren | 2010-02-07 12:29:31 +0100 (Sun, 07 Feb 2010) | 5 lines Remove call to gestalt('sysu') from platform.py. This gestalt call is not available on OSX an appearently causes problems for some users. Fixes issue 7812 ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/platform.py Modified: python/branches/py3k/Lib/platform.py ============================================================================== --- python/branches/py3k/Lib/platform.py (original) +++ python/branches/py3k/Lib/platform.py Sun Feb 7 12:33:33 2010 @@ -729,7 +729,7 @@ except ImportError: return release,versioninfo,machine # Get the infos - sysv,sysu,sysa = _mac_ver_lookup(('sysv','sysu','sysa')) + sysv, sysa = _mac_ver_lookup(('sysv','sysa')) # Decode the infos if sysv: major = (sysv & 0xFF00) >> 8 @@ -747,24 +747,6 @@ else: release = '%s.%i.%i' % (_bcd2str(major),minor,patch) - if sysu: - # NOTE: this block is left as documentation of the - # intention of this function, the 'sysu' gestalt is no - # longer available and there are no alternatives. - major = int((sysu & 0xFF000000) >> 24) - minor = (sysu & 0x00F00000) >> 20 - bugfix = (sysu & 0x000F0000) >> 16 - stage = (sysu & 0x0000FF00) >> 8 - nonrel = (sysu & 0x000000FF) - version = '%s.%i.%i' % (_bcd2str(major),minor,bugfix) - nonrel = _bcd2str(nonrel) - stage = {0x20:'development', - 0x40:'alpha', - 0x60:'beta', - 0x80:'final'}.get(stage,'') - versioninfo = (version,stage,nonrel) - - if sysa: machine = {0x1: '68k', 0x2: 'PowerPC', From python-checkins at python.org Sun Feb 7 12:34:16 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 11:34:16 -0000 Subject: [Python-checkins] r78059 - python/trunk/Lib/unittest/case.py Message-ID: Author: georg.brandl Date: Sun Feb 7 12:34:15 2010 New Revision: 78059 Log: Use "regexp" consistently. Modified: python/trunk/Lib/unittest/case.py Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Sun Feb 7 12:34:15 2010 @@ -88,7 +88,7 @@ def __init__(self, expected, test_case, expected_regexp=None): self.expected = expected self.failureException = test_case.failureException - self.expected_regex = expected_regexp + self.expected_regexp = expected_regexp def __enter__(self): pass @@ -105,10 +105,10 @@ # let unexpected exceptions pass through return False self.exc_value = exc_value #store for later retrieval - if self.expected_regex is None: + if self.expected_regexp is None: return True - expected_regexp = self.expected_regex + expected_regexp = self.expected_regexp if isinstance(expected_regexp, basestring): expected_regexp = re.compile(expected_regexp) if not expected_regexp.search(str(exc_value)): @@ -853,12 +853,12 @@ with context: callable_obj(*args, **kwargs) - def assertRegexpMatches(self, text, expected_regex, msg=None): - if isinstance(expected_regex, basestring): - expected_regex = re.compile(expected_regex) - if not expected_regex.search(text): + def assertRegexpMatches(self, text, expected_regexp, msg=None): + if isinstance(expected_regexp, basestring): + expected_regexp = re.compile(expected_regexp) + if not expected_regexp.search(text): msg = msg or "Regexp didn't match" - msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) + msg = '%s: %r not found in %r' % (msg, expected_regexp.pattern, text) raise self.failureException(msg) From python-checkins at python.org Sun Feb 7 12:34:49 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:34:49 -0000 Subject: [Python-checkins] r78060 - in python/branches/release31-maint: Lib/platform.py Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:34:48 2010 New Revision: 78060 Log: Merged revisions 78058 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r78058 | ronald.oussoren | 2010-02-07 12:33:33 +0100 (Sun, 07 Feb 2010) | 12 lines Merged revisions 78056 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78056 | ronald.oussoren | 2010-02-07 12:29:31 +0100 (Sun, 07 Feb 2010) | 5 lines Remove call to gestalt('sysu') from platform.py. This gestalt call is not available on OSX an appearently causes problems for some users. Fixes issue 7812 ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/platform.py Modified: python/branches/release31-maint/Lib/platform.py ============================================================================== --- python/branches/release31-maint/Lib/platform.py (original) +++ python/branches/release31-maint/Lib/platform.py Sun Feb 7 12:34:48 2010 @@ -698,7 +698,7 @@ except ImportError: return release,versioninfo,machine # Get the infos - sysv,sysu,sysa = _mac_ver_lookup(('sysv','sysu','sysa')) + sysv, sysa = _mac_ver_lookup(('sysv','sysa')) # Decode the infos if sysv: major = (sysv & 0xFF00) >> 8 @@ -716,24 +716,6 @@ else: release = '%s.%i.%i' % (_bcd2str(major),minor,patch) - if sysu: - # NOTE: this block is left as documentation of the - # intention of this function, the 'sysu' gestalt is no - # longer available and there are no alternatives. - major = int((sysu & 0xFF000000) >> 24) - minor = (sysu & 0x00F00000) >> 20 - bugfix = (sysu & 0x000F0000) >> 16 - stage = (sysu & 0x0000FF00) >> 8 - nonrel = (sysu & 0x000000FF) - version = '%s.%i.%i' % (_bcd2str(major),minor,bugfix) - nonrel = _bcd2str(nonrel) - stage = {0x20:'development', - 0x40:'alpha', - 0x60:'beta', - 0x80:'final'}.get(stage,'') - versioninfo = (version,stage,nonrel) - - if sysa: machine = {0x1: '68k', 0x2: 'PowerPC', From python-checkins at python.org Sun Feb 7 12:38:28 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:38:28 -0000 Subject: [Python-checkins] r78061 - in python/trunk: Doc/library/macostools.rst Lib/test/test_macostools.py Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:38:28 2010 New Revision: 78061 Log: A number of APIs in macostools cannot work in 64-bit mode because they use Carbon APIs that aren't available there. This patch disables tests for the affected entrypoints in macostools and mentions this in the documentation. In theory it is possible to replace the implementation by code that does work in 64-bit mode, but that would require further updates to the Carbon wrappers because the modern APIs aren't wrapped properly. Modified: python/trunk/Doc/library/macostools.rst python/trunk/Lib/test/test_macostools.py Modified: python/trunk/Doc/library/macostools.rst ============================================================================== --- python/trunk/Doc/library/macostools.rst (original) +++ python/trunk/Doc/library/macostools.rst Sun Feb 7 12:38:28 2010 @@ -17,6 +17,8 @@ This module has been removed in Python 3.0. + + The :mod:`macostools` module defines the following functions: @@ -28,17 +30,30 @@ modification and backup times (default is to copy them). Custom icons, comments and icon position are not copied. + .. note:: + + This function does not work in 64-bit code because it uses APIs that + are not available in 64-bit mode. .. function:: copytree(src, dst) Recursively copy a file tree from *src* to *dst*, creating folders as needed. *src* and *dst* should be specified as pathnames. + .. note:: + + This function does not work in 64-bit code because it uses APIs that + are not available in 64-bit mode. .. function:: mkalias(src, dst) Create a finder alias *dst* pointing to *src*. + .. note:: + + This function does not work in 64-bit code because it uses APIs that + are not available in 64-bit mode. + .. function:: touched(dst) Modified: python/trunk/Lib/test/test_macostools.py ============================================================================== --- python/trunk/Lib/test/test_macostools.py (original) +++ python/trunk/Lib/test/test_macostools.py Sun Feb 7 12:38:28 2010 @@ -59,37 +59,39 @@ DeprecationWarning) macostools.touched(test_support.TESTFN) - def test_copy(self): - try: - os.unlink(TESTFN2) - except: - pass - macostools.copy(test_support.TESTFN, TESTFN2) - self.assertEqual(self.compareData(), '') - - def test_mkalias(self): - try: - os.unlink(TESTFN2) - except: - pass - macostools.mkalias(test_support.TESTFN, TESTFN2) - fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) - self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) - - def test_mkalias_relative(self): - try: - os.unlink(TESTFN2) - except: - pass - # If the directory doesn't exist, then chances are this is a new - # install of Python so don't create it since the user might end up - # running ``sudo make install`` and creating the directory here won't - # leave it with the proper permissions. - if not os.path.exists(sys.prefix): - return - macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix) - fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) - self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) + if sys.maxint < 2**32: + def test_copy(self): + try: + os.unlink(TESTFN2) + except: + pass + macostools.copy(test_support.TESTFN, TESTFN2) + self.assertEqual(self.compareData(), '') + + if sys.maxint < 2**32: + def test_mkalias(self): + try: + os.unlink(TESTFN2) + except: + pass + macostools.mkalias(test_support.TESTFN, TESTFN2) + fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) + self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) + + def test_mkalias_relative(self): + try: + os.unlink(TESTFN2) + except: + pass + # If the directory doesn't exist, then chances are this is a new + # install of Python so don't create it since the user might end up + # running ``sudo make install`` and creating the directory here won't + # leave it with the proper permissions. + if not os.path.exists(sys.prefix): + return + macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix) + fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) + self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) def test_main(): From python-checkins at python.org Sun Feb 7 12:39:16 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:39:16 -0000 Subject: [Python-checkins] r78062 - in python/branches/release26-maint: Doc/library/macostools.rst Lib/test/test_macostools.py Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:39:16 2010 New Revision: 78062 Log: Merged revisions 78061 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78061 | ronald.oussoren | 2010-02-07 12:38:28 +0100 (Sun, 07 Feb 2010) | 10 lines A number of APIs in macostools cannot work in 64-bit mode because they use Carbon APIs that aren't available there. This patch disables tests for the affected entrypoints in macostools and mentions this in the documentation. In theory it is possible to replace the implementation by code that does work in 64-bit mode, but that would require further updates to the Carbon wrappers because the modern APIs aren't wrapped properly. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/macostools.rst python/branches/release26-maint/Lib/test/test_macostools.py Modified: python/branches/release26-maint/Doc/library/macostools.rst ============================================================================== --- python/branches/release26-maint/Doc/library/macostools.rst (original) +++ python/branches/release26-maint/Doc/library/macostools.rst Sun Feb 7 12:39:16 2010 @@ -17,6 +17,8 @@ This module has been removed in Python 3.0. + + The :mod:`macostools` module defines the following functions: @@ -28,17 +30,30 @@ modification and backup times (default is to copy them). Custom icons, comments and icon position are not copied. + .. note:: + + This function does not work in 64-bit code because it uses APIs that + are not available in 64-bit mode. .. function:: copytree(src, dst) Recursively copy a file tree from *src* to *dst*, creating folders as needed. *src* and *dst* should be specified as pathnames. + .. note:: + + This function does not work in 64-bit code because it uses APIs that + are not available in 64-bit mode. .. function:: mkalias(src, dst) Create a finder alias *dst* pointing to *src*. + .. note:: + + This function does not work in 64-bit code because it uses APIs that + are not available in 64-bit mode. + .. function:: touched(dst) Modified: python/branches/release26-maint/Lib/test/test_macostools.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_macostools.py (original) +++ python/branches/release26-maint/Lib/test/test_macostools.py Sun Feb 7 12:39:16 2010 @@ -57,37 +57,39 @@ DeprecationWarning) macostools.touched(test_support.TESTFN) - def test_copy(self): - try: - os.unlink(TESTFN2) - except: - pass - macostools.copy(test_support.TESTFN, TESTFN2) - self.assertEqual(self.compareData(), '') - - def test_mkalias(self): - try: - os.unlink(TESTFN2) - except: - pass - macostools.mkalias(test_support.TESTFN, TESTFN2) - fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) - self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) - - def test_mkalias_relative(self): - try: - os.unlink(TESTFN2) - except: - pass - # If the directory doesn't exist, then chances are this is a new - # install of Python so don't create it since the user might end up - # running ``sudo make install`` and creating the directory here won't - # leave it with the proper permissions. - if not os.path.exists(sys.prefix): - return - macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix) - fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) - self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) + if sys.maxint < 2**32: + def test_copy(self): + try: + os.unlink(TESTFN2) + except: + pass + macostools.copy(test_support.TESTFN, TESTFN2) + self.assertEqual(self.compareData(), '') + + if sys.maxint < 2**32: + def test_mkalias(self): + try: + os.unlink(TESTFN2) + except: + pass + macostools.mkalias(test_support.TESTFN, TESTFN2) + fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) + self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) + + def test_mkalias_relative(self): + try: + os.unlink(TESTFN2) + except: + pass + # If the directory doesn't exist, then chances are this is a new + # install of Python so don't create it since the user might end up + # running ``sudo make install`` and creating the directory here won't + # leave it with the proper permissions. + if not os.path.exists(sys.prefix): + return + macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix) + fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) + self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) def test_main(): From python-checkins at python.org Sun Feb 7 12:46:38 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:46:38 -0000 Subject: [Python-checkins] r78063 - python/branches/py3k/Mac/README Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:46:38 2010 New Revision: 78063 Log: Mention a configure warning that almost certainly indicates that configure is picking up a library that doesn't contain all architectures required for a universal build on OSX. Modified: python/branches/py3k/Mac/README Modified: python/branches/py3k/Mac/README ============================================================================== --- python/branches/py3k/Mac/README (original) +++ python/branches/py3k/Mac/README Sun Feb 7 12:46:38 2010 @@ -217,6 +217,25 @@ from within the BuildScript directory. The script accepts a number of command-line arguments, run it with --help for more information. +Configure warnings +================== + +The configure script sometimes emits warnings like the one below:: + + configure: WARNING: libintl.h: present but cannot be compiled + configure: WARNING: libintl.h: check for missing prerequisite headers? + configure: WARNING: libintl.h: see the Autoconf documentation + configure: WARNING: libintl.h: section "Present But Cannot Be Compiled" + configure: WARNING: libintl.h: proceeding with the preprocessor's result + configure: WARNING: libintl.h: in the future, the compiler will take precedence + configure: WARNING: ## -------------------------------------- ## + configure: WARNING: ## Report this to http://bugs.python.org/ ## + configure: WARNING: ## -------------------------------------- ## + +This almost always means you are trying to build a universal binary for +Python and have libaries in ``/usr/local`` that don't contain the required +architectures. Temporarily move ``/usr/local`` aside to finish the build. + Odds and ends ============= From python-checkins at python.org Sun Feb 7 12:47:11 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:47:11 -0000 Subject: [Python-checkins] r78064 - in python/branches/release31-maint: Mac/README Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:47:11 2010 New Revision: 78064 Log: Merged revisions 78063 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r78063 | ronald.oussoren | 2010-02-07 12:46:38 +0100 (Sun, 07 Feb 2010) | 4 lines Mention a configure warning that almost certainly indicates that configure is picking up a library that doesn't contain all architectures required for a universal build on OSX. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Mac/README Modified: python/branches/release31-maint/Mac/README ============================================================================== --- python/branches/release31-maint/Mac/README (original) +++ python/branches/release31-maint/Mac/README Sun Feb 7 12:47:11 2010 @@ -145,6 +145,25 @@ from within the BuildScript directory. The script accepts a number of command-line arguments, run it with --help for more information. +Configure warnings +================== + +The configure script sometimes emits warnings like the one below:: + + configure: WARNING: libintl.h: present but cannot be compiled + configure: WARNING: libintl.h: check for missing prerequisite headers? + configure: WARNING: libintl.h: see the Autoconf documentation + configure: WARNING: libintl.h: section "Present But Cannot Be Compiled" + configure: WARNING: libintl.h: proceeding with the preprocessor's result + configure: WARNING: libintl.h: in the future, the compiler will take precedence + configure: WARNING: ## -------------------------------------- ## + configure: WARNING: ## Report this to http://bugs.python.org/ ## + configure: WARNING: ## -------------------------------------- ## + +This almost always means you are trying to build a universal binary for +Python and have libaries in ``/usr/local`` that don't contain the required +architectures. Temporarily move ``/usr/local`` aside to finish the build. + Odds and ends ============= From python-checkins at python.org Sun Feb 7 12:50:54 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:50:54 -0000 Subject: [Python-checkins] r78065 - in python/branches/release26-maint: configure configure.in Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:50:54 2010 New Revision: 78065 Log: Fix for issue 7714 (backport from trunk) Modified: python/branches/release26-maint/configure python/branches/release26-maint/configure.in Modified: python/branches/release26-maint/configure ============================================================================== --- python/branches/release26-maint/configure (original) +++ python/branches/release26-maint/configure Sun Feb 7 12:50:54 2010 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 77195 . +# From configure.in Revision: 77864 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.6. # @@ -3855,7 +3855,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f conftest* +rm -f -r conftest* @@ -5394,7 +5394,7 @@ else ac_cv_header_stdc=no fi -rm -f conftest* +rm -f -r conftest* fi @@ -5415,7 +5415,7 @@ else ac_cv_header_stdc=no fi -rm -f conftest* +rm -f -r conftest* fi @@ -6513,7 +6513,7 @@ fi -rm -f conftest* +rm -f -r conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -7043,7 +7043,7 @@ else ac_cv_type_uid_t=no fi -rm -f conftest* +rm -f -r conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -12973,7 +12973,7 @@ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + gcc_version=`gcc -dumpversion` if test ${gcc_version} '<' 4.0 then LIBTOOL_CRUFT="-lcc_dynamic" @@ -14168,7 +14168,7 @@ else unistd_defines_pthreads=no fi -rm -f conftest* +rm -f -r conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -15782,7 +15782,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f conftest* +rm -f -r conftest* ;; kame) @@ -15805,7 +15805,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f conftest* +rm -f -r conftest* ;; linux-glibc) @@ -15826,7 +15826,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f conftest* +rm -f -r conftest* ;; linux-inet6) @@ -15864,7 +15864,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f conftest* +rm -f -r conftest* ;; v6d) @@ -15887,7 +15887,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f conftest* +rm -f -r conftest* ;; zeta) @@ -15909,7 +15909,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f conftest* +rm -f -r conftest* ;; esac @@ -23684,7 +23684,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -23703,7 +23703,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* fi @@ -23973,7 +23973,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* fi Modified: python/branches/release26-maint/configure.in ============================================================================== --- python/branches/release26-maint/configure.in (original) +++ python/branches/release26-maint/configure.in Sun Feb 7 12:50:54 2010 @@ -1574,7 +1574,7 @@ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + gcc_version=`gcc -dumpversion` if test ${gcc_version} '<' 4.0 then LIBTOOL_CRUFT="-lcc_dynamic" From python-checkins at python.org Sun Feb 7 12:53:18 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:53:18 -0000 Subject: [Python-checkins] r78066 - in python/branches/py3k: configure configure.in Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:53:18 2010 New Revision: 78066 Log: Fix for issue 7714, ported from the trunk. Modified: python/branches/py3k/configure python/branches/py3k/configure.in Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Sun Feb 7 12:53:18 2010 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 77216 . +# From configure.in Revision: 77862 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -3796,7 +3796,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f conftest* +rm -f -r conftest* @@ -5339,7 +5339,7 @@ else ac_cv_header_stdc=no fi -rm -f conftest* +rm -f -r conftest* fi @@ -5360,7 +5360,7 @@ else ac_cv_header_stdc=no fi -rm -f conftest* +rm -f -r conftest* fi @@ -6458,7 +6458,7 @@ fi -rm -f conftest* +rm -f -r conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -6988,7 +6988,7 @@ else ac_cv_type_uid_t=no fi -rm -f conftest* +rm -f -r conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -14399,7 +14399,7 @@ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + gcc_version=`gcc -dumpversion` if test ${gcc_version} '<' 4.0 then LIBTOOL_CRUFT="-lcc_dynamic" @@ -15657,7 +15657,7 @@ else unistd_defines_pthreads=no fi -rm -f conftest* +rm -f -r conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -16955,7 +16955,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f conftest* +rm -f -r conftest* ;; kame) @@ -16978,7 +16978,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f conftest* +rm -f -r conftest* ;; linux-glibc) @@ -16999,7 +16999,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f conftest* +rm -f -r conftest* ;; linux-inet6) @@ -17037,7 +17037,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f conftest* +rm -f -r conftest* ;; v6d) @@ -17060,7 +17060,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f conftest* +rm -f -r conftest* ;; zeta) @@ -17082,7 +17082,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f conftest* +rm -f -r conftest* ;; esac @@ -25597,7 +25597,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -25616,7 +25616,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* fi @@ -25886,7 +25886,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* fi Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Sun Feb 7 12:53:18 2010 @@ -1469,7 +1469,7 @@ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + gcc_version=`gcc -dumpversion` if test ${gcc_version} '<' 4.0 then LIBTOOL_CRUFT="-lcc_dynamic" From python-checkins at python.org Sun Feb 7 12:54:01 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 11:54:01 -0000 Subject: [Python-checkins] r78067 - in python/branches/release26-maint/Lib/test: test_richcmp.py test_tempfile.py Message-ID: Author: georg.brandl Date: Sun Feb 7 12:54:01 2010 New Revision: 78067 Log: Manual backport of r78046. Modified: python/branches/release26-maint/Lib/test/test_richcmp.py python/branches/release26-maint/Lib/test/test_tempfile.py Modified: python/branches/release26-maint/Lib/test/test_richcmp.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_richcmp.py (original) +++ python/branches/release26-maint/Lib/test/test_richcmp.py Sun Feb 7 12:54:01 2010 @@ -195,9 +195,9 @@ def __lt__(self, other): return 0 def __gt__(self, other): return 0 def __eq__(self, other): return 0 - def __le__(self, other): raise TestFailed, "This shouldn't happen" - def __ge__(self, other): raise TestFailed, "This shouldn't happen" - def __ne__(self, other): raise TestFailed, "This shouldn't happen" + def __le__(self, other): raise test_support.TestFailed, "This shouldn't happen" + def __ge__(self, other): raise test_support.TestFailed, "This shouldn't happen" + def __ne__(self, other): raise test_support.TestFailed, "This shouldn't happen" def __cmp__(self, other): raise RuntimeError, "expected" a = Misb() b = Misb() Modified: python/branches/release26-maint/Lib/test/test_tempfile.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_tempfile.py (original) +++ python/branches/release26-maint/Lib/test/test_tempfile.py Sun Feb 7 12:54:01 2010 @@ -127,7 +127,7 @@ if i == 20: break except: - failOnException("iteration") + self.failOnException("iteration") test_classes.append(test__RandomNameSequence) From python-checkins at python.org Sun Feb 7 12:54:03 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:54:03 -0000 Subject: [Python-checkins] r78068 - in python/branches/release31-maint: configure configure.in Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:54:03 2010 New Revision: 78068 Log: Merged revisions 78066 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r78066 | ronald.oussoren | 2010-02-07 12:53:18 +0100 (Sun, 07 Feb 2010) | 2 lines Fix for issue 7714, ported from the trunk. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/configure python/branches/release31-maint/configure.in Modified: python/branches/release31-maint/configure ============================================================================== --- python/branches/release31-maint/configure (original) +++ python/branches/release31-maint/configure Sun Feb 7 12:54:03 2010 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 77197 . +# From configure.in Revision: 77863 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.1. # @@ -3802,7 +3802,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f conftest* +rm -f -r conftest* @@ -5350,7 +5350,7 @@ else ac_cv_header_stdc=no fi -rm -f conftest* +rm -f -r conftest* fi @@ -5371,7 +5371,7 @@ else ac_cv_header_stdc=no fi -rm -f conftest* +rm -f -r conftest* fi @@ -6469,7 +6469,7 @@ fi -rm -f conftest* +rm -f -r conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -6999,7 +6999,7 @@ else ac_cv_type_uid_t=no fi -rm -f conftest* +rm -f -r conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -13276,7 +13276,7 @@ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + gcc_version=`gcc -dumpversion` if test ${gcc_version} '<' 4.0 then LIBTOOL_CRUFT="-lcc_dynamic" @@ -14414,7 +14414,7 @@ else unistd_defines_pthreads=no fi -rm -f conftest* +rm -f -r conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -15882,7 +15882,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f conftest* +rm -f -r conftest* ;; kame) @@ -15905,7 +15905,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f conftest* +rm -f -r conftest* ;; linux-glibc) @@ -15926,7 +15926,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f conftest* +rm -f -r conftest* ;; linux-inet6) @@ -15964,7 +15964,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f conftest* +rm -f -r conftest* ;; v6d) @@ -15987,7 +15987,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f conftest* +rm -f -r conftest* ;; zeta) @@ -16009,7 +16009,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f conftest* +rm -f -r conftest* ;; esac @@ -24262,7 +24262,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -24281,7 +24281,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* fi @@ -24551,7 +24551,7 @@ _ACEOF fi -rm -f conftest* +rm -f -r conftest* fi Modified: python/branches/release31-maint/configure.in ============================================================================== --- python/branches/release31-maint/configure.in (original) +++ python/branches/release31-maint/configure.in Sun Feb 7 12:54:03 2010 @@ -1515,7 +1515,7 @@ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + gcc_version=`gcc -dumpversion` if test ${gcc_version} '<' 4.0 then LIBTOOL_CRUFT="-lcc_dynamic" From python-checkins at python.org Sun Feb 7 12:57:15 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 11:57:15 -0000 Subject: [Python-checkins] r78069 - in python/branches/release26-maint: configure configure.in Message-ID: Author: ronald.oussoren Date: Sun Feb 7 12:57:14 2010 New Revision: 78069 Log: Merged revisions 77587 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r77587 | ronald.oussoren | 2010-01-17 20:27:57 +0100 (Sun, 17 Jan 2010) | 8 lines This patch ensures that the configure-script mentions checking for --enable-universalsdk and that it doesn't default to the 10.4u SDK when that SDK does not exist. (This affects OSX) This patch should fix most of issue 4834, although I haven't gotten enough information from the user to be sure. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/configure python/branches/release26-maint/configure.in Modified: python/branches/release26-maint/configure ============================================================================== --- python/branches/release26-maint/configure (original) +++ python/branches/release26-maint/configure Sun Feb 7 12:57:14 2010 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 77864 . +# From configure.in Revision: 78065 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.6. # @@ -1871,12 +1871,18 @@ CONFIG_ARGS="$ac_configure_args" +{ echo "$as_me:$LINENO: checking for --enable-universalsdk" >&5 +echo $ECHO_N "checking for --enable-universalsdk... $ECHO_C" >&6; } # Check whether --enable-universalsdk was given. if test "${enable_universalsdk+set}" = set; then enableval=$enable_universalsdk; case $enableval in yes) enableval=/Developer/SDKs/MacOSX10.4u.sdk + if test ! -d "${enableval}" + then + enableval=/ + fi ;; esac case $enableval in @@ -1886,9 +1892,16 @@ ;; *) UNIVERSALSDK=$enableval + if test ! -d "${UNIVERSALSDK}" + then + { { echo "$as_me:$LINENO: error: --enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}" >&5 +echo "$as_me: error: --enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}" >&2;} + { (exit 1); exit 1; }; } + fi ;; esac + else UNIVERSALSDK= @@ -1896,6 +1909,14 @@ fi +if test -n "${UNIVERSALSDK}" +then + { echo "$as_me:$LINENO: result: ${UNIVERSALSDK}" >&5 +echo "${ECHO_T}${UNIVERSALSDK}" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi Modified: python/branches/release26-maint/configure.in ============================================================================== --- python/branches/release26-maint/configure.in (original) +++ python/branches/release26-maint/configure.in Sun Feb 7 12:57:14 2010 @@ -69,12 +69,17 @@ AC_SUBST(CONFIG_ARGS) CONFIG_ARGS="$ac_configure_args" +AC_MSG_CHECKING([for --enable-universalsdk]) AC_ARG_ENABLE(universalsdk, AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)), [ case $enableval in yes) enableval=/Developer/SDKs/MacOSX10.4u.sdk + if test ! -d "${enableval}" + then + enableval=/ + fi ;; esac case $enableval in @@ -84,12 +89,23 @@ ;; *) UNIVERSALSDK=$enableval + if test ! -d "${UNIVERSALSDK}" + then + AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) + fi ;; esac + ],[ UNIVERSALSDK= enable_universalsdk= ]) +if test -n "${UNIVERSALSDK}" +then + AC_MSG_RESULT(${UNIVERSALSDK}) +else + AC_MSG_RESULT(no) +fi AC_SUBST(UNIVERSALSDK) AC_SUBST(ARCH_RUN_32BIT) From python-checkins at python.org Sun Feb 7 12:59:25 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 11:59:25 -0000 Subject: [Python-checkins] r78070 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Sun Feb 7 12:59:25 2010 New Revision: 78070 Log: Blocked revisions 78018-78019,78032,78036-78039,78042,78046,78048,78051,78059 via svnmerge ........ r78018 | georg.brandl | 2010-02-06 11:08:21 +0100 (Sa, 06 Feb 2010) | 1 line #7864: make deprecation notices a bit clearer. ........ r78019 | georg.brandl | 2010-02-06 11:23:16 +0100 (Sa, 06 Feb 2010) | 1 line Review sysconfig docs. ........ r78032 | georg.brandl | 2010-02-06 22:54:40 +0100 (Sa, 06 Feb 2010) | 1 line Remove unused imports from test_logging. ........ r78036 | georg.brandl | 2010-02-06 23:49:47 +0100 (Sa, 06 Feb 2010) | 1 line Remove unused import. ........ r78037 | georg.brandl | 2010-02-06 23:59:15 +0100 (Sa, 06 Feb 2010) | 1 line No need to assign the results of expressions used only for side effects. ........ r78038 | georg.brandl | 2010-02-07 00:02:29 +0100 (So, 07 Feb 2010) | 1 line Add a missing import. ........ r78039 | georg.brandl | 2010-02-07 00:06:24 +0100 (So, 07 Feb 2010) | 1 line Add missing imports. ........ r78042 | georg.brandl | 2010-02-07 00:12:12 +0100 (So, 07 Feb 2010) | 1 line Add missing import. ........ r78046 | georg.brandl | 2010-02-07 00:18:00 +0100 (So, 07 Feb 2010) | 1 line Fix various missing import/unbound name errors. ........ r78048 | georg.brandl | 2010-02-07 00:23:45 +0100 (So, 07 Feb 2010) | 1 line We heard you like test failures so we put unbound locals in your test so that you can fail while you fail. ........ r78051 | georg.brandl | 2010-02-07 00:53:52 +0100 (So, 07 Feb 2010) | 1 line Add missing import when running these tests standalone. ........ r78059 | georg.brandl | 2010-02-07 12:34:15 +0100 (So, 07 Feb 2010) | 1 line Use "regexp" consistently. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sun Feb 7 13:01:19 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:01:19 -0000 Subject: [Python-checkins] r78071 - in python/branches/release26-maint: Lib/email/test/test_email_torture.py Lib/plat-mac/Carbon/MediaDescr.py Lib/plat-mac/bundlebuilder.py Lib/plat-mac/macostools.py Lib/test/test_cfgparser.py Lib/test/test_docxmlrpc.py Lib/test/test_long.py Lib/test/test_minidom.py Lib/test/test_multiprocessing.py Lib/test/test_platform.py Lib/test/test_sgmllib.py Lib/urllib.py Message-ID: Author: georg.brandl Date: Sun Feb 7 13:01:19 2010 New Revision: 78071 Log: Merged revisions 78035,78040,78043,78049-78050,78052-78054 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78035 | georg.brandl | 2010-02-06 23:44:17 +0100 (Sa, 06 Feb 2010) | 1 line Fix duplicate import. ........ r78040 | georg.brandl | 2010-02-07 00:08:00 +0100 (So, 07 Feb 2010) | 1 line Fix a few UnboundLocalErrors in test_long. ........ r78043 | georg.brandl | 2010-02-07 00:12:19 +0100 (So, 07 Feb 2010) | 1 line Remove duplicate test method. ........ r78049 | georg.brandl | 2010-02-07 00:33:33 +0100 (So, 07 Feb 2010) | 1 line Fix import/access for some identifiers. _TestSharedCTypes does not seem to be executed? ........ r78050 | georg.brandl | 2010-02-07 00:34:10 +0100 (So, 07 Feb 2010) | 1 line Fix more unbound locals in code paths that do not seem to be used. ........ r78052 | georg.brandl | 2010-02-07 00:54:04 +0100 (So, 07 Feb 2010) | 1 line Add missing import when running these tests standalone. ........ r78053 | georg.brandl | 2010-02-07 00:54:43 +0100 (So, 07 Feb 2010) | 1 line Fix some name errors in Mac modules. ........ r78054 | georg.brandl | 2010-02-07 00:58:25 +0100 (So, 07 Feb 2010) | 1 line Add missing import. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/email/test/test_email_torture.py python/branches/release26-maint/Lib/plat-mac/Carbon/MediaDescr.py python/branches/release26-maint/Lib/plat-mac/bundlebuilder.py python/branches/release26-maint/Lib/plat-mac/macostools.py python/branches/release26-maint/Lib/test/test_cfgparser.py python/branches/release26-maint/Lib/test/test_docxmlrpc.py python/branches/release26-maint/Lib/test/test_long.py python/branches/release26-maint/Lib/test/test_minidom.py python/branches/release26-maint/Lib/test/test_multiprocessing.py python/branches/release26-maint/Lib/test/test_platform.py python/branches/release26-maint/Lib/test/test_sgmllib.py python/branches/release26-maint/Lib/urllib.py Modified: python/branches/release26-maint/Lib/email/test/test_email_torture.py ============================================================================== --- python/branches/release26-maint/Lib/email/test/test_email_torture.py (original) +++ python/branches/release26-maint/Lib/email/test/test_email_torture.py Sun Feb 7 13:01:19 2010 @@ -13,7 +13,7 @@ from types import ListType from email.test.test_email import TestEmailBase -from test.test_support import TestSkipped +from test.test_support import TestSkipped, run_unittest import email from email import __file__ as testfile @@ -128,7 +128,7 @@ def test_main(): for testclass in _testclasses(): - test_support.run_unittest(testclass) + run_unittest(testclass) Modified: python/branches/release26-maint/Lib/plat-mac/Carbon/MediaDescr.py ============================================================================== --- python/branches/release26-maint/Lib/plat-mac/Carbon/MediaDescr.py (original) +++ python/branches/release26-maint/Lib/plat-mac/Carbon/MediaDescr.py Sun Feb 7 13:01:19 2010 @@ -15,7 +15,7 @@ data = data[:self.size] values = struct.unpack(self.fmt, data) if len(values) != len(self.names): - raise Error, ('Format length does not match number of names', descr) + raise Error, ('Format length does not match number of names') rv = {} for i in range(len(values)): name = self.names[i] @@ -26,7 +26,7 @@ rv[name] = value return rv - def encode(dict): + def encode(self, dict): list = [self.fmt] for name in self.names: if type(name) == type(()): Modified: python/branches/release26-maint/Lib/plat-mac/bundlebuilder.py ============================================================================== --- python/branches/release26-maint/Lib/plat-mac/bundlebuilder.py (original) +++ python/branches/release26-maint/Lib/plat-mac/bundlebuilder.py Sun Feb 7 13:01:19 2010 @@ -426,7 +426,7 @@ pass elif self.mainprogram is not None: self.name = os.path.splitext(os.path.basename(self.mainprogram))[0] - elif executable is not None: + elif self.executable is not None: self.name = os.path.splitext(os.path.basename(self.executable))[0] if self.name[-4:] != ".app": self.name += ".app" Modified: python/branches/release26-maint/Lib/plat-mac/macostools.py ============================================================================== --- python/branches/release26-maint/Lib/plat-mac/macostools.py (original) +++ python/branches/release26-maint/Lib/plat-mac/macostools.py Sun Feb 7 13:01:19 2010 @@ -10,6 +10,7 @@ from Carbon import Res from Carbon import File, Files import os +import errno import MacOS try: openrf = MacOS.openrf Modified: python/branches/release26-maint/Lib/test/test_cfgparser.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_cfgparser.py (original) +++ python/branches/release26-maint/Lib/test/test_cfgparser.py Sun Feb 7 13:01:19 2010 @@ -17,8 +17,9 @@ return result def values(self): + # XXX never used? result = self.items() - return [i[1] for i in values] + return [i[1] for i in result] def iteritems(self): return iter(self.items()) def iterkeys(self): return iter(self.keys()) Modified: python/branches/release26-maint/Lib/test/test_docxmlrpc.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_docxmlrpc.py (original) +++ python/branches/release26-maint/Lib/test/test_docxmlrpc.py Sun Feb 7 13:01:19 2010 @@ -3,6 +3,7 @@ from test import test_support import threading import time +import socket import unittest import xmlrpclib Modified: python/branches/release26-maint/Lib/test/test_long.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_long.py (original) +++ python/branches/release26-maint/Lib/test/test_long.py Sun Feb 7 13:01:19 2010 @@ -506,7 +506,7 @@ except OverflowError: self.fail("int(long(sys.maxint)) overflowed!") if not isinstance(x, int): - raise TestFailed("int(long(sys.maxint)) should have returned int") + self.fail("int(long(sys.maxint)) should have returned int") x = int(hugeneg_aslong) try: self.assertEqual(x, hugeneg, @@ -514,8 +514,7 @@ except OverflowError: self.fail("int(long(-sys.maxint-1)) overflowed!") if not isinstance(x, int): - raise TestFailed("int(long(-sys.maxint-1)) should have " - "returned int") + self.fail("int(long(-sys.maxint-1)) should have returned int") # but long -> int should overflow for hugepos+1 and hugeneg-1 x = hugepos_aslong + 1 try: @@ -714,7 +713,7 @@ self.d = d assert float(n) / float(d) == value else: - raise TypeError("can't deal with %r" % val) + raise TypeError("can't deal with %r" % value) def __cmp__(self, other): if not isinstance(other, Rat): Modified: python/branches/release26-maint/Lib/test/test_minidom.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_minidom.py (original) +++ python/branches/release26-maint/Lib/test/test_minidom.py Sun Feb 7 13:01:19 2010 @@ -1295,12 +1295,13 @@ self.confirm(len(n1.entities) == len(n2.entities) and len(n1.notations) == len(n2.notations)) for i in range(len(n1.notations)): + # XXX this loop body doesn't seem to be executed? no1 = n1.notations.item(i) no2 = n1.notations.item(i) self.confirm(no1.name == no2.name and no1.publicId == no2.publicId and no1.systemId == no2.systemId) - statck.append((no1, no2)) + stack.append((no1, no2)) for i in range(len(n1.entities)): e1 = n1.entities.item(i) e2 = n2.entities.item(i) Modified: python/branches/release26-maint/Lib/test/test_multiprocessing.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_multiprocessing.py (original) +++ python/branches/release26-maint/Lib/test/test_multiprocessing.py Sun Feb 7 13:01:19 2010 @@ -1560,10 +1560,10 @@ return x = Value('i', 7, lock=lock) - y = Value(ctypes.c_double, 1.0/3.0, lock=lock) + y = Value(c_double, 1.0/3.0, lock=lock) foo = Value(_Foo, 3, 2, lock=lock) - arr = Array('d', range(10), lock=lock) - string = Array('c', 20, lock=lock) + arr = self.Array('d', range(10), lock=lock) + string = self.Array('c', 20, lock=lock) string.value = 'hello' p = self.Process(target=self._double, args=(x, y, foo, arr, string)) Modified: python/branches/release26-maint/Lib/test/test_platform.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_platform.py (original) +++ python/branches/release26-maint/Lib/test/test_platform.py Sun Feb 7 13:01:19 2010 @@ -128,8 +128,10 @@ if os.path.isdir(sys.executable) and \ os.path.exists(sys.executable+'.exe'): # Cygwin horror - executable = executable + '.exe' - res = platform.libc_ver(sys.executable) + executable = sys.executable + '.exe' + else: + executable = sys.executable + res = platform.libc_ver(executable) def test_parse_release_file(self): Modified: python/branches/release26-maint/Lib/test/test_sgmllib.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_sgmllib.py (original) +++ python/branches/release26-maint/Lib/test/test_sgmllib.py Sun Feb 7 13:01:19 2010 @@ -298,14 +298,6 @@ ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]), ]) - def test_illegal_declarations(self): - s = 'abcdef' - self.check_events(s, [ - ("data", "abc"), - ("unknown decl", 'spacer type="block" height="25"'), - ("data", "def"), - ]) - def test_weird_starttags(self): self.check_events("", [ ("starttag", "a", []), Modified: python/branches/release26-maint/Lib/urllib.py ============================================================================== --- python/branches/release26-maint/Lib/urllib.py (original) +++ python/branches/release26-maint/Lib/urllib.py Sun Feb 7 13:01:19 2010 @@ -28,7 +28,6 @@ import time import sys from urlparse import urljoin as basejoin -import warnings __all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve", "urlcleanup", "quote", "quote_plus", "unquote", "unquote_plus", @@ -72,8 +71,8 @@ def urlopen(url, data=None, proxies=None): """Create a file-like object for the specified URL to read from.""" from warnings import warnpy3k - warnings.warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " - "favor of urllib2.urlopen()", stacklevel=2) + warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " + "favor of urllib2.urlopen()", stacklevel=2) global _urlopener if proxies is not None: From python-checkins at python.org Sun Feb 7 13:01:58 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:01:58 -0000 Subject: [Python-checkins] r78072 - in python/branches/release26-maint: Doc/faq/design.rst Doc/faq/extending.rst Doc/faq/library.rst Doc/faq/programming.rst Doc/howto/doanddont.rst Doc/library/inspect.rst Message-ID: Author: georg.brandl Date: Sun Feb 7 13:01:57 2010 New Revision: 78072 Log: Merged revisions 78024 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78024 | georg.brandl | 2010-02-06 19:44:44 +0100 (Sa, 06 Feb 2010) | 1 line #5341: fix "builtin" where used as an adjective ("built-in" is correct). ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/faq/design.rst python/branches/release26-maint/Doc/faq/extending.rst python/branches/release26-maint/Doc/faq/library.rst python/branches/release26-maint/Doc/faq/programming.rst python/branches/release26-maint/Doc/howto/doanddont.rst python/branches/release26-maint/Doc/library/inspect.rst Modified: python/branches/release26-maint/Doc/faq/design.rst ============================================================================== --- python/branches/release26-maint/Doc/faq/design.rst (original) +++ python/branches/release26-maint/Doc/faq/design.rst Sun Feb 7 13:01:57 2010 @@ -657,9 +657,10 @@ you won't be fooled into accidentally overwriting a list when you need a sorted copy but also need to keep the unsorted version around. -In Python 2.4 a new builtin -- :func:`sorted` -- has been added. This function -creates a new list from a provided iterable, sorts it and returns it. For -example, here's how to iterate over the keys of a dictionary in sorted order:: +In Python 2.4 a new built-in function -- :func:`sorted` -- has been added. +This function creates a new list from a provided iterable, sorts it and returns +it. For example, here's how to iterate over the keys of a dictionary in sorted +order:: for key in sorted(dict.iterkeys()): ... # do whatever with dict[key]... Modified: python/branches/release26-maint/Doc/faq/extending.rst ============================================================================== --- python/branches/release26-maint/Doc/faq/extending.rst (original) +++ python/branches/release26-maint/Doc/faq/extending.rst Sun Feb 7 13:01:57 2010 @@ -439,7 +439,7 @@ Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ---------------------------------------------------------------------------------------------------------------- -In Python 2.2, you can inherit from builtin classes such as :class:`int`, +In Python 2.2, you can inherit from built-in classes such as :class:`int`, :class:`list`, :class:`dict`, etc. The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html) Modified: python/branches/release26-maint/Doc/faq/library.rst ============================================================================== --- python/branches/release26-maint/Doc/faq/library.rst (original) +++ python/branches/release26-maint/Doc/faq/library.rst Sun Feb 7 13:01:57 2010 @@ -25,10 +25,10 @@ Where is the math.py (socket.py, regex.py, etc.) source file? ------------------------------------------------------------- -If you can't find a source file for a module it may be a builtin or dynamically -loaded module implemented in C, C++ or other compiled language. In this case -you may not have the source file or it may be something like mathmodule.c, -somewhere in a C source directory (not on the Python Path). +If you can't find a source file for a module it may be a built-in or +dynamically loaded module implemented in C, C++ or other compiled language. +In this case you may not have the source file or it may be something like +mathmodule.c, somewhere in a C source directory (not on the Python Path). There are (at least) three kinds of modules in Python: @@ -359,7 +359,7 @@ In theory, this means an exact accounting requires an exact understanding of the PVM bytecode implementation. In practice, it means that operations on shared -variables of builtin data types (ints, lists, dicts, etc) that "look atomic" +variables of built-in data types (ints, lists, dicts, etc) that "look atomic" really are. For example, the following operations are all atomic (L, L1, L2 are lists, D, @@ -502,9 +502,9 @@ :func:`os.read` is a low-level function which takes a file descriptor, a small integer representing the opened file. :func:`os.popen` creates a high-level -file object, the same type returned by the builtin :func:`open` function. Thus, -to read n bytes from a pipe p created with :func:`os.popen`, you need to use -``p.read(n)``. +file object, the same type returned by the built-in :func:`open` function. +Thus, to read n bytes from a pipe p created with :func:`os.popen`, you need to +use ``p.read(n)``. How do I run a subprocess with pipes connected to both input and output? @@ -603,10 +603,11 @@ which in turn are a medium-level layer of abstraction on top of (among other things) low-level C file descriptors. -For most file objects you create in Python via the builtin ``file`` constructor, -``f.close()`` marks the Python file object as being closed from Python's point -of view, and also arranges to close the underlying C stream. This also happens -automatically in f's destructor, when f becomes garbage. +For most file objects you create in Python via the built-in ``file`` +constructor, ``f.close()`` marks the Python file object as being closed from +Python's point of view, and also arranges to close the underlying C stream. +This also happens automatically in ``f``'s destructor, when ``f`` becomes +garbage. But stdin, stdout and stderr are treated specially by Python, because of the special status also given to them by C. Running ``sys.stdout.close()`` marks Modified: python/branches/release26-maint/Doc/faq/programming.rst ============================================================================== --- python/branches/release26-maint/Doc/faq/programming.rst (original) +++ python/branches/release26-maint/Doc/faq/programming.rst Sun Feb 7 13:01:57 2010 @@ -178,9 +178,10 @@ L2 = list(L1[:3]) # "list" is redundant if L1 is a list. -Note that the functionally-oriented builtins such as :func:`map`, :func:`zip`, -and friends can be a convenient accelerator for loops that perform a single -task. For example to pair the elements of two lists together:: +Note that the functionally-oriented built-in functions such as :func:`map`, +:func:`zip`, and friends can be a convenient accelerator for loops that +perform a single task. For example to pair the elements of two lists +together:: >>> zip([1,2,3], [4,5,6]) [(1, 4), (2, 5), (3, 6)] @@ -202,7 +203,7 @@ Consider using the string formatting operations ``string % tuple`` and ``string % dictionary``. -Be sure to use the :meth:`list.sort` builtin method to do sorting, and see the +Be sure to use the :meth:`list.sort` built-in method to do sorting, and see the `sorting mini-HOWTO `_ for examples of moderately advanced usage. :meth:`list.sort` beats other techniques for sorting in all but the most extreme circumstances. @@ -363,7 +364,7 @@ one hand, requiring :keyword:`global` for assigned variables provides a bar against unintended side-effects. On the other hand, if ``global`` was required for all global references, you'd be using ``global`` all the time. You'd have -to declare as global every reference to a builtin function or to a component of +to declare as global every reference to a built-in function or to a component of an imported module. This clutter would defeat the usefulness of the ``global`` declaration for identifying side-effects. @@ -1068,7 +1069,7 @@ How do I iterate over a sequence in reverse order? -------------------------------------------------- -Use the :func:`reversed` builtin function, which is new in Python 2.4:: +Use the :func:`reversed` built-in function, which is new in Python 2.4:: for x in reversed(sequence): ... # do something with x... Modified: python/branches/release26-maint/Doc/howto/doanddont.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/doanddont.rst (original) +++ python/branches/release26-maint/Doc/howto/doanddont.rst Sun Feb 7 13:01:57 2010 @@ -52,10 +52,10 @@ f.read() does not work. Of course, it works just fine (assuming you have a file called -"www".) But it does not work if somewhere in the module, the statement ``from os -import *`` is present. The :mod:`os` module has a function called :func:`open` -which returns an integer. While it is very useful, shadowing builtins is one of -its least useful properties. +"www".) But it does not work if somewhere in the module, the statement ``from +os import *`` is present. The :mod:`os` module has a function called +:func:`open` which returns an integer. While it is very useful, shadowing a +builtin is one of its least useful properties. Remember, you can never know for sure what names a module exports, so either take what you need --- ``from module import name1, name2``, or keep them in the Modified: python/branches/release26-maint/Doc/library/inspect.rst ============================================================================== --- python/branches/release26-maint/Doc/library/inspect.rst (original) +++ python/branches/release26-maint/Doc/library/inspect.rst Sun Feb 7 13:01:57 2010 @@ -126,7 +126,7 @@ | frame | f_back | next outer frame object | | | | | (this frame's caller) | | +-----------+-----------------+---------------------------+-------+ -| | f_builtins | built-in namespace seen | | +| | f_builtins | builtins namespace seen | | | | | by this frame | | +-----------+-----------------+---------------------------+-------+ | | f_code | code object being | | From python-checkins at python.org Sun Feb 7 13:03:42 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 12:03:42 -0000 Subject: [Python-checkins] r78073 - in python/branches/py3k: configure configure.in Message-ID: Author: ronald.oussoren Date: Sun Feb 7 13:03:42 2010 New Revision: 78073 Log: * Checks that the SDK specified with --enable-universalsk=VALUE exists. * Fall back to the default system SDK when specifying --enable-universalsk without a value and the 10.4u SDK is not avaiable. Port of fix for issue 4834 from the trunk. Modified: python/branches/py3k/configure python/branches/py3k/configure.in Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Sun Feb 7 13:03:42 2010 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 77862 . +# From configure.in Revision: 78066 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -1886,12 +1886,18 @@ CONFIG_ARGS="$ac_configure_args" +{ echo "$as_me:$LINENO: checking for --enable-universalsdk" >&5 +echo $ECHO_N "checking for --enable-universalsdk... $ECHO_C" >&6; } # Check whether --enable-universalsdk was given. if test "${enable_universalsdk+set}" = set; then enableval=$enable_universalsdk; case $enableval in yes) enableval=/Developer/SDKs/MacOSX10.4u.sdk + if test ! -d "${enableval}" + then + enableval=/ + fi ;; esac case $enableval in @@ -1901,9 +1907,16 @@ ;; *) UNIVERSALSDK=$enableval + if test ! -d "${UNIVERSALSDK}" + then + { { echo "$as_me:$LINENO: error: --enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}" >&5 +echo "$as_me: error: --enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}" >&2;} + { (exit 1); exit 1; }; } + fi ;; esac + else UNIVERSALSDK= @@ -1911,6 +1924,14 @@ fi +if test -n "${UNIVERSALSDK}" +then + { echo "$as_me:$LINENO: result: ${UNIVERSALSDK}" >&5 +echo "${ECHO_T}${UNIVERSALSDK}" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Sun Feb 7 13:03:42 2010 @@ -86,12 +86,17 @@ AC_SUBST(CONFIG_ARGS) CONFIG_ARGS="$ac_configure_args" +AC_MSG_CHECKING([for --enable-universalsdk]) AC_ARG_ENABLE(universalsdk, AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)), [ case $enableval in yes) enableval=/Developer/SDKs/MacOSX10.4u.sdk + if test ! -d "${enableval}" + then + enableval=/ + fi ;; esac case $enableval in @@ -101,12 +106,23 @@ ;; *) UNIVERSALSDK=$enableval + if test ! -d "${UNIVERSALSDK}" + then + AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) + fi ;; esac + ],[ UNIVERSALSDK= enable_universalsdk= ]) +if test -n "${UNIVERSALSDK}" +then + AC_MSG_RESULT(${UNIVERSALSDK}) +else + AC_MSG_RESULT(no) +fi AC_SUBST(UNIVERSALSDK) AC_SUBST(ARCH_RUN_32BIT) From python-checkins at python.org Sun Feb 7 13:04:41 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 12:04:41 -0000 Subject: [Python-checkins] r78074 - in python/branches/release31-maint: configure configure.in Message-ID: Author: ronald.oussoren Date: Sun Feb 7 13:04:41 2010 New Revision: 78074 Log: Merged revisions 78073 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r78073 | ronald.oussoren | 2010-02-07 13:03:42 +0100 (Sun, 07 Feb 2010) | 7 lines * Checks that the SDK specified with --enable-universalsk=VALUE exists. * Fall back to the default system SDK when specifying --enable-universalsk without a value and the 10.4u SDK is not avaiable. Port of fix for issue 4834 from the trunk. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/configure python/branches/release31-maint/configure.in Modified: python/branches/release31-maint/configure ============================================================================== --- python/branches/release31-maint/configure (original) +++ python/branches/release31-maint/configure Sun Feb 7 13:04:41 2010 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 77863 . +# From configure.in Revision: 78068 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.1. # @@ -1881,12 +1881,18 @@ CONFIG_ARGS="$ac_configure_args" +{ echo "$as_me:$LINENO: checking for --enable-universalsdk" >&5 +echo $ECHO_N "checking for --enable-universalsdk... $ECHO_C" >&6; } # Check whether --enable-universalsdk was given. if test "${enable_universalsdk+set}" = set; then enableval=$enable_universalsdk; case $enableval in yes) enableval=/Developer/SDKs/MacOSX10.4u.sdk + if test ! -d "${enableval}" + then + enableval=/ + fi ;; esac case $enableval in @@ -1896,9 +1902,16 @@ ;; *) UNIVERSALSDK=$enableval + if test ! -d "${UNIVERSALSDK}" + then + { { echo "$as_me:$LINENO: error: --enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}" >&5 +echo "$as_me: error: --enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}" >&2;} + { (exit 1); exit 1; }; } + fi ;; esac + else UNIVERSALSDK= @@ -1906,6 +1919,14 @@ fi +if test -n "${UNIVERSALSDK}" +then + { echo "$as_me:$LINENO: result: ${UNIVERSALSDK}" >&5 +echo "${ECHO_T}${UNIVERSALSDK}" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi Modified: python/branches/release31-maint/configure.in ============================================================================== --- python/branches/release31-maint/configure.in (original) +++ python/branches/release31-maint/configure.in Sun Feb 7 13:04:41 2010 @@ -78,12 +78,17 @@ AC_SUBST(CONFIG_ARGS) CONFIG_ARGS="$ac_configure_args" +AC_MSG_CHECKING([for --enable-universalsdk]) AC_ARG_ENABLE(universalsdk, AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)), [ case $enableval in yes) enableval=/Developer/SDKs/MacOSX10.4u.sdk + if test ! -d "${enableval}" + then + enableval=/ + fi ;; esac case $enableval in @@ -93,12 +98,23 @@ ;; *) UNIVERSALSDK=$enableval + if test ! -d "${UNIVERSALSDK}" + then + AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) + fi ;; esac + ],[ UNIVERSALSDK= enable_universalsdk= ]) +if test -n "${UNIVERSALSDK}" +then + AC_MSG_RESULT(${UNIVERSALSDK}) +else + AC_MSG_RESULT(no) +fi AC_SUBST(UNIVERSALSDK) AC_SUBST(ARCH_RUN_32BIT) From python-checkins at python.org Sun Feb 7 13:16:12 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:16:12 -0000 Subject: [Python-checkins] r78075 - python/trunk/Lib/test/test_pep292.py Message-ID: Author: georg.brandl Date: Sun Feb 7 13:16:12 2010 New Revision: 78075 Log: Fix another duplicated test method. Modified: python/trunk/Lib/test/test_pep292.py Modified: python/trunk/Lib/test/test_pep292.py ============================================================================== --- python/trunk/Lib/test/test_pep292.py (original) +++ python/trunk/Lib/test/test_pep292.py Sun Feb 7 13:16:12 2010 @@ -86,13 +86,6 @@ s = Template('$who likes $100') raises(ValueError, s.substitute, dict(who='tim')) - def test_delimiter_override(self): - class PieDelims(Template): - delimiter = '@' - s = PieDelims('@who likes to eat a bag of @{what} worth $100') - self.assertEqual(s.substitute(dict(who='tim', what='ham')), - 'tim likes to eat a bag of ham worth $100') - def test_idpattern_override(self): class PathPattern(Template): idpattern = r'[_a-z][._a-z0-9]*' @@ -183,6 +176,12 @@ raises(ValueError, s.substitute, dict(gift='bud', who='you')) eq(s.safe_substitute(), 'this &gift is for &{who} &') + class PieDelims(Template): + delimiter = '@' + s = PieDelims('@who likes to eat a bag of @{what} worth $100') + self.assertEqual(s.substitute(dict(who='tim', what='ham')), + 'tim likes to eat a bag of ham worth $100') + def test_main(): from test import test_support From python-checkins at python.org Sun Feb 7 13:19:44 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:19:44 -0000 Subject: [Python-checkins] r78076 - python/trunk/Lib/test/test_optparse.py Message-ID: Author: georg.brandl Date: Sun Feb 7 13:19:43 2010 New Revision: 78076 Log: Fix wrong usage of "except X, Y:". Modified: python/trunk/Lib/test/test_optparse.py Modified: python/trunk/Lib/test/test_optparse.py ============================================================================== --- python/trunk/Lib/test/test_optparse.py (original) +++ python/trunk/Lib/test/test_optparse.py Sun Feb 7 13:19:43 2010 @@ -453,7 +453,7 @@ return int(value) else: return int(value[:-1]) * _time_units[value[-1]] - except ValueError, IndexError: + except (ValueError, IndexError): raise OptionValueError( 'option %s: invalid duration: %r' % (opt, value)) From python-checkins at python.org Sun Feb 7 13:25:51 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:25:51 -0000 Subject: [Python-checkins] r78077 - python/trunk/Lib/test/test_csv.py Message-ID: Author: georg.brandl Date: Sun Feb 7 13:25:50 2010 New Revision: 78077 Log: Fix two redefined test methods. Modified: python/trunk/Lib/test/test_csv.py Modified: python/trunk/Lib/test/test_csv.py ============================================================================== --- python/trunk/Lib/test/test_csv.py (original) +++ python/trunk/Lib/test/test_csv.py Sun Feb 7 13:25:50 2010 @@ -549,10 +549,10 @@ def test_null(self): self.writerAssertEqual([], '') - def test_single(self): + def test_single_writer(self): self.writerAssertEqual([['abc']], 'abc\r\n') - def test_simple(self): + def test_simple_writer(self): self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n') def test_quotes(self): From python-checkins at python.org Sun Feb 7 13:27:07 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:27:07 -0000 Subject: [Python-checkins] r78078 - python/trunk/Lib/test/test_functools.py Message-ID: Author: georg.brandl Date: Sun Feb 7 13:27:06 2010 New Revision: 78078 Log: Fix a redefined test method. Modified: python/trunk/Lib/test/test_functools.py Modified: python/trunk/Lib/test/test_functools.py ============================================================================== --- python/trunk/Lib/test/test_functools.py (original) +++ python/trunk/Lib/test/test_functools.py Sun Feb 7 13:27:06 2010 @@ -48,6 +48,14 @@ self.assertRaises(TypeError, setattr, p, 'args', (1, 2)) self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2)) + p = self.thetype(hex) + try: + del p.__dict__ + except TypeError: + pass + else: + self.fail('partial object allowed __dict__ to be deleted') + def test_argument_checking(self): self.assertRaises(TypeError, self.thetype) # need at least a func arg try: @@ -122,15 +130,6 @@ self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0) self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1) - def test_attributes(self): - p = self.thetype(hex) - try: - del p.__dict__ - except TypeError: - pass - else: - self.fail('partial object allowed __dict__ to be deleted') - def test_weakref(self): f = self.thetype(int, base=16) p = proxy(f) From python-checkins at python.org Sun Feb 7 13:34:26 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:34:26 -0000 Subject: [Python-checkins] r78079 - python/trunk/Lib/test/test_fnmatch.py Message-ID: Author: georg.brandl Date: Sun Feb 7 13:34:26 2010 New Revision: 78079 Log: Add a minimal test for fnmatchcase(). Modified: python/trunk/Lib/test/test_fnmatch.py Modified: python/trunk/Lib/test/test_fnmatch.py ============================================================================== --- python/trunk/Lib/test/test_fnmatch.py (original) +++ python/trunk/Lib/test/test_fnmatch.py Sun Feb 7 13:34:26 2010 @@ -44,6 +44,11 @@ check('\nfoo', 'foo*', False) check('\n', '*') + def test_fnmatchcase(self): + check = self.check_match + check('AbC', 'abc', 0) + check('abc', 'AbC', 0) + def test_main(): test_support.run_unittest(FnmatchTestCase) From python-checkins at python.org Sun Feb 7 13:55:12 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 12:55:12 -0000 Subject: [Python-checkins] r78080 - python/trunk/Lib/test/test_posixpath.py Message-ID: Author: georg.brandl Date: Sun Feb 7 13:55:12 2010 New Revision: 78080 Log: Remove duplicate test method. Modified: python/trunk/Lib/test/test_posixpath.py Modified: python/trunk/Lib/test/test_posixpath.py ============================================================================== --- python/trunk/Lib/test/test_posixpath.py (original) +++ python/trunk/Lib/test/test_posixpath.py Sun Feb 7 13:55:12 2010 @@ -2,7 +2,7 @@ from test import test_support import posixpath, os -from posixpath import realpath, abspath, join, dirname, basename, relpath +from posixpath import realpath, abspath, dirname, basename # An absolute path to a temporary filename for testing. We can't rely on TESTFN # being an absolute path, so we need this. @@ -89,11 +89,6 @@ self.assertRaises(TypeError, posixpath.isabs) - def test_splitdrive(self): - self.assertEqual(posixpath.splitdrive("/foo/bar"), ("", "/foo/bar")) - - self.assertRaises(TypeError, posixpath.splitdrive) - def test_basename(self): self.assertEqual(posixpath.basename("/foo/bar"), "bar") self.assertEqual(posixpath.basename("/"), "") From python-checkins at python.org Sun Feb 7 13:56:54 2010 From: python-checkins at python.org (vinay.sajip) Date: Sun, 07 Feb 2010 12:56:54 -0000 Subject: [Python-checkins] r78081 - in python/trunk: Lib/logging/__init__.py Lib/logging/config.py Misc/NEWS Message-ID: Author: vinay.sajip Date: Sun Feb 7 13:56:54 2010 New Revision: 78081 Log: Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code. Modified: python/trunk/Lib/logging/__init__.py python/trunk/Lib/logging/config.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/logging/__init__.py ============================================================================== --- python/trunk/Lib/logging/__init__.py (original) +++ python/trunk/Lib/logging/__init__.py Sun Feb 7 13:56:54 2010 @@ -769,7 +769,10 @@ if raiseExceptions: ei = sys.exc_info() try: - traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) + traceback.print_exception(ei[0], ei[1], ei[2], + None, sys.stderr) + sys.stderr.write('Logged from file %s, line %s\n' % ( + record.filename, record.lineno)) except IOError: pass # see issue 5971 finally: @@ -1572,17 +1575,8 @@ #else, swallow #Let's try and shutdown automatically on application exit... -try: - import atexit - atexit.register(shutdown) -except ImportError: # for Python versions < 2.0 - def exithook(status, old_exit=sys.exit): - try: - shutdown() - finally: - old_exit(status) - - sys.exit = exithook +import atexit +atexit.register(shutdown) # Null handler Modified: python/trunk/Lib/logging/config.py ============================================================================== --- python/trunk/Lib/logging/config.py (original) +++ python/trunk/Lib/logging/config.py Sun Feb 7 13:56:54 2010 @@ -58,15 +58,11 @@ the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). - In versions of ConfigParser which have the readfp method [typically - shipped in 2.x versions of Python], you can pass in a file-like object - rather than a filename, in which case the file-like object will be read - using readfp. """ import ConfigParser cp = ConfigParser.ConfigParser(defaults) - if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): + if hasattr(fname, 'readline'): cp.readfp(fname) else: cp.read(fname) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Feb 7 13:56:54 2010 @@ -75,6 +75,8 @@ Library ------- +- Issue #7869: logging: improved diagnostic for format-time errors. + - Issue #7868: logging: added loggerClass attribute to Manager. - Issue #7851: logging: clarification on logging configuration files. From python-checkins at python.org Sun Feb 7 14:01:56 2010 From: python-checkins at python.org (mark.dickinson) Date: Sun, 07 Feb 2010 13:01:56 -0000 Subject: [Python-checkins] r78082 - python/trunk/Lib/test/test_format.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 14:01:56 2010 New Revision: 78082 Log: Add missing global declarations for 'overflowok'; remove 'overflowrequired', which is no longer needed. Modified: python/trunk/Lib/test/test_format.py Modified: python/trunk/Lib/test/test_format.py ============================================================================== --- python/trunk/Lib/test/test_format.py (original) +++ python/trunk/Lib/test/test_format.py Sun Feb 7 14:01:56 2010 @@ -11,10 +11,11 @@ # test on unicode strings as well overflowok = 1 -overflowrequired = 0 def testformat(formatstr, args, output=None, limit=None): + global overflowok + if verbose: if output: print "%s %% %s =? %s ..." %\ @@ -29,12 +30,7 @@ if verbose: print 'overflow (this is fine)' else: - if overflowrequired: - if verbose: - print 'no' - print "overflow expected on %s %% %s" % \ - (repr(formatstr), repr(args)) - elif output and limit is None and result != output: + if output and limit is None and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" % \ @@ -63,6 +59,8 @@ class FormatTest(unittest.TestCase): def test_format(self): + global overflowok + testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1)) # expect overflow testboth("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') @@ -81,12 +79,12 @@ testboth('%12.*f', (123456, 1.0)) # check for internal overflow validation on length of precision - overflowrequired = 1 + # these tests should no longer cause overflow in Python + # 2.7/3.1 and later. testboth("%#.*g", (110, -1.e+100/3.)) testboth("%#.*G", (110, -1.e+100/3.)) testboth("%#.*f", (110, -1.e+100/3.)) testboth("%#.*F", (110, -1.e+100/3.)) - overflowrequired = 0 # Formatting of long integers. Overflow is not ok overflowok = 0 From python-checkins at python.org Sun Feb 7 14:02:11 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 13:02:11 -0000 Subject: [Python-checkins] r78083 - in python/branches/release26-maint: Lib/test/test_csv.py Lib/test/test_fnmatch.py Lib/test/test_functools.py Lib/test/test_optparse.py Lib/test/test_pep292.py Message-ID: Author: georg.brandl Date: Sun Feb 7 14:02:10 2010 New Revision: 78083 Log: Merged revisions 78075-78079 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78075 | georg.brandl | 2010-02-07 13:16:12 +0100 (So, 07 Feb 2010) | 1 line Fix another duplicated test method. ........ r78076 | georg.brandl | 2010-02-07 13:19:43 +0100 (So, 07 Feb 2010) | 1 line Fix wrong usage of "except X, Y:". ........ r78077 | georg.brandl | 2010-02-07 13:25:50 +0100 (So, 07 Feb 2010) | 1 line Fix two redefined test methods. ........ r78078 | georg.brandl | 2010-02-07 13:27:06 +0100 (So, 07 Feb 2010) | 1 line Fix a redefined test method. ........ r78079 | georg.brandl | 2010-02-07 13:34:26 +0100 (So, 07 Feb 2010) | 1 line Add a minimal test for fnmatchcase(). ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_csv.py python/branches/release26-maint/Lib/test/test_fnmatch.py python/branches/release26-maint/Lib/test/test_functools.py python/branches/release26-maint/Lib/test/test_optparse.py python/branches/release26-maint/Lib/test/test_pep292.py Modified: python/branches/release26-maint/Lib/test/test_csv.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_csv.py (original) +++ python/branches/release26-maint/Lib/test/test_csv.py Sun Feb 7 14:02:10 2010 @@ -531,10 +531,10 @@ def test_null(self): self.writerAssertEqual([], '') - def test_single(self): + def test_single_writer(self): self.writerAssertEqual([['abc']], 'abc\r\n') - def test_simple(self): + def test_simple_writer(self): self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n') def test_quotes(self): Modified: python/branches/release26-maint/Lib/test/test_fnmatch.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_fnmatch.py (original) +++ python/branches/release26-maint/Lib/test/test_fnmatch.py Sun Feb 7 14:02:10 2010 @@ -44,6 +44,11 @@ check('\nfoo', 'foo*', False) check('\n', '*') + def test_fnmatchcase(self): + check = self.check_match + check('AbC', 'abc', 0) + check('abc', 'AbC', 0) + def test_main(): test_support.run_unittest(FnmatchTestCase) Modified: python/branches/release26-maint/Lib/test/test_functools.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_functools.py (original) +++ python/branches/release26-maint/Lib/test/test_functools.py Sun Feb 7 14:02:10 2010 @@ -43,6 +43,14 @@ self.assertRaises(TypeError, setattr, p, 'args', (1, 2)) self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2)) + p = self.thetype(hex) + try: + del p.__dict__ + except TypeError: + pass + else: + self.fail('partial object allowed __dict__ to be deleted') + def test_argument_checking(self): self.assertRaises(TypeError, self.thetype) # need at least a func arg try: @@ -117,15 +125,6 @@ self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0) self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1) - def test_attributes(self): - p = self.thetype(hex) - try: - del p.__dict__ - except TypeError: - pass - else: - self.fail('partial object allowed __dict__ to be deleted') - def test_weakref(self): f = self.thetype(int, base=16) p = proxy(f) Modified: python/branches/release26-maint/Lib/test/test_optparse.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_optparse.py (original) +++ python/branches/release26-maint/Lib/test/test_optparse.py Sun Feb 7 14:02:10 2010 @@ -459,7 +459,7 @@ return int(value) else: return int(value[:-1]) * _time_units[value[-1]] - except ValueError, IndexError: + except (ValueError, IndexError): raise OptionValueError( 'option %s: invalid duration: %r' % (opt, value)) Modified: python/branches/release26-maint/Lib/test/test_pep292.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_pep292.py (original) +++ python/branches/release26-maint/Lib/test/test_pep292.py Sun Feb 7 14:02:10 2010 @@ -86,13 +86,6 @@ s = Template('$who likes $100') raises(ValueError, s.substitute, dict(who='tim')) - def test_delimiter_override(self): - class PieDelims(Template): - delimiter = '@' - s = PieDelims('@who likes to eat a bag of @{what} worth $100') - self.assertEqual(s.substitute(dict(who='tim', what='ham')), - 'tim likes to eat a bag of ham worth $100') - def test_idpattern_override(self): class PathPattern(Template): idpattern = r'[_a-z][._a-z0-9]*' @@ -183,6 +176,12 @@ raises(ValueError, s.substitute, dict(gift='bud', who='you')) eq(s.safe_substitute(), 'this &gift is for &{who} &') + class PieDelims(Template): + delimiter = '@' + s = PieDelims('@who likes to eat a bag of @{what} worth $100') + self.assertEqual(s.substitute(dict(who='tim', what='ham')), + 'tim likes to eat a bag of ham worth $100') + def test_main(): from test import test_support From python-checkins at python.org Sun Feb 7 14:05:51 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 13:05:51 -0000 Subject: [Python-checkins] r78084 - in python/branches/release26-maint: Lib/test/test_posixpath.py Message-ID: Author: georg.brandl Date: Sun Feb 7 14:05:51 2010 New Revision: 78084 Log: Merged revisions 78080 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78080 | georg.brandl | 2010-02-07 13:55:12 +0100 (So, 07 Feb 2010) | 1 line Remove duplicate test method. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_posixpath.py Modified: python/branches/release26-maint/Lib/test/test_posixpath.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_posixpath.py (original) +++ python/branches/release26-maint/Lib/test/test_posixpath.py Sun Feb 7 14:05:51 2010 @@ -2,7 +2,7 @@ from test import test_support import posixpath, os -from posixpath import realpath, abspath, join, dirname, basename, relpath +from posixpath import realpath, abspath, dirname, basename # An absolute path to a temporary filename for testing. We can't rely on TESTFN # being an absolute path, so we need this. @@ -89,11 +89,6 @@ self.assertRaises(TypeError, posixpath.isabs) - def test_splitdrive(self): - self.assertEqual(posixpath.splitdrive("/foo/bar"), ("", "/foo/bar")) - - self.assertRaises(TypeError, posixpath.splitdrive) - def test_basename(self): self.assertEqual(posixpath.basename("/foo/bar"), "bar") self.assertEqual(posixpath.basename("/"), "") From python-checkins at python.org Sun Feb 7 14:06:52 2010 From: python-checkins at python.org (vinay.sajip) Date: Sun, 07 Feb 2010 13:06:52 -0000 Subject: [Python-checkins] r78085 - python/trunk/Lib/logging/handlers.py Message-ID: Author: vinay.sajip Date: Sun Feb 7 14:06:51 2010 New Revision: 78085 Log: logging: Removed some more 1.5.2 support code. Modified: python/trunk/Lib/logging/handlers.py Modified: python/trunk/Lib/logging/handlers.py ============================================================================== --- python/trunk/Lib/logging/handlers.py (original) +++ python/trunk/Lib/logging/handlers.py Sun Feb 7 14:06:51 2010 @@ -1,4 +1,4 @@ -# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -19,7 +19,7 @@ based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. -Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. To use, simply 'import logging.handlers' and log away! """ @@ -850,24 +850,6 @@ """ return self.subject - weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] - - monthname = [None, - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] - - def date_time(self): - """ - Return the current date and time formatted for a MIME header. - Needed for Python 1.5.2 (no email package available) - """ - year, month, day, hh, mm, ss, wd, y, z = time.gmtime(time.time()) - s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( - self.weekdayname[wd], - day, self.monthname[month], year, - hh, mm, ss) - return s - def emit(self, record): """ Emit a record. @@ -876,10 +858,7 @@ """ try: import smtplib - try: - from email.utils import formatdate - except ImportError: - formatdate = self.date_time + from email.utils import formatdate port = self.mailport if not port: port = smtplib.SMTP_PORT From python-checkins at python.org Sun Feb 7 14:09:52 2010 From: python-checkins at python.org (mark.dickinson) Date: Sun, 07 Feb 2010 13:09:52 -0000 Subject: [Python-checkins] r78086 - python/trunk/Lib/test/test_format.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 14:09:52 2010 New Revision: 78086 Log: Actually raise on failure, instead of doing nothing. Modified: python/trunk/Lib/test/test_format.py Modified: python/trunk/Lib/test/test_format.py ============================================================================== --- python/trunk/Lib/test/test_format.py (original) +++ python/trunk/Lib/test/test_format.py Sun Feb 7 14:09:52 2010 @@ -33,8 +33,8 @@ if output and limit is None and result != output: if verbose: print 'no' - print "%s %% %s == %s != %s" % \ - (repr(formatstr), repr(args), repr(result), repr(output)) + raise AssertionError("%r %% %r == %r != %r" % + (formatstr, args, result, output)) # when 'limit' is specified, it determines how many characters # must match exactly; lengths must always match. # ex: limit=5, '12345678' matches '12345___' From python-checkins at python.org Sun Feb 7 14:15:38 2010 From: python-checkins at python.org (mark.dickinson) Date: Sun, 07 Feb 2010 13:15:38 -0000 Subject: [Python-checkins] r78087 - in python/branches/py3k: Lib/test/test_format.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 14:15:37 2010 New Revision: 78087 Log: Merged revisions 78082,78086 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78082 | mark.dickinson | 2010-02-07 13:01:56 +0000 (Sun, 07 Feb 2010) | 1 line Add missing global declarations for 'overflowok'; remove 'overflowrequired', which is no longer needed. ........ r78086 | mark.dickinson | 2010-02-07 13:09:52 +0000 (Sun, 07 Feb 2010) | 1 line Actually raise on failure, instead of doing nothing. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_format.py Modified: python/branches/py3k/Lib/test/test_format.py ============================================================================== --- python/branches/py3k/Lib/test/test_format.py (original) +++ python/branches/py3k/Lib/test/test_format.py Sun Feb 7 14:15:37 2010 @@ -11,7 +11,6 @@ # test on unicode strings as well overflowok = 1 -overflowrequired = 0 def testformat(formatstr, args, output=None, limit=None): if verbose: @@ -28,15 +27,9 @@ if verbose: print('overflow (this is fine)') else: - if overflowrequired: + if output and limit is None and result != output: if verbose: print('no') - print("overflow expected on %r %% %r" % (formatstr, args)) - elif output and limit is None and result != output: - if verbose: - print('no') - #print("%r %% %r == %r != %r" %\ - # (formatstr, args, result, output)) raise AssertionError("%r %% %r == %r != %r" % (formatstr, args, result, output)) # when 'limit' is specified, it determines how many characters @@ -57,6 +50,8 @@ class FormatTest(unittest.TestCase): def test_format(self): + global overflowok + testformat("%.1d", (1,), "1") testformat("%.*d", (sys.maxsize,1)) # expect overflow testformat("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') @@ -72,13 +67,14 @@ testformat("%#.*g", (110, -1.e+100/3.)) # test some ridiculously large precision, expect overflow testformat('%12.*f', (123456, 1.0)) + # check for internal overflow validation on length of precision - overflowrequired = 1 + # these tests should no longer cause overflow in Python + # 2.7/3.1 and later. testformat("%#.*g", (110, -1.e+100/3.)) testformat("%#.*G", (110, -1.e+100/3.)) testformat("%#.*f", (110, -1.e+100/3.)) testformat("%#.*F", (110, -1.e+100/3.)) - overflowrequired = 0 # Formatting of integers. Overflow is not ok overflowok = 0 testformat("%x", 10, "a") From python-checkins at python.org Sun Feb 7 17:56:24 2010 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 07 Feb 2010 16:56:24 -0000 Subject: [Python-checkins] r78088 - python/trunk/Lib/test/test_memoryio.py Message-ID: Author: antoine.pitrou Date: Sun Feb 7 17:56:23 2010 New Revision: 78088 Log: Issue #7870: Remove duplicate test methods. Reported by Georg Brandl. Modified: python/trunk/Lib/test/test_memoryio.py Modified: python/trunk/Lib/test/test_memoryio.py ============================================================================== --- python/trunk/Lib/test/test_memoryio.py (original) +++ python/trunk/Lib/test/test_memoryio.py Sun Feb 7 17:56:23 2010 @@ -484,25 +484,6 @@ class TextIOTestMixin: - def test_relative_seek(self): - memio = self.ioclass() - - self.assertRaises(IOError, memio.seek, -1, 1) - self.assertRaises(IOError, memio.seek, 3, 1) - self.assertRaises(IOError, memio.seek, -3, 1) - self.assertRaises(IOError, memio.seek, -1, 2) - self.assertRaises(IOError, memio.seek, 1, 1) - self.assertRaises(IOError, memio.seek, 1, 2) - - def test_textio_properties(self): - memio = self.ioclass() - - # These are just dummy values but we nevertheless check them for fear - # of unexpected breakage. - self.assertTrue(memio.encoding is None) - self.assertEqual(memio.errors, "strict") - self.assertEqual(memio.line_buffering, False) - def test_newlines_property(self): memio = self.ioclass(newline=None) # The C StringIO decodes newlines in write() calls, but the Python From python-checkins at python.org Sun Feb 7 17:59:50 2010 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 07 Feb 2010 16:59:50 -0000 Subject: [Python-checkins] r78089 - python/branches/release26-maint Message-ID: Author: antoine.pitrou Date: Sun Feb 7 17:59:50 2010 New Revision: 78089 Log: Blocked revisions 78088 via svnmerge ........ r78088 | antoine.pitrou | 2010-02-07 17:56:23 +0100 (dim., 07 f?vr. 2010) | 4 lines Issue #7870: Remove duplicate test methods. Reported by Georg Brandl. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sun Feb 7 18:00:43 2010 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 07 Feb 2010 17:00:43 -0000 Subject: [Python-checkins] r78090 - in python/branches/py3k: Lib/test/test_memoryio.py Message-ID: Author: antoine.pitrou Date: Sun Feb 7 18:00:43 2010 New Revision: 78090 Log: Merged revisions 78088 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78088 | antoine.pitrou | 2010-02-07 17:56:23 +0100 (dim., 07 f?vr. 2010) | 4 lines Issue #7870: Remove duplicate test methods. Reported by Georg Brandl. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_memoryio.py Modified: python/branches/py3k/Lib/test/test_memoryio.py ============================================================================== --- python/branches/py3k/Lib/test/test_memoryio.py (original) +++ python/branches/py3k/Lib/test/test_memoryio.py Sun Feb 7 18:00:43 2010 @@ -470,25 +470,6 @@ class TextIOTestMixin: - def test_relative_seek(self): - memio = self.ioclass() - - self.assertRaises(IOError, memio.seek, -1, 1) - self.assertRaises(IOError, memio.seek, 3, 1) - self.assertRaises(IOError, memio.seek, -3, 1) - self.assertRaises(IOError, memio.seek, -1, 2) - self.assertRaises(IOError, memio.seek, 1, 1) - self.assertRaises(IOError, memio.seek, 1, 2) - - def test_textio_properties(self): - memio = self.ioclass() - - # These are just dummy values but we nevertheless check them for fear - # of unexpected breakage. - self.assertTrue(memio.encoding is None) - self.assertEqual(memio.errors, "strict") - self.assertEqual(memio.line_buffering, False) - def test_newlines_property(self): memio = self.ioclass(newline=None) # The C StringIO decodes newlines in write() calls, but the Python From python-checkins at python.org Sun Feb 7 18:02:22 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 17:02:22 -0000 Subject: [Python-checkins] r78091 - in python/trunk: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/case.py Message-ID: Author: georg.brandl Date: Sun Feb 7 18:02:22 2010 New Revision: 78091 Log: Rename "exc_value" attribute on assertRaises context manager to "exception". Modified: python/trunk/Doc/library/unittest.rst python/trunk/Lib/test/test_unittest.py python/trunk/Lib/unittest/case.py Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Sun Feb 7 18:02:22 2010 @@ -898,13 +898,13 @@ do_something() The context manager will store the caught exception object in its - :attr:`exc_value` attribute. This can be useful if the intention + :attr:`exception` attribute. This can be useful if the intention is to perform additional checks on the exception raised:: with self.assertRaises(SomeException) as cm: do_something() - the_exception = cm.exc_value + the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) .. versionchanged:: 2.7 Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Sun Feb 7 18:02:22 2010 @@ -6,8 +6,6 @@ TestCase.{assert,fail}* methods (some are tested implicitly) """ -from StringIO import StringIO -import __builtin__ import os import re import sys @@ -626,7 +624,6 @@ # a good chance that it won't be imported when this test is run module_name = 'audioop' - import sys if module_name in sys.modules: del sys.modules[module_name] @@ -1014,7 +1011,6 @@ # a good chance that it won't be imported when this test is run module_name = 'audioop' - import sys if module_name in sys.modules: del sys.modules[module_name] @@ -1962,8 +1958,6 @@ # methods. Contains formatted tracebacks instead # of sys.exc_info() results." def test_addFailure(self): - import sys - class Foo(unittest.TestCase): def test_1(self): pass @@ -2012,8 +2006,6 @@ # methods. Contains formatted tracebacks instead # of sys.exc_info() results." def test_addError(self): - import sys - class Foo(unittest.TestCase): def test_1(self): pass @@ -2888,7 +2880,7 @@ ctx = self.assertRaises(ExceptionMock) with ctx: Stub(v) - e = ctx.exc_value + e = ctx.exception self.assertIsInstance(e, ExceptionMock) self.assertEqual(e.args[0], v) Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Sun Feb 7 18:02:22 2010 @@ -104,7 +104,7 @@ if not issubclass(exc_type, self.expected): # let unexpected exceptions pass through return False - self.exc_value = exc_value #store for later retrieval + self.exception = exc_value # store for later retrieval if self.expected_regexp is None: return True @@ -389,7 +389,7 @@ with self.assertRaises(SomeException) as cm: do_something() - the_exception = cm.exc_value + the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ context = _AssertRaisesContext(excClass, self) From python-checkins at python.org Sun Feb 7 18:02:58 2010 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 07 Feb 2010 17:02:58 -0000 Subject: [Python-checkins] r78092 - python/branches/release31-maint Message-ID: Author: antoine.pitrou Date: Sun Feb 7 18:02:58 2010 New Revision: 78092 Log: Merged revisions 78090 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r78090 | antoine.pitrou | 2010-02-07 18:00:43 +0100 (dim., 07 f?vr. 2010) | 9 lines Merged revisions 78088 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78088 | antoine.pitrou | 2010-02-07 17:56:23 +0100 (dim., 07 f?vr. 2010) | 4 lines Issue #7870: Remove duplicate test methods. Reported by Georg Brandl. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Sun Feb 7 18:03:16 2010 From: python-checkins at python.org (georg.brandl) Date: Sun, 07 Feb 2010 17:03:16 -0000 Subject: [Python-checkins] r78093 - in python/trunk/Lib/test: regrtest.py test__locale.py test_abstract_numbers.py test_applesingle.py test_bsddb.py test_builtin.py test_cmath.py test_cmd_line.py test_cmd_line_script.py test_collections.py test_commands.py test_compileall.py test_contextlib.py test_cookielib.py test_copy.py test_decimal.py test_deque.py test_descr.py test_dircache.py test_docxmlrpc.py test_epoll.py test_file.py test_file2k.py test_filecmp.py test_fileio.py test_float.py test_fork1.py test_frozen.py test_future_builtins.py test_gdbm.py test_getopt.py test_hashlib.py test_heapq.py test_imaplib.py test_inspect.py test_io.py test_logging.py test_long.py test_macos.py test_memoryio.py test_multibytecodec.py test_ntpath.py test_optparse.py test_os.py test_parser.py test_pdb.py test_print.py test_profile.py test_pyexpat.py test_queue.py test_random.py test_re.py test_set.py test_socketserver.py test_sqlite.py test_ssl.py test_strftime.py test_struct.py test_structmembers.py test_sys.py test_sysconfig.py test_tarfile.py test_tempfile.py test_tk.py test_tokenize.py test_traceback.py test_ttk_guionly.py test_ttk_textonly.py test_types.py test_undocumented_details.py test_urllib2net.py test_xml_etree.py test_xml_etree_c.py test_zipimport_support.py Message-ID: Author: georg.brandl Date: Sun Feb 7 18:03:15 2010 New Revision: 78093 Log: Remove unused imports in test modules. Modified: python/trunk/Lib/test/regrtest.py python/trunk/Lib/test/test__locale.py python/trunk/Lib/test/test_abstract_numbers.py python/trunk/Lib/test/test_applesingle.py python/trunk/Lib/test/test_bsddb.py python/trunk/Lib/test/test_builtin.py python/trunk/Lib/test/test_cmath.py python/trunk/Lib/test/test_cmd_line.py python/trunk/Lib/test/test_cmd_line_script.py python/trunk/Lib/test/test_collections.py python/trunk/Lib/test/test_commands.py python/trunk/Lib/test/test_compileall.py python/trunk/Lib/test/test_contextlib.py python/trunk/Lib/test/test_cookielib.py python/trunk/Lib/test/test_copy.py python/trunk/Lib/test/test_decimal.py python/trunk/Lib/test/test_deque.py python/trunk/Lib/test/test_descr.py python/trunk/Lib/test/test_dircache.py python/trunk/Lib/test/test_docxmlrpc.py python/trunk/Lib/test/test_epoll.py python/trunk/Lib/test/test_file.py python/trunk/Lib/test/test_file2k.py python/trunk/Lib/test/test_filecmp.py python/trunk/Lib/test/test_fileio.py python/trunk/Lib/test/test_float.py python/trunk/Lib/test/test_fork1.py python/trunk/Lib/test/test_frozen.py python/trunk/Lib/test/test_future_builtins.py python/trunk/Lib/test/test_gdbm.py python/trunk/Lib/test/test_getopt.py python/trunk/Lib/test/test_hashlib.py python/trunk/Lib/test/test_heapq.py python/trunk/Lib/test/test_imaplib.py python/trunk/Lib/test/test_inspect.py python/trunk/Lib/test/test_io.py python/trunk/Lib/test/test_logging.py python/trunk/Lib/test/test_long.py python/trunk/Lib/test/test_macos.py python/trunk/Lib/test/test_memoryio.py python/trunk/Lib/test/test_multibytecodec.py python/trunk/Lib/test/test_ntpath.py python/trunk/Lib/test/test_optparse.py python/trunk/Lib/test/test_os.py python/trunk/Lib/test/test_parser.py python/trunk/Lib/test/test_pdb.py python/trunk/Lib/test/test_print.py python/trunk/Lib/test/test_profile.py python/trunk/Lib/test/test_pyexpat.py python/trunk/Lib/test/test_queue.py python/trunk/Lib/test/test_random.py python/trunk/Lib/test/test_re.py python/trunk/Lib/test/test_set.py python/trunk/Lib/test/test_socketserver.py python/trunk/Lib/test/test_sqlite.py python/trunk/Lib/test/test_ssl.py python/trunk/Lib/test/test_strftime.py python/trunk/Lib/test/test_struct.py python/trunk/Lib/test/test_structmembers.py python/trunk/Lib/test/test_sys.py python/trunk/Lib/test/test_sysconfig.py python/trunk/Lib/test/test_tarfile.py python/trunk/Lib/test/test_tempfile.py python/trunk/Lib/test/test_tk.py python/trunk/Lib/test/test_tokenize.py python/trunk/Lib/test/test_traceback.py python/trunk/Lib/test/test_ttk_guionly.py python/trunk/Lib/test/test_ttk_textonly.py python/trunk/Lib/test/test_types.py python/trunk/Lib/test/test_undocumented_details.py python/trunk/Lib/test/test_urllib2net.py python/trunk/Lib/test/test_xml_etree.py python/trunk/Lib/test/test_xml_etree_c.py python/trunk/Lib/test/test_zipimport_support.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Sun Feb 7 18:03:15 2010 @@ -149,7 +149,6 @@ import cStringIO import getopt -import itertools import json import os import random @@ -448,8 +447,8 @@ if use_mp: from threading import Thread - from Queue import Queue, Empty - from subprocess import Popen, PIPE, STDOUT + from Queue import Queue + from subprocess import Popen, PIPE from collections import deque debug_output_pat = re.compile(r"\[\d+ refs\]$") pending = deque() Modified: python/trunk/Lib/test/test__locale.py ============================================================================== --- python/trunk/Lib/test/test__locale.py (original) +++ python/trunk/Lib/test/test__locale.py Sun Feb 7 18:03:15 2010 @@ -1,4 +1,4 @@ -from test.test_support import verbose, run_unittest +from test.test_support import run_unittest from _locale import (setlocale, LC_NUMERIC, localeconv, Error) try: from _locale import (RADIXCHAR, THOUSEP, nl_langinfo) Modified: python/trunk/Lib/test/test_abstract_numbers.py ============================================================================== --- python/trunk/Lib/test/test_abstract_numbers.py (original) +++ python/trunk/Lib/test/test_abstract_numbers.py Sun Feb 7 18:03:15 2010 @@ -1,10 +1,8 @@ """Unit tests for numbers.py.""" import math -import operator import unittest from numbers import Complex, Real, Rational, Integral -from numbers import Number from test import test_support class TestNumbers(unittest.TestCase): Modified: python/trunk/Lib/test/test_applesingle.py ============================================================================== --- python/trunk/Lib/test/test_applesingle.py (original) +++ python/trunk/Lib/test/test_applesingle.py Sun Feb 7 18:03:15 2010 @@ -7,9 +7,7 @@ MacOS = test_support.import_module('MacOS') # The following should exist if MacOS does. -import macostools import applesingle -import Carbon.File AS_MAGIC=0x00051600 AS_VERSION=0x00020000 Modified: python/trunk/Lib/test/test_bsddb.py ============================================================================== --- python/trunk/Lib/test/test_bsddb.py (original) +++ python/trunk/Lib/test/test_bsddb.py Sun Feb 7 18:03:15 2010 @@ -3,7 +3,6 @@ Adapted to unittest format and expanded scope by Raymond Hettinger """ import os, sys -import copy import unittest from test import test_support Modified: python/trunk/Lib/test/test_builtin.py ============================================================================== --- python/trunk/Lib/test/test_builtin.py (original) +++ python/trunk/Lib/test/test_builtin.py Sun Feb 7 18:03:15 2010 @@ -1,12 +1,12 @@ # Python test set -- built-in functions import platform -import test.test_support, unittest +import unittest from test.test_support import fcmp, have_unicode, TESTFN, unlink, \ - run_unittest, run_with_locale + run_unittest from operator import neg -import sys, warnings, cStringIO, random, fractions, UserDict +import sys, warnings, cStringIO, random, UserDict warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) warnings.filterwarnings("ignore", "integer argument expected", Modified: python/trunk/Lib/test/test_cmath.py ============================================================================== --- python/trunk/Lib/test/test_cmath.py (original) +++ python/trunk/Lib/test/test_cmath.py Sun Feb 7 18:03:15 2010 @@ -1,7 +1,6 @@ from test.test_support import run_unittest from test.test_math import parse_testfile, test_file import unittest -import os, sys import cmath, math from cmath import phase, polar, rect, pi Modified: python/trunk/Lib/test/test_cmd_line.py ============================================================================== --- python/trunk/Lib/test/test_cmd_line.py (original) +++ python/trunk/Lib/test/test_cmd_line.py Sun Feb 7 18:03:15 2010 @@ -2,7 +2,6 @@ # All tests are executed with environment variables ignored # See test_cmd_line_script.py for testing of script execution -import os import test.test_support, unittest import sys from test.script_helper import spawn_python, kill_python, python_exit_code Modified: python/trunk/Lib/test/test_cmd_line_script.py ============================================================================== --- python/trunk/Lib/test/test_cmd_line_script.py (original) +++ python/trunk/Lib/test/test_cmd_line_script.py Sun Feb 7 18:03:15 2010 @@ -3,9 +3,8 @@ import unittest import os import os.path -import sys import test.test_support -from test.script_helper import (spawn_python, kill_python, run_python, +from test.script_helper import (run_python, temp_dir, make_script, compile_script, make_pkg, make_zip_script, make_zip_pkg) Modified: python/trunk/Lib/test/test_collections.py ============================================================================== --- python/trunk/Lib/test/test_collections.py (original) +++ python/trunk/Lib/test/test_collections.py Sun Feb 7 18:03:15 2010 @@ -6,7 +6,6 @@ from test import mapping_tests import pickle, cPickle, copy from random import randrange, shuffle -import operator import keyword import re from collections import Hashable, Iterable, Iterator @@ -848,7 +847,7 @@ d = self._empty_mapping() self.assertRaises(KeyError, d.popitem) -import doctest, collections +import collections def test_main(verbose=None): NamedTupleDocs = doctest.DocTestSuite(module=collections) Modified: python/trunk/Lib/test/test_commands.py ============================================================================== --- python/trunk/Lib/test/test_commands.py (original) +++ python/trunk/Lib/test/test_commands.py Sun Feb 7 18:03:15 2010 @@ -12,8 +12,7 @@ from test.test_support import run_unittest, reap_children, import_module # Silence Py3k warning -import_module('commands', deprecated=True) -from commands import * +commands = import_module('commands', deprecated=True) # The module says: # "NB This only works (and is only relevant) for UNIX." @@ -28,8 +27,8 @@ class CommandTests(unittest.TestCase): def test_getoutput(self): - self.assertEquals(getoutput('echo xyzzy'), 'xyzzy') - self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy')) + self.assertEquals(commands.getoutput('echo xyzzy'), 'xyzzy') + self.assertEquals(commands.getstatusoutput('echo xyzzy'), (0, 'xyzzy')) # we use mkdtemp in the next line to create an empty directory # under our exclusive control; from that, we can invent a pathname @@ -39,7 +38,7 @@ dir = tempfile.mkdtemp() name = os.path.join(dir, "foo") - status, output = getstatusoutput('cat ' + name) + status, output = commands.getstatusoutput('cat ' + name) self.assertNotEquals(status, 0) finally: if dir is not None: @@ -60,7 +59,7 @@ /\. # and end with the name of the file. ''' - self.assertTrue(re.match(pat, getstatus("/."), re.VERBOSE)) + self.assertTrue(re.match(pat, commands.getstatus("/."), re.VERBOSE)) def test_main(): Modified: python/trunk/Lib/test/test_compileall.py ============================================================================== --- python/trunk/Lib/test/test_compileall.py (original) +++ python/trunk/Lib/test/test_compileall.py Sun Feb 7 18:03:15 2010 @@ -4,9 +4,7 @@ import py_compile import shutil import struct -import sys import tempfile -import time from test import test_support import unittest Modified: python/trunk/Lib/test/test_contextlib.py ============================================================================== --- python/trunk/Lib/test/test_contextlib.py (original) +++ python/trunk/Lib/test/test_contextlib.py Sun Feb 7 18:03:15 2010 @@ -1,9 +1,7 @@ """Unit tests for contextlib.py, and other context managers.""" -import sys import os -import decimal import tempfile import unittest import threading @@ -147,7 +145,6 @@ self.fail("Didn't raise ZeroDivisionError") def test_nested_right_exception(self): - state = [] @contextmanager def a(): yield 1 Modified: python/trunk/Lib/test/test_cookielib.py ============================================================================== --- python/trunk/Lib/test/test_cookielib.py (original) +++ python/trunk/Lib/test/test_cookielib.py Sun Feb 7 18:03:15 2010 @@ -1722,7 +1722,6 @@ def test_main(verbose=None): - from test import test_sets test_support.run_unittest( DateTimeTests, HeaderTests, Modified: python/trunk/Lib/test/test_copy.py ============================================================================== --- python/trunk/Lib/test/test_copy.py (original) +++ python/trunk/Lib/test/test_copy.py Sun Feb 7 18:03:15 2010 @@ -3,7 +3,6 @@ import copy import copy_reg import weakref -import operator import unittest from test import test_support Modified: python/trunk/Lib/test/test_decimal.py ============================================================================== --- python/trunk/Lib/test/test_decimal.py (original) +++ python/trunk/Lib/test/test_decimal.py Sun Feb 7 18:03:15 2010 @@ -24,7 +24,6 @@ with the corresponding argument. """ -import glob import math import os, sys import pickle, copy Modified: python/trunk/Lib/test/test_deque.py ============================================================================== --- python/trunk/Lib/test/test_deque.py (original) +++ python/trunk/Lib/test/test_deque.py Sun Feb 7 18:03:15 2010 @@ -6,7 +6,6 @@ import copy import cPickle as pickle import random -import os BIG = 100000 Modified: python/trunk/Lib/test/test_descr.py ============================================================================== --- python/trunk/Lib/test/test_descr.py (original) +++ python/trunk/Lib/test/test_descr.py Sun Feb 7 18:03:15 2010 @@ -261,7 +261,6 @@ pass else: self.fail("NotImplemented should have caused TypeError") - import sys try: C(sys.maxint+1) except OverflowError: @@ -654,7 +653,6 @@ def test_module_subclasses(self): # Testing Python subclass of module... log = [] - import types, sys MT = type(sys) class MM(MT): def __init__(self, name): @@ -1131,7 +1129,6 @@ # Test cyclical leaks [SF bug 519621] class F(object): __slots__ = ['a', 'b'] - log = [] s = F() s.a = [Counted(), s] self.assertEqual(Counted.counter, 1) @@ -1140,7 +1137,7 @@ self.assertEqual(Counted.counter, 0) # Test lookup leaks [SF bug 572567] - import sys,gc + import gc if hasattr(gc, 'get_objects'): class G(object): def __cmp__(self, other): @@ -1945,7 +1942,6 @@ return 'EPS' return self # sys.stdout needs to be the original to trigger the recursion bug - import sys test_stdout = sys.stdout sys.stdout = test_support.get_original_stdout() try: @@ -2309,7 +2305,6 @@ self.assertIn('im_self', dir(a.Amethod)) # Try a module subclass. - import sys class M(type(sys)): pass minstance = M("m") @@ -3506,7 +3501,6 @@ self.fail("d.foo should be undefined now") # Test a nasty bug in recurse_down_subclasses() - import gc class A(object): pass class B(A): @@ -4327,7 +4321,6 @@ def test_file_fault(self): # Testing sys.stdout is changed in getattr... - import sys test_stdout = sys.stdout class StdoutGuard: def __getattr__(self, attr): @@ -4416,8 +4409,6 @@ def test_not_implemented(self): # Testing NotImplemented... # all binary methods should be able to return a NotImplemented - import sys - import types import operator def specialmethod(self, other): Modified: python/trunk/Lib/test/test_dircache.py ============================================================================== --- python/trunk/Lib/test/test_dircache.py (original) +++ python/trunk/Lib/test/test_dircache.py Sun Feb 7 18:03:15 2010 @@ -4,7 +4,7 @@ """ import unittest -from test.test_support import run_unittest, TESTFN, import_module +from test.test_support import run_unittest, import_module dircache = import_module('dircache', deprecated=True) import os, time, sys, tempfile Modified: python/trunk/Lib/test/test_docxmlrpc.py ============================================================================== --- python/trunk/Lib/test/test_docxmlrpc.py (original) +++ python/trunk/Lib/test/test_docxmlrpc.py Sun Feb 7 18:03:15 2010 @@ -5,7 +5,6 @@ import time import socket import unittest -import xmlrpclib PORT = None Modified: python/trunk/Lib/test/test_epoll.py ============================================================================== --- python/trunk/Lib/test/test_epoll.py (original) +++ python/trunk/Lib/test/test_epoll.py Sun Feb 7 18:03:15 2010 @@ -21,12 +21,10 @@ """ Tests for epoll wrapper. """ -import os import socket import errno import time import select -import tempfile import unittest from test import test_support Modified: python/trunk/Lib/test/test_file.py ============================================================================== --- python/trunk/Lib/test/test_file.py (original) +++ python/trunk/Lib/test/test_file.py Sun Feb 7 18:03:15 2010 @@ -12,7 +12,7 @@ import io import _pyio as pyio -from test.test_support import TESTFN, findfile, run_unittest +from test.test_support import TESTFN, run_unittest from UserList import UserList class AutoFileTests(unittest.TestCase): Modified: python/trunk/Lib/test/test_file2k.py ============================================================================== --- python/trunk/Lib/test/test_file2k.py (original) +++ python/trunk/Lib/test/test_file2k.py Sun Feb 7 18:03:15 2010 @@ -8,7 +8,7 @@ from weakref import proxy from test import test_support -from test.test_support import TESTFN, findfile, run_unittest +from test.test_support import TESTFN, run_unittest from UserList import UserList class AutoFileTests(unittest.TestCase): Modified: python/trunk/Lib/test/test_filecmp.py ============================================================================== --- python/trunk/Lib/test/test_filecmp.py (original) +++ python/trunk/Lib/test/test_filecmp.py Sun Feb 7 18:03:15 2010 @@ -1,5 +1,5 @@ -import os, filecmp, shutil, tempfile, shutil +import os, filecmp, shutil, tempfile import unittest from test import test_support Modified: python/trunk/Lib/test/test_fileio.py ============================================================================== --- python/trunk/Lib/test/test_fileio.py (original) +++ python/trunk/Lib/test/test_fileio.py Sun Feb 7 18:03:15 2010 @@ -10,8 +10,7 @@ from weakref import proxy from functools import wraps -from test.test_support import (TESTFN, findfile, check_warnings, run_unittest, - make_bad_fd) +from test.test_support import TESTFN, check_warnings, run_unittest, make_bad_fd from test.test_support import py3k_bytes as bytes from _io import FileIO as _FileIO Modified: python/trunk/Lib/test/test_float.py ============================================================================== --- python/trunk/Lib/test/test_float.py (original) +++ python/trunk/Lib/test/test_float.py Sun Feb 7 18:03:15 2010 @@ -523,7 +523,6 @@ if float.__getformat__("double").startswith("IEEE"): def test_negative_zero(self): - import math def pos_pos(): return 0.0, math.atan2(0.0, -1) def pos_neg(): @@ -537,7 +536,6 @@ if float.__getformat__("double").startswith("IEEE"): def test_underflow_sign(self): - import math # check that -1e-1000 gives -0.0, not 0.0 self.assertEquals(math.atan2(-1e-1000, -1), math.atan2(-0.0, -1)) self.assertEquals(math.atan2(float('-1e-1000'), -1), Modified: python/trunk/Lib/test/test_fork1.py ============================================================================== --- python/trunk/Lib/test/test_fork1.py (original) +++ python/trunk/Lib/test/test_fork1.py Sun Feb 7 18:03:15 2010 @@ -1,7 +1,6 @@ """This test checks for correct fork() behavior. """ -import errno import imp import os import signal Modified: python/trunk/Lib/test/test_frozen.py ============================================================================== --- python/trunk/Lib/test/test_frozen.py (original) +++ python/trunk/Lib/test/test_frozen.py Sun Feb 7 18:03:15 2010 @@ -2,7 +2,7 @@ from test.test_support import captured_stdout, run_unittest import unittest -import sys, os +import sys class FrozenTests(unittest.TestCase): def test_frozen(self): Modified: python/trunk/Lib/test/test_future_builtins.py ============================================================================== --- python/trunk/Lib/test/test_future_builtins.py (original) +++ python/trunk/Lib/test/test_future_builtins.py Sun Feb 7 18:03:15 2010 @@ -2,7 +2,6 @@ # we're testing the behavior of these future builtins: from future_builtins import hex, oct, map, zip, filter -from test import test_support class BuiltinTest(unittest.TestCase): def test_hex(self): Modified: python/trunk/Lib/test/test_gdbm.py ============================================================================== --- python/trunk/Lib/test/test_gdbm.py (original) +++ python/trunk/Lib/test/test_gdbm.py Sun Feb 7 18:03:15 2010 @@ -1,7 +1,6 @@ import unittest import os -from test.test_support import (verbose, TESTFN, run_unittest, unlink, - import_module) +from test.test_support import TESTFN, run_unittest, unlink, import_module gdbm = import_module('gdbm') Modified: python/trunk/Lib/test/test_getopt.py ============================================================================== --- python/trunk/Lib/test/test_getopt.py (original) +++ python/trunk/Lib/test/test_getopt.py Sun Feb 7 18:03:15 2010 @@ -5,7 +5,6 @@ import unittest import getopt -import os sentinel = object() Modified: python/trunk/Lib/test/test_hashlib.py ============================================================================== --- python/trunk/Lib/test/test_hashlib.py (original) +++ python/trunk/Lib/test/test_hashlib.py Sun Feb 7 18:03:15 2010 @@ -8,7 +8,6 @@ import array import hashlib -import StringIO import itertools import sys try: Modified: python/trunk/Lib/test/test_heapq.py ============================================================================== --- python/trunk/Lib/test/test_heapq.py (original) +++ python/trunk/Lib/test/test_heapq.py Sun Feb 7 18:03:15 2010 @@ -367,8 +367,6 @@ def test_main(verbose=None): - from types import BuiltinFunctionType - test_classes = [TestHeapPython, TestHeapC, TestErrorHandling] test_support.run_unittest(*test_classes) Modified: python/trunk/Lib/test/test_imaplib.py ============================================================================== --- python/trunk/Lib/test/test_imaplib.py (original) +++ python/trunk/Lib/test/test_imaplib.py Sun Feb 7 18:03:15 2010 @@ -7,10 +7,7 @@ from contextlib import contextmanager import imaplib import os.path -import select -import socket import SocketServer -import sys import time from test_support import reap_threads, verbose Modified: python/trunk/Lib/test/test_inspect.py ============================================================================== --- python/trunk/Lib/test/test_inspect.py (original) +++ python/trunk/Lib/test/test_inspect.py Sun Feb 7 18:03:15 2010 @@ -4,7 +4,7 @@ import inspect import datetime -from test.test_support import TESTFN, run_unittest +from test.test_support import run_unittest from test import inspect_fodder as mod from test import inspect_fodder2 as mod2 Modified: python/trunk/Lib/test/test_io.py ============================================================================== --- python/trunk/Lib/test/test_io.py (original) +++ python/trunk/Lib/test/test_io.py Sun Feb 7 18:03:15 2010 @@ -31,9 +31,8 @@ import unittest import warnings import weakref -import gc import abc -from itertools import chain, cycle, count +from itertools import cycle, count from collections import deque from test import test_support as support Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Sun Feb 7 18:03:15 2010 @@ -42,7 +42,6 @@ find_unused_port import textwrap import threading -import time import unittest import warnings import weakref Modified: python/trunk/Lib/test/test_long.py ============================================================================== --- python/trunk/Lib/test/test_long.py (original) +++ python/trunk/Lib/test/test_long.py Sun Feb 7 18:03:15 2010 @@ -583,8 +583,6 @@ # ----------------------------------- tests of auto int->long conversion def test_auto_overflow(self): - import math, sys - special = [0, 1, 2, 3, sys.maxint-1, sys.maxint, sys.maxint+1] sqrt = int(math.sqrt(sys.maxint)) special.extend([sqrt-1, sqrt, sqrt+1]) @@ -704,8 +702,6 @@ self.assertEqual(long(float(x)), y) def test_float_overflow(self): - import math - for x in -2.0, -1.0, 0.0, 1.0, 2.0: self.assertEqual(float(long(x)), x) @@ -735,8 +731,6 @@ "float(shuge) should not equal int(shuge)") def test_logs(self): - import math - LOG10E = math.log10(math.e) for exp in range(10) + [100, 1000, 10000]: @@ -756,7 +750,6 @@ def test_mixed_compares(self): eq = self.assertEqual - import math # We're mostly concerned with that mixing floats and longs does the # right stuff, even when longs are too large to fit in a float. Modified: python/trunk/Lib/test/test_macos.py ============================================================================== --- python/trunk/Lib/test/test_macos.py (original) +++ python/trunk/Lib/test/test_macos.py Sun Feb 7 18:03:15 2010 @@ -4,8 +4,6 @@ import subprocess MacOS = test_support.import_module('MacOS') -#The following should exist if MacOS exists. -import Carbon.File TESTFN2 = test_support.TESTFN + '2' Modified: python/trunk/Lib/test/test_memoryio.py ============================================================================== --- python/trunk/Lib/test/test_memoryio.py (original) +++ python/trunk/Lib/test/test_memoryio.py Sun Feb 7 18:03:15 2010 @@ -11,7 +11,6 @@ import io import _pyio as pyio -import sys import pickle class MemorySeekTestMixin: Modified: python/trunk/Lib/test/test_multibytecodec.py ============================================================================== --- python/trunk/Lib/test/test_multibytecodec.py (original) +++ python/trunk/Lib/test/test_multibytecodec.py Sun Feb 7 18:03:15 2010 @@ -5,7 +5,6 @@ # from test import test_support -from test import test_multibytecodec_support from test.test_support import TESTFN import unittest, StringIO, codecs, sys, os import _multibytecodec Modified: python/trunk/Lib/test/test_ntpath.py ============================================================================== --- python/trunk/Lib/test/test_ntpath.py (original) +++ python/trunk/Lib/test/test_ntpath.py Sun Feb 7 18:03:15 2010 @@ -1,6 +1,6 @@ import ntpath import os -from test.test_support import verbose, TestFailed +from test.test_support import TestFailed import test.test_support as test_support import unittest Modified: python/trunk/Lib/test/test_optparse.py ============================================================================== --- python/trunk/Lib/test/test_optparse.py (original) +++ python/trunk/Lib/test/test_optparse.py Sun Feb 7 18:03:15 2010 @@ -19,9 +19,9 @@ from test import test_support -from optparse import make_option, Option, IndentedHelpFormatter, \ - TitledHelpFormatter, OptionParser, OptionContainer, OptionGroup, \ - SUPPRESS_HELP, SUPPRESS_USAGE, OptionError, OptionConflictError, \ +from optparse import make_option, Option, \ + TitledHelpFormatter, OptionParser, OptionGroup, \ + SUPPRESS_USAGE, OptionError, OptionConflictError, \ BadOptionError, OptionValueError, Values from optparse import _match_abbrev from optparse import _parse_num @@ -1236,7 +1236,6 @@ def variable_args(self, option, opt, value, parser): self.assertTrue(value is None) - done = 0 value = [] rargs = parser.rargs while rargs: Modified: python/trunk/Lib/test/test_os.py ============================================================================== --- python/trunk/Lib/test/test_os.py (original) +++ python/trunk/Lib/test/test_os.py Sun Feb 7 18:03:15 2010 @@ -134,7 +134,6 @@ self.assertTrue(s == "foobar") def test_tmpnam(self): - import sys if not hasattr(os, "tmpnam"): return warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, @@ -185,8 +184,6 @@ self.assertEquals(result[stat.ST_SIZE], 3) self.assertEquals(result.st_size, 3) - import sys - # Make sure all the attributes are there members = dir(result) for name in dir(stat): Modified: python/trunk/Lib/test/test_parser.py ============================================================================== --- python/trunk/Lib/test/test_parser.py (original) +++ python/trunk/Lib/test/test_parser.py Sun Feb 7 18:03:15 2010 @@ -1,5 +1,4 @@ import parser -import os import unittest import sys from test import test_support Modified: python/trunk/Lib/test/test_pdb.py ============================================================================== --- python/trunk/Lib/test/test_pdb.py (original) +++ python/trunk/Lib/test/test_pdb.py Sun Feb 7 18:03:15 2010 @@ -2,10 +2,7 @@ # specified test modules (RFE #5142). import imp -import os import sys -import doctest -import tempfile from test import test_support # This little helper class is essential for testing pdb under doctest. Modified: python/trunk/Lib/test/test_print.py ============================================================================== --- python/trunk/Lib/test/test_print.py (original) +++ python/trunk/Lib/test/test_print.py Sun Feb 7 18:03:15 2010 @@ -8,7 +8,6 @@ import unittest from test import test_support -import sys from StringIO import StringIO NotDefined = object() Modified: python/trunk/Lib/test/test_profile.py ============================================================================== --- python/trunk/Lib/test/test_profile.py (original) +++ python/trunk/Lib/test/test_profile.py Sun Feb 7 18:03:15 2010 @@ -1,6 +1,5 @@ """Test suite for the profile module.""" -import os import sys import pstats import unittest Modified: python/trunk/Lib/test/test_pyexpat.py ============================================================================== --- python/trunk/Lib/test/test_pyexpat.py (original) +++ python/trunk/Lib/test/test_pyexpat.py Sun Feb 7 18:03:15 2010 @@ -4,7 +4,6 @@ import StringIO, sys import unittest -import pyexpat from xml.parsers import expat from test.test_support import sortdict, run_unittest Modified: python/trunk/Lib/test/test_queue.py ============================================================================== --- python/trunk/Lib/test/test_queue.py (original) +++ python/trunk/Lib/test/test_queue.py Sun Feb 7 18:03:15 2010 @@ -1,7 +1,6 @@ # Some simple queue module tests, plus some failure conditions # to ensure the Queue locks remain stable. import Queue -import sys import threading import time import unittest Modified: python/trunk/Lib/test/test_random.py ============================================================================== --- python/trunk/Lib/test/test_random.py (original) +++ python/trunk/Lib/test/test_random.py Sun Feb 7 18:03:15 2010 @@ -5,7 +5,7 @@ import time import pickle import warnings -from math import log, exp, sqrt, pi, fsum, sin +from math import log, exp, pi, fsum, sin from functools import reduce from test import test_support Modified: python/trunk/Lib/test/test_re.py ============================================================================== --- python/trunk/Lib/test/test_re.py (original) +++ python/trunk/Lib/test/test_re.py Sun Feb 7 18:03:15 2010 @@ -1,7 +1,7 @@ from test.test_support import verbose, run_unittest import re from re import Scanner -import sys, os, traceback +import sys, traceback from weakref import proxy # Misc tests from Tim Peters' re.doc @@ -715,7 +715,7 @@ self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow]) def run_re_tests(): - from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR + from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR if verbose: print 'Running re_tests test suite' else: Modified: python/trunk/Lib/test/test_set.py ============================================================================== --- python/trunk/Lib/test/test_set.py (original) +++ python/trunk/Lib/test/test_set.py Sun Feb 7 18:03:15 2010 @@ -5,7 +5,6 @@ import operator import copy import pickle -import os from random import randrange, shuffle import sys import collections @@ -1694,7 +1693,6 @@ #============================================================================== def test_main(verbose=None): - from test import test_sets test_classes = ( TestSet, TestSetSubclass, Modified: python/trunk/Lib/test/test_socketserver.py ============================================================================== --- python/trunk/Lib/test/test_socketserver.py (original) +++ python/trunk/Lib/test/test_socketserver.py Sun Feb 7 18:03:15 2010 @@ -3,7 +3,6 @@ """ import contextlib -import errno import imp import os import select @@ -11,13 +10,11 @@ import socket import tempfile import threading -import time import unittest import SocketServer import test.test_support from test.test_support import reap_children, reap_threads, verbose -from test.test_support import TESTFN as TEST_FILE test.test_support.requires("network") Modified: python/trunk/Lib/test/test_sqlite.py ============================================================================== --- python/trunk/Lib/test/test_sqlite.py (original) +++ python/trunk/Lib/test/test_sqlite.py Sun Feb 7 18:03:15 2010 @@ -1,4 +1,3 @@ -import unittest from test.test_support import run_unittest, import_module # Skip test if _sqlite3 module was not built. Modified: python/trunk/Lib/test/test_ssl.py ============================================================================== --- python/trunk/Lib/test/test_ssl.py (original) +++ python/trunk/Lib/test/test_ssl.py Sun Feb 7 18:03:15 2010 @@ -6,13 +6,10 @@ import asyncore import socket import select -import errno -import subprocess import time import os import pprint import urllib, urlparse -import shutil import traceback from BaseHTTPServer import HTTPServer Modified: python/trunk/Lib/test/test_strftime.py ============================================================================== --- python/trunk/Lib/test/test_strftime.py (original) +++ python/trunk/Lib/test/test_strftime.py Sun Feb 7 18:03:15 2010 @@ -4,7 +4,6 @@ import calendar import sys -import os import re from test import test_support import time Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Sun Feb 7 18:03:15 2010 @@ -6,7 +6,7 @@ DeprecationWarning) from functools import wraps -from test.test_support import TestFailed, verbose, run_unittest +from test.test_support import run_unittest import sys ISBIGENDIAN = sys.byteorder == "big" Modified: python/trunk/Lib/test/test_structmembers.py ============================================================================== --- python/trunk/Lib/test/test_structmembers.py (original) +++ python/trunk/Lib/test/test_structmembers.py Sun Feb 7 18:03:15 2010 @@ -5,7 +5,7 @@ LONG_MAX, LONG_MIN, ULONG_MAX, \ LLONG_MAX, LLONG_MIN, ULLONG_MAX -import warnings, exceptions, unittest, sys +import unittest from test import test_support ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8, Modified: python/trunk/Lib/test/test_sys.py ============================================================================== --- python/trunk/Lib/test/test_sys.py (original) +++ python/trunk/Lib/test/test_sys.py Sun Feb 7 18:03:15 2010 @@ -1,6 +1,6 @@ # -*- coding: iso-8859-1 -*- import unittest, test.test_support -import sys, cStringIO, os +import sys, os, cStringIO import struct import operator @@ -415,7 +415,7 @@ sys._clear_type_cache() def test_ioencoding(self): - import subprocess,os + import subprocess env = dict(os.environ) # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424, Modified: python/trunk/Lib/test/test_sysconfig.py ============================================================================== --- python/trunk/Lib/test/test_sysconfig.py (original) +++ python/trunk/Lib/test/test_sysconfig.py Sun Feb 7 18:03:15 2010 @@ -6,7 +6,6 @@ """ import unittest import sys -import test import os import shutil from copy import copy, deepcopy @@ -80,7 +79,7 @@ return self._uname def _cleanup_testfn(self): - path = test.test_support.TESTFN + path = TESTFN if os.path.isfile(path): os.remove(path) elif os.path.isdir(path): Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Sun Feb 7 18:03:15 2010 @@ -3,7 +3,6 @@ import sys import os import shutil -import tempfile import StringIO from hashlib import md5 import errno Modified: python/trunk/Lib/test/test_tempfile.py ============================================================================== --- python/trunk/Lib/test/test_tempfile.py (original) +++ python/trunk/Lib/test/test_tempfile.py Sun Feb 7 18:03:15 2010 @@ -3,7 +3,6 @@ import os import sys import re -import errno import warnings import unittest Modified: python/trunk/Lib/test/test_tk.py ============================================================================== --- python/trunk/Lib/test/test_tk.py (original) +++ python/trunk/Lib/test/test_tk.py Sun Feb 7 18:03:15 2010 @@ -1,5 +1,4 @@ import os -import sys import unittest from test import test_support Modified: python/trunk/Lib/test/test_tokenize.py ============================================================================== --- python/trunk/Lib/test/test_tokenize.py (original) +++ python/trunk/Lib/test/test_tokenize.py Sun Feb 7 18:03:15 2010 @@ -529,7 +529,7 @@ from test import test_support -from tokenize import (tokenize, untokenize, generate_tokens, NUMBER, NAME, OP, +from tokenize import (untokenize, generate_tokens, NUMBER, NAME, OP, STRING, ENDMARKER, tok_name) from StringIO import StringIO import os Modified: python/trunk/Lib/test/test_traceback.py ============================================================================== --- python/trunk/Lib/test/test_traceback.py (original) +++ python/trunk/Lib/test/test_traceback.py Sun Feb 7 18:03:15 2010 @@ -67,7 +67,7 @@ self.assertTrue(err[1].find("2") == err[2].find("^")) def test_bug737473(self): - import sys, os, tempfile, time + import os, tempfile, time savedpath = sys.path[:] testdir = tempfile.mkdtemp() Modified: python/trunk/Lib/test/test_ttk_guionly.py ============================================================================== --- python/trunk/Lib/test/test_ttk_guionly.py (original) +++ python/trunk/Lib/test/test_ttk_guionly.py Sun Feb 7 18:03:15 2010 @@ -1,5 +1,4 @@ import os -import sys import unittest from test import test_support Modified: python/trunk/Lib/test/test_ttk_textonly.py ============================================================================== --- python/trunk/Lib/test/test_ttk_textonly.py (original) +++ python/trunk/Lib/test/test_ttk_textonly.py Sun Feb 7 18:03:15 2010 @@ -1,5 +1,4 @@ import os -import sys from test import test_support # Skip this test if _tkinter does not exist. Modified: python/trunk/Lib/test/test_types.py ============================================================================== --- python/trunk/Lib/test/test_types.py (original) +++ python/trunk/Lib/test/test_types.py Sun Feb 7 18:03:15 2010 @@ -20,7 +20,6 @@ if not {'x': 1}: self.fail('{\'x\': 1} is false instead of true') def f(): pass class C: pass - import sys x = C() if not f: self.fail('f is false instead of true') if not C: self.fail('C is false instead of true') Modified: python/trunk/Lib/test/test_undocumented_details.py ============================================================================== --- python/trunk/Lib/test/test_undocumented_details.py (original) +++ python/trunk/Lib/test/test_undocumented_details.py Sun Feb 7 18:03:15 2010 @@ -1,6 +1,5 @@ -from test.test_support import run_unittest, have_unicode +from test.test_support import run_unittest import unittest -import sys class TestImplementationComparisons(unittest.TestCase): Modified: python/trunk/Lib/test/test_urllib2net.py ============================================================================== --- python/trunk/Lib/test/test_urllib2net.py (original) +++ python/trunk/Lib/test/test_urllib2net.py Sun Feb 7 18:03:15 2010 @@ -6,9 +6,7 @@ import socket import urllib2 -import sys import os -import mimetools def _retry_thrice(func, exc, *args, **kwargs): @@ -73,7 +71,7 @@ class CloseSocketTest(unittest.TestCase): def test_close(self): - import socket, httplib, gc + import httplib # calling .close() on urllib2's response objects should close the # underlying socket @@ -154,7 +152,6 @@ ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def _test_urls(self, urls, handlers, retry=True): - import socket import time import logging debug = logging.getLogger("test_urllib2").debug Modified: python/trunk/Lib/test/test_xml_etree.py ============================================================================== --- python/trunk/Lib/test/test_xml_etree.py (original) +++ python/trunk/Lib/test/test_xml_etree.py Sun Feb 7 18:03:15 2010 @@ -2,7 +2,6 @@ # all included components work as they should. For a more extensive # test suite, see the selftest script in the ElementTree distribution. -import doctest import sys from test import test_support Modified: python/trunk/Lib/test/test_xml_etree_c.py ============================================================================== --- python/trunk/Lib/test/test_xml_etree_c.py (original) +++ python/trunk/Lib/test/test_xml_etree_c.py Sun Feb 7 18:03:15 2010 @@ -1,6 +1,5 @@ # xml.etree test for cElementTree -import doctest import sys from test import test_support Modified: python/trunk/Lib/test/test_zipimport_support.py ============================================================================== --- python/trunk/Lib/test/test_zipimport_support.py (original) +++ python/trunk/Lib/test/test_zipimport_support.py Sun Feb 7 18:03:15 2010 @@ -2,7 +2,6 @@ # for working with modules located inside zipfiles # The tests are centralised in this fashion to make it easy to drop them # if a platform doesn't support zipimport -import unittest import test.test_support import os import os.path @@ -15,8 +14,7 @@ import linecache import pdb from test.script_helper import (spawn_python, kill_python, run_python, - temp_dir, make_script, compile_script, - make_pkg, make_zip_script, make_zip_pkg) + temp_dir, make_script, make_zip_script) verbose = test.test_support.verbose From python-checkins at python.org Sun Feb 7 19:44:13 2010 From: python-checkins at python.org (michael.foord) Date: Sun, 07 Feb 2010 18:44:13 -0000 Subject: [Python-checkins] r78094 - in python/trunk/Lib: test/test_unittest.py unittest/case.py Message-ID: Author: michael.foord Date: Sun Feb 7 19:44:12 2010 New Revision: 78094 Log: assertRaises as context manager now allows you to access exception as documented Modified: python/trunk/Lib/test/test_unittest.py python/trunk/Lib/unittest/case.py Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Sun Feb 7 19:44:12 2010 @@ -3059,8 +3059,13 @@ pass else: self.fail("assertRaises() didn't let exception pass through") - with self.assertRaises(KeyError): - raise KeyError + with self.assertRaises(KeyError) as cm: + try: + raise KeyError + except Exception, e: + raise + self.assertIs(cm.exception, e) + with self.assertRaises(KeyError): raise KeyError("key") try: Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Sun Feb 7 19:44:12 2010 @@ -91,7 +91,7 @@ self.expected_regexp = expected_regexp def __enter__(self): - pass + return self def __exit__(self, exc_type, exc_value, tb): if exc_type is None: From python-checkins at python.org Sun Feb 7 20:56:40 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 19:56:40 -0000 Subject: [Python-checkins] r78095 - in python/branches/py3k: Mac/Makefile.in Mac/Tools/pythonw.c Modules/posixmodule.c configure configure.in pyconfig.h.in Message-ID: Author: ronald.oussoren Date: Sun Feb 7 20:56:39 2010 New Revision: 78095 Log: Forward port a number of OSX bugfixes from the trunk to 3.2 Modified: python/branches/py3k/Mac/Makefile.in python/branches/py3k/Mac/Tools/pythonw.c python/branches/py3k/Modules/posixmodule.c python/branches/py3k/configure python/branches/py3k/configure.in python/branches/py3k/pyconfig.h.in Modified: python/branches/py3k/Mac/Makefile.in ============================================================================== --- python/branches/py3k/Mac/Makefile.in (original) +++ python/branches/py3k/Mac/Makefile.in Sun Feb 7 20:56:39 2010 @@ -16,6 +16,7 @@ PYTHONFRAMEWORK=@PYTHONFRAMEWORK@ PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@ LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@ +CC=@CC@ # These are normally glimpsed from the previous set Modified: python/branches/py3k/Mac/Tools/pythonw.c ============================================================================== --- python/branches/py3k/Mac/Tools/pythonw.c (original) +++ python/branches/py3k/Mac/Tools/pythonw.c Sun Feb 7 20:56:39 2010 @@ -6,9 +6,21 @@ * * This program uses posix_spawn rather than plain execv because we need * slightly more control over how the "real" interpreter is executed. + * + * On OSX 10.4 (and earlier) this falls back to using exec because the + * posix_spawnv functions aren't available there. */ + +#pragma weak_import posix_spawnattr_init +#pragma weak_import posix_spawnattr_setbinpref_np +#pragma weak_import posix_spawnattr_setflags +#pragma weak_import posix_spawn + +#include #include +#ifdef HAVE_SPAWN_H #include +#endif #include #include #include @@ -74,6 +86,7 @@ return g_path; } +#ifdef HAVE_SPAWN_H static void setup_spawnattr(posix_spawnattr_t* spawnattr) { @@ -132,16 +145,26 @@ /* NOTREACHTED */ } } +#endif int main(int argc, char **argv) { - posix_spawnattr_t spawnattr = NULL; char* exec_path = get_python_path(); +#ifdef HAVE_SPAWN_H + /* We're weak-linking to posix-spawnv to ensure that + * an executable build on 10.5 can work on 10.4. + */ + if (posix_spawn != NULL) { + posix_spawnattr_t spawnattr = NULL; - setup_spawnattr(&spawnattr); - posix_spawn(NULL, exec_path, NULL, - &spawnattr, argv, environ); - err(1, "posix_spawn: %s", argv[0]); + setup_spawnattr(&spawnattr); + posix_spawn(NULL, exec_path, NULL, + &spawnattr, argv, environ); + err(1, "posix_spawn: %s", argv[0]); + } +#endif + execve(exec_path, argv, environ); + err(1, "execve: %s", argv[0]); /* NOTREACHED */ } Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Sun Feb 7 20:56:39 2010 @@ -3785,6 +3785,10 @@ #else #ifdef HAVE_LIBUTIL_H #include +#else +#ifdef HAVE_UTIL_H +#include +#endif /* HAVE_UTIL_H */ #endif /* HAVE_LIBUTIL_H */ #endif /* HAVE_PTY_H */ #ifdef HAVE_STROPTS_H Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Sun Feb 7 20:56:39 2010 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 78066 . +# From configure.in Revision: 78073 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -4640,6 +4640,38 @@ ARCH_RUN_32BIT="" LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + # You have to use different flags on various versions of + # OSX to extract PPC code from an universal binary, basically + # '-arch ppc' on OSX 10.4 and '-arch ppc7400' on anything + # newer. + # Because '-arch pp7400' works on OSX 10.5 or higher this + # test is only present in the '32-bit' branch, all other + # branches require OSX 10.5 to compile. + + { echo "$as_me:$LINENO: checking lipo flag for extracting ppc code" >&5 +echo $ECHO_N "checking lipo flag for extracting ppc code... $ECHO_C" >&6; } + FN="test.$$" + cat >${FN}.c <<-EOF + int main() { return 0; } +EOF + ${CC} ${CFLAGS} -arch ppc -arch i386 -o ${FN} ${FN}.c -isysroot ${UNIVERSALSDK} + if test $? != 0 ; then + rm ${FN} ${FN}.c + { echo "$as_me:$LINENO: result: failed, assumee -extract ppc7400" >&5 +echo "${ECHO_T}failed, assumee -extract ppc7400" >&6; } + else + lipo "${FN}" -extract ppc7400 -output "${FN}.out" 2>/dev/null + if test $? != 0 ; then + LIPO_32BIT_FLAGS="-extract ppc -extract i386" + { echo "$as_me:$LINENO: result: \"'-extract ppc'\"" >&5 +echo "${ECHO_T}\"'-extract ppc'\"" >&6; } + else + { echo "$as_me:$LINENO: result: \"'-extract ppc7400'\"" >&5 +echo "${ECHO_T}\"'-extract ppc7400'\"" >&6; } + fi + rm -f ${FN} ${FN}.c ${FN}.out + fi + elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" LIPO_32BIT_FLAGS="" @@ -5589,6 +5621,8 @@ + + for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ @@ -5600,7 +5634,7 @@ sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ -bluetooth/bluetooth.h linux/tipc.h +bluetooth/bluetooth.h linux/tipc.h spawn.h util.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Sun Feb 7 20:56:39 2010 @@ -898,6 +898,34 @@ ARCH_RUN_32BIT="" LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + # You have to use different flags on various versions of + # OSX to extract PPC code from an universal binary, basically + # '-arch ppc' on OSX 10.4 and '-arch ppc7400' on anything + # newer. + # Because '-arch pp7400' works on OSX 10.5 or higher this + # test is only present in the '32-bit' branch, all other + # branches require OSX 10.5 to compile. + + AC_MSG_CHECKING(lipo flag for extracting ppc code) + FN="test.$$" + cat >${FN}.c <<-EOF + int main() { return 0; } +EOF + ${CC} ${CFLAGS} -arch ppc -arch i386 -o ${FN} ${FN}.c -isysroot ${UNIVERSALSDK} + if test $? != 0 ; then + rm ${FN} ${FN}.c + AC_MSG_RESULT([failed, assumee -extract ppc7400]) + else + lipo "${FN}" -extract ppc7400 -output "${FN}.out" 2>/dev/null + if test $? != 0 ; then + LIPO_32BIT_FLAGS="-extract ppc -extract i386" + AC_MSG_RESULT("'-extract ppc'") + else + AC_MSG_RESULT("'-extract ppc7400'") + fi + rm -f ${FN} ${FN}.c ${FN}.out + fi + elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" LIPO_32BIT_FLAGS="" @@ -1251,7 +1279,7 @@ sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ -bluetooth/bluetooth.h linux/tipc.h) +bluetooth/bluetooth.h linux/tipc.h spawn.h util.h) AC_HEADER_DIRENT AC_HEADER_MAJOR Modified: python/branches/py3k/pyconfig.h.in ============================================================================== --- python/branches/py3k/pyconfig.h.in (original) +++ python/branches/py3k/pyconfig.h.in Sun Feb 7 20:56:39 2010 @@ -632,6 +632,9 @@ /* Define if you have the 'socketpair' function. */ #undef HAVE_SOCKETPAIR +/* Define to 1 if you have the header file. */ +#undef HAVE_SPAWN_H + /* Define if your compiler provides ssize_t */ #undef HAVE_SSIZE_T @@ -850,6 +853,9 @@ Include/unicodeobject.h). */ #undef HAVE_USABLE_WCHAR_T +/* Define to 1 if you have the header file. */ +#undef HAVE_UTIL_H + /* Define to 1 if you have the `utimes' function. */ #undef HAVE_UTIMES From python-checkins at python.org Sun Feb 7 21:04:45 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 20:04:45 -0000 Subject: [Python-checkins] r78096 - in python/branches/release26-maint: Doc/library/readline.rst Misc/NEWS Modules/readline.c setup.py Message-ID: Author: ronald.oussoren Date: Sun Feb 7 21:04:45 2010 New Revision: 78096 Log: Backport the patch that enables linking the readline module to libedit on OSX 10.5 or later. (Issue 6877) Modified: python/branches/release26-maint/Doc/library/readline.rst python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Modules/readline.c python/branches/release26-maint/setup.py Modified: python/branches/release26-maint/Doc/library/readline.rst ============================================================================== --- python/branches/release26-maint/Doc/library/readline.rst (original) +++ python/branches/release26-maint/Doc/library/readline.rst Sun Feb 7 21:04:45 2010 @@ -14,6 +14,17 @@ interactive prompt and the prompts offered by the :func:`raw_input` and :func:`input` built-in functions. +..note:: + + On MacOS X the :mod:`readline` module can be implemented using + the ``libedit`` library instead of GNU readline. + + The configuration file for ``libedit`` is different from that + of GNU readline. If you programmaticly load configuration strings + you can check for the text "libedit" in :const:`readline.__doc__` + to differentiate between GNU readline and libedit. + + The :mod:`readline` module defines the following functions: @@ -181,7 +192,6 @@ Append a line to the history buffer, as if it was the last line typed. - .. seealso:: Module :mod:`rlcompleter` Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sun Feb 7 21:04:45 2010 @@ -203,6 +203,9 @@ Extension Modules ----------------- +- Issue #6877: Make it possible to link the readline extension to libedit + on OSX. + - Expat: Fix DoS via XML document with malformed UTF-8 sequences (CVE_2009_3560). Modified: python/branches/release26-maint/Modules/readline.c ============================================================================== --- python/branches/release26-maint/Modules/readline.c (original) +++ python/branches/release26-maint/Modules/readline.c Sun Feb 7 21:04:45 2010 @@ -38,9 +38,30 @@ #if defined(_RL_FUNCTION_TYPEDEF) extern char **completion_matches(char *, rl_compentry_func_t *); #else +#if !defined(__APPLE__) extern char **completion_matches(char *, CPFunction *); #endif #endif +#endif + +#ifdef __APPLE__ +/* + * It is possible to link the readline module to the readline + * emulation library of editline/libedit. + * + * On OSX this emulation library is not 100% API compatible + * with the "real" readline and cannot be detected at compile-time, + * hence we use a runtime check to detect if we're using libedit + * + * Currently there is one know API incompatibility: + * - 'get_history' has a 1-based index with GNU readline, and a 0-based + * index with libedit's emulation. + * - Note that replace_history and remove_history use a 0-based index + * with both implementation. + */ +static int using_libedit_emulation = 0; +static const char libedit_version_tag[] = "EditLine wrapper"; +#endif /* __APPLE__ */ static void on_completion_display_matches_hook(char **matches, @@ -478,6 +499,29 @@ if (!PyArg_ParseTuple(args, "i:index", &idx)) return NULL; +#ifdef __APPLE__ + if (using_libedit_emulation) { + /* Libedit emulation uses 0-based indexes, + * the real one uses 1-based indexes, + * adjust the index to ensure that Python + * code doesn't have to worry about the + * difference. + */ + HISTORY_STATE *hist_st; + hist_st = history_get_history_state(); + + idx --; + + /* + * Apple's readline emulation crashes when + * the index is out of range, therefore + * test for that and fail gracefully. + */ + if (idx < 0 || idx >= hist_st->length) { + Py_RETURN_NONE; + } + } +#endif /* __APPLE__ */ if ((hist_ent = history_get(idx))) return PyString_FromString(hist_ent->line); else { @@ -981,6 +1025,15 @@ char *line; HISTORY_STATE *state = history_get_history_state(); if (state->length > 0) +#ifdef __APPLE__ + if (using_libedit_emulation) { + /* + * Libedit's emulation uses 0-based indexes, + * the real readline uses 1-based indexes. + */ + line = history_get(state->length - 1)->line; + } else +#endif /* __APPLE__ */ line = history_get(state->length)->line; else line = ""; @@ -1014,16 +1067,35 @@ PyDoc_STRVAR(doc_module, "Importing this module enables command line editing using GNU readline."); +#ifdef __APPLE__ +PyDoc_STRVAR(doc_module_le, +"Importing this module enables command line editing using libedit readline."); +#endif /* __APPLE__ */ + PyMODINIT_FUNC initreadline(void) { PyObject *m; +#ifdef __APPLE__ + if (strncmp(rl_library_version, libedit_version_tag, strlen(libedit_version_tag)) == 0) { + using_libedit_emulation = 1; + } + + if (using_libedit_emulation) + m = Py_InitModule4("readline", readline_methods, doc_module_le, + (PyObject *)NULL, PYTHON_API_VERSION); + else + +#endif /* __APPLE__ */ + m = Py_InitModule4("readline", readline_methods, doc_module, (PyObject *)NULL, PYTHON_API_VERSION); if (m == NULL) return; + + PyOS_ReadlineFunctionPointer = call_readline; setup_readline(); } Modified: python/branches/release26-maint/setup.py ============================================================================== --- python/branches/release26-maint/setup.py (original) +++ python/branches/release26-maint/setup.py Sun Feb 7 21:04:45 2010 @@ -556,16 +556,16 @@ # readline do_readline = self.compiler.find_library_file(lib_dirs, 'readline') - if platform == 'darwin': # and os.uname()[2] < '9.': - # MacOSX 10.4 has a broken readline. Don't try to build - # the readline module unless the user has installed a fixed - # readline package - # FIXME: The readline emulation on 10.5 is better, but the - # readline module doesn't compile out of the box. - if find_file('readline/rlconf.h', inc_dirs, []) is None: - do_readline = False + if platform == 'darwin': + os_release = int(os.uname()[2].split('.')[0]) + if os_release < 9: + # MacOSX 10.4 has a broken readline. Don't try to build + # the readline module unless the user has installed a fixed + # readline package + if find_file('readline/rlconf.h', inc_dirs, []) is None: + do_readline = False if do_readline: - if sys.platform == 'darwin': + if platform == 'darwin' and os_release < 9: # In every directory on the search path search for a dynamic # library and then a static library, instead of first looking # for dynamic libraries on the entiry path. From python-checkins at python.org Sun Feb 7 21:18:03 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 20:18:03 -0000 Subject: [Python-checkins] r78097 - in python/trunk: Doc/library/zipfile.rst Lib/test/test_zipfile.py Lib/zipfile.py Misc/NEWS Message-ID: Author: ronald.oussoren Date: Sun Feb 7 21:18:02 2010 New Revision: 78097 Log: Issue 6003: ZipFile.writestr "compression_type" argument Modified: python/trunk/Doc/library/zipfile.rst python/trunk/Lib/test/test_zipfile.py python/trunk/Lib/zipfile.py python/trunk/Misc/NEWS Modified: python/trunk/Doc/library/zipfile.rst ============================================================================== --- python/trunk/Doc/library/zipfile.rst (original) +++ python/trunk/Doc/library/zipfile.rst Sun Feb 7 21:18:02 2010 @@ -284,7 +284,7 @@ byte, the name of the file in the archive will be truncated at the null byte. -.. method:: ZipFile.writestr(zinfo_or_arcname, bytes) +.. method:: ZipFile.writestr(zinfo_or_arcname, bytes[, compress_type]) Write the string *bytes* to the archive; *zinfo_or_arcname* is either the file name it will be given in the archive, or a :class:`ZipInfo` instance. If it's @@ -294,6 +294,10 @@ created with mode ``'r'`` will raise a :exc:`RuntimeError`. Calling :meth:`writestr` on a closed ZipFile will raise a :exc:`RuntimeError`. + If given, *compress_type* overrides the value given for the *compression* + parameter to the constructor for the new entry, or in the *zinfo_or_arcname* + (if that is a :class:`ZipInfo` instance). + .. note:: When passing a :class:`ZipInfo` instance as the *zinfo_or_acrname* parameter, @@ -301,6 +305,9 @@ member of the given :class:`ZipInfo` instance. By default, the :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`. + .. versionchanged:: 2.7 + The *compression_type* argument. + The following data attributes are also available: Modified: python/trunk/Lib/test/test_zipfile.py ============================================================================== --- python/trunk/Lib/test/test_zipfile.py (original) +++ python/trunk/Lib/test/test_zipfile.py Sun Feb 7 21:18:02 2010 @@ -408,6 +408,20 @@ # remove the test file subdirectories shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) + def test_writestr_compression(self): + zipfp = zipfile.ZipFile(TESTFN2, "w") + zipfp.writestr("a.txt", "hello world", compress_type=zipfile.ZIP_STORED) + if zlib: + zipfp.writestr("b.txt", "hello world", compress_type=zipfile.ZIP_DEFLATED) + + info = zipfp.getinfo('a.txt') + self.assertEqual(info.compress_type, zipfile.ZIP_STORED) + + if zlib: + info = zipfp.getinfo('b.txt') + self.assertEqual(info.compress_type, zipfile.ZIP_DEFLATED) + + def zip_test_writestr_permissions(self, f, compression): # Make sure that writestr creates files with mode 0600, # when it is passed a name rather than a ZipInfo instance. Modified: python/trunk/Lib/zipfile.py ============================================================================== --- python/trunk/Lib/zipfile.py (original) +++ python/trunk/Lib/zipfile.py Sun Feb 7 21:18:02 2010 @@ -1063,13 +1063,14 @@ self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo - def writestr(self, zinfo_or_arcname, bytes): + def writestr(self, zinfo_or_arcname, bytes, compress_type=None): """Write a file into the archive. The contents is the string 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or the name of the file in the archive.""" if not isinstance(zinfo_or_arcname, ZipInfo): zinfo = ZipInfo(filename=zinfo_or_arcname, date_time=time.localtime(time.time())[:6]) + zinfo.compress_type = self.compression zinfo.external_attr = 0600 << 16 else: @@ -1079,6 +1080,9 @@ raise RuntimeError( "Attempt to write to ZIP archive that was already closed") + if compress_type is not None: + zinfo.compress_type = compress_type + zinfo.file_size = len(bytes) # Uncompressed size zinfo.header_offset = self.fp.tell() # Start of header bytes self._writecheck(zinfo) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Feb 7 21:18:02 2010 @@ -15,6 +15,9 @@ Library ------- +- Issue #6003: add an argument to ``zipfile.Zipfile.writestr`` to + specify the compression type. + What's New in Python 2.7 alpha 3? ================================= From python-checkins at python.org Sun Feb 7 21:24:02 2010 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 07 Feb 2010 20:24:02 -0000 Subject: [Python-checkins] r78098 - in python/branches/py3k: Doc/library/zipfile.rst Lib/test/test_zipfile.py Lib/zipfile.py Misc/NEWS Message-ID: Author: ronald.oussoren Date: Sun Feb 7 21:24:02 2010 New Revision: 78098 Log: Merged revisions 78097 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78097 | ronald.oussoren | 2010-02-07 21:18:02 +0100 (Sun, 07 Feb 2010) | 2 lines Issue 6003: ZipFile.writestr "compression_type" argument ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/zipfile.rst python/branches/py3k/Lib/test/test_zipfile.py python/branches/py3k/Lib/zipfile.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Doc/library/zipfile.rst ============================================================================== --- python/branches/py3k/Doc/library/zipfile.rst (original) +++ python/branches/py3k/Doc/library/zipfile.rst Sun Feb 7 21:24:02 2010 @@ -267,7 +267,7 @@ byte, the name of the file in the archive will be truncated at the null byte. -.. method:: ZipFile.writestr(zinfo_or_arcname, bytes) +.. method:: ZipFile.writestr(zinfo_or_arcname, bytes[, compress_type]) Write the string *bytes* to the archive; *zinfo_or_arcname* is either the file name it will be given in the archive, or a :class:`ZipInfo` instance. If it's @@ -277,6 +277,10 @@ created with mode ``'r'`` will raise a :exc:`RuntimeError`. Calling :meth:`writestr` on a closed ZipFile will raise a :exc:`RuntimeError`. + If given, *compress_type* overrides the value given for the *compression* + parameter to the constructor for the new entry, or in the *zinfo_or_arcname* + (if that is a :class:`ZipInfo` instance). + .. note:: When passing a :class:`ZipInfo` instance as the *zinfo_or_acrname* parameter, @@ -284,6 +288,9 @@ member of the given :class:`ZipInfo` instance. By default, the :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`. + .. versionchanged:: 2.7 + The *compression_type* argument. + The following data attributes are also available: Modified: python/branches/py3k/Lib/test/test_zipfile.py ============================================================================== --- python/branches/py3k/Lib/test/test_zipfile.py (original) +++ python/branches/py3k/Lib/test/test_zipfile.py Sun Feb 7 21:24:02 2010 @@ -407,6 +407,20 @@ # remove the test file subdirectories shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) + def test_writestr_compression(self): + zipfp = zipfile.ZipFile(TESTFN2, "w") + zipfp.writestr("a.txt", "hello world", compress_type=zipfile.ZIP_STORED) + if zlib: + zipfp.writestr("b.txt", "hello world", compress_type=zipfile.ZIP_DEFLATED) + + info = zipfp.getinfo('a.txt') + self.assertEqual(info.compress_type, zipfile.ZIP_STORED) + + if zlib: + info = zipfp.getinfo('b.txt') + self.assertEqual(info.compress_type, zipfile.ZIP_DEFLATED) + + def zip_test_writestr_permissions(self, f, compression): # Make sure that writestr creates files with mode 0600, # when it is passed a name rather than a ZipInfo instance. Modified: python/branches/py3k/Lib/zipfile.py ============================================================================== --- python/branches/py3k/Lib/zipfile.py (original) +++ python/branches/py3k/Lib/zipfile.py Sun Feb 7 21:24:02 2010 @@ -1065,7 +1065,7 @@ self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo - def writestr(self, zinfo_or_arcname, data): + def writestr(self, zinfo_or_arcname, data, compress_type=None): """Write a file into the archive. The contents is 'data', which may be either a 'str' or a 'bytes' instance; if it is a 'str', it is encoded as UTF-8 first. @@ -1087,6 +1087,9 @@ zinfo.file_size = len(data) # Uncompressed size zinfo.header_offset = self.fp.tell() # Start of header data + if compress_type is not None: + zinfo.compress_type = compress_type + self._writecheck(zinfo) self._didModify = True zinfo.CRC = crc32(data) & 0xffffffff # CRC-32 checksum Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sun Feb 7 21:24:02 2010 @@ -242,6 +242,9 @@ Library ------- +- Issue #6003: add an argument to ``zipfile.Zipfile.writestr`` to + specify the compression type. + - Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is specified, rather than fall through to AF_PACKET (in the `socket` module). Also, raise ValueError rather than TypeError when an unknown TIPC address From python-checkins at python.org Sun Feb 7 21:31:10 2010 From: python-checkins at python.org (mark.dickinson) Date: Sun, 07 Feb 2010 20:31:10 -0000 Subject: [Python-checkins] r78099 - python/trunk/Lib/test/test_strtod.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 21:31:10 2010 New Revision: 78099 Log: Skip test_strtod entirely when correctly-rounded string->float isn't implemented Modified: python/trunk/Lib/test/test_strtod.py Modified: python/trunk/Lib/test/test_strtod.py ============================================================================== --- python/trunk/Lib/test/test_strtod.py (original) +++ python/trunk/Lib/test/test_strtod.py Sun Feb 7 21:31:10 2010 @@ -8,6 +8,10 @@ import sys from test import test_support +if getattr(sys, 'float_repr_style', '') != 'short': + raise unittest.SkipTest('correctly-rounded string->float conversions ' + 'not available on this system') + # Correctly rounded str -> float in pure Python, for comparison. strtod_parser = re.compile(r""" # A numeric string consists of: @@ -78,8 +82,6 @@ TEST_SIZE = 16 - at unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short', - "applies only when using short float repr style") class StrtodTests(unittest.TestCase): def check_strtod(self, s): """Compare the result of Python's builtin correctly rounded From python-checkins at python.org Sun Feb 7 21:32:50 2010 From: python-checkins at python.org (mark.dickinson) Date: Sun, 07 Feb 2010 20:32:50 -0000 Subject: [Python-checkins] r78100 - in python/branches/py3k: Lib/test/test_strtod.py Message-ID: Author: mark.dickinson Date: Sun Feb 7 21:32:50 2010 New Revision: 78100 Log: Merged revisions 78099 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78099 | mark.dickinson | 2010-02-07 20:31:10 +0000 (Sun, 07 Feb 2010) | 1 line Skip test_strtod entirely when correctly-rounded string->float isn't implemented ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_strtod.py Modified: python/branches/py3k/Lib/test/test_strtod.py ============================================================================== --- python/branches/py3k/Lib/test/test_strtod.py (original) +++ python/branches/py3k/Lib/test/test_strtod.py Sun Feb 7 21:32:50 2010 @@ -8,6 +8,10 @@ import sys import test.support +if getattr(sys, 'float_repr_style', '') != 'short': + raise unittest.SkipTest('correctly-rounded string->float conversions ' + 'not available on this system') + # Correctly rounded str -> float in pure Python, for comparison. strtod_parser = re.compile(r""" # A numeric string consists of: @@ -78,8 +82,6 @@ TEST_SIZE = 16 - at unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short', - "applies only when using short float repr style") class StrtodTests(unittest.TestCase): def check_strtod(self, s): """Compare the result of Python's builtin correctly rounded From solipsis at pitrou.net Mon Feb 8 01:04:00 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 8 Feb 2010 01:04:00 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r78100): sum=0 Message-ID: <20100208000400.F1B761770B@ns6635.ovh.net> py3k results for svn r78100 (hg cset 3a10967c2ef4) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogRRDMYX', '-x', 'test_httpservers'] From python-checkins at python.org Mon Feb 8 01:04:54 2010 From: python-checkins at python.org (georg.brandl) Date: Mon, 08 Feb 2010 00:04:54 -0000 Subject: [Python-checkins] r78101 - python/trunk/Lib/test/test_fnmatch.py Message-ID: Author: georg.brandl Date: Mon Feb 8 01:04:54 2010 New Revision: 78101 Log: Fix test_fnmatch. Modified: python/trunk/Lib/test/test_fnmatch.py Modified: python/trunk/Lib/test/test_fnmatch.py ============================================================================== --- python/trunk/Lib/test/test_fnmatch.py (original) +++ python/trunk/Lib/test/test_fnmatch.py Mon Feb 8 01:04:54 2010 @@ -7,13 +7,13 @@ class FnmatchTestCase(unittest.TestCase): - def check_match(self, filename, pattern, should_match=1): + def check_match(self, filename, pattern, should_match=1, fn=fnmatch): if should_match: - self.assertTrue(fnmatch(filename, pattern), + self.assertTrue(fn(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: - self.assertTrue(not fnmatch(filename, pattern), + self.assertTrue(not fn(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) @@ -46,8 +46,8 @@ def test_fnmatchcase(self): check = self.check_match - check('AbC', 'abc', 0) - check('abc', 'AbC', 0) + check('AbC', 'abc', 0, fnmatchcase) + check('abc', 'AbC', 0, fnmatchcase) def test_main(): From python-checkins at python.org Mon Feb 8 02:35:35 2010 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 08 Feb 2010 01:35:35 -0000 Subject: [Python-checkins] r78102 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: andrew.kuchling Date: Mon Feb 8 02:35:35 2010 New Revision: 78102 Log: Move distutils into its own subsection; add various items Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Mon Feb 8 02:35:35 2010 @@ -222,11 +222,60 @@ :pep:`378` - Format Specifier for Thousands Separator PEP written by Raymond Hettinger; implemented by Eric Smith. +PEP 391: Dictionary-Based Configuration For Logging +==================================================== + +XXX write this section. + +.. seealso:: + + :pep:`391` - Dictionary-Based Configuration For Logging + PEP written and implemented by Vinay Sajip. + +PEP 3106: Dictionary Views +==================================================== + +XXX write this section. + +.. seealso:: + + :pep:`3106` - Revamping dict.keys(), .values() and .items() + PEP written by Guido van Rossum. + Backported to 2.7 by Alexandre Vassalotti; :issue:`1967`. + + Other Language Changes ====================== Some smaller changes made to the core Python language are: +* The syntax for set literals has been backported from Python 3.x. + Curly brackets are used to surround the contents of the resulting + mutable set; set literals are + distinguished from dictionaries by not containing colons and values. + ``{}`` continues to represent an empty dictionary; use + ``set()`` for an empty set. + + >>> {1,2,3,4,5} + set([1, 2, 3, 4, 5]) + >>> set() + set([]) + >>> {} + {} + + Backported by Alexandre Vassalotti; :issue:`2335`. + +* Dictionary and set comprehensions are another feature backported from + 3.x, generalizing list/generator comprehensions to use + the literal syntax for sets and dictionaries. + + >>> {x:x*x for x in range(6)} + {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25} + >>> {'a'*x for x in range(6)} + set(['', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa']) + + Backported by Alexandre Vassalotti; :issue:`2333`. + * The :keyword:`with` statement can now use multiple context managers in one statement. Context managers are processed from left to right and each one is treated as beginning a new :keyword:`with` statement. @@ -375,6 +424,10 @@ Python3-warning mode, Python 2.7 will now warn about this odd usage. (Noted by James Lingard; :issue:`7362`.) +* When a module object is garbage-collected, the module's dictionary is + now only cleared if no one else is holding a reference to the + dictionary (:issue:`7140`). + .. ====================================================================== @@ -592,46 +645,6 @@ left-alignment. This has been changed to right-alignment, which seems more sensible for numeric types. (Changed by Mark Dickinson; :issue:`6857`.) -* Distutils is being more actively developed, thanks to Tarek Ziad? - who has taken over maintenance of the package, so there are a number - of fixes and improvments. - - A new :file:`setup.py` subcommand, ``check``, will check that the - arguments being passed to the :func:`setup` function are complete - and correct (:issue:`5732`). - - Byte-compilation by the ``install_lib`` subcommand is now only done - if the ``sys.dont_write_bytecode`` setting allows it (:issue:`7071`). - - :func:`distutils.sdist.add_defaults` now uses - *package_dir* and *data_files* to create the MANIFEST file. - :mod:`distutils.sysconfig` now reads the :envvar:`AR` and - :envvar:`ARFLAGS` environment variables. - - .. ARFLAGS done in #5941 - - It is no longer mandatory to store clear-text passwords in the - :file:`.pypirc` file when registering and uploading packages to PyPI. As long - as the username is present in that file, the :mod:`distutils` package will - prompt for the password if not present. (Added by Tarek Ziad?, - based on an initial contribution by Nathan Van Gheem; :issue:`4394`.) - - A Distutils setup can now specify that a C extension is optional by - setting the *optional* option setting to true. If this optional is - supplied, failure to build the extension will not abort the build - process, but instead simply not install the failing extension. - (Contributed by Georg Brandl; :issue:`5583`.) - - The :class:`distutils.dist.DistributionMetadata` class' - :meth:`read_pkg_file` method will read the contents of a package's - :file:`PKG-INFO` metadata file. For an example of its use, see - :ref:`reading-metadata`. - (Contributed by Tarek Ziad?; :issue:`7457`.) - - :file:`setup.py` files will now accept a :option:`--no-user-cfg` switch - to skip reading the :file:`~/.pydistutils.cfg` file. (Suggested by - by Michael Hoffman, and implemented by Paul Winkler; :issue:`1180`.) - * The :class:`Fraction` class now accepts two rational numbers as arguments to its constructor. (Implemented by Mark Dickinson; :issue:`5812`.) @@ -649,9 +662,12 @@ otherwise. (Contributed by Antoine Pitrou; :issue:`4688`.) * The :mod:`gzip` module's :class:`GzipFile` now supports the context - management protocol, so you can write ``with gzip.GzipFile(...) as f: ...``. - (Contributed by Hagen Fuerstenau; :issue:`3860`.) - It's now possible to override the modification time + management protocol, so you can write ``with gzip.GzipFile(...) as f: ...`` + (contributed by Hagen Fuerstenau; :issue:`3860`), and it now implements + the :class:`io.BufferedIOBase` ABC, so you can wrap it with + :class:`io.BufferedReader` for faster processing + (contributed by Nir Aides; :issue:`7471`). + It's also now possible to override the modification time recorded in a gzipped file by providing an optional timestamp to the constructor. (Contributed by Jacques Frechet; :issue:`4272`.) @@ -786,8 +802,11 @@ (Contributed by Tarek Ziad?; :issue:`6693`.) * The :mod:`socket` module's :class:`SSL` objects now support the - buffer API, which fixed a test suite failure. (Fixed by Antoine Pitrou; - :issue:`7133`.) + buffer API, which fixed a test suite failure. (Fixed by Antoine + Pitrou; :issue:`7133`.) The :func:`create_connection` function + gained a *source_address* parameter, a ``(host, port)`` 2-tuple + giving the source address that will be used for the connection. + (Contributed by Eldon Ziegler; :issue:`3972`.) * The :mod:`SocketServer` module's :class:`TCPServer` class now has a :attr:`disable_nagle_algorithm` class attribute. @@ -830,7 +849,7 @@ Light; :issue:`4285`.) :func:`sys.getwindowsversion` also returns a named tuple, - with attributes named :attr:`major`, :attr:`minor`, :attr:`build`, + with attributes named :attr:`major`, :attr:`minor`, :attr:`build`, :attr:`platform`:, :attr:`service_pack`, :attr:`service_pack_major`, :attr:`service_pack_minor`, :attr:`suite_mask`, and :attr:`product_type`. (Contributed by Brian Curtin; :issue:`7766`.) @@ -888,6 +907,54 @@ variables relevant for the current platform. +Distutils Enhancements +--------------------------------- + +Distutils is being more actively developed, thanks to Tarek Ziad? +who has taken over maintenance of the package, so there are a number +of fixes and improvements. + +A new :file:`setup.py` subcommand, ``check``, will check that the +arguments being passed to the :func:`setup` function are complete +and correct (:issue:`5732`). + +Byte-compilation by the ``install_lib`` subcommand is now only done +if the ``sys.dont_write_bytecode`` setting allows it (:issue:`7071`). + +:func:`distutils.sdist.add_defaults` now uses +*package_dir* and *data_files* to create the MANIFEST file. +:mod:`distutils.sysconfig` now reads the :envvar:`AR` and +:envvar:`ARFLAGS` environment variables. + +.. ARFLAGS done in #5941 + +It is no longer mandatory to store clear-text passwords in the +:file:`.pypirc` file when registering and uploading packages to PyPI. As long +as the username is present in that file, the :mod:`distutils` package will +prompt for the password if not present. (Added by Tarek Ziad?, +based on an initial contribution by Nathan Van Gheem; :issue:`4394`.) + +A Distutils setup can now specify that a C extension is optional by +setting the *optional* option setting to true. If this optional is +supplied, failure to build the extension will not abort the build +process, but instead simply not install the failing extension. +(Contributed by Georg Brandl; :issue:`5583`.) + +The :class:`distutils.dist.DistributionMetadata` class' +:meth:`read_pkg_file` method will read the contents of a package's +:file:`PKG-INFO` metadata file. For an example of its use, see +:ref:`reading-metadata`. +(Contributed by Tarek Ziad?; :issue:`7457`.) + +:file:`setup.py` files will now accept a :option:`--no-user-cfg` switch +to skip reading the :file:`~/.pydistutils.cfg` file. (Suggested by +by Michael Hoffman, and implemented by Paul Winkler; :issue:`1180`.) + +When creating a tar-format archive, the ``sdist`` subcommand now +allows specifying the user id and group that will own the files in the +archives using the :option:`--owner` and :option:`--group` switches +(:issue:`6516`). + Unit Testing Enhancements --------------------------------- From python-checkins at python.org Mon Feb 8 07:50:14 2010 From: python-checkins at python.org (vinay.sajip) Date: Mon, 08 Feb 2010 06:50:14 -0000 Subject: [Python-checkins] r78103 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Mon Feb 8 07:50:14 2010 New Revision: 78103 Log: Removed spurious print statement in test. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Mon Feb 8 07:50:14 2010 @@ -1638,7 +1638,6 @@ self.assertRaises(TypeError, man.setLoggerClass, int) man.setLoggerClass(MyLogger) logger = man.getLogger('test') - print >> open('/tmp/tmp.txt', 'w'), type(logger) logger.warning('should appear in logged') logging.warning('should not appear in logged') From python-checkins at python.org Mon Feb 8 14:22:24 2010 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 08 Feb 2010 13:22:24 -0000 Subject: [Python-checkins] r78104 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: andrew.kuchling Date: Mon Feb 8 14:22:24 2010 New Revision: 78104 Log: Add two items; move a subsection Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Mon Feb 8 14:22:24 2010 @@ -412,7 +412,10 @@ * The :class:`file` object will now set the :attr:`filename` attribute on the :exc:`IOError` exception when trying to open a directory - on POSIX platforms. (Noted by Jan Kaliszewski; :issue:`4764`.) + on POSIX platforms (noted by Jan Kaliszewski; :issue:`4764`), and + now explicitly checks for and forbids writing to read-only file objects + instead of trusting the C library to catch and report the error + (fixed by Stefan Krah; :issue:`5677`). * The Python tokenizer now translates line endings itself, so the :func:`compile` built-in function can now accept code using any @@ -896,15 +899,18 @@ accepts a file object, in addition to the path names accepted in earlier versions. (Contributed by Gabriel Genellina; :issue:`4756`.) -.. ====================================================================== -.. whole new modules get described in subsections here +New module: sysconfig +--------------------------------- + +XXX A new :mod:`sysconfig` module has been extracted from +:mod:`distutils` and put in the standard library. -* XXX A new :mod:`sysconfig` module has been extracted from :mod:`distutils` - and put in the standard library. +The :mod:`sysconfig` module provides access to Python's configuration +information like the list of installation paths and the configuration +variables relevant for the current platform. - The :mod:`sysconfig` module provides access to Python's configuration - information like the list of installation paths and the configuration - variables relevant for the current platform. +.. ====================================================================== +.. whole new modules get described in subsections here Distutils Enhancements @@ -955,6 +961,7 @@ archives using the :option:`--owner` and :option:`--group` switches (:issue:`6516`). + Unit Testing Enhancements --------------------------------- @@ -1296,6 +1303,12 @@ Other Changes and Fixes ======================= +* Two benchmark scripts, :file:`iobench` and :file:`ccbench`, were + added to the :file:`Tools` directory. :file:`iobench` measures the + speed of the built-in :class:`file` objects while performing various + operations, and :file:`ccbench` is a concurrency that performs + several tasks using a varying number of threads. + * When importing a module from a :file:`.pyc` or :file:`.pyo` file with an existing :file:`.py` counterpart, the :attr:`co_filename` attributes of the resulting code objects are overwritten when the From python-checkins at python.org Mon Feb 8 16:32:08 2010 From: python-checkins at python.org (vinay.sajip) Date: Mon, 08 Feb 2010 15:32:08 -0000 Subject: [Python-checkins] r78105 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Mon Feb 8 16:32:08 2010 New Revision: 78105 Log: logging: skipped listening tests because they're not working reliably. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Mon Feb 8 16:32:08 2010 @@ -1592,6 +1592,7 @@ logging.config.stopListening() t.join(2.0) + @unittest.skip("See issue #7857") def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) @@ -1611,6 +1612,7 @@ ('ERROR', '4'), ], stream=output) + @unittest.skip("See issue #7857") def test_listen_config_1_ok(self): with captured_stdout() as output: self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) From python-checkins at python.org Mon Feb 8 17:05:50 2010 From: python-checkins at python.org (vinay.sajip) Date: Mon, 08 Feb 2010 16:05:50 -0000 Subject: [Python-checkins] r78106 - python/trunk/Lib/test/test_logging.py Message-ID: Author: vinay.sajip Date: Mon Feb 8 17:05:50 2010 New Revision: 78106 Log: Issue #7857: Another attempt to keep the buildbots happy. Modified: python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Mon Feb 8 17:05:50 2010 @@ -1574,6 +1574,7 @@ t = logging.config.listen(port) t.start() t.ready.wait() + t.ready.clear() try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2.0) @@ -1589,10 +1590,11 @@ left -= sent sock.close() finally: + t.ready.wait(2.0) logging.config.stopListening() t.join(2.0) - @unittest.skip("See issue #7857") + #@unittest.skip("See issue #7857") def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) From python-checkins at python.org Mon Feb 8 21:25:47 2010 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 08 Feb 2010 20:25:47 -0000 Subject: [Python-checkins] r78107 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: antoine.pitrou Date: Mon Feb 8 21:25:47 2010 New Revision: 78107 Log: Clarify and correct description for ccbench and iobench. Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Mon Feb 8 21:25:47 2010 @@ -1305,9 +1305,10 @@ * Two benchmark scripts, :file:`iobench` and :file:`ccbench`, were added to the :file:`Tools` directory. :file:`iobench` measures the - speed of the built-in :class:`file` objects while performing various - operations, and :file:`ccbench` is a concurrency that performs - several tasks using a varying number of threads. + speed of built-in file I/O objects (as returned by :func:`open`) + while performing various operations, and :file:`ccbench` is a concurrency + benchmark that tries to measure computing throughput and thread switching + latency when performing several tasks using a varying number of threads. * When importing a module from a :file:`.pyc` or :file:`.pyo` file with an existing :file:`.py` counterpart, the :attr:`co_filename` From python-checkins at python.org Mon Feb 8 22:18:16 2010 From: python-checkins at python.org (vinay.sajip) Date: Mon, 08 Feb 2010 21:18:16 -0000 Subject: [Python-checkins] r78108 - in python/trunk/Lib: logging/config.py test/test_logging.py Message-ID: Author: vinay.sajip Date: Mon Feb 8 22:18:15 2010 New Revision: 78108 Log: logging: gingerly re-enabling skipped tests after improving thread sync code in configurator. Modified: python/trunk/Lib/logging/config.py python/trunk/Lib/test/test_logging.py Modified: python/trunk/Lib/logging/config.py ============================================================================== --- python/trunk/Lib/logging/config.py (original) +++ python/trunk/Lib/logging/config.py Mon Feb 8 22:18:15 2010 @@ -803,6 +803,8 @@ raise except: traceback.print_exc() + if self.server.ready: + self.server.ready.set() except socket.error, e: if not isinstance(e.args, tuple): raise @@ -819,12 +821,13 @@ allow_reuse_address = 1 def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT, - handler=None): + handler=None, ready=None): ThreadingTCPServer.__init__(self, (host, port), handler) logging._acquireLock() self.abort = 0 logging._releaseLock() self.timeout = 1 + self.ready = ready def serve_until_stopped(self): import select @@ -849,7 +852,8 @@ self.ready = threading.Event() def run(self): - server = self.rcvr(port=self.port, handler=self.hdlr) + server = self.rcvr(port=self.port, handler=self.hdlr, + ready=self.ready) self.ready.set() global _listener logging._acquireLock() Modified: python/trunk/Lib/test/test_logging.py ============================================================================== --- python/trunk/Lib/test/test_logging.py (original) +++ python/trunk/Lib/test/test_logging.py Mon Feb 8 22:18:15 2010 @@ -1594,7 +1594,6 @@ logging.config.stopListening() t.join(2.0) - #@unittest.skip("See issue #7857") def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10)) @@ -1614,7 +1613,6 @@ ('ERROR', '4'), ], stream=output) - @unittest.skip("See issue #7857") def test_listen_config_1_ok(self): with captured_stdout() as output: self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1)) From python-checkins at python.org Mon Feb 8 22:52:09 2010 From: python-checkins at python.org (ezio.melotti) Date: Mon, 08 Feb 2010 21:52:09 -0000 Subject: [Python-checkins] r78109 - python/trunk/Lib/unittest/case.py Message-ID: Author: ezio.melotti Date: Mon Feb 8 22:52:08 2010 New Revision: 78109 Log: Fix exc_value -> exception in docstring Modified: python/trunk/Lib/unittest/case.py Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Mon Feb 8 22:52:08 2010 @@ -384,7 +384,7 @@ do_something() The context manager keeps a reference to the exception as - the exc_value attribute. This allows you to inspect the + the 'exception' attribute. This allows you to inspect the exception after the assertion:: with self.assertRaises(SomeException) as cm: From python-checkins at python.org Mon Feb 8 22:57:48 2010 From: python-checkins at python.org (ezio.melotti) Date: Mon, 08 Feb 2010 21:57:48 -0000 Subject: [Python-checkins] r78110 - in python/branches/py3k: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/case.py Message-ID: Author: ezio.melotti Date: Mon Feb 8 22:57:48 2010 New Revision: 78110 Log: Merged revisions 78091,78094,78109 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78091 | georg.brandl | 2010-02-07 19:02:22 +0200 (Sun, 07 Feb 2010) | 1 line Rename "exc_value" attribute on assertRaises context manager to "exception". ........ r78094 | michael.foord | 2010-02-07 20:44:12 +0200 (Sun, 07 Feb 2010) | 1 line assertRaises as context manager now allows you to access exception as documented ........ r78109 | ezio.melotti | 2010-02-08 23:52:08 +0200 (Mon, 08 Feb 2010) | 1 line Fix exc_value -> exception in docstring ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/unittest/case.py Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Mon Feb 8 22:57:48 2010 @@ -895,24 +895,24 @@ do_something() The context manager will store the caught exception object in its - :attr:`exc_value` attribute. This can be useful if the intention + :attr:`exception` attribute. This can be useful if the intention is to perform additional checks on the exception raised:: with self.assertRaises(SomeException) as cm: do_something() - the_exception = cm.exc_value + the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) - .. versionchanged:: 3.1 + .. versionchanged:: 3.1 Added the ability to use :meth:`assertRaises` as a context manager. + .. versionchanged:: 3.2 + Added the :attr:`exception` attribute. + .. deprecated:: 3.1 :meth:`failUnlessRaises`. - .. versionchanged:: 3.2 - Added the :attr:`exc_value` attribute. - .. method:: assertRaisesRegexp(exception, regexp[, callable, ...]) Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Mon Feb 8 22:57:48 2010 @@ -626,7 +626,6 @@ # a good chance that it won't be imported when this test is run module_name = 'audioop' - import sys if module_name in sys.modules: del sys.modules[module_name] @@ -1014,7 +1013,6 @@ # a good chance that it won't be imported when this test is run module_name = 'audioop' - import sys if module_name in sys.modules: del sys.modules[module_name] @@ -1972,8 +1970,6 @@ # methods. Contains formatted tracebacks instead # of sys.exc_info() results." def test_addFailure(self): - import sys - class Foo(unittest.TestCase): def test_1(self): pass @@ -2022,8 +2018,6 @@ # methods. Contains formatted tracebacks instead # of sys.exc_info() results." def test_addError(self): - import sys - class Foo(unittest.TestCase): def test_1(self): pass @@ -2861,7 +2855,7 @@ ctx = self.assertRaises(ExceptionMock) with ctx: Stub(v) - e = ctx.exc_value + e = ctx.exception self.assertIsInstance(e, ExceptionMock) self.assertEqual(e.args[0], v) @@ -3047,8 +3041,14 @@ pass else: self.fail("assertRaises() didn't let exception pass through") - with self.assertRaises(KeyError): - raise KeyError + with self.assertRaises(KeyError) as cm: + try: + raise KeyError + except Exception as e: + exc = e + raise + self.assertIs(cm.exception, exc) + with self.assertRaises(KeyError): raise KeyError("key") try: Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Mon Feb 8 22:57:48 2010 @@ -99,7 +99,7 @@ self.expected_regex = expected_regexp def __enter__(self): - pass + return self def __exit__(self, exc_type, exc_value, tb): if exc_type is None: @@ -116,8 +116,8 @@ if not issubclass(exc_type, self.expected): # let unexpected exceptions pass through return False - #store exception, without traceback, for later retrieval - self.exc_value = exc_value.with_traceback(None) + # store exception, without traceback, for later retrieval + self.exception = exc_value.with_traceback(None) if self.expected_regex is None: return True @@ -397,12 +397,12 @@ do_something() The context manager keeps a reference to the exception as - the exc_value attribute. This allows you to inspect the + the 'exception' attribute. This allows you to inspect the exception after the assertion:: with self.assertRaises(SomeException) as cm: do_something() - the_exception = cm.exc_value + the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ context = _AssertRaisesContext(excClass, self, callableObj) From python-checkins at python.org Mon Feb 8 23:07:38 2010 From: python-checkins at python.org (ezio.melotti) Date: Mon, 08 Feb 2010 22:07:38 -0000 Subject: [Python-checkins] r78111 - python/branches/release31-maint/Doc/library/unittest.rst Message-ID: Author: ezio.melotti Date: Mon Feb 8 23:07:38 2010 New Revision: 78111 Log: Use non-deprecated method in the example Modified: python/branches/release31-maint/Doc/library/unittest.rst Modified: python/branches/release31-maint/Doc/library/unittest.rst ============================================================================== --- python/branches/release31-maint/Doc/library/unittest.rst (original) +++ python/branches/release31-maint/Doc/library/unittest.rst Mon Feb 8 23:07:38 2010 @@ -816,7 +816,7 @@ If only the *exception* argument is given, returns a context manager so that the code under test can be written inline rather than as a function:: - with self.failUnlessRaises(some_error_class): + with self.assertRaises(SomeException): do_something() .. versionchanged:: 3.1 From python-checkins at python.org Mon Feb 8 23:22:41 2010 From: python-checkins at python.org (ezio.melotti) Date: Mon, 08 Feb 2010 22:22:41 -0000 Subject: [Python-checkins] r78112 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: ezio.melotti Date: Mon Feb 8 23:22:41 2010 New Revision: 78112 Log: Fix typo Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Mon Feb 8 23:22:41 2010 @@ -853,7 +853,7 @@ :func:`sys.getwindowsversion` also returns a named tuple, with attributes named :attr:`major`, :attr:`minor`, :attr:`build`, - :attr:`platform`:, :attr:`service_pack`, :attr:`service_pack_major`, + :attr:`platform`, :attr:`service_pack`, :attr:`service_pack_major`, :attr:`service_pack_minor`, :attr:`suite_mask`, and :attr:`product_type`. (Contributed by Brian Curtin; :issue:`7766`.) From python-checkins at python.org Mon Feb 8 23:37:21 2010 From: python-checkins at python.org (georg.brandl) Date: Mon, 08 Feb 2010 22:37:21 -0000 Subject: [Python-checkins] r78113 - python/trunk/Lib/plat-irix6/cdplayer.py Message-ID: Author: georg.brandl Date: Mon Feb 8 23:37:20 2010 New Revision: 78113 Log: Fix missing string formatting argument. Modified: python/trunk/Lib/plat-irix6/cdplayer.py Modified: python/trunk/Lib/plat-irix6/cdplayer.py ============================================================================== --- python/trunk/Lib/plat-irix6/cdplayer.py (original) +++ python/trunk/Lib/plat-irix6/cdplayer.py Mon Feb 8 23:37:20 2010 @@ -85,7 +85,7 @@ new.write(self.id + '.title:\t' + self.title + '\n') new.write(self.id + '.artist:\t' + self.artist + '\n') for i in range(1, len(self.track)): - new.write('%s.track.%r:\t%s\n' % (i, track)) + new.write('%s.track.%r:\t%s\n' % (self.id, i, track)) old.close() new.close() posix.rename(filename + '.new', filename) From python-checkins at python.org Mon Feb 8 23:37:53 2010 From: python-checkins at python.org (georg.brandl) Date: Mon, 08 Feb 2010 22:37:53 -0000 Subject: [Python-checkins] r78114 - python/trunk/Lib/plat-irix6/cdplayer.py Message-ID: Author: georg.brandl Date: Mon Feb 8 23:37:52 2010 New Revision: 78114 Log: Fix undefined local. Modified: python/trunk/Lib/plat-irix6/cdplayer.py Modified: python/trunk/Lib/plat-irix6/cdplayer.py ============================================================================== --- python/trunk/Lib/plat-irix6/cdplayer.py (original) +++ python/trunk/Lib/plat-irix6/cdplayer.py Mon Feb 8 23:37:52 2010 @@ -85,7 +85,7 @@ new.write(self.id + '.title:\t' + self.title + '\n') new.write(self.id + '.artist:\t' + self.artist + '\n') for i in range(1, len(self.track)): - new.write('%s.track.%r:\t%s\n' % (self.id, i, track)) + new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i])) old.close() new.close() posix.rename(filename + '.new', filename) From python-checkins at python.org Mon Feb 8 23:40:51 2010 From: python-checkins at python.org (georg.brandl) Date: Mon, 08 Feb 2010 22:40:51 -0000 Subject: [Python-checkins] r78115 - python/trunk/Lib/test/test_strftime.py Message-ID: Author: georg.brandl Date: Mon Feb 8 23:40:51 2010 New Revision: 78115 Log: Fix missing string formatting placeholder. Modified: python/trunk/Lib/test/test_strftime.py Modified: python/trunk/Lib/test/test_strftime.py ============================================================================== --- python/trunk/Lib/test/test_strftime.py (original) +++ python/trunk/Lib/test/test_strftime.py Mon Feb 8 23:40:51 2010 @@ -118,7 +118,7 @@ try: result = time.strftime(e[0], now) except ValueError, error: - print "Standard '%s' format gaver error:" % (e[0], error) + print "Standard '%s' format gave error: %s" % (e[0], error) continue if re.match(escapestr(e[1], self.ampm), result): continue From python-checkins at python.org Mon Feb 8 23:41:16 2010 From: python-checkins at python.org (michael.foord) Date: Mon, 08 Feb 2010 22:41:16 -0000 Subject: [Python-checkins] r78116 - in python/trunk: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/case.py Message-ID: Author: michael.foord Date: Mon Feb 8 23:41:16 2010 New Revision: 78116 Log: Make assertMultiLineEqual the default for comparing unicode strings. Modified: python/trunk/Doc/library/unittest.rst python/trunk/Lib/test/test_unittest.py python/trunk/Lib/unittest/case.py Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Mon Feb 8 23:41:16 2010 @@ -695,7 +695,7 @@ *second*. In addition, if *first* and *second* are the exact same type and one of - list, tuple, dict, set, or frozenset or any type that a subclass + list, tuple, dict, set, frozenset or unicode or any type that a subclass registers :meth:`addTypeEqualityFunc` the type specific equality function will be called in order to generate a more useful default error message. @@ -777,7 +777,8 @@ Test that the multiline string *first* is equal to the string *second*. When not equal a diff of the two strings highlighting the differences - will be included in the error message. + will be included in the error message. This method is used by default + when comparing Unicode strings with :meth:`assertEqual`. If specified *msg* will be used as the error message on failure. @@ -823,7 +824,8 @@ .. method:: assertSetEqual(set1, set2, msg=None) Tests that two sets are equal. If not, an error message is constructed - that lists the differences between the sets. + that lists the differences between the sets. This method is used by + default when comparing sets or frozensets with :meth:`assertEqual`. Fails if either of *set1* or *set2* does not have a :meth:`set.difference` method. @@ -836,7 +838,9 @@ .. method:: assertDictEqual(expected, actual, msg=None) Test that two dictionaries are equal. If not, an error message is - constructed that shows the differences in the dictionaries. + constructed that shows the differences in the dictionaries. This + method will be used by default to compare dictionaries in + calls to :meth:`assertEqual`. If specified *msg* will be used as the error message on failure. @@ -860,6 +864,8 @@ Tests that two lists or tuples are equal. If not an error message is constructed that shows only the differences between the two. An error is also raised if either of the parameters are of the wrong type. + These methods are used by default when comparing lists or tuples with + :meth:`assertEqual`. If specified *msg* will be used as the error message on failure. Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Mon Feb 8 23:41:16 2010 @@ -2810,8 +2810,9 @@ self.assertMultiLineEqual(type_changer(sample_text), type_changer(revised_sample_text)) except self.failureException, e: - # no fair testing ourself with ourself, use assertEqual.. - self.assertEqual(sample_text_error, str(e).encode('utf8')) + # assertMultiLineEqual is hooked up as the default for + # unicode strings - so we can't use it for this check + self.assertTrue(sample_text_error == str(e).encode('utf8')) def testAssertIsNone(self): self.assertIsNone(None) Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Mon Feb 8 23:41:16 2010 @@ -176,6 +176,7 @@ self.addTypeEqualityFunc(tuple, self.assertTupleEqual) self.addTypeEqualityFunc(set, self.assertSetEqual) self.addTypeEqualityFunc(frozenset, self.assertSetEqual) + self.addTypeEqualityFunc(unicode, self.assertMultiLineEqual) def addTypeEqualityFunc(self, typeobj, function): """Add a type specific assertEqual style function to compare a type. From python-checkins at python.org Mon Feb 8 23:48:37 2010 From: python-checkins at python.org (georg.brandl) Date: Mon, 08 Feb 2010 22:48:37 -0000 Subject: [Python-checkins] r78117 - python/trunk/Lib/test/test_strftime.py Message-ID: Author: georg.brandl Date: Mon Feb 8 23:48:37 2010 New Revision: 78117 Log: Convert test failure from output-producing to self.fail(). Modified: python/trunk/Lib/test/test_strftime.py Modified: python/trunk/Lib/test/test_strftime.py ============================================================================== --- python/trunk/Lib/test/test_strftime.py (original) +++ python/trunk/Lib/test/test_strftime.py Mon Feb 8 23:48:37 2010 @@ -118,16 +118,15 @@ try: result = time.strftime(e[0], now) except ValueError, error: - print "Standard '%s' format gave error: %s" % (e[0], error) - continue + self.fail("strftime '%s' format gave error: %s" % (e[0], error)) if re.match(escapestr(e[1], self.ampm), result): continue if not result or result[0] == '%': - print "Does not support standard '%s' format (%s)" % \ - (e[0], e[2]) + self.fail("strftime does not support standard '%s' format (%s)" + % (e[0], e[2])) else: - print "Conflict for %s (%s):" % (e[0], e[2]) - print " Expected %s, but got %s" % (e[1], result) + self.fail("Conflict for %s (%s): expected %s, but got %s" + % (e[0], e[2], e[1], result)) def strftest2(self, now): nowsecs = str(long(now))[:-1] From python-checkins at python.org Tue Feb 9 00:10:39 2010 From: python-checkins at python.org (michael.foord) Date: Mon, 08 Feb 2010 23:10:39 -0000 Subject: [Python-checkins] r78118 - in python/branches/py3k: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/case.py Message-ID: Author: michael.foord Date: Tue Feb 9 00:10:39 2010 New Revision: 78118 Log: Merged revisions 78116 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78116 | michael.foord | 2010-02-08 22:41:16 +0000 (Mon, 08 Feb 2010) | 1 line Make assertMultiLineEqual the default for comparing unicode strings. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/unittest/case.py Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Tue Feb 9 00:10:39 2010 @@ -690,13 +690,18 @@ *second*. In addition, if *first* and *second* are the exact same type and one of - list, tuple, dict, set, or frozenset or any type that a subclass - registers :meth:`addTypeEqualityFunc` the type specific equality function - will be called in order to generate a more useful default error message. + list, tuple, dict, set, frozenset or str or any type that a subclass + registers with :meth:`addTypeEqualityFunc` the type specific equality + function will be called in order to generate a more useful default + error message. .. versionchanged:: 3.1 Added the automatic calling of type specific equality function. + .. versionchanged:: 3.2 + :meth:`assertMultiLineEqual` added as the default type equality + function for comparing strings. + .. deprecated:: 3.1 :meth:`failUnlessEqual`. @@ -772,7 +777,8 @@ Test that the multiline string *first* is equal to the string *second*. When not equal a diff of the two strings highlighting the differences - will be included in the error message. + will be included in the error message. This method is used by default + when comparing strings with :meth:`assertEqual`. If specified *msg* will be used as the error message on failure. @@ -818,7 +824,8 @@ .. method:: assertSetEqual(set1, set2, msg=None) Tests that two sets are equal. If not, an error message is constructed - that lists the differences between the sets. + that lists the differences between the sets. This method is used by + default when comparing sets or frozensets with :meth:`assertEqual`. Fails if either of *set1* or *set2* does not have a :meth:`set.difference` method. @@ -831,7 +838,9 @@ .. method:: assertDictEqual(expected, actual, msg=None) Test that two dictionaries are equal. If not, an error message is - constructed that shows the differences in the dictionaries. + constructed that shows the differences in the dictionaries. This + method will be used by default to compare dictionaries in + calls to :meth:`assertEqual`. If specified *msg* will be used as the error message on failure. @@ -855,6 +864,8 @@ Tests that two lists or tuples are equal. If not an error message is constructed that shows only the differences between the two. An error is also raised if either of the parameters are of the wrong type. + These methods are used by default when comparing lists or tuples with + :meth:`assertEqual`. If specified *msg* will be used as the error message on failure. Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Tue Feb 9 00:10:39 2010 @@ -2795,8 +2795,9 @@ try: self.assertMultiLineEqual(sample_text, revised_sample_text) except self.failureException as e: - # no fair testing ourself with ourself, use assertEqual.. - self.assertEqual(sample_text_error, str(e)) + # no fair testing ourself with ourself, and assertEqual is used for strings + # so can't use assertEqual either. Just use assertTrue. + self.assertTrue(sample_text_error == str(e)) def testAssertIsNone(self): self.assertIsNone(None) Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Tue Feb 9 00:10:39 2010 @@ -189,6 +189,7 @@ self.addTypeEqualityFunc(tuple, self.assertTupleEqual) self.addTypeEqualityFunc(set, self.assertSetEqual) self.addTypeEqualityFunc(frozenset, self.assertSetEqual) + self.addTypeEqualityFunc(str, self.assertMultiLineEqual) def addTypeEqualityFunc(self, typeobj, function): """Add a type specific assertEqual style function to compare a type. From python-checkins at python.org Tue Feb 9 00:15:22 2010 From: python-checkins at python.org (michael.foord) Date: Mon, 08 Feb 2010 23:15:22 -0000 Subject: [Python-checkins] r78119 - python/trunk/Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Tue Feb 9 00:15:22 2010 New Revision: 78119 Log: Doc fix for unittest. Modified: python/trunk/Doc/library/unittest.rst Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Tue Feb 9 00:15:22 2010 @@ -696,8 +696,9 @@ In addition, if *first* and *second* are the exact same type and one of list, tuple, dict, set, frozenset or unicode or any type that a subclass - registers :meth:`addTypeEqualityFunc` the type specific equality function - will be called in order to generate a more useful default error message. + registers with :meth:`addTypeEqualityFunc` the type specific equality + function will be called in order to generate a more useful default error + message. .. versionchanged:: 2.7 Added the automatic calling of type specific equality function. From python-checkins at python.org Tue Feb 9 00:16:41 2010 From: python-checkins at python.org (michael.foord) Date: Mon, 08 Feb 2010 23:16:41 -0000 Subject: [Python-checkins] r78120 - python/branches/py3k Message-ID: Author: michael.foord Date: Tue Feb 9 00:16:41 2010 New Revision: 78120 Log: Blocked revisions 78119 via svnmerge ........ r78119 | michael.foord | 2010-02-08 23:15:22 +0000 (Mon, 08 Feb 2010) | 1 line Doc fix for unittest. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Tue Feb 9 01:03:57 2010 From: python-checkins at python.org (michael.foord) Date: Tue, 09 Feb 2010 00:03:57 -0000 Subject: [Python-checkins] r78121 - python/branches/py3k/Doc/library/unittest.rst Message-ID: Author: michael.foord Date: Tue Feb 9 01:03:57 2010 New Revision: 78121 Log: Fixing typo in unittest docs. Modified: python/branches/py3k/Doc/library/unittest.rst Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Tue Feb 9 01:03:57 2010 @@ -698,9 +698,9 @@ .. versionchanged:: 3.1 Added the automatic calling of type specific equality function. - .. versionchanged:: 3.2 - :meth:`assertMultiLineEqual` added as the default type equality - function for comparing strings. + .. versionchanged:: 3.2 + :meth:`assertMultiLineEqual` added as the default type equality + function for comparing strings. .. deprecated:: 3.1 :meth:`failUnlessEqual`. From solipsis at pitrou.net Tue Feb 9 01:05:11 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 9 Feb 2010 01:05:11 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r78110): sum=0 Message-ID: <20100209000512.023C21770D@ns6635.ovh.net> py3k results for svn r78110 (hg cset 4cf52fd22180) -------------------------------------------------- test_os leaked [-23, 23, 0] references, sum=0 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogRuWb7j', '-x', 'test_httpservers'] From nnorwitz at gmail.com Tue Feb 9 01:52:55 2010 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 8 Feb 2010 19:52:55 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20100209005255.GA4749@kbk-i386-bb.psfb.org> More important issues: ---------------------- test_bz2 leaked [-84, 0, 0] references, sum=-84 Less important issues: ---------------------- test_popen2 leaked [0, 25, -25] references, sum=0 From python-checkins at python.org Tue Feb 9 03:51:27 2010 From: python-checkins at python.org (collin.winter) Date: Tue, 09 Feb 2010 02:51:27 -0000 Subject: [Python-checkins] r78122 - peps/trunk/pep-3146.txt Message-ID: Author: collin.winter Date: Tue Feb 9 03:51:26 2010 New Revision: 78122 Log: Commit updated version of PEP 3146. Modified: peps/trunk/pep-3146.txt Modified: peps/trunk/pep-3146.txt ============================================================================== --- peps/trunk/pep-3146.txt (original) +++ peps/trunk/pep-3146.txt Tue Feb 9 03:51:26 2010 @@ -165,6 +165,50 @@ framework that the wider CPython development community can build upon it for years to come, extracting increased performance in each subsequent release. +Alternatives +------------ + +There are number of alternative strategies for improving Python performance +which we considered, but found unsatisfactory. + +- *Cython, Shedskin*: Cython [#cython]_ and Shedskin [#shedskin]_ are both + static compilers for Python. We view these as useful-but-limited workarounds + for CPython's historically-poor performance. Shedskin does not support the + full Python standard library [#shedskin-library-limits]_, while Cython + requires manual Cython-specific annotations for optimum performance. + + Static compilers like these are useful for writing extension modules without + worrying about reference counting, but because they are static, ahead-of-time + compilers, they cannot optimize the full range of code under consideration by + a just-in-time compiler informed by runtime data. +- *IronPython*: IronPython [#ironpython]_ is Python on Microsoft's .Net + platform. It is not actively tested on Mono [#mono]_, meaning that it is + essentially Windows-only, making it unsuitable as a general CPython + replacement. +- *Jython*: Jython [#jython]_ is a complete implementation of Python 2.5, but + is significantly slower than Unladen Swallow (3-5x on measured benchmarks) and + has no support for CPython extension modules [#jython-c-ext]_, which would + make migration of large applications prohibitively expensive. +- *Psyco*: Psyco [#psyco]_ is a specializing JIT compiler for CPython, + implemented as an extension module. It primarily improves performance for + numerical code. Pros: exists; makes some code faster. Cons: 32-bit only, with + no plans for 64-bit support; supports x86 only; very difficult to maintain; + incompatible with SSE2 optimized code due to alignment issues. +- *PyPy*: PyPy [#pypy]_ has good performance on numerical code, but is slower + than Unladen Swallow on non-numerical workloads. PyPy only supports 32-bit + x86 code generation. It has poor support for CPython extension modules, + making migration for large applications prohibitively expensive. +- *PyV8*: PyV8 [#pyv8]_ is an alpha-stage experimental Python-to-JavaScript + compiler that runs on top of V8. PyV8 does not implement the whole Python + language, and has no support for CPython extension modules. +- *WPython*: WPython [#wpython]_ is a wordcode-based reimplementation of + CPython's interpreter loop. While it provides a modest improvement to + interpreter performance [#wpython-performance]_, it is not an either-or + substitute for a just-in-time compiler. An interpreter will never be as fast + as optimized machine code. We view WPython and similar interpreter + enhancements as complementary to our work, rather than as competitors. + + Performance =========== @@ -411,6 +455,25 @@ Stddev: 0.00214 -> 0.00240: 1.1209x larger Timeline: http://tinyurl.com/yajn8fa + ### bzr_startup ### + Min: 0.067990 -> 0.097985: 1.4412x slower + Avg: 0.084322 -> 0.111348: 1.3205x slower + Significant (t=-37.432534, a=0.95) + Stddev: 0.00793 -> 0.00643: 1.2330x smaller + Timeline: http://tinyurl.com/ybdm537 + + ### hg_startup ### + Min: 0.016997 -> 0.024997: 1.4707x slower + Avg: 0.026990 -> 0.036772: 1.3625x slower + Significant (t=-53.104502, a=0.95) + Stddev: 0.00406 -> 0.00417: 1.0273x larger + Timeline: http://tinyurl.com/ycout8m + + +``bzr_startup`` and ``hg_startup`` measure how long it takes Bazaar and +Mercurial, respectively, to display their help screens. ``startup_nosite`` +runs ``python -S`` many times; usage of the ``-S`` option is rare, but we feel +this gives a good indication of where increased startup time is coming from. Unladen Swallow has made headway toward optimizing startup time, but there is still more work to do and further optimizations to implement. Improving start-up @@ -422,40 +485,31 @@ ----------- Statically linking LLVM's code generation, analysis and optimization libraries -significantly increases the size of the ``python`` binary. - - -32-bit; gcc 4.0.3 - -+-------------+---------------+---------------+----------------------+ -| Binary size | CPython 2.6.4 | CPython 3.1.1 | Unladen Swallow r988 | -+=============+===============+===============+======================+ -| Release | 3.8M | 4.0M | 74M | -+-------------+---------------+---------------+----------------------+ -| Debug | 3.3M | 3.6M | 118M | -+-------------+---------------+---------------+----------------------+ - -64-bit; gcc 4.2.4 - -+-------------+---------------+---------------+----------------------+ -| Binary size | CPython 2.6.4 | CPython 3.1.1 | Unladen Swallow r988 | -+=============+===============+===============+======================+ -| Release | 5.5M | 5.7M | 89M | -+-------------+---------------+---------------+----------------------+ -| Debug | 4.1M | 4.4M | 128M | -+-------------+---------------+---------------+----------------------+ - -The increased binary size is due to statically linking LLVM's code generation, -analysis and optimization libraries into the ``python`` binary. This can be -straightforwardly addressed by modifying LLVM to better support shared linking -and then using that, instead of the current static linking. For the moment, -though, static linking provides an accurate look at the cost of linking against -LLVM. - -Unladen Swallow recently experienced a regression in binary size, going from -19MB in Unladen's 2009Q3 release up to the current 74MB shown in the table -above. Resolution of this issue [#us-binary-size]_ will block final merger into -the ``py3k`` branch. +significantly increases the size of the ``python`` binary. The tables below +report stripped on-disk binary sizes; the binaries are stripped to better +correspond with the configurations used by system package managers. We feel this +is the most realistic measure of any change in binary size. + + ++-------------+---------------+---------------+-----------------------+ +| Binary size | CPython 2.6.4 | CPython 3.1.1 | Unladen Swallow r1041 | ++=============+===============+===============+=======================+ +| 32-bit | 1.3M | 1.4M | 12M | ++-------------+---------------+---------------+-----------------------+ +| 64-bit | 1.6M | 1.6M | 12M | ++-------------+---------------+---------------+-----------------------+ + + +The increased binary size is caused by statically linking LLVM's code +generation, analysis and optimization libraries into the ``python`` binary. +This can be straightforwardly addressed by modifying LLVM to better support +shared linking and then using that, instead of the current static linking. For +the moment, though, static linking provides an accurate look at the cost of +linking against LLVM. + +Even when statically linking, we believe there is still headroom to improve +on-disk binary size by narrowing Unladen Swallow's dependencies on LLVM. This +issue is actively being addressed [#us-binary-size]_. Performance Retrospective @@ -610,7 +664,8 @@ best support on x86 and x86-64 systems, and these are the platforms where Unladen Swallow has received the most testing. We are confident in LLVM/Unladen Swallow's support for x86 and x86-64 hardware. PPC and ARM support exists, but -is not widely used and may be buggy. +is not widely used and may be buggy (for example, [#llvm-ppc-eager-jit-issue]_, +[#llvm-far-call-issue]_, [#llvm-arm-jit-issue]_). Unladen Swallow is known to work on the following operating systems: Linux, Darwin, Windows. Unladen Swallow has received the most testing on Linux and @@ -631,7 +686,7 @@ -------------------------------------------------------- Unladen Swallow's JIT compiler operates on CPython bytecode, and as such, it is -immune to Python languages changes that only affect the parser. +immune to Python language changes that affect only the parser. We recommend that changes to the CPython bytecode compiler or the semantics of individual bytecodes be prototyped in the interpreter loop first, then be ported @@ -765,6 +820,10 @@ Unladen Swallow [#us-oprofile-change]_, other profiling tools should be easy as well, provided they support a similar JIT interface [#oprofile-jit-interface]_. +We have documented the process for using oProfile to profile Unladen Swallow +[#oprofile-workflow]_. This document will be merged into CPython's `Doc/` tree +in the merge. + Addition of C++ to CPython -------------------------- @@ -781,12 +840,17 @@ - Easy use of LLVM's full, powerful code generation and related APIs. - Convenient, abstract data structures simplify code. - C++ is limited to relatively small corners of the CPython codebase. +- C++ can be disabled via ``./configure --without-llvm``, which even omits the + dependency on ``libstdc++``. Lowlights: - Developers must know two related languages, C and C++ to work on the full range of CPython's internals. - A C++ style guide will need to be developed and enforced. See `Open Issues`_. +- Different C++ compilers emit different ABIs; this can cause problems if + CPython is compiled with one C++ compiler and extensions modules are compiled + with a different C++ compiler. Managing LLVM Releases, C++ API Changes @@ -813,20 +877,26 @@ following an LLVM release, and failing that, llvm.org itself includes binary releases. -Pre-built LLVM packages are available from MacPorts [#llvm-macports]_ for -Darwin, and from most major Linux distributions ([#llvm-ubuntu]_, +Unladen Swallow has historically included a copy of the LLVM and Clang source +trees in the Unladen Swallow tree; this was done to allow us to closely track +LLVM trunk as we made patches to it. We do not recommend this model of +development for CPython. CPython releases should be based on official LLVM +releases. Pre-built LLVM packages are available from MacPorts [#llvm-macports]_ +for Darwin, and from most major Linux distributions ([#llvm-ubuntu]_, [#llvm-debian]_, [#llvm-fedora]_). LLVM itself provides additional binaries, such as for MinGW [#llvm-mingw]_. LLVM is currently intended to be statically linked; this means that binary releases of CPython will include the relevant parts (not all!) of LLVM. This -will increase the binary size, as noted above. +will increase the binary size, as noted above. To simplify downstream package +management, we will modify LLVM to better support shared linking. This issue +will block final merger [#us-shared-link-issue]_. Unladen Swallow has tasked a full-time engineer with fixing any remaining -critical issues in LLVM before LLVM's 2.7 release. We would like CPython 3.x to -be able to depend on a released version of LLVM, rather than closely tracking -LLVM trunk as Unladen Swallow has done. We believe we will finish this work -before the release of LLVM 2.7, expected in May 2010. +critical issues in LLVM before LLVM's 2.7 release. We consider it essential that +CPython 3.x be able to depend on a released version of LLVM, rather than closely +tracking LLVM trunk as Unladen Swallow has done. We believe we will finish this +work [#us-llvm-punchlist]_ before the release of LLVM 2.7, expected in May 2010. Building CPython @@ -868,27 +938,22 @@ interaction, b) statically linking LLVM into ``libpython``, c) compiling parts of the Python runtime to LLVM IR to enable cross-language inlining. -Incremental builds, however, are significantly slower. The table below shows -incremental rebuild times after touching ``Objects/listobject.c``. - -+-------------+---------------+---------------+----------------------+ -| Incr make | CPython 2.6.4 | CPython 3.1.1 | Unladen Swallow r988 | -+=============+===============+===============+======================+ -| Run 1 | 0m1.854s | 0m1.456s | 0m24.464s | -+-------------+---------------+---------------+----------------------+ -| Run 2 | 0m1.437s | 0m1.442s | 0m24.416s | -+-------------+---------------+---------------+----------------------+ -| Run 3 | 0m1.440s | 0m1.425s | 0m24.352s | -+-------------+---------------+---------------+----------------------+ +Incremental builds are also somewhat slower than mainline CPython. The table +below shows incremental rebuild times after touching ``Objects/listobject.c``. -As with full builds, this extra time comes from a) additional ``.cc`` files -needed for LLVM interaction, and b) statically linking LLVM into ``libpython``. - -If ``libpython`` were linked shared against LLVM, this overhead would go down. -Incremental builds of Unladen Swallow also currently (as of r988) suffer from a -known bug in the Unladen Swallow ``Makefile`` [#rebuild-too-much]_ where too -many ``.cc`` files are recompiled. We consider this a blocking issue for full -merger with the ``py3k`` branch. ++-------------+---------------+---------------+-----------------------+ +| Incr make | CPython 2.6.4 | CPython 3.1.1 | Unladen Swallow r1024 | ++=============+===============+===============+=======================+ +| Run 1 | 0m1.854s | 0m1.456s | 0m6.680s | ++-------------+---------------+---------------+-----------------------+ +| Run 2 | 0m1.437s | 0m1.442s | 0m5.310s | ++-------------+---------------+---------------+-----------------------+ +| Run 3 | 0m1.440s | 0m1.425s | 0m7.639s | ++-------------+---------------+---------------+-----------------------+ + +As with full builds, this extra time comes from statically linking LLVM +into ``libpython``. If ``libpython`` were linked shared against LLVM, this +overhead would go down. Proposed Merge Plan @@ -930,6 +995,31 @@ ``py3k-jit`` branch. +Contingency Plans +----------------- + +There is a chance that we will not be able to reduce memory usage or startup +time to a level satisfactory to the CPython community. Our primary contingency +plan for this situation is to shift from a online just-in-time compilation +strategy to an offline ahead-of-time strategy using an instrumented CPython +interpreter loop to obtain feedback. This is the same model used by gcc's +feedback-directed optimizations (`-fprofile-generate`) [#gcc-fdo]_ and +Microsoft Visual Studio's profile-guided optimizations [#msvc-pgo]_; we will +refer to this as "feedback-directed optimization" here, or FDO. + +We believe that an FDO compiler for Python would be inferior to a JIT compiler. +FDO requires a high-quality, representative benchmark suite, which is a relative +rarity in both open- and closed-source development. A JIT compiler can +dynamically find and optimize the hot spots in any application -- benchmark +suite or no -- allowing it to adapt to changes in application bottlenecks +without human intervention. + +If an ahead-of-time FDO compiler is required, it should be able to leverage a +large percentage of the code and infrastructure already developed for Unladen +Swallow's JIT compiler. Indeed, these two compilation strategies could exist +side-by-side. + + Future Work =========== @@ -959,6 +1049,9 @@ initially avoided a purely-tracing JIT compiler in favor of a simpler, function-at-a-time compiler. However this function-at-a-time compiler has laid the groundwork for a future tracing compiler implemented in the same terms. +- Profile generation/reuse. The runtime data gathered by the JIT could be + persisted to disk and reused by subsequent JIT compilations, or by external + tools such as Cython [#cython]_ or a feedback-enhanced code coverage tool. This list is by no means exhaustive. There is a vast literature on optimizations for dynamic languages that could and should be implemented in terms of Unladen @@ -977,8 +1070,6 @@ organization. We would like a non-Google-affiliated member of the CPython development team to review our work for correctness and compatibility, but we realize this may not be possible for every commit. -- *How to link LLVM.* Should we change LLVM to better support shared linking, - and then use shared linking to link the parts of it we need into CPython? - *Prioritization of remaining issues.* We would like input from the CPython development team on how to prioritize the remaining issues in the Unladen Swallow codebase. Some issues like memory usage are obviously critical before @@ -1007,6 +1098,10 @@ under the terms of the Python Software Foundation License v2 [#psf-lic]_ under the umbrella of Google's blanket Contributor License Agreement with the PSF. +LLVM is licensed [#llvm-lic]_ under the University of llinois/NCSA Open Source +License [#ui-lic]_, a liberal, OSI-approved license. The University of Illinois +Urbana-Champaign is the sole copyright holder for LLVM. + References ========== @@ -1026,9 +1121,6 @@ .. [#llvm-hardware] http://llvm.org/docs/GettingStarted.html#hardware -.. [#rebuild-too-much] - http://code.google.com/p/unladen-swallow/issues/detail?id=115 - .. [#llvm-c-api] http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ @@ -1077,6 +1169,9 @@ .. [#oprofile-jit-interface] http://oprofile.sourceforge.net/doc/devel/jit-interface.html +.. [#oprofile-workflow] + http://code.google.com/p/unladen-swallow/wiki/UsingOProfile + .. [#llvm-mingw] http://llvm.org/releases/download.html @@ -1179,6 +1274,12 @@ .. [#psf-lic] http://www.python.org/psf/license/ +.. [#llvm-lic] + http://llvm.org/docs/DeveloperPolicy.html#clp + +.. [#ui-lic] + http://www.opensource.org/licenses/UoI-NCSA.php + .. [#v8] http://code.google.com/p/v8/ @@ -1296,6 +1397,54 @@ .. [#us-nbody] http://code.google.com/p/unladen-swallow/source/browse/tests/performance/bm_nbody.py +.. [#us-shared-link-issue] + http://code.google.com/p/unladen-swallow/issues/detail?id=130 + +.. [#us-llvm-punchlist] + http://code.google.com/p/unladen-swallow/issues/detail?id=131 + +.. [#llvm-ppc-eager-jit-issue] + http://llvm.org/PR4816 + +.. [#llvm-arm-jit-issue] + http://llvm.org/PR6065 + +.. [#cython] + http://www.cython.org/ + +.. [#shedskin] + http://shed-skin.blogspot.com/ + +.. [#shedskin-library-limits] + http://shedskin.googlecode.com/files/shedskin-tutorial-0.3.html + +.. [#wpython] + http://code.google.com/p/wpython/ + +.. [#wpython-performance] + http://www.mail-archive.com/python-dev at python.org/msg45143.html + +.. [#ironpython] + http://ironpython.net/ + +.. [#mono] + http://www.mono-project.com/ + +.. [#jython] + http://www.jython.org/ + +.. [#jython-c-ext] + http://wiki.python.org/jython/JythonFaq/GeneralInfo + +.. [#pyv8] + http://code.google.com/p/pyv8/ + +.. [#gcc-fdo] + http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html + +.. [#msvc-pgo] + http://msdn.microsoft.com/en-us/library/e7k32f4k.aspx + Copyright ========= From python-checkins at python.org Tue Feb 9 17:51:16 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 09 Feb 2010 16:51:16 -0000 Subject: [Python-checkins] r78123 - in python/branches/py3k: Lib/test/test_xml_etree.py Lib/xml/etree/ElementTree.py Misc/ACKS Misc/NEWS Message-ID: Author: antoine.pitrou Date: Tue Feb 9 17:51:16 2010 New Revision: 78123 Log: Issue #6233: ElementTree failed converting unicode characters to XML entities when they could't be represented in the requested output encoding. Patch by Jerry Chen. Modified: python/branches/py3k/Lib/test/test_xml_etree.py python/branches/py3k/Lib/xml/etree/ElementTree.py python/branches/py3k/Misc/ACKS python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/test_xml_etree.py ============================================================================== --- python/branches/py3k/Lib/test/test_xml_etree.py (original) +++ python/branches/py3k/Lib/test/test_xml_etree.py Tue Feb 9 17:51:16 2010 @@ -210,6 +210,17 @@ """ ET.XML("" % encoding) +def check_issue6233(): + """ + >>> from xml.etree import ElementTree as ET + + >>> e = ET.XML("t\xe3g") + >>> ET.tostring(e, 'ascii') + b"\\ntãg" + >>> e = ET.XML("t\xe3g".encode('iso-8859-1')) # create byte string with the right encoding + >>> ET.tostring(e, 'ascii') + b"\\ntãg" + """ # # xinclude tests (samples from appendix C of the xinclude specification) Modified: python/branches/py3k/Lib/xml/etree/ElementTree.py ============================================================================== --- python/branches/py3k/Lib/xml/etree/ElementTree.py (original) +++ python/branches/py3k/Lib/xml/etree/ElementTree.py Tue Feb 9 17:51:16 2010 @@ -662,9 +662,9 @@ # write XML to file tag = node.tag if tag is Comment: - file.write(_encode("" % _escape_cdata(node.text), encoding)) + file.write(b"") elif tag is ProcessingInstruction: - file.write(_encode("" % _escape_cdata(node.text), encoding)) + file.write(b"") else: items = list(node.items()) xmlns_items = [] # new namespaces in this scope @@ -696,7 +696,7 @@ if node.text or len(node): file.write(_encode(">", encoding)) if node.text: - file.write(_encode(_escape_cdata(node.text), encoding)) + file.write(_encode_cdata(node.text, encoding)) for n in node: self._write(file, n, encoding, namespaces) file.write(_encode("", encoding)) @@ -705,7 +705,7 @@ for k, v in xmlns_items: del namespaces[v] if node.tail: - file.write(_encode(_escape_cdata(node.tail), encoding)) + file.write(_encode_cdata(node.tail, encoding)) # -------------------------------------------------------------------- # helpers @@ -788,13 +788,16 @@ # the following functions assume an ascii-compatible encoding # (or "utf-16") -def _escape_cdata(text): +def _encode_cdata(text, encoding): # escape character data try: text = text.replace("&", "&") text = text.replace("<", "<") text = text.replace(">", ">") - return text + if encoding: + return text.encode(encoding, "xmlcharrefreplace") + else: + return text except (TypeError, AttributeError): _raise_serialization_error(text) Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Tue Feb 9 17:51:16 2010 @@ -131,6 +131,7 @@ Brad Chapman David Chaum Nicolas Chauvat +Jerry Chen Michael Chermside Albert Chin-A-Young Adal Chiriliuc Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Feb 9 17:51:16 2010 @@ -242,6 +242,10 @@ Library ------- +- Issue #6233: ElementTree failed converting unicode characters to XML + entities when they could't be represented in the requested output + encoding. Patch by Jerry Chen. + - Issue #6003: add an argument to ``zipfile.Zipfile.writestr`` to specify the compression type. From python-checkins at python.org Tue Feb 9 17:53:09 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 09 Feb 2010 16:53:09 -0000 Subject: [Python-checkins] r78124 - in python/branches/release31-maint: Lib/test/test_xml_etree.py Lib/xml/etree/ElementTree.py Misc/ACKS Misc/NEWS Message-ID: Author: antoine.pitrou Date: Tue Feb 9 17:53:09 2010 New Revision: 78124 Log: Merged revisions 78123 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r78123 | antoine.pitrou | 2010-02-09 17:51:16 +0100 (mar., 09 f?vr. 2010) | 5 lines Issue #6233: ElementTree failed converting unicode characters to XML entities when they could't be represented in the requested output encoding. Patch by Jerry Chen. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_xml_etree.py python/branches/release31-maint/Lib/xml/etree/ElementTree.py python/branches/release31-maint/Misc/ACKS python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/test/test_xml_etree.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_xml_etree.py (original) +++ python/branches/release31-maint/Lib/test/test_xml_etree.py Tue Feb 9 17:53:09 2010 @@ -210,6 +210,17 @@ """ ET.XML("" % encoding) +def check_issue6233(): + """ + >>> from xml.etree import ElementTree as ET + + >>> e = ET.XML("t\xe3g") + >>> ET.tostring(e, 'ascii') + b"\\ntãg" + >>> e = ET.XML("t\xe3g".encode('iso-8859-1')) # create byte string with the right encoding + >>> ET.tostring(e, 'ascii') + b"\\ntãg" + """ # # xinclude tests (samples from appendix C of the xinclude specification) Modified: python/branches/release31-maint/Lib/xml/etree/ElementTree.py ============================================================================== --- python/branches/release31-maint/Lib/xml/etree/ElementTree.py (original) +++ python/branches/release31-maint/Lib/xml/etree/ElementTree.py Tue Feb 9 17:53:09 2010 @@ -662,9 +662,9 @@ # write XML to file tag = node.tag if tag is Comment: - file.write(_encode("" % _escape_cdata(node.text), encoding)) + file.write(b"") elif tag is ProcessingInstruction: - file.write(_encode("" % _escape_cdata(node.text), encoding)) + file.write(b"") else: items = list(node.items()) xmlns_items = [] # new namespaces in this scope @@ -696,7 +696,7 @@ if node.text or len(node): file.write(_encode(">", encoding)) if node.text: - file.write(_encode(_escape_cdata(node.text), encoding)) + file.write(_encode_cdata(node.text, encoding)) for n in node: self._write(file, n, encoding, namespaces) file.write(_encode("", encoding)) @@ -705,7 +705,7 @@ for k, v in xmlns_items: del namespaces[v] if node.tail: - file.write(_encode(_escape_cdata(node.tail), encoding)) + file.write(_encode_cdata(node.tail, encoding)) # -------------------------------------------------------------------- # helpers @@ -788,13 +788,16 @@ # the following functions assume an ascii-compatible encoding # (or "utf-16") -def _escape_cdata(text): +def _encode_cdata(text, encoding): # escape character data try: text = text.replace("&", "&") text = text.replace("<", "<") text = text.replace(">", ">") - return text + if encoding: + return text.encode(encoding, "xmlcharrefreplace") + else: + return text except (TypeError, AttributeError): _raise_serialization_error(text) Modified: python/branches/release31-maint/Misc/ACKS ============================================================================== --- python/branches/release31-maint/Misc/ACKS (original) +++ python/branches/release31-maint/Misc/ACKS Tue Feb 9 17:53:09 2010 @@ -126,6 +126,7 @@ Brad Chapman David Chaum Nicolas Chauvat +Jerry Chen Michael Chermside Albert Chin-A-Young Adal Chiriliuc Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Tue Feb 9 17:53:09 2010 @@ -79,6 +79,10 @@ Library ------- +- Issue #6233: ElementTree failed converting unicode characters to XML + entities when they could't be represented in the requested output + encoding. Patch by Jerry Chen. + - Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is specified, rather than fall through to AF_PACKET (in the `socket` module). Also, raise ValueError rather than TypeError when an unknown TIPC address From python-checkins at python.org Tue Feb 9 18:08:06 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 09 Feb 2010 17:08:06 -0000 Subject: [Python-checkins] r78125 - in python/trunk: Lib/test/test_xml_etree.py Lib/xml/etree/ElementTree.py Misc/ACKS Misc/NEWS Message-ID: Author: antoine.pitrou Date: Tue Feb 9 18:08:05 2010 New Revision: 78125 Log: Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">") in XML processing instructions and comments. These raw characters are allowed by the XML specification, and are necessary when outputting e.g. PHP code in a processing instruction. Patch by Neil Muller. Modified: python/trunk/Lib/test/test_xml_etree.py python/trunk/Lib/xml/etree/ElementTree.py python/trunk/Misc/ACKS python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/test_xml_etree.py ============================================================================== --- python/trunk/Lib/test/test_xml_etree.py (original) +++ python/trunk/Lib/test/test_xml_etree.py Tue Feb 9 18:08:05 2010 @@ -213,6 +213,23 @@ """ ET.XML("" % encoding) +def processinginstruction(): + """ + Test ProcessingInstruction directly + + >>> from xml.etree import ElementTree as ET + + >>> ET.tostring(ET.ProcessingInstruction('test', 'instruction')) + '' + >>> ET.tostring(ET.PI('test', 'instruction')) + '' + + Issue #2746 + + >>> ET.tostring(ET.PI('test', '')) + '?>' + + """ # # xinclude tests (samples from appendix C of the xinclude specification) Modified: python/trunk/Lib/xml/etree/ElementTree.py ============================================================================== --- python/trunk/Lib/xml/etree/ElementTree.py (original) +++ python/trunk/Lib/xml/etree/ElementTree.py Tue Feb 9 18:08:05 2010 @@ -666,9 +666,9 @@ # write XML to file tag = node.tag if tag is Comment: - file.write("" % _escape_cdata(node.text, encoding)) + file.write("" % _encode(node.text, encoding)) elif tag is ProcessingInstruction: - file.write("" % _escape_cdata(node.text, encoding)) + file.write("" % _encode(node.text, encoding)) else: items = node.items() xmlns_items = [] # new namespaces in this scope Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Tue Feb 9 18:08:05 2010 @@ -525,6 +525,7 @@ Sjoerd Mullender Sape Mullender Michael Muller +Neil Muller R. David Murray Piotr Meyer John Nagle Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Feb 9 18:08:05 2010 @@ -78,6 +78,11 @@ Library ------- +- Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">") + in XML processing instructions and comments. These raw characters are + allowed by the XML specification, and are necessary when outputting e.g. + PHP code in a processing instruction. Patch by Neil Muller. + - Issue #7869: logging: improved diagnostic for format-time errors. - Issue #7868: logging: added loggerClass attribute to Manager. From python-checkins at python.org Tue Feb 9 18:25:47 2010 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 09 Feb 2010 17:25:47 -0000 Subject: [Python-checkins] r78126 - in python/branches/py3k: Lib/test/test_xml_etree.py Lib/xml/etree/ElementTree.py Misc/ACKS Misc/NEWS Message-ID: Author: antoine.pitrou Date: Tue Feb 9 18:25:47 2010 New Revision: 78126 Log: Merged revisions 78125 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78125 | antoine.pitrou | 2010-02-09 18:08:05 +0100 (mar., 09 f?vr. 2010) | 7 lines Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">") in XML processing instructions and comments. These raw characters are allowed by the XML specification, and are necessary when outputting e.g. PHP code in a processing instruction. Patch by Neil Muller. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_xml_etree.py python/branches/py3k/Lib/xml/etree/ElementTree.py python/branches/py3k/Misc/ACKS python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/test_xml_etree.py ============================================================================== --- python/branches/py3k/Lib/test/test_xml_etree.py (original) +++ python/branches/py3k/Lib/test/test_xml_etree.py Tue Feb 9 18:25:47 2010 @@ -210,6 +210,26 @@ """ ET.XML("" % encoding) +def processinginstruction(): + r""" + Test ProcessingInstruction directly + + >>> from xml.etree import ElementTree as ET + + >>> ET.tostring(ET.ProcessingInstruction('test', 'instruction')) + '' + >>> ET.tostring(ET.PI('test', 'instruction')) + '' + + Issue #2746 + + >>> ET.tostring(ET.PI('test', '')) + '?>' + >>> ET.tostring(ET.PI('test', '\xe3'), 'latin1') + b"\n\xe3?>" + + """ + def check_issue6233(): """ >>> from xml.etree import ElementTree as ET Modified: python/branches/py3k/Lib/xml/etree/ElementTree.py ============================================================================== --- python/branches/py3k/Lib/xml/etree/ElementTree.py (original) +++ python/branches/py3k/Lib/xml/etree/ElementTree.py Tue Feb 9 18:25:47 2010 @@ -662,9 +662,9 @@ # write XML to file tag = node.tag if tag is Comment: - file.write(b"") + file.write(_encode("" % node.text, encoding)) elif tag is ProcessingInstruction: - file.write(b"") + file.write(_encode("" % node.text, encoding)) else: items = list(node.items()) xmlns_items = [] # new namespaces in this scope Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Tue Feb 9 18:25:47 2010 @@ -529,6 +529,7 @@ Sjoerd Mullender Sape Mullender Michael Muller +Neil Muller R. David Murray Piotr Meyer John Nagle Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Feb 9 18:25:47 2010 @@ -242,6 +242,11 @@ Library ------- +- Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">") + in XML processing instructions and comments. These raw characters are + allowed by the XML specification, and are necessary when outputting e.g. + PHP code in a processing instruction. Patch by Neil Muller. + - Issue #6233: ElementTree failed converting unicode characters to XML entities when they could't be represented in the requested output encoding. Patch by Jerry Chen. From python-checkins at python.org Tue Feb 9 22:27:48 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 09 Feb 2010 21:27:48 -0000 Subject: [Python-checkins] r78127 - peps/trunk/pep-0345.txt Message-ID: Author: tarek.ziade Date: Tue Feb 9 22:27:47 2010 New Revision: 78127 Log: made author-email optional Modified: peps/trunk/pep-0345.txt Modified: peps/trunk/pep-0345.txt ============================================================================== --- peps/trunk/pep-0345.txt (original) +++ peps/trunk/pep-0345.txt Tue Feb 9 22:27:47 2010 @@ -189,8 +189,8 @@ Los Angeles, CA -Author-email -:::::::::::: +Author-email (optional) +::::::::::::::::::::::: A string containing the author's e-mail address. It can contain a name and e-mail address in the legal forms for a RFC-822 From python-checkins at python.org Tue Feb 9 22:41:27 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 09 Feb 2010 21:41:27 -0000 Subject: [Python-checkins] r78128 - peps/trunk/pep-0345.txt Message-ID: Author: tarek.ziade Date: Tue Feb 9 22:41:26 2010 New Revision: 78128 Log: added author field in the list of changed fields Modified: peps/trunk/pep-0345.txt Modified: peps/trunk/pep-0345.txt ============================================================================== --- peps/trunk/pep-0345.txt (original) +++ peps/trunk/pep-0345.txt Tue Feb 9 22:41:26 2010 @@ -514,7 +514,8 @@ * Changed fields: -- Platform + - Platform + - Author * Added fields: From python-checkins at python.org Tue Feb 9 23:42:53 2010 From: python-checkins at python.org (tarek.ziade) Date: Tue, 09 Feb 2010 22:42:53 -0000 Subject: [Python-checkins] r78129 - peps/trunk/pep-0345.txt Message-ID: Author: tarek.ziade Date: Tue Feb 9 23:42:53 2010 New Revision: 78129 Log: removed the section about why the author-email field *was* mandatory Modified: peps/trunk/pep-0345.txt Modified: peps/trunk/pep-0345.txt ============================================================================== --- peps/trunk/pep-0345.txt (original) +++ peps/trunk/pep-0345.txt Tue Feb 9 23:42:53 2010 @@ -194,14 +194,7 @@ A string containing the author's e-mail address. It can contain a name and e-mail address in the legal forms for a RFC-822 -``From:`` header. It's not optional because cataloging systems -can use the e-mail portion of this field as a unique key -representing the author. A catalog might provide authors the -ability to store their GPG key, personal home page, and other -additional metadata *about the author*, and optionally the -ability to associate several e-mail addresses with the same -person. Author-related metadata fields are not covered by this -PEP. +``From:`` header. Example:: From solipsis at pitrou.net Wed Feb 10 01:04:00 2010 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 10 Feb 2010 01:04:00 +0100 (CET) Subject: [Python-checkins] Daily py3k reference leaks (r78126): sum=0 Message-ID: <20100210000400.85C481770B@ns6635.ovh.net> py3k results for svn r78126 (hg cset 08f045a18b09) -------------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/py3k/refleaks/reflogVfGoct', '-x', 'test_httpservers'] From python-checkins at python.org Wed Feb 10 15:25:12 2010 From: python-checkins at python.org (michael.foord) Date: Wed, 10 Feb 2010 14:25:12 -0000 Subject: [Python-checkins] r78130 - in python/trunk: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/__init__.py Lib/unittest/case.py Lib/unittest/result.py Lib/unittest/runner.py Misc/NEWS Message-ID: Author: michael.foord Date: Wed Feb 10 15:25:12 2010 New Revision: 78130 Log: Issue 7893 and Issue 7588 Modified: python/trunk/Doc/library/unittest.rst python/trunk/Lib/test/test_unittest.py python/trunk/Lib/unittest/__init__.py python/trunk/Lib/unittest/case.py python/trunk/Lib/unittest/result.py python/trunk/Lib/unittest/runner.py python/trunk/Misc/NEWS Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Wed Feb 10 15:25:12 2010 @@ -134,7 +134,7 @@ represent tests. The crux of each test is a call to :meth:`~TestCase.assertEqual` to check for an -expected result; :meth:`~TestCase.assert_` to verify a condition; or +expected result; :meth:`~TestCase.assertTrue` to verify a condition; or :meth:`~TestCase.assertRaises` to verify that an expected exception gets raised. These methods are used instead of the :keyword:`assert` statement so the test runner can accumulate all test results and produce a report. @@ -682,6 +682,7 @@ .. deprecated:: 2.7 :meth:`failUnless`; use one of the ``assert`` variants. + :meth:`assert_`; use :meth:`assertTrue`. .. method:: assertEqual(first, second[, msg]) @@ -1063,13 +1064,7 @@ Returns a description of the test, or :const:`None` if no description has been provided. The default implementation of this method returns the first line of the test method's docstring, if available, - along with the method name. - - .. versionchanged:: 2.7 - In earlier versions this only returned the first line of the test - method's docstring, if available or the :const:`None`. That led to - undesirable behavior of not printing the test name when someone was - thoughtful enough to write a docstring. + or :const:`None`. .. method:: addTypeEqualityFunc(typeobj, function) @@ -1521,6 +1516,14 @@ The default implementation appends the test to the instance's :attr:`unexpectedSuccesses` attribute. +.. class:: TextTestResult(stream, descriptions, verbosity) + + A concrete implementation of :class:`TestResult` used by the + :class:`TextTestRunner`. + + .. versionadded:: 2.7 + This class was previously named ``_TextTestResult``. The old name still + exists as an alias but is deprecated. .. data:: defaultTestLoader @@ -1529,7 +1532,7 @@ instead of repeatedly creating new instances. -.. class:: TextTestRunner([stream[, descriptions[, verbosity]]]) +.. class:: TextTestRunner([stream[, descriptions[, verbosity], [resultclass]]]) A basic test runner implementation which prints results on standard error. It has a few configurable parameters, but is essentially very simple. Graphical @@ -1541,6 +1544,13 @@ It is not intended to be called directly, but can be overridden in subclasses to provide a custom ``TestResult``. + ``_makeResult()`` instantiates the class or callable passed in the + ``TextTestRunner`` constructor as the ``resultclass`` argument. It + defaults to :class::`TextTestResult` if no ``resultclass`` is provided. + The result class is instantiated with the following arguments:: + + stream, descriptions, verbosity + .. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit, [verbosity]]]]]]]) Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Wed Feb 10 15:25:12 2010 @@ -2032,6 +2032,35 @@ self.assertTrue(test_case is test) self.assertIsInstance(formatted_exc, str) + def testGetDescriptionWithoutDocstring(self): + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + 'testGetDescriptionWithoutDocstring (' + __name__ + + '.Test_TestResult)') + + def testGetDescriptionWithOneLineDocstring(self): + """Tests getDescription() for a method with a docstring.""" + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + ('testGetDescriptionWithOneLineDocstring ' + '(' + __name__ + '.Test_TestResult)\n' + 'Tests getDescription() for a method with a docstring.')) + + def testGetDescriptionWithMultiLineDocstring(self): + """Tests getDescription() for a method with a longer docstring. + The second line of the docstring. + """ + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + ('testGetDescriptionWithMultiLineDocstring ' + '(' + __name__ + '.Test_TestResult)\n' + 'Tests getDescription() for a method with a longer ' + 'docstring.')) + + ### Support code for Test_TestCase ################################################################ @@ -2445,18 +2474,13 @@ self.assertEqual(events, expected) def testShortDescriptionWithoutDocstring(self): - self.assertEqual( - self.shortDescription(), - 'testShortDescriptionWithoutDocstring (' + __name__ + - '.Test_TestCase)') + self.assertIsNone(self.shortDescription()) def testShortDescriptionWithOneLineDocstring(self): """Tests shortDescription() for a method with a docstring.""" self.assertEqual( self.shortDescription(), - ('testShortDescriptionWithOneLineDocstring ' - '(' + __name__ + '.Test_TestCase)\n' - 'Tests shortDescription() for a method with a docstring.')) + 'Tests shortDescription() for a method with a docstring.') def testShortDescriptionWithMultiLineDocstring(self): """Tests shortDescription() for a method with a longer docstring. @@ -2467,10 +2491,8 @@ """ self.assertEqual( self.shortDescription(), - ('testShortDescriptionWithMultiLineDocstring ' - '(' + __name__ + '.Test_TestCase)\n' 'Tests shortDescription() for a method with a longer ' - 'docstring.')) + 'docstring.') def testAddTypeEqualityFunc(self): class SadSnake(object): @@ -3491,6 +3513,19 @@ # StringIO objects never compare equal, a cheap test instead. self.assertEqual(obj.stream.getvalue(), stream.getvalue()) + def test_resultclass(self): + def MockResultClass(*args): + return args + STREAM = object() + DESCRIPTIONS = object() + VERBOSITY = object() + runner = unittest.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY, + resultclass=MockResultClass) + self.assertEqual(runner.resultclass, MockResultClass) + + expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY) + self.assertEqual(runner._makeResult(), expectedresult) + class TestDiscovery(TestCase): Modified: python/trunk/Lib/unittest/__init__.py ============================================================================== --- python/trunk/Lib/unittest/__init__.py (original) +++ python/trunk/Lib/unittest/__init__.py Wed Feb 10 15:25:12 2010 @@ -60,4 +60,7 @@ from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames, findTestCases) from .main import TestProgram, main -from .runner import TextTestRunner +from .runner import TextTestRunner, TextTestResult + +# deprecated +_TextTestResult = TextTestResult Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Wed Feb 10 15:25:12 2010 @@ -216,18 +216,15 @@ return result.TestResult() def shortDescription(self): - """Returns both the test method name and first line of its docstring. + """Returns a one-line description of the test, or None if no + description has been provided. - If no docstring is given, only returns the method name. + The default implementation of this method returns the first line of + the specified test method's docstring. """ - desc = str(self) - doc_first_line = None + doc = self._testMethodDoc + return doc and doc.split("\n")[0].strip() or None - if self._testMethodDoc: - doc_first_line = self._testMethodDoc.split("\n")[0].strip() - if doc_first_line: - desc = '\n'.join((desc, doc_first_line)) - return desc def id(self): return "%s.%s" % (util.strclass(self.__class__), self._testMethodName) @@ -488,7 +485,6 @@ assertNotEquals = assertNotEqual assertAlmostEquals = assertAlmostEqual assertNotAlmostEquals = assertNotAlmostEqual - assert_ = assertTrue # These fail* assertion method names are pending deprecation and will # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578 @@ -505,6 +501,7 @@ failUnlessAlmostEqual = _deprecate(assertAlmostEqual) failIfAlmostEqual = _deprecate(assertNotAlmostEqual) failUnless = _deprecate(assertTrue) + assert_ = _deprecate(assertTrue) failUnlessRaises = _deprecate(assertRaises) failIf = _deprecate(assertFalse) Modified: python/trunk/Lib/unittest/result.py ============================================================================== --- python/trunk/Lib/unittest/result.py (original) +++ python/trunk/Lib/unittest/result.py Wed Feb 10 15:25:12 2010 @@ -27,7 +27,7 @@ def startTest(self, test): "Called when the given test is about to be run" - self.testsRun = self.testsRun + 1 + self.testsRun += 1 def startTestRun(self): """Called once before any tests are executed. @@ -36,8 +36,7 @@ """ def stopTest(self, test): - "Called when the given test has been run" - pass + """Called when the given test has been run""" def stopTestRun(self): """Called once after all tests are executed. Modified: python/trunk/Lib/unittest/runner.py ============================================================================== --- python/trunk/Lib/unittest/runner.py (original) +++ python/trunk/Lib/unittest/runner.py Wed Feb 10 15:25:12 2010 @@ -22,7 +22,7 @@ self.write('\n') # text-mode streams translate to \r\n if needed -class _TextTestResult(result.TestResult): +class TextTestResult(result.TestResult): """A test result class that can print formatted text results to a stream. Used by TextTestRunner. @@ -31,27 +31,28 @@ separator2 = '-' * 70 def __init__(self, stream, descriptions, verbosity): - super(_TextTestResult, self).__init__() + super(TextTestResult, self).__init__() self.stream = stream self.showAll = verbosity > 1 self.dots = verbosity == 1 self.descriptions = descriptions def getDescription(self, test): - if self.descriptions: - return test.shortDescription() or str(test) + doc_first_line = test.shortDescription() + if self.descriptions and doc_first_line: + return '\n'.join((str(test), doc_first_line)) else: return str(test) def startTest(self, test): - super(_TextTestResult, self).startTest(test) + super(TextTestResult, self).startTest(test) if self.showAll: self.stream.write(self.getDescription(test)) self.stream.write(" ... ") self.stream.flush() def addSuccess(self, test): - super(_TextTestResult, self).addSuccess(test) + super(TextTestResult, self).addSuccess(test) if self.showAll: self.stream.writeln("ok") elif self.dots: @@ -59,7 +60,7 @@ self.stream.flush() def addError(self, test, err): - super(_TextTestResult, self).addError(test, err) + super(TextTestResult, self).addError(test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: @@ -67,7 +68,7 @@ self.stream.flush() def addFailure(self, test, err): - super(_TextTestResult, self).addFailure(test, err) + super(TextTestResult, self).addFailure(test, err) if self.showAll: self.stream.writeln("FAIL") elif self.dots: @@ -75,7 +76,7 @@ self.stream.flush() def addSkip(self, test, reason): - super(_TextTestResult, self).addSkip(test, reason) + super(TextTestResult, self).addSkip(test, reason) if self.showAll: self.stream.writeln("skipped {0!r}".format(reason)) elif self.dots: @@ -83,7 +84,7 @@ self.stream.flush() def addExpectedFailure(self, test, err): - super(_TextTestResult, self).addExpectedFailure(test, err) + super(TextTestResult, self).addExpectedFailure(test, err) if self.showAll: self.stream.writeln("expected failure") elif self.dots: @@ -91,7 +92,7 @@ self.stream.flush() def addUnexpectedSuccess(self, test): - super(_TextTestResult, self).addUnexpectedSuccess(test) + super(TextTestResult, self).addUnexpectedSuccess(test) if self.showAll: self.stream.writeln("unexpected success") elif self.dots: @@ -118,13 +119,18 @@ It prints out the names of tests as they are run, errors as they occur, and a summary of the results at the end of the test run. """ - def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1): + resultclass = TextTestResult + + def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1, + resultclass=None): self.stream = _WritelnDecorator(stream) self.descriptions = descriptions self.verbosity = verbosity + if resultclass is not None: + self.resultclass = resultclass def _makeResult(self): - return _TextTestResult(self.stream, self.descriptions, self.verbosity) + return self.resultclass(self.stream, self.descriptions, self.verbosity) def run(self, test): "Run the given test case or test suite." Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Feb 10 15:25:12 2010 @@ -17,6 +17,11 @@ - Issue #6003: add an argument to ``zipfile.Zipfile.writestr`` to specify the compression type. +- Issue #7893: ``unittest.TextTestResult`` is made public and a ``resultclass`` + argument added to the TextTestRunner constructor allowing a different result + class to be used without having to subclass. +- Issue 7588: ``unittest.TextTestResult.getDescription`` now includes the test + name in failure reports even if the test has a docstring. What's New in Python 2.7 alpha 3? From python-checkins at python.org Wed Feb 10 15:31:31 2010 From: python-checkins at python.org (michael.foord) Date: Wed, 10 Feb 2010 14:31:31 -0000 Subject: [Python-checkins] r78131 - python/trunk/Lib/unittest/case.py Message-ID: Author: michael.foord Date: Wed Feb 10 15:31:30 2010 New Revision: 78131 Log: Remove deprecation on assert_. It is used too frequently. Modified: python/trunk/Lib/unittest/case.py Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Wed Feb 10 15:31:30 2010 @@ -485,6 +485,7 @@ assertNotEquals = assertNotEqual assertAlmostEquals = assertAlmostEqual assertNotAlmostEquals = assertNotAlmostEqual + assert_ = assertTrue # These fail* assertion method names are pending deprecation and will # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578 @@ -501,7 +502,6 @@ failUnlessAlmostEqual = _deprecate(assertAlmostEqual) failIfAlmostEqual = _deprecate(assertNotAlmostEqual) failUnless = _deprecate(assertTrue) - assert_ = _deprecate(assertTrue) failUnlessRaises = _deprecate(assertRaises) failIf = _deprecate(assertFalse) From python-checkins at python.org Wed Feb 10 16:50:58 2010 From: python-checkins at python.org (michael.foord) Date: Wed, 10 Feb 2010 15:50:58 -0000 Subject: [Python-checkins] r78132 - python/trunk/Lib/test/test_unittest.py Message-ID: Author: michael.foord Date: Wed Feb 10 16:50:58 2010 New Revision: 78132 Log: Fix for unittest tests, to be merged to py3k Modified: python/trunk/Lib/test/test_unittest.py Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Wed Feb 10 16:50:58 2010 @@ -2033,7 +2033,7 @@ self.assertIsInstance(formatted_exc, str) def testGetDescriptionWithoutDocstring(self): - result = unittest.TextTestResult(None, True, None) + result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), 'testGetDescriptionWithoutDocstring (' + __name__ + @@ -2041,7 +2041,7 @@ def testGetDescriptionWithOneLineDocstring(self): """Tests getDescription() for a method with a docstring.""" - result = unittest.TextTestResult(None, True, None) + result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), ('testGetDescriptionWithOneLineDocstring ' @@ -2052,7 +2052,7 @@ """Tests getDescription() for a method with a longer docstring. The second line of the docstring. """ - result = unittest.TextTestResult(None, True, None) + result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), ('testGetDescriptionWithMultiLineDocstring ' From python-checkins at python.org Wed Feb 10 16:51:42 2010 From: python-checkins at python.org (michael.foord) Date: Wed, 10 Feb 2010 15:51:42 -0000 Subject: [Python-checkins] r78133 - in python/branches/py3k: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/__init__.py Lib/unittest/case.py Lib/unittest/result.py Lib/unittest/runner.py Misc/NEWS Message-ID: Author: michael.foord Date: Wed Feb 10 16:51:42 2010 New Revision: 78133 Log: Merged revisions 78130 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78130 | michael.foord | 2010-02-10 14:25:12 +0000 (Wed, 10 Feb 2010) | 1 line Issue 7893 and Issue 7588 ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/unittest/__init__.py python/branches/py3k/Lib/unittest/case.py python/branches/py3k/Lib/unittest/result.py python/branches/py3k/Lib/unittest/runner.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Wed Feb 10 16:51:42 2010 @@ -195,7 +195,7 @@ represent tests. The crux of each test is a call to :meth:`~TestCase.assertEqual` to check for an -expected result; :meth:`~TestCase.assert_` to verify a condition; or +expected result; :meth:`~TestCase.assertTrue` to verify a condition; or :meth:`~TestCase.assertRaises` to verify that an expected exception gets raised. These methods are used instead of the :keyword:`assert` statement so the test runner can accumulate all test results and produce a report. @@ -677,6 +677,7 @@ .. deprecated:: 3.1 :meth:`failUnless`. + :meth:`assert_`; use :meth:`assertTrue`. .. method:: assertEqual(first, second, msg=None) @@ -1067,14 +1068,13 @@ Returns a description of the test, or :const:`None` if no description has been provided. The default implementation of this method returns the first line of the test method's docstring, if available, - along with the method name. - - .. versionchanged:: 3.1 - In earlier versions this only returned the first line of the test - method's docstring, if available or the :const:`None`. That led to - undesirable behavior of not printing the test name when someone was - thoughtful enough to write a docstring. + or :const:`None`. + .. versionchanged:: 3.1,3.2 + In 3.1 this was changed to add the test name to the short description + even in the presence of a docstring. This caused compatibility issues + with unittest extensions and adding the test name was moved to the + :class:`TextTestResult`. .. method:: addTypeEqualityFunc(typeobj, function) @@ -1517,6 +1517,14 @@ The default implementation appends the test to the instance's :attr:`unexpectedSuccesses` attribute. +.. class:: TextTestResult(stream, descriptions, verbosity) + + A concrete implementation of :class:`TestResult` used by the + :class:`TextTestRunner`. + + .. versionadded:: 3.2 + This class was previously named ``_TextTestResult``. The old name still + exists as an alias but is deprecated. .. data:: defaultTestLoader @@ -1525,7 +1533,7 @@ instead of repeatedly creating new instances. -.. class:: TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=1) +.. class:: TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=1, runnerclass=None) A basic test runner implementation which prints results on standard error. It has a few configurable parameters, but is essentially very simple. Graphical @@ -1537,6 +1545,12 @@ It is not intended to be called directly, but can be overridden in subclasses to provide a custom ``TestResult``. + ``_makeResult()`` instantiates the class or callable passed in the + ``TextTestRunner`` constructor as the ``resultclass`` argument. It + defaults to :class::`TextTestResult` if no ``resultclass`` is provided. + The result class is instantiated with the following arguments:: + + stream, descriptions, verbosity .. function:: main(module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=unittest.loader.defaultTestLoader, exit=True, verbosity=1) Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Wed Feb 10 16:51:42 2010 @@ -2044,6 +2044,35 @@ self.assertTrue(test_case is test) self.assertIsInstance(formatted_exc, str) + def testGetDescriptionWithoutDocstring(self): + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + 'testGetDescriptionWithoutDocstring (' + __name__ + + '.Test_TestResult)') + + def testGetDescriptionWithOneLineDocstring(self): + """Tests getDescription() for a method with a docstring.""" + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + ('testGetDescriptionWithOneLineDocstring ' + '(' + __name__ + '.Test_TestResult)\n' + 'Tests getDescription() for a method with a docstring.')) + + def testGetDescriptionWithMultiLineDocstring(self): + """Tests getDescription() for a method with a longer docstring. + The second line of the docstring. + """ + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + ('testGetDescriptionWithMultiLineDocstring ' + '(' + __name__ + '.Test_TestResult)\n' + 'Tests getDescription() for a method with a longer ' + 'docstring.')) + + ### Support code for Test_TestCase ################################################################ @@ -2458,18 +2487,13 @@ self.assertEqual(events, expected) def testShortDescriptionWithoutDocstring(self): - self.assertEqual( - self.shortDescription(), - 'testShortDescriptionWithoutDocstring (' + __name__ + - '.Test_TestCase)') + self.assertIsNone(self.shortDescription()) def testShortDescriptionWithOneLineDocstring(self): """Tests shortDescription() for a method with a docstring.""" self.assertEqual( self.shortDescription(), - ('testShortDescriptionWithOneLineDocstring ' - '(' + __name__ + '.Test_TestCase)\n' - 'Tests shortDescription() for a method with a docstring.')) + 'Tests shortDescription() for a method with a docstring.') def testShortDescriptionWithMultiLineDocstring(self): """Tests shortDescription() for a method with a longer docstring. @@ -2480,10 +2504,8 @@ """ self.assertEqual( self.shortDescription(), - ('testShortDescriptionWithMultiLineDocstring ' - '(' + __name__ + '.Test_TestCase)\n' 'Tests shortDescription() for a method with a longer ' - 'docstring.')) + 'docstring.') def testAddTypeEqualityFunc(self): class SadSnake(object): @@ -3472,6 +3494,19 @@ # StringIO objects never compare equal, a cheap test instead. self.assertEqual(obj.stream.getvalue(), stream.getvalue()) + def test_resultclass(self): + def MockResultClass(*args): + return args + STREAM = object() + DESCRIPTIONS = object() + VERBOSITY = object() + runner = unittest.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY, + resultclass=MockResultClass) + self.assertEqual(runner.resultclass, MockResultClass) + + expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY) + self.assertEqual(runner._makeResult(), expectedresult) + class TestDiscovery(TestCase): Modified: python/branches/py3k/Lib/unittest/__init__.py ============================================================================== --- python/branches/py3k/Lib/unittest/__init__.py (original) +++ python/branches/py3k/Lib/unittest/__init__.py Wed Feb 10 16:51:42 2010 @@ -60,4 +60,7 @@ from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames, findTestCases) from .main import TestProgram, main -from .runner import TextTestRunner +from .runner import TextTestRunner, TextTestResult + +# deprecated +_TextTestResult = TextTestResult Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Wed Feb 10 16:51:42 2010 @@ -229,18 +229,15 @@ return result.TestResult() def shortDescription(self): - """Returns both the test method name and first line of its docstring. + """Returns a one-line description of the test, or None if no + description has been provided. - If no docstring is given, only returns the method name. + The default implementation of this method returns the first line of + the specified test method's docstring. """ - desc = str(self) - doc_first_line = None + doc = self._testMethodDoc + return doc and doc.split("\n")[0].strip() or None - if self._testMethodDoc: - doc_first_line = self._testMethodDoc.split("\n")[0].strip() - if doc_first_line: - desc = '\n'.join((desc, doc_first_line)) - return desc def id(self): return "%s.%s" % (util.strclass(self.__class__), self._testMethodName) @@ -501,7 +498,6 @@ assertNotEquals = assertNotEqual assertAlmostEquals = assertAlmostEqual assertNotAlmostEquals = assertNotAlmostEqual - assert_ = assertTrue # These fail* assertion method names are pending deprecation and will # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578 @@ -518,6 +514,7 @@ failUnlessAlmostEqual = _deprecate(assertAlmostEqual) failIfAlmostEqual = _deprecate(assertNotAlmostEqual) failUnless = _deprecate(assertTrue) + assert_ = _deprecate(assertTrue) failUnlessRaises = _deprecate(assertRaises) failIf = _deprecate(assertFalse) Modified: python/branches/py3k/Lib/unittest/result.py ============================================================================== --- python/branches/py3k/Lib/unittest/result.py (original) +++ python/branches/py3k/Lib/unittest/result.py Wed Feb 10 16:51:42 2010 @@ -27,7 +27,7 @@ def startTest(self, test): "Called when the given test is about to be run" - self.testsRun = self.testsRun + 1 + self.testsRun += 1 def startTestRun(self): """Called once before any tests are executed. @@ -36,8 +36,7 @@ """ def stopTest(self, test): - "Called when the given test has been run" - pass + """Called when the given test has been run""" def stopTestRun(self): """Called once after all tests are executed. Modified: python/branches/py3k/Lib/unittest/runner.py ============================================================================== --- python/branches/py3k/Lib/unittest/runner.py (original) +++ python/branches/py3k/Lib/unittest/runner.py Wed Feb 10 16:51:42 2010 @@ -22,7 +22,7 @@ self.write('\n') # text-mode streams translate to \r\n if needed -class _TextTestResult(result.TestResult): +class TextTestResult(result.TestResult): """A test result class that can print formatted text results to a stream. Used by TextTestRunner. @@ -31,27 +31,28 @@ separator2 = '-' * 70 def __init__(self, stream, descriptions, verbosity): - super(_TextTestResult, self).__init__() + super(TextTestResult, self).__init__() self.stream = stream self.showAll = verbosity > 1 self.dots = verbosity == 1 self.descriptions = descriptions def getDescription(self, test): - if self.descriptions: - return test.shortDescription() or str(test) + doc_first_line = test.shortDescription() + if self.descriptions and doc_first_line: + return '\n'.join((str(test), doc_first_line)) else: return str(test) def startTest(self, test): - super(_TextTestResult, self).startTest(test) + super(TextTestResult, self).startTest(test) if self.showAll: self.stream.write(self.getDescription(test)) self.stream.write(" ... ") self.stream.flush() def addSuccess(self, test): - super(_TextTestResult, self).addSuccess(test) + super(TextTestResult, self).addSuccess(test) if self.showAll: self.stream.writeln("ok") elif self.dots: @@ -59,7 +60,7 @@ self.stream.flush() def addError(self, test, err): - super(_TextTestResult, self).addError(test, err) + super(TextTestResult, self).addError(test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: @@ -67,7 +68,7 @@ self.stream.flush() def addFailure(self, test, err): - super(_TextTestResult, self).addFailure(test, err) + super(TextTestResult, self).addFailure(test, err) if self.showAll: self.stream.writeln("FAIL") elif self.dots: @@ -75,7 +76,7 @@ self.stream.flush() def addSkip(self, test, reason): - super(_TextTestResult, self).addSkip(test, reason) + super(TextTestResult, self).addSkip(test, reason) if self.showAll: self.stream.writeln("skipped {0!r}".format(reason)) elif self.dots: @@ -83,7 +84,7 @@ self.stream.flush() def addExpectedFailure(self, test, err): - super(_TextTestResult, self).addExpectedFailure(test, err) + super(TextTestResult, self).addExpectedFailure(test, err) if self.showAll: self.stream.writeln("expected failure") elif self.dots: @@ -91,7 +92,7 @@ self.stream.flush() def addUnexpectedSuccess(self, test): - super(_TextTestResult, self).addUnexpectedSuccess(test) + super(TextTestResult, self).addUnexpectedSuccess(test) if self.showAll: self.stream.writeln("unexpected success") elif self.dots: @@ -118,13 +119,18 @@ It prints out the names of tests as they are run, errors as they occur, and a summary of the results at the end of the test run. """ - def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1): + resultclass = TextTestResult + + def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1, + resultclass=None): self.stream = _WritelnDecorator(stream) self.descriptions = descriptions self.verbosity = verbosity + if resultclass is not None: + self.resultclass = resultclass def _makeResult(self): - return _TextTestResult(self.stream, self.descriptions, self.verbosity) + return self.resultclass(self.stream, self.descriptions, self.verbosity) def run(self, test): "Run the given test case or test suite." Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Feb 10 16:51:42 2010 @@ -447,6 +447,13 @@ unpickled. This fixes crashes under Windows when trying to run test_multiprocessing in verbose mode. +- Issue #7893: ``unittest.TextTestResult`` is made public and a ``resultclass`` + argument added to the TextTestRunner constructor allowing a different result + class to be used without having to subclass. + +- Issue 7588: ``unittest.TextTestResult.getDescription`` now includes the test + name in failure reports even if the test has a docstring. + - Issue #3001: Add a C implementation of recursive locks which is used by default when instantiating a `threading.RLock` object. This makes recursive locks as fast as regular non-recursive locks (previously, From python-checkins at python.org Wed Feb 10 16:52:56 2010 From: python-checkins at python.org (michael.foord) Date: Wed, 10 Feb 2010 15:52:56 -0000 Subject: [Python-checkins] r78134 - in python/branches/py3k: Lib/unittest/case.py Message-ID: Author: michael.foord Date: Wed Feb 10 16:52:56 2010 New Revision: 78134 Log: Merged revisions 78131 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78131 | michael.foord | 2010-02-10 14:31:30 +0000 (Wed, 10 Feb 2010) | 1 line Remove deprecation on assert_. It is used too frequently. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/unittest/case.py Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Wed Feb 10 16:52:56 2010 @@ -498,6 +498,7 @@ assertNotEquals = assertNotEqual assertAlmostEquals = assertAlmostEqual assertNotAlmostEquals = assertNotAlmostEqual + assert_ = assertTrue # These fail* assertion method names are pending deprecation and will # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578 @@ -514,7 +515,6 @@ failUnlessAlmostEqual = _deprecate(assertAlmostEqual) failIfAlmostEqual = _deprecate(assertNotAlmostEqual) failUnless = _deprecate(assertTrue) - assert_ = _deprecate(assertTrue) failUnlessRaises = _deprecate(assertRaises) failIf = _deprecate(assertFalse) From python-checkins at python.org Wed Feb 10 16:53:19 2010 From: python-checkins at python.org (michael.foord) Date: Wed, 10 Feb 2010 15:53:19 -0000 Subject: [Python-checkins] r78135 - in python/branches/py3k: Lib/test/test_unittest.py Message-ID: Author: michael.foord Date: Wed Feb 10 16:53:19 2010 New Revision: 78135 Log: Merged revisions 78132 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r78132 | michael.foord | 2010-02-10 15:50:58 +0000 (Wed, 10 Feb 2010) | 1 line Fix for unittest tests, to be merged to py3k ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_unittest.py Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Wed Feb 10 16:53:19 2010 @@ -2045,7 +2045,7 @@ self.assertIsInstance(formatted_exc, str) def testGetDescriptionWithoutDocstring(self): - result = unittest.TextTestResult(None, True, None) + result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), 'testGetDescriptionWithoutDocstring (' + __name__ + @@ -2053,7 +2053,7 @@ def testGetDescriptionWithOneLineDocstring(self): """Tests getDescription() for a method with a docstring.""" - result = unittest.TextTestResult(None, True, None) + result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), ('testGetDescriptionWithOneLineDocstring ' @@ -2064,7 +2064,7 @@ """Tests getDescription() for a method with a longer docstring. The second line of the docstring. """ - result = unittest.TextTestResult(None, True, None) + result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), ('testGetDescriptionWithMultiLineDocstring ' From python-checkins at python.org Wed Feb 10 22:40:33 2010 From: python-checkins at python.org (ezio.melotti) Date: Wed, 10 Feb 2010 21:40:33 -0000 Subject: [Python-checkins] r78136 - in python/trunk: Lib/test/regrtest.py Lib/test/test_subprocess.py Lib/test/test_support.py Misc/NEWS Message-ID: Author: ezio.melotti Date: Wed Feb 10 22:40:33 2010 New Revision: 78136 Log: #7712: add a temp_cwd context manager to test_support and use it in regrtest to run all the tests in a temporary directory, saving the original CWD in test_support.SAVEDCWD. Thanks to Florent Xicluna who helped with the patch. Modified: python/trunk/Lib/test/regrtest.py python/trunk/Lib/test/test_subprocess.py python/trunk/Lib/test/test_support.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Wed Feb 10 22:40:33 2010 @@ -158,9 +158,27 @@ import traceback import warnings import unittest +import tempfile import imp +# Some times __path__ and __file__ are not absolute (e.g. while running from +# Lib/) and, if we change the CWD to run the tests in a temporary dir, some +# imports might fail. This affects only the modules imported before os.chdir(). +# These modules are searched first in sys.path[0] (so '' -- the CWD) and if +# they are found in the CWD their __file__ and __path__ will be relative (this +# happens before the chdir). All the modules imported after the chdir, are +# not found in the CWD, and since the other paths in sys.path[1:] are absolute +# (site.py absolutize them), the __file__ and __path__ will be absolute too. +# Therefore it is necessary to absolutize manually the __file__ and __path__ of +# the packages to prevent later imports to fail when the CWD is different. +for module in sys.modules.itervalues(): + if hasattr(module, '__path__'): + module.__path__ = [os.path.abspath(path) for path in module.__path__] + if hasattr(module, '__file__'): + module.__file__ = os.path.abspath(module.__file__) + + # Ignore ImportWarnings that only occur in the source tree, # (because of modules with the same name as source-directories in Modules/) for mod in ("ctypes", "gzip", "zipfile", "tarfile", "encodings.zlib_codec", @@ -350,6 +368,9 @@ resource_denieds = [] environment_changed = [] + if verbose: + print 'The CWD is now', os.getcwd() + if findleaks: try: import gc @@ -364,8 +385,7 @@ found_garbage = [] if single: - from tempfile import gettempdir - filename = os.path.join(gettempdir(), 'pynexttest') + filename = 'pynexttest' try: fp = open(filename, 'r') next_test = fp.read().strip() @@ -376,7 +396,7 @@ if fromfile: tests = [] - fp = open(fromfile) + fp = open(os.path.join(test_support.SAVEDCWD, fromfile)) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): @@ -959,6 +979,7 @@ deltas = [] nwarmup, ntracked, fname = huntrleaks + fname = os.path.join(test_support.SAVEDCWD, fname) repcount = nwarmup + ntracked print >> sys.stderr, "beginning", repcount, "repetitions" print >> sys.stderr, ("1234567890"*(repcount//10 + 1))[:repcount] @@ -1501,4 +1522,23 @@ i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] - main() + + # findtestdir() gets the dirname out of sys.argv[0], so we have to make it + # absolute before changing the CWD. + if sys.argv[0]: + sys.argv[0] = os.path.abspath(sys.argv[0]) + + + # Define a writable temp dir that will be used as cwd while running + # the tests. The name of the dir includes the pid to allow parallel + # testing (see the -j option). + TESTCWD = 'test_python_{}'.format(os.getpid()) + + TESTCWD = os.path.abspath(os.path.join(tempfile.gettempdir(), TESTCWD)) + + # Run the tests in a context manager that temporary changes the CWD to a + # temporary and writable directory. If it's not possible to create or + # change the CWD, the original CWD will be used. The original CWD is + # available from test_support.SAVEDCWD. + with test_support.temp_cwd(TESTCWD, quiet=True): + main() Modified: python/trunk/Lib/test/test_subprocess.py ============================================================================== --- python/trunk/Lib/test/test_subprocess.py (original) +++ python/trunk/Lib/test/test_subprocess.py Wed Feb 10 22:40:33 2010 @@ -7,6 +7,7 @@ import tempfile import time import re +import sysconfig mswindows = (sys.platform == "win32") @@ -140,9 +141,21 @@ p.wait() self.assertEqual(p.stderr, None) - def test_executable(self): - p = subprocess.Popen(["somethingyoudonthave", - "-c", "import sys; sys.exit(47)"], + def test_executable_with_cwd(self): + python_dir = os.path.dirname(os.path.realpath(sys.executable)) + p = subprocess.Popen(["somethingyoudonthave", "-c", + "import sys; sys.exit(47)"], + executable=sys.executable, cwd=python_dir) + p.wait() + self.assertEqual(p.returncode, 47) + + @unittest.skipIf(sysconfig.is_python_build(), + "need an installed Python. See #7774") + def test_executable_without_cwd(self): + # For a normal installation, it should work without 'cwd' + # argument. For test runs in the build directory, see #7774. + p = subprocess.Popen(["somethingyoudonthave", "-c", + "import sys; sys.exit(47)"], executable=sys.executable) p.wait() self.assertEqual(p.returncode, 47) Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Wed Feb 10 22:40:33 2010 @@ -22,7 +22,7 @@ "get_original_stdout", "unload", "unlink", "rmtree", "forget", "is_resource_enabled", "requires", "find_unused_port", "bind_port", "fcmp", "have_unicode", "is_jython", "TESTFN", "HOST", "FUZZ", - "findfile", "sortdict", "check_syntax_error", + "SAVEDCWD", "temp_cwd", "findfile", "sortdict", "check_syntax_error", "open_urlresource", "check_warnings", "CleanImport", "EnvironmentVarGuard", "captured_output", "captured_stdout", "TransientResource", "transient_internet", @@ -379,27 +379,42 @@ 'Unicode filename tests may not be effective' \ % TESTFN_UNICODE_UNENCODEABLE + # Disambiguate TESTFN for parallel testing, while letting it remain a valid # module name. -TESTFN = "{0}_{1}_tmp".format(TESTFN, os.getpid()) +TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid()) + +# Save the initial cwd +SAVEDCWD = os.getcwd() + + at contextlib.contextmanager +def temp_cwd(name='tempcwd', quiet=False): + """ + Context manager that creates a temporary directory and set it as CWD. + + The new CWD is created in the current directory and it's named *name*. + If *quiet* is False (default) and it's not possible to create or change + the CWD, an error is raised. If it's True, only a warning is raised + and the original CWD is used. + """ + saved_dir = os.getcwd() + is_temporary = False + try: + os.mkdir(name) + os.chdir(name) + is_temporary = True + except OSError: + if not quiet: + raise + warnings.warn('tests may fail, unable to change the CWD to ' + name, + RuntimeWarning, stacklevel=3) + try: + yield os.getcwd() + finally: + os.chdir(saved_dir) + if is_temporary: + rmtree(name) -# Make sure we can write to TESTFN, try in /tmp if we can't -fp = None -try: - fp = open(TESTFN, 'w+') -except IOError: - TMP_TESTFN = os.path.join('/tmp', TESTFN) - try: - fp = open(TMP_TESTFN, 'w+') - TESTFN = TMP_TESTFN - del TMP_TESTFN - except IOError: - print ('WARNING: tests will fail, unable to write to: %s or %s' % - (TESTFN, TMP_TESTFN)) -if fp is not None: - fp.close() - unlink(TESTFN) -del fp def findfile(file, here=__file__): """Try to find a file on sys.path and the working directory. If it is not Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Feb 10 22:40:33 2010 @@ -17,13 +17,24 @@ - Issue #6003: add an argument to ``zipfile.Zipfile.writestr`` to specify the compression type. + - Issue #7893: ``unittest.TextTestResult`` is made public and a ``resultclass`` argument added to the TextTestRunner constructor allowing a different result class to be used without having to subclass. + - Issue 7588: ``unittest.TextTestResult.getDescription`` now includes the test name in failure reports even if the test has a docstring. +Tests +----- + +- Issue #7712: test_support gained a new `temp_cwd` context manager which is + now also used by regrtest to run all the tests in a temporary directory. + The original CWD is saved in `test_support.SAVEDCWD`. + Thanks to Florent Xicluna who helped with the patch. + + What's New in Python 2.7 alpha 3? ================================= From python-checkins at python.org Wed Feb 10 23:42:04 2010 From: python-checkins at python.org (r.david.murray) Date: Wed, 10 Feb 2010 22:42:04 -0000 Subject: [Python-checkins] r78137 - in python/trunk: Lib/shelve.py Misc/NEWS Message-ID: Author: r.david.