[ python-Bugs-1611753 ] can't pickle NAN's in binary mode

SourceForge.net noreply at sourceforge.net
Sat Dec 9 15:37:33 CET 2006


Bugs item #1611753, was opened at 2006-12-08 18:45
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1611753&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Out of Date
Priority: 5
Private: No
Submitted By: Wayne Christopher (wayne606)
>Assigned to: Michael Hudson (mwh)
Summary: can't pickle NAN's in binary mode

Initial Comment:
I think the problem is that pack(">d", float("nan")) does not work.  Same for Inf.  This works fine with pickle in ascii mode.  I tried this on SuSE 10.0, x86_64.

Python 2.4.2 (#2, Sep 10 2006, 23:53:27)
[GCC 4.1.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> foo = [1, 2, float("nan")]
>>> foo
[1, 2, nan]
>>> fp = file("/tmp/xxx", "wb")
>>> pickle.dump(foo, fp, -1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/software/64/lib/python2.4/pickle.py", line 1382, in dump
    Pickler(file, protocol, bin).dump(obj)
  File "/home/software/64/lib/python2.4/pickle.py", line 231, in dump
    self.save(obj)
  File "/home/software/64/lib/python2.4/pickle.py", line 293, in save
    f(self, obj) # Call unbound method with explicit self
  File "/home/software/64/lib/python2.4/pickle.py", line 614, in save_list
    self._batch_appends(iter(obj))
  File "/home/software/64/lib/python2.4/pickle.py", line 647, in _batch_appends
    save(x)
  File "/home/software/64/lib/python2.4/pickle.py", line 293, in save
    f(self, obj) # Call unbound method with explicit self
  File "/home/software/64/lib/python2.4/pickle.py", line 489, in save_float
    self.write(BINFLOAT + pack('>d', obj))
SystemError: frexp() result out of range


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

>Comment By: Michael Hudson (mwh)
Date: 2006-12-09 14:37

Message:
Logged In: YES 
user_id=6656
Originator: NO

This is fixed in 2.5 (and if you think it worked fine in ASCII mode, I
don't think you tried moving your pickles between Linux and Windows
systems...).

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

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


More information about the Python-bugs-list mailing list