Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 676
    • Issues 676
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

April 05-07 - Mercurial Paris Conference 2023 - One day of workshop dedicated to Heptapod and Mercurial usage and workflow. There are still places available for both workshops and talks!

  • PyPyPyPy
  • pypypypy
  • Issues
  • #3324
Closed
Open
Issue created Oct 08, 2020 by scaramallion@scaramallion

Issue pickling datetime.time subclass

I've run across an issue pickling datetime.time subclasses:

import datetime
import pickle

class TimeFoo(datetime.time): pass
class DateFoo(datetime.date): pass

if __name__ == "__main__":
    t = DateFoo(2001, 2, 3) 
    d = pickle.dumps(t)  # OK
    print(d)
    # b'\x80\x03c__main__\nDateFoo\nq\x00C\x04\x07\xd1\x02\x03q\x01\x85q\x02Rq\x03.'
    t = pickle.loads(d)

    t = TimeFoo(1, 2, 3)
    d = pickle.dumps(t)  # :(
    print(d)
    # b'\x80\x03cdatetime\ntime\nq\x00C\x06\x01\x02\x03\x00\x00\x00q\x01\x85q\x02Rq\x03.'
    t = pickle.loads(d)

The class info in the pickle dump should be __main__\nTimeFoo. Issue arises because datetime.time.__reduce_ex__() returns (time, ...) rather than (self.__class__, ...) on (I assume) this line.

Edited Oct 08, 2020 by scaramallion
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking