This is an automated email from the ASF dual-hosted git repository.
jialiang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new dafb41cece AMBARI-26522 : Fix imports for collections (#4033)
dafb41cece is described below
commit dafb41cece212437375975c978f435d37c2038d3
Author: HARSHITH GANDHE <[email protected]>
AuthorDate: Wed Jul 2 06:31:11 2025 +0530
AMBARI-26522 : Fix imports for collections (#4033)
Co-authored-by: harshith gandhe <[email protected]>
---
ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/runtime.py | 5 ++++-
ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/sandbox.py | 5 ++++-
ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/utils.py | 5 ++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git
a/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/runtime.py
b/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/runtime.py
index b39ac65b56..606fb0981e 100644
--- a/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/runtime.py
+++ b/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/runtime.py
@@ -261,7 +261,10 @@ class Context(object):
# register the context as mapping if possible
try:
- from collections import Mapping
+ try:
+ from collections.abc import Mapping
+ except ImportError:
+ from collections import Mapping
Mapping.register(Context)
except ImportError:
diff --git
a/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/sandbox.py
b/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/sandbox.py
index 42d8f012f4..a222fa9c7b 100644
--- a/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/sandbox.py
+++ b/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/sandbox.py
@@ -74,7 +74,10 @@ except ImportError:
#: register Python 2.6 abstract base classes
try:
- from collections import MutableSet, MutableMapping, MutableSequence
+ try:
+ from collections.abc import MutableSet, MutableMapping, MutableSequence
+ except ImportError:
+ from collections import MutableSet, MutableMapping, MutableSequence
_mutable_set_types += (MutableSet,)
_mutable_mapping_types += (MutableMapping,)
diff --git a/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/utils.py
b/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/utils.py
index 5f3f0ba2d0..3ebdecbaef 100644
--- a/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/utils.py
+++ b/ambari-common/src/main/python/ambari_jinja2/ambari_jinja2/utils.py
@@ -547,7 +547,10 @@ class LRUCache(object):
# register the LRU cache as mutable mapping if possible
try:
- from collections import MutableMapping
+ try:
+ from collections.abc import MutableMapping
+ except ImportError:
+ from collections import MutableMapping
MutableMapping.register(LRUCache)
except ImportError:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]