summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-03-06 18:44:35 +0000
committerGeorg Brandl <georg@python.org>2007-03-06 18:44:35 +0000
commitffb0a804c6eba81d6ed15e11b88f9fbb670d0cfe (patch)
tree5c2412a8bae1d102b77784f922c34e0b9b6353ec /Lib
parent8c9b3d6a137334777a2652a9fcc2eaac390b2921 (diff)
downloadcpython-git-ffb0a804c6eba81d6ed15e11b88f9fbb670d0cfe.tar.gz
Patch #1638879: don't accept strings with embedded NUL bytes in long().
(backport from rev. 54173)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_builtin.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 72b696690b..da2afbac35 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1017,6 +1017,11 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(ValueError, long, '53', 40)
self.assertRaises(TypeError, long, 1, 12)
+ # SF patch #1638879: embedded NULs were not detected with
+ # explicit base
+ self.assertRaises(ValueError, long, '123\0', 10)
+ self.assertRaises(ValueError, long, '123\x00 245', 20)
+
self.assertEqual(long('100000000000000000000000000000000', 2),
4294967296)
self.assertEqual(long('102002022201221111211', 3), 4294967296)