]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport tim_one's patch:
authorAnthony Baxter <anthonybaxter@gmail.com>
Thu, 18 Apr 2002 02:19:46 +0000 (02:19 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Thu, 18 Apr 2002 02:19:46 +0000 (02:19 +0000)
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.

Lib/distutils/command/bdist_dumb.py
Lib/distutils/command/bdist_wininst.py
Lib/test/test_b1.py
Objects/complexobject.c

index 8dfc3271dfaf18d8bdc8faa611b9e0efb0089985..13fe27c3aaa656bbf8ad4767c5a5993819ce6e0b 100644 (file)
@@ -81,6 +81,7 @@ class bdist_dumb (Command):
 
         # And make an archive relative to the root of the
         # pseudo-installation tree.
+        install.warn_dir = 0
         archive_basename = "%s.%s" % (self.distribution.get_fullname(),
                                       self.plat_name)
         self.make_archive(os.path.join(self.dist_dir, archive_basename),
index 7ef29f30b63b5341fb2c9e39ed725484e1d5bd5a..58d3c9372593df3737d6ad36a60fe3318d35e2b2 100644 (file)
@@ -98,6 +98,7 @@ class bdist_wininst (Command):
                 value = value + '/Include/$dist_name'
             setattr(install,
                     'install_' + key,
+        install.warn_dir = 0
                     value)
 
         self.announce("installing to %s" % self.bdist_dir)
index 275c6742b6001ccefc1a8b71d8d67f7f9aee40fc..d7e09250df21d8f8db1059a05a296ba1c2268326 100644 (file)
@@ -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()
index 48a9afa2e7fafcc591ff4b199d604c8a504fc3fa..8392f5d80d364a5cc45b929a55f17a378ad3a801 100644 (file)
@@ -787,7 +787,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
 
                }  /* end of switch  */
 
-       } while (*s!='\0' && !sw_error);
+       } while (s - start < len && !sw_error);
 
        if (sw_error) {
                PyErr_SetString(PyExc_ValueError,