Skip to content

Commit 4195b5c

Browse files
author
Victor Stinner
committed
Backout f8409b3d6449: the PEP 410 is not accepted yet
1 parent 72476ea commit 4195b5c

9 files changed

Lines changed: 174 additions & 814 deletions

File tree

‎Doc/library/os.rst‎

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -808,16 +808,13 @@ as internal buffering of data.
808808
Availability: Unix.
809809

810810

811-
.. function:: fstat(fd, timestamp=None)
811+
.. function:: fstat(fd)
812812

813813
Return status for file descriptor *fd*, like :func:`~os.stat`.
814814

815815
Availability: Unix, Windows.
816816

817-
.. versionchanged:: 3.3
818-
Added the *timestamp* argument.
819-
820-
.. function:: fstatat(dirfd, path, flags=0, timestamp="float")
817+
.. function:: fstatat(dirfd, path, flags=0)
821818

822819
Like :func:`stat` but if *path* is relative, it is taken as relative to *dirfd*.
823820
*flags* is optional and may be 0 or :data:`AT_SYMLINK_NOFOLLOW`.
@@ -1699,7 +1696,7 @@ Files and Directories
16991696
.. versionadded:: 3.3
17001697

17011698

1702-
.. function:: lstat(path, timestamp=None)
1699+
.. function:: lstat(path)
17031700

17041701
Perform the equivalent of an :c:func:`lstat` system call on the given path.
17051702
Similar to :func:`~os.stat`, but does not follow symbolic links. On
@@ -1709,9 +1706,6 @@ Files and Directories
17091706
.. versionchanged:: 3.2
17101707
Added support for Windows 6.0 (Vista) symbolic links.
17111708

1712-
.. versionchanged:: 3.3
1713-
The *timestamp* argument was added.
1714-
17151709

17161710
.. function:: lutimes(path[, times])
17171711

@@ -1975,7 +1969,7 @@ Files and Directories
19751969
.. versionadded:: 3.3
19761970

19771971

1978-
.. function:: stat(path, timestamp=None)
1972+
.. function:: stat(path)
19791973

19801974
Perform the equivalent of a :c:func:`stat` system call on the given path.
19811975
(This function follows symlinks; to stat a symlink use :func:`lstat`.)
@@ -1995,11 +1989,6 @@ Files and Directories
19951989
* :attr:`st_ctime` - platform dependent; time of most recent metadata change on
19961990
Unix, or the time of creation on Windows)
19971991

1998-
:attr:`st_atime`, :attr:`st_mtime` and :attr:`st_ctime` are :class:`float`
1999-
by default, or :class:`int` if :func:`os.stat_float_times` is ``False``. Set
2000-
the *timestamp* argument to get another :ref:`timestamp type
2001-
<timestamp-types>`.
2002-
20031992
On some Unix systems (such as Linux), the following attributes may also be
20041993
available:
20051994

@@ -2055,9 +2044,6 @@ Files and Directories
20552044

20562045
Availability: Unix, Windows.
20572046

2058-
.. versionchanged:: 3.3
2059-
Added the *timestamp* argument.
2060-
20612047

20622048
.. function:: stat_float_times([newvalue])
20632049

@@ -2083,9 +2069,6 @@ Files and Directories
20832069
are processed, this application should turn the feature off until the library
20842070
has been corrected.
20852071

2086-
.. deprecated:: 3.3
2087-
Use *timestamp* argument of stat functions instead.
2088-
20892072

20902073
.. function:: statvfs(path)
20912074

@@ -2876,39 +2859,27 @@ written in Python, such as a mail server's external command delivery program.
28762859
with :const:`P_NOWAIT` return suitable process handles.
28772860

28782861

2879-
.. function:: wait3(options[, timestamp=float])
2862+
.. function:: wait3([options])
28802863

