summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/bsddb/dbtables.py2
-rw-r--r--Lib/contextlib.py4
-rw-r--r--Lib/ctypes/test/test_cfuncs.py22
-rw-r--r--Lib/ctypes/test/test_functions.py22
-rw-r--r--Lib/test/test_with.py17
5 files changed, 44 insertions, 23 deletions
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
index 06fcf8aacf..56b4e3a01d 100644
--- a/Lib/bsddb/dbtables.py
+++ b/Lib/bsddb/dbtables.py
@@ -362,7 +362,7 @@ class bsdTableDB :
unique = 0
while not unique:
# Generate a random 64-bit row ID string
- # (note: might have <64 bits of randomness
+ # (note: might have <64 bits of true randomness
# but it's plenty for our database id needs!)
blist = []
for x in range(_rowid_str_len):
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index fba4889002..aeec40e1e3 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -25,6 +25,10 @@ class GeneratorContextManager(object):
else:
raise RuntimeError("generator didn't stop")
else:
+ if value is None:
+ # Need to force instantiation so we can reliably
+ # tell if we get the same exception back
+ value = type()
try:
self.gen.throw(type, value, traceback)
raise RuntimeError("generator didn't stop after throw()")
diff --git a/Lib/ctypes/test/test_cfuncs.py b/Lib/ctypes/test/test_cfuncs.py
index e939bc1be8..8f97fc46a1 100644
--- a/Lib/ctypes/test/test_cfuncs.py
+++ b/Lib/ctypes/test/test_cfuncs.py
@@ -158,17 +158,17 @@ class CFunctions(unittest.TestCase):
self.failUnlessEqual(self._dll.tf_bd(0, 42.), 14.)
self.failUnlessEqual(self.S(), 42)
-## def test_longdouble(self):
-## self._dll.tf_D.restype = c_longdouble
-## self._dll.tf_D.argtypes = (c_longdouble,)
-## self.failUnlessEqual(self._dll.tf_D(42.), 14.)
-## self.failUnlessEqual(self.S(), 42)
-
-## def test_longdouble_plus(self):
-## self._dll.tf_bD.restype = c_longdouble
-## self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
-## self.failUnlessEqual(self._dll.tf_bD(0, 42.), 14.)
-## self.failUnlessEqual(self.S(), 42)
+ def test_longdouble(self):
+ self._dll.tf_D.restype = c_longdouble
+ self._dll.tf_D.argtypes = (c_longdouble,)
+ self.failUnlessEqual(self._dll.tf_D(42.), 14.)
+ self.failUnlessEqual(self.S(), 42)
+
+ def test_longdouble_plus(self):
+ self._dll.tf_bD.restype = c_longdouble
+ self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
+ self.failUnlessEqual(self._dll.tf_bD(0, 42.), 14.)
+ self.failUnlessEqual(self.S(), 42)
def test_callwithresult(self):
def process_result(result):
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index 626af948c9..3af11cc5de 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -143,17 +143,17 @@ class FunctionTestCase(unittest.TestCase):
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
-## def test_longdoubleresult(self):
-## f = dll._testfunc_D_bhilfD
-## f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
-## f.restype = c_longdouble
-## result = f(1, 2, 3, 4, 5.0, 6.0)
-## self.failUnlessEqual(result, 21)
-## self.failUnlessEqual(type(result), float)
-
-## result = f(-1, -2, -3, -4, -5.0, -6.0)
-## self.failUnlessEqual(result, -21)
-## self.failUnlessEqual(type(result), float)
+ def test_longdoubleresult(self):
+ f = dll._testfunc_D_bhilfD
+ f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
+ f.restype = c_longdouble
+ result = f(1, 2, 3, 4, 5.0, 6.0)
+ self.failUnlessEqual(result, 21)
+ self.failUnlessEqual(type(result), float)
+
+ result = f(-1, -2, -3, -4, -5.0, -6.0)
+ self.failUnlessEqual(result, -21)
+ self.failUnlessEqual(type(result), float)
def test_longlongresult(self):
try:
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index a7bc2068b4..e77846399d 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -442,6 +442,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
self.assertAfterWithGeneratorInvariantsNoError(self.bar)
def testRaisedStopIteration1(self):
+ # From bug 1462485
@contextmanager
def cm():
yield
@@ -453,6 +454,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
self.assertRaises(StopIteration, shouldThrow)
def testRaisedStopIteration2(self):
+ # From bug 1462485
class cm(object):
def __enter__(self):
pass
@@ -465,7 +467,21 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
self.assertRaises(StopIteration, shouldThrow)
+ def testRaisedStopIteration3(self):
+ # Another variant where the exception hasn't been instantiated
+ # From bug 1705170
+ @contextmanager
+ def cm():
+ yield
+
+ def shouldThrow():
+ with cm():
+ raise next(iter([]))
+
+ self.assertRaises(StopIteration, shouldThrow)
+
def testRaisedGeneratorExit1(self):
+ # From bug 1462485
@contextmanager
def cm():
yield
@@ -477,6 +493,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
self.assertRaises(GeneratorExit, shouldThrow)
def testRaisedGeneratorExit2(self):
+ # From bug 1462485
class cm (object):
def __enter__(self):
pass