Commit f6cd967e authored by Christian Heimes's avatar Christian Heimes

Merged revisions...

Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines

  Merged the ACKS from py3k
........
  r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line

  Make _ctypes.c PY_SSIZE_T_CLEAN.
........
  r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines

  Opps! I merged the revisions, but forgot to add
  the header to ACKS
........
  r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line

  Minor docstring typos
........
  r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line

  Add various items
........
  r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines

  Try to get this test to be less flaky.  It was failing sometimes because
  the connect would succeed before the timeout occurred.  Try using an
  address and port that hopefully doesn't exist to ensure we get no response.
  If this doesn't work, we can use a public address close to python.org
  and hopefully that address never gets taken.
........
  r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line

  Changed test so it no longer runs as a side effect of importing.
........
  r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines

  Ensure that the mailbox is closed to prevent problems on Windows with removing
  an open file.  This doesn't seem to be a problem in 2.6, but that appears
  to be somewhat accidental (specific to reference counting).  When this
  gets merged to 3.0, it will make the 3.0 code simpler.
........
  r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line

  Changed test so it no longer runs as a side effect of importing.
........
  r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line

  Changed test so it no longer runs as a side effect of importing.
........
  r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines

  Add Josiah.
........
  r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines

  Add an example for an RFC 822 continuation.
........
  r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines

  Added help options to PDB
........
  r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line

  Prepare integration of bytearray backport branch
........
  r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines

  Removed merge tracking for "svnmerge" for
  svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
  r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines

  Fix and simplify error handling, silencing a compiler warning.
