Issue 8825: int("0",0) throws exception (original) (raw)

Created on 2010-05-26 17:44 by cmoss60, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (11)
msg106554 - (view) Author: C Moss (cmoss60) Date: 2010-05-26 17:44
The expression int("0",0) throws an exception, though the expectation would be to return 0 (zero). int("0x0",0) == 0 int("00",0) = 0
msg106556 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-05-26 17:56
Hmm. It works for me: Python 2.6.5 (r265:79063, May 18 2010, 17:12:15) [GCC 4.2.1 (Apple Inc. build 5659)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> int("0", 0) 0 What version of Python are you using, and on what platform. Also, please could you show the exact code you used and the full exception traceback?
msg106558 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-05-26 18:02
Works fine on 2.6 and 3.1 on Windows.
msg106559 - (view) Author: C Moss (cmoss60) Date: 2010-05-26 18:03
I'm using MS IronPython 2.6 which is using CPython 2.6.1. Regards, Clark
msg106560 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-05-26 18:05
FWIW it works fine on 2.6/2.7/3.1/3.2 on Linux too.
msg106561 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-05-26 18:07
That's an IronPython bug, and I see the same thing as you when I run on IP 2.6. You could submit a bug report to them here: http://ironpython.codeplex.com/workitem/list/basic
msg106563 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-05-26 18:09
We ought to add a test case for this so that other implementations can detect an error.
msg106568 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-05-26 19:11
Added some test cases in r81551 (trunk) and r81552 (release26-maint). I'll merge these to py3k. But I notice that the rules for py3k are a little odd: >>> int('0000', 0) 0 >>> int('0001', 0) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 0: '0001' I expected the prohibition on leading zeros to apply to the first example, as well as the second.
msg106569 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-05-26 19:19
Tests merged to 3.x in r81553, r81554. Closing.
msg106629 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2010-05-27 23:56
I've opened a bug in the IronPython bug tracker: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27209
msg106639 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-05-28 07:17
Dino: I think Clark already did this: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27186 Sorry; I checked that there was an IronPython issue open before I closed this one, but forgot to mention it here.
History
Date User Action Args
2022-04-11 14:57:01 admin set github: 53071
2010-05-28 07:17:33 mark.dickinson set messages: +
2010-05-27 23:56:26 dino.viehland set messages: +
2010-05-26 19:24:34 brian.curtin set nosy: + dino.viehland
2010-05-26 19:19:29 mark.dickinson set status: open -> closedresolution: works for memessages: +
2010-05-26 19:11:58 giampaolo.rodola set nosy: + giampaolo.rodola
2010-05-26 19:11:19 mark.dickinson set messages: +
2010-05-26 18:09:23 rhettinger set nosy: + rhettingermessages: +
2010-05-26 18:07:06 brian.curtin set messages: +
2010-05-26 18:05:52 ezio.melotti set nosy: + ezio.melotti, michael.foordmessages: +
2010-05-26 18:03:58 cmoss60 set messages: +
2010-05-26 18:02:41 brian.curtin set nosy: + brian.curtinmessages: +
2010-05-26 17:56:40 mark.dickinson set nosy: + mark.dickinsonmessages: +
2010-05-26 17:44:20 cmoss60 create