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

Created on 2019-06-22 16:15 by Justin Blanchard, last changed 2019-08-29 08:12 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14307 merged python-dev, 2019-06-22 16:42
PR 15583 merged miss-islington, 2019-08-29 07:36
PR 15584 merged miss-islington, 2019-08-29 07:37
Messages (5)
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!
msg350743 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-29 07:36
New changeset 122376df550b71dd3bec0513c7483cc1714212fa by Serhiy Storchaka (Justin Blanchard) in branch 'master':
bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307)
https://github.com/python/cpython/commit/122376df550b71dd3bec0513c7483cc1714212fa
msg350746 - (view) Author: miss-islington (miss-islington) Date: 2019-08-29 07:56
New changeset d1d42bf4a404f092fe90fe8984481c507a64ef0a by Miss Islington (bot) in branch '3.8':
bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307)
https://github.com/python/cpython/commit/d1d42bf4a404f092fe90fe8984481c507a64ef0a
msg350747 - (view) Author: miss-islington (miss-islington) Date: 2019-08-29 07:57
New changeset 6b50c10f675a9e8438024c5fcc592b0d38d8c62d by Miss Islington (bot) in branch '3.7':
bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307)
https://github.com/python/cpython/commit/6b50c10f675a9e8438024c5fcc592b0d38d8c62d
msg350751 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-29 08:12
Thank you for your contribution Justin!
History
Date User Action Args
2019-08-29 08:12:38serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg350751

stage: patch review -> resolved
2019-08-29 07:57:44miss-islingtonsetmessages: + msg350747
2019-08-29 07:56:09miss-islingtonsetnosy: + miss-islington
messages: + msg350746
2019-08-29 07:37:03miss-islingtonsetpull_requests: + pull_request15260
2019-08-29 07:36:54miss-islingtonsetpull_requests: + pull_request15259
2019-08-29 07:36:20serhiy.storchakasetmessages: + msg350743
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