diff --git a/d9241f802160abee31e9bfe892e85770812bea75.patch b/d9241f802160abee31e9bfe892e85770812bea75.patch new file mode 100644 index 0000000..d01915d --- /dev/null +++ b/d9241f802160abee31e9bfe892e85770812bea75.patch @@ -0,0 +1,76 @@ +From d9241f802160abee31e9bfe892e85770812bea75 Mon Sep 17 00:00:00 2001 +From: Oleg Broytman +Date: Wed, 11 Sep 2019 21:58:46 +0300 +Subject: [PATCH] Fix(ImportManager): Fix infinite recursion + +--- + Cheetah/ImportManager.py | 7 +++++-- + Cheetah/Tests/ImportHooks.py | 8 ++++++++ + Cheetah/compat.py | 5 +++++ + docs/news.rst | 5 +++++ + 4 files changed, 23 insertions(+), 2 deletions(-) + +diff --git a/Cheetah/ImportManager.py b/Cheetah/ImportManager.py +index 8dff8f4..8117f11 100644 +--- a/Cheetah/ImportManager.py ++++ b/Cheetah/ImportManager.py +@@ -21,7 +21,7 @@ + import py_compile + import sys + from Cheetah.compat import PY2, string_type, new_module, get_suffixes, \ +- load_module_from_file ++ load_module_from_file, RecursionError + if PY2: + import imp + else: +@@ -520,7 +520,10 @@ def doimport(self, nm, parentnm, fqname): + else: + # now we're dealing with an absolute import + for director in self.metapath: +- mod = director.getmod(nm) ++ try: ++ mod = director.getmod(nm) ++ except RecursionError: ++ mod = __oldimport__(nm) # noqa: F821 undefined name + if mod: + break + if mod: +diff --git a/Cheetah/Tests/ImportHooks.py b/Cheetah/Tests/ImportHooks.py +index 2a4ff03..d7b5f5d 100644 +--- a/Cheetah/Tests/ImportHooks.py ++++ b/Cheetah/Tests/ImportHooks.py +@@ -4,6 +4,7 @@ + import sys + import unittest + import Cheetah.ImportHooks ++from Cheetah.compat import PY2 + + + ImportHooksTemplatesDir = os.path.join( +@@ -85,3 +86,10 @@ def test_import_builtin(self): + __import__(nm) + return + raise self.fail("All builtin modules are imported") ++ ++ if not PY2: ++ def test_import_bootlocale(self): ++ if '_bootlocale' in sys.modules: ++ del sys.modules['_bootlocale'] ++ Cheetah.ImportHooks.install() ++ import _bootlocale # noqa: F401 '_bootlocale' imported but unused +diff --git a/Cheetah/compat.py b/Cheetah/compat.py +index ea6a30c..9f42ba7 100644 +--- a/Cheetah/compat.py ++++ b/Cheetah/compat.py +@@ -12,6 +12,11 @@ + string_type = str + unicode = str + ++try: ++ RecursionError = RecursionError ++except NameError: # Python 2.7, 3.4 ++ RecursionError = RuntimeError ++ + if PY2: + import imp +