GothenburgBitFactory / tasklib

A Python library for interacting with taskwarrior databases.
http://tasklib.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
148 stars 28 forks source link

Override __copy__ and __deepcopy__ on LazyUUIDTask #42

Closed robgolding closed 8 years ago

robgolding commented 8 years ago

Fixes #41


Fairly small change to fix this bug! Since we do a deepcopy of all the task's data attributes after loading from JSON, and a recurring task has a parent, we were trying to copy a LazyUUIDTask. That meant we tried to load it in via replace(), and caused an infinite loop.

Since they're lazy by definition, the copy is implemented as just a new object with the same UUID.

Still needs a suitable test!

tbabej commented 8 years ago

Thanks for looking into this, looks good!

I wonder, should we also override these methods for LazyUUIDTaskSet?

robgolding commented 8 years ago

I don't think so, since child attributes are descended into and the __copy__ method is called, we get that for free anyway :)

Just added a test which actually does fail without this fix, so I'll be happy if everything passes!