.. function:: getatime(path)
- Return the time of last access of *path*. The return value is a number giving
+ Return the time of last access of *path*. The return value is a floating point number giving
the number of seconds since the epoch (see the :mod:`time` module). Raise
:exc:`OSError` if the file does not exist or is inaccessible.
- If :func:`os.stat_float_times` returns ``True``, the result is a floating point
- number.
-
.. function:: getmtime(path)
- Return the time of last modification of *path*. The return value is a number
+ Return the time of last modification of *path*. The return value is a floating point number
giving the number of seconds since the epoch (see the :mod:`time` module).
Raise :exc:`OSError` if the file does not exist or is inaccessible.
- If :func:`os.stat_float_times` returns ``True``, the result is a floating point
- number.
-
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.
* the time of creation on Windows, expressed in nanoseconds as an
integer.
- See also the :func:`stat_float_times` function.
-
.. note::
The exact meaning and resolution of the :attr:`st_atime`,
Added the :attr:`st_file_attributes` member on Windows.
-.. function:: stat_float_times([newvalue])
-
- Determine whether :class:`stat_result` represents time stamps as float objects.
- If *newvalue* is ``True``, future calls to :func:`~os.stat` return floats, if it is
- ``False``, future calls return ints. If *newvalue* is omitted, return the
- current setting.
-
- For compatibility with older Python versions, accessing :class:`stat_result` as
- a tuple always returns integers.
-
- Python now returns float values by default. Applications which do not work
- correctly with floating point time stamps can use this function to restore the
- old behaviour.
-
- The resolution of the timestamps (that is the smallest possible fraction)
- depends on the system. Some systems only support second resolution; on these
- systems, the fraction will always be zero.
-
- It is recommended that this setting is only changed at program startup time in
- the *__main__* module; libraries should never change this setting. If an
- application uses a library that works incorrectly if floating point time stamps
- are processed, this application should turn the feature off until the library
- has been corrected.
-
- .. deprecated:: 3.3
-
-
.. function:: statvfs(path)
Perform a :c:func:`statvfs` system call on the given path. The return value is
API and Feature Removals
------------------------
+* The ``os.stat_float_times()`` function has been removed. It was introduced in
+ Python 2.3 for backward compatibility with Python 2.2, and was deprecated
+ since Python 3.1.
+
* Unknown escapes consisting of ``'\'`` and an ASCII letter in replacement
templates for :func:`re.sub` were deprecated in Python 3.5, and will now
cause an error.
HAVE_WHEEL_GROUP = sys.platform.startswith('freebsd') and os.getgid() == 0
-@contextlib.contextmanager
-def ignore_deprecation_warnings(msg_regex, quiet=False):
- with support.check_warnings((msg_regex, DeprecationWarning), quiet=quiet):
- yield
-
-
def requires_os_func(name):
return unittest.skipUnless(hasattr(os, name), 'requires os.%s' % name)
os.mkdir(self.dirname)
create_file(self.fname)
- def restore_float_times(state):
- with ignore_deprecation_warnings('stat_float_times'):
- os.stat_float_times(state)
-
- # ensure that st_atime and st_mtime are float
- with ignore_deprecation_warnings('stat_float_times'):
- old_float_times = os.stat_float_times(-1)
- self.addCleanup(restore_float_times, old_float_times)
-
- os.stat_float_times(True)
-
def support_subsecond(self, filename):
# Heuristic to check if the filesystem supports timestamp with
# subsecond resolution: check if float and int timestamps are different
--- /dev/null
+Remove the os.stat_float_times() function. It was introduced in Python 2.3
+for backward compatibility with Python 2.2, and was deprecated since Python
+3.1.
}
-
-/* If true, st_?time is float. */
-static int _stat_float_times = 1;
-
-PyDoc_STRVAR(stat_float_times__doc__,
-"stat_float_times([newval]) -> oldval\n\n\
-Determine whether os.[lf]stat represents time stamps as float objects.\n\
-\n\
-If value is True, future calls to stat() return floats; if it is False,\n\
-future calls return ints.\n\
-If value is omitted, return the current setting.\n");
-
-/* AC 3.5: the public default value should be None, not ready for that yet */
-static PyObject*
-stat_float_times(PyObject* self, PyObject *args)
-{
- int newval = -1;
- if (!PyArg_ParseTuple(args, "|i:stat_float_times", &newval))
- return NULL;
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "stat_float_times() is deprecated",
- 1))
- return NULL;
- if (newval == -1)
- /* Return old value */
- return PyBool_FromLong(_stat_float_times);
- _stat_float_times = newval;
- Py_RETURN_NONE;
-}
-
static PyObject *billion = NULL;
static void
if (!ns_total)
goto exit;
- if (_stat_float_times) {
- float_s = PyFloat_FromDouble(sec + 1e-9*nsec);
- if (!float_s)
- goto exit;
- }
- else {
- float_s = s;
- Py_INCREF(float_s);
+ float_s = PyFloat_FromDouble(sec + 1e-9*nsec);
+ if (!float_s) {
+ goto exit;
}
PyStructSequence_SET_ITEM(v, index, s);
#else
bnsec = 0;
#endif
- if (_stat_float_times) {
- val = PyFloat_FromDouble(bsec + 1e-9*bnsec);
- } else {
- val = PyLong_FromLong((long)bsec);
- }
+ val = PyFloat_FromDouble(bsec + 1e-9*bnsec);
PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX,
val);
}
OS_RENAME_METHODDEF
OS_REPLACE_METHODDEF
OS_RMDIR_METHODDEF
- {"stat_float_times", stat_float_times, METH_VARARGS, stat_float_times__doc__},
OS_SYMLINK_METHODDEF
OS_SYSTEM_METHODDEF
OS_UMASK_METHODDEF
posix_constants_confstr
posix_constants_pathconf
posix_constants_sysconf
-_stat_float_times # deprecated, __main__-only
structseq_new
ticks_per_second