28812864
Similar to :func:`waitpid`, except no process id argument is given and a
28822865
3-element tuple containing the child's process id, exit status indication, and
28832866
resource usage information is returned. Refer to :mod:`resource`.\
28842867
:func:`getrusage` for details on resource usage information. The option
28852868
argument is the same as that provided to :func:`waitpid` and :func:`wait4`.
2886-
:attr:`ru_utime` and :attr:`ru_stime` attributes of the resource usage are
2887-
:class:`float` by default, set the *timestamp* argument to get another
2888-
:ref:`timestamp type <timestamp-types>`.
28892869

28902870
Availability: Unix.
28912871

2892-
.. versionchanged:: 3.3
2893-
Added the *timestamp* argument.
2894-
28952872

2896-
.. function:: wait4(pid, options[, timestamp=float])
2873+
.. function:: wait4(pid, options)
28972874

28982875
Similar to :func:`waitpid`, except a 3-element tuple, containing the child's
28992876
process id, exit status indication, and resource usage information is returned.
29002877
Refer to :mod:`resource`.\ :func:`getrusage` for details on resource usage
29012878
information. The arguments to :func:`wait4` are the same as those provided to
29022879
:func:`waitpid`.
2903-
:attr:`ru_utime` and :attr:`ru_stime` attributes of the resource usage are
2904-
:class:`float` by default, set the *timestamp* argument to get another
2905-
:ref:`timestamp type <timestamp-types>`.
29062880

29072881
Availability: Unix.
29082882

2909-
.. versionchanged:: 3.3
2910-
Added the *timestamp* argument.
2911-
29122883

29132884
.. data:: WNOHANG
29142885

‎Doc/library/time.rst‎

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ An explanation of some terminology and conventions is in order.
9595
| local time | | |
9696
+-------------------------+-------------------------+-------------------------+
9797

98-
.. _timestamp-types:
99-
100-
* Python supports the following timestamp types:
101-
102-
* :class:`int`
103-
* :class:`float`
104-
* :class:`decimal.Decimal`
105-
10698

10799
The module defines the following functions and data items:
108100

@@ -127,7 +119,7 @@ The module defines the following functions and data items:
127119
trailing newline.
128120

129121

130-
.. function:: clock(timestamp=float)
122+
.. function:: clock()
131123

132124
.. index::
133125
single: CPU time
@@ -144,27 +136,16 @@ The module defines the following functions and data items:
144136
:c:func:`QueryPerformanceCounter`. The resolution is typically better than one
145137
microsecond.
146138

147-
Return as a floating point number by default, set the *timestamp* argument
148-
to get another :ref:`timestamp type <timestamp-types>`.
149-
150-
.. versionchanged:: 3.3
151-
Added the *timestamp* argument.
152-
153139

154-
.. function:: clock_getres(clk_id, timestamp=float)
140+
.. function:: clock_getres(clk_id)
155141

156142
Return the resolution (precision) of the specified clock *clk_id*.
157-
Return a floating point number by default, set the *timestamp* argument to
158-
get another :ref:`timestamp type <timestamp-types>`.
159-
160143

161144
.. versionadded:: 3.3
162145

163-
.. function:: clock_gettime(clk_id, timestamp=float)
146+
.. function:: clock_gettime(clk_id)
164147

165148
Return the time of the specified clock *clk_id*.
166-
Return a floating point number by default, set the *timestamp* argument to
167-
get another :ref:`timestamp type <timestamp-types>`.
168149

169150
.. versionadded:: 3.3
170151

@@ -233,22 +214,19 @@ The module defines the following functions and data items:
233214
flag is set to ``1`` when DST applies to the given time.
234215

235216

236-
.. function:: mktime(t, timestamp=float)
217+
.. function:: mktime(t)
237218

