Skip to content

Commit

Permalink
[libcxx] Support Python 3.8 in the test suite
Browse files Browse the repository at this point in the history
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
  • Loading branch information
broadwaylamb committed Jan 21, 2020
1 parent 3023352 commit 7b8dc8c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libcxx/utils/libcxx/test/target_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,25 @@ def __init__(self, full_config):
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.

Expand Down

0 comments on commit 7b8dc8c

Please sign in to comment.