Patchwork D11310: template: FileNotFoundError is actually a built in exception

login
register
mail settings
Submitter phabricator
Date Aug. 19, 2021, 6:12 p.m.
Message ID <differential-rev-PHID-DREV-unwlbremgumlztuqtggc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49626/
State Superseded
Headers show

Comments

phabricator - Aug. 19, 2021, 6:12 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  However it is python3 only.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11310

AFFECTED FILES
  mercurial/pycompat.py
  mercurial/templater.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -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()
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -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