Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1b2914

Browse files
Merge branch 'main' into win-chmod-follow-symlinks
2 parents 37725be + fddc829 commit b1b2914

63 files changed

Lines changed: 1449 additions & 995 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Lib/test/test_patma.py @brandtbucher
4040
Lib/test/test_peepholer.py @brandtbucher
4141
Lib/test/test_type_*.py @JelleZijlstra
4242
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum
43+
Tools/c-analyzer/ @ericsnowcurrently
4344

4445
# Exceptions
4546
Lib/traceback.py @iritkatriel
@@ -78,11 +79,6 @@ Python/traceback.c @iritkatriel
7879
**/*importlib/resources/* @jaraco @warsaw @FFY00
7980
**/importlib/metadata/* @jaraco @warsaw
8081

81-
# Subinterpreters
82-
Lib/test/support/interpreters/** @ericsnowcurrently
83-
Modules/_xx*interp*module.c @ericsnowcurrently
84-
Lib/test/test_interpreters/** @ericsnowcurrently
85-
8682
# Dates and times
8783
**/*datetime* @pganssle @abalkin
8884
**/*str*time* @pganssle @abalkin
@@ -153,15 +149,7 @@ Doc/c-api/stable.rst @encukou
153149
**/*itertools* @rhettinger
154150
**/*collections* @rhettinger
155151
**/*random* @rhettinger
156-
Doc/**/*queue* @rhettinger
157-
PCbuild/**/*queue* @rhettinger
158-
Modules/_queuemodule.c @rhettinger
159-
Lib/*queue*.py @rhettinger
160-
Lib/asyncio/*queue*.py @rhettinger
161-
Lib/multiprocessing/*queue*.py @rhettinger
162-
Lib/test/*queue*.py @rhettinger
163-
Lib/test_asyncio/*queue*.py @rhettinger
164-
Lib/test_multiprocessing/*queue*.py @rhettinger
152+
**/*queue* @rhettinger
165153
**/*bisect* @rhettinger
166154
**/*heapq* @rhettinger
167155
**/*functools* @rhettinger
@@ -201,6 +189,11 @@ Lib/test_multiprocessing/*queue*.py @rhettinger
201189
/Lib/test/test_clinic.py @erlend-aasland @AlexWaygood
202190
Doc/howto/clinic.rst @erlend-aasland
203191

192+
# Subinterpreters
193+
Lib/test/support/interpreters/ @ericsnowcurrently
194+
Modules/_xx*interp*module.c @ericsnowcurrently
195+
Lib/test/test_interpreters/ @ericsnowcurrently
196+
204197
# WebAssembly
205198
/Tools/wasm/ @brettcannon
206199

.github/workflows/reusable-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Build CPython
19-
run: .\PCbuild\build.bat -e -d -p Win32 ${{ inputs.free-threaded && '--disable-gil' || '' }}
19+
run: .\PCbuild\build.bat -e -d -v -p Win32 ${{ inputs.free-threaded && '--disable-gil' || '' }}
2020
- name: Display build info
2121
run: .\python.bat -m test.pythoninfo
2222
- name: Tests
@@ -33,7 +33,7 @@ jobs:
3333
- name: Register MSVC problem matcher
3434
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3535
- name: Build CPython
36-
run: .\PCbuild\build.bat -e -d -p x64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
36+
run: .\PCbuild\build.bat -e -d -v -p x64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
3737
- name: Display build info
3838
run: .\python.bat -m test.pythoninfo
3939
- name: Tests
@@ -50,4 +50,4 @@ jobs:
5050
- name: Register MSVC problem matcher
5151
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
5252
- name: Build CPython
53-
run: .\PCbuild\build.bat -e -d -p arm64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
53+
run: .\PCbuild\build.bat -e -d -v -p arm64 ${{ inputs.free-threaded && '--disable-gil' || '' }}

Doc/c-api/exceptions.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ Querying the error indicator
541541
542542
.. note::
543543
544-
This function *does not* implicitly set the ``__traceback__``
544+
This function *does not* implicitly set the
545+
:attr:`~BaseException.__traceback__`
545546
attribute on the exception value. If setting the traceback
546547
appropriately is desired, the following additional snippet is needed::
547548
@@ -753,7 +754,8 @@ Exception Objects
753754
.. c:function:: PyObject* PyException_GetTraceback(PyObject *ex)
754755
755756
Return the traceback associated with the exception as a new reference, as
756-
accessible from Python through :attr:`__traceback__`. If there is no
757+
accessible from Python through the :attr:`~BaseException.__traceback__`
758+
attribute. If there is no
757759
traceback associated, this returns ``NULL``.
758760
759761
@@ -767,8 +769,8 @@ Exception Objects
767769
768770
Return the context (another exception instance during whose handling *ex* was
769771
raised) associated with the exception as a new reference, as accessible from
770-
Python through :attr:`__context__`. If there is no context associated, this
771-
returns ``NULL``.
772+
Python through the :attr:`~BaseException.__context__` attribute.
773+
If there is no context associated, this returns ``NULL``.
772774
773775
774776
.. c:function:: void PyException_SetContext(PyObject *ex, PyObject *ctx)
@@ -782,7 +784,8 @@ Exception Objects
782784
783785
Return the cause (either an exception instance, or ``None``,
784786
set by ``raise ... from ...``) associated with the exception as a new
785-
reference, as accessible from Python through :attr:`__cause__`.
787+
reference, as accessible from Python through the
788+
:attr:`~BaseException.__cause__` attribute.
786789
787790
788791
.. c:function:: void PyException_SetCause(PyObject *ex, PyObject *cause)
@@ -791,7 +794,8 @@ Exception Objects
791794
it. There is no type check to make sure that *cause* is either an exception
792795
instance or ``None``. This steals a reference to *cause*.
793796
794-
:attr:`__suppress_context__` is implicitly set to ``True`` by this function.
797+
The :attr:`~BaseException.__suppress_context__` attribute is implicitly set
798+
to ``True`` by this function.
795799
796800
797801
.. c:function:: PyObject* PyException_GetArgs(PyObject *ex)

Doc/library/dis.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,17 @@ operation is being performed, so the intermediate analysis object isn't useful:
328328
source line information (if any) is taken directly from the disassembled code
329329
object.
330330

331-
The *show_caches* and *adaptive* parameters work as they do in :func:`dis`.
331+
The *adaptive* parameter works as it does in :func:`dis`.
332332

333333
.. versionadded:: 3.4
334334

335335
.. versionchanged:: 3.11
336336
Added the *show_caches* and *adaptive* parameters.
337337

338+
.. versionchanged:: 3.13
339+
The *show_caches* parameter is deprecated and has no effect. The *cache_info*
340+
field of each instruction is populated regardless of its value.
341+
338342

339343
.. function:: findlinestarts(code)
340344

@@ -482,6 +486,14 @@ details of bytecode instructions as :class:`Instruction` instances:
482486
:class:`dis.Positions` object holding the
483487
start and end locations that are covered by this instruction.
484488

489+
.. data::cache_info
490+
491+
Information about the cache entries of this instruction, as
492+
triplets of the form ``(name, size, data)``, where the ``name``
493+
and ``size`` describe the cache format and data is the contents
494+
of the cache. ``cache_info`` is ``None`` if the instruction does not have
495+
caches.
496+
485497
.. versionadded:: 3.4
486498

487499
.. versionchanged:: 3.11
@@ -493,8 +505,8 @@ details of bytecode instructions as :class:`Instruction` instances:
493505
Changed field ``starts_line``.
494506

495507
Added fields ``start_offset``, ``cache_offset``, ``end_offset``,
496-
``baseopname``, ``baseopcode``, ``jump_target``, ``oparg``, and
497-
``line_number``.
508+
``baseopname``, ``baseopcode``, ``jump_target``, ``oparg``,
509+
``line_number`` and ``cache_info``.
498510

499511

500512
.. class:: Positions

Doc/library/exceptions.rst

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,48 @@ information on defining exceptions is available in the Python Tutorial under
3838
Exception context
3939
-----------------
4040

41-
When raising a new exception while another exception
42-
is already being handled, the new exception's
43-
:attr:`__context__` attribute is automatically set to the handled
44-
exception. An exception may be handled when an :keyword:`except` or
45-
:keyword:`finally` clause, or a :keyword:`with` statement, is used.
46-
47-
This implicit exception context can be
48-
supplemented with an explicit cause by using :keyword:`!from` with
49-
:keyword:`raise`::
50-
51-
raise new_exc from original_exc
52-
53-
The expression following :keyword:`from<raise>` must be an exception or ``None``. It
54-
will be set as :attr:`__cause__` on the raised exception. Setting
55-
:attr:`__cause__` also implicitly sets the :attr:`__suppress_context__`
56-
attribute to ``True``, so that using ``raise new_exc from None``
57-
effectively replaces the old exception with the new one for display
58-
purposes (e.g. converting :exc:`KeyError` to :exc:`AttributeError`), while
59-
leaving the old exception available in :attr:`__context__` for introspection
60-
when debugging.
61-
62-
The default traceback display code shows these chained exceptions in
63-
addition to the traceback for the exception itself. An explicitly chained
64-
exception in :attr:`__cause__` is always shown when present. An implicitly
65-
chained exception in :attr:`__context__` is shown only if :attr:`__cause__`
66-
is :const:`None` and :attr:`__suppress_context__` is false.
67-
68-
In either case, the exception itself is always shown after any chained
69-
exceptions so that the final line of the traceback always shows the last
70-
exception that was raised.
41+
.. index:: pair: exception; chaining
42+
__cause__ (exception attribute)
43+
__context__ (exception attribute)
44+
__suppress_context__ (exception attribute)
45+
46+
Three attributes on exception objects provide information about the context in
47+
which an the exception was raised:
48+
49+
.. attribute:: BaseException.__context__
50+
BaseException.__cause__
51+
BaseException.__suppress_context__
52+
53+
When raising a new exception while another exception
54+
is already being handled, the new exception's
55+
:attr:`!__context__` attribute is automatically set to the handled
56+
exception. An exception may be handled when an :keyword:`except` or
57+
:keyword:`finally` clause, or a :keyword:`with` statement, is used.
58+
59+
This implicit exception context can be
60+
supplemented with an explicit cause by using :keyword:`!from` with
61+
:keyword:`raise`::
62+
63+
raise new_exc from original_exc
64+
65+
The expression following :keyword:`from<raise>` must be an exception or ``None``. It
66+
will be set as :attr:`!__cause__` on the raised exception. Setting
67+
:attr:`!__cause__` also implicitly sets the :attr:`!__suppress_context__`
68+
attribute to ``True``, so that using ``raise new_exc from None``
69+
effectively replaces the old exception with the new one for display
70+
purposes (e.g. converting :exc:`KeyError` to :exc:`AttributeError`), while
71+
leaving the old exception available in :attr:`!__context__` for introspection
72+
when debugging.
73+
74+
The default traceback display code shows these chained exceptions in
75+
addition to the traceback for the exception itself. An explicitly chained
76+
exception in :attr:`!__cause__` is always shown when present. An implicitly
77+
chained exception in :attr:`!__context__` is shown only if :attr:`!__cause__`
78+
is :const:`None` and :attr:`!__suppress_context__` is false.
79+
80+
In either case, the exception itself is always shown after any chained
81+
exceptions so that the final line of the traceback always shows the last
82+
exception that was raised.
7183

7284

7385
Inheriting from built-in exceptions
@@ -126,6 +138,12 @@ The following exceptions are used mostly as base classes for other exceptions.
126138
tb = sys.exception().__traceback__
127139
raise OtherException(...).with_traceback(tb)
128140

141+
.. attribute:: __traceback__
142+
143+
A writable field that holds the
144+
:ref:`traceback object <traceback-objects>` associated with this
145+
exception. See also: :ref:`raise`.
146+
129147
.. method:: add_note(note)
130148

131149
Add the string ``note`` to the exception's notes which appear in the standard
@@ -929,8 +947,10 @@ their subgroups based on the types of the contained exceptions.
929947
true for the exceptions that should be in the subgroup.
930948

931949
The nesting structure of the current exception is preserved in the result,
932-
as are the values of its :attr:`message`, :attr:`__traceback__`,
933-
:attr:`__cause__`, :attr:`__context__` and :attr:`__notes__` fields.
950+
as are the values of its :attr:`message`,
951+
:attr:`~BaseException.__traceback__`, :attr:`~BaseException.__cause__`,
952+
:attr:`~BaseException.__context__` and
953+
:attr:`~BaseException.__notes__` fields.
934954
Empty nested groups are omitted from the result.
935955

936956
The condition is checked for all exceptions in the nested exception group,
@@ -956,10 +976,14 @@ their subgroups based on the types of the contained exceptions.
956976
and :meth:`split` return instances of the subclass rather
957977
than :exc:`ExceptionGroup`.
958978

959-
:meth:`subgroup` and :meth:`split` copy the :attr:`__traceback__`,
960-
:attr:`__cause__`, :attr:`__context__` and :attr:`__notes__` fields from
979+
:meth:`subgroup` and :meth:`split` copy the
980+
:attr:`~BaseException.__traceback__`,
981+
:attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` and
982+
:attr:`~BaseException.__notes__` fields from
961983
the original exception group to the one returned by :meth:`derive`, so
962-
these fields do not need to be updated by :meth:`derive`. ::
984+
these fields do not need to be updated by :meth:`derive`.
985+
986+
.. doctest::
963987

964988
>>> class MyGroup(ExceptionGroup):
965989
... def derive(self, excs):

Doc/library/itertools.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -914,14 +914,15 @@ which incur interpreter overhead.
914914
# grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError
915915
# grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF
916916
args = [iter(iterable)] * n
917-
if incomplete == 'fill':
918-
return zip_longest(*args, fillvalue=fillvalue)
919-
elif incomplete == 'strict':
920-
return zip(*args, strict=True)
921-
elif incomplete == 'ignore':
922-
return zip(*args)
923-
else:
924-
raise ValueError('Expected fill, strict, or ignore')
917+
match incomplete:
918+
case 'fill':
919+
return zip_longest(*args, fillvalue=fillvalue)
920+
case 'strict':
921+
return zip(*args, strict=True)
922+
case 'ignore':
923+
return zip(*args)
924+
case _:
925+
raise ValueError('Expected fill, strict, or ignore')
925926
926927
def sliding_window(iterable, n):
927928
# sliding_window('ABCDEFG', 4) --> ABCD BCDE CDEF DEFG

Doc/library/os.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2164,9 +2164,12 @@ features:
21642164
for possible values of *mode*. As of Python 3.3, this is equivalent to
21652165
``os.chmod(path, mode, follow_symlinks=False)``.
21662166

2167+
``lchmod()`` is not part of POSIX, but Unix implementations may have it if
2168+
changing the mode of symbolic links is supported.
2169+
21672170
.. audit-event:: os.chmod path,mode,dir_fd os.lchmod
21682171

2169-
.. availability:: Unix, Windows.
2172+
.. availability:: Unix, Windows, not Linux, FreeBSD >= 1.3, NetBSD >= 1.3, not OpenBSD
21702173

21712174
.. versionchanged:: 3.6
21722175
Accepts a :term:`path-like object`.

0 commit comments

Comments
 (0)