238219
This is the inverse function of :func:`localtime`. Its argument is the
239220
:class:`struct_time` or full 9-tuple (since the dst flag is needed; use ``-1``
240221
as the dst flag if it is unknown) which expresses the time in *local* time, not
241-
It returns a floating point number by default, for compatibility with
242-
:func:`time`, set the *timestamp* argument to get another :ref:`timestamp
243-
type <timestamp-types>`.
244-
222+
UTC. It returns a floating point number, for compatibility with :func:`time`.
245223
If the input value cannot be represented as a valid time, either
246224
:exc:`OverflowError` or :exc:`ValueError` will be raised (which depends on
247225
whether the invalid value is caught by Python or the underlying C libraries).
248226
The earliest date for which it can generate a time is platform-dependent.
249227

250228

251-
.. function:: monotonic(timestamp=float)
229+
.. function:: monotonic()
252230

253231
Monotonic clock. The reference point of the returned value is undefined so
254232
only the difference of consecutive calls is valid.
@@ -462,20 +440,15 @@ The module defines the following functions and data items:
462440
:exc:`TypeError` is raised.
463441

464442

465-
.. function:: time(timestamp=float)
443+
.. function:: time()
466444

467-
Return the time expressed in seconds since the epoch in UTC. Return a
468-
floating point number by default, set the *timestamp* argument to get
469-
another :ref:`timestamp type <timestamp-types>`.
470-
Note that even though the time is always returned as a floating point
445+
Return the time as a floating point number expressed in seconds since the epoch,
446+
in UTC. Note that even though the time is always returned as a floating point
471447
number, not all systems provide time with a better precision than 1 second.
472448
While this function normally returns non-decreasing values, it can return a
473449
lower value than a previous call if the system clock has been set back between
474450
the two calls.
475451

476-
.. versionchanged:: 3.3
477-
Added the *timestamp* argument.
478-
479452

480453
.. data:: timezone
481454

@@ -573,16 +546,13 @@ The module defines the following functions and data items:
573546
('EET', 'EEST')
574547

575548

576-
.. function:: wallclock(timestamp=float)
549+
.. function:: wallclock()
577550

578551
.. index::
579552
single: Wallclock
580553
single: benchmarking
581554

582555
Return the current time in fractions of a second to the system's best ability.
583-
Return a floating point number by default, set the *timestamp* argument to
584-
get another :ref:`timestamp type <timestamp-types>`.
585-
586556
Use this when the most accurate representation of wall-clock is required, i.e.
587557
when "processor time" is inappropriate. The reference point of the returned
588558
value is undefined so only the difference of consecutive calls is valid.

‎Doc/whatsnew/3.3.rst‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -270,42 +270,6 @@ new, more precise information::
270270
'<function C.D.meth at 0x7f46b9fe31e0>'
271271

272272

273-
PEP 410: Use decimal.Decimal type for timestamps
274-
================================================
275-
276-
:pep:`410` - Use decimal.Decimal type for timestamps
277-
PEP written and implemented by Victor Stinner.
278-
279-
The following functions have a new optional *timestamp* argument to get a
280-
timestamp as a :class:`decimal.Decimal` instead of :class:`int` or
281-
:class:`float`:
282-
283-
* :mod:`time` module: :func:`~time.clock`, :func:`~time.clock_gettime`,
284-
:func:`~time.clock_getres`, :func:`~time.monotonic`, :func:`~time.time` and
285-
:func:`~time.wallclock`
286-
* :mod:`os` module: :func:`~os.fstat`, :func:`~os.fstatat`, :func:`~os.lstat`
287-
and :func:`~os.stat` (``st_atime``, ``st_ctime`` and ``st_mtime`` fields of
288-
the stat structure)
289-
290-
:class:`decimal.Decimal` supports a resolution of a nanosecond (10^-9)
291-
resolution, whereas :class:`float` has only a resolution of a microsecond
292-
(10^-6) in common cases. See the list of available :ref:`timestamp types
293-
<timestamp-types>`.
294-
295-
Example::
296-
297-
>>> import decimal, time
298-
>>> time.time()
299-
1328006975.681211
300-
>>> time.time(timestamp=int)
301-
1328006979
302-
>>> time.time(timestamp=decimal.Decimal)
303-
Decimal('1328006983.761119')
304-
305-
:func:`os.stat_float_times` has been deprecated, use *timestamp* argument of
306-
`os.stat` instead.
307-
308-
309273
Other Language Changes
310274
======================
311275

