homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: floattime() should not raise an exception
Type: Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, vstinner
Priority: normal Keywords: patch

Created on 2012年03月19日 12:28 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
floattime.patch vstinner, 2012年03月19日 12:28 review
Messages (2)
msg156334 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012年03月19日 12:28
floattime() raises an OSError if _PyTime_gettimeofday() returns secs=0 and usec=0. This is wrong because _PyTime_gettimeofday() cannot fail and secs=0 is valid if the current time is 0 (1970年1月1日 at 12:00 UTC). Extract of _PyTime_gettimeofday() "doc":
/* Similar to POSIX gettimeofday but cannot fail. If system gettimeofday
 * fails or is not available, fall back to lower resolution clocks.
 */
PyAPI_FUNC(void) _PyTime_gettimeofday(_PyTime_timeval *tp);
In practice, I suppose that nobody noticed the bug because we are in 2012, not in 1969 :-) And even if you change your system clock to 19691131, you may not be able to reproduce the bug because you have to call gettimeofday() exactly at midnight to get also usec=0 ...
Attached patch removes the exception.
msg156863 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012年03月26日 20:08
New changeset 206c45f45236 by Victor Stinner in branch 'default':
Issue #14368: _PyTime_gettimeofday() cannot fail
http://hg.python.org/cpython/rev/206c45f45236 
History
Date User Action Args
2022年04月11日 14:57:28adminsetgithub: 58576
2012年03月26日 20:08:55vstinnersetstatus: open -> closed
resolution: fixed
2012年03月26日 20:08:42python-devsetnosy: + python-dev
messages: + msg156863
2012年03月19日 12:28:49vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /