From 43e709b9f234fecdc17681967c842fb5bc373f66 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 25 Nov 2025 21:41:49 +0100 Subject: [PATCH] [stable-11] Fix crash in module_utils.datetime.fromtimestamp() (#11206) (#11214) Fix crash in module_utils.datetime.fromtimestamp() (#11206) Fix crash in module_utils.datetime.fromtimestamp(). (cherry picked from commit cbf13ab6c9156066bf51c543b1ffde5b32f7f248) --- changelogs/fragments/11206-datetime.yml | 3 +++ plugins/module_utils/datetime.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/11206-datetime.yml diff --git a/changelogs/fragments/11206-datetime.yml b/changelogs/fragments/11206-datetime.yml new file mode 100644 index 0000000000..136c0edf4a --- /dev/null +++ b/changelogs/fragments/11206-datetime.yml @@ -0,0 +1,3 @@ +bugfixes: + - "datetime module utils - fix bug in ``fromtimestamp()`` that caused the function to crash. + This function is not used in community.general (https://github.com/ansible-collections/community.general/pull/11206)." diff --git a/plugins/module_utils/datetime.py b/plugins/module_utils/datetime.py index c7899f68da..e8e358dbad 100644 --- a/plugins/module_utils/datetime.py +++ b/plugins/module_utils/datetime.py @@ -22,8 +22,8 @@ def ensure_timezone_info(value): def fromtimestamp(value): if _USE_TIMEZONE: - return _datetime.fromtimestamp(value, tz=_datetime.timezone.utc) - return _datetime.utcfromtimestamp(value) + return _datetime.datetime.fromtimestamp(value, tz=_datetime.timezone.utc) + return _datetime.datetime.utcfromtimestamp(value) def now():