See more details in my forum post:
http://www.python-forum.org/pythonforum/viewtopic.php?f=18&t=26724
I'm trying to pickle a bunch of functions (mostly built-in) and pickle keeps
giving me errors. I have no Ellipsis in my data at all, and for some reason,
pickle seems to think I do.
Here is an error I once received:
Traceback (most recent call last):
File "C:/Sunjay/My Website/projects/sunjay.ca/build/domath", line 132, in
main()
File "C:/Sunjay/My Website/projects/sunjay.ca/build/domath", line 127, in main
actions[action](form)
File "C:/Sunjay/My Website/projects/sunjay.ca/build/domath", line 107, in
do_math
print SESSION.output()
File "C:\Python27\lib\site-packages\session.py", line 207, in output
self.commit()
File "C:\Python27\lib\site-packages\session.py", line 152, in commit
dump(data, f, HIGHEST_PROTOCOL)
PicklingError: Can't pickle : attribute lookup
__builtin__.ellipsis failed
As well as the data structure which I am pickling:
user_session = {'math_user': {'scope': {'int': , 'DEGREE':
'DEGREE', 'atan': , 'pow': ,
'fsum': , 'cosh': , 'ldexp':
, 'hypot': , 'acosh':
, 'tan': , 'asin': , 'isnan': , 'log': , 'fabs': , 'floor': ,
'atanh': , 'sqrt': ,
'__package__': None, 'frexp': , 'factorial': , 'abs': , 'degrees': , '_': 123, 'fib': ,
'pi': 3.141592653589793, 'log10': , '__doc__': 'This
module is always available. It provides access to
mathematical\nfunctions for complex numbers.', 'mode': , 'polar': , 'asinh': , 'float': , 'fmod': ,
'CALC_MODE': 'RADIAN', '__builtins__': {}, 'copysign': , 'cos': , 'ceil': ,
'atan2': , 'isinf': , 'sinh':
, 'phase': , '__name__':
'cmath', 'rect': , 'trunc': ,
'expm1': , 'e': 2.718281828459045, 'tanh': , 'radians': , 'sin': , 'lgamma': , 'erf': , 'Vector': , 'erfc': ,
'RADIAN': 'RADIAN', 'modf': , 'Ans': 123, 'exp': , 'acos': , 'log1p': , 'round': ,
'gamma': }, 'history': [('123', 123)]},
'__date_loaded__': '2011-06-11'}
The above data structure can be simply put as so:
user_session = {
"math_user": {
"scope": {dictionary of all python math functions plus other types and
functions},
"history": [list of previous commands],
"__date_loaded__": timestamp of today's date
}
}
Please help me find out why this code is failing:
>>> from cPickle import dump, HIGHEST_PROTOCOL
>>> dump(user_session, open("C:\\Session.dump", "wb"), HIGHEST_PROTOCOL)
Traceback (most recent call last):
File "", line 1, in
dump(SESSION.data, open("C:\\Session.dump", "wb"), HIGHEST_PROTOCOL)
PicklingError: Can't pickle : attribute lookup
__builtin__.ellipsis failed
Thanks for your help,
Sunjay V. - www.sunjay.ca--
http://mail.python.org/mailman/listinfo/python-list