mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Fix #1679: "0x" was taken as a valid integer literal.
Fixes the tokenizer, tokenize.py and int() to reject this. Patches by Malte Helmert.
This commit is contained in:
parent
2686f4d9d1
commit
14404b68d8
6 changed files with 45 additions and 16 deletions
|
@ -816,6 +816,11 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(int('0123', 0), 83)
|
||||
self.assertEqual(int('0x123', 16), 291)
|
||||
|
||||
# Bug 1679: "0x" is not a valid hex literal
|
||||
self.assertRaises(ValueError, int, "0x", 16)
|
||||
self.assertRaises(ValueError, int, "0x", 0)
|
||||
|
||||
|
||||
# SF bug 1334662: int(string, base) wrong answers
|
||||
# Various representations of 2**32 evaluated to 0
|
||||
# rather than 2**32 in previous versions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue