Bug report
Bug description:
Documented behaviour: The plistlib documentation for dump states: "When aware_datetime is true and the value is an aware datetime.datetime, it will be converted to UTC timezone before writing it." The load documentation states: "When aware_datetime is true, fields with type datetime.datetime will be created as aware datetime.datetime with datetime.UTC as tzinfo."
Expected: UTC datetimes 2020-06-15 12:00 and 2020-06-15 11:00.
Actual: Both decoded datetimes are 2020-06-15 12:00 UTC.
import datetime as d
import plistlib as p
class Zone(d.tzinfo):
def utcoffset(self, dt):
return d.timedelta(hours=dt.fold)
def dst(self, dt):
return d.timedelta(0)
try:
z = Zone()
values = [d.datetime(2020, 6, 15, 12, tzinfo=z, fold=f) for f in (0, 1)]
offsets = [v.utcoffset() for v in values]
if not (values[0].tzinfo is values[1].tzinfo
and values[0].replace(tzinfo=None) == values[1].replace(tzinfo=None)
and offsets == [d.timedelta(0), d.timedelta(hours=1)]):
raise ValueError("input does not meet the reported conditions")
expected = [(v.replace(tzinfo=None) - o).replace(tzinfo=d.timezone.utc)
for v, o in zip(values, offsets)]
actual = p.loads(p.dumps(values, fmt=p.FMT_BINARY, aware_datetime=True),
aware_datetime=True)
if actual != expected:
print("REFUTATION CONFIRMED:", "input:", values,
"actual:", actual, "expected:", expected)
else:
print("REFUTATION REJECTED:", "actual matches the documented expectation")
except Exception as e:
print("REFUTATION REJECTED:", type(e).__name__, str(e))
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library plistlib:
REFUTATION CONFIRMED: input: [datetime.datetime(2020, 6, 15, 12, 0, tzinfo=<__main__.Zone object at 0x000001F754246BA0>), datetime.datetime(2020, 6, 15, 12, 0, fold=1, tzinfo=<__main__.Zone object at 0x000001F754246BA0>)] actual: [datetime.datetime(2020, 6, 15, 12, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2020, 6, 15, 12, 0, tzinfo=datetime.timezone.utc)] expected: [datetime.datetime(2020, 6, 15, 12, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2020, 6, 15, 11, 0, tzinfo=datetime.timezone.utc)]
This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/plistlib-20261003-073911-c4
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: The plistlib documentation for dump states: "When aware_datetime is true and the value is an aware datetime.datetime, it will be converted to UTC timezone before writing it." The load documentation states: "When aware_datetime is true, fields with type datetime.datetime will be created as aware datetime.datetime with datetime.UTC as tzinfo."
Expected: UTC datetimes 2020-06-15 12:00 and 2020-06-15 11:00.
Actual: Both decoded datetimes are 2020-06-15 12:00 UTC.
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library
plistlib:This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/plistlib-20261003-073911-c4
CPython versions tested on:
3.14
Operating systems tested on:
Windows