classification
Title: datetime.time unpickling fails in case of python2 pickle with seconds>=24
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Justin Blanchard, belopolsky, p-ganssle, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-06-22 16:15 by Justin Blanchard, last changed 2019-06-22 17:53 by xtreak.

Pull Requests
URL Status Linked Edit
PR 14307 open python-dev, 2019-06-22 16:42
Messages (1)
msg346284 - (view) Author: Justin Blanchard (Justin Blanchard) * Date: 2019-06-22 16:15
Under bpo-22005, Python 3 gained support for unpickling datetime data from Python 2. (Thanks!) It turns out the input validation isn't quite right: it bombs on datetime.time when the encoded seconds (not hours) field is >=24:

python2>>> datetime.time(1, 2, 3).__reduce__()
(<type 'datetime.time'>, ('\x01\x02\x03\x00\x00\x00',))
python2>>> datetime.time(23, 24, 25).__reduce__()
(<type 'datetime.time'>, ('\x17\x18\x19\x00\x00\x00',))

python3>>> datetime.time('\x01\x02\x03\x00\x00\x00')
datetime.time(1, 2, 3)
python3>>> datetime.time('\x17\x18\x19\x00\x00\x00')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required (got type str)

I would like to contribute a fix and will be opening a PR. This is my first contribution - any help and patience appreciated!
History
Date User Action Args
2019-06-22 17:53:28xtreaksetnosy: + serhiy.storchaka
2019-06-22 16:51:31xtreaksetnosy: + belopolsky, p-ganssle

versions: - Python 3.6
2019-06-22 16:42:42python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14131
2019-06-22 16:15:13Justin Blanchardcreate