[Pythonmac-SIG] fpconst vs pickle

Bob Ippolito bob at redivi.com
Sun Jul 27 14:18:56 EDT 2003


This is a Darwin bug.. on Darwin 6.6 (10.2.6), you couldn't create  
floats from string values:
[crack:~] bob% pythonw
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.
 >>> float('Inf')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
ValueError: invalid literal for float(): Inf
 >>> import os
 >>> os.uname()
('Darwin', 'crack.mob.lan', '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')

Darwin 7.0.0b1 (Panther DP) does not have this problem.

[navi:~] bob% pythonw
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.
 >>> float('Inf')
Inf
 >>> import os
 >>> os.uname()
('Darwin', 'navi.eva.lan.', '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')

-bob

On Saturday, July 26, 2003, at 2:53PM, Willard Myers wrote:

> 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
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig




More information about the Pythonmac-SIG mailing list