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
01b5aab7
Commit
01b5aab7
authored
Oct 24, 2017
by
Victor Stinner
Committed by
GitHub
Oct 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31827: Remove os.stat_float_times() (GH-4061)
parent
87d332dc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
99 deletions
+13
-99
Doc/library/os.path.rst
Doc/library/os.path.rst
+2
-8
Doc/library/os.rst
Doc/library/os.rst
+0
-29
Doc/whatsnew/3.7.rst
Doc/whatsnew/3.7.rst
+4
-0
Lib/test/test_os.py
Lib/test/test_os.py
+0
-17
Misc/NEWS.d/next/Library/2017-10-20-16-12-01.bpo-31827.7R8s8s.rst
...S.d/next/Library/2017-10-20-16-12-01.bpo-31827.7R8s8s.rst
+3
-0
Modules/posixmodule.c
Modules/posixmodule.c
+4
-44
Tools/c-globals/ignored-globals.txt
Tools/c-globals/ignored-globals.txt
+0
-1
No files found.
Doc/library/os.path.rst
View file @
01b5aab7
...
...
@@ -192,23 +192,17 @@ the :mod:`glob` module.)
.. 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`.
...
...
Doc/library/os.rst
View file @
01b5aab7
...
...
@@ -2335,8 +2335,6 @@ features:
* 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`,
...
...
@@ -2431,33 +2429,6 @@ features:
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
...
...
Doc/whatsnew/3.7.rst
View file @
01b5aab7
...
...
@@ -507,6 +507,10 @@ Removed
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.
...
...
Lib/test/test_os.py
View file @
01b5aab7
...
...
@@ -81,12 +81,6 @@ else:
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
)
...
...
@@ -488,17 +482,6 @@ class UtimeTests(unittest.TestCase):
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
...
...
Misc/NEWS.d/next/Library/2017-10-20-16-12-01.bpo-31827.7R8s8s.rst
0 → 100644
View file @
01b5aab7
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.
Modules/posixmodule.c
View file @
01b5aab7
...
...
@@ -1934,36 +1934,6 @@ statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
/* 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
...
...
@@ -1986,14 +1956,9 @@ fill_time(PyObject *v, int index, time_t sec, unsigned long nsec)
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
);
...
...
@@ -2084,11 +2049,7 @@ _pystat_fromstructstat(STRUCT_STAT *st)
#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
);
}
...
...
@@ -12452,7 +12413,6 @@ static PyMethodDef posix_methods[] = {
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
...
...
Tools/c-globals/ignored-globals.txt
View file @
01b5aab7
...
...
@@ -122,7 +122,6 @@ user_signals
posix_constants_confstr
posix_constants_pathconf
posix_constants_sysconf
_stat_float_times # deprecated, __main__-only
structseq_new
ticks_per_second
...
...
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