[Python-bugs-list] [ python-Bugs-495094 ] evaluating integers inconsistently

noreply@sourceforge.net noreply@sourceforge.net
Wed, 19 Dec 2001 11:50:40 -0800


Bugs item #495094, was opened at 2001-12-19 08:44
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=495094&group_id=5470

Category: Python Interpreter Core
Group: Python 2.1.1
>Status: Deleted
Resolution: None
Priority: 5
Submitted By: Fahri Basegmez (basegmez)
Assigned to: Tim Peters (tim_one)
Summary: evaluating integers inconsistently

Initial Comment:
Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit 
(Intel)] on win32
Type "copyright", "credits" or "license" for more 
information.
IDLE 0.8 -- press F1 for help
>>> eval('01234')
668
>>> for i in range(10):print eval('0' + str(i))

0
1
2
3
4
5
6
7
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in ?
    for i in range(10):print eval('0' + str(i))
  File "<string>", line 1
    08
     ^
SyntaxError: unexpected EOF while parsing
>>> 08
SyntaxError: invalid syntax
>>> 01
1
>>> 0123456
42798
>>> 0123456L
42798L
>>> 

eval function and Python interpreter evaluates 
integers/long integers inconsistenly.  It should be an 
error either for all cases or for none.

Fahri Basegmez

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-12-19 10:57

Message:
Logged In: YES 
user_id=31435

Hmm.  What is your complaint here, exactly?  You showed a 
bunch of code but didn't point out anything that surprised 
me.  Do you know that integer literals beginning with "0" 
are in octal notation (so that the digits '8' and '9' 
aren't legal then, and 010 is decimal 8?).  Similarly, 
integer literals beginning with "0x" are in hex notation.  
A decimal integer literal cannot begin with 0.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=495094&group_id=5470