if self.enforce_reversible:
self.enforce_reversible = False
if self.encode(self.decode(encoded)) != encoded:
raise ValueError("Decoding is not reversible for "%s"" % encoded)
self.enforce_reversible = True
After Change
if self.enforce_reversible:
self.enforce_reversible = False
decoded_encoded = self.encode(self.decode(encoded))
self.enforce_reversible = True
if decoded_encoded != encoded:
raise ValueError("Decoding is not reversible for "%s"" % encoded)