|
if isinstance(index, (int, slice)): |
there is a corner case that need to be note.
the object used as an index of a list, can be something other than int or slice.
it may be any object with an __index__ method which returns an int. for example, uint8 from numpy is not a subclass of pythons built in int. therefore, it cant be used as index of ListTag. (but it can be used as index of IntArrayTag)
i suggest to add a attribute in Path object: "isNbtPath". then we can use hasattr(index, "isNbtPath") to know if it is a nbt_Path.
nbtlib/nbtlib/tag.py
Line 982 in a6c0cd9
there is a corner case that need to be note.
the object used as an index of a list, can be something other than int or slice.
it may be any object with an
__index__method which returns an int. for example, uint8 from numpy is not a subclass of pythons built inint. therefore, it cant be used as index of ListTag. (but it can be used as index of IntArrayTag)i suggest to add a attribute in Path object: "isNbtPath". then we can use hasattr(index, "isNbtPath") to know if it is a nbt_Path.