Skip to content

Commit f2f67e7

Browse files
Merge branch 'main' into pythongh-99773
2 parents f57b4dc + 66b3922 commit f2f67e7

Some content is hidden

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

43 files changed

+547
-383
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,5 @@ Lib/test/test_configparser.py @jaraco
280280

281281
# Doc sections
282282
Doc/reference/ @willingc
283+
284+
**/*weakref* @kumaraditya303

Doc/c-api/contextvars.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Context object management functions:
136136
137137
.. versionadded:: 3.14
138138
139-
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyContext* ctx)
139+
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyObject *obj)
140140
141141
Context object watcher callback function. The object passed to the callback
142142
is event-specific; see :c:type:`PyContextEvent` for details.

Doc/c-api/long.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
608608
Exactly what values are considered compact is an implementation detail
609609
and is subject to change.
610610
611+
.. versionadded:: 3.12
612+
613+
611614
.. c:function:: Py_ssize_t PyUnstable_Long_CompactValue(const PyLongObject* op)
612615
613616
If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`,
614617
return its value.
615618
616619
Otherwise, the return value is undefined.
617620
621+
.. versionadded:: 3.12
622+

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ Glossary
617617

618618
As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil`
619619
build configuration. After building Python with this option, code must be
620-
run with :option:`-X gil 0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
620+
run with :option:`-X gil=0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
621621
environment variable. This feature enables improved performance for
622622
multi-threaded applications and makes it easier to use multi-core CPUs
623623
efficiently. For more details, see :pep:`703`.

Doc/library/argparse.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,25 @@ be positional::
662662
usage: PROG [-h] [-f FOO] bar
663663
PROG: error: the following arguments are required: bar
664664

665+
By default, argparse automatically handles the internal naming and
666+
display names of arguments, simplifying the process without requiring
667+
additional configuration.
668+
As such, you do not need to specify the dest_ and metavar_ parameters.
669+
The dest_ parameter defaults to the argument name with underscores ``_``
670+
replacing hyphens ``-`` . The metavar_ parameter defaults to the
671+
upper-cased name. For example::
672+
673+
>>> parser = argparse.ArgumentParser(prog='PROG')
674+
>>> parser.add_argument('--foo-bar')
675+
>>> parser.parse_args(['--foo-bar', 'FOO-BAR']
676+
Namespace(foo_bar='FOO-BAR')
677+
>>> parser.print_help()
678+
usage: [-h] [--foo-bar FOO-BAR]
679+
680+
optional arguments:
681+
-h, --help show this help message and exit
682+
--foo-bar FOO-BAR
683+
665684

666685
.. _action:
667686

@@ -758,6 +777,9 @@ how the command-line arguments should be handled. The supplied actions are:
758777

759778
.. versionadded:: 3.8
760779

780+
Only actions that consume command-line arguments (e.g. ``'store'``,
781+
``'append'`` or ``'extend'``) can be used with positional arguments.
782+
761783
You may also specify an arbitrary action by passing an Action subclass or
762784
other object that implements the same interface. The ``BooleanOptionalAction``
763785
is available in ``argparse`` and adds support for boolean actions such as
@@ -885,6 +907,8 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are:
885907
If the ``nargs`` keyword argument is not provided, the number of arguments consumed
886908
is determined by the action_. Generally this means a single command-line argument
887909
will be consumed and a single item (not a list) will be produced.
910+
Actions that do not consume command-line arguments (e.g.
911+
``'store_const'``) set ``nargs=0``.
888912

889913

890914
.. _const:

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ other coroutines::
158158
# Nothing happens if we just call "nested()".
159159
# A coroutine object is created but not awaited,
160160
# so it *won't run at all*.
161-
nested()
161+
nested() # will raise a "RuntimeWarning".
162162

163163
# Let's do it differently now and await it:
164164
print(await nested()) # will print "42".

Doc/library/gzip.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ The module defines the following items:
184184
attribute instead.
185185

186186

187-
.. function:: compress(data, compresslevel=9, *, mtime=None)
187+
.. function:: compress(data, compresslevel=9, *, mtime=0)
188188

189189
Compress the *data*, returning a :class:`bytes` object containing
190190
the compressed data. *compresslevel* and *mtime* have the same meaning as in
191-
the :class:`GzipFile` constructor above.
191+
the :class:`GzipFile` constructor above,
192+
but *mtime* defaults to 0 for reproducible output.
192193

193194
.. versionadded:: 3.2
194195
.. versionchanged:: 3.8
@@ -203,6 +204,10 @@ The module defines the following items:
203204
.. versionchanged:: 3.13
204205
The gzip header OS byte is guaranteed to be set to 255 when this function
205206
is used as was the case in 3.10 and earlier.
207+
.. versionchanged:: 3.14
208+
The *mtime* parameter now defaults to 0 for reproducible output.
209+
For the previous behaviour of using the current time,
210+
pass ``None`` to *mtime*.
206211

207212
.. function:: decompress(data)
208213

Doc/library/string.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,8 @@ The available presentation types for :class:`float` and
509509
| | significant digits. With no precision given, uses a |
510510
| | precision of ``6`` digits after the decimal point for |
511511
| | :class:`float`, and shows all coefficient digits |
512-
| | for :class:`~decimal.Decimal`. If no digits follow the |
513-
| | decimal point, the decimal point is also removed unless |
514-
| | the ``#`` option is used. |
512+
| | for :class:`~decimal.Decimal`. If ``p=0``, the decimal |
513+
| | point is omitted unless the ``#`` option is used. |
515514
+---------+----------------------------------------------------------+
516515
| ``'E'`` | Scientific notation. Same as ``'e'`` except it uses |
517516
| | an upper case 'E' as the separator character. |
@@ -522,9 +521,8 @@ The available presentation types for :class:`float` and
522521
| | precision given, uses a precision of ``6`` digits after |
523522
| | the decimal point for :class:`float`, and uses a |
524523
| | precision large enough to show all coefficient digits |
525-
| | for :class:`~decimal.Decimal`. If no digits follow the |
526-
| | decimal point, the decimal point is also removed unless |
527-
| | the ``#`` option is used. |
524+
| | for :class:`~decimal.Decimal`. If ``p=0``, the decimal |
525+
| | point is omitted unless the ``#`` option is used. |
528526
+---------+----------------------------------------------------------+
529527
| ``'F'`` | Fixed-point notation. Same as ``'f'``, but converts |
530528
| | ``nan`` to ``NAN`` and ``inf`` to ``INF``. |

Doc/tutorial/controlflow.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ Defining Functions
461461
We can create a function that writes the Fibonacci series to an arbitrary
462462
boundary::
463463

464-
>>> def fib(n): # write Fibonacci series up to n
465-
... """Print a Fibonacci series up to n."""
464+
>>> def fib(n): # write Fibonacci series less than n
465+
... """Print a Fibonacci series less than n."""
466466
... a, b = 0, 1
467467
... while a < n:
468468
... print(a, end=' ')
@@ -832,7 +832,7 @@ parameters as there is a ``/`` in the function definition::
832832
File "<stdin>", line 1, in <module>
833833
TypeError: pos_only_arg() got some positional-only arguments passed as keyword arguments: 'arg'
834834

835-
The third function ``kwd_only_args`` only allows keyword arguments as indicated
835+
The third function ``kwd_only_arg`` only allows keyword arguments as indicated
836836
by a ``*`` in the function definition::
837837

838838
>>> kwd_only_arg(3)

Doc/tutorial/datastructures.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ objects:
1919
.. method:: list.append(x)
2020
:noindex:
2121

22-
Add an item to the end of the list. Equivalent to ``a[len(a):] = [x]``.
22+
Add an item to the end of the list. Similar to ``a[len(a):] = [x]``.
2323

2424

2525
.. method:: list.extend(iterable)
2626
:noindex:
2727

28-
Extend the list by appending all the items from the iterable. Equivalent to
28+
Extend the list by appending all the items from the iterable. Similar to
2929
``a[len(a):] = iterable``.
3030

3131

@@ -56,7 +56,7 @@ objects:
5656
.. method:: list.clear()
5757
:noindex:
5858

59-
Remove all items from the list. Equivalent to ``del a[:]``.
59+
Remove all items from the list. Similar to ``del a[:]``.
6060

6161

6262
.. method:: list.index(x[, start[, end]])
@@ -93,7 +93,7 @@ objects:
9393
.. method:: list.copy()
9494
:noindex:
9595

96-
Return a shallow copy of the list. Equivalent to ``a[:]``.
96+
Return a shallow copy of the list. Similar to ``a[:]``.
9797

9898

9999
An example that uses most of the list methods::

Doc/tutorial/venv.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ virtual environment you're using, and modify the environment so that running
7676
``python`` will get you that particular version and installation of Python.
7777
For example:
7878

79-
.. code-block:: bash
79+
.. code-block:: console
8080
8181
$ source ~/envs/tutorial-env/bin/activate
8282
(tutorial-env) $ python
@@ -108,7 +108,7 @@ complete documentation for ``pip``.)
108108

109109
You can install the latest version of a package by specifying a package's name:
110110

111-
.. code-block:: bash
111+
.. code-block:: console
112112
113113
(tutorial-env) $ python -m pip install novas
114114
Collecting novas
@@ -120,7 +120,7 @@ You can install the latest version of a package by specifying a package's name:
120120
You can also install a specific version of a package by giving the
121121
package name followed by ``==`` and the version number:
122122

123-
.. code-block:: bash
123+
.. code-block:: console
124124
125125
(tutorial-env) $ python -m pip install requests==2.6.0
126126
Collecting requests==2.6.0
@@ -133,7 +133,7 @@ version is already installed and do nothing. You can supply a
133133
different version number to get that version, or you can run ``python
134134
-m pip install --upgrade`` to upgrade the package to the latest version:
135135

136-
.. code-block:: bash
136+
.. code-block:: console
137137
138138
(tutorial-env) $ python -m pip install --upgrade requests
139139
Collecting requests
@@ -148,7 +148,7 @@ remove the packages from the virtual environment.
148148

149149
``python -m pip show`` will display information about a particular package:
150150

151-
.. code-block:: bash
151+
.. code-block:: console
152152
153153
(tutorial-env) $ python -m pip show requests
154154
---
@@ -166,7 +166,7 @@ remove the packages from the virtual environment.
166166
``python -m pip list`` will display all of the packages installed in
167167
the virtual environment:
168168

169-
.. code-block:: bash
169+
.. code-block:: console
170170
171171
(tutorial-env) $ python -m pip list
172172
novas (3.1.1.3)
@@ -179,7 +179,7 @@ the virtual environment:
179179
but the output uses the format that ``python -m pip install`` expects.
180180
A common convention is to put this list in a ``requirements.txt`` file:
181181

182-
.. code-block:: bash
182+
.. code-block:: console
183183
184184
(tutorial-env) $ python -m pip freeze > requirements.txt
185185
(tutorial-env) $ cat requirements.txt
@@ -191,7 +191,7 @@ The ``requirements.txt`` can then be committed to version control and
191191
shipped as part of an application. Users can then install all the
192192
necessary packages with ``install -r``:
193193

194-
.. code-block:: bash
194+
.. code-block:: console
195195
196196
(tutorial-env) $ python -m pip install -r requirements.txt
197197
Collecting novas==3.1.1.3 (from -r requirements.txt (line 1))

Include/cpython/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef enum {
5252
* if the callback returns with an exception set, it must return -1. Otherwise
5353
* it should return 0
5454
*/
55-
typedef int (*PyContext_WatchCallback)(PyContextEvent, PyContext *);
55+
typedef int (*PyContext_WatchCallback)(PyContextEvent, PyObject *);
5656

5757
/*
5858
* Register a per-interpreter callback that will be invoked for context object

Include/internal/pycore_interp.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ struct _is {
102102
PyInterpreterState *next;
103103

104104
int64_t id;
105-
int64_t id_refcount;
105+
Py_ssize_t id_refcount;
106106
int requires_idref;
107-
PyThread_type_lock id_mutex;
108107

109108
#define _PyInterpreterState_WHENCE_NOTSET -1
110109
#define _PyInterpreterState_WHENCE_UNKNOWN 0
@@ -318,8 +317,7 @@ _PyInterpreterState_SetFinalizing(PyInterpreterState *interp, PyThreadState *tst
318317
PyAPI_FUNC(int64_t) _PyInterpreterState_ObjectToID(PyObject *);
319318
PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(int64_t);
320319
PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpIDObject(PyObject *);
321-
PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *);
322-
PyAPI_FUNC(int) _PyInterpreterState_IDIncref(PyInterpreterState *);
320+
PyAPI_FUNC(void) _PyInterpreterState_IDIncref(PyInterpreterState *);
323321
PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *);
324322

325323
PyAPI_FUNC(int) _PyInterpreterState_IsReady(PyInterpreterState *interp);

Include/internal/pycore_lock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ PyMutex_LockFlags(PyMutex *m, _PyLockFlags flags)
6464
}
6565
}
6666

67-
// Unlock a mutex, returns 0 if the mutex is not locked (used for improved
68-
// error messages).
67+
// Unlock a mutex, returns -1 if the mutex is not locked (used for improved
68+
// error messages) otherwise returns 0.
6969
extern int _PyMutex_TryUnlock(PyMutex *m);
7070

7171

0 commit comments

Comments
 (0)