This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients belopolsky, ronaldoussoren, serhiy.storchaka
Date 2016-04-07.09:46:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1460022382.4.0.161874143104.issue26709@psf.upfronthosting.co.za>
In-reply-to
Content
Plistlib fails to load dates before year 1901 and after year 2038 in binary format on platforms with 32-bit time_t.

>>> data = plistlib.dumps(datetime.datetime(1901, 1, 1), fmt=plistlib.FMT_BINARY)
>>> plistlib.loads(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 1006, in loads
    fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 997, in load
    return p.parse(fp)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 623, in parse
    return self._read_object(self._object_offsets[top_object])
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 688, in _read_object
    return datetime.datetime.utcfromtimestamp(f + (31 * 365 + 8) * 86400)
OverflowError: timestamp out of range for platform time_t
>>> data = plistlib.dumps(datetime.datetime(2039, 1, 1), fmt=plistlib.FMT_BINARY)
>>> plistlib.loads(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 1006, in loads
    fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 997, in load
    return p.parse(fp)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 623, in parse
    return self._read_object(self._object_offsets[top_object])
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 688, in _read_object                                                                                                                    
    return datetime.datetime.utcfromtimestamp(f + (31 * 365 + 8) * 86400)                                                                                                                      
OverflowError: timestamp out of range for platform time_t

Proposed patch fixes this issue.
History
Date User Action Args
2016-04-07 09:46:22serhiy.storchakasetrecipients: + serhiy.storchaka, ronaldoussoren, belopolsky
2016-04-07 09:46:22serhiy.storchakasetmessageid: <1460022382.4.0.161874143104.issue26709@psf.upfronthosting.co.za>
2016-04-07 09:46:22serhiy.storchakalinkissue26709 messages
2016-04-07 09:46:21serhiy.storchakacreate