Skip to content

Commit d5e2b6f

Browse files
committed
Merged revisions 61538-61540,61556,61559-61560,61563,61565,61571,61575-61576,61580-61582,61586,61591,61593,61595,61605-61606,61613-61616,61618,61621-61623,61625,61627,61631-61634 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r61538 | steven.bethard | 2008-03-18 20:03:50 +0100 (Di, 18 Mär 2008) | 1 line cell_compare needs to return -2 instead of NULL. ........ r61539 | steven.bethard | 2008-03-18 20:04:32 +0100 (Di, 18 Mär 2008) | 1 line _have_soundcard() is a bad check for winsound.Beep, since you can have a soundcard but have the beep driver disabled. This revision basically disables the beep tests by wrapping them in a try/except. The Right Way To Do It is to come up with a _have_enabled_beep_driver() and use that. ........ r61540 | gregory.p.smith | 2008-03-18 20:05:32 +0100 (Di, 18 Mär 2008) | 8 lines Fix chown on 64-bit linux. It needed to take a long (64-bit on 64bit linux) as uid and gid input to accept values >=2**31 as valid while still accepting negative numbers to pass -1 to chown for "no change". Fixes issue1747858. This should be backported to release25-maint. ........ r61556 | steven.bethard | 2008-03-18 20:59:14 +0100 (Di, 18 Mär 2008) | 1 line Fix test_atexit so that it still passes when -3 is supplied. (It was catching the warning messages on stdio from using the reload() function.) ........ r61559 | neal.norwitz | 2008-03-18 21:30:38 +0100 (Di, 18 Mär 2008) | 1 line Import the test properly. This is especially important for py3k. ........ r61560 | gregory.p.smith | 2008-03-18 21:40:01 +0100 (Di, 18 Mär 2008) | 2 lines news entry for the chown fix ........ r61563 | brett.cannon | 2008-03-18 22:12:42 +0100 (Di, 18 Mär 2008) | 2 lines Ignore BIG5HKSCS-2004.TXT which is downloaded as part of a test. ........ r61565 | steven.bethard | 2008-03-18 22:30:13 +0100 (Di, 18 Mär 2008) | 1 line Have regrtest skip test_py3kwarn when the -3 flag is missing. ........ r61571 | gregory.p.smith | 2008-03-18 23:27:41 +0100 (Di, 18 Mär 2008) | 4 lines Add a test to make sure zlib.crc32 and binascii.crc32 return the same thing. Fix a buglet in binascii.crc32, the second optional argument could previously have a signedness mismatch with the C variable its going into. ........ r61575 | raymond.hettinger | 2008-03-19 00:22:29 +0100 (Mi, 19 Mär 2008) | 1 line Speed-up isinstance() for one easy case. ........ r61576 | raymond.hettinger | 2008-03-19 00:33:08 +0100 (Mi, 19 Mär 2008) | 1 line Issue: 2354: Add 3K warning for the cmp argument to list.sort() and sorted(). ........ r61580 | andrew.kuchling | 2008-03-19 02:05:35 +0100 (Mi, 19 Mär 2008) | 1 line Add Jeff Rush ........ r61581 | gregory.p.smith | 2008-03-19 02:38:35 +0100 (Mi, 19 Mär 2008) | 3 lines Mention that crc32 and adler32 are available in a different module (zlib). Some people look for them in hashlib. ........ r61582 | gregory.p.smith | 2008-03-19 02:46:10 +0100 (Mi, 19 Mär 2008) | 3 lines Use zlib's crc32 routine instead of binascii when available. zlib's is faster when compiled properly optimized and about the same speed otherwise. ........ r61586 | david.wolever | 2008-03-19 03:26:57 +0100 (Mi, 19 Mär 2008) | 1 line Added my name to ACKS ........ r61591 | gregory.p.smith | 2008-03-19 04:14:41 +0100 (Mi, 19 Mär 2008) | 5 lines Fix the struct module DeprecationWarnings that zipfile was triggering by removing all use of signed struct values. test_zipfile and test_zipfile64 pass. no more warnings. ........ r61593 | raymond.hettinger | 2008-03-19 04:56:59 +0100 (Mi, 19 Mär 2008) | 1 line Fix compiler warning. ........ r61595 | martin.v.loewis | 2008-03-19 05:39:13 +0100 (Mi, 19 Mär 2008) | 2 lines Issue #2400: Allow relative imports to "import *". ........ r61605 | martin.v.loewis | 2008-03-19 07:00:28 +0100 (Mi, 19 Mär 2008) | 2 lines Import relimport using a relative import. ........ r61606 | trent.nelson | 2008-03-19 07:28:24 +0100 (Mi, 19 Mär 2008) | 1 line Issue2290: Support x64 Windows builds that live in pcbuild/amd64. Without it, sysutils._python_build() returns the wrong directory, which causes the test_get_config_h_filename method in Lib/distutils/tests/test_sysconfig.py to fail. ........ r61613 | trent.nelson | 2008-03-19 08:45:19 +0100 (Mi, 19 Mär 2008) | 3 lines Refine the Visual Studio 2008 build solution in order to improve how we deal with external components, as well as fixing outstanding issues with Windows x64 build support. Introduce two new .vcproj files, _bsddb44.vcproj and sqlite3.vcproj, which replace the previous pre-link event scripts for _bsddb and _sqlite3 respectively. The new project files inherit from our property files as if they were any other Python module. This has numerous benefits. First, the components get built with exactly the same compiler flags and settings as the rest of Python. Second, it makes it much easier to debug problems in the external components when they're part of the build system. Third, they'll benefit from profile guided optimisation in the release builds, just like the rest of Python core. I've also introduced a slightly new pattern for managing externals in subversion. New components get checked in as <name>-<version>.x, where <version> matches the exact vendor version string. After the initial import of the external component, the .x is tagged as .0 (i.e. tcl-8.4.18.x -> tcl-8.4.18.0). Some components may not need any tweaking, whereas there are others that might (tcl/tk fall into this bucket). In that case, the relevant modifications are made to the .x branch, which will be subsequently tagged as .1 (and then n+1 going forward) when they build successfully and all tests pass. Buildbots will be converted to rely on these explicit tags only, which makes it easy for us to switch them over to a new version as and when required. (Simple change to external(-amd64).bat: if we've bumped tcl to 8.4.18.1, change the .bat to rmdir 8.4.18.0 if it exists and check out a new .1 copy.) ........ r61614 | trent.nelson | 2008-03-19 08:56:39 +0100 (Mi, 19 Mär 2008) | 1 line Remove extraneous apostrophe and semi-colon from AdditionalIncludeDirectories. ........ r61615 | georg.brandl | 2008-03-19 08:56:40 +0100 (Mi, 19 Mär 2008) | 2 lines Remove footnote from versionchanged as it upsets LaTeX. ........ r61616 | georg.brandl | 2008-03-19 08:57:57 +0100 (Mi, 19 Mär 2008) | 2 lines Another one. ........ r61618 | trent.nelson | 2008-03-19 09:06:03 +0100 (Mi, 19 Mär 2008) | 1 line Fix the tcl-8.4.18.1 path and make sure we cd into the right directory when building tcl/tk. ........ r61621 | trent.nelson | 2008-03-19 10:23:08 +0100 (Mi, 19 Mär 2008) | 1 line Lets have another try at getting the Windows buildbots in a consistent state before rebuilding using the new process. ........ r61622 | eric.smith | 2008-03-19 13:09:55 +0100 (Mi, 19 Mär 2008) | 2 lines Use test.test_support.captured_stdout instead of a custom contextmanager. Thanks Nick Coghlan. ........ r61623 | eric.smith | 2008-03-19 13:15:10 +0100 (Mi, 19 Mär 2008) | 1 line Trivial typo. ........ r61625 | thomas.heller | 2008-03-19 17:10:57 +0100 (Mi, 19 Mär 2008) | 2 lines Checkout sqlite-source when it is not there. ........ r61627 | brett.cannon | 2008-03-19 17:50:13 +0100 (Mi, 19 Mär 2008) | 5 lines test_nis would fail if test.test_support.verbose was true but NIS was not set up on the machine. Closes issue2411. Thanks Michael Bishop. ........ r61631 | brett.cannon | 2008-03-19 18:37:43 +0100 (Mi, 19 Mär 2008) | 2 lines Use sys.py3kwarning instead of trying to trigger a Py3k-related warning. ........ r61632 | raymond.hettinger | 2008-03-19 18:45:19 +0100 (Mi, 19 Mär 2008) | 1 line Issue 2354: Fix-up compare warning. Patch contributed by Jeff Balogh. ........ r61633 | raymond.hettinger | 2008-03-19 18:58:59 +0100 (Mi, 19 Mär 2008) | 1 line The filter() function does support a None argument in Py3.0. ........ r61634 | raymond.hettinger | 2008-03-19 19:01:58 +0100 (Mi, 19 Mär 2008) | 1 line Remove itertools warnings I had added before the 2-to-3 handled the migration. ........
1 parent c918171 commit d5e2b6f