........
parent 41be953d
...@@ -29,18 +29,20 @@ easily. ...@@ -29,18 +29,20 @@ easily.
The configuration file consists of sections, led by a ``[section]`` header and The configuration file consists of sections, led by a ``[section]`` header and
followed by ``name: value`` entries, with continuations in the style of followed by ``name: value`` entries, with continuations in the style of
:rfc:`822`; ``name=value`` is also accepted. Note that leading whitespace is :rfc:`822` (see section 3.1.1, "LONG HEADER FIELDS"); ``name=value`` is also
removed from values. The optional values can contain format strings which refer accepted. Note that leading whitespace is removed from values. The optional
to other values in the same section, or values in a special ``DEFAULT`` section. values can contain format strings which refer to other values in the same
Additional defaults can be provided on initialization and retrieval. Lines section, or values in a special ``DEFAULT`` section. Additional defaults can be
beginning with ``'#'`` or ``';'`` are ignored and may be used to provide provided on initialization and retrieval. Lines beginning with ``'#'`` or
comments. ``';'`` are ignored and may be used to provide comments.
For example:: For example::
[My Section] [My Section]
foodir: %(dir)s/whatever foodir: %(dir)s/whatever
dir=frob dir=frob
long: this value continues
in the next line
would resolve the ``%(dir)s`` to the value of ``dir`` (``frob`` in this case). would resolve the ``%(dir)s`` to the value of ``dir`` (``frob`` in this case).
All reference expansions are done on demand. All reference expansions are done on demand.
......
...@@ -555,10 +555,11 @@ adding a colon followed by a format specifier. For example:: ...@@ -555,10 +555,11 @@ adding a colon followed by a format specifier. For example::
Format specifiers can reference other fields through nesting:: Format specifiers can reference other fields through nesting::
fmt = '{0:{1}}' fmt = '{0:{1}}'
fmt.format('Invoice #1234', width) ->
'Invoice #1234 '
fmt.format('Invoice #1234', 15) -> fmt.format('Invoice #1234', 15) ->
'Invoice #1234 ' 'Invoice #1234 '
width = 35
fmt.format('Invoice #1234', width) ->
'Invoice #1234 '
The alignment of a field within the desired width can be specified: The alignment of a field within the desired width can be specified:
...@@ -571,11 +572,38 @@ Character Effect ...@@ -571,11 +572,38 @@ Character Effect
= (For numeric types only) Pad after the sign. = (For numeric types only) Pad after the sign.
================ ============================================ ================ ============================================
Format data types:: Format specifiers can also include a presentation type, which
controls how the value is formatted. For example, floating-point numbers
... XXX take table from PEP 3101 can be formatted as a general number or in exponential notation:
Classes and types can define a __format__ method to control how it's >>> '{0:g}'.format(3.75)
'3.75'
>>> '{0:e}'.format(3.75)
'3.750000e+00'
A variety of presentation types are available. Consult the 2.6
documentation for a complete list (XXX add link, once it's in the 2.6
docs), but here's a sample::
'b' - Binary. Outputs the number in base 2.
'c' - Character. Converts the integer to the corresponding
Unicode character before printing.
'd' - Decimal Integer. Outputs the number in base 10.
'o' - Octal format. Outputs the number in base 8.
'x' - Hex format. Outputs the number in base 16, using lower-
case letters for the digits above 9.
'e' - Exponent notation. Prints the number in scientific
notation using the letter 'e' to indicate the exponent.
'g' - General format. This prints the number as a fixed-point
number, unless the number is too large, in which case
it switches to 'e' exponent notation.
'n' - Number. This is the same as 'g', except that it uses the
current locale setting to insert the appropriate
number separator characters.
'%' - Percentage. Multiplies the number by 100 and displays
in fixed ('f') format, followed by a percent sign.
Classes and types can define a __format__ method to control how they're
formatted. It receives a single argument, the format specifier:: formatted. It receives a single argument, the format specifier::
def __format__(self, format_spec): def __format__(self, format_spec):
...@@ -610,7 +638,6 @@ function from somewhere else. ...@@ -610,7 +638,6 @@ function from somewhere else.
Python 2.6 has a ``__future__`` import that removes ``print`` as language Python 2.6 has a ``__future__`` import that removes ``print`` as language
syntax, letting you use the functional form instead. For example:: syntax, letting you use the functional form instead. For example::
XXX need to check
from __future__ import print_function from __future__ import print_function
print('# of entries', len(dictionary), file=sys.stderr) print('# of entries', len(dictionary), file=sys.stderr)
...@@ -701,6 +728,21 @@ and it also supports the ``b''`` notation. ...@@ -701,6 +728,21 @@ and it also supports the ``b''`` notation.
.. ====================================================================== .. ======================================================================
.. _pep-3118:
PEP 3118: Revised Buffer Protocol
=====================================================
The buffer protocol is a C-level API that lets Python extensions
XXX
.. seealso::
:pep:`3118` - Revising the buffer protocol
PEP written by Travis Oliphant and Carl Banks.
.. ======================================================================
.. _pep-3119: .. _pep-3119:
PEP 3119: Abstract Base Classes PEP 3119: Abstract Base Classes
...@@ -1082,7 +1124,7 @@ Optimizations ...@@ -1082,7 +1124,7 @@ Optimizations
by using pymalloc for the Unicode string's data. by using pymalloc for the Unicode string's data.
* The ``with`` statement now stores the :meth:`__exit__` method on the stack, * The ``with`` statement now stores the :meth:`__exit__` method on the stack,
producing a small speedup. (Implemented by Nick Coghlan.) producing a small speedup. (Implemented by Jeffrey Yasskin.)
* To reduce memory usage, the garbage collector will now clear internal * To reduce memory usage, the garbage collector will now clear internal
free lists when garbage-collecting the highest generation of objects. free lists when garbage-collecting the highest generation of objects.
...@@ -1361,10 +1403,8 @@ complete list of changes, or look through the CVS logs for all the details. ...@@ -1361,10 +1403,8 @@ complete list of changes, or look through the CVS logs for all the details.
the forward search. the forward search.
(Contributed by John Lenton.) (Contributed by John Lenton.)
* The :mod:`new` module has been removed from Python 3.0. * (3.0-warning mode) The :mod:`new` module has been removed from
Importing it therefore Python 3.0. Importing it therefore triggers a warning message.
triggers a warning message when Python is running in 3.0-warning
mode.
* The :mod:`operator` module gained a * The :mod:`operator` module gained a
:func:`methodcaller` function that takes a name and an optional :func:`methodcaller` function that takes a name and an optional
...@@ -1483,6 +1523,14 @@ complete list of changes, or look through the CVS logs for all the details. ...@@ -1483,6 +1523,14 @@ complete list of changes, or look through the CVS logs for all the details.
.. Issue 1727780 .. Issue 1727780
The new ``triangular(low, high, mode)`` function returns random
numbers following a triangular distribution. The returned values
are between *low* and *high*, not including *high* itself, and
with *mode* as the mode, the most frequently occurring value
in the distribution. (Contributed by Raymond Hettinger. XXX check)
.. Patch 1681432
* Long regular expression searches carried out by the :mod:`re` * Long regular expression searches carried out by the :mod:`re`
module will now check for signals being delivered, so especially module will now check for signals being delivered, so especially
long searches can now be interrupted. long searches can now be interrupted.
...@@ -1500,6 +1548,16 @@ complete list of changes, or look through the CVS logs for all the details. ...@@ -1500,6 +1548,16 @@ complete list of changes, or look through the CVS logs for all the details.
.. Patch 1861 .. Patch 1861
* The :mod:`select` module now has wrapper functions
for the Linux :cfunc:`epoll` and BSD :cfunc:`kqueue` system calls.
Also, a :meth:`modify` method was added to the existing :class:`poll`
objects; ``pollobj.modify(fd, eventmask)`` takes a file descriptor
or file object and an event mask,
(Contributed by XXX.)
.. Patch 1657
* The :mod:`sets` module has been deprecated; it's better to * The :mod:`sets` module has been deprecated; it's better to
use the built-in :class:`set` and :class:`frozenset` types. use the built-in :class:`set` and :class:`frozenset` types.
...@@ -1948,9 +2006,8 @@ Some of the more notable changes are: ...@@ -1948,9 +2006,8 @@ Some of the more notable changes are:
Porting to Python 2.6 Porting to Python 2.6
===================== =====================
This section lists previously described changes, and a few This section lists previously described changes and other bugfixes
esoteric bugfixes, that may require changes to your that may require changes to your code:
code:
* The :meth:`__init__` method of :class:`collections.deque` * The :meth:`__init__` method of :class:`collections.deque`
now clears any existing contents of the deque now clears any existing contents of the deque
...@@ -1986,7 +2043,11 @@ code: ...@@ -1986,7 +2043,11 @@ code:
.. Issue 1330538 .. Issue 1330538
* In 3.0-warning mode, inequality comparisons between two dictionaries * (3.0-warning mode) The :class:`Exception` class now warns
when accessed using slicing or index access; having
:class:`Exception` behave like a tuple is being phased out.
* (3.0-warning mode) inequality comparisons between two dictionaries
or two objects that don't implement comparison methods are reported or two objects that don't implement comparison methods are reported
as warnings. ``dict1 == dict2`` still works, but ``dict1 < dict2`` as warnings. ``dict1 == dict2`` still works, but ``dict1 < dict2``
is being phased out. is being phased out.
......
...@@ -1233,7 +1233,7 @@ def help(): ...@@ -1233,7 +1233,7 @@ def help():
print('along the Python search path') print('along the Python search path')
def main(): def main():
if not sys.argv[1:]: if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
print("usage: pdb.py scriptfile [arg] ...") print("usage: pdb.py scriptfile [arg] ...")
sys.exit(2) sys.exit(2)
......
This diff is collapsed.
import imaplib import imaplib
import time import time
# We can check only that it successfully produces a result, from test import test_support
# not the correctness of the result itself, since the result import unittest
# depends on the timezone the machine is in.
timevalues = [2000000000, 2000000000.0, time.localtime(2000000000),
'"18-May-2033 05:33:20 +0200"']
for t in timevalues: class TestImaplib(unittest.TestCase):
imaplib.Time2Internaldate(t) def test_that_Time2Internaldate_returns_a_result(self):
# We can check only that it successfully produces a result,
# not the correctness of the result itself, since the result
# depends on the timezone the machine is in.
timevalues = [2000000000, 2000000000.0, time.localtime(2000000000),
'"18-May-2033 05:33:20 +0200"']
for t in timevalues:
imaplib.Time2Internaldate(t)
def test_main():
test_support.run_unittest(TestImaplib)
if __name__ == "__main__":
unittest.main()
...@@ -374,7 +374,7 @@ class TestMailbox(TestBase): ...@@ -374,7 +374,7 @@ class TestMailbox(TestBase):
def test_flush(self): def test_flush(self):
# Write changes to disk # Write changes to disk
self._test_flush_or_close(self._box.flush) self._test_flush_or_close(self._box.flush, True)
def test_lock_unlock(self): def test_lock_unlock(self):
# Lock and unlock the mailbox # Lock and unlock the mailbox
...@@ -386,15 +386,17 @@ class TestMailbox(TestBase): ...@@ -386,15 +386,17 @@ class TestMailbox(TestBase):
def test_close(self): def test_close(self):
# Close mailbox and flush changes to disk # Close mailbox and flush changes to disk
self._test_flush_or_close(self._box.close) self._test_flush_or_close(self._box.close, False)
def _test_flush_or_close(self, method): def _test_flush_or_close(self, method, should_call_close):
contents = [self._template % i for i in range(3)] contents = [self._template % i for i in range(3)]
self._box.add(contents[0]) self._box.add(contents[0])
self._box.add(contents[1]) self._box.add(contents[1])
self._box.add(contents[2]) self._box.add(contents[2])
oldbox = self._box oldbox = self._box
method() method()
if should_call_close:
self._box.close()
self._box = self._factory(self._path) self._box = self._factory(self._path)
keys = self._box.keys() keys = self._box.keys()
self.assertEqual(len(keys), 3) self.assertEqual(len(keys), 3)
......
This diff is collapsed.
...@@ -107,24 +107,19 @@ class TimeoutTestCase(unittest.TestCase): ...@@ -107,24 +107,19 @@ class TimeoutTestCase(unittest.TestCase):
self.sock.close() self.sock.close()
def testConnectTimeout(self): def testConnectTimeout(self):
# If we are too close to www.python.org, this test will fail. # Choose a private address that is unlikely to exist to prevent
# Pick a host that should be farther away. # failures due to the connect succeeding before the timeout.
if (socket.getfqdn().split('.')[-2:] == ['python', 'org'] or # Use a dotted IP address to avoid including the DNS lookup time
socket.getfqdn().split('.')[-2:-1] == ['xs4all']):
self.addr_remote = ('tut.fi', 80)
# Lookup the IP address to avoid including the DNS lookup time
# with the connect time. This avoids failing the assertion that # with the connect time. This avoids failing the assertion that
# the timeout occurred fast enough. # the timeout occurred fast enough.
self.addr_remote = (socket.gethostbyname(self.addr_remote[0]), 80) addr = ('10.0.0.0', 12345)
# Test connect() timeout # Test connect() timeout
_timeout = 0.001 _timeout = 0.001
self.sock.settimeout(_timeout) self.sock.settimeout(_timeout)
_t1 = time.time() _t1 = time.time()
self.failUnlessRaises(socket.error, self.sock.connect, self.failUnlessRaises(socket.error, self.sock.connect, addr)
self.addr_remote)
_t2 = time.time() _t2 = time.time()
_delta = abs(_t1 - _t2) _delta = abs(_t1 - _t2)
......
Acknowledgements
----------------
This list is not complete and not in any useful order, but I would
like to thank everybody who contributed in any way, with code, hints,
bug reports, ideas, moral support, endorsement, or even complaints....
Without you I would've stopped working on Python long ago!
--Guido
PS: In the standard Python distribution this file is encoded in Latin-1.
David Abrahams David Abrahams
Jim Ahlstrom Jim Ahlstrom
......
...@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise. ...@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise.
Permissions History Permissions History
------------------- -------------------
- Josiah Carlson was given SVN access on 26 March 2008 by Georg Brandl,
for work on asyncore/asynchat.
- Benjamin Peterson was given SVN access on 25 March 2008 by Georg - Benjamin Peterson was given SVN access on 25 March 2008 by Georg
Brandl, for bug triage work. Brandl, for bug triage work.
......
...@@ -99,6 +99,8 @@ bytes(cdata) ...@@ -99,6 +99,8 @@ bytes(cdata)
* *
*/ */
#define PY_SSIZE_T_CLEAN
#include "Python.h" #include "Python.h"
#include "structmember.h" #include "structmember.h"
...@@ -2273,7 +2275,7 @@ static PyObject * ...@@ -2273,7 +2275,7 @@ static PyObject *
CData_setstate(PyObject *_self, PyObject *args) CData_setstate(PyObject *_self, PyObject *args)
{ {
void *data; void *data;
int len; Py_ssize_t len;
int res; int res;
PyObject *dict, *mydict; PyObject *dict, *mydict;
CDataObject *self = (CDataObject *)_self; CDataObject *self = (CDataObject *)_self;
...@@ -3007,7 +3009,7 @@ CFuncPtr_FromVtblIndex(PyTypeObject *type, PyObject *args, PyObject *kwds) ...@@ -3007,7 +3009,7 @@ CFuncPtr_FromVtblIndex(PyTypeObject *type, PyObject *args, PyObject *kwds)
char *name = NULL; char *name = NULL;
PyObject *paramflags = NULL; PyObject *paramflags = NULL;
GUID *iid = NULL; GUID *iid = NULL;
int iid_len = 0; Py_ssize_t iid_len = 0;
if (!PyArg_ParseTuple(args, "is|Oz#", &index, &name, &paramflags, &iid, &iid_len)) if (!PyArg_ParseTuple(args, "is|Oz#", &index, &name, &paramflags, &iid, &iid_len))
return NULL; return NULL;
......
...@@ -409,7 +409,7 @@ poll_register(pollObject *self, PyObject *args) ...@@ -409,7 +409,7 @@ poll_register(pollObject *self, PyObject *args)
PyDoc_STRVAR(poll_modify_doc, PyDoc_STRVAR(poll_modify_doc,
"modify(fd, eventmask) -> None\n\n\ "modify(fd, eventmask) -> None\n\n\
Modify an already register file descriptor.\n\ Modify an already registered file descriptor.\n\
fd -- either an integer, or an object with a fileno() method returning an\n\ fd -- either an integer, or an object with a fileno() method returning an\n\
int.\n\ int.\n\
events -- an optional bitmask describing the type of events to check for"); events -- an optional bitmask describing the type of events to check for");
...@@ -915,10 +915,10 @@ pyepoll_register(pyEpoll_Object *self, PyObject *args, PyObject *kwds) ...@@ -915,10 +915,10 @@ pyepoll_register(pyEpoll_Object *self, PyObject *args, PyObject *kwds)
PyDoc_STRVAR(pyepoll_register_doc, PyDoc_STRVAR(pyepoll_register_doc,
"register(fd[, eventmask]) -> bool\n\ "register(fd[, eventmask]) -> bool\n\
\n\ \n\
Registers a new fd or modifies an already registered fd. register returns\n\ Registers a new fd or modifies an already registered fd. register() returns\n\
True if a new fd was registered or False if the event mask for fd was modified.\n\ True if a new fd was registered or False if the event mask for fd was modified.\n\
fd is the target file descriptor of the operation\n\ fd is the target file descriptor of the operation.\n\
events is a bit set composed of the various EPOLL constants, the default\n\ events is a bit set composed of the various EPOLL constants; the default\n\
is EPOLL_IN | EPOLL_OUT | EPOLL_PRI.\n\ is EPOLL_IN | EPOLL_OUT | EPOLL_PRI.\n\
\n\ \n\
The epoll interface supports all file descriptors that support poll."); The epoll interface supports all file descriptors that support poll.");
...@@ -988,6 +988,7 @@ pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds) ...@@ -988,6 +988,7 @@ pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds)
else if (dtimeout * 1000.0 > INT_MAX) { else if (dtimeout * 1000.0 > INT_MAX) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"timeout is too large"); "timeout is too large");
return NULL;
} }
else { else {
timeout = (int)(dtimeout * 1000.0); timeout = (int)(dtimeout * 1000.0);
...@@ -1024,19 +1025,15 @@ pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds) ...@@ -1024,19 +1025,15 @@ pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds)
} }
for (i = 0; i < nfds; i++) { for (i = 0; i < nfds; i++) {
etuple = Py_BuildValue("iI", evs[i].data.fd, etuple = Py_BuildValue("iI", evs[i].data.fd, evs[i].events);
evs[i].events);
if (etuple == NULL) { if (etuple == NULL) {
Py_CLEAR(elist);
goto error; goto error;
} }
PyList_SET_ITEM(elist, i, etuple); PyList_SET_ITEM(elist, i, etuple);
} }
if (0) { error:
error:
Py_CLEAR(elist);
Py_XDECREF(etuple);
}
PyMem_Free(evs); PyMem_Free(evs);
return elist; return elist;
} }
...@@ -1716,7 +1713,7 @@ that are ready.\n\ ...@@ -1716,7 +1713,7 @@ that are ready.\n\
\n\ \n\
*** IMPORTANT NOTICE ***\n\ *** IMPORTANT NOTICE ***\n\
On Windows and OpenVMS, only sockets are supported; on Unix, all file\n\ On Windows and OpenVMS, only sockets are supported; on Unix, all file\n\
descriptors."); descriptors can be used.");
static PyMethodDef select_methods[] = { static PyMethodDef select_methods[] = {
{"select", select_select, METH_VARARGS, select_doc}, {"select", select_select, METH_VARARGS, select_doc},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment