This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pickle lacks float('inf')
Type: enhancement Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: anthonydoggett, brett.cannon, georg.brandl, gvanrossum, tim.peters
Priority: low Keywords:

Created on 2001-07-28 15:21 by anthonydoggett, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (7)
msg53198 - (view) Author: Anthony Doggett (anthonydoggett) Date: 2001-07-28 15:21
Support for float('inf') still appears to be missing in

Python 2.1.1 (#1, Jul 28 2001, 14:15:01) 
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)]
on linux2

>>> cPickle.dumps(float('inf'), 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
SystemError: frexp() result out of range
>>> pickle.dumps(float('inf'), 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/var/ajd111/python/lib/python2.1/pickle.py",
line 943, in dumps
    Pickler(file, bin).dump(object)
  File "/var/ajd111/python/lib/python2.1/pickle.py",
line 109, in dump
    self.save(object)
  File "/var/ajd111/python/lib/python2.1/pickle.py",
line 211, in save
    f(self, object)
  File "/var/ajd111/python/lib/python2.1/pickle.py",
line 273, in save_float
    self.write(BINFLOAT + pack('>d', object))
SystemError: frexp() result out of range


Both structmodule.c and cPickle.c require changes.
Surely something like 

  if (x == HUGE_VAL) {    /* Inf */
      e = 1024;
      f = 0.0;
  }
  else {
      f = frexp(x, &e);
      ...

and

  if (e == 1024)
      x = HUGE_VAL;		/* Inf */
  else {

is all that is required for all IEEE754 machines?

(structmodule.c requires similar changes for Float
also)
msg53199 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-08-01 22:41
Logged In: YES 
user_id=31435

Note that Python has no intentional support for Infs and 
NaNs anywhere; even that float('inf') doesn't blow up when 
you do it is a platform accident (it blows up ("invalid 
literal") on my box).

Given that, in the absence of a comprehensive plan for 
supporting this stuff across the board, and worker bees to 
implement it, I downgraded the priority.  A good plan would 
refactor the code so that dealing with the platform double 
and float formats occurs in only one place.
msg53200 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-09-05 18:21
Logged In: YES 
user_id=6380

Is there a point in keeping this bug report open
indefinitely? A "won't fix" would make just as much sense.
Maybe add Inf support to PEP 42.
msg53201 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-09-05 20:16
Logged In: YES 
user_id=31435

Changed to Feature Request, and added to new "Non-
accidental 754 support" section of PEP 42.
msg53202 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-05-13 00:46
Logged In: YES 
user_id=357491

PEP 754 should make sure to deal with this.
msg53203 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-05-13 01:12
Logged In: YES 
user_id=31435

This appears to be outside the scope of PEP 754 (as 
defined by the PEP's author -- he's just aiming at symbolic 
constants and inquiry functions).
msg53204 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-07-17 13:11
Logged In: YES 
user_id=1188172

This is in CVS for 2.5.
History
Date User Action Args
2022-04-10 16:04:15adminsetgithub: 34850
2001-07-28 15:21:02anthonydoggettcreate