26 files changed

+277
-215
lines changed

Diff for: Doc/library/hashlib.rst

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ algorithm (defined in Internet :rfc:`1321`). The terms "secure hash" and
1919
"message digest" are interchangeable. Older algorithms were called message
2020
digests. The modern term is secure hash.
2121

22+
.. note::
23+
If you want the adler32 or crc32 hash functions they are available in
24+
the :mod:`zlib` module.
25+
2226
.. warning::
2327

2428
Some algorithms have known hash collision weaknesses, see the FAQ at the end.

Diff for: Lib/distutils/sysconfig.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@
2323
EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
2424

2525
# Path to the base directory of the project. On Windows the binary may
26-
# live in project/PCBuild9
26+
# live in project/PCBuild9. If we're dealing with an x64 Windows build,
27+
# it'll live in project/PCbuild/amd64.
2728
project_base = os.path.dirname(os.path.abspath(sys.executable))
2829
if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
2930
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
3031
# PC/VS7.1
3132
if os.name == "nt" and "\\pc\\v" in project_base[-10:].lower():
3233
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir,
3334
os.path.pardir))
35+
# PC/AMD64
36+
if os.name == "nt" and "\\pcbuild\\amd64" in project_base[-14:].lower():
37+
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir,
38+
os.path.pardir))
3439

