# HG changeset patch # User Matt Harbison # Date 2021-09-20 14:46:35 # Node ID ae79611e3115c18cd3c213b656847b4e2b0547e2 # Parent 94d4a3f78e995eb1e3234154c5e3b29210360340 util: avoid a name-error warning in the `mmapread` exception handler Newly caught by pytype 2021-09-09. File "/mnt/c/Users/Matt/hg/mercurial/util.py", line 458, in mmapread: Name 'fd' is not defined [name-error] Differential Revision: https://phab.mercurial-scm.org/D11470 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -449,8 +449,8 @@ def mmapread(fp, size=None): return b'' elif size is None: size = 0 + fd = getattr(fp, 'fileno', lambda: fp)() try: - fd = getattr(fp, 'fileno', lambda: fp)() return mmap.mmap(fd, size, access=mmap.ACCESS_READ) except ValueError: # Empty files cannot be mmapped, but mmapread should still work. Check