extended the has checksum case for edge cases that caused problems
This commit is contained in:
@@ -102,8 +102,20 @@ def checksum(*args, csum=None, _seen=None):
|
||||
_seen.add(obj_id)
|
||||
|
||||
if hasattr(arg, "__checksum__"):
|
||||
logger.debug("Checksum via __checksum__: %s", str(arg))
|
||||
csum.update(str(arg.__checksum__()).encode())
|
||||
method = getattr(arg, "__checksum__")
|
||||
if callable(method) and not isinstance(arg, type):
|
||||
logger.debug("Checksum via __checksum__: %s", str(arg))
|
||||
csum.update(str(method()).encode())
|
||||
elif isinstance(arg, type):
|
||||
try:
|
||||
src = inspect.getsource(arg)
|
||||
csum.update(strip_comments(src).encode())
|
||||
logger.debug("Checksum via class source for %s", arg.__name__)
|
||||
except (OSError, TypeError):
|
||||
csum.update(arg.__name__.encode())
|
||||
logger.debug("Checksum via class name for %s", arg.__name__)
|
||||
else:
|
||||
logger.debug("Skipping unbound __checksum__ on %s", type(arg))
|
||||
elif isinstance(arg, bytes):
|
||||
csum.update(arg)
|
||||
elif isinstance(arg, str):
|
||||
|
||||
Reference in New Issue
Block a user