Skip to content

Commit e394236

Browse files
generatedunixname1734921407115435meta-codesync[bot]
authored andcommitted
Sync pre-release CPython main branch from GitHub (2026-06-06)
Summary: Imported python/cpython `3.16.0a0` from upstream rev [`ab93017`](https://www.github.com/python/cpython/commit/ab930175e7e909aaa3ec7e761bfdbb886677bebb) (committed 2026-06-06 21:38:15+00:00). # Commit Info - Base: (`3.16.0a0`) - [`785b6dc`](https://www.github.com/python/cpython/commit/785b6dcf71b08c34a1d0a1cff9dc4afe997ad283) (commit date: 2026-06-06 02:27:41+00:00) - Imported: (`3.16.0a0`) - [`ab93017`](https://www.github.com/python/cpython/commit/ab930175e7e909aaa3ec7e761bfdbb886677bebb) (commit date: 2026-06-06 21:38:15+00:00) # Noteworthy file changes - Low-signal files (7 added) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GKwr5yLiVo9oNAAQAGJYMwUHxRYNbr0LAAAz Differential Revision: D107786331 fbshipit-source-id: 55c4a150e52201baed8d4e3d7256de6d2f336e42
1 parent e97a167 commit e394236

33 files changed

Lines changed: 2130 additions & 73 deletions

Doc/c-api/long.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
7171
on failure.
7272
7373
74+
.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned long long v)
75+
76+
Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long long`,
77+
or ``NULL`` on failure.
78+
79+
7480
.. c:function:: PyObject* PyLong_FromInt32(int32_t value)
7581
PyObject* PyLong_FromInt64(int64_t value)
7682
@@ -81,12 +87,6 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
8187
.. versionadded:: 3.14
8288
8389
84-
.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned long long v)
85-
86-
Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long long`,
87-
or ``NULL`` on failure.
88-
89-
9090
.. c:function:: PyObject* PyLong_FromUInt32(uint32_t value)
9191
PyObject* PyLong_FromUInt64(uint64_t value)
9292

Doc/library/importlib.resources.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ For all the following functions:
240240

241241
.. versionchanged:: 3.13
242242
Multiple *path_names* are accepted.
243-
*encoding* and *errors* must be given as keyword arguments.
244243

245244

246245
.. function:: is_resource(anchor, *path_names)

Doc/library/logging.handlers.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ timed intervals.
402402
rollover interval.
403403

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

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

453+
.. versionchanged:: next
454+
Use the creation time instead of the last modification time, if supported by the OS and file system.
455+
456+
452457
.. method:: doRollover()
453458

454459
Does a rollover, as described above.

Doc/library/math.rst

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,20 @@ noted otherwise, all return values are floats.
8383

8484
**Trigonometric functions**
8585
--------------------------------------------------------------------------------------------------
86-
:func:`acos(x) <acos>` Arc cosine of *x*
87-
:func:`asin(x) <asin>` Arc sine of *x*
88-
:func:`atan(x) <atan>` Arc tangent of *x*
89-
:func:`atan2(y, x) <atan2>` ``atan(y / x)``
90-
:func:`cos(x) <cos>` Cosine of *x*
91-
:func:`sin(x) <sin>` Sine of *x*
92-
:func:`tan(x) <tan>` Tangent of *x*
86+
:func:`acos(x) <acos>` Arc cosine of *x*, in radians
87+
:func:`acospi(x) <acospi>` Arc cosine of *x*, in half-turns
88+
:func:`asin(x) <asin>` Arc sine of *x*, in radians
89+
:func:`asinpi(x) <asinpi>` Arc sine of *x*, in half-turns
90+
:func:`atan(x) <atan>` Arc tangent of *x*, in radians
91+
:func:`atanpi(x) <atanpi>` Arc tangent of *x*, in half-turns
92+
:func:`atan2(y, x) <atan2>` ``atan(y / x)``, in radians
93+
:func:`atan2pi(y, x) <atan2pi>` ``atan(y / x)``, in half-turns
94+
:func:`cos(x) <cos>` Cosine of *x* radians
95+
:func:`cospi(x) <cospi>` Cosine of *x⋅π* radians
96+
:func:`sin(x) <sin>` Sine of *x* radians
97+
:func:`sinpi(x) <sinpi>` Sine of *x⋅π* radians
98+
:func:`tan(x) <tan>` Tangent of *x* radians
99+
:func:`tanpi(x) <tanpi>` Tangent of *x⋅π* radians
93100

94101
**Hyperbolic functions**
95102
--------------------------------------------------------------------------------------------------
@@ -599,18 +606,42 @@ Trigonometric functions
599606
``pi``.
600607

601608

609+
.. function:: acospi(x)
610+
611+
Return the arc cosine of *x*, in half-turns. The result is between ``0`` and
612+
``1``.
613+
614+
.. versionadded:: next
615+
616+
602617
.. function:: asin(x)
603618

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

607622

623+
.. function:: asinpi(x)
624+
625+
Return the arc sine of *x*, in half-turns. The result is between ``-0.5`` and
626+
``0.5``.
627+
628+
.. versionadded:: next
629+
630+
608631
.. function:: atan(x)
609632

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

613636

637+
.. function:: atanpi(x)
638+
639+
Return the arc tangent of *x*, in half-turns. The result is between ``-0.5`` and
640+
``0.5``.
641+
642+
.. versionadded:: next
643+
644+
614645
.. function:: atan2(y, x)
615646

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

623654

655+
.. function:: atan2pi(y, x)
656+
657+
Return ``atanpi(y / x)``, in half-turns. The result is between ``-1`` and ``1``.
658+
The vector in the plane from the origin to point ``(x, y)`` makes this angle
659+
with the positive X axis. The point of :func:`atan2pi` is that the signs of both
660+
inputs are known to it, so it can compute the correct quadrant for the angle.
661+
For example, ``atanpi(1)`` and ``atan2pi(1, 1)`` are both ``0.25``, but
662+
``atan2pi(-1, -1)`` is ``-0.75``.
663+
664+
.. versionadded:: next
665+
666+
624667
.. function:: cos(x)
625668

626669
Return the cosine of *x* radians.
627670

628671

672+
.. function:: cospi(x)
673+
674+
Return the cosine of *x* half-turns (*x⋅π* radians).
675+
676+
.. versionadded:: next
677+
678+
629679
.. function:: sin(x)
630680

631681
Return the sine of *x* radians.
632682

633683

684+
.. function:: sinpi(x)
685+
686+
Return the sine of *x* half-turns (*x⋅π* radians).
687+
688+
.. versionadded:: next
689+
690+
634691
.. function:: tan(x)
635692

636693
Return the tangent of *x* radians.
637694

638695

696+
.. function:: tanpi(x)
697+
698+
Return the tangent of *x* half-turns (*x⋅π* radians).
699+
700+
.. versionadded:: next
701+
702+
639703
Hyperbolic functions
640704
--------------------
641705

Doc/whatsnew/3.16.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,28 @@ lzma
102102
requires ``lzma`` 5.4.0 or newer while RISC-V requires 5.6.0 or newer.
103103
(Contributed by Chien Wong in :gh:`115988`.)
104104

105+
logging
106+
-------
107+
108+
* :class:`~logging.handlers.TimedRotatingFileHandler` now uses the creation
109+
time instead of the last modification time of an existing log file as
110+
the basis for the first rotation after handler creation, if supported by
111+
the OS and file system.
112+
This allows it to be used in short-running programs that start and end
113+
before the rotation interval expires.
114+
(Contributed by Iván Márton and Serhiy Storchaka in :gh:`84649`.)
115+
116+
math
117+
----
118+
119+
* Added trigonometric functions that work in units of half turns, rather than
120+
radians. The new functions :func:`math.acospi`, :func:`math.asinpi`,
121+
:func:`math.atanpi`, and :func:`math.atan2pi` return half-turn angles. The
122+
new functions :func:`math.cospi`, :func:`math.sinpi`, and :func:`math.tanpi`
123+
take half-turn angle arguments. These functions are recommended by IEEE
124+
754-2019 and standardized in C23.
125+
(Contributed by Jeff Epler in :gh:`150534`.)
126+
105127
os
106128
--
107129

Lib/idlelib/iomenu.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def set_filename_change_hook(self, hook):
6161
self.filename_change_hook = hook
6262

6363
filename = None
64+
file_timestamp = None
6465
dirname = None
6566

6667
def set_filename(self, filename):
@@ -127,6 +128,7 @@ def loadfile(self, filename):
127128
chars = f.read()
128129
fileencoding = f.encoding
129130
eol_convention = f.newlines
131+
file_timestamp = self.getmtime(filename)
130132
converted = False
131133
except (UnicodeDecodeError, SyntaxError):
132134
# Wait for the editor window to appear
@@ -142,6 +144,7 @@ def loadfile(self, filename):
142144
chars = f.read()
143145
fileencoding = f.encoding
144146
eol_convention = f.newlines
147+
file_timestamp = self.getmtime(filename)
145148
converted = True
146149
except OSError as err:
147150
messagebox.showerror("I/O Error", str(err), parent=self.text)
@@ -170,6 +173,7 @@ def loadfile(self, filename):
170173
self.text.insert("1.0", chars)
171174
self.reset_undo()
172175
self.set_filename(filename)
176+
self.file_timestamp = file_timestamp
173177
if converted:
174178
# We need to save the conversion results first
175179
# before being able to execute the code
@@ -206,7 +210,26 @@ def save(self, event):
206210
if not self.filename:
207211
self.save_as(event)
208212
else:
213+
# Check the time of most recent content modification so the
214+
# user doesn't accidentally overwrite a newer version of the file.
215+
try:
216+
file_timestamp = self.getmtime(self.filename)
217+
except OSError:
218+
pass
219+
else:
220+
if self.file_timestamp != file_timestamp:
221+
confirm = messagebox.askokcancel(
222+
title="File has changed",
223+
message=(
224+
"The file has changed on disk since reading it!\n\n"
225+
"Do you really want to overwrite it?"),
226+
default=messagebox.CANCEL,
227+
parent=self.text)
228+
if not confirm:
229+
return "break"
230+
209231
if self.writefile(self.filename):
232+
self.file_timestamp = self.getmtime(self.filename)
210233
self.set_saved(True)
211234
try:
212235
self.editwin.store_file_breaks()
@@ -219,6 +242,7 @@ def save_as(self, event):
219242
filename = self.asksavefile()
220243
if filename:
221244
if self.writefile(filename):
245+
self.file_timestamp = self.getmtime(filename)
222246
self.set_filename(filename)
223247
self.set_saved(1)
224248
try:
@@ -251,6 +275,9 @@ def writefile(self, filename):
251275
parent=self.text)
252276
return False
253277

278+
def getmtime(self, filename):
279+
return os.stat(filename).st_mtime
280+
254281
def fixnewlines(self):
255282
"""Return text with os eols.
256283

Lib/logging/handlers.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,28 @@ def __init__(self, filename, when='h', interval=1, backupCount=0,
284284
if os.path.exists(filename):
285285
# Use the minimum of file creation and modification time as
286286
# the base of the rollover calculation
287-
stat_result = os.stat(filename)
288-
# Use st_birthtime whenever it is available or use st_ctime
289-
# instead otherwise
290-
try:
291-
creation_time = stat_result.st_birthtime
292-
except AttributeError:
293-
creation_time = stat_result.st_ctime
294-
t = int(min(creation_time, stat_result.st_mtime))
287+
creation_time = modification_time = None
288+
if hasattr(os, 'statx'):
289+
statx_result = os.statx(filename,
290+
os.STATX_BTIME|os.STATX_CTIME|os.STATX_MTIME)
291+
# Use stx_btime whenever it is available or use stx_ctime
292+
# instead otherwise
293+
creation_time = statx_result.stx_btime
294+
if creation_time is None:
295+
creation_time = statx_result.stx_ctime
296+
modification_time = statx_result.stx_mtime
297+
if creation_time is None or modification_time is None:
298+
stat_result = os.stat(filename)
299+
# Use st_birthtime whenever it is available or use st_ctime
300+
# instead otherwise
301+
if creation_time is None:
302+
try:
303+
creation_time = stat_result.st_birthtime
304+
except AttributeError:
305+
creation_time = stat_result.st_ctime
306+
if modification_time is None:
307+
modification_time = stat_result.st_mtime
308+
t = int(min(creation_time, modification_time))
295309
else:
296310
t = int(time.time())
297311
self.rolloverAt = self.computeRollover(t)

Lib/shutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,8 @@ def move(src, dst, copy_function=copy2):
944944
return real_dst
945945

946946
def _destinsrc(src, dst):
947-
src = os.path.abspath(src)
948-
dst = os.path.abspath(dst)
947+
src = os.path.realpath(src)
948+
dst = os.path.realpath(dst)
949949
if not src.endswith(os.path.sep):
950950
src += os.path.sep
951951
if not dst.endswith(os.path.sep):

0 commit comments

Comments
 (0)