template: FileNotFoundError is actually a built in exception stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 19 Aug 2021 17:46:46 +0200
branchstable
changeset 47857 2b76255a4f74
parent 47856 142a76127e3a
child 47858 df94c13ddf60
template: FileNotFoundError is actually a built in exception However it is python3 only. Differential Revision: https://phab.mercurial-scm.org/D11310
mercurial/pycompat.py
mercurial/templater.py
--- a/mercurial/pycompat.py	Thu Aug 19 18:04:14 2021 +0200
+++ b/mercurial/pycompat.py	Thu Aug 19 17:46:46 2021 +0200
@@ -40,6 +40,8 @@
     def future_set_exception_info(f, exc_info):
         f.set_exception_info(*exc_info)
 
+    # this is close enough for our usage
+    FileNotFoundError = OSError
 
 else:
     import concurrent.futures as futures
@@ -53,6 +55,8 @@
     def future_set_exception_info(f, exc_info):
         f.set_exception(exc_info[0])
 
+    FileNotFoundError = __builtins__['FileNotFoundError']
+
 
 def identity(a):
     return a
--- a/mercurial/templater.py	Thu Aug 19 18:04:14 2021 +0200
+++ b/mercurial/templater.py	Thu Aug 19 17:46:46 2021 +0200
@@ -71,7 +71,10 @@
 import os
 
 from .i18n import _
-from .pycompat import getattr
+from .pycompat import (
+    FileNotFoundError,
+    getattr,
+)
 from . import (
     config,
     encoding,
@@ -856,7 +859,7 @@
                     subresource = resourceutil.open_resource(
                         b'mercurial.templates', rel
                     )
-                except resourceutil.FileNotFoundError:
+                except FileNotFoundError:
                     subresource = None
             else:
                 dir = templatedir()