[Pythonmac-SIG] fpconst vs pickle
Willard Myers
wlmyers at mac.com
Sat Jul 26 15:53:23 EDT 2003
I have the same Python 2.3c2+ installed on two different machines here,
along with the very useful fpconst module (which is pure Python). On
one machine, I can pickle/unpickle (with pickle or cPickle) the
constants defined in fpconst; on the other I hit a ValueError on
unpickle. I have different versions of Mac OS X on the two machines;
can that really cause this behavior? If that were so, I'd expect the
first case below to fail and the other to succeed :-<
Details:
=== Works ===
[abenaki:~] wlmyers% python
Python 2.3c2+ (#12, Jul 25 2003, 12:58:00)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import fpconst, pickle
>>> infinity = pickle.dumps(fpconst.PosInf)
>>> print infinity
FInf
.
>>> pickle.loads(infinity)
Inf
>>> type(pickle.loads(infinity))
<type 'float'>
>>> import os
>>> os.uname()
('Darwin', 'Abenaki.local.', '7.0.0b1', 'Darwin Kernel Version 7.0.0b1:
Mon Jun 16 23:01:44 PDT 2003; root:xnu/xnu-452.1.obj~1/RELEASE_PPC ',
'Power Macintosh')
=== Doesn't work ===
[mawson:Programming/Python/fpconst-0.6.0] wlmyers% python
Python 2.3c2+ (#12, Jul 25 2003, 12:58:00)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import fpconst, pickle
>>> infinity = pickle.dumps(fpconst.PosInf)
>>> print infinity
FInf
.
>>> pickle.loads(infinity)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/
pickle.py", line 1394, in loads
return Unpickler(file).load()
File
"/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/
pickle.py", line 872, in load
dispatch[key](self)
File
"/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/
pickle.py", line 968, in load_float
self.append(float(self.readline()[:-1]))
ValueError: invalid literal for float(): Inf
>>> import os
>>> os.uname()
('Darwin', 'Mawson.local.', '6.6', 'Darwin Kernel Version 6.6: Thu May
1 21:48:54 PDT 2003; root:xnu/xnu-344.34.obj~1/RELEASE_PPC ', 'Power
Macintosh')
>>>
Bill
More information about the Pythonmac-SIG
mailing list