Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Doc/library/logging.handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ timed intervals.
rollover interval.

When computing the next rollover time for the first time (when the handler
is created), the last modification time of an existing log file, or else
is created), the creation time (if supported by the OS and file system)
or the last modification of an existing log file, or else
the current time, is used to compute when the next rotation will occur.

If the *utc* argument is true, times in UTC will be used; otherwise
Expand Down Expand Up @@ -449,6 +450,10 @@ timed intervals.
.. versionchanged:: 3.9
The *errors* parameter was added.

.. versionchanged:: next
Use the creation time instead of the last modification time, if supported by the OS and file system.


.. method:: doRollover()

Does a rollover, as described above.
Expand Down
78 changes: 71 additions & 7 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,20 @@ noted otherwise, all return values are floats.

**Trigonometric functions**
--------------------------------------------------------------------------------------------------
:func:`acos(x) <acos>` Arc cosine of *x*
:func:`asin(x) <asin>` Arc sine of *x*
:func:`atan(x) <atan>` Arc tangent of *x*
:func:`atan2(y, x) <atan2>` ``atan(y / x)``
:func:`cos(x) <cos>` Cosine of *x*
:func:`sin(x) <sin>` Sine of *x*
:func:`tan(x) <tan>` Tangent of *x*
:func:`acos(x) <acos>` Arc cosine of *x*, in radians
:func:`acospi(x) <acospi>` Arc cosine of *x*, in half-turns
:func:`asin(x) <asin>` Arc sine of *x*, in radians
:func:`asinpi(x) <asinpi>` Arc sine of *x*, in half-turns
:func:`atan(x) <atan>` Arc tangent of *x*, in radians
:func:`atanpi(x) <atanpi>` Arc tangent of *x*, in half-turns
:func:`atan2(y, x) <atan2>` ``atan(y / x)``, in radians
:func:`atan2pi(y, x) <atan2pi>` ``atan(y / x)``, in half-turns
:func:`cos(x) <cos>` Cosine of *x* radians
:func:`cospi(x) <cospi>` Cosine of *x⋅π* radians
:func:`sin(x) <sin>` Sine of *x* radians
:func:`sinpi(x) <sinpi>` Sine of *x⋅π* radians
:func:`tan(x) <tan>` Tangent of *x* radians
:func:`tanpi(x) <tanpi>` Tangent of *x⋅π* radians

**Hyperbolic functions**
--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -599,18 +606,42 @@ Trigonometric functions
``pi``.


.. function:: acospi(x)

Return the arc cosine of *x*, in half-turns. The result is between ``0`` and
``1``.

.. versionadded:: next


.. function:: asin(x)

Return the arc sine of *x*, in radians. The result is between ``-pi/2`` and
``pi/2``.


.. function:: asinpi(x)

Return the arc sine of *x*, in half-turns. The result is between ``-0.5`` and
``0.5``.

.. versionadded:: next


.. function:: atan(x)

Return the arc tangent of *x*, in radians. The result is between ``-pi/2`` and
``pi/2``.


.. function:: atanpi(x)

Return the arc tangent of *x*, in half-turns. The result is between ``-0.5`` and
``0.5``.

.. versionadded:: next


.. function:: atan2(y, x)

Return ``atan(y / x)``, in radians. The result is between ``-pi`` and ``pi``.
Expand All @@ -621,21 +652,54 @@ Trigonometric functions
-1)`` is ``-3*pi/4``.


.. function:: atan2pi(y, x)

Return ``atanpi(y / x)``, in half-turns. The result is between ``-1`` and ``1``.
The vector in the plane from the origin to point ``(x, y)`` makes this angle
with the positive X axis. The point of :func:`atan2pi` is that the signs of both
inputs are known to it, so it can compute the correct quadrant for the angle.
For example, ``atanpi(1)`` and ``atan2pi(1, 1)`` are both ``0.25``, but
``atan2pi(-1, -1)`` is ``-0.75``.

.. versionadded:: next


.. function:: cos(x)

Return the cosine of *x* radians.


.. function:: cospi(x)

Return the cosine of *x* half-turns (*x⋅π* radians).

.. versionadded:: next


.. function:: sin(x)

Return the sine of *x* radians.


.. function:: sinpi(x)

Return the sine of *x* half-turns (*x⋅π* radians).

.. versionadded:: next


.. function:: tan(x)

Return the tangent of *x* radians.


.. function:: tanpi(x)

Return the tangent of *x* half-turns (*x⋅π* radians).

.. versionadded:: next


Hyperbolic functions
--------------------

Expand Down
22 changes: 22 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ lzma
requires ``lzma`` 5.4.0 or newer while RISC-V requires 5.6.0 or newer.
(Contributed by Chien Wong in :gh:`115988`.)

logging
-------

* :class:`~logging.handlers.TimedRotatingFileHandler` now uses the creation
time instead of the last modification time of an existing log file as
the basis for the first rotation after handler creation, if supported by
the OS and file system.
This allows it to be used in short-running programs that start and end
before the rotation interval expires.
(Contributed by Iván Márton and Serhiy Storchaka in :gh:`84649`.)

math
----

* Added trigonometric functions that work in units of half turns, rather than
radians. The new functions :func:`math.acospi`, :func:`math.asinpi`,
:func:`math.atanpi`, and :func:`math.atan2pi` return half-turn angles. The
new functions :func:`math.cospi`, :func:`math.sinpi`, and :func:`math.tanpi`
take half-turn angle arguments. These functions are recommended by IEEE
754-2019 and standardized in C23.
(Contributed by Jeff Epler in :gh:`150534`.)

os
--

Expand Down
30 changes: 22 additions & 8 deletions Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,28 @@ def __init__(self, filename, when='h', interval=1, backupCount=0,
if os.path.exists(filename):
# Use the minimum of file creation and modification time as
# the base of the rollover calculation
stat_result = os.stat(filename)
# Use st_birthtime whenever it is available or use st_ctime
# instead otherwise
try:
creation_time = stat_result.st_birthtime
except AttributeError:
creation_time = stat_result.st_ctime
t = int(min(creation_time, stat_result.st_mtime))
creation_time = modification_time = None
if hasattr(os, 'statx'):
statx_result = os.statx(filename,
os.STATX_BTIME|os.STATX_CTIME|os.STATX_MTIME)
# Use stx_btime whenever it is available or use stx_ctime
# instead otherwise
creation_time = statx_result.stx_btime
if creation_time is None:
creation_time = statx_result.stx_ctime
modification_time = statx_result.stx_mtime
if creation_time is None or modification_time is None:
stat_result = os.stat(filename)
# Use st_birthtime whenever it is available or use st_ctime
# instead otherwise
if creation_time is None:
try:
creation_time = stat_result.st_birthtime
except AttributeError:
creation_time = stat_result.st_ctime
if modification_time is None:
modification_time = stat_result.st_mtime
t = int(min(creation_time, modification_time))
else:
t = int(time.time())
self.rolloverAt = self.computeRollover(t)
Expand Down
4 changes: 2 additions & 2 deletions Lib/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,8 @@ def move(src, dst, copy_function=copy2):
return real_dst

def _destinsrc(src, dst):
src = os.path.abspath(src)
dst = os.path.abspath(dst)
src = os.path.realpath(src)
dst = os.path.realpath(dst)
if not src.endswith(os.path.sep):
src += os.path.sep
if not dst.endswith(os.path.sep):
Expand Down
Loading
Loading