Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

date.fromtimestamp(None) behaves differently between_pydatetime and_datetime #120268

Closed
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@Eclips4

Description

@Eclips4

Bug report

Bug description:

./pythonPython3.14.0a0 (heads/main-dirty:55402d3232,Jun82024,11:03:56) [GCC13.2.0]onlinuxType"help","copyright","credits"or"license"formoreinformation.>>>import_datetime>>>_datetime.date.fromtimestamp(None)Traceback (mostrecentcalllast):File"<python-input-1>",line1,in<module>_datetime.date.fromtimestamp(None)~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^TypeError:'NoneType'objectcannotbeinterpretedasaninteger>>>import_pydatetime>>>_pydatetime.date.fromtimestamp(None)datetime.date(2024,6,8)>>>

This happens because the_pydatetime.date.fromtimestamp is usingtime.localtime which is acceptsNone as a valid argument while_datetime.date.fromtimestamp is trying to convertNone to an integer.
I would prefer to change the Python implementation, as the documentaion fordatetime.date.fromtimestamp doesn't mention that it can acceptNone as a valid argument.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp