mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
[3.6] bpo-31619: Fixed a ValueError when convert a string with large number of underscores (GH-3827) (#3863)
to integer with binary base.
(cherry picked from commit 85c0b8941f
)
This commit is contained in:
parent
ec47aff13a
commit
b5a630f3dd
3 changed files with 14 additions and 4 deletions
|
@ -506,5 +506,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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue