Bug report
Bug description:
Documented behaviour: The plistlib documentation for dump's aware_datetime parameter states: “When true, datetime.datetime objects will be converted to UTC before writing.” The supported-types documentation includes datetime.datetime objects and lists.
Expected: [2024-11-03 05:30:00+00:00, 2024-11-03 06:30:00+00:00]
Actual: [2024-11-03 05:30:00+00:00, 2024-11-03 05:30:00+00:00]
import datetime as d
import io
import plistlib
class FoldTZ(d.tzinfo):
def utcoffset(self, dt):
return d.timedelta(hours=-4-dt.fold)
def dst(self, dt):
return d.timedelta(0)
def tzname(self, dt):
return "FoldTZ"
def __repr__(self):
return "FoldTZ()"
tz = FoldTZ()
xs = [d.datetime(2024, 11, 3, 1, 30, tzinfo=tz, fold=f) for f in (0, 1)]
try:
if not (isinstance(xs, list) and all(
isinstance(x, d.datetime) and x.microsecond == 0
and isinstance(x.utcoffset(), d.timedelta)
and abs(x.utcoffset()) < d.timedelta(days=1) for x in xs
)):
raise ValueError("input is not a supported list of aware whole-second datetimes")
expected = [(x.replace(tzinfo=None) - x.utcoffset()).replace(tzinfo=d.UTC)
for x in xs]
buf = io.BytesIO()
plistlib.dump(xs, buf, fmt=plistlib.FMT_BINARY, aware_datetime=True)
actual = plistlib.loads(buf.getvalue(), aware_datetime=True)
if actual != expected:
print("REFUTATION CONFIRMED:", "input=", xs, "actual=", actual,
"expected=", expected)
else:
print("REFUTATION REJECTED:", "actual matches documented UTC conversion")
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(2024, 11, 3, 1, 30, tzinfo=FoldTZ()), datetime.datetime(2024, 11, 3, 1, 30, fold=1, tzinfo=FoldTZ())] actual= [datetime.datetime(2024, 11, 3, 5, 30, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 11, 3, 5, 30, tzinfo=datetime.timezone.utc)] expected= [datetime.datetime(2024, 11, 3, 5, 30, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 11, 3, 6, 30, 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-c3
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: The plistlib documentation for dump's aware_datetime parameter states: “When true, datetime.datetime objects will be converted to UTC before writing.” The supported-types documentation includes datetime.datetime objects and lists.
Expected: [2024-11-03 05:30:00+00:00, 2024-11-03 06:30:00+00:00]
Actual: [2024-11-03 05:30:00+00:00, 2024-11-03 05:30:00+00:00]
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-c3
CPython versions tested on:
3.14
Operating systems tested on:
Windows