Question about tnodeList attribute

24 views
Skip to first unread message

vitalije

unread,
May 31, 2020, 11:04:22 AM5/31/20
to leo-editor
I've started to work on the #1598. For now I am still reading code and trying to figure out how it works.

I have found a list of native vnode attributes:

    nativeVnodeAttributes = (
       
'a',
       
'descendentTnodeUnknownAttributes',
       
'descendentVnodeUnknownAttributes',
       
'expanded', 'marks', 't', 'tnodeList',
   
)

However, analyzing the write code, I see that the only <v> attributes that are ever written are "t" and sometimes "decendentVnodeUnknownAttributes".

The v.tnodeList is assigned and deleted on several places in Leo code, but I can't find any place that it is actually used. I can't recall seeing this attribute ever, and I don't remember what its purpose used to be.

I assume that all those ancient attributes can be safely ignored. Am I missing something?

If those attributes can be ignored, I think Leo's reading and writing logic can be greatly simplified.

Also there is a method FastRead.bytesToUnicode with the following __doc__:
    """
    Recursively convert bytes objects in strings / lists / dicts to str
    objects, thanks to TNT
    http://stackoverflow.com/questions/22840092
    Needed for reading Python 2.7 pickles in Python 3.4.
    """


Leo is now running on Python 3.5 or newer. Do we still need to warry about this Python2.7 pickle compatibility? If not, code can be further simplified.

Vitalije

Edward K. Ream

unread,
May 31, 2020, 1:48:18 PM5/31/20
to leo-editor
On Sun, May 31, 2020 at 10:04 AM vitalije <vita...@gmail.com> wrote:


The v.tnodeList is assigned and deleted on several places in Leo code, but I can't find any place that it is actually used. I can't recall seeing this attribute ever, and I don't remember what its purpose used to be.

I don't either.

I assume that all those ancient attributes can be safely ignored. Am I missing something?

Thanks for spotting this. I don't think you are missing anything. If cff's don't find anything, then there is nothing to find. Just make sure you search plugins as well.

If I had to guess, my guess would be that tnode attributes were originally used to handle marks and saved positions. They were probably saved in the vnode associated with root at-file nodes, and become vestigial when we started using an external cache for such things.

If those attributes can be ignored, I think Leo's reading and writing logic can be greatly simplified.

Good.
 
Also there is a method FastRead.bytesToUnicode with the following __doc__:
    """
    Recursively convert bytes objects in strings / lists / dicts to str
    objects, thanks to TNT
    http://stackoverflow.com/questions/22840092
    Needed for reading Python 2.7 pickles in Python 3.4.
    """


Leo is now running on Python 3.5 or newer. Do we still need to worry about this Python2.7 pickle compatibility?

The short answer is, I'm not sure. One can imagine a situation in which a uA in an old .leo file might contain a 2.7 pickle. My guess that this situation will be quite rare, now that Leo has required Python 3.6+ for about a year.

I suggest the following. Let's assume that all pickles are "modern." That is, I think it's ok for Leo to issue a message and fail to load a .leo file if it contains an old pickle. In that case, maybe there could be a script to do the conversion. But let's see if the problem ever happens.

Edward

vitalije

unread,
May 31, 2020, 2:32:42 PM5/31/20
to leo-editor
Thanks for the advice.

Vitalije

Edward K. Ream

unread,
May 31, 2020, 3:33:47 PM5/31/20
to leo-editor


On Sun, May 31, 2020 at 1:32 PM vitalije <vita...@gmail.com> wrote:
Thanks for the advice.

You're welcome.

Edward
Reply all
Reply to author
Forward
0 new messages