New submission from Michael Shields <michael.shie...@freenome.com>:

On macOS 10.5.5:

/tmp $ defaults export com.apple.security.KCN -
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
<plist version="1.0">
<dict>
        <key>absentCircleWithNoReason</key>
        <false/>
        <key>applicationDate</key>
        <date>0000-12-30T00:00:00Z</date>
        <key>lastCircleStatus</key>
        <integer>-1</integer>
        <key>lastWritten</key>
        <date>2019-10-15T17:23:33Z</date>
        <key>pendingApplicationReminder</key>
        <date>4001-01-01T00:00:00Z</date>
        <key>pendingApplicationReminderInterval</key>
        <integer>86400</integer>
</dict>
</plist>
/tmp $ cat plist_date_reduction.py 
#!/usr/bin/env python3

import plistlib
import subprocess

if __name__ == "__main__":
    plist = subprocess.check_output(["defaults", "export", 
"com.apple.security.KCN", "-"])
    print(plistlib.loads(plist, fmt=plistlib.FMT_XML))
/tmp $ python3.8 plist_date_reduction.py 
Traceback (most recent call last):
  File "plist_date_reduction.py", line 8, in <module>
    print(plistlib.loads(plist, fmt=plistlib.FMT_XML))
  File 
"/usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/lib/python3.8/plistlib.py",
 line 1000, in loads
    return load(
  File 
"/usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/lib/python3.8/plistlib.py",
 line 992, in load
    return p.parse(fp)
  File 
"/usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/lib/python3.8/plistlib.py",
 line 288, in parse
    self.parser.ParseFile(fileobj)
  File 
"/private/tmp/python@3.8-20200527-50093-16hak5w/Python-3.8.3/Modules/pyexpat.c",
 line 461, in EndElement
  File 
"/usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/lib/python3.8/plistlib.py",
 line 300, in handle_end_element
    handler()
  File 
"/usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/lib/python3.8/plistlib.py",
 line 376, in end_date
    self.add_object(_date_from_string(self.get_data()))
  File 
"/usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/lib/python3.8/plistlib.py",
 line 254, in _date_from_string
    return datetime.datetime(*lst)
ValueError: year 0 is out of range

----------
components: Library (Lib)
messages: 372131
nosy: shields-fn
priority: normal
severity: normal
status: open
title: plistlib can't decode date from year 0
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41083>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to