Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e25f35e

Browse files
committed
Merged revisions 61644,61646-61647,61649-61652,61656-61658,61663,61665,61667 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r61644 | trent.nelson | 2008-03-19 22:51:16 +0100 (Mi, 19 Mär 2008) | 1 line Force a clean of the tcltk/tcltk64 directories now that we've completely changed the tcl/tk build environment. ........ r61646 | gregory.p.smith | 2008-03-19 23:23:51 +0100 (Mi, 19 Mär 2008) | 2 lines Improve the error message when the CRCs don't match. ........ r61647 | trent.nelson | 2008-03-19 23:41:10 +0100 (Mi, 19 Mär 2008) | 1 line Comment out tcltk/tcltk64 removal. ........ r61649 | raymond.hettinger | 2008-03-19 23:47:48 +0100 (Mi, 19 Mär 2008) | 1 line Remove unnecessary traceback save/restore pair. ........ r61650 | trent.nelson | 2008-03-19 23:51:42 +0100 (Mi, 19 Mär 2008) | 1 line Bump the SIGALM delay from 3 seconds to 20 seconds, mainly in an effort to see if it fixes the alarm failures in this test experienced by some of the buildbots. ........ r61651 | brett.cannon | 2008-03-20 00:01:17 +0100 (Do, 20 Mär 2008) | 5 lines Make sure that the warnings filter is not reset or changed beyond the current running test file. Closes issue2407. Thanks Jerry Seutter. ........ r61652 | gregory.p.smith | 2008-03-20 00:03:25 +0100 (Do, 20 Mär 2008) | 10 lines Prevent ioctl op codes from being sign extended from int to unsigned long when used on platforms that actually define ioctl as taking an unsigned long. (the BSDs and OS X / Darwin) Adds a unittest for fcntl.ioctl that tests what happens with both positive and negative numbers. This was done because of issue1471 but I'm not able to reproduce -that- problem in the first place on Linux 32bit or 64bit or OS X 10.4 & 10.5 32bit or 64 bit. ........ r61656 | sean.reifschneider | 2008-03-20 01:46:50 +0100 (Do, 20 Mär 2008) | 2 lines Issue #2143: Fix embedded readline() hang on SSL socket EOF. ........ r61657 | sean.reifschneider | 2008-03-20 01:50:07 +0100 (Do, 20 Mär 2008) | 2 lines Forgot to add NEWS item about smtplib SSL readline hang fix. ........ r61658 | trent.nelson | 2008-03-20 01:58:44 +0100 (Do, 20 Mär 2008) | 1 line Revert r61650; the intent of this commit was to try and address alarm failures on some of the build slaves. As Neal points out, it's called after test_main(), so it's not going to factor into the test when run via regrtest.py (and removes the original functionality that Jeffrey wanted that would kill the test if it took longer than 3 seconds to run when executing it directly during development). ........ r61663 | sean.reifschneider | 2008-03-20 04:20:48 +0100 (Do, 20 Mär 2008) | 2 lines Issue 2188: Documentation hint about disabling proxy detection. ........ r61665 | gregory.p.smith | 2008-03-20 06:41:53 +0100 (Do, 20 Mär 2008) | 7 lines Attempt to fix the Solaris Sparc 10 buildbot. It was failing with an invalid argument error on ioctl. This was caused by the added test_fcntl ioctl test that hard coded 0 as the fd to use. Without a terminal, this fails on solaris. (it passed from the command line on sol 10, both 32 and 64 bit) Also, test_ioctl exists so I moved the test into there where it belongs. ........ r61667 | georg.brandl | 2008-03-20 08:25:55 +0100 (Do, 20 Mär 2008) | 2 lines #2383: remove obsolete XXX comment in stat.py. ........
1 parent 593cd6b commit e25f35e

12 files changed

Lines changed: 106 additions & 53 deletions

File tree

Doc/library/fcntl.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ The module defines the following functions:
4949
This function is identical to the :func:`fcntl` function, except that the
5050
argument handling is even more complicated.
5151

52+
The op parameter is limited to values that can fit in 32-bits.
53+
5254
The parameter *arg* can be one of an integer, absent (treated identically to the
5355
integer ``0``), an object supporting the read-only buffer interface (most likely
5456
a plain Python string) or an object supporting the read-write buffer interface.

Doc/library/urllib2.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ The following classes are provided:
179179
Cause requests to go through a proxy. If *proxies* is given, it must be a
180180
dictionary mapping protocol names to URLs of proxies. The default is to read the
181181
list of proxies from the environment variables :envvar:`<protocol>_proxy`.
182+
To disable autodetected proxy pass an empty dictionary.
182183

183184

184185
.. class:: HTTPPasswordMgr()

Lib/bsddb/test/test_1413192.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import shutil
77
import tempfile
8+
from test.test_support import catch_warning
89
import warnings
10+
911
try:
1012
# For Pythons w/distutils and add-on pybsddb
1113
from bsddb3 import db
@@ -33,12 +35,11 @@ def __init__(self):
3335
del self.the_txn
3436

3537

36-
warnings.filterwarnings('ignore', 'DBTxn aborted in destructor')
37-
try:
38+
with catch_warning():
39+
warnings.filterwarnings('ignore', 'DBTxn aborted in destructor')
3840
context = Context()
3941
del context
40-
finally:
41-
warnings.resetwarnings()
42+
4243

4344
# try not to leave a turd
4445
try:

Lib/gzip.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ def _read_eof(self):
321321
crc32 = read32(self.fileobj)
322322
isize = U32(read32(self.fileobj)) # may exceed 2GB
323323
if U32(crc32) != U32(self.crc):
324-
raise IOError("CRC check failed")
324+
raise IOError("CRC check failed %s != %s" % (hex(U32(crc32)),
325+
hex(U32(self.crc))))
325326
elif isize != LOWU32(self.size):
326327
raise IOError("Incorrect length of data produced")
327328

Lib/smtplib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def readline(self):
174174
chr = None
175175
while chr != b"\n":
176176
chr = self.sslobj.read(1)
177+
if not chr: break
177178
str += chr
178179
return str
179180

Lib/stat.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
Suggested usage: from stat import *
44
"""
55

6-
# XXX Strictly spoken, this module may have to be adapted for each POSIX
7-
# implementation; in practice, however, the numeric constants used by
8-
# stat() are almost universal (even for stat() emulations on non-UNIX
9-
# systems like MS-DOS).
10-
11-
# Indices for stat struct members in tuple returned by os.stat()
6+
# Indices for stat struct members in the tuple returned by os.stat()
127

138
ST_MODE = 0
149
ST_INO = 1

Lib/test/test_fcntl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
OS/2+EMX doesn't support the file locking operations.
44
55
"""
6-
import struct
76
import fcntl
8-
import os, sys
7+
import os
8+
import struct
9+
import sys
910
import unittest
1011
from test.test_support import verbose, TESTFN, unlink, run_unittest
1112

12-
# TODO - Write tests for ioctl(), flock() and lockf().
13-
13+
# TODO - Write tests for flock() and lockf().
1414

1515
def get_lockdata():
1616
if sys.platform.startswith('atheos'):

Lib/test/test_hmac.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ def update(self, v):
211211
def digest(self):
212212
return self._x.digest()
213213

214-
warnings.simplefilter('error', RuntimeWarning)
215-
try:
214+
with test_support.catch_warning():
215+
warnings.simplefilter('error', RuntimeWarning)
216216
try:
217217
hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash)
218218
except RuntimeWarning:
@@ -227,8 +227,6 @@ def digest(self):
227227
pass
228228
else:
229229
self.fail('Expected warning about small block_size')
230-
finally:
231-
warnings.resetwarnings()
232230

233231

234232

Lib/test/test_ioctl.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
except IOError:
1515
raise TestSkipped("Unable to open /dev/tty")
1616

17+
try:
18+
import pty
19+
except ImportError:
20+
pty = None
21+
1722
class IoctlTests(unittest.TestCase):
1823
def test_ioctl(self):
1924
# If this process has been put into the background, TIOCGPGRP returns
@@ -34,6 +39,30 @@ def test_ioctl_mutate(self):
3439
self.assertEquals(r, 0)
3540
self.assert_(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
3641

42+
def test_ioctl_signed_unsigned_code_param(self):
43+
if not pty:
44+
raise TestSkipped('pty module required')
45+
mfd, sfd = pty.openpty()
46+
try:
47+
if termios.TIOCSWINSZ < 0:
48+
set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
49+
set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffff
50+
else:
51+
set_winsz_opcode_pos = termios.TIOCSWINSZ
52+
set_winsz_opcode_maybe_neg, = struct.unpack("i",
53+
struct.pack("I", termios.TIOCSWINSZ))
54+
55+
# We're just testing that these calls do not raise exceptions.
56+
saved_winsz = fcntl.ioctl(mfd, termios.TIOCGWINSZ, "\0"*8)
57+
our_winsz = struct.pack("HHHH",80,25,0,0)
58+
# test both with a positive and potentially negative ioctl code
59+
new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_pos, our_winsz)
60+
new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz)
61+
fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, saved_winsz)
62+
finally:
63+
os.close(mfd)
64+
os.close(sfd)
65+
3766
def test_main():
3867
run_unittest(IoctlTests)
3968

Lib/test/test_unicode_file.py

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ def _do_single(self, filename):
4949

5050
self.failUnless(base in file_list)
5151

52+
# Do as many "equivalancy' tests as we can - ie, check that although we
53+
# have different types for the filename, they refer to the same file.
54+
def _do_equivalent(self, filename1, filename2):
55+
# Note we only check "filename1 against filename2" - we don't bother
56+
# checking "filename2 against 1", as we assume we are called again with
57+
# the args reversed.
58+
self.failUnless(type(filename1)!=type(filename2),
59+
"No point checking equivalent filenames of the same type")
60+
# stat and lstat should return the same results.
61+
self.failUnlessEqual(os.stat(filename1),
62+
os.stat(filename2))
63+
self.failUnlessEqual(os.lstat(filename1),
64+
os.lstat(filename2))
65+
# Copy/rename etc tests using equivalent filename
66+
self._do_copyish(filename1, filename2)
67+
5268
# Tests that copy, move, etc one file to another.
5369
def _do_copyish(self, filename1, filename2):
5470
# Should be able to rename the file using either name.
@@ -58,31 +74,20 @@ def _do_copyish(self, filename1, filename2):
5874
os.rename(filename1 + ".new", filename2)
5975
self.failUnless(os.path.isfile(filename2))
6076

61-
# Try using shutil on the filenames.
62-
try:
63-
filename1==filename2
64-
except UnicodeDecodeError:
65-
# these filenames can't be compared - shutil.copy tries to do
66-
# just that. This is really a bug in 'shutil' - if one of shutil's
67-
# 2 params are Unicode and the other isn't, it should coerce the
68-
# string to Unicode with the filesystem encoding before comparison.
69-
pass
70-
else:
71-
# filenames can be compared.
72-
shutil.copy(filename1, filename2 + ".new")
73-
os.unlink(filename1 + ".new") # remove using equiv name.
74-
# And a couple of moves, one using each name.
75-
shutil.move(filename1, filename2 + ".new")
76-
self.failUnless(not os.path.exists(filename2))
77-
shutil.move(filename1 + ".new", filename2)
78-
self.failUnless(os.path.exists(filename1))
79-
# Note - due to the implementation of shutil.move,
80-
# it tries a rename first. This only fails on Windows when on
81-
# different file systems - and this test can't ensure that.
82-
# So we test the shutil.copy2 function, which is the thing most
83-
# likely to fail.
84-
shutil.copy2(filename1, filename2 + ".new")
85-
os.unlink(filename1 + ".new")
77+
shutil.copy(filename1, filename2 + ".new")
78+
os.unlink(filename1 + ".new") # remove using equiv name.
79+
# And a couple of moves, one using each name.
80+
shutil.move(filename1, filename2 + ".new")
81+
self.failUnless(not os.path.exists(filename2))
82+
shutil.move(filename1 + ".new", filename2)
83+
self.failUnless(os.path.exists(filename1))
84+
# Note - due to the implementation of shutil.move,
85+
# it tries a rename first. This only fails on Windows when on
86+
# different file systems - and this test can't ensure that.
87+
# So we test the shutil.copy2 function, which is the thing most
88+
# likely to fail.
89+
shutil.copy2(filename1, filename2 + ".new")
90+
os.unlink(filename1 + ".new")
8691

8792
def _do_directory(self, make_name, chdir_name, encoded):
8893
cwd = os.getcwd()
@@ -127,6 +132,16 @@ def _test_single(self, filename):
127132
finally:
128133
os.unlink(filename)
129134

135+
def _test_equivalent(self, filename1, filename2):
136+
remove_if_exists(filename1)
137+
self.failUnless(not os.path.exists(filename2))
138+
f = file(filename1, "w")
139+
f.close()
140+
try:
141+
self._do_equivalent(filename1, filename2)
142+
finally:
143+
os.unlink(filename1)
144+
130145
# The 'test' functions are unittest entry points, and simply call our
131146
# _test functions with each of the filename combinations we wish to test
132147
def test_single_files(self):
@@ -135,6 +150,9 @@ def test_single_files(self):
135150
self._test_single(TESTFN_UNICODE_UNENCODEABLE)
136151

137152
def test_directories(self):
153+
# For all 'equivalent' combinations:
154+
# Make dir with encoded, chdir with unicode, checkdir with encoded
155+
# (or unicode/encoded/unicode, etc
138156
ext = ".dir"
139157
self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext, False)
140158
# Our directory name that can't use a non-unicode name.

0 commit comments

Comments
 (0)