3540
# python_build: (Boolean) if true, we're either building Python or
3641
# building an extension with an un-installed Python, so we use

Diff for: Lib/hashlib.py

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
More algorithms may be available on your platform but the above are
1919
guaranteed to exist.
2020
21+
NOTE: If you want the adler32 or crc32 hash functions they are available in
22+
the zlib module.
23+
2124
Choose your hash function wisely. Some have known collision weaknesses.
2225
sha384 and sha512 will be slow on 32 bit platforms.
2326

Diff for: Lib/test/regrtest.py

+8
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,14 @@ def __init__(self):
11571157
if sys.platform != 'sunos5':
11581158
self.expected.add('test_nis')
11591159

1160+
# TODO: This is a hack to raise TestSkipped if -3 is not enabled.
1161+
# Instead of relying on callable to have a warning, we should expose
1162+
# the -3 flag to Python code somehow
1163+
with test_support.catch_warning() as w:
1164+
callable(int)
1165+
if w.message is None:
1166+
self.expected.add('test_py3kwarn')
1167+
11601168
self.valid = True
11611169

11621170
def isvalid(self):

Diff for: Lib/test/test_import.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,20 @@ def test_trailing_slash(self):
255255
self.assertEqual(mod.testdata, 'test_trailing_slash')
256256
unload("test_trailing_slash")
257257

