From 1402094097dc61364a9a437cd8b715fc72c62766 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 23 Mar 2020 17:10:43 +0100 Subject: [PATCH] bpo-40014: test.pythoninfo catchs os.getgrouplist() error test.pythoninfo now catchs and handles OSError when calling os.getgrouplist(). --- Lib/test/pythoninfo.py | 9 +++++++-- .../next/Tests/2020-03-23-17-11-43.bpo-40014.MZdRMI.rst | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2020-03-23-17-11-43.bpo-40014.MZdRMI.rst diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index cc230dd2297a0ba..628863c0c40f672 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -333,8 +333,13 @@ def collect_pwd(info_add): return if hasattr(os, 'getgrouplist'): - groups = os.getgrouplist(entry.pw_name, entry.pw_gid) - groups = ', '.join(map(str, groups)) + try: + groups = os.getgrouplist(entry.pw_name, entry.pw_gid) + except OSError as exc: + # bpo-40014: os.getgrouplist() can fail on macOS 10.15 (Catalina) + groups = f'' + else: + groups = ', '.join(map(str, groups)) info_add('os.getgrouplist', groups) diff --git a/Misc/NEWS.d/next/Tests/2020-03-23-17-11-43.bpo-40014.MZdRMI.rst b/Misc/NEWS.d/next/Tests/2020-03-23-17-11-43.bpo-40014.MZdRMI.rst new file mode 100644 index 000000000000000..bff93eac3933251 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-03-23-17-11-43.bpo-40014.MZdRMI.rst @@ -0,0 +1,2 @@ +``test.pythoninfo`` now catchs and handles :exc:`OSError` when calling +:func:`os.getgrouplist`.