curious problem with large numbers - Due to subprocess - using pickle
Michael Spencer
mahs at telcopartners.com
Fri Apr 8 16:03:10 EDT 2005
Michael Spencer wrote:
>>
> Problem is associated with executing iteractive input in a subprocess.
>
> >python idle.py -n
>
> IDLE 1.1 ==== No Subprocess ====
> >>> 1e10000
> 1.#INF
> >>>
>
> Michael
>
>
It seems that the culprit is pickle - used to send messages between the IDLE
shell and the execution server.
>>> import pickle
>>> pickle.dumps(1e10000)
'F1.#INF\n.'
>>> pickle.loads(_)
Traceback (most recent call last):
File "<input>", line 1, in ?
File "c:\python24\lib\pickle.py", line 1394, in loads
return Unpickler(file).load()
File "c:\python24\lib\pickle.py", line 872, in load
dispatch[key](self)
File "c:\python24\lib\pickle.py", line 968, in load_float
self.append(float(self.readline()[:-1]))
ValueError: invalid literal for float(): 1.#INF
>>> import cPickle as pickle
>>> pickle.dumps(1e10000)
'F1.#INF\n.'
>>> pickle.loads(_)
Traceback (most recent call last):
File "<input>", line 1, in ?
ValueError: could not convert string to float
>>>
It seems that somewhere IDLE traps this error and shows '1.0' instead.
However, I can't follow the IDLE output code, so I won't try to track this down
any further
IDLE 1.1
>>> 2e10000
1.0
>>> 3e10000
1.0
>>> 100e10000
1.0
>>> 999e1000
1.0
>>>
Michael
More information about the Python-list
mailing list