Skip to content

Commit 7b8dc8c

Browse files
committed
[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
1 parent 3023352 commit 7b8dc8c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

libcxx/utils/libcxx/test/target_info.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,25 @@ def __init__(self, full_config):
206206
def platform(self):
207207
return 'linux'
208208

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

216226
def platform_ver(self):
217-
_, ver, _ = platform.linux_distribution()
227+
_, ver, _ = self._distribution()
218228
ver = ver.lower().strip().replace(' ', '-')
219229
return ver # Permitted to be None.
220230

0 commit comments

Comments
 (0)