[issue15400] int('12345L', 10) raises ValueError

Michael Smith report at bugs.python.org
Thu Jul 19 21:21:43 CEST 2012


New submission from Michael Smith <kojiromike at gmail.com>:

The trailing 'L' in representations of long integers causes the int function to raise a ValueError. This is unexpected because it's reasonable to expect that `int` should be able to parse a number from any string when that string represented as a bare word would be a valid python number. The following all raise ValueError:

int(hex(12345L), 16)
int(oct(12345L), 8)

but not

int('12345', 10)
int(hex(12345), 16)
int(oct(12345), 8)
(and not bin() because of http://bugs.python.org/issue3186)

----------
components: Interpreter Core
messages: 165862
nosy: Michael.Smith
priority: normal
severity: normal
status: open
title: int('12345L', 10) raises ValueError
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15400>
_______________________________________


More information about the Python-bugs-list mailing list