summarylogtreecommitdiffstats
path: root/platform_linux_distribution.diff
blob: 2b9bddacf799168d92cd4eece652a54729deb59a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py
--- a/llvm/projects/libcxx/utils/libcxx/test/target_info.py
+++ b/llvm/projects/libcxx/utils/libcxx/test/target_info.py
@@ -207,15 +207,25 @@
     def platform(self):
         return 'linux'
 
+    def _distribution(self):
+        try:
+            # linux_distribution is not available since Python 3.8
+            # However, this function is only used to detect SLES 11,
+            # which is quite an old distribution that doesn't have
+            # Python 3.8.
+            return platform.linux_distribution()
+        except AttributeError:
+            return '', '', ''
+
     def platform_name(self):
-        name, _, _ = platform.linux_distribution()
+        name, _, _ = self._distribution()
         # Some distros have spaces, e.g. 'SUSE Linux Enterprise Server'
         # lit features can't have spaces
         name = name.lower().strip().replace(' ', '-')
         return name # Permitted to be None
 
     def platform_ver(self):
-        _, ver, _ = platform.linux_distribution()
+        _, ver, _ = self._distribution()
         ver = ver.lower().strip().replace(' ', '-')
         return ver # Permitted to be None.