diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -99,7 +99,7 @@ # Otherwise non-ASCII filenames in existing repositories would be # corrupted. # This must be set once prior to any fsencode/fsdecode calls. - sys._enablelegacywindowsfsencoding() + sys._enablelegacywindowsfsencoding() # pytype: disable=module-attr fsencode = os.fsencode fsdecode = os.fsdecode diff --git a/mercurial/scmwindows.py b/mercurial/scmwindows.py --- a/mercurial/scmwindows.py +++ b/mercurial/scmwindows.py @@ -10,11 +10,12 @@ ) try: - import _winreg as winreg + import _winreg as winreg # pytype: disable=import-error winreg.CloseKey except ImportError: - import winreg + # py2 only + import winreg # pytype: disable=import-error # MS-DOS 'more' is the only pager available by default on Windows. fallbackpager = b'more' diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -26,11 +26,12 @@ ) try: - import _winreg as winreg + import _winreg as winreg # pytype: disable=import-error winreg.CloseKey except ImportError: - import winreg + # py2 only + import winreg # pytype: disable=import-error osutil = policy.importmod('osutil') @@ -282,7 +283,7 @@ # fileno(), usually set to -1. fno = getattr(fd, 'fileno', None) if fno is not None and fno() >= 0: - msvcrt.setmode(fno(), os.O_BINARY) + msvcrt.setmode(fno(), os.O_BINARY) # pytype: disable=module-attr def pconvert(path):