258+
class RelativeImport(unittest.TestCase):
259+
def tearDown(self):
260+
try:
261+
del sys.modules["test.relimport"]
262+
except:
263+
pass
264+
265+
def test_relimport_star(self):
266+
# This will import * from .test_import.
267+
from . import relimport
268+
self.assertTrue(hasattr(relimport, "RelativeImport"))
269+
258270
def test_main(verbose=None):
259-
run_unittest(ImportTest, PathsTests)
271+
run_unittest(ImportTest, PathsTests, RelativeImport)
260272

261273
if __name__ == '__main__':
262274
test_main()

Diff for: Lib/test/test_int_literal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import unittest
77
from test import test_support
88

9-
class TextHexOctBin(unittest.TestCase):
9+
class TestHexOctBin(unittest.TestCase):
1010

1111
def test_hex_baseline(self):
1212
# A few upper/lowercase tests
@@ -141,7 +141,7 @@ def test_bin_unsigned(self):
141141
self.assertEqual(-0b1111111111111111111111111111111111111111111111111111111111111111, -18446744073709551615)
142142

143143
def test_main():
144-
test_support.run_unittest(TextHexOctBin)
144+
test_support.run_unittest(TestHexOctBin)
145145

146146
if __name__ == "__main__":
147147
test_main()

Diff for: Lib/test/test_nis.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.test_support import verbose, run_unittest
1+
from test import test_support
22
import unittest
33
import nis
44

@@ -8,8 +8,10 @@ def test_maps(self):
88
maps = nis.maps()
99
except nis.error as msg:
1010
# NIS is probably not active, so this test isn't useful
11-
if verbose:
12-
self.fail("(failing because of verbose mode) %s" % msg)
11+
if test_support.verbose:
12+
print("Test Skipped:", msg)
13+
# Can't raise TestSkipped as regrtest only recognizes the exception
14+
# import time.
1315
return
1416
try:
1517
# On some systems, this map is only accessible to the
@@ -35,7 +37,7 @@ def test_maps(self):
3537
break
3638

3739
def test_main():
38-
run_unittest(NisTests)
40+
test_support.run_unittest(NisTests)
3941

4042
if __name__ == '__main__':
4143
test_main()

Diff for: Lib/test/test_posix.py

+28
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import time
1111
import os
12+
import pwd
1213
import unittest
1314
import warnings
1415
warnings.filterwarnings('ignore', '.* potential security risk .*',
@@ -141,6 +142,33 @@ def test_stat(self):
141142
if hasattr(posix, 'stat'):
142143
self.assert_(posix.stat(test_support.TESTFN))
143144

145+
if hasattr(posix, 'chown'):
146+
def test_chown(self):
147+
# raise an OSError if the file does not exist
148+
os.unlink(test_support.TESTFN)
149+
self.assertRaises(OSError, posix.chown, test_support.TESTFN, -1, -1)
150+
151+
# re-create the file
152+
open(test_support.TESTFN, 'w').close()
153+
if os.getuid() == 0:
154+
try:
155+
# Many linux distros have a nfsnobody user as MAX_UID-2
156+
# that makes a good test case for signedness issues.
157+
# http://bugs.python.org/issue1747858
158+
# This part of the test only runs when run as root.
159+
# Only scary people run their tests as root.
160+
ent = pwd.getpwnam('nfsnobody')
161+
posix.chown(test_support.TESTFN, ent.pw_uid, ent.pw_gid)
162+
except KeyError:
163+
pass
164+
else:
165+
# non-root cannot chown to root, raises OSError
166+
self.assertRaises(OSError, posix.chown,
167+
test_support.TESTFN, 0, 0)
168+
169+
# test a successful chown call
170+
posix.chown(test_support.TESTFN, os.getuid(), os.getgid())
171+
144172
def test_chdir(self):
145173
if hasattr(posix, 'chdir'):
146174
posix.chdir(os.curdir)

Diff for: Lib/test/test_print.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# 2.x
1313
from StringIO import StringIO
1414

15-
from contextlib import contextmanager
16-
1715
NotDefined = object()
1816

1917
# A dispatch table all 8 combinations of providing
@@ -40,15 +38,6 @@
4038
lambda args, sep, end, file: print(sep=sep, end=end, file=file, *args),
4139
}
4240

