Skip to content

python 3.8.2: datetime.datetime(1969,1,1).timestamp() yields OSError #85169

Closed

Description

@EddieParker
BPO 40997
Nosy @abalkin, @pganssle
Superseder
  • bpo-37527: Timestamp conversion on windows fails with timestamps close to EPOCH
  • 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 2020-06-17.19:13:55.457>
    created_at = <Date 2020-06-17.06:33:01.117>
    labels = ['3.8', 'type-bug', 'library']
    title = 'python 3.8.2: datetime.datetime(1969,1,1).timestamp() yields OSError'
    updated_at = <Date 2020-06-17.19:13:55.449>
    user = 'https://bugs.python.org/EddieParker'

    bugs.python.org fields:

    activity = <Date 2020-06-17.19:13:55.449>
    actor = 'SilentGhost'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-17.19:13:55.457>
    closer = 'SilentGhost'
    components = ['Library (Lib)']
    creation = <Date 2020-06-17.06:33:01.117>
    creator = 'Eddie Parker'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40997
    keywords = []
    message_count = 2.0
    messages = ['371710', '371771']
    nosy_count = 4.0
    nosy_names = ['belopolsky', 'SilentGhost', 'p-ganssle', 'Eddie Parker']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '37527'
    type = 'behavior'
    url = 'https://bugs.python.org/issue40997'
    versions = ['Python 3.8']

    Activity

    1. EddieParker commented on Jun 17, 2020

      EddieParkermannequin
      MannequinAuthor

      Running the following yields an unexpected OSError: Invalid argument:

      Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import datetime
      >>> datetime.datetime(1000,1,1).timestamp()
      >>> datetime.datetime(1969,1,1).timestamp()
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      OSError: [Errno 22] Invalid argument

      I understand that the time can't yield a valid timestamp, but the exception doesn't really explain that and the documentation doesn't mention OSError as an exception to indicate an invalid date is specified.

      Ideally a better exception could be used (ValueError?) or the documentation could mention this possibility? Or even better, allow timestamp() to take a parameter for what to return in the case of an invalid timestamp (None?)

      I mention this because I hit this in some asyncio code which was a nuisance to debug and finding it excepting on a timestamp that had worked before with an OS error baffled me until I got it in a debugger.

      Thanks as always!

    2. added
      3.8 (EOL)
      stdlib
      type-bug
      on Jun 17, 2020
    3. SilentGhost commented on Jun 17, 2020

      SilentGhostmannequin
      Mannequin

      This looks like a duplicate of bpo-37527.

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)stdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions