Skip to content

Commit 8dbe13f

Browse files
broadwaylambzmodem
authored andcommitted
[libcxx] Support Python 3.8 in the test suite
Summary: `platform.linux_distribution()` has been deprecated in Python 3.5 and removed in Python 3.8. Reviewers: bcain, bcraig, jroelofs, EricWF, mclow.lists, ldionne Reviewed By: jroelofs Subscribers: dexonsmith, christof, ldionne, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D72501 (cherry picked from commit 7b8dc8c)
1 parent f636e9f commit 8dbe13f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

libcxx/utils/libcxx/test/target_info.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,25 @@ def __init__(self, full_config):
207207
def platform(self):
208208
return 'linux'
209209

210+
def _distribution(self):
211+
try:
212+
# linux_distribution is not available since Python 3.8
213+
# However, this function is only used to detect SLES 11,
214+
# which is quite an old distribution that doesn't have
215+
# Python 3.8.
216+
return platform.linux_distribution()
217+
except AttributeError:
218+
return '', '', ''
219+
210220
def platform_name(self):
211-
name, _, _ = platform.linux_distribution()
221+
name, _, _ = self._distribution()
212222
# Some distros have spaces, e.g. 'SUSE Linux Enterprise Server'
213223
# lit features can't have spaces
214224
name = name.lower().strip().replace(' ', '-')
215225
return name # Permitted to be None
216226

217227
def platform_ver(self):
218-
_, ver, _ = platform.linux_distribution()
228+
_, ver, _ = self._distribution()
219229
ver = ver.lower().strip().replace(' ', '-')
220230
return ver # Permitted to be None.
221231

0 commit comments

Comments
 (0)