[ python-Bugs-862980 ] int('somenumber',0) returns somenummber
SourceForge.net
noreply at sourceforge.net
Fri Dec 19 11:00:44 EST 2003
Bugs item #862980, was opened at 2003-12-19 16:13
Message generated for change (Comment added) made by lcreighton
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=862980&group_id=5470
Category: Python Interpreter Core
Group: Not a Bug
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Laura Creighton (lcreighton)
Assigned to: Nobody/Anonymous (nobody)
Summary: int('somenumber',0) returns somenummber
Initial Comment:
Found this incredibly minor bug in Python 2.2 and 2.3
while writing testcases for PyPy.
>>> int('123',1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: int() base must be >= 2 and <= 36
>>> int('123',0)
123
>>>
Laura
----------------------------------------------------------------------
>Comment By: Laura Creighton (lcreighton)
Date: 2003-12-19 17:00
Message:
Logged In: YES
user_id=376262
Ooops, sorry about that.
So, now I guess I should change the PyPy one to guess.
Thanks Tim.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2003-12-19 16:53
Message:
Logged In: YES
user_id=31435
Sorry, you don't get a Bug Hunter award for this one, not
even an incredibly minor award <wink>. From the docs,
"If radix is zero, the proper radix is guessed based on the
contents of string; the interpretation is the same as for
integer literals." So, e.g.,
>>> int('10', 0)
10
>>> int('010', 0)
8
>>> int('0x10', 0)
16
>>>
but
>>> int('010')
10
>>>
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=862980&group_id=5470
More information about the Python-bugs-list
mailing list