I notice some user attribute (uA) issues when switching from python2
to python3. I have a leo file which contains pickled uA and which was
created using python2. When I opened that file with python3
(unknowingly--I was using a fresh Arch Linux install and didn't
realize python3 was the default--everywhere else I edit this leo file,
I had a manual install of python27), I got the following error:
getSaxUa can not unpickle
sol=b'7d71005509636f6d706c657465647101636461746574696d650a6461746574696d650a710228550a07db0c1a163226013e477103747104527105732e'
Thanks to that console message, I made sure not to save the file
fearing I might lose the uA information. Since I hadn't realized I
was running python3, it took me a little while to figure out the
different python version was the root of the problem.
I decided to create a small test outline to see if I would have lost
information and it appears I would have. So this is just a warning
for others to be careful with uA. If you have your own custom code
which is creating the uA, then maybe it won't catch you by surprise.
If there are any plugins which use uA behind the scenes and the user
doesn't even know uA are being used, then there might be some
surprises in store.
I wonder if python pickles are fundamentally incompatible between the
two versions or if there is something better leo could be doing. Does
anyone know?
The issue can be duplicated with the below steps:
1. Create a new outline in python2
2. Insert the following text in a body:
from datetime import datetime
d = p.v.u
id = d.get('sol',{})
id['completed'] = datetime.now()
d['sol'] = id
p.v.u = d
3. Execute the body with Ctrl-b - the node will now have a uA
4. Insert the following in another node body and make a script button from it:
d = p.v.u
id = d.get('sol',{})
print(id)
5. Select the original node and hit the script button to display the
uA to console
6. Save the outline
7. Open the outline using python3 and watch for the 'getSaxUa can not
unpickle' message
For now I'm going to stick with python2. When I want to switch, I
will need to write a script to somehow convert the uA.
Brian
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.