# HG changeset patch # User Franz Glasner # Date 1644404427 -3600 # Node ID c9f9401abc0c478b15f80856eec94ce75938c7ec # Parent 21d2589c96b9c1de12f15a360eb7f88c861ceae8 Use getattr when trying to get mmap.madvise() diff -r 21d2589c96b9 -r c9f9401abc0c shasum.py --- a/shasum.py Tue Feb 08 21:45:14 2022 +0100 +++ b/shasum.py Wed Feb 09 12:00:27 2022 +0100 @@ -481,10 +481,7 @@ # NOTE: On Windows mmapped files with length 0 are not supported. # So ensure to not call mmap.mmap() if the file size is 0. # - try: - madvise = mmap.mmap.madvise - except AttributeError: - madvise = None + madvise = getattr(mmap.mmap, "madvise", None) if filesize < MAP_CHUNK_SIZE: mapsize = filesize else: