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

Skip to content

Commit 4611265

Browse files
committed
Catch up with main
2 parents 241ce0f + 0ff6368 commit 4611265

93 files changed

Lines changed: 2278 additions & 1096 deletions

File tree

Some content is hidden

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

Doc/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ help:
2929
@echo " venv to create a venv with necessary tools"
3030
@echo " html to make standalone HTML files"
3131
@echo " htmlview to open the index page built by the html target in your browser"
32+
@echo " htmllive to rebuild and reload HTML files in your browser"
3233
@echo " htmlhelp to make HTML files and a HTML help project"
3334
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
3435
@echo " text to make plain text files"
@@ -139,6 +140,11 @@ pydoc-topics: build
139140
htmlview: html
140141
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
141142

143+
.PHONY: htmllive
144+
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
145+
htmllive: SPHINXOPTS = --re-ignore="/venv/"
146+
htmllive: html
147+
142148
.PHONY: clean
143149
clean: clean-venv
144150
-rm -rf build/*

Doc/c-api/dict.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,33 @@ Dictionary Objects
173173
174174
.. versionadded:: 3.4
175175
176+
177+
.. c:function:: int PyDict_Pop(PyObject *p, PyObject *key, PyObject **result)
178+
179+
Remove *key* from dictionary *p* and optionally return the removed value.
180+
Do not raise :exc:`KeyError` if the key missing.
181+
182+
- If the key is present, set *\*result* to a new reference to the removed
183+
value if *result* is not ``NULL``, and return ``1``.
184+
- If the key is missing, set *\*result* to ``NULL`` if *result* is not
185+
``NULL``, and return ``0``.
186+
- On error, raise an exception and return ``-1``.
187+
188+
This is similar to :meth:`dict.pop`, but without the default value and
189+
not raising :exc:`KeyError` if the key missing.
190+
191+
.. versionadded:: 3.13
192+
193+
194+
.. c:function:: int PyDict_PopString(PyObject *p, const char *key, PyObject **result)
195+
196+
Similar to :c:func:`PyDict_Pop`, but *key* is specified as a
197+
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
198+
:c:expr:`PyObject*`.
199+
200+
.. versionadded:: 3.13
201+
202+
176203
.. c:function:: PyObject* PyDict_Items(PyObject *p)
177204
178205
Return a :c:type:`PyListObject` containing all the items from the dictionary.

Doc/c-api/list.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,30 @@ List Objects
128128
list is not supported.
129129
130130
131+
.. c:function:: int PyList_Extend(PyObject *list, PyObject *iterable)
132+
133+
Extend *list* with the contents of *iterable*. This is the same as
134+
``PyList_SetSlice(list, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, iterable)``
135+
and analogous to ``list.extend(iterable)`` or ``list += iterable``.
136+
137+
Raise an exception and return ``-1`` if *list* is not a :class:`list`
138+
object. Return 0 on success.
139+
140+
.. versionadded:: 3.13
141+
142+
143+
.. c:function:: int PyList_Clear(PyObject *list)
144+
145+
Remove all items from *list*. This is the same as
146+
``PyList_SetSlice(list, 0, PY_SSIZE_T_MAX, NULL)`` and analogous to
147+
``list.clear()`` or ``del list[:]``.
148+
149+
Raise an exception and return ``-1`` if *list* is not a :class:`list`
150+
object. Return 0 on success.
151+
152+
.. versionadded:: 3.13
153+
154+
131155
.. c:function:: int PyList_Sort(PyObject *list)
132156
133157
Sort the items of *list* in place. Return ``0`` on success, ``-1`` on

Doc/library/glob.rst

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ unlike :func:`fnmatch.fnmatch` or :func:`pathlib.Path.glob`.
3434
For a literal match, wrap the meta-characters in brackets.
3535
For example, ``'[?]'`` matches the character ``'?'``.
3636

37-
38-
.. seealso::
39-
The :mod:`pathlib` module offers high-level path objects.
37+
The :mod:`glob` module defines the following functions:
4038

4139

4240
.. function:: glob(pathname, *, root_dir=None, dir_fd=None, recursive=False, \
@@ -117,7 +115,48 @@ For example, ``'[?]'`` matches the character ``'?'``.
117115
.. versionadded:: 3.4
118116

119117

120-
For example, consider a directory containing the following files:
118+
.. function:: translate(pathname, *, recursive=False, include_hidden=False, seps=None)
119+
120+
Convert the given path specification to a regular expression for use with
121+
:func:`re.match`. The path specification can contain shell-style wildcards.
122+
123+
For example:
124+
125+
>>> import glob, re
126+
>>>
127+
>>> regex = glob.translate('**/*.txt', recursive=True, include_hidden=True)
128+
>>> regex
129+
'(?s:(?:.+/)?[^/]*\\.txt)\\Z'
130+
>>> reobj = re.compile(regex)
131+
>>> reobj.match('foo/bar/baz.txt')
132+
<re.Match object; span=(0, 15), match='foo/bar/baz.txt'>
133+
134+
Path separators and segments are meaningful to this function, unlike
135+
:func:`fnmatch.translate`. By default wildcards do not match path
136+
separators, and ``*`` pattern segments match precisely one path segment.
137+
138+
If *recursive* is true, the pattern segment "``**``" will match any number
139+
of path segments. If "``**``" occurs in any position other than a full
140+
pattern segment, :exc:`ValueError` is raised.
141+
142+
If *include_hidden* is true, wildcards can match path segments that start
143+
with a dot (``.``).
144+
145+
A sequence of path separators may be supplied to the *seps* argument. If
146+
not given, :data:`os.sep` and :data:`~os.altsep` (if available) are used.
147+
148+
.. seealso::
149+
150+
:meth:`pathlib.PurePath.match` and :meth:`pathlib.Path.glob` methods,
151+
which call this function to implement pattern matching and globbing.
152+
153+
.. versionadded:: 3.13
154+
155+
156+
Examples
157+
--------
158+
159+
Consider a directory containing the following files:
121160
:file:`1.gif`, :file:`2.txt`, :file:`card.gif` and a subdirectory :file:`sub`
122161
which contains only the file :file:`3.txt`. :func:`glob` will produce
123162
the following results. Notice how any leading components of the path are
@@ -146,6 +185,7 @@ default. For example, consider a directory containing :file:`card.gif` and
146185
['.card.gif']
147186

148187
.. seealso::
188+
The :mod:`fnmatch` module offers shell-style filename (not path) expansion.
149189

150-
Module :mod:`fnmatch`
151-
Shell-style filename (not path) expansion
190+
.. seealso::
191+
The :mod:`pathlib` module offers high-level path objects.

Doc/library/mailbox.rst

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,108 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
424424
remove the underlying message while the returned file remains open.
425425

426426

427+
.. method:: get_flags(key)
428+
429+
Return as a string the flags that are set on the message
430+
corresponding to *key*.
431+
This is the same as ``get_message(key).get_flags()`` but much
432+
faster, because it does not open the message file.
433+
Use this method when iterating over the keys to determine which
434+
messages are interesting to get.
435+
436+
If you do have a :class:`MaildirMessage` object, use
437+
its :meth:`~MaildirMessage.get_flags` method instead, because
438+
changes made by the message's :meth:`~MaildirMessage.set_flags`,
439+
:meth:`~MaildirMessage.add_flag` and :meth:`~MaildirMessage.remove_flag`
440+
methods are not reflected here until the mailbox's
441+
:meth:`__setitem__` method is called.
442+
443+
.. versionadded:: 3.13
444+
445+
446+
.. method:: set_flags(key, flags)
447+
448+
On the message corresponding to *key*, set the flags specified
449+
by *flags* and unset all others.
450+
Calling ``some_mailbox.set_flags(key, flags)`` is similar to ::
451+
452+
one_message = some_mailbox.get_message(key)
453+
one_message.set_flags(flags)
454+
some_mailbox[key] = one_message
455+
456+
but faster, because it does not open the message file.
457+
458+
If you do have a :class:`MaildirMessage` object, use
459+
its :meth:`~MaildirMessage.set_flags` method instead, because
460+
changes made with this mailbox method will not be visible to the
461+
message object's method, :meth:`~MaildirMessage.get_flags`.
462+
463+
.. versionadded:: 3.13
464+
465+
466+
.. method:: add_flag(key, flag)
467+
468+
On the message corresponding to *key*, set the flags specified
469+
by *flag* without changing other flags. To add more than one
470+
flag at a time, *flag* may be a string of more than one character.
471+
472+
Considerations for using this method versus the message object's
473+
:meth:`~MaildirMessage.add_flag` method are similar to
474+
those for :meth:`set_flags`; see the discussion there.
475+
476+
.. versionadded:: 3.13
477+
478+
479+
.. method:: remove_flag(key, flag)
480+
481+
On the message corresponding to *key*, unset the flags specified
482+
by *flag* without changing other flags. To remove more than one
483+
flag at a time, *flag* may be a string of more than one character.
484+
485+
Considerations for using this method versus the message object's
486+
:meth:`~MaildirMessage.remove_flag` method are similar to
487+
those for :meth:`set_flags`; see the discussion there.
488+
489+
.. versionadded:: 3.13
490+
491+
492+
.. method:: get_info(key)
493+
494+
Return a string containing the info for the message
495+
corresponding to *key*.
496+
This is the same as ``get_message(key).get_info()`` but much
497+
faster, because it does not open the message file.
498+
Use this method when iterating over the keys to determine which
499+
messages are interesting to get.
500+
501+
If you do have a :class:`MaildirMessage` object, use
502+
its :meth:`~MaildirMessage.get_info` method instead, because
503+
changes made by the message's :meth:`~MaildirMessage.set_info` method
504+
are not reflected here until the mailbox's :meth:`__setitem__` method
505+
is called.
506+
507+
.. versionadded:: 3.13
508+
509+
510+
.. method:: set_info(key, info)
511+
512+
Set the info of the message corresponding to *key* to *info*.
513+
Calling ``some_mailbox.set_info(key, flags)`` is similar to ::
514+
515+
one_message = some_mailbox.get_message(key)
516+
one_message.set_info(info)
517+
some_mailbox[key] = one_message
518+
519+
but faster, because it does not open the message file.
520+
521+
If you do have a :class:`MaildirMessage` object, use
522+
its :meth:`~MaildirMessage.set_info` method instead, because
523+
changes made with this mailbox method will not be visible to the
524+
message object's method, :meth:`~MaildirMessage.get_info`.
525+
526+
.. versionadded:: 3.13
527+
528+
427529
.. seealso::
428530