43-
@contextmanager
44-
def stdout_redirected(new_stdout):
45-
save_stdout = sys.stdout
46-
sys.stdout = new_stdout
47-
try:
48-
yield None
49-
finally:
50-
sys.stdout = save_stdout
51-
5241
# Class used to test __str__ and print
5342
class ClassWith__str__:
5443
def __init__(self, x):
@@ -69,8 +58,7 @@ def check(self, expected, args,
6958
end is not NotDefined,
7059
file is not NotDefined)]
7160

72-
t = StringIO()
73-
with stdout_redirected(t):
61+
with test_support.captured_stdout() as t:
7462
fn(args, sep, end, file)
7563

7664
self.assertEqual(t.getvalue(), expected)

Diff for: Lib/test/test_winsound.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,27 @@ def test_errors(self):
2323
self.assertRaises(ValueError, winsound.Beep, 32768, 75)
2424

2525
def test_extremes(self):
26-
if _have_soundcard():
27-
winsound.Beep(37, 75)
28-
winsound.Beep(32767, 75)
29-
else:
30-
# The behaviour of winsound.Beep() seems to differ between
31-
# different versions of Windows when there's either a) no
32-
# sound card entirely, b) legacy beep driver has been disabled,
33-
# or c) the legacy beep driver has been uninstalled. Sometimes
34-
# RuntimeErrors are raised, sometimes they're not. Meh.
35-
try:
36-
winsound.Beep(37, 75)
37-
winsound.Beep(32767, 75)
38-
except RuntimeError:
39-
pass
26+
self._beep(37, 75)
27+
self._beep(32767, 75)
4028

4129
def test_increasingfrequency(self):
42-
if _have_soundcard():
43-
for i in range(100, 2000, 100):
44-
winsound.Beep(i, 75)
30+
for i in xrange(100, 2000, 100):
31+
self._beep(i, 75)
32+
33+
def _beep(self, *args):
34+
# these tests used to use _have_soundcard(), but it's quite
35+
# possible to have a soundcard, and yet have the beep driver
36+
# disabled. So basically, we have no way of knowing whether
37+
# a beep should be produced or not, so currently if these
38+
# tests fail we're ignoring them
39+
#
40+
# XXX the right fix for this is to define something like
41+
# _have_enabled_beep_driver() and use that instead of the
42+
# try/except below
43+
try:
44+
winsound.Beep(*args)
45+
except RuntimeError:
46+
pass
4547

4648
class MessageBeepTest(unittest.TestCase):
4749

Diff for: Lib/test/test_zlib.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
from test import test_support
33
import zlib
4+
import binascii
45
import random
56

67

@@ -46,6 +47,12 @@ def test_crc32_adler32_unsigned(self):
4647
self.assertEqual(zlib.adler32(foo+foo), 3573550353)
4748
self.assertEqual(zlib.adler32('spam'), 72286642)
4849

50+
def test_same_as_binascii_crc32(self):
51+
foo = 'abcdefghijklmnop'
52+
crc = -1808088941
53+
self.assertEqual(binascii.crc32(foo), crc)
54+
self.assertEqual(zlib.crc32(foo), crc)
55+
self.assertEqual(binascii.crc32('spam'), zlib.crc32('spam'))
4956

5057

5158

0 commit comments

Comments
 (0)