summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-10-03 11:13:44 (GMT)
committerGitHub <noreply@github.com>2017-10-03 11:13:44 (GMT)
commit85c0b8941f0c8ef3ed787c9d504712c6ad3eb5d3 (patch)
tree0b5ed0847156a9397d7b8bbee4ed6349a689172c /Lib
parent1a87de7fcfa3c19f08e29047337c350b4a32b259 (diff)
downloadcpython-85c0b8941f0c8ef3ed787c9d504712c6ad3eb5d3.zip
cpython-85c0b8941f0c8ef3ed787c9d504712c6ad3eb5d3.tar.gz
cpython-85c0b8941f0c8ef3ed787c9d504712c6ad3eb5d3.tar.bz2
bpo-31619: Fixed a ValueError when convert a string with large number of underscores (#3827)
to integer with binary base.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_int.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index 854117e..c048b71 100644
--- a/Lib/test/test_int.py
+++ b/Lib/test/test_int.py
@@ -508,5 +508,13 @@ class IntTestCases(unittest.TestCase):
check('123\ud800')
check('123\ud800', 10)
+ def test_issue31619(self):
+ self.assertEqual(int('1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1', 2),
+ 0b1010101010101010101010101010101)
+ self.assertEqual(int('1_2_3_4_5_6_7_0_1_2_3', 8), 0o12345670123)
+ self.assertEqual(int('1_2_3_4_5_6_7_8_9', 16), 0x123456789)
+ self.assertEqual(int('1_2_3_4_5_6_7', 32), 1144132807)
+
+
if __name__ == "__main__":
unittest.main()