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:
Georg Brandl 2008-01-19 19:27:05 +00:00
parent 2686f4d9d1
commit 14404b68d8
6 changed files with 45 additions and 16 deletions

View file

@ -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