[Python-bugs-list] [ python-Bugs-445484 ] pickle lacks float('inf')

noreply@sourceforge.net noreply@sourceforge.net
Sat, 28 Jul 2001 08:21:03 -0700


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

Category: None
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Anthony Doggett (anthonydoggett)
Assigned to: Nobody/Anonymous (nobody)
Summary: pickle lacks float('inf')

Initial Comment:
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)

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

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