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.

Unsupported provider

classification
Title: Catch time(), ftime(), localtime() and clock() errors
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2012-01-24 01:06 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
time_error.patch vstinner, 2012-01-24 01:06 review
Messages (9)
msg151871 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-01-24 01:06
Attach patch catchs errors on time(), ftime(), localtime() and clock(). It changes floattime() and _Py_gettimeofday() signature: result now indicates if an error occurred or not, and these function now directly raise an exception.

Catching time() error is maybe overflow: modern version of its manual page don't mention errors.
msg152044 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-26 23:08
New changeset 9ee4a104e33d by Victor Stinner in branch 'default':
Issue #13847: time.localtime() and time.gmtime() now raise an OSError instead
http://hg.python.org/cpython/rev/9ee4a104e33d
msg152049 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-26 23:39
New changeset 94b7eb09d0b3 by Victor Stinner in branch 'default':
Issue #13847: time.clock() now raises a RuntimeError if the processor time used
http://hg.python.org/cpython/rev/94b7eb09d0b3
msg152052 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-01-26 23:44
I added tests on localtime() and clock().

I read more carefully time(), ftime() and gettimeofday() manpage: it is not possible that they fail if the argument is an invalid pointer, the current code is correct.

I don't want to backport changes because they are incompatible.

--

There is a failure on FreeBSD 8.2:


======================================================================
FAIL: test_localtime_failure (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/buildarea/3.x.krah-freebsd/build/Lib/test/test_time.py", line 358, in test_localtime_failure
    self.assertRaises(OSError, time.localtime, invalid_time_t)
AssertionError: OSError not raised by localtime

http://www.python.org/dev/buildbot/all/builders/AMD64%20FreeBSD%208.2%203.x/builds/1746/steps/test/logs/stdio

test_localtime_failure() should be removed or at least skipped on FreeBSD, except if someone knows another invalid time_t value on this platform.
msg152053 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-26 23:50
New changeset 516d42a6e518 by Victor Stinner in branch 'default':
Issue #13847: Fix test_mktime(), time.localtime() now raises OSError
http://hg.python.org/cpython/rev/516d42a6e518
msg152055 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-27 00:03
New changeset 856f0864437a by Victor Stinner in branch 'default':
Issue #13847: Make test_localtime_failure() more robust
http://hg.python.org/cpython/rev/856f0864437a
msg152056 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-01-27 00:04
The issue should be done with the last commit.
msg152064 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-01-27 05:31
There is still an error on Windows:

======================================================================
FAIL: test_localtime_failure (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Buildslave\3.x.moore-windows\build\lib\test\test_time.py", line 364, in test_localtime_failure
    self.assertRaises(OSError, time.gmtime, invalid_time_t)
AssertionError: OSError not raised by gmtime

http://www.python.org/dev/buildbot/all/builders/x86%20XP-5%203.x/builds/4074/steps/test/logs/stdio

time.ctime() uses localtime() internally, whereas time.gmtime() doesn't. Another time should maybe be written (to test a different time_t value). Or remove completly the whole test because it is not reliable :-)
msg152283 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-29 23:23
New changeset 5b42aefb8969 by Victor Stinner in branch 'default':
Issue #13847: Fix test_time, time.gmtime() doesn't use localtime()
http://hg.python.org/cpython/rev/5b42aefb8969
History
Date User Action Args
2022-04-11 14:57:26adminsetgithub: 58055
2012-01-31 22:38:15vstinnersetstatus: open -> closed
resolution: fixed
2012-01-29 23:23:33python-devsetmessages: + msg152283
2012-01-27 23:18:02terry.reedysettype: enhancement
stage: needs patch
2012-01-27 05:31:48vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg152064
2012-01-27 00:04:15vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg152056
2012-01-27 00:03:32python-devsetmessages: + msg152055
2012-01-26 23:50:33python-devsetmessages: + msg152053
2012-01-26 23:44:16vstinnersetmessages: + msg152052
2012-01-26 23:39:23python-devsetmessages: + msg152049
2012-01-26 23:08:51python-devsetnosy: + python-dev
messages: + msg152044
2012-01-24 01:06:28vstinnercreate