[Python-checkins] python/dist/src/Lib/test test_b1.py,1.44,1.45

tim_one@sourceforge.net tim_one@sourceforge.net
Sun, 14 Apr 2002 15:04:05 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv28911/python/Lib/test

Modified Files:
	test_b1.py 
Log Message:
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.


Index: test_b1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** test_b1.py	26 Feb 2002 22:39:23 -0000	1.44
--- test_b1.py	14 Apr 2002 22:04:03 -0000	1.45
***************
*** 125,138 ****
--- 125,151 ----
  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