allenai / mmda

multimodal document analysis
Apache License 2.0
159 stars 18 forks source link

`copy(token)` doesn't work now #88

Open lolipopshock opened 2 years ago

lolipopshock commented 2 years ago

It will lead to a recursion error

---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-63-895f162424ef> in <module>
----> 1 copy(token)

~/miniconda3/lib/python3.8/copy.py in copy(x)
    100     if isinstance(rv, str):
    101         return x
--> 102     return _reconstruct(x, None, *rv)
    103 
    104 

~/miniconda3/lib/python3.8/copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    269         if deep:
    270             state = deepcopy(state, memo)
--> 271         if hasattr(y, '__setstate__'):
    272             y.__setstate__(state)
    273         else:

~/gitsource/mmda/mmda/types/annotation.py in __getattr__(self, field)
     55     # TODO[kylel] - comment explaining
     56     def __getattr__(self, field: str) -> List["Annotation"]:
---> 57         if self.key_prefix + field in self.doc.fields:
     58             return self.doc.find_overlapping(self, self.key_prefix + field)
     59 

~/gitsource/mmda/mmda/types/annotation.py in key_prefix(self)
     45     @property
     46     def key_prefix(self) -> str:
---> 47         return f"{self.__class__.__name__}|{self.uuid}|"
     48 
     49     def attach_doc(self, doc: "Document") -> None:

... last 2 frames repeated, from the frame below ...

~/gitsource/mmda/mmda/types/annotation.py in __getattr__(self, field)
     55     # TODO[kylel] - comment explaining
     56     def __getattr__(self, field: str) -> List["Annotation"]:
---> 57         if self.key_prefix + field in self.doc.fields:
     58             return self.doc.find_overlapping(self, self.key_prefix + field)
     59 

RecursionError: maximum recursion depth exceeded