Skip to content

Commit b4efb3d

Browse files
committed
Merged revisions 83212,83829,83833,83838-83839,83878,84019,84025,84028,84032,84036 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83212 | florent.xicluna | 2010-07-28 18:39:41 +0200 (mer., 28 juil. 2010) | 2 lines Syntax cleanup. ........ r83829 | florent.xicluna | 2010-08-08 18:16:07 +0200 (dim., 08 août 2010) | 2 lines Use unittest specific methods for some urllib test cases. And replace urllib2 with urllib.request in comments. ........ r83833 | florent.xicluna | 2010-08-08 18:25:27 +0200 (dim., 08 août 2010) | 2 lines Add test case for the HTTPResponse being an iterable. Follow-up of issue #4608. ........ r83838 | florent.xicluna | 2010-08-08 20:03:44 +0200 (dim., 08 août 2010) | 2 lines Typo. ........ r83839 | florent.xicluna | 2010-08-08 20:06:13 +0200 (dim., 08 août 2010) | 2 lines Issue #7564: Skip test_ioctl if another process is attached to /dev/tty. ........ r83878 | florent.xicluna | 2010-08-09 10:29:08 +0200 (lun., 09 août 2010) | 1 line Merge the 2to3 script from /sandbox/trunk/2to3/2to3, revision 72867 (latest). ........ r84019 | florent.xicluna | 2010-08-14 17:56:42 +0200 (sam., 14 août 2010) | 11 lines Merged manually from 2.7 branch to 3.x trunk. ------------------------------------------------------------------------ r79925 | nick.coghlan | 2010-04-10 16:24:36 +0200 (sam. 10 avril 2010) Try to turn some buildbots green by allowing test_multiprocessing to pass even if it hits the sys.exc_clear code in the threading module, and improve the test coverage by making the ctypes dependencies a bit more granular (two of the cited ctypes objects don't exist on my system) ------------------------------------------------------------------------ ........ r84025 | florent.xicluna | 2010-08-14 18:56:27 +0200 (sam., 14 août 2010) | 1 line List Misc/python-config.in in Misc/README. Fix few typos. ........ r84028 | florent.xicluna | 2010-08-14 19:02:49 +0200 (sam., 14 août 2010) | 1 line Fix order. ........ r84032 | florent.xicluna | 2010-08-14 19:15:31 +0200 (sam., 14 août 2010) | 1 line Convert to spaces. ........ r84036 | florent.xicluna | 2010-08-14 20:03:19 +0200 (sam., 14 août 2010) | 1 line Remove bad merge (from svnmerge r82301) ........
1 parent 3554473 commit b4efb3d

File tree

16 files changed

+156
-112
lines changed

16 files changed

+156
-112
lines changed

Doc/library/stdtypes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,10 +1163,6 @@ functions based on regular expressions.
11631163
You can use :meth:`str.maketrans` to create a translation map from
11641164
character-to-character mappings in different formats.
11651165

1166-
You can use the :func:`~string.maketrans` helper function in the :mod:`string`
1167-
module to create a translation table. For string objects, set the *table*
1168-
argument to ``None`` for translations that only delete characters:
1169-
11701166
.. note::
11711167

11721168
An even more flexible approach is to create a custom character mapping

Lib/ctypes/test/test_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def func(x):
164164
result = integrate(0.0, 1.0, CALLBACK(func), 10)
165165
diff = abs(result - 1./3.)
166166

167-
self.assertTrue(diff < 0.01, "%s not less than 0.01" % diff)
167+
self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
168168

169169
################################################################
170170

Lib/json/encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def _iterencode(o, _current_indent_level):
397397
yield 'true'
398398
elif o is False:
399399
yield 'false'
400-
elif isinstance(o, (int, int)):
400+
elif isinstance(o, int):
401401
yield str(o)
402402
elif isinstance(o, float):
403403
yield _floatstr(o)

Lib/pickletools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ def __repr__(self):
733733

734734
pyinteger_or_bool = StackObject(
735735
name='int_or_bool',
736-
obtype=(int, int, bool),
736+
obtype=(int, bool),
737737
doc="A Python integer object (short or long), or "
738738
"a Python bool.")
739739

Lib/test/test_binop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def isint(x):
1515

1616
def isnum(x):
1717
"""Test whether an object is an instance of a built-in numeric type."""
18-
for T in int, int, float, complex:
18+
for T in int, float, complex:
1919
if isinstance(x, T):
2020
return 1
2121
return 0

Lib/test/test_ioctl.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77

88
try:
99
tty = open("/dev/tty", "r")
10-
tty.close()
1110
except IOError:
1211
raise unittest.SkipTest("Unable to open /dev/tty")
12+
else:
13+
# Skip if another process is in foreground
14+
r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
15+
tty.close()
16+
rpgrp = struct.unpack("i", r)[0]
17+
if rpgrp not in (os.getpgrp(), os.getsid(0)):
18+
raise unittest.SkipTest("Neither the process group nor the session "
19+
"are attached to /dev/tty")
20+
del tty, r, rpgrp
1321

1422
try:
1523
import pty

