diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-04-14 22:04:03 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-04-14 22:04:03 (GMT) |
commit | 077f27141fbd31849d6bba074e445bf391a0e6f4 (patch) | |
tree | 752b029eda4906ce8a003049eaa8d1bd1feaa555 /Lib/test/test_b1.py | |
parent | 518d261f632e3b0ea6869756da39025fd23a9a6e (diff) | |
download | cpython-077f27141fbd31849d6bba074e445bf391a0e6f4.zip cpython-077f27141fbd31849d6bba074e445bf391a0e6f4.tar.gz cpython-077f27141fbd31849d6bba074e445bf391a0e6f4.tar.bz2 |
SF bug 543840: complex(string) accepts strings with \0
complex_subtype_from_string(): this stopped parsing at the first 0
byte, as if that were the end of the input string.
Bugfix candidate.
Diffstat (limited to 'Lib/test/test_b1.py')
-rw-r--r-- | Lib/test/test_b1.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py index 8d47abc..554e350 100644 --- a/Lib/test/test_b1.py +++ b/Lib/test/test_b1.py @@ -124,16 +124,29 @@ 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: raise TestFailed, 'complex(u" 3.14+J )"' + +# SF bug 543840: complex(string) accepts strings with \0 +# Fixed in 2.3. +try: + complex('1+1j\0j') +except ValueError: + pass +else: + raise TestFailed("complex('1+1j\0j') should have raised ValueError") + class Z: def __complex__(self): return 3.14j z = Z() |