summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-10-10 21:51:04 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-10-10 21:51:04 (GMT)
commit759920c5cb7aa8f9218b35148a3e4fb129cb86f2 (patch)
treee59e52ff9ea28029407eaf58c8e3813f8fd9cf62 /Lib
parentfc260a9a97156cc1cfee88b5947ed99d6b37025a (diff)
parent9086f9260f1f48a231cba4e7123eb7ac8159ba40 (diff)
downloadcpython-759920c5cb7aa8f9218b35148a3e4fb129cb86f2.zip
cpython-759920c5cb7aa8f9218b35148a3e4fb129cb86f2.tar.gz
cpython-759920c5cb7aa8f9218b35148a3e4fb129cb86f2.tar.bz2
Issue #22604: Fix assertion error in debug mode when dividing a complex number by (nan+0j).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_complex.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index cd55375..0ef9a7a 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -27,7 +27,7 @@ class ComplexTest(unittest.TestCase):
unittest.TestCase.assertAlmostEqual(self, a, b)
def assertCloseAbs(self, x, y, eps=1e-9):
- """Return true iff floats x and y "are close\""""
+ """Return true iff floats x and y "are close"."""
# put the one with larger magnitude second
if abs(x) > abs(y):
x, y = y, x
@@ -62,7 +62,7 @@ class ComplexTest(unittest.TestCase):
self.fail(msg.format(x, y))
def assertClose(self, x, y, eps=1e-9):
- """Return true iff complexes x and y "are close\""""
+ """Return true iff complexes x and y "are close"."""
self.assertCloseAbs(x.real, y.real, eps)
self.assertCloseAbs(x.imag, y.imag, eps)
@@ -104,6 +104,11 @@ class ComplexTest(unittest.TestCase):
self.assertAlmostEqual(complex.__truediv__(2+0j, 1+1j), 1-1j)
self.assertRaises(ZeroDivisionError, complex.__truediv__, 1+1j, 0+0j)
+ for denom_real, denom_imag in [(0, NAN), (NAN, 0), (NAN, NAN)]:
+ z = complex(0, 0) / complex(denom_real, denom_imag)
+ self.assertTrue(isnan(z.real))
+ self.assertTrue(isnan(z.imag))
+
def test_floordiv(self):
self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 1.5+0j)
self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 0+0j)