429531
`maildir man page from Courier <https://www.courier-mta.org/maildir.html>`_
@@ -838,7 +940,7 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
838940
.. note::
839941

840942
A message is typically moved from :file:`new` to :file:`cur` after its
841-
mailbox has been accessed, whether or not the message is has been
943+
mailbox has been accessed, whether or not the message has been
842944
read. A message ``msg`` has been read if ``"S" in msg.get_flags()`` is
843945
``True``.
844946

Doc/library/stdtypes.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4755,14 +4755,17 @@ support membership tests:
47554755

47564756
.. versionadded:: 3.10
47574757

4758-
Keys views are set-like since their entries are unique and :term:`hashable`. If all
4759-
values are hashable, so that ``(key, value)`` pairs are unique and hashable,
4760-
then the items view is also set-like. (Values views are not treated as set-like
4758+
Keys views are set-like since their entries are unique and :term:`hashable`.
4759+
Items views also have set-like operations since the (key, value) pairs
4760+
are unique and the keys are hashable.
4761+
If all values in an items view are hashable as well,
4762+
then the items view can interoperate with other sets.
4763+
(Values views are not treated as set-like
47614764
since the entries are generally not unique.) For set-like views, all of the
47624765
operations defined for the abstract base class :class:`collections.abc.Set` are
47634766
available (for example, ``==``, ``<``, or ``^``). While using set operators,
4764-
set-like views accept any iterable as the other operand, unlike sets which only
4765-
accept sets as the input.
4767+
set-like views accept any iterable as the other operand,
4768+
unlike sets which only accept sets as the input.
47664769

47674770
An example of dictionary view usage::
47684771

Doc/reference/expressions.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,10 +1781,11 @@ Or, when processing a file stream in chunks:
17811781
while chunk := file.read(9000):
17821782
process(chunk)
17831783
1784-
Assignment expressions must be surrounded by parentheses when used
1785-
as sub-expressions in slicing, conditional, lambda,
1786-
keyword-argument, and comprehension-if expressions
1787-
and in ``assert`` and ``with`` statements.
1784+
Assignment expressions must be surrounded by parentheses when
1785+
used as expression statements and when used as sub-expressions in
1786+
slicing, conditional, lambda,
1787+
keyword-argument, and comprehension-if expressions and
1788+
in ``assert``, ``with``, and ``assignment`` statements.
17881789
In all other places where they can be used, parentheses are not required,
17891790
including in ``if`` and ``while`` statements.
17901791

Doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ sphinx==6.2.1
1111

1212
blurb
1313

14+
sphinx-autobuild
1415
sphinxext-opengraph==0.7.5
1516

1617
# The theme used by the documentation is stored separately, so we need

Doc/whatsnew/3.13.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ doctest
183183
:attr:`doctest.TestResults.skipped` attributes.
184184
(Contributed by Victor Stinner in :gh:`108794`.)
185185

186+
glob
187+
----
188+
189+
* Add :func:`glob.translate` function that converts a path specification with
190+
shell-style wildcards to a regular expression.
191+
(Contributed by Barney Gale in :gh:`72904`.)
192+
186193
io
187194
--
188195

@@ -1164,6 +1171,16 @@ New Features
11641171
:c:func:`PyErr_WriteUnraisable`, but allow to customize the warning mesage.
11651172
(Contributed by Serhiy Storchaka in :gh:`108082`.)
11661173

1174+
* Add :c:func:`PyList_Extend` and :c:func:`PyList_Clear` functions: similar to
1175+
Python ``list.extend()`` and ``list.clear()`` methods.
1176+
(Contributed by Victor Stinner in :gh:`111138`.)
1177+
1178+
* Add :c:func:`PyDict_Pop` and :c:func:`PyDict_PopString` functions: remove a
1179+
key from a dictionary and optionally return the removed value. This is
1180+
similar to :meth:`dict.pop`, but without the default value and not raising
1181+
:exc:`KeyError` if the key missing.
1182+
(Contributed by Stefan Behnel and Victor Stinner in :gh:`111262`.)
1183+
11671184

11681185
Porting to Python 3.13
11691186
----------------------

Include/cpython/compile.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,3 @@ typedef struct {
6868
#define PY_INVALID_STACK_EFFECT INT_MAX
6969
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
7070
PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump);
71-
72-
PyAPI_FUNC(int) PyUnstable_OpcodeIsValid(int opcode);
73-
PyAPI_FUNC(int) PyUnstable_OpcodeHasArg(int opcode);
74-
PyAPI_FUNC(int) PyUnstable_OpcodeHasConst(int opcode);
75-
PyAPI_FUNC(int) PyUnstable_OpcodeHasName(int opcode);
76-
PyAPI_FUNC(int) PyUnstable_OpcodeHasJump(int opcode);
77-
PyAPI_FUNC(int) PyUnstable_OpcodeHasFree(int opcode);
78-
PyAPI_FUNC(int) PyUnstable_OpcodeHasLocal(int opcode);
79-
PyAPI_FUNC(int) PyUnstable_OpcodeHasExc(int opcode);
80-
81-
PyAPI_FUNC(PyObject*) PyUnstable_GetUnaryIntrinsicName(int index);
82-
PyAPI_FUNC(PyObject*) PyUnstable_GetBinaryIntrinsicName(int index);

0 commit comments

Comments
 (0)