GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-67795: Accept any real numbers as timestamp and timeout by serhiy-storchaka · Pull Request #139224 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 22, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Functions that take timestamp or timeout arguments now accept any real numbers, not only integers or floats, although this does not improve precision.

  • Issue: Inconsistency in datetime.utcfromtimestamp(Decimal) #67795

📚 Documentation preview 📚: https://cpython-previews--139224.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

edgarrmondragon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@serhiy-storchaka
pythongh-67795: Accept any real numbers as timestamp and timeout
b77edfd
Functions that take timestamp or timeout arguments now accept any
real numbers, not only integers or floats, although this does not
improve precision.
@serhiy-storchaka
serhiy-storchaka requested a review from vstinner September 22, 2025 09:13
@serhiy-storchaka
serhiy-storchaka requested review from AA-Turner, abalkin and pganssle as code owners September 22, 2025 09:13
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 22, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Sep 22, 2025
Inconsistency in datetime.utcfromtimestamp(Decimal) #67795
Open
@vstinner

vstinner commented Sep 22, 2025

Copy link
Copy Markdown
Member

Nice, it works as expected:

$ ./python
>>> import socket, fractions, decimal

>>> socket.setdefaulttimeout(fractions.Fraction(1, 5))
>>> socket.getdefaulttimeout()
0.2

>>> socket.setdefaulttimeout(decimal.Decimal('1.5'))
>>> socket.getdefaulttimeout()
1.5
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner approved these changes Sep 22, 2025
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You may just mention Decimal and Fraction in the global NEWS entry.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/whatsnew/3.15.rst Outdated

* Functions that take timestamp or timeout arguments now accept any
real numbers, not only integers or floats, although this does not
improve precision.

@vstinner vstinner Sep 22, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may give Decimal and Fraction as examples.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Sep 22, 2025
serhiy-storchaka added 2 commits September 22, 2025 15:35
@serhiy-storchaka
Add more tests.
fa9847b
@serhiy-storchaka
Explicitly mention Decimal and Fraction.
fff31e6
@serhiy-storchaka
serhiy-storchaka merged commit 1a2e00c into python:main Sep 23, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 23, 2025
@serhiy-storchaka
serhiy-storchaka deleted the timestamp-timeout-non-float branch September 23, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@abalkin abalkin Awaiting requested review from abalkin
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@serhiy-storchaka @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.