[Python-bugs-list] [ python-Bugs-481726 ] literal fp pound errors pass silently

noreply@sourceforge.net noreply@sourceforge.net
Wed, 14 Nov 2001 08:00:35 -0800


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

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Grant Griffin (dspguru)
Assigned to: Nobody/Anonymous (nobody)
Summary: literal fp pound errors pass silently

Initial Comment:
It looks like anything beyond a pound sign in a 
floating point literal is allowed, but ignored.  Here 
are a couple of examples:

----------

Python 2.2b1 (#25, Oct 19 2001, 11:44:52) [MSC 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for 
more information.
>>> a=1.#INF
>>> a
1.0

ActivePython 2.1.1, build 212 (ActiveState)
Python 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit 
(Intel)] on win32
Type "copyright", "credits" or "license" for more 
information.
>>> a=1.#asdf
>>> a
1.0
>>> a=2.#INF
>>> a
2.0
-----------

It seems like this notation should either be 
disallowed totally, or at least be disallowed when it 
does not result in a valid IEEE magic number (as in 
the second and third examples).

Also, maybe this has an impact on pickling if IEEE 
magic numbers cannot be remade from their strings, e.g.

>>> x=1e300
>>> y=x*x
>>> y
1.#INF
>>> z=float(str(y))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: invalid literal for float(): 1.#INF

(Note that "float()" does not accept the "#" notation, 
but the parser does.)

thanks,

=g2

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

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