Closed sanminaben closed 5 years ago
Hi,
Thanks a lot for the bugreport and the fix for this bug in PR #25.
You're totally right, I don't know why I used is
here. It was already fixed in dev
as I've rewritten a part of this code in the packagers, but I will do a quick release to avoid waiting for these changes to be merged.
Hi, no problem at all, I had not realized you had a dev
branch, checked it out now. Thanks for merging my pull request!
When trying to backup a VM using the following config.yml options:
virt-backup fails with the following error message:
After looking through the code, it seems that the offending line is here:
in
virt-backup/backups/pending.py
:The problem is that
if self.compression is "xz"
can evaluate as False even if self.compression is a type 'str' with a value 'xz'. The "is" operator evaluates that two objects are the same (same instance, i.e. same id(object) value), and while this will always work with "None" (there is only one None object exists in the interpreter), it will not work for other types by intermittence. Worse, because the interpreter tends to reuse the same objects for identical immutable int or str values, the "is" operator will sometimes pass, sometimes fail. Replacing the "is" operator with "==" solves the problem.