Skip to content

Commit b04215f

Browse files
Merge remote-tracking branch 'upstream/main' into tier2_inliner_redux
2 parents 24b127f + ffed8d9 commit b04215f

36 files changed

+424
-188
lines changed

.github/workflows/jit.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
target:
3030
- i686-pc-windows-msvc/msvc
3131
- x86_64-pc-windows-msvc/msvc
32+
- aarch64-pc-windows-msvc/msvc
3233
- x86_64-apple-darwin/clang
3334
- aarch64-apple-darwin/clang
3435
- x86_64-unknown-linux-gnu/gcc
@@ -49,6 +50,10 @@ jobs:
4950
architecture: x64
5051
runner: windows-latest
5152
compiler: msvc
53+
- target: aarch64-pc-windows-msvc/msvc
54+
architecture: ARM64
55+
runner: windows-latest
56+
compiler: msvc
5257
- target: x86_64-apple-darwin/clang
5358
architecture: x86_64
5459
runner: macos-13
@@ -85,14 +90,21 @@ jobs:
8590
with:
8691
python-version: '3.11'
8792

88-
- name: Windows
89-
if: runner.os == 'Windows'
93+
- name: Native Windows
94+
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
9095
run: |
9196
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
9297
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
9398
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
9499
95-
- name: macOS
100+
# No PGO or tests (yet):
101+
- name: Emulated Windows
102+
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
103+
run: |
104+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
105+
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
106+
107+
- name: Native macOS
96108
if: runner.os == 'macOS'
97109
run: |
98110
brew install llvm@${{ matrix.llvm }}

Doc/library/filecmp.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,20 @@ The :mod:`filecmp` module defines the following functions:
7070
The :class:`dircmp` class
7171
-------------------------
7272

73-
.. class:: dircmp(a, b, ignore=None, hide=None)
73+
.. class:: dircmp(a, b, ignore=None, hide=None, shallow=True)
7474

7575
Construct a new directory comparison object, to compare the directories *a*
7676
and *b*. *ignore* is a list of names to ignore, and defaults to
7777
:const:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and
7878
defaults to ``[os.curdir, os.pardir]``.
7979

8080
The :class:`dircmp` class compares files by doing *shallow* comparisons
81-
as described for :func:`filecmp.cmp`.
81+
as described for :func:`filecmp.cmp` by default using the *shallow*
82+
parameter.
83+
84+
.. versionchanged:: 3.13
85+
86+
Added the *shallow* parameter.
8287

8388
The :class:`dircmp` class provides the following methods:
8489

Doc/library/itertools.rst

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ Iterator Arguments Results
5656
:func:`chain` p, q, ... p0, p1, ... plast, q0, q1, ... ``chain('ABC', 'DEF') --> A B C D E F``
5757
:func:`chain.from_iterable` iterable p0, p1, ... plast, q0, q1, ... ``chain.from_iterable(['ABC', 'DEF']) --> A B C D E F``
5858
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
59-
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
60-
:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
59+
:func:`dropwhile` predicate, seq seq[n], seq[n+1], starting when predicate fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
60+
:func:`filterfalse` predicate, seq elements of seq where predicate(elem) fails ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
6161
:func:`groupby` iterable[, key] sub-iterators grouped by value of key(v)
6262
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
6363
:func:`pairwise` iterable (p[0], p[1]), (p[1], p[2]) ``pairwise('ABCDEFG') --> AB BC CD DE EF FG``
6464
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
65-
:func:`takewhile` pred, seq seq[0], seq[1], until pred fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``
65+
:func:`takewhile` predicate, seq seq[0], seq[1], until predicate fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``
6666
:func:`tee` it, n it1, it2, ... itn splits one iterator into n
6767
:func:`zip_longest` p, q, ... (p[0], q[0]), (p[1], q[1]), ... ``zip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D-``
6868
============================ ============================ ================================================= =============================================================
@@ -90,7 +90,7 @@ Examples Results
9090

9191
.. _itertools-functions:
9292

93-
Itertool functions
93+
Itertool Functions
9494
------------------
9595

9696
The following module functions all construct and return iterators. Some provide
@@ -859,27 +859,20 @@ which incur interpreter overhead.
859859
"Returns the nth item or a default value."
860860
return next(islice(iterable, n, None), default)
861861

862-
def quantify(iterable, pred=bool):
862+
def quantify(iterable, predicate=bool):
863863
"Given a predicate that returns True or False, count the True results."
864-
return sum(map(pred, iterable))
864+
return sum(map(predicate, iterable))
865+
866+
def first_true(iterable, default=False, predicate=None):
867+
"Returns the first true value or the *default* if there is no true value."
868+
# first_true([a,b,c], x) --> a or b or c or x
869+
# first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
870+
return next(filter(predicate, iterable), default)
865871

866872
def all_equal(iterable, key=None):
867873
"Returns True if all the elements are equal to each other."
868874
return len(take(2, groupby(iterable, key))) <= 1
869875