Lib/test/test_multiprocessing.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import gc
1515
import signal
1616
import array
17-
import copy
1817
import socket
1918
import random
2019
import logging
@@ -68,11 +67,21 @@ def latin(s):
6867
#
6968

7069
try:
71-
from ctypes import Structure, Value, copy, c_int, c_double
70+
from ctypes import Structure, c_int, c_double
7271
except ImportError:
7372
Structure = object
7473
c_int = c_double = None
7574

75+
try:
76+
from ctypes import Value
77+
except ImportError:
78+
Value = None
79+
80+
try:
81+
from ctypes import copy as ctypes_copy
82+
except ImportError:
83+
ctypes_copy = None
84+
7685
#
7786
# Creates a wrapper for a function which records the time it takes to finish
7887
#
@@ -1103,11 +1112,9 @@ def baz():
11031112
yield i*i
11041113

11051114
class IteratorProxy(BaseProxy):
1106-
_exposed_ = ('next', '__next__')
1115+
_exposed_ = ('__next__',)
11071116
def __iter__(self):
11081117
return self
1109-
def __next__(self):
1110-
return self._callmethod('next')
11111118
def __next__(self):
11121119
return self._callmethod('__next__')
11131120

@@ -1565,7 +1572,7 @@ def _double(self, x, y, foo, arr, string):
15651572
for i in range(len(arr)):
15661573
arr[i] *= 2
15671574

1568-
@unittest.skipIf(c_int is None, "requires _ctypes")
1575+
@unittest.skipIf(Value is None, "requires ctypes.Value")
15691576
def test_sharedctypes(self, lock=False):
15701577
x = Value('i', 7, lock=lock)
15711578
y = Value(ctypes.c_double, 1.0/3.0, lock=lock)
@@ -1586,13 +1593,14 @@ def test_sharedctypes(self, lock=False):
15861593
self.assertAlmostEqual(arr[i], i*2)
15871594
self.assertEqual(string.value, latin('hellohello'))
15881595

1596+
@unittest.skipIf(Value is None, "requires ctypes.Value")
15891597
def test_synchronize(self):
15901598
self.test_sharedctypes(lock=True)
15911599

1592-
@unittest.skipIf(c_int is None, "requires _ctypes")
1600+
@unittest.skipIf(ctypes_copy is None, "requires ctypes.copy")
15931601
def test_copy(self):
15941602
foo = _Foo(2, 5.0)
1595-
bar = copy(foo)
1603+
bar = ctypes_copy(foo)
15961604
foo.x = 0
15971605
foo.y = 0
15981606
self.assertEqual(bar.x, 2)

Lib/test/test_pow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ def powtest(self, type):
1818
self.assertEquals(pow(2, i), pow2)
1919
if i != 30 : pow2 = pow2*2
2020

21-
for othertype in int, int:
21+
for othertype in (int,):
2222
for i in list(range(-10, 0)) + list(range(1, 10)):
2323
ii = type(i)
2424
for j in range(1, 11):
2525
jj = -othertype(j)
2626
pow(ii, jj)
2727

28-
for othertype in int, int, float:
28+
for othertype in int, float:
2929
for i in range(1, 100):
3030
zero = type(0)
3131
exp = -othertype(i/10.0)

Lib/test/test_sys.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def test_excepthook(self):
7979
# Python/pythonrun.c::PyErr_PrintEx() is tricky.
8080

8181
def test_exit(self):
82-
import subprocess
8382

8483
self.assertRaises(TypeError, sys.exit, 42, 42)
8584

@@ -458,7 +457,6 @@ def test_clear_type_cache(self):
458457
sys._clear_type_cache()
459458

460459
def test_ioencoding(self):
461-
import subprocess,os
462460
env = dict(os.environ)
463461

464462
# Test character: cent sign, encoded as 0x4A (ASCII J) in CP424,
@@ -480,7 +478,7 @@ def test_executable(self):
480478
# Issue #7774: Ensure that sys.executable is an empty string if argv[0]
481479
# has been set to an non existent program name and Python is unable to
482480
# retrieve the real program name
483-
import subprocess
481+
484482
# For a normal installation, it should work without 'cwd'
485483
# argument. For test runs in the build directory, see #7774.
486484
python_dir = os.path.dirname(os.path.realpath(sys.executable))

Lib/test/test_urllib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_geturl(self):
103103
self.assertEqual(self.returned_obj.geturl(), self.pathname)
104104

105105
def test_getcode(self):
106-
self.assertEqual(self.returned_obj.getcode(), None)
106+
self.assertIsNone(self.returned_obj.getcode())
107107

108108
def test_iter(self):
109109
# Test iterator
@@ -132,7 +132,7 @@ def test_getproxies_environment_keep_no_proxies(self):
132132
self.env.set('NO_PROXY', 'localhost')
133133
proxies = urllib.request.getproxies_environment()
134134
# getproxies_environment use lowered case truncated (no '_proxy') keys
135-
self.assertEquals('localhost', proxies['no'])
135+
self.assertEqual('localhost', proxies['no'])
136136

137137

138138
class urlopen_HttpTests(unittest.TestCase):

0 commit comments

Comments
 (0)