Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f1464f4d
Commit
f1464f4d
authored
Apr 15, 2019
by
pxinwr
Committed by
Victor Stinner
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31904: Port the time module on VxWorks (GH-12305)
time.clock() is not available on VxWorks.
parent
236d0b75
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
5 deletions
+15
-5
Doc/library/time.rst
Doc/library/time.rst
+2
-0
Lib/test/test_time.py
Lib/test/test_time.py
+5
-1
Misc/NEWS.d/next/Library/2019-03-13-16-48-42.bpo-31904.9sjd38.rst
...S.d/next/Library/2019-03-13-16-48-42.bpo-31904.9sjd38.rst
+1
-0
Modules/timemodule.c
Modules/timemodule.c
+7
-4
No files found.
Doc/library/time.rst
View file @
f1464f4d
...
...
@@ -153,6 +153,8 @@ Functions
:c:func:`QueryPerformanceCounter`. The resolution is typically better than one
microsecond.
.. availability:: Windows, Unix. Not available on VxWorks.
.. deprecated:: 3.3
The behaviour of this function depends on the platform: use
:func:`perf_counter` or :func:`process_time` instead, depending on your
...
...
Lib/test/test_time.py
View file @
f1464f4d
...
...
@@ -88,6 +88,8 @@ class TimeTestCase(unittest.TestCase):
check_ns
(
time
.
clock_gettime
(
time
.
CLOCK_REALTIME
),
time
.
clock_gettime_ns
(
time
.
CLOCK_REALTIME
))
@
unittest
.
skipUnless
(
hasattr
(
time
,
'clock'
),
'need time.clock()'
)
def
test_clock
(
self
):
with
self
.
assertWarns
(
DeprecationWarning
):
time
.
clock
()
...
...
@@ -549,7 +551,9 @@ class TimeTestCase(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
time
.
ctime
,
float
(
"nan"
))
def
test_get_clock_info
(
self
):
clocks
=
[
'clock'
,
'monotonic'
,
'perf_counter'
,
'process_time'
,
'time'
]
clocks
=
[
'monotonic'
,
'perf_counter'
,
'process_time'
,
'time'
]
if
hasattr
(
time
,
'clock'
):
clocks
.
append
(
'clock'
)
for
name
in
clocks
:
if
name
==
'clock'
:
...
...
Misc/NEWS.d/next/Library/2019-03-13-16-48-42.bpo-31904.9sjd38.rst
0 → 100644
View file @
f1464f4d
Add time module support and fix test_time faiures for VxWorks.
Modules/timemodule.c
View file @
f1464f4d
...
...
@@ -145,7 +145,7 @@ perf_counter(_Py_clock_info_t *info)
return
_PyFloat_FromPyTime
(
t
);
}
#if
defined(MS_WINDOWS) || defined(HAVE_CLOCK
)
#if
(defined(MS_WINDOWS) || defined(HAVE_CLOCK)) && !defined(__VXWORKS__
)
#define PYCLOCK
static
PyObject
*
pyclock
(
_Py_clock_info_t
*
info
)
...
...
@@ -765,7 +765,7 @@ time_strftime(PyObject *self, PyObject *args)
return
NULL
;
}
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX)
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX)
|| defined(__VXWORKS__)
if
(
buf
.
tm_year
+
1900
<
1
||
9999
<
buf
.
tm_year
+
1900
)
{
PyErr_SetString
(
PyExc_ValueError
,
"strftime() requires year in [1; 9999]"
);
...
...
@@ -1001,18 +1001,21 @@ time_mktime(PyObject *self, PyObject *tm_tuple)
return
NULL
;
}
#if
def _AIX
#if
defined(_AIX) || (defined(__VXWORKS__) && !defined(_WRS_CONFIG_LP64))
/* bpo-19748: AIX mktime() valid range is 00:00:00 UTC, January 1, 1970
to 03:14:07 UTC, January 19, 2038. Thanks to the workaround below,
it is possible to support years in range [1902; 2037] */
if
(
tm
.
tm_year
<
2
||
tm
.
tm_year
>
137
)
{
/* bpo-19748: On AIX, mktime() does not report overflow error
for timestamp < -2^31 or timestamp > 2**31-1. */
for timestamp < -2^31 or timestamp > 2**31-1. VxWorks has the
same issue when working in 32 bit mode. */
PyErr_SetString
(
PyExc_OverflowError
,
"mktime argument out of range"
);
return
NULL
;
}
#endif
#ifdef _AIX
/* bpo-34373: AIX mktime() has an integer overflow for years in range
[1902; 1969]. Workaround the issue by using a year greater or equal than
1970 (tm_year >= 70): mktime() behaves correctly in that case
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment