Skip to content

Commit f78e02b

Browse files
committed
Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r63562 | martin.v.loewis | 2008-05-23 17:06:50 +0200 (Fri, 23 May 2008) | 2 lines Patch #1722225: Support QNX 6. ........ r63570 | trent.nelson | 2008-05-23 22:33:14 +0200 (Fri, 23 May 2008) | 1 line Introduce a user macro named $(externalsDir), which should point to the root directory of where all the external sources should live. Developers can change this value if their external sources live elsewhere. The default of '..\..' matches the current status quo. ........ r63728 | gregory.p.smith | 2008-05-26 23:16:34 +0200 (Mon, 26 May 2008) | 4 lines Fix issue2589: there was a potential integer overflow leading to memory corruption on esoteric platforms and incorrect behavior on normal platforms. ........ r63734 | gregory.p.smith | 2008-05-27 00:07:28 +0200 (Tue, 27 May 2008) | 3 lines Fix issue2588: Do not execute str[size-1] = '\0' when a 0 size is passed in. (The assert won't prevent this in non-debug builds). ........ r63784 | raymond.hettinger | 2008-05-29 10:38:23 +0200 (Thu, 29 May 2008) | 1 line Fix two typos. ........ r63788 | facundo.batista | 2008-05-29 18:39:26 +0200 (Thu, 29 May 2008) | 6 lines Fixed the semantic of timeout for socket.create_connection and all the upper level libraries that use it, including urllib2. Added and fixed some tests, and changed docs correspondingly. Thanks to John J Lee for the patch and the pusing, :) ........ r63802 | mark.dickinson | 2008-05-30 04:46:53 +0200 (Fri, 30 May 2008) | 2 lines Fix typo in testSum ........ r63817 | raymond.hettinger | 2008-05-30 20:20:50 +0200 (Fri, 30 May 2008) | 8 lines * Mark intermedidate computes values (hi, lo, yr) as volatile. * Expand comments. * Swap variable names in the sum_exact code so that x and y are consistently chosen as the larger and smaller magnitude values respectively. ........ r63827 | raymond.hettinger | 2008-05-31 05:24:31 +0200 (Sat, 31 May 2008) | 1 line Implement heapq in terms of less-than (to match list.sort()). ........ r63839 | gerhard.haering | 2008-05-31 23:33:27 +0200 (Sat, 31 May 2008) | 2 lines Fixed rowcount for SELECT statements. They're -1 now (again), for better DB-API 2.0 compliance. ........ r63887 | gregory.p.smith | 2008-06-02 06:05:52 +0200 (Mon, 02 Jun 2008) | 4 lines Fix issue 2782: be less strict about the format string type in strftime. Accept unicode and anything else ParseTuple "s#" can deal with. This matches the time.strftime behavior. ........ r63975 | neal.norwitz | 2008-06-06 06:47:01 +0200 (Fri, 06 Jun 2008) | 3 lines Aldo Cortesi confirmed this is still needed for OpenBSD 4.2 and 4.3. (I didn't regen configure, since I don't have a working autoconf.) ........ r63998 | raymond.hettinger | 2008-06-06 23:47:51 +0200 (Fri, 06 Jun 2008) | 1 line Issue 3501: Make heapq support both __le__ and __lt__. ........
1 parent 4066186 commit f78e02b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+420
-264
lines changed

Doc/library/ftplib.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ The module defines the following items:
4444
the method call ``login(user, passwd, acct)`` is made (where *passwd* and
4545
*acct* default to the empty string when not given). The optional *timeout*
4646
parameter specifies a timeout in seconds for blocking operations like the
47-
connection attempt (if is not specified, or passed as None, the global
48-
default timeout setting will be used).
47+
connection attempt (if is not specified, the global default timeout setting
48+
will be used).
4949

5050

5151
.. attribute:: all_errors
@@ -123,10 +123,8 @@ followed by ``lines`` for the text version or ``binary`` for the binary version.
123123
made.
124124

125125
The optional *timeout* parameter specifies a timeout in seconds for the
126-
connection attempt. If is not specified, or passed as None, the object
127-
timeout is used (the timeout that you passed when instantiating the class);
128-
if the object timeout is also None, the global default timeout setting will
129-
be used.
126+
connection attempt. If no *timeout* is passed, the global default timeout
127+
setting will be used.
130128

131129

132130
.. method:: FTP.getwelcome()

Doc/library/http.client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The module provides the following classes:
3333
be raised if the status line can't be parsed as a valid HTTP/1.0 or 1.1
3434
status line. If the optional *timeout* parameter is given, blocking
3535
operations (like connection attempts) will timeout after that many seconds
36-
(if it is not given or ``None``, the global default timeout setting is used).
36+
(if it is not given, the global default timeout setting is used).
3737

3838
For example, the following calls all create instances that connect to the server
3939
at the same host and port::

Doc/library/poplib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ A single class is provided by the :mod:`poplib` module:
2929
This class implements the actual POP3 protocol. The connection is created when
3030
the instance is initialized. If *port* is omitted, the standard POP3 port (110)
3131
is used. The optional *timeout* parameter specifies a timeout in seconds for the
32-
connection attempt (if not specified, or passed as None, the global default
33-
timeout setting will be used).
32+
connection attempt (if not specified, the global default timeout setting will
33+
be used).
3434

3535

3636
.. class:: POP3_SSL(host[, port[, keyfile[, certfile]]])

Doc/library/smtplib.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
2525
with those parameters during initialization. An :exc:`SMTPConnectError` is
2626
raised if the specified host doesn't respond correctly. The optional
2727
*timeout* parameter specifies a timeout in seconds for blocking operations
28-
like the connection attempt (if not specified, or passed as None, the global
29-
default timeout setting will be used).
28+
like the connection attempt (if not specified, the global default timeout
29+
setting will be used).
3030

3131
For normal use, you should only require the initialization/connect,
3232
:meth:`sendmail`, and :meth:`quit` methods. An example is included below.
@@ -42,8 +42,8 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
4242
and *certfile* are also optional, and can contain a PEM formatted private key
4343
and certificate chain file for the SSL connection. The optional *timeout*
4444
parameter specifies a timeout in seconds for blocking operations like the
45-
connection attempt (if not specified, or passed as None, the global default
46-
timeout setting will be used).
45+
connection attempt (if not specified, the global default timeout setting
46+
will be used).
4747

4848

4949
.. class:: LMTP([host[, port[, local_hostname]]])

Doc/library/socket.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,11 @@ The module :mod:`socket` exports the following constants and functions:
197197

198198
.. function:: create_connection(address[, timeout])
199199

200-
Connects to the *address* received (as usual, a ``(host, port)`` pair), with an
201-
optional timeout for the connection. Especially useful for higher-level
202-
protocols, it is not normally used directly from application-level code.
203-
Passing the optional *timeout* parameter will set the timeout on the socket
204-
instance (if it is not given or ``None``, the global default timeout setting is
205-
used).
200+
Convenience function. Connect to *address* (a 2-tuple ``(host, port)``),
201+
and return the socket object. Passing the optional *timeout* parameter will
202+
set the timeout on the socket instance before attempting to connect. If no
203+
*timeout* is supplied, the global default timeout setting returned by
204+
:func:`getdefaulttimeout` is used.
206205

207206

208207
.. function:: getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]])

Doc/library/telnetlib.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Character), EL (Erase Line), GA (Go Ahead), SB (Subnegotiation Begin).
2828
:class:`Telnet` represents a connection to a Telnet server. The instance is
2929
initially not connected by default; the :meth:`open` method must be used to
3030
establish a connection. Alternatively, the host name and optional port
31+
and timeout can be passed to the constructor, in which case the connection to
32+
the server will be established before the constructor returns. The optional
33+
*timeout* parameter specifies a timeout in seconds for the connection attempt (if
34+
not specified, the global default timeout setting will be used).
35+
3136
number can be passed to the constructor, to, in which case the connection to
3237
the server will be established before the constructor returns. The optional
3338
*timeout* parameter specifies a timeout in seconds for blocking operations
@@ -123,8 +128,7 @@ Telnet Objects
123128
Connect to a host. The optional second argument is the port number, which
124129
defaults to the standard Telnet port (23). The optional *timeout* parameter
125130
specifies a timeout in seconds for blocking operations like the connection
126-
attempt (if not specified, or passed as None, the global default timeout
127-
setting will be used).
131+
attempt (if not specified, the global default timeout setting will be used).
128132

129133
Do not try to reopen an already connected instance.
130134

Doc/library/urllib2.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ The :mod:`urllib2` module defines the following functions:
2727
returns a string in this format.
2828

2929
The optional *timeout* parameter specifies a timeout in seconds for blocking
30-
operations like the connection attempt (if not specified, or passed as
31-
``None``, the global default timeout setting will be used). This actually
32-
only works for HTTP, HTTPS, FTP and FTPS connections.
30+
operations like the connection attempt (if not specified, the global default
31+
timeout setting will be used). This actually only works for HTTP, HTTPS,
32+
FTP and FTPS connections.
3333

3434
This function returns a file-like object with two additional methods:
3535

@@ -404,9 +404,9 @@ OpenerDirector Objects
404404
the same as those of :func:`urlopen` (which simply calls the :meth:`open`
405405
method on the currently installed global :class:`OpenerDirector`). The
406406
optional *timeout* parameter specifies a timeout in seconds for blocking
407-
operations like the connection attempt (if not specified, or passed as
408-
``None``, the global default timeout setting will be used; this actually only
409-
works for HTTP, HTTPS, FTP and FTPS connections).
407+
operations like the connection attempt (if not specified, the global default
408+
timeout setting will be usedi). The timeout feature actually works only for
409+
HTTP, HTTPS, FTP and FTPS connections).
410410

411411

412412
.. method:: OpenerDirector.error(proto[, arg[, ...]])

Include/pyport.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,13 @@ extern int gethostname(char *, int);
431431
extern char * _getpty(int *, int, mode_t, int);
432432
#endif
433433

434+
/* On QNX 6, struct termio must be declared by including sys/termio.h
435+
if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must
436+
be included before termios.h or it will generate an error. */
437+
#ifdef HAVE_SYS_TERMIO_H
438+
#include <sys/termio.h>
439+
#endif
440+
434441
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
435442
#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H)
436443
/* BSDI does not supply a prototype for the 'openpty' and 'forkpty'

Lib/ftplib.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from socket import getfqdn; socket.getfqdn = getfqdn; del getfqdn
4545
except ImportError:
4646
import socket
47+
from socket import _GLOBAL_DEFAULT_TIMEOUT
4748

4849
__all__ = ["FTP","Netrc"]
4950

@@ -71,7 +72,6 @@ class error_proto(Error): pass # response does not begin with [1-5]
7172
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
7273
CRLF = '\r\n'
7374

74-
7575
# The class itself
7676
class FTP:
7777

@@ -110,14 +110,15 @@ class FTP:
110110
# Initialize host to localhost, port to standard ftp port
111111
# Optional arguments are host (for connect()),
112112
# and user, passwd, acct (for login())
113-
def __init__(self, host='', user='', passwd='', acct='', timeout=None):
113+
def __init__(self, host='', user='', passwd='', acct='',
114+
timeout=_GLOBAL_DEFAULT_TIMEOUT):
114115
self.timeout = timeout
115116
if host:
116117
self.connect(host)
117118
if user:
118119
self.login(user, passwd, acct)
119120

120-
def connect(self, host='', port=0, timeout=None):
121+
def connect(self, host='', port=0, timeout=-999):
121122
'''Connect to host. Arguments are:
122123
- host: hostname to connect to (string, default previous host)
123124
- port: port to connect to (integer, default previous port)
@@ -126,7 +127,7 @@ def connect(self, host='', port=0, timeout=None):
126127
self.host = host
127128
if port > 0:
128129
self.port = port
129-
if timeout is not None:
130+
if timeout != -999:
130131
self.timeout = timeout
131132
self.sock = socket.create_connection((self.host, self.port), self.timeout)
132133
self.af = self.sock.family

Lib/heapq.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def heapreplace(heap, item):
167167

168168
def heappushpop(heap, item):
169169
"""Fast version of a heappush followed by a heappop."""
170-
if heap and item > heap[0]:
170+
if heap and heap[0] < item:
171171
item, heap[0] = heap[0], item
172172
_siftup(heap, 0)
173173
return item
@@ -240,10 +240,11 @@ def _siftdown(heap, startpos, pos):
240240
while pos > startpos:
241241
parentpos = (pos - 1) >> 1
242242
parent = heap[parentpos]
243-
if parent <= newitem:
244-
break
245-
heap[pos] = parent
246-
pos = parentpos
243+
if newitem < parent:
244+
heap[pos] = parent
245+
pos = parentpos
246+
continue
247+
break
247248
heap[pos] = newitem
248249

249250
# The child indices of heap index pos are already heaps, and we want to make
@@ -294,7 +295,7 @@ def _siftup(heap, pos):
294295
while childpos < endpos:
295296
# Set childpos to index of smaller child.
296297
rightpos = childpos + 1
297-
if rightpos < endpos and heap[rightpos] <= heap[childpos]:
298+
if rightpos < endpos and not heap[childpos] < heap[rightpos]:
298299
childpos = rightpos
299300
# Move the smaller child up.
300301
heap[pos] = heap[childpos]

0 commit comments

Comments
 (0)