[Python-bugs-list] [ python-Bugs-481726 ] literal fp pound errors pass silently
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 14 Nov 2001 10:17:39 -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: Not a Bug
>Status: Closed
>Resolution: Invalid
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
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-11-14 10:17
Message:
Logged In: YES
user_id=31435
Not a bug: as Michael said, "#" is Python's comment
character. See the Reference Manual for Python's grammar
for float literals.
BTW, I expect you're running on Windows, as I don't know of
any other system that spells infinity as "1.#INF". float
("1.#INF") fails on Windows because Microsoft's C floating
input routines don't accept it (although Microsoft's C
floating output routines produce it). Other platforms are
much better behaved in this respect (they can read what
they write).
Beyond all that, Python has no knowledge of 754 gimmicks.
Repairing that is a feature request in PEP 42; that's a
major project (IMO), but with no volunteers in sight.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2001-11-14 10:07
Message:
Logged In: YES
user_id=6656
You haven't forgotten the fact that # is the comment
character in Python, have you?
This makes it "tricky" to implement reading
1.#INF
as anything other than
1.
!
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=481726&group_id=5470