Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime.time unpickling fails in case of python2 pickle with seconds>=24 #81553

Closed
UncombedCoconut mannequin opened this issue Jun 22, 2019 · 5 comments
Closed

datetime.time unpickling fails in case of python2 pickle with seconds>=24 #81553

UncombedCoconut mannequin opened this issue Jun 22, 2019 · 5 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@UncombedCoconut
Copy link
Mannequin

UncombedCoconut mannequin commented Jun 22, 2019

BPO 37372
Nosy @abalkin, @serhiy-storchaka, @pganssle, @miss-islington, @UncombedCoconut
PRs
  • bpo-37372: Fix unpickling certain datetime.time objects from Python 2 #14307
  • [3.8] bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307) #15583
  • [3.7] bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307) #15584
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-08-29.08:12:38.004>
    created_at = <Date 2019-06-22.16:15:13.660>
    labels = ['3.7', '3.8', 'type-bug', 'library', '3.9']
    title = 'datetime.time unpickling fails in case of python2 pickle with seconds>=24'
    updated_at = <Date 2019-08-29.08:12:38.003>
    user = 'https://github.com/UncombedCoconut'

    bugs.python.org fields:

    activity = <Date 2019-08-29.08:12:38.003>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-08-29.08:12:38.004>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2019-06-22.16:15:13.660>
    creator = 'Justin Blanchard'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37372
    keywords = ['patch']
    message_count = 5.0
    messages = ['346284', '350743', '350746', '350747', '350751']
    nosy_count = 5.0
    nosy_names = ['belopolsky', 'serhiy.storchaka', 'p-ganssle', 'miss-islington', 'Justin Blanchard']
    pr_nums = ['14307', '15583', '15584']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37372'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @UncombedCoconut
    Copy link
    Mannequin Author

    UncombedCoconut mannequin commented Jun 22, 2019

    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!

    @UncombedCoconut UncombedCoconut mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 22, 2019
    @serhiy-storchaka
    Copy link
    Member

    New changeset 122376d by Serhiy Storchaka (Justin Blanchard) in branch 'master':
    bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307)
    122376d

    @miss-islington
    Copy link
    Contributor

    New changeset d1d42bf by Miss Islington (bot) in branch '3.8':
    bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307)
    d1d42bf

    @miss-islington
    Copy link
    Contributor

    New changeset 6b50c10 by Miss Islington (bot) in branch '3.7':
    bpo-37372: Fix error unpickling datetime.time objects from Python 2 with seconds>=24. (GH-14307)
    6b50c10

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution Justin!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants