diff options
author | Fred Drake <fdrake@acm.org> | 2001-12-13 19:52:22 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-12-13 19:52:22 (GMT) |
commit | 526c7a0101d826fdab8b1ef5a757e1eae351687c (patch) | |
tree | fe3c026e4862df026da3aa91eba621e19f29877c /Lib | |
parent | 733c8935f9dfd1be70c472649eb845ea22bbc878 (diff) | |
download | cpython-526c7a0101d826fdab8b1ef5a757e1eae351687c.zip cpython-526c7a0101d826fdab8b1ef5a757e1eae351687c.tar.gz cpython-526c7a0101d826fdab8b1ef5a757e1eae351687c.tar.bz2 |
Ensure that complex() only accepts a string argument as the first arg,
and only if there is no second arg.
This closes SF patch #479551.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_b1.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py index b328b38..f2d0c24 100644 --- a/Lib/test/test_b1.py +++ b/Lib/test/test_b1.py @@ -122,6 +122,14 @@ if complex(0j, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)' if complex(0.0, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)' if complex(0j, 3.14) != 3.14j: raise TestFailed, 'complex(0j, 3.14)' if complex(0.0, 3.14) != 3.14j: raise TestFailed, 'complex(0.0, 3.14)' +if complex("1") != 1+0j: raise TestFailed, 'complex("1")' +if complex("1j") != 1j: raise TestFailed, 'complex("1j")' +try: complex("1", "1") +except TypeError: pass +else: raise TestFailed, 'complex("1", "1")' +try: complex(1, "1") +except TypeError: pass +else: raise TestFailed, 'complex(1, "1")' if complex(" 3.14+J ") != 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"' if have_unicode: if complex(unicode(" 3.14+J ")) != 3.14+1j: |