‎Include/pytime.h‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#ifndef Py_PYTIME_H
33
#define Py_PYTIME_H
44

5-
#include "pyport.h"
6-
#include "object.h"
5+
#include "pyconfig.h" /* include for defines */
76

87
/**************************************************************************
98
Symbols and macros to supply platform-independent interfaces to time related
@@ -38,31 +37,6 @@ do { \
3837
((tv_end.tv_sec - tv_start.tv_sec) + \
3938
(tv_end.tv_usec - tv_start.tv_usec) * 0.000001)
4039

41-
#if defined(HAVE_LONG_LONG)
42-
typedef unsigned PY_LONG_LONG _PyTime_fraction_t;
43-
#else
44-
typedef size_t _PyTime_fraction_t;
45-
#endif
46-
47-
typedef struct
48-
{
49-
/* timestamp = seconds + numerator / denominator */
50-
time_t seconds;
51-
_PyTime_fraction_t numerator;
52-
/* denominator cannot be zero */
53-
_PyTime_fraction_t denominator;
54-
/* the timestamp resolution is 1/divisor */
55-
} _PyTime_t;
56-
57-
/* Similar to POSIX gettimeofday. If system gettimeofday
58-
fails or is not available, fall back to lower resolution clocks. */
59-
PyAPI_FUNC(void) _PyTime_get(_PyTime_t *tp);
60-
61-
/* Convert a timestamp structure to the specified timestamp type.
62-
63-
Raise a ValueError if the timestamp type is unknown. */
64-
PyAPI_FUNC(PyObject*) _PyTime_Convert(_PyTime_t *ts, PyObject *timestamp);
65-
6640
/* Dummy to force linking. */
6741
PyAPI_FUNC(void) _PyTime_Init(void);
6842

‎Lib/test/test_os.py‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# does add tests for a few functions which have been determined to be more
33
# portable than they had been thought to be.
44

5-
import decimal
65
import os
76
import errno
87
import unittest
@@ -239,36 +238,6 @@ def test_stat_attributes_bytes(self):
239238
warnings.simplefilter("ignore", DeprecationWarning)
240239
self.check_stat_attributes(fname)
241240

242-
def test_stat_timestamp(self):
243-
# test deprecation
244-
with warnings.catch_warnings():
245-
warnings.simplefilter("error", DeprecationWarning)
246-
self.assertRaises(DeprecationWarning, os.stat_float_times, False)
247-
248-
with warnings.catch_warnings():
249-
warnings.simplefilter("ignore", DeprecationWarning)
250-
old_value = os.stat_float_times()
251-
try:
252-
# test invalid timestamp types
253-
self.assertRaises(ValueError, os.stat, self.fname,
254-
timestamp="abc")
255-
self.assertRaises(ValueError, os.stat, self.fname,
256-
timestamp=decimal.Context)
257-
258-
for float_times in (False, True):
259-
os.stat_float_times(float_times)
260-
t = os.stat(self.fname).st_mtime
261-
if float_times:
262-
self.assertIsInstance(t, float)
263-
else:
264-
self.assertIsInstance(t, int)
265-
266-
for type in (int, float, decimal.Decimal):
267-
t = os.stat(self.fname, timestamp=type).st_mtime
268-
self.assertIsInstance(t, type)
269-
finally:
270-
os.stat_float_times(old_value)
271-
272241
def test_statvfs_attributes(self):
273242
if not hasattr(os, "statvfs"):
274243
return

0 commit comments

Comments
 (0)