From 99a161bd0602d79e6c37b1bf64cd9a2553e0dd55 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 28 Sep 2020 08:48:50 +0200 Subject: [PATCH] Use platform.system for Darwin comparisons (#945) (#972) * Use platform.system for Darwin comparisons In Python3, `platform.platform()` returns `macOS-10.15.6-x86_64-i386-64bit` instead of `Darwin-10.15.6-x86_64-i386-64bit`. `platform.system()` returns `Darwin` On py2 and py3. * Add changlog fragment * Update changelogs/fragments/945-darwin-timezone-py3.yaml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit 954fb0a311d5a43c729de35043880794fd196638) Co-authored-by: Matt Martz --- changelogs/fragments/945-darwin-timezone-py3.yaml | 2 ++ plugins/modules/system/timezone.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/945-darwin-timezone-py3.yaml diff --git a/changelogs/fragments/945-darwin-timezone-py3.yaml b/changelogs/fragments/945-darwin-timezone-py3.yaml new file mode 100644 index 0000000000..98725b9454 --- /dev/null +++ b/changelogs/fragments/945-darwin-timezone-py3.yaml @@ -0,0 +1,2 @@ +bugfixes: +- timezone - support Python3 on macos/darwin (https://github.com/ansible-collections/community.general/pull/945). diff --git a/plugins/modules/system/timezone.py b/plugins/modules/system/timezone.py index 054cfc4763..d10dd9bb8b 100644 --- a/plugins/modules/system/timezone.py +++ b/plugins/modules/system/timezone.py @@ -122,7 +122,7 @@ class Timezone(object): module.fail_json(msg='Adjusting timezone is not supported in Global Zone') return super(Timezone, SmartOSTimezone).__new__(SmartOSTimezone) - elif re.match('^Darwin', platform.platform()): + elif platform.system() == 'Darwin': return super(Timezone, DarwinTimezone).__new__(DarwinTimezone) elif re.match('^(Free|Net|Open)BSD', platform.platform()): return super(Timezone, BSDTimezone).__new__(BSDTimezone)