diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-01-02 19:45:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-02 19:45:36 (GMT) |
commit | 50b093f5c7060c0b44c264808411346cee7becf0 (patch) | |
tree | 9541a227bc17c7c2542fbba4fa042c2522c74290 /Lib/plistlib.py | |
parent | fff1e8a50b4eeea83090f4c11e21b4577e8d09e3 (diff) | |
download | cpython-50b093f5c7060c0b44c264808411346cee7becf0.zip cpython-50b093f5c7060c0b44c264808411346cee7becf0.tar.gz cpython-50b093f5c7060c0b44c264808411346cee7becf0.tar.bz2 |
gh-53502: Fix plistlib.dump() for naive datetime with aware_datetime option (GH-113645)
Diffstat (limited to 'Lib/plistlib.py')
-rw-r--r-- | Lib/plistlib.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/plistlib.py b/Lib/plistlib.py index 6eb70ce..0fc1b5c 100644 --- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -155,7 +155,7 @@ def _date_from_string(s, aware_datetime): def _date_to_string(d, aware_datetime): - if aware_datetime and d.tzinfo is not None: + if aware_datetime: d = d.astimezone(datetime.UTC) return '%04d-%02d-%02dT%02d:%02d:%02dZ' % ( d.year, d.month, d.day, @@ -791,7 +791,7 @@ class _BinaryPlistWriter (object): self._fp.write(struct.pack('>Bd', 0x23, value)) elif isinstance(value, datetime.datetime): - if self._aware_datetime and value.tzinfo is not None: + if self._aware_datetime: dt = value.astimezone(datetime.UTC) offset = dt - datetime.datetime(2001, 1, 1, tzinfo=datetime.UTC) f = offset.total_seconds() |