diff --git a/lib3/yaml/constructor.py b/lib3/yaml/constructor.py index 981543ae..3c4a4ec9 100644 --- a/lib3/yaml/constructor.py +++ b/lib3/yaml/constructor.py @@ -330,9 +330,15 @@ def construct_yaml_timestamp(self, node): delta = datetime.timedelta(hours=tz_hour, minutes=tz_minute) if values['tz_sign'] == '-': delta = -delta - data = datetime.datetime(year, month, day, hour, minute, second, fraction) - if delta: - data -= delta + data = None + # If we are correcting to UTC, we can make the datetime object + # timezone-aware + if delta is not None: + data = datetime.datetime(year, month, day, hour, minute, second, fraction, datetime.timezone.utc) + if delta: + data -= delta + else: + data = datetime.datetime(year, month, day, hour, minute, second, fraction) return data def construct_yaml_omap(self, node):