870-
def first_true(iterable, default=False, pred=None):
871-
"""Returns the first true value in the iterable.
872-
873-
If no true value is found, returns *default*
874-
875-
If *pred* is not None, returns the first item
876-
for which pred(item) is true.
877-
878-
"""
879-
# first_true([a,b,c], x) --> a or b or c or x
880-
# first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
881-
return next(filter(pred, iterable), default)
882-
883876
def unique_everseen(iterable, key=None):
884877
"List unique elements, preserving order. Remember all elements ever seen."
885878
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
@@ -964,14 +957,14 @@ which incur interpreter overhead.
964957
num_active -= 1
965958
nexts = cycle(islice(nexts, num_active))
966959
967-
def partition(pred, iterable):
960+
def partition(predicate, iterable):
968961
"""Partition entries into false entries and true entries.
969962

970-
If *pred* is slow, consider wrapping it with functools.lru_cache().
963+
If *predicate* is slow, consider wrapping it with functools.lru_cache().
971964
"""
972965
# partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9
973966
t1, t2 = tee(iterable)
974-
return filterfalse(pred, t1), filter(pred, t2)
967+
return filterfalse(predicate, t1), filter(predicate, t2)
975968

976969
def subslices(seq):
977970
"Return all contiguous non-empty subslices of a sequence."
@@ -1214,7 +1207,7 @@ The following recipes have a more mathematical flavor:
12141207
>>> quantify([True, False, False, True, True])
12151208
3
12161209

1217-
>>> quantify(range(12), pred=lambda x: x%2==1)
1210+
>>> quantify(range(12), predicate=lambda x: x%2==1)
12181211
6
12191212

12201213
>>> a = [[1, 2, 3], [4, 5, 6]]

Doc/tutorial/introduction.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,6 @@ indexed and sliced::
405405
>>> squares[-3:] # slicing returns a new list
406406
[9, 16, 25]
407407

408-
All slice operations return a new list containing the requested elements. This
409-
means that the following slice returns a
410-
:ref:`shallow copy <shallow_vs_deep_copy>` of the list::
411-
412-
>>> squares[:]
413-
[1, 4, 9, 16, 25]
414-
415408
Lists also support operations like concatenation::
416409

417410
>>> squares + [36, 49, 64, 81, 100]
@@ -435,6 +428,30 @@ the :meth:`!list.append` *method* (we will see more about methods later)::
435428
>>> cubes
436429
[1, 8, 27, 64, 125, 216, 343]
437430

431+
Simple assignment in Python never copies data. When you assign a list
432+
to a variable, the variable refers to the *existing list*.
433+
Any changes you make to the list through one variable will be seen
434+
through all other variables that refer to it.::
435+
436+
>>> rgb = ["Red", "Green", "Blue"]
437+
>>> rgba = rgb
438+
>>> id(rgb) == id(rgba) # they reference the same object
439+
True
440+
>>> rgba.append("Alph")
441+
>>> rgb
442+
["Red", "Green", "Blue", "Alph"]
443+
444+
All slice operations return a new list containing the requested elements. This
445+
means that the following slice returns a
446+
:ref:`shallow copy <shallow_vs_deep_copy>` of the list::
447+
448+
>>> correct_rgba = rgba[:]
449+
>>> correct_rgba[-1] = "Alpha"
450+
>>> correct_rgba
451+
["Red", "Green", "Blue", "Alpha"]
452+
>>> rgba
453+
["Red", "Green", "Blue", "Alph"]
454+
438455
Assignment to slices is also possible, and this can even change the size of the
439456
list or clear it entirely::
440457

Doc/whatsnew/3.13.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,9 @@ Deprecated
791791
coroutine.
792792
(Contributed by Irit Katriel in :gh:`81137`.)
793793

794+
* The undocumented and unused ``tarfile`` attribute of :class:`tarfile.TarFile`
795+
is deprecated and scheduled for removal in Python 3.16.
796+
794797

795798
Pending Removal in Python 3.14
796799
------------------------------

Include/pyexpat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/* note: you must import expat.h before importing this module! */
55

6-
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1"
6+
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.2"
77
#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
88

99
struct PyExpat_CAPI

Lib/filecmp.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ def _do_cmp(f1, f2):
8888
class dircmp:
8989
"""A class that manages the comparison of 2 directories.
9090
91-
dircmp(a, b, ignore=None, hide=None)
91+
dircmp(a, b, ignore=None, hide=None, shallow=True)
9292
A and B are directories.
9393
IGNORE is a list of names to ignore,
9494
defaults to DEFAULT_IGNORES.
9595
HIDE is a list of names to hide,
9696
defaults to [os.curdir, os.pardir].
97+
SHALLOW specifies whether to just check the stat signature (do not read
98+
the files).
99+
defaults to True.
97100
98101
High level usage:
99102
x = dircmp(dir1, dir2)
@@ -121,7 +124,7 @@ class dircmp:
121124
in common_dirs.
122125
"""
123126

124-
def __init__(self, a, b, ignore=None, hide=None): # Initialize
127+
def __init__(self, a, b, ignore=None, hide=None, shallow=True): # Initialize
125128
self.left = a
126129
self.right = b
127130
if hide is None:
@@ -132,6 +135,7 @@ def __init__(self, a, b, ignore=None, hide=None): # Initialize
132135
self.ignore = DEFAULT_IGNORES
133136
else:
134137
self.ignore = ignore
138+
self.shallow = shallow
135139

136140
def phase0(self): # Compare everything except common subdirectories
137141
self.left_list = _filter(os.listdir(self.left),
@@ -184,7 +188,7 @@ def phase2(self): # Distinguish files, directories, funnies
184188
self.common_funny.append(x)
185189

186190
def phase3(self): # Find out differences between common files
187-
xx = cmpfiles(self.left, self.right, self.common_files)
191+
xx = cmpfiles(self.left, self.right, self.common_files, self.shallow)
188192
self.same_files, self.diff_files, self.funny_files = xx
189193

190194
def phase4(self): # Find out differences between common subdirectories
@@ -196,7 +200,8 @@ def phase4(self): # Find out differences between common subdirectories
196200
for x in self.common_dirs:
197201
a_x = os.path.join(self.left, x)
198202
b_x = os.path.join(self.right, x)
199-
self.subdirs[x] = self.__class__(a_x, b_x, self.ignore, self.hide)
203+
self.subdirs[x] = self.__class__(a_x, b_x, self.ignore, self.hide,
204+
self.shallow)
200205

201206
def phase4_closure(self): # Recursively call phase4() on subdirectories
202207
self.phase4()

Lib/pathlib/_abc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def _make_child_direntry(self, entry):
789789
def _make_child_relpath(self, name):
790790
return self.joinpath(name)
791791

792-
def glob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
792+
def glob(self, pattern, *, case_sensitive=None, follow_symlinks=True):
793793
"""Iterate over this subtree and yield all existing files (of any
794794
kind, including directories) matching the given relative pattern.
795795
"""
@@ -846,7 +846,7 @@ def glob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
846846
paths = _select_children(paths, bool(stack), follow_symlinks, match)
847847
return paths
848848

849-
def rglob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
849+
def rglob(self, pattern, *, case_sensitive=None, follow_symlinks=True):
850850
"""Recursively yield all existing files (of any kind, including
851851
directories) matching the given relative pattern, anywhere in
852852
this subtree.

Lib/tarfile.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ class TarInfo(object):
872872
pax_headers = ('A dictionary containing key-value pairs of an '
873873
'associated pax extended header.'),
874874
sparse = 'Sparse member information.',
875-
tarfile = None,
875+
_tarfile = None,
876876
_sparse_structs = None,
877877
_link_target = None,
878878
)
@@ -901,6 +901,24 @@ def __init__(self, name=""):
901901
self.sparse = None # sparse member information
902902
self.pax_headers = {} # pax header information
903903

904+
@property
905+
def tarfile(self):
906+
import warnings
907+
warnings.warn(
908+
'The undocumented "tarfile" attribute of TarInfo objects '
909+
+ 'is deprecated and will be removed in Python 3.16',
910+
DeprecationWarning, stacklevel=2)
911+
return self._tarfile
912+
913+
@tarfile.setter
914+
def tarfile(self, tarfile):
915+
import warnings
916+
warnings.warn(
917+
'The undocumented "tarfile" attribute of TarInfo objects '
918+
+ 'is deprecated and will be removed in Python 3.16',
919+
DeprecationWarning, stacklevel=2)
920+
self._tarfile = tarfile
921+
904922
@property
905923
def path(self):
906924
'In pax headers, "name" is called "path".'
@@ -2030,7 +2048,7 @@ def gettarinfo(self, name=None, arcname=None, fileobj=None):
20302048
# Now, fill the TarInfo object with
20312049
# information specific for the file.
20322050
tarinfo = self.tarinfo()
2033-
tarinfo.tarfile = self # Not needed
2051+
tarinfo._tarfile = self # To be removed in 3.16.
20342052

20352053
# Use os.stat or os.lstat, depending on if symlinks shall be resolved.
20362054
if fileobj is None:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
3+
# gh-115832: An object destructor running during the final GC of interpreter
4+
# shutdown triggered an infinite loop in the instrumentation code.
5+
6+
import sys
7+
8+
class CallableCycle:
9+
def __init__(self):
10+
self._cycle = self
11+
12+
def __del__(self):
13+
pass
14+
15+
def __call__(self, code, instruction_offset):
16+
pass
17+
18+
def tracefunc(frame, event, arg):
19+
pass
20+
21+
def main():
22+
tool_id = sys.monitoring.PROFILER_ID
23+
event_id = sys.monitoring.events.PY_START
24+
25+
sys.monitoring.use_tool_id(tool_id, "test profiler")
26+
sys.monitoring.set_events(tool_id, event_id)
27+
sys.monitoring.register_callback(tool_id, event_id, CallableCycle())
28+
29+
if __name__ == "__main__":
30+
sys.exit(main())

0 commit comments

Comments
 (0)