[Python-checkins] gh-89427: Provide the original prompt value for VIRTUAL_ENV_PROMPT (GH-106726)

2024-01-23 Thread vsajip
https://github.com/python/cpython/commit/8edc8029def8040ebe1caf75d815439156dd2124
commit: 8edc8029def8040ebe1caf75d815439156dd2124
branch: main
author: Jim Porter <[email protected]>
committer: vsajip 
date: 2024-01-23T08:53:04Z
summary:

gh-89427: Provide the original prompt value for VIRTUAL_ENV_PROMPT (GH-106726)

This improves the implementation in gh-106643.

Previously, venv passed "() " to the activation scripts, but we want
to provide the original value so that users can inspect it in the
$VIRTUAL_ENV_PROMPT env var.

Note: Lib/venv/scripts/common/Activate.ps1 surrounded the prompt value with
parens a second time, so no change was necessary in that file.

files:
M Lib/test/test_venv.py
M Lib/venv/__init__.py
M Lib/venv/scripts/common/activate
M Lib/venv/scripts/nt/activate.bat
M Lib/venv/scripts/posix/activate.csh
M Lib/venv/scripts/posix/activate.fish

diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 6852625c36c62b..6dda00efd7bbb6 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -169,7 +169,7 @@ def test_config_file_command_key(self):
 ('--clear', 'clear', True),
 ('--upgrade', 'upgrade', True),
 ('--upgrade-deps', 'upgrade_deps', True),
-('--prompt', 'prompt', True),
+('--prompt="foobar"', 'prompt', 'foobar'),
 ('--without-scm-ignore-files', 'scm_ignore_files', frozenset()),
 ]
 for opt, attr, value in options:
@@ -201,7 +201,7 @@ def test_prompt(self):
 self.run_with_capture(builder.create, self.env_dir)
 context = builder.ensure_directories(self.env_dir)
 data = self.get_text_file_contents('pyvenv.cfg')
-self.assertEqual(context.prompt, '(%s) ' % env_name)
+self.assertEqual(context.prompt, env_name)
 self.assertNotIn("prompt = ", data)
 
 rmtree(self.env_dir)
@@ -209,7 +209,7 @@ def test_prompt(self):
 self.run_with_capture(builder.create, self.env_dir)
 context = builder.ensure_directories(self.env_dir)
 data = self.get_text_file_contents('pyvenv.cfg')
-self.assertEqual(context.prompt, '(My prompt) ')
+self.assertEqual(context.prompt, 'My prompt')
 self.assertIn("prompt = 'My prompt'\n", data)
 
 rmtree(self.env_dir)
@@ -218,7 +218,7 @@ def test_prompt(self):
 self.run_with_capture(builder.create, self.env_dir)
 context = builder.ensure_directories(self.env_dir)
 data = self.get_text_file_contents('pyvenv.cfg')
-self.assertEqual(context.prompt, '(%s) ' % cwd)
+self.assertEqual(context.prompt, cwd)
 self.assertIn("prompt = '%s'\n" % cwd, data)
 
 def test_upgrade_dependencies(self):
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index f04ca8fafcc33b..4856594755ae57 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -129,8 +129,7 @@ def create_if_needed(d):
 context = types.SimpleNamespace()
 context.env_dir = env_dir
 context.env_name = os.path.split(env_dir)[1]
-prompt = self.prompt if self.prompt is not None else context.env_name
-context.prompt = '(%s) ' % prompt
+context.prompt = self.prompt if self.prompt is not None else 
context.env_name
 create_if_needed(env_dir)
 executable = sys._base_executable
 if not executable:  # see gh-96861
diff --git a/Lib/venv/scripts/common/activate b/Lib/venv/scripts/common/activate
index a4e0609045a9d5..cbd4873f012246 100644
--- a/Lib/venv/scripts/common/activate
+++ b/Lib/venv/scripts/common/activate
@@ -66,7 +66,7 @@ fi
 
 if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
 _OLD_VIRTUAL_PS1="${PS1:-}"
-PS1="__VENV_PROMPT__${PS1:-}"
+PS1="(__VENV_PROMPT__) ${PS1:-}"
 export PS1
 fi
 
diff --git a/Lib/venv/scripts/nt/activate.bat b/Lib/venv/scripts/nt/activate.bat
index c1c3c82ee37f10..2c98122362a060 100644
--- a/Lib/venv/scripts/nt/activate.bat
+++ b/Lib/venv/scripts/nt/activate.bat
@@ -16,7 +16,7 @@ if defined _OLD_VIRTUAL_PROMPT set 
PROMPT=%_OLD_VIRTUAL_PROMPT%
 if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
 
 set _OLD_VIRTUAL_PROMPT=%PROMPT%
-set PROMPT=__VENV_PROMPT__%PROMPT%
+set PROMPT=(__VENV_PROMPT__) %PROMPT%
 
 if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
 set PYTHONHOME=
diff --git a/Lib/venv/scripts/posix/activate.csh 
b/Lib/venv/scripts/posix/activate.csh
index 9caf138a919a86..c707f1988b0acc 100644
--- a/Lib/venv/scripts/posix/activate.csh
+++ b/Lib/venv/scripts/posix/activate.csh
@@ -19,7 +19,7 @@ setenv VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
 set _OLD_VIRTUAL_PROMPT="$prompt"
 
 if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
-set prompt = "__VENV_PROMPT__$prompt"
+set prompt = "(__VENV_PROMPT__) $prompt"
 endif
 
 alias pydoc python -m pydoc
diff --git a/Lib/venv/scripts/posix/activate.fish 
b/Lib/venv/scripts/posix/activate.fish
index 565df23d1e2a13..25c42756789bbc 100644
--- a

[Python-checkins] [3.11] Docs: align usage of versionadded/versionchanged with recommended practice (#114409) (#114473)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/eb94a0426fa8c8c4f7de7426a647def6c792f3c4
commit: eb94a0426fa8c8c4f7de7426a647def6c792f3c4
branch: 3.11
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-23T10:39:25+01:00
summary:

[3.11] Docs: align usage of versionadded/versionchanged with recommended 
practice (#114409) (#114473)

(cherry picked from commit 1d7bddd9612bcbaaedbc837e2936de773e855411)

Co-authored-by: C.A.M. Gerlach 
Co-authored-by: Ezio Melotti 

files:
M Doc/library/argparse.rst
M Doc/library/asyncio-stream.rst
M Doc/library/bdb.rst
M Doc/library/concurrent.futures.rst
M Doc/library/configparser.rst
M Doc/library/datetime.rst
M Doc/library/difflib.rst
M Doc/library/email.policy.rst
M Doc/library/functions.rst
M Doc/library/functools.rst
M Doc/library/http.client.rst
M Doc/library/http.server.rst
M Doc/library/logging.config.rst
M Doc/library/logging.handlers.rst
M Doc/library/os.rst
M Doc/library/pdb.rst
M Doc/library/pickletools.rst
M Doc/library/shutil.rst
M Doc/library/subprocess.rst
M Doc/library/urllib.parse.rst
M Doc/library/venv.rst
M Doc/library/xml.etree.elementtree.rst
M Doc/library/xml.sax.utils.rst
M Doc/library/zipapp.rst
M Doc/library/zipfile.rst

diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 19c510fccf050c..6da873027f7785 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1923,8 +1923,8 @@ FileType objects
   >>> parser.parse_args(['-'])
   Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)
 
-   .. versionadded:: 3.4
-  The *encodings* and *errors* keyword arguments.
+   .. versionchanged:: 3.4
+  Added the *encodings* and *errors* parameters.
 
 
 Argument groups
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index 4f7da27fbd350e..20739ca4f19221 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -77,8 +77,8 @@ and work with streams:
.. versionchanged:: 3.7
   Added the *ssl_handshake_timeout* parameter.
 
-   .. versionadded:: 3.8
-  Added *happy_eyeballs_delay* and *interleave* parameters.
+   .. versionchanged:: 3.8
+  Added the *happy_eyeballs_delay* and *interleave* parameters.
 
.. versionchanged:: 3.10
   Removed the *loop* parameter.
diff --git a/Doc/library/bdb.rst b/Doc/library/bdb.rst
index 4ce5c9bcde38ff..52f0ca7c013482 100644
--- a/Doc/library/bdb.rst
+++ b/Doc/library/bdb.rst
@@ -132,8 +132,8 @@ The :mod:`bdb` module also defines two classes:
frame is considered to originate in a certain module is determined
by the ``__name__`` in the frame globals.
 
-   .. versionadded:: 3.1
-  The *skip* argument.
+   .. versionchanged:: 3.1
+  Added the *skip* parameter.
 
The following methods of :class:`Bdb` normally don't need to be overridden.
 
diff --git a/Doc/library/concurrent.futures.rst 
b/Doc/library/concurrent.futures.rst
index 426ff2bf4ccce0..7c38d73488d59e 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -171,8 +171,8 @@ And::
   should be higher than the number of workers
   for :class:`ProcessPoolExecutor`.
 
-   .. versionadded:: 3.6
-  The *thread_name_prefix* argument was added to allow users to
+   .. versionchanged:: 3.6
+  Added the *thread_name_prefix* parameter to allow users to
   control the :class:`threading.Thread` names for worker threads created by
   the pool for easier debugging.
 
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index f6e17908a7e29e..25641a212ab9c9 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -1045,14 +1045,14 @@ ConfigParser Objects
  config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],
  encoding='cp1250')
 
-  .. versionadded:: 3.2
- The *encoding* parameter.  Previously, all files were read using the
- default encoding for :func:`open`.
+  .. versionchanged:: 3.2
+ Added the *encoding* parameter.
+ Previously, all files were read using the default encoding for 
:func:`open`.
 
-  .. versionadded:: 3.6.1
+  .. versionchanged:: 3.6.1
  The *filenames* parameter accepts a :term:`path-like object`.
 
-  .. versionadded:: 3.7
+  .. versionchanged:: 3.7
  The *filenames* parameter accepts a :class:`bytes` object.
 
 
@@ -1313,9 +1313,9 @@ Exceptions
that is already present or in strict parsers when a section if found more
than once in a single input file, string or dictionary.
 
-   .. versionadded:: 3.2
-  Optional ``source`` and ``lineno`` attributes and arguments to
-  :meth:`!__init__` were added.
+   .. versionchanged:: 3.2
+  Added the optional *source* and *lineno* attributes and parameters to
+  :meth:`!__init__`.
 
 
 .. exception:: DuplicateOptionError
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 28a366cb7501f8..164836b0e1e49a 100644
--- a/Doc/libr

[Python-checkins] [3.12] Docs: align usage of versionadded/versionchanged with recommended practice (#114409) (#114472)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/3efcf6673e46507e144e859fa9a33d1820380b9a
commit: 3efcf6673e46507e144e859fa9a33d1820380b9a
branch: 3.12
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-23T10:39:57+01:00
summary:

[3.12] Docs: align usage of versionadded/versionchanged with recommended 
practice (#114409) (#114472)

(cherry picked from commit 1d7bddd9612bcbaaedbc837e2936de773e855411)

Co-authored-by: C.A.M. Gerlach 
Co-authored-by: Ezio Melotti 

files:
M Doc/library/argparse.rst
M Doc/library/asyncio-stream.rst
M Doc/library/bdb.rst
M Doc/library/concurrent.futures.rst
M Doc/library/configparser.rst
M Doc/library/datetime.rst
M Doc/library/difflib.rst
M Doc/library/email.policy.rst
M Doc/library/functions.rst
M Doc/library/functools.rst
M Doc/library/http.client.rst
M Doc/library/http.server.rst
M Doc/library/logging.config.rst
M Doc/library/logging.handlers.rst
M Doc/library/logging.rst
M Doc/library/os.rst
M Doc/library/pdb.rst
M Doc/library/pickletools.rst
M Doc/library/shutil.rst
M Doc/library/subprocess.rst
M Doc/library/unittest.rst
M Doc/library/urllib.parse.rst
M Doc/library/venv.rst
M Doc/library/xml.etree.elementtree.rst
M Doc/library/xml.sax.utils.rst
M Doc/library/zipapp.rst
M Doc/library/zipfile.rst

diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index fbffa71d200735..1395d457f874b0 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1936,8 +1936,8 @@ FileType objects
   >>> parser.parse_args(['-'])
   Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)
 
-   .. versionadded:: 3.4
-  The *encodings* and *errors* keyword arguments.
+   .. versionchanged:: 3.4
+  Added the *encodings* and *errors* parameters.
 
 
 Argument groups
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index 91e5ba2f30e340..3ce6f4fa7d7e1e 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -77,8 +77,8 @@ and work with streams:
.. versionchanged:: 3.7
   Added the *ssl_handshake_timeout* parameter.
 
-   .. versionadded:: 3.8
-  Added *happy_eyeballs_delay* and *interleave* parameters.
+   .. versionchanged:: 3.8
+  Added the *happy_eyeballs_delay* and *interleave* parameters.
 
.. versionchanged:: 3.10
   Removed the *loop* parameter.
diff --git a/Doc/library/bdb.rst b/Doc/library/bdb.rst
index 4ce5c9bcde38ff..52f0ca7c013482 100644
--- a/Doc/library/bdb.rst
+++ b/Doc/library/bdb.rst
@@ -132,8 +132,8 @@ The :mod:`bdb` module also defines two classes:
frame is considered to originate in a certain module is determined
by the ``__name__`` in the frame globals.
 
-   .. versionadded:: 3.1
-  The *skip* argument.
+   .. versionchanged:: 3.1
+  Added the *skip* parameter.
 
The following methods of :class:`Bdb` normally don't need to be overridden.
 
diff --git a/Doc/library/concurrent.futures.rst 
b/Doc/library/concurrent.futures.rst
index cc6df06e74cf27..4059bdb54fc411 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -171,8 +171,8 @@ And::
   should be higher than the number of workers
   for :class:`ProcessPoolExecutor`.
 
-   .. versionadded:: 3.6
-  The *thread_name_prefix* argument was added to allow users to
+   .. versionchanged:: 3.6
+  Added the *thread_name_prefix* parameter to allow users to
   control the :class:`threading.Thread` names for worker threads created by
   the pool for easier debugging.
 
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 0031737853e7b4..18e5bc20f3f690 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -1045,14 +1045,14 @@ ConfigParser Objects
  config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],
  encoding='cp1250')
 
-  .. versionadded:: 3.2
- The *encoding* parameter.  Previously, all files were read using the
- default encoding for :func:`open`.
+  .. versionchanged:: 3.2
+ Added the *encoding* parameter.
+ Previously, all files were read using the default encoding for 
:func:`open`.
 
-  .. versionadded:: 3.6.1
+  .. versionchanged:: 3.6.1
  The *filenames* parameter accepts a :term:`path-like object`.
 
-  .. versionadded:: 3.7
+  .. versionchanged:: 3.7
  The *filenames* parameter accepts a :class:`bytes` object.
 
 
@@ -1291,9 +1291,9 @@ Exceptions
that is already present or in strict parsers when a section if found more
than once in a single input file, string or dictionary.
 
-   .. versionadded:: 3.2
-  Optional ``source`` and ``lineno`` attributes and arguments to
-  :meth:`!__init__` were added.
+   .. versionchanged:: 3.2
+  Added the optional *source* and *lineno* attributes and parameters to
+  :meth:`!__init__`.
 
 
 .. exception:: DuplicateOptionError
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index

[Python-checkins] gh-113317: Don't use global clinic instance in bad_argument() (#114330)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/e14930ff6397439759eb34ca70a3493baa845014
commit: e14930ff6397439759eb34ca70a3493baa845014
branch: main
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-23T11:07:56+01:00
summary:

gh-113317: Don't use global clinic instance in bad_argument() (#114330)

Make it possible for a converter to have multiple includes, by collecting
them in a list on the converter instance. This implies converter includes
are added during template generation, so we have to add them to the
clinic instance at the end of the template generation instead of in the
beginning.

files:
M Tools/clinic/clinic.py

diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index c247bd075321cd..770878a3f8d2c7 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -818,12 +818,6 @@ def output_templates(
 del parameters[0]
 converters = [p.converter for p in parameters]
 
-# Copy includes from parameters to Clinic
-for converter in converters:
-include = converter.include
-if include:
-clinic.add_include(include.filename, include.reason,
-   condition=include.condition)
 if f.critical_section:
 clinic.add_include('pycore_critical_section.h', 
'Py_BEGIN_CRITICAL_SECTION()')
 has_option_groups = parameters and (parameters[0].group or 
parameters[-1].group)
@@ -1367,6 +1361,13 @@ def parser_body(
 declarations=declarations)
 
 
+# Copy includes from parameters to Clinic after parse_arg() has been
+# called above.
+for converter in converters:
+for include in converter.includes:
+clinic.add_include(include.filename, include.reason,
+   condition=include.condition)
+
 if new_or_init:
 methoddef_define = ''
 
@@ -2988,7 +2989,6 @@ class CConverter(metaclass=CConverterAutoRegister):
 # Only set by self_converter.
 signature_name: str | None = None
 
-include: Include | None = None
 broken_limited_capi: bool = False
 
 # keep in sync with self_converter.__init__!
@@ -3008,6 +3008,7 @@ def __init__(self,
 self.name = ensure_legal_c_identifier(name)
 self.py_name = py_name
 self.unused = unused
+self.includes: list[Include] = []
 
 if default is not unspecified:
 if (self.default_type
@@ -3263,8 +3264,7 @@ def bad_argument(self, displayname: str, expected: str, 
*, limited_capi: bool, e
 else:
 if expected_literal:
 expected = f'"{expected}"'
-if clinic is not None:
-clinic.add_include('pycore_modsupport.h', 
'_PyArg_BadArgument()')
+self.add_include('pycore_modsupport.h', '_PyArg_BadArgument()')
 return f'_PyArg_BadArgument("name", "{displayname}", 
{expected}, {{argname}});'
 
 def format_code(self, fmt: str, *,
@@ -3336,9 +3336,8 @@ def parser_name(self) -> str:
 
 def add_include(self, name: str, reason: str,
 *, condition: str | None = None) -> None:
-if self.include is not None:
-raise ValueError("a converter only supports a single include")
-self.include = Include(name, reason, condition)
+include = Include(name, reason, condition)
+self.includes.append(include)
 
 type_checks = {
 '&PyLong_Type': ('PyLong_Check', 'int'),

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (#114425)

2024-01-23 Thread hugovk
https://github.com/python/cpython/commit/7d21cae964fc47afda400fc1fbbcf7984fcfe819
commit: 7d21cae964fc47afda400fc1fbbcf7984fcfe819
branch: main
author: Nikita Sobolev 
committer: hugovk <[email protected]>
date: 2024-01-23T13:05:27+02:00
summary:

gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (#114425)

* gh-101100: Fix sphinx warnings in `Doc/library/locale.rst`

* Remove `/` from signatures

files:
M Doc/library/locale.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst
index a7201199191215..414979524e57b6 100644
--- a/Doc/library/locale.rst
+++ b/Doc/library/locale.rst
@@ -18,7 +18,7 @@ know all the specifics of each country where the software is 
executed.
 
 .. index:: pair: module; _locale
 
-The :mod:`locale` module is implemented on top of the :mod:`_locale` module,
+The :mod:`locale` module is implemented on top of the :mod:`!_locale` module,
 which in turn uses an ANSI C locale implementation if available.
 
 The :mod:`locale` module defines the following exception and functions:
@@ -192,7 +192,13 @@ The :mod:`locale` module defines the following exception 
and functions:
   Get a format string for :func:`time.strftime` to represent time in the 
am/pm
   format.
 
-   .. data:: DAY_1 ... DAY_7
+   .. data:: DAY_1
+ DAY_2
+ DAY_3
+ DAY_4
+ DAY_5
+ DAY_6
+ DAY_7
 
   Get the name of the n-th day of the week.
 
@@ -202,15 +208,43 @@ The :mod:`locale` module defines the following exception 
and functions:
  international convention (ISO 8601) that Monday is the first day of 
the
  week.
 
-   .. data:: ABDAY_1 ... ABDAY_7
+   .. data:: ABDAY_1
+ ABDAY_2
+ ABDAY_3
+ ABDAY_4
+ ABDAY_5
+ ABDAY_6
+ ABDAY_7
 
   Get the abbreviated name of the n-th day of the week.
 
-   .. data:: MON_1 ... MON_12
+   .. data:: MON_1
+ MON_2
+ MON_3
+ MON_4
+ MON_5
+ MON_6
+ MON_7
+ MON_8
+ MON_9
+ MON_10
+ MON_11
+ MON_12
 
   Get the name of the n-th month.
 
-   .. data:: ABMON_1 ... ABMON_12
+   .. data:: ABMON_1
+ ABMON_2
+ ABMON_3
+ ABMON_4
+ ABMON_5
+ ABMON_6
+ ABMON_7
+ ABMON_8
+ ABMON_9
+ ABMON_10
+ ABMON_11
+ ABMON_12
 
   Get the abbreviated name of the n-th month.
 
@@ -229,14 +263,14 @@ The :mod:`locale` module defines the following exception 
and functions:
 
.. data:: NOEXPR
 
-  Get a regular expression that can be used with the regex(3) function to
+  Get a regular expression that can be used with the ``regex(3)`` function 
to
   recognize a negative response to a yes/no question.
 
   .. note::
 
  The regular expressions for :const:`YESEXPR` and
  :const:`NOEXPR` use syntax suitable for the
- :c:func:`regex` function from the C library, which might
+ ``regex`` function from the C library, which might
  differ from the syntax used in :mod:`re`.
 
.. data:: CRNCYSTR
@@ -581,9 +615,9 @@ the locale is ``C``).
 
 When Python code uses the :mod:`locale` module to change the locale, this also
 affects the embedding application.  If the embedding application doesn't want
-this to happen, it should remove the :mod:`_locale` extension module (which 
does
+this to happen, it should remove the :mod:`!_locale` extension module (which 
does
 all the work) from the table of built-in modules in the :file:`config.c` file,
-and make sure that the :mod:`_locale` module is not accessible as a shared
+and make sure that the :mod:`!_locale` module is not accessible as a shared
 library.
 
 
@@ -597,17 +631,18 @@ Access to message catalogs
 .. function:: dcgettext(domain, msg, category)
 .. function:: textdomain(domain)
 .. function:: bindtextdomain(domain, dir)
+.. function:: bind_textdomain_codeset(domain, codeset)
 
 The locale module exposes the C library's gettext interface on systems that
-provide this interface.  It consists of the functions :func:`!gettext`,
-:func:`!dgettext`, :func:`!dcgettext`, :func:`!textdomain`, 
:func:`!bindtextdomain`,
-and :func:`!bind_textdomain_codeset`.  These are similar to the same functions 
in
+provide this interface.  It consists of the functions :func:`gettext`,
+:func:`dgettext`, :func:`dcgettext`, :func:`textdomain`, 
:func:`bindtextdomain`,
+and :func:`bind_textdomain_codeset`.  These are similar to the same functions 
in
 the :mod:`gettext` module, but use the C library's binary format for message
 catalogs, and the C library's search algorithms for locating message catalogs.
 
 Python applications should normally find no need to invoke these functions, and
 should use :mod:`gettext` instead.  A known excep

[Python-checkins] [3.12] gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (GH-114425) (#114477)

2024-01-23 Thread hugovk
https://github.com/python/cpython/commit/1b9abe4acc61c161afda23be30f597aed4c27c22
commit: 1b9abe4acc61c161afda23be30f597aed4c27c22
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2024-01-23T13:23:31+02:00
summary:

[3.12] gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (GH-114425) 
(#114477)

gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (GH-114425)

* gh-101100: Fix sphinx warnings in `Doc/library/locale.rst`

* Remove `/` from signatures
(cherry picked from commit 7d21cae964fc47afda400fc1fbbcf7984fcfe819)

Co-authored-by: Nikita Sobolev 

files:
M Doc/library/locale.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst
index 69567484712ad3..7c87c52d040e46 100644
--- a/Doc/library/locale.rst
+++ b/Doc/library/locale.rst
@@ -18,7 +18,7 @@ know all the specifics of each country where the software is 
executed.
 
 .. index:: pair: module; _locale
 
-The :mod:`locale` module is implemented on top of the :mod:`_locale` module,
+The :mod:`locale` module is implemented on top of the :mod:`!_locale` module,
 which in turn uses an ANSI C locale implementation if available.
 
 The :mod:`locale` module defines the following exception and functions:
@@ -192,7 +192,13 @@ The :mod:`locale` module defines the following exception 
and functions:
   Get a format string for :func:`time.strftime` to represent time in the 
am/pm
   format.
 
-   .. data:: DAY_1 ... DAY_7
+   .. data:: DAY_1
+ DAY_2
+ DAY_3
+ DAY_4
+ DAY_5
+ DAY_6
+ DAY_7
 
   Get the name of the n-th day of the week.
 
@@ -202,15 +208,43 @@ The :mod:`locale` module defines the following exception 
and functions:
  international convention (ISO 8601) that Monday is the first day of 
the
  week.
 
-   .. data:: ABDAY_1 ... ABDAY_7
+   .. data:: ABDAY_1
+ ABDAY_2
+ ABDAY_3
+ ABDAY_4
+ ABDAY_5
+ ABDAY_6
+ ABDAY_7
 
   Get the abbreviated name of the n-th day of the week.
 
-   .. data:: MON_1 ... MON_12
+   .. data:: MON_1
+ MON_2
+ MON_3
+ MON_4
+ MON_5
+ MON_6
+ MON_7
+ MON_8
+ MON_9
+ MON_10
+ MON_11
+ MON_12
 
   Get the name of the n-th month.
 
-   .. data:: ABMON_1 ... ABMON_12
+   .. data:: ABMON_1
+ ABMON_2
+ ABMON_3
+ ABMON_4
+ ABMON_5
+ ABMON_6
+ ABMON_7
+ ABMON_8
+ ABMON_9
+ ABMON_10
+ ABMON_11
+ ABMON_12
 
   Get the abbreviated name of the n-th month.
 
@@ -229,14 +263,14 @@ The :mod:`locale` module defines the following exception 
and functions:
 
.. data:: NOEXPR
 
-  Get a regular expression that can be used with the regex(3) function to
+  Get a regular expression that can be used with the ``regex(3)`` function 
to
   recognize a negative response to a yes/no question.
 
   .. note::
 
  The regular expressions for :const:`YESEXPR` and
  :const:`NOEXPR` use syntax suitable for the
- :c:func:`regex` function from the C library, which might
+ ``regex`` function from the C library, which might
  differ from the syntax used in :mod:`re`.
 
.. data:: CRNCYSTR
@@ -591,9 +625,9 @@ the locale is ``C``).
 
 When Python code uses the :mod:`locale` module to change the locale, this also
 affects the embedding application.  If the embedding application doesn't want
-this to happen, it should remove the :mod:`_locale` extension module (which 
does
+this to happen, it should remove the :mod:`!_locale` extension module (which 
does
 all the work) from the table of built-in modules in the :file:`config.c` file,
-and make sure that the :mod:`_locale` module is not accessible as a shared
+and make sure that the :mod:`!_locale` module is not accessible as a shared
 library.
 
 
@@ -607,17 +641,18 @@ Access to message catalogs
 .. function:: dcgettext(domain, msg, category)
 .. function:: textdomain(domain)
 .. function:: bindtextdomain(domain, dir)
+.. function:: bind_textdomain_codeset(domain, codeset)
 
 The locale module exposes the C library's gettext interface on systems that
-provide this interface.  It consists of the functions :func:`!gettext`,
-:func:`!dgettext`, :func:`!dcgettext`, :func:`!textdomain`, 
:func:`!bindtextdomain`,
-and :func:`!bind_textdomain_codeset`.  These are similar to the same functions 
in
+provide this interface.  It consists of the functions :func:`gettext`,
+:func:`dgettext`, :func:`dcgettext`, :func:`textdomain`, 
:func:`bindtextdomain`,
+and :func:`bind_textdomain_codeset`.  These are similar to the same functions 
in
 the :mod:`gettext` module, but use the C

[Python-checkins] [3.11] gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (GH-114425) (#114478)

2024-01-23 Thread hugovk
https://github.com/python/cpython/commit/b62db465e5e7f8fba2a5e506ea27aadbf6391225
commit: b62db465e5e7f8fba2a5e506ea27aadbf6391225
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2024-01-23T13:24:51+02:00
summary:

[3.11] gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (GH-114425) 
(#114478)

gh-101100: Fix sphinx warnings in `Doc/library/locale.rst` (GH-114425)

* gh-101100: Fix sphinx warnings in `Doc/library/locale.rst`

* Remove `/` from signatures
(cherry picked from commit 7d21cae964fc47afda400fc1fbbcf7984fcfe819)

Co-authored-by: Nikita Sobolev 

files:
M Doc/library/locale.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst
index 3a07d2d1f4ce08..4601e8f33b5ef5 100644
--- a/Doc/library/locale.rst
+++ b/Doc/library/locale.rst
@@ -18,7 +18,7 @@ know all the specifics of each country where the software is 
executed.
 
 .. index:: pair: module; _locale
 
-The :mod:`locale` module is implemented on top of the :mod:`_locale` module,
+The :mod:`locale` module is implemented on top of the :mod:`!_locale` module,
 which in turn uses an ANSI C locale implementation if available.
 
 The :mod:`locale` module defines the following exception and functions:
@@ -192,7 +192,13 @@ The :mod:`locale` module defines the following exception 
and functions:
   Get a format string for :func:`time.strftime` to represent time in the 
am/pm
   format.
 
-   .. data:: DAY_1 ... DAY_7
+   .. data:: DAY_1
+ DAY_2
+ DAY_3
+ DAY_4
+ DAY_5
+ DAY_6
+ DAY_7
 
   Get the name of the n-th day of the week.
 
@@ -202,15 +208,43 @@ The :mod:`locale` module defines the following exception 
and functions:
  international convention (ISO 8601) that Monday is the first day of 
the
  week.
 
-   .. data:: ABDAY_1 ... ABDAY_7
+   .. data:: ABDAY_1
+ ABDAY_2
+ ABDAY_3
+ ABDAY_4
+ ABDAY_5
+ ABDAY_6
+ ABDAY_7
 
   Get the abbreviated name of the n-th day of the week.
 
-   .. data:: MON_1 ... MON_12
+   .. data:: MON_1
+ MON_2
+ MON_3
+ MON_4
+ MON_5
+ MON_6
+ MON_7
+ MON_8
+ MON_9
+ MON_10
+ MON_11
+ MON_12
 
   Get the name of the n-th month.
 
-   .. data:: ABMON_1 ... ABMON_12
+   .. data:: ABMON_1
+ ABMON_2
+ ABMON_3
+ ABMON_4
+ ABMON_5
+ ABMON_6
+ ABMON_7
+ ABMON_8
+ ABMON_9
+ ABMON_10
+ ABMON_11
+ ABMON_12
 
   Get the abbreviated name of the n-th month.
 
@@ -229,14 +263,14 @@ The :mod:`locale` module defines the following exception 
and functions:
 
.. data:: NOEXPR
 
-  Get a regular expression that can be used with the regex(3) function to
+  Get a regular expression that can be used with the ``regex(3)`` function 
to
   recognize a negative response to a yes/no question.
 
   .. note::
 
  The regular expressions for :const:`YESEXPR` and
  :const:`NOEXPR` use syntax suitable for the
- :c:func:`regex` function from the C library, which might
+ ``regex`` function from the C library, which might
  differ from the syntax used in :mod:`re`.
 
.. data:: CRNCYSTR
@@ -603,9 +637,9 @@ the locale is ``C``).
 
 When Python code uses the :mod:`locale` module to change the locale, this also
 affects the embedding application.  If the embedding application doesn't want
-this to happen, it should remove the :mod:`_locale` extension module (which 
does
+this to happen, it should remove the :mod:`!_locale` extension module (which 
does
 all the work) from the table of built-in modules in the :file:`config.c` file,
-and make sure that the :mod:`_locale` module is not accessible as a shared
+and make sure that the :mod:`!_locale` module is not accessible as a shared
 library.
 
 
@@ -619,17 +653,18 @@ Access to message catalogs
 .. function:: dcgettext(domain, msg, category)
 .. function:: textdomain(domain)
 .. function:: bindtextdomain(domain, dir)
+.. function:: bind_textdomain_codeset(domain, codeset)
 
 The locale module exposes the C library's gettext interface on systems that
-provide this interface.  It consists of the functions :func:`!gettext`,
-:func:`!dgettext`, :func:`!dcgettext`, :func:`!textdomain`, 
:func:`!bindtextdomain`,
-and :func:`!bind_textdomain_codeset`.  These are similar to the same functions 
in
+provide this interface.  It consists of the functions :func:`gettext`,
+:func:`dgettext`, :func:`dcgettext`, :func:`textdomain`, 
:func:`bindtextdomain`,
+and :func:`bind_textdomain_codeset`.  These are similar to the same functions 
in
 the :mod:`gettext` module, but use the C

[Python-checkins] gh-114423: Remove DummyThread from threading._active when thread dies (GH-114424)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/5a1ecc8cc7d3dfedd14adea1c3cdc3cfeb79f0e1
commit: 5a1ecc8cc7d3dfedd14adea1c3cdc3cfeb79f0e1
branch: main
author: Fabio Zadrozny <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-23T14:12:50+02:00
summary:

gh-114423: Remove DummyThread from threading._active when thread dies 
(GH-114424)

files:
A Misc/NEWS.d/next/Library/2024-01-22-11-43-38.gh-issue-114423.6mMoPH.rst
M Lib/test/test_threading.py
M Lib/threading.py

diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 7160c53d691ba2..dbdc46fff1e313 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -227,8 +227,6 @@ def f():
 tid = _thread.start_new_thread(f, ())
 done.wait()
 self.assertEqual(ident[0], tid)
-# Kill the "immortal" _DummyThread
-del threading._active[ident[0]]
 
 # run with a small(ish) thread stack size (256 KiB)
 def test_various_ops_small_stack(self):
@@ -256,11 +254,29 @@ def test_various_ops_large_stack(self):
 
 def test_foreign_thread(self):
 # Check that a "foreign" thread can use the threading module.
+dummy_thread = None
+error = None
 def f(mutex):
-# Calling current_thread() forces an entry for the foreign
-# thread to get made in the threading._active map.
-threading.current_thread()
-mutex.release()
+try:
+nonlocal dummy_thread
+nonlocal error
+# Calling current_thread() forces an entry for the foreign
+# thread to get made in the threading._active map.
+dummy_thread = threading.current_thread()
+tid = dummy_thread.ident
+self.assertIn(tid, threading._active)
+self.assertIsInstance(dummy_thread, threading._DummyThread)
+self.assertIs(threading._active.get(tid), dummy_thread)
+# gh-29376
+self.assertTrue(
+dummy_thread.is_alive(),
+'Expected _DummyThread to be considered alive.'
+)
+self.assertIn('_DummyThread', repr(dummy_thread))
+except BaseException as e:
+error = e
+finally:
+mutex.release()
 
 mutex = threading.Lock()
 mutex.acquire()
@@ -268,20 +284,25 @@ def f(mutex):
 tid = _thread.start_new_thread(f, (mutex,))
 # Wait for the thread to finish.
 mutex.acquire()
-self.assertIn(tid, threading._active)
-self.assertIsInstance(threading._active[tid], threading._DummyThread)
-#Issue 29376
-self.assertTrue(threading._active[tid].is_alive())
-self.assertRegex(repr(threading._active[tid]), '_DummyThread')
-
+if error is not None:
+raise error
+self.assertEqual(tid, dummy_thread.ident)
 # Issue gh-106236:
 with self.assertRaises(RuntimeError):
-threading._active[tid].join()
-threading._active[tid]._started.clear()
+dummy_thread.join()
+dummy_thread._started.clear()
 with self.assertRaises(RuntimeError):
-threading._active[tid].is_alive()
-
-del threading._active[tid]
+dummy_thread.is_alive()
+# Busy wait for the following condition: after the thread dies, the
+# related dummy thread must be removed from threading._active.
+timeout = 5
+timeout_at = time.monotonic() + timeout
+while time.monotonic() < timeout_at:
+if threading._active.get(dummy_thread.ident) is not dummy_thread:
+break
+time.sleep(.1)
+else:
+self.fail('It was expected that the created threading._DummyThread 
was removed from threading._active.')
 
 # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)
 # exposed at the Python level.  This test relies on ctypes to get at it.
diff --git a/Lib/threading.py b/Lib/threading.py
index c561800a128059..ecf799bc26ab06 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -54,6 +54,13 @@
 TIMEOUT_MAX = _thread.TIMEOUT_MAX
 del _thread
 
+# get thread-local implementation, either from the thread
+# module, or from the python fallback
+
+try:
+from _thread import _local as local
+except ImportError:
+from _threading_local import local
 
 # Support for profile and trace hooks
 
@@ -1476,10 +1483,36 @@ def __init__(self):
 _active[self._ident] = self
 
 
+# Helper thread-local instance to detect when a _DummyThread
+# is collected. Not a part of the public API.
+_thread_local_info = local()
+
+
+class _DeleteDummyThreadOnDel:
+'''
+Helper class to remove a dummy thread from threading._active on __del__.
+'''
+
+def __init__(self, dummy_thread):
+self._dummy_thread = dummy_threa

[Python-checkins] Docs: mark up FTP.retrbinary and FTP.storbinary with param lists (#114399)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/5277d4c7dbd1baee300e494fce2738cee218c243
commit: 5277d4c7dbd1baee300e494fce2738cee218c243
branch: main
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-23T14:53:35+01:00
summary:

Docs: mark up FTP.retrbinary and FTP.storbinary with param lists (#114399)

Co-authored-by: Ezio Melotti 

files:
M Doc/library/ftplib.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst
index 6ff97008c3015b..c7251db50a9371 100644
--- a/Doc/library/ftplib.rst
+++ b/Doc/library/ftplib.rst
@@ -201,14 +201,27 @@ FTP objects
 
.. method:: FTP.retrbinary(cmd, callback, blocksize=8192, rest=None)
 
-  Retrieve a file in binary transfer mode.  *cmd* should be an appropriate
-  ``RETR`` command: ``'RETR filename'``. The *callback* function is called 
for
-  each block of data received, with a single bytes argument giving the data
-  block. The optional *blocksize* argument specifies the maximum chunk 
size to
-  read on the low-level socket object created to do the actual transfer 
(which
-  will also be the largest size of the data blocks passed to *callback*).  
A
-  reasonable default is chosen. *rest* means the same thing as in the
-  :meth:`transfercmd` method.
+  Retrieve a file in binary transfer mode.
+
+  :param str cmd:
+An appropriate ``STOR`` command: :samp:`"STOR {filename}"`.
+
+  :param callback:
+ A single parameter callable that is called
+ for each block of data received,
+ with its single argument being the data as :class:`bytes`.
+  :type callback: :term:`callable`
+
+  :param int blocksize:
+ The maximum chunk size to read on the low-level
+ :class:`~socket.socket` object created to do the actual transfer.
+ This also corresponds to the largest size of data
+ that will be passed to *callback*.
+ Defaults to ``8192``.
+
+  :param int rest:
+ A ``REST`` command to be sent to the server.
+ See the documentation for the *rest* parameter of the 
:meth:`transfercmd` method.
 
 
.. method:: FTP.retrlines(cmd, callback=None)
@@ -232,16 +245,33 @@ FTP objects
 
.. method:: FTP.storbinary(cmd, fp, blocksize=8192, callback=None, 
rest=None)
 
-  Store a file in binary transfer mode.  *cmd* should be an appropriate
-  ``STOR`` command: ``"STOR filename"``. *fp* is a :term:`file object`
-  (opened in binary mode) which is read until EOF using its 
:meth:`~io.IOBase.read`
-  method in blocks of size *blocksize* to provide the data to be stored.
-  The *blocksize* argument defaults to 8192.  *callback* is an optional 
single
-  parameter callable that is called on each block of data after it is sent.
-  *rest* means the same thing as in the :meth:`transfercmd` method.
+  Store a file in binary transfer mode.
+
+  :param str cmd:
+An appropriate ``STOR`` command: :samp:`"STOR {filename}"`.
+
+  :param fp:
+ A file object (opened in binary mode) which is read until EOF,
+ using its :meth:`~io.RawIOBase.read` method in blocks of size 
*blocksize*
+ to provide the data to be stored.
+  :type fp: :term:`file object`
+
+  :param int blocksize:
+ The read block size.
+ Defaults to ``8192``.
+
+  :param callback:
+ A single parameter callable that is called
+ for each block of data sent,
+ with its single argument being the data as :class:`bytes`.
+  :type callback: :term:`callable`
+
+  :param int rest:
+ A ``REST`` command to be sent to the server.
+ See the documentation for the *rest* parameter of the 
:meth:`transfercmd` method.
 
   .. versionchanged:: 3.2
- *rest* parameter added.
+ The *rest* parameter was added.
 
 
.. method:: FTP.storlines(cmd, fp, callback=None)
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index 1b24f145c2f13b..221a1f05c11e49 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -45,7 +45,6 @@ Doc/library/enum.rst
 Doc/library/exceptions.rst
 Doc/library/faulthandler.rst
 Doc/library/fcntl.rst
-Doc/library/ftplib.rst
 Doc/library/functools.rst
 Doc/library/http.cookiejar.rst
 Doc/library/http.server.rst

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] Docs: mark up FTP.connect() and FTP.login() with param lists (#114395)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/01105c7c4f7f01a8b1077008e61d5c7df0ab832b
commit: 01105c7c4f7f01a8b1077008e61d5c7df0ab832b
branch: main
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-23T13:57:23Z
summary:

Docs: mark up FTP.connect() and FTP.login() with param lists (#114395)

Use rst substitutions to reduce raw text duplication.

Co-authored-by: Ezio Melotti 
Co-authored-by: Hugo van Kemenade <[email protected]>

files:
M Doc/library/ftplib.rst

diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst
index c7251db50a9371..e93a1e85598e3a 100644
--- a/Doc/library/ftplib.rst
+++ b/Doc/library/ftplib.rst
@@ -55,38 +55,56 @@ Reference
 FTP objects
 ^^^
 
+.. Use substitutions for some param docs so we don't need to repeat them
+   in multiple places.
+
+.. |param_doc_user| replace::
+   The username to log in with (default: ``'anonymous'``).
+
+.. |param_doc_passwd| replace::
+   The password to use when logging in.
+   If not given, and if *passwd* is the empty string or ``"-"``,
+   a password will be automatically generated.
+
+.. Ideally, we'd like to use the :rfc: directive, but Sphinx will not allow it.
+
+.. |param_doc_acct| replace::
+   Account information to be used for the ``ACCT`` FTP command.
+   Few systems implement this.
+   See `RFC-959 `__
+   for more details.
+
+.. |param_doc_source_address| replace::
+   A 2-tuple ``(host, port)`` for the socket to bind to as its
+   source address before connecting.
+
 .. class:: FTP(host='', user='', passwd='', acct='', timeout=None, \
source_address=None, *, encoding='utf-8')
 
Return a new instance of the :class:`FTP` class.
-   When *host* is given, the method call :meth:`connect(host) `
-   is made by the constructor.
-   When *user* is given, additionally the method call
-   :meth:`login(user, passwd, acct) ` is made.
 
:param str host:
   The hostname to connect to.
+  If given, :code:`connect(host)` is implicitly called by the constructor.
 
:param str user:
-  The username to log in with.
-  If empty string, ``"anonymous"`` is used.
+  |param_doc_user|
+  If given, :code:`login(host, passwd, acct)` is implicitly called
+  by the constructor.
 
:param str passwd:
-  The password to use when logging in.
-  If not given, and if *passwd* is the empty string or ``"-"``,
-  a password will be automatically generated.
+  |param_doc_passwd|
 
:param str acct:
-  Account information; see the ACCT FTP command.
+  |param_doc_acct|
 
:param timeout:
-  A timeout in seconds for blocking operations like :meth:`connect`.
-  If not specified, the global default timeout setting will be used.
+  A timeout in seconds for blocking operations like :meth:`connect`
+  (default: the global default timeout setting).
:type timeout: int | None
 
:param source_address:
-  *source_address* is a 2-tuple ``(host, port)`` for the socket
-  to bind to as its source address before connecting.
+  |param_doc_source_address|
:type source_address: tuple | None
 
:param str encoding:
@@ -140,17 +158,29 @@ FTP objects
 
.. method:: FTP.connect(host='', port=0, timeout=None, source_address=None)
 
-  Connect to the given host and port.  The default port number is ``21``, 
as
-  specified by the FTP protocol specification.  It is rarely needed to 
specify a
-  different port number.  This function should be called only once for each
-  instance; it should not be called at all if a host was given when the 
instance
-  was created.  All other methods can only be used after a connection has 
been
-  made.
-  The optional *timeout* parameter specifies a timeout in seconds for the
-  connection attempt. If no *timeout* is passed, the global default timeout
-  setting will be used.
-  *source_address* is a 2-tuple ``(host, port)`` for the socket to bind to 
as
-  its source address before connecting.
+  Connect to the given host and port.
+  This function should be called only once for each instance;
+  it should not be called if a *host* argument was given
+  when the :class:`FTP` instance was created.
+  All other :class:`!FTP` methods can only be called
+  after a connection has successfully been made.
+
+  :param str host:
+ The host to connect to.
+
+  :param int port:
+ The TCP port to connect to (default: ``21``,
+ as specified by the FTP protocol specification).
+ It is rarely needed to specify a different port number.
+
+  :param timeout:
+ A timeout in seconds for the connection attempt
+ (default: the global default timeout setting).
+  :type timeout: int | None
+
+  :param source_address:
+ |param_doc_source_address|
+  :type source_address: tuple | None
 
   .. audit-event:: ftplib

[Python-checkins] [3.12] Docs: mark up FTP.retrbinary and FTP.storbinary with param lists (GH-114399) (#114483)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/e18ceb7564ee360392c6e5f16191f516c5cd8e98
commit: e18ceb7564ee360392c6e5f16191f516c5cd8e98
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-23T14:00:27Z
summary:

[3.12] Docs: mark up FTP.retrbinary and FTP.storbinary with param lists 
(GH-114399) (#114483)

(cherry picked from commit 5277d4c7dbd1baee300e494fce2738cee218c243)

Co-authored-by: Erlend E. Aasland 
Co-authored-by: Ezio Melotti 

files:
M Doc/library/ftplib.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst
index 6ff97008c3015b..c7251db50a9371 100644
--- a/Doc/library/ftplib.rst
+++ b/Doc/library/ftplib.rst
@@ -201,14 +201,27 @@ FTP objects
 
.. method:: FTP.retrbinary(cmd, callback, blocksize=8192, rest=None)
 
-  Retrieve a file in binary transfer mode.  *cmd* should be an appropriate
-  ``RETR`` command: ``'RETR filename'``. The *callback* function is called 
for
-  each block of data received, with a single bytes argument giving the data
-  block. The optional *blocksize* argument specifies the maximum chunk 
size to
-  read on the low-level socket object created to do the actual transfer 
(which
-  will also be the largest size of the data blocks passed to *callback*).  
A
-  reasonable default is chosen. *rest* means the same thing as in the
-  :meth:`transfercmd` method.
+  Retrieve a file in binary transfer mode.
+
+  :param str cmd:
+An appropriate ``STOR`` command: :samp:`"STOR {filename}"`.
+
+  :param callback:
+ A single parameter callable that is called
+ for each block of data received,
+ with its single argument being the data as :class:`bytes`.
+  :type callback: :term:`callable`
+
+  :param int blocksize:
+ The maximum chunk size to read on the low-level
+ :class:`~socket.socket` object created to do the actual transfer.
+ This also corresponds to the largest size of data
+ that will be passed to *callback*.
+ Defaults to ``8192``.
+
+  :param int rest:
+ A ``REST`` command to be sent to the server.
+ See the documentation for the *rest* parameter of the 
:meth:`transfercmd` method.
 
 
.. method:: FTP.retrlines(cmd, callback=None)
@@ -232,16 +245,33 @@ FTP objects
 
.. method:: FTP.storbinary(cmd, fp, blocksize=8192, callback=None, 
rest=None)
 
-  Store a file in binary transfer mode.  *cmd* should be an appropriate
-  ``STOR`` command: ``"STOR filename"``. *fp* is a :term:`file object`
-  (opened in binary mode) which is read until EOF using its 
:meth:`~io.IOBase.read`
-  method in blocks of size *blocksize* to provide the data to be stored.
-  The *blocksize* argument defaults to 8192.  *callback* is an optional 
single
-  parameter callable that is called on each block of data after it is sent.
-  *rest* means the same thing as in the :meth:`transfercmd` method.
+  Store a file in binary transfer mode.
+
+  :param str cmd:
+An appropriate ``STOR`` command: :samp:`"STOR {filename}"`.
+
+  :param fp:
+ A file object (opened in binary mode) which is read until EOF,
+ using its :meth:`~io.RawIOBase.read` method in blocks of size 
*blocksize*
+ to provide the data to be stored.
+  :type fp: :term:`file object`
+
+  :param int blocksize:
+ The read block size.
+ Defaults to ``8192``.
+
+  :param callback:
+ A single parameter callable that is called
+ for each block of data sent,
+ with its single argument being the data as :class:`bytes`.
+  :type callback: :term:`callable`
+
+  :param int rest:
+ A ``REST`` command to be sent to the server.
+ See the documentation for the *rest* parameter of the 
:meth:`transfercmd` method.
 
   .. versionchanged:: 3.2
- *rest* parameter added.
+ The *rest* parameter was added.
 
 
.. method:: FTP.storlines(cmd, fp, callback=None)
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index afea37bf83846f..df34700e285601 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -52,7 +52,6 @@ Doc/library/enum.rst
 Doc/library/exceptions.rst
 Doc/library/faulthandler.rst
 Doc/library/fcntl.rst
-Doc/library/ftplib.rst
 Doc/library/functools.rst
 Doc/library/getopt.rst
 Doc/library/http.cookiejar.rst

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.11] Docs: mark up FTP.retrbinary and FTP.storbinary with param lists (GH-114399) (#114484)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/ec71690fcc53d99266c7eaf548172cdf6abd1a8b
commit: ec71690fcc53d99266c7eaf548172cdf6abd1a8b
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-23T14:00:35Z
summary:

[3.11] Docs: mark up FTP.retrbinary and FTP.storbinary with param lists 
(GH-114399) (#114484)

(cherry picked from commit 5277d4c7dbd1baee300e494fce2738cee218c243)

Co-authored-by: Erlend E. Aasland 
Co-authored-by: Ezio Melotti 

files:
M Doc/library/ftplib.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst
index 93481c128a4588..9ac68316e7c75a 100644
--- a/Doc/library/ftplib.rst
+++ b/Doc/library/ftplib.rst
@@ -201,14 +201,27 @@ FTP objects
 
.. method:: FTP.retrbinary(cmd, callback, blocksize=8192, rest=None)
 
-  Retrieve a file in binary transfer mode.  *cmd* should be an appropriate
-  ``RETR`` command: ``'RETR filename'``. The *callback* function is called 
for
-  each block of data received, with a single bytes argument giving the data
-  block. The optional *blocksize* argument specifies the maximum chunk 
size to
-  read on the low-level socket object created to do the actual transfer 
(which
-  will also be the largest size of the data blocks passed to *callback*).  
A
-  reasonable default is chosen. *rest* means the same thing as in the
-  :meth:`transfercmd` method.
+  Retrieve a file in binary transfer mode.
+
+  :param str cmd:
+An appropriate ``STOR`` command: :samp:`"STOR {filename}"`.
+
+  :param callback:
+ A single parameter callable that is called
+ for each block of data received,
+ with its single argument being the data as :class:`bytes`.
+  :type callback: :term:`callable`
+
+  :param int blocksize:
+ The maximum chunk size to read on the low-level
+ :class:`~socket.socket` object created to do the actual transfer.
+ This also corresponds to the largest size of data
+ that will be passed to *callback*.
+ Defaults to ``8192``.
+
+  :param int rest:
+ A ``REST`` command to be sent to the server.
+ See the documentation for the *rest* parameter of the 
:meth:`transfercmd` method.
 
 
.. method:: FTP.retrlines(cmd, callback=None)
@@ -232,16 +245,33 @@ FTP objects
 
.. method:: FTP.storbinary(cmd, fp, blocksize=8192, callback=None, 
rest=None)
 
-  Store a file in binary transfer mode.  *cmd* should be an appropriate
-  ``STOR`` command: ``"STOR filename"``. *fp* is a :term:`file object`
-  (opened in binary mode) which is read until EOF using its 
:meth:`~io.IOBase.read`
-  method in blocks of size *blocksize* to provide the data to be stored.
-  The *blocksize* argument defaults to 8192.  *callback* is an optional 
single
-  parameter callable that is called on each block of data after it is sent.
-  *rest* means the same thing as in the :meth:`transfercmd` method.
+  Store a file in binary transfer mode.
+
+  :param str cmd:
+An appropriate ``STOR`` command: :samp:`"STOR {filename}"`.
+
+  :param fp:
+ A file object (opened in binary mode) which is read until EOF,
+ using its :meth:`~io.RawIOBase.read` method in blocks of size 
*blocksize*
+ to provide the data to be stored.
+  :type fp: :term:`file object`
+
+  :param int blocksize:
+ The read block size.
+ Defaults to ``8192``.
+
+  :param callback:
+ A single parameter callable that is called
+ for each block of data sent,
+ with its single argument being the data as :class:`bytes`.
+  :type callback: :term:`callable`
+
+  :param int rest:
+ A ``REST`` command to be sent to the server.
+ See the documentation for the *rest* parameter of the 
:meth:`transfercmd` method.
 
   .. versionchanged:: 3.2
- *rest* parameter added.
+ The *rest* parameter was added.
 
 
.. method:: FTP.storlines(cmd, fp, callback=None)
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index c173e6dd4fcb40..1e244bf325b38d 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -48,7 +48,6 @@ Doc/library/enum.rst
 Doc/library/exceptions.rst
 Doc/library/faulthandler.rst
 Doc/library/fcntl.rst
-Doc/library/ftplib.rst
 Doc/library/functools.rst
 Doc/library/http.cookiejar.rst
 Doc/library/http.server.rst

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.11] Docs: mark up FTP.connect() and FTP.login() with param lists (GH-114395) (#114486)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/8790e5799a187138243d66a0418ee32f0871600e
commit: 8790e5799a187138243d66a0418ee32f0871600e
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-23T14:03:51Z
summary:

[3.11] Docs: mark up FTP.connect() and FTP.login() with param lists (GH-114395) 
(#114486)

Use rst substitutions to reduce raw text duplication.

(cherry picked from commit 01105c7c4f7f01a8b1077008e61d5c7df0ab832b)

Co-authored-by: Erlend E. Aasland 
Co-authored-by: Ezio Melotti 
Co-authored-by: Hugo van Kemenade <[email protected]>

files:
M Doc/library/ftplib.rst

diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst
index 9ac68316e7c75a..f41835b804d48a 100644
--- a/Doc/library/ftplib.rst
+++ b/Doc/library/ftplib.rst
@@ -55,38 +55,56 @@ Reference
 FTP objects
 ^^^
 
+.. Use substitutions for some param docs so we don't need to repeat them
+   in multiple places.
+
+.. |param_doc_user| replace::
+   The username to log in with (default: ``'anonymous'``).
+
+.. |param_doc_passwd| replace::
+   The password to use when logging in.
+   If not given, and if *passwd* is the empty string or ``"-"``,
+   a password will be automatically generated.
+
+.. Ideally, we'd like to use the :rfc: directive, but Sphinx will not allow it.
+
+.. |param_doc_acct| replace::
+   Account information to be used for the ``ACCT`` FTP command.
+   Few systems implement this.
+   See `RFC-959 `__
+   for more details.
+
+.. |param_doc_source_address| replace::
+   A 2-tuple ``(host, port)`` for the socket to bind to as its
+   source address before connecting.
+
 .. class:: FTP(host='', user='', passwd='', acct='', timeout=None, \
source_address=None, *, encoding='utf-8')
 
Return a new instance of the :class:`FTP` class.
-   When *host* is given, the method call :meth:`connect(host) `
-   is made by the constructor.
-   When *user* is given, additionally the method call
-   :meth:`login(user, passwd, acct) ` is made.
 
:param str host:
   The hostname to connect to.
+  If given, :code:`connect(host)` is implicitly called by the constructor.
 
:param str user:
-  The username to log in with.
-  If empty string, ``"anonymous"`` is used.
+  |param_doc_user|
+  If given, :code:`login(host, passwd, acct)` is implicitly called
+  by the constructor.
 
:param str passwd:
-  The password to use when logging in.
-  If not given, and if *passwd* is the empty string or ``"-"``,
-  a password will be automatically generated.
+  |param_doc_passwd|
 
:param str acct:
-  Account information; see the ACCT FTP command.
+  |param_doc_acct|
 
:param timeout:
-  A timeout in seconds for blocking operations like :meth:`connect`.
-  If not specified, the global default timeout setting will be used.
+  A timeout in seconds for blocking operations like :meth:`connect`
+  (default: the global default timeout setting).
:type timeout: int | None
 
:param source_address:
-  *source_address* is a 2-tuple ``(host, port)`` for the socket
-  to bind to as its source address before connecting.
+  |param_doc_source_address|
:type source_address: tuple | None
 
:param str encoding:
@@ -140,17 +158,29 @@ FTP objects
 
.. method:: FTP.connect(host='', port=0, timeout=None, source_address=None)
 
-  Connect to the given host and port.  The default port number is ``21``, 
as
-  specified by the FTP protocol specification.  It is rarely needed to 
specify a
-  different port number.  This function should be called only once for each
-  instance; it should not be called at all if a host was given when the 
instance
-  was created.  All other methods can only be used after a connection has 
been
-  made.
-  The optional *timeout* parameter specifies a timeout in seconds for the
-  connection attempt. If no *timeout* is passed, the global default timeout
-  setting will be used.
-  *source_address* is a 2-tuple ``(host, port)`` for the socket to bind to 
as
-  its source address before connecting.
+  Connect to the given host and port.
+  This function should be called only once for each instance;
+  it should not be called if a *host* argument was given
+  when the :class:`FTP` instance was created.
+  All other :class:`!FTP` methods can only be called
+  after a connection has successfully been made.
+
+  :param str host:
+ The host to connect to.
+
+  :param int port:
+ The TCP port to connect to (default: ``21``,
+ as specified by the FTP protocol specification).
+ It is rarely needed to specify a different port number.
+
+  :param timeout:
+ A timeout in seconds for the connection attempt
+ (default: the global default timeout setting)

[Python-checkins] [3.12] Docs: mark up FTP.connect() and FTP.login() with param lists (GH-114395) (#114485)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/d492b19856e6cd05d33ce6264d2733cb926b02f4
commit: d492b19856e6cd05d33ce6264d2733cb926b02f4
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-23T14:04:01Z
summary:

[3.12] Docs: mark up FTP.connect() and FTP.login() with param lists (GH-114395) 
(#114485)

Use rst substitutions to reduce raw text duplication.

(cherry picked from commit 01105c7c4f7f01a8b1077008e61d5c7df0ab832b)

Co-authored-by: Erlend E. Aasland 
Co-authored-by: Ezio Melotti 
Co-authored-by: Hugo van Kemenade <[email protected]>

files:
M Doc/library/ftplib.rst

diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst
index c7251db50a9371..e93a1e85598e3a 100644
--- a/Doc/library/ftplib.rst
+++ b/Doc/library/ftplib.rst
@@ -55,38 +55,56 @@ Reference
 FTP objects
 ^^^
 
+.. Use substitutions for some param docs so we don't need to repeat them
+   in multiple places.
+
+.. |param_doc_user| replace::
+   The username to log in with (default: ``'anonymous'``).
+
+.. |param_doc_passwd| replace::
+   The password to use when logging in.
+   If not given, and if *passwd* is the empty string or ``"-"``,
+   a password will be automatically generated.
+
+.. Ideally, we'd like to use the :rfc: directive, but Sphinx will not allow it.
+
+.. |param_doc_acct| replace::
+   Account information to be used for the ``ACCT`` FTP command.
+   Few systems implement this.
+   See `RFC-959 `__
+   for more details.
+
+.. |param_doc_source_address| replace::
+   A 2-tuple ``(host, port)`` for the socket to bind to as its
+   source address before connecting.
+
 .. class:: FTP(host='', user='', passwd='', acct='', timeout=None, \
source_address=None, *, encoding='utf-8')
 
Return a new instance of the :class:`FTP` class.
-   When *host* is given, the method call :meth:`connect(host) `
-   is made by the constructor.
-   When *user* is given, additionally the method call
-   :meth:`login(user, passwd, acct) ` is made.
 
:param str host:
   The hostname to connect to.
+  If given, :code:`connect(host)` is implicitly called by the constructor.
 
:param str user:
-  The username to log in with.
-  If empty string, ``"anonymous"`` is used.
+  |param_doc_user|
+  If given, :code:`login(host, passwd, acct)` is implicitly called
+  by the constructor.
 
:param str passwd:
-  The password to use when logging in.
-  If not given, and if *passwd* is the empty string or ``"-"``,
-  a password will be automatically generated.
+  |param_doc_passwd|
 
:param str acct:
-  Account information; see the ACCT FTP command.
+  |param_doc_acct|
 
:param timeout:
-  A timeout in seconds for blocking operations like :meth:`connect`.
-  If not specified, the global default timeout setting will be used.
+  A timeout in seconds for blocking operations like :meth:`connect`
+  (default: the global default timeout setting).
:type timeout: int | None
 
:param source_address:
-  *source_address* is a 2-tuple ``(host, port)`` for the socket
-  to bind to as its source address before connecting.
+  |param_doc_source_address|
:type source_address: tuple | None
 
:param str encoding:
@@ -140,17 +158,29 @@ FTP objects
 
.. method:: FTP.connect(host='', port=0, timeout=None, source_address=None)
 
-  Connect to the given host and port.  The default port number is ``21``, 
as
-  specified by the FTP protocol specification.  It is rarely needed to 
specify a
-  different port number.  This function should be called only once for each
-  instance; it should not be called at all if a host was given when the 
instance
-  was created.  All other methods can only be used after a connection has 
been
-  made.
-  The optional *timeout* parameter specifies a timeout in seconds for the
-  connection attempt. If no *timeout* is passed, the global default timeout
-  setting will be used.
-  *source_address* is a 2-tuple ``(host, port)`` for the socket to bind to 
as
-  its source address before connecting.
+  Connect to the given host and port.
+  This function should be called only once for each instance;
+  it should not be called if a *host* argument was given
+  when the :class:`FTP` instance was created.
+  All other :class:`!FTP` methods can only be called
+  after a connection has successfully been made.
+
+  :param str host:
+ The host to connect to.
+
+  :param int port:
+ The TCP port to connect to (default: ``21``,
+ as specified by the FTP protocol specification).
+ It is rarely needed to specify a different port number.
+
+  :param timeout:
+ A timeout in seconds for the connection attempt
+ (default: the global default timeout setting)

[Python-checkins] gh-108303: Move `.whl` test files to `Lib/test/wheeldata/` (#114343)

2024-01-23 Thread vstinner
https://github.com/python/cpython/commit/ba253a4794ae2d35a6f6df46a98a1ed38bd61268
commit: ba253a4794ae2d35a6f6df46a98a1ed38bd61268
branch: main
author: Nikita Sobolev 
committer: vstinner 
date: 2024-01-23T16:33:12+01:00
summary:

gh-108303: Move `.whl` test files to `Lib/test/wheeldata/` (#114343)

files:
A Lib/test/wheeldata/setuptools-67.6.1-py3-none-any.whl
A Lib/test/wheeldata/wheel-0.40.0-py3-none-any.whl
D Lib/test/setuptools-67.6.1-py3-none-any.whl
D Lib/test/wheel-0.40.0-py3-none-any.whl
M Lib/test/support/__init__.py
M Makefile.pre.in

diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 8344dd1849c61d..f2e6af078a5f29 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -2193,7 +2193,9 @@ def _findwheel(pkgname):
 If set, the wheels are searched for in WHEEL_PKG_DIR (see ensurepip).
 Otherwise, they are searched for in the test directory.
 """
-wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or TEST_HOME_DIR
+wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or os.path.join(
+TEST_HOME_DIR, 'wheeldata',
+)
 filenames = os.listdir(wheel_dir)
 filenames = sorted(filenames, reverse=True)  # approximate "newest" first
 for filename in filenames:
diff --git a/Lib/test/setuptools-67.6.1-py3-none-any.whl 
b/Lib/test/wheeldata/setuptools-67.6.1-py3-none-any.whl
similarity index 100%
rename from Lib/test/setuptools-67.6.1-py3-none-any.whl
rename to Lib/test/wheeldata/setuptools-67.6.1-py3-none-any.whl
diff --git a/Lib/test/wheel-0.40.0-py3-none-any.whl 
b/Lib/test/wheeldata/wheel-0.40.0-py3-none-any.whl
similarity index 100%
rename from Lib/test/wheel-0.40.0-py3-none-any.whl
rename to Lib/test/wheeldata/wheel-0.40.0-py3-none-any.whl
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 1107259b5ae1ca..21b122ae0fcd9f 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2318,6 +2318,7 @@ TESTSUBDIRS=  idlelib/idle_test \
test/tokenizedata \
test/tracedmodules \
test/typinganndata \
+   test/wheeldata \
test/xmltestdata \
test/xmltestdata/c14n-20
 

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.12] gh-108303: Move `.whl` test files to `Lib/test/wheeldata/` (GH-114343) (#114488)

2024-01-23 Thread vstinner
https://github.com/python/cpython/commit/be85f35f12bebc669b0aa1c2e9cdd0624fb32a10
commit: be85f35f12bebc669b0aa1c2e9cdd0624fb32a10
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: vstinner 
date: 2024-01-23T15:58:44Z
summary:

[3.12] gh-108303: Move `.whl` test files to `Lib/test/wheeldata/` (GH-114343) 
(#114488)

gh-108303: Move `.whl` test files to `Lib/test/wheeldata/` (GH-114343)
(cherry picked from commit ba253a4794ae2d35a6f6df46a98a1ed38bd61268)

Co-authored-by: Nikita Sobolev 

files:
A Lib/test/wheeldata/setuptools-67.6.1-py3-none-any.whl
A Lib/test/wheeldata/wheel-0.40.0-py3-none-any.whl
D Lib/test/setuptools-67.6.1-py3-none-any.whl
D Lib/test/wheel-0.40.0-py3-none-any.whl
M Lib/test/support/__init__.py
M Makefile.pre.in

diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index fd9265c93c35f3..8c4b4e023f633f 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -2179,7 +2179,9 @@ def _findwheel(pkgname):
 If set, the wheels are searched for in WHEEL_PKG_DIR (see ensurepip).
 Otherwise, they are searched for in the test directory.
 """
-wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or TEST_HOME_DIR
+wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or os.path.join(
+TEST_HOME_DIR, 'wheeldata',
+)
 filenames = os.listdir(wheel_dir)
 filenames = sorted(filenames, reverse=True)  # approximate "newest" first
 for filename in filenames:
diff --git a/Lib/test/setuptools-67.6.1-py3-none-any.whl 
b/Lib/test/wheeldata/setuptools-67.6.1-py3-none-any.whl
similarity index 100%
rename from Lib/test/setuptools-67.6.1-py3-none-any.whl
rename to Lib/test/wheeldata/setuptools-67.6.1-py3-none-any.whl
diff --git a/Lib/test/wheel-0.40.0-py3-none-any.whl 
b/Lib/test/wheeldata/wheel-0.40.0-py3-none-any.whl
similarity index 100%
rename from Lib/test/wheel-0.40.0-py3-none-any.whl
rename to Lib/test/wheeldata/wheel-0.40.0-py3-none-any.whl
diff --git a/Makefile.pre.in b/Makefile.pre.in
index e6f6e6c675a641..7f46f340efe038 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2241,6 +2241,7 @@ TESTSUBDIRS=  idlelib/idle_test \
test/tokenizedata \
test/tracedmodules \
test/typinganndata \
+   test/wheeldata \
test/xmltestdata \
test/xmltestdata/c14n-20 \
test/ziptestdata

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-112984: Fix link error on free-threaded Windows build (GH-114455)

2024-01-23 Thread zooba
https://github.com/python/cpython/commit/5f1997896d9c3ecf92e9863177c452b468a6a2c8
commit: 5f1997896d9c3ecf92e9863177c452b468a6a2c8
branch: main
author: Sam Gross 
committer: zooba 
date: 2024-01-23T18:05:15Z
summary:

gh-112984: Fix link error on free-threaded Windows build (GH-114455)

The test_peg_generator test tried to link the python313_d.lib library,
which failed because the library is now named python313t_d.lib. The
underlying problem is that the "compiler" attribute was not set when
we call get_libraries() from distutils.

files:
M Tools/peg_generator/pegen/build.py

diff --git a/Tools/peg_generator/pegen/build.py 
b/Tools/peg_generator/pegen/build.py
index 00295c984d1bb6..67a7c0c4788e9d 100644
--- a/Tools/peg_generator/pegen/build.py
+++ b/Tools/peg_generator/pegen/build.py
@@ -220,6 +220,9 @@ def compile_c_extension(
 )
 else:
 objects = compiler.object_filenames(extension.sources, 
output_dir=cmd.build_temp)
+# The cmd.get_libraries() call needs a valid compiler attribute or we will
+# get an incorrect library name on the free-threaded Windows build.
+cmd.compiler = compiler
 # Now link the object files together into a "shared object"
 compiler.link_shared_object(
 objects,

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-111964: Implement stop-the-world pauses (gh-112471)

2024-01-23 Thread ericsnowcurrently
https://github.com/python/cpython/commit/441affc9e7f419ef0b68f734505fa2f79fe653c7
commit: 441affc9e7f419ef0b68f734505fa2f79fe653c7
branch: main
author: Sam Gross 
committer: ericsnowcurrently 
date: 2024-01-23T11:08:23-07:00
summary:

gh-111964: Implement stop-the-world pauses (gh-112471)

The `--disable-gil` builds occasionally need to pause all but one thread.  Some
examples include:

* Cyclic garbage collection, where this is often called a "stop the world event"
* Before calling `fork()`, to ensure a consistent state for internal data 
structures
* During interpreter shutdown, to ensure that daemon threads aren't accessing 
Python objects

This adds the following functions to implement global and per-interpreter 
pauses:

* `_PyEval_StopTheWorldAll()` and `_PyEval_StartTheWorldAll()` (for the global 
runtime)
* `_PyEval_StopTheWorld()` and `_PyEval_StartTheWorld()` (per-interpreter)

(The function names may change.)

These functions are no-ops outside of the `--disable-gil` build.

files:
M Include/cpython/pystate.h
M Include/internal/pycore_ceval.h
M Include/internal/pycore_interp.h
M Include/internal/pycore_llist.h
M Include/internal/pycore_pystate.h
M Include/internal/pycore_runtime.h
M Include/internal/pycore_runtime_init.h
M Include/pymacro.h
M Python/ceval_gil.c
M Python/pystate.c

diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 10913943c1140d..60b056bdcc2f1f 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -102,7 +102,7 @@ struct _ts {
 #endif
 int _whence;
 
-/* Thread state (_Py_THREAD_ATTACHED, _Py_THREAD_DETACHED, _Py_THREAD_GC).
+/* Thread state (_Py_THREAD_ATTACHED, _Py_THREAD_DETACHED, 
_Py_THREAD_SUSPENDED).
See Include/internal/pycore_pystate.h for more details. */
 int state;
 
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index a357bfa3a26064..a66af1389541dd 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -205,6 +205,7 @@ void _PyEval_FrameClearAndPop(PyThreadState *tstate, 
_PyInterpreterFrame *frame)
 #define _PY_CALLS_TO_DO_BIT 2
 #define _PY_ASYNC_EXCEPTION_BIT 3
 #define _PY_GC_SCHEDULED_BIT 4
+#define _PY_EVAL_PLEASE_STOP_BIT 5
 
 /* Reserve a few bits for future use */
 #define _PY_EVAL_EVENTS_BITS 8
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 922c84543a1393..f953b8426e180a 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -41,6 +41,22 @@ struct _Py_long_state {
 int max_str_digits;
 };
 
+// Support for stop-the-world events. This exists in both the PyRuntime struct
+// for global pauses and in each PyInterpreterState for per-interpreter pauses.
+struct _stoptheworld_state {
+PyMutex mutex;   // Serializes stop-the-world attempts.
+
+// NOTE: The below fields are protected by HEAD_LOCK(runtime), not by the
+// above mutex.
+bool requested;  // Set when a pause is requested.
+bool world_stopped;  // Set when the world is stopped.
+bool is_global;  // Set when contained in PyRuntime struct.
+
+PyEvent stop_event;  // Set when thread_countdown reaches zero.
+Py_ssize_t thread_countdown;  // Number of threads that must pause.
+
+PyThreadState *requester; // Thread that requested the pause (may be NULL).
+};
 
 /* cross-interpreter data registry */
 
@@ -166,6 +182,7 @@ struct _is {
 
 struct _warnings_runtime_state warnings;
 struct atexit_state atexit;
+struct _stoptheworld_state stoptheworld;
 
 #if defined(Py_GIL_DISABLED)
 struct _mimalloc_interp_state mimalloc;
diff --git a/Include/internal/pycore_llist.h b/Include/internal/pycore_llist.h
index 5fd261da05fa5d..f629902fda9ff1 100644
--- a/Include/internal/pycore_llist.h
+++ b/Include/internal/pycore_llist.h
@@ -37,8 +37,7 @@ struct llist_node {
 };
 
 // Get the struct containing a node.
-#define llist_data(node, type, member) \
-(type*)((char*)node - offsetof(type, member))
+#define llist_data(node, type, member) (_Py_CONTAINER_OF(node, type, member))
 
 // Iterate over a list.
 #define llist_for_each(node, head) \
diff --git a/Include/internal/pycore_pystate.h 
b/Include/internal/pycore_pystate.h
index 348c5c634284b0..289ef28f0dd9a9 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -21,23 +21,27 @@ extern "C" {
 // interpreter at the same time. Only the "bound" thread may perform the
 // transitions between "attached" and "detached" on its own PyThreadState.
 //
-// The "gc" state is used to implement stop-the-world pauses, such as for
-// cyclic garbage collection. It is only used in `--disable-gil` builds. It is
-// similar to the "detached" state, but only the thread performing a
-// stop-the-world pause may transition threads between the "detached" and "gc"
-// states. A thread trying to "attach" from the "gc" state will block until
-// it is transitioned back to "detached" when the stop-t

[Python-checkins] gh-113884: Make queue.SimpleQueue thread-safe when the GIL is disabled (#114161)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/925907ea362c4c014086be48625ac7dd67645cfc
commit: 925907ea362c4c014086be48625ac7dd67645cfc
branch: main
author: mpage 
committer: erlend-aasland 
date: 2024-01-23T20:25:41+01:00
summary:

gh-113884: Make queue.SimpleQueue thread-safe when the GIL is disabled (#114161)

* use the ParkingLot API to manage waiting threads
* use Argument Clinic's critical section directive to protect queue methods
* remove unnecessary overflow check

Co-authored-by: Erlend E. Aasland 

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-01-17-00-52-57.gh-issue-113884.CvEjUE.rst
M Modules/_queuemodule.c
M Modules/clinic/_queuemodule.c.h

diff --git a/Misc/NEWS.d/next/Core and 
Builtins/2024-01-17-00-52-57.gh-issue-113884.CvEjUE.rst b/Misc/NEWS.d/next/Core 
and Builtins/2024-01-17-00-52-57.gh-issue-113884.CvEjUE.rst
new file mode 100644
index 00..6a39fd2f60ab81
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-01-17-00-52-57.gh-issue-113884.CvEjUE.rst 
@@ -0,0 +1 @@
+Make :class:`queue.SimpleQueue` thread safe when the GIL is disabled.
diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c
index 8fca3cdd0deb18..18b24855c52ad6 100644
--- a/Modules/_queuemodule.c
+++ b/Modules/_queuemodule.c
@@ -3,8 +3,9 @@
 #endif
 
 #include "Python.h"
-#include "pycore_ceval.h" // _PyEval_MakePendingCalls()
+#include "pycore_ceval.h" // Py_MakePendingCalls()
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
+#include "pycore_parking_lot.h"
 #include "pycore_time.h"  // _PyTime_t
 
 #include 
@@ -151,7 +152,9 @@ RingBuf_Get(RingBuf *buf)
 return item;
 }
 
-// Returns 0 on success or -1 if the buffer failed to grow
+// Returns 0 on success or -1 if the buffer failed to grow.
+//
+// Steals a reference to item.
 static int
 RingBuf_Put(RingBuf *buf, PyObject *item)
 {
@@ -164,7 +167,7 @@ RingBuf_Put(RingBuf *buf, PyObject *item)
 return -1;
 }
 }
-buf->items[buf->put_idx] = Py_NewRef(item);
+buf->items[buf->put_idx] = item;
 buf->put_idx = (buf->put_idx + 1) % buf->items_cap;
 buf->num_items++;
 return 0;
@@ -184,9 +187,13 @@ RingBuf_IsEmpty(RingBuf *buf)
 
 typedef struct {
 PyObject_HEAD
-PyThread_type_lock lock;
-int locked;
+
+// Are there threads waiting for items
+bool has_threads_waiting;
+
+// Items in the queue
 RingBuf buf;
+
 PyObject *weakreflist;
 } simplequeueobject;
 
@@ -209,12 +216,6 @@ simplequeue_dealloc(simplequeueobject *self)
 PyTypeObject *tp = Py_TYPE(self);
 
 PyObject_GC_UnTrack(self);
-if (self->lock != NULL) {
-/* Unlock the lock so it's safe to free it */
-if (self->locked > 0)
-PyThread_release_lock(self->lock);
-PyThread_free_lock(self->lock);
-}
 (void)simplequeue_clear(self);
 if (self->weakreflist != NULL)
 PyObject_ClearWeakRefs((PyObject *) self);
@@ -249,12 +250,6 @@ simplequeue_new_impl(PyTypeObject *type)
 self = (simplequeueobject *) type->tp_alloc(type, 0);
 if (self != NULL) {
 self->weakreflist = NULL;
-self->lock = PyThread_allocate_lock();
-if (self->lock == NULL) {
-Py_DECREF(self);
-PyErr_SetString(PyExc_MemoryError, "can't allocate lock");
-return NULL;
-}
 if (RingBuf_Init(&self->buf) < 0) {
 Py_DECREF(self);
 return NULL;
@@ -264,7 +259,29 @@ simplequeue_new_impl(PyTypeObject *type)
 return (PyObject *) self;
 }
 
+typedef struct {
+bool handed_off;
+simplequeueobject *queue;
+PyObject *item;
+} HandoffData;
+
+static void
+maybe_handoff_item(HandoffData *data, PyObject **item, int has_more_waiters)
+{
+if (item == NULL) {
+// No threads were waiting
+data->handed_off = false;
+}
+else {
+// There was at least one waiting thread, hand off the item
+*item = data->item;
+data->handed_off = true;
+}
+data->queue->has_threads_waiting = has_more_waiters;
+}
+
 /*[clinic input]
+@critical_section
 _queue.SimpleQueue.put
 item: object
 block: bool = True
@@ -280,21 +297,28 @@ never blocks.  They are provided for compatibility with 
the Queue class.
 static PyObject *
 _queue_SimpleQueue_put_impl(simplequeueobject *self, PyObject *item,
 int block, PyObject *timeout)
-/*[clinic end generated code: output=4333136e88f90d8b input=6e601fa707a782d5]*/
+/*[clinic end generated code: output=4333136e88f90d8b input=a16dbb33363c0fa8]*/
 {
-/* BEGIN GIL-protected critical section */
-if (RingBuf_Put(&self->buf, item) < 0)
-return NULL;
-if (self->locked) {
-/* A get() may be waiting, wake it up */
-self->locked = 0;
-PyThread_release_lock(self->lock);
+HandoffData data = {
+.handed_off = 0,
+.item = Py_NewRef(item),
+.queue = self,
+};
+if (self->has_threads_waiting) {
+

[Python-checkins] Docs: use placeholders in dbm flag param docs (#114482)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/8c265408c51609c6b4a6788cac9cc5fea7a14888
commit: 8c265408c51609c6b4a6788cac9cc5fea7a14888
branch: main
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-23T20:54:44+01:00
summary:

Docs: use placeholders in dbm flag param docs (#114482)

Also correct the default flag param for dbm.dumb.open();
it's 'c', not 'r'.

files:
M Doc/library/dbm.rst

diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst
index cb95c61322582f..eca1c25602a018 100644
--- a/Doc/library/dbm.rst
+++ b/Doc/library/dbm.rst
@@ -36,6 +36,21 @@ the Oracle Berkeley DB.
 .. versionchanged:: 3.11
Accepts :term:`path-like object` for filename.
 
+.. Substitutions for the open() flag param docs;
+   all submodules use the same text.
+
+.. |flag_r| replace::
+   Open existing database for reading only.
+
+.. |flag_w| replace::
+   Open existing database for reading and writing.
+
+.. |flag_c| replace::
+   Open database for reading and writing, creating it if it doesn't exist.
+
+.. |flag_n| replace::
+   Always create a new, empty database, open for reading and writing.
+
 .. function:: open(file, flag='r', mode=0o666)
 
Open the database file *file* and return a corresponding object.
@@ -46,21 +61,13 @@ the Oracle Berkeley DB.
 
The optional *flag* argument can be:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+---+
+   .. csv-table::
+  :header: "Value", "Meaning"
+
+  ``'r'`` (default), |flag_r|
+  ``'w'``, |flag_w|
+  ``'c'``, |flag_c|
+  ``'n'``, |flag_n|
 
The optional *mode* argument is the Unix mode of the file, used only when 
the
database has to be created.  It defaults to octal ``0o666`` (and will be
@@ -165,21 +172,13 @@ supported.
 
The optional *flag* argument can be:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+---+
+   .. csv-table::
+  :header: "Value", "Meaning"
+
+  ``'r'`` (default), |flag_r|
+  ``'w'``, |flag_w|
+  ``'c'``, |flag_c|
+  ``'n'``, |flag_n|
 
The following additional characters may be appended to the flag to control
how the database is opened:
@@ -297,21 +296,13 @@ to locate the appropriate header file to simplify 
building this module.
 
The optional *flag* argument must be one of these values:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+---+
+   .. csv-table::
+  :header: "Value", "Meaning"
+
+  ``'r'`` (default), |flag_r|
+  ``'w'``, |flag_w|
+  ``'c'``, |f

[Python-checkins] [3.12] Docs: use placeholders in dbm flag param docs (GH-114482) (#114497)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/a73a6a3c69bedee52b7a828b4bd133d76becd73c
commit: a73a6a3c69bedee52b7a828b4bd133d76becd73c
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-23T21:05:21+01:00
summary:

[3.12] Docs: use placeholders in dbm flag param docs (GH-114482) (#114497)

Also correct the default flag param for dbm.dumb.open();
it's 'c', not 'r'.
(cherry picked from commit 8c265408c51609c6b4a6788cac9cc5fea7a14888)

Co-authored-by: Erlend E. Aasland 

files:
M Doc/library/dbm.rst

diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst
index 8b799ad6cb57fd..bc72f0f76ac2e2 100644
--- a/Doc/library/dbm.rst
+++ b/Doc/library/dbm.rst
@@ -36,6 +36,21 @@ the Oracle Berkeley DB.
 .. versionchanged:: 3.11
Accepts :term:`path-like object` for filename.
 
+.. Substitutions for the open() flag param docs;
+   all submodules use the same text.
+
+.. |flag_r| replace::
+   Open existing database for reading only.
+
+.. |flag_w| replace::
+   Open existing database for reading and writing.
+
+.. |flag_c| replace::
+   Open database for reading and writing, creating it if it doesn't exist.
+
+.. |flag_n| replace::
+   Always create a new, empty database, open for reading and writing.
+
 .. function:: open(file, flag='r', mode=0o666)
 
Open the database file *file* and return a corresponding object.
@@ -46,21 +61,13 @@ the Oracle Berkeley DB.
 
The optional *flag* argument can be:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+---+
+   .. csv-table::
+  :header: "Value", "Meaning"
+
+  ``'r'`` (default), |flag_r|
+  ``'w'``, |flag_w|
+  ``'c'``, |flag_c|
+  ``'n'``, |flag_n|
 
The optional *mode* argument is the Unix mode of the file, used only when 
the
database has to be created.  It defaults to octal ``0o666`` (and will be
@@ -165,21 +172,13 @@ supported.
 
The optional *flag* argument can be:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+---+
+   .. csv-table::
+  :header: "Value", "Meaning"
+
+  ``'r'`` (default), |flag_r|
+  ``'w'``, |flag_w|
+  ``'c'``, |flag_c|
+  ``'n'``, |flag_n|
 
The following additional characters may be appended to the flag to control
how the database is opened:
@@ -290,21 +289,13 @@ to locate the appropriate header file to simplify 
building this module.
 
The optional *flag* argument must be one of these values:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+--

[Python-checkins] [3.11] Docs: use placeholders in dbm flag param docs (GH-114482) (#114498)

2024-01-23 Thread erlend-aasland
https://github.com/python/cpython/commit/e85f4c6fa96d9b6f7d4a1d0a9ac07c12ba7f33db
commit: e85f4c6fa96d9b6f7d4a1d0a9ac07c12ba7f33db
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-23T21:05:39+01:00
summary:

[3.11] Docs: use placeholders in dbm flag param docs (GH-114482) (#114498)

Also correct the default flag param for dbm.dumb.open();
it's 'c', not 'r'.
(cherry picked from commit 8c265408c51609c6b4a6788cac9cc5fea7a14888)

Co-authored-by: Erlend E. Aasland 

files:
M Doc/library/dbm.rst

diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst
index 8b799ad6cb57fd..bc72f0f76ac2e2 100644
--- a/Doc/library/dbm.rst
+++ b/Doc/library/dbm.rst
@@ -36,6 +36,21 @@ the Oracle Berkeley DB.
 .. versionchanged:: 3.11
Accepts :term:`path-like object` for filename.
 
+.. Substitutions for the open() flag param docs;
+   all submodules use the same text.
+
+.. |flag_r| replace::
+   Open existing database for reading only.
+
+.. |flag_w| replace::
+   Open existing database for reading and writing.
+
+.. |flag_c| replace::
+   Open database for reading and writing, creating it if it doesn't exist.
+
+.. |flag_n| replace::
+   Always create a new, empty database, open for reading and writing.
+
 .. function:: open(file, flag='r', mode=0o666)
 
Open the database file *file* and return a corresponding object.
@@ -46,21 +61,13 @@ the Oracle Berkeley DB.
 
The optional *flag* argument can be:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+---+
+   .. csv-table::
+  :header: "Value", "Meaning"
+
+  ``'r'`` (default), |flag_r|
+  ``'w'``, |flag_w|
+  ``'c'``, |flag_c|
+  ``'n'``, |flag_n|
 
The optional *mode* argument is the Unix mode of the file, used only when 
the
database has to be created.  It defaults to octal ``0o666`` (and will be
@@ -165,21 +172,13 @@ supported.
 
The optional *flag* argument can be:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+---+
+   .. csv-table::
+  :header: "Value", "Meaning"
+
+  ``'r'`` (default), |flag_r|
+  ``'w'``, |flag_w|
+  ``'c'``, |flag_c|
+  ``'n'``, |flag_n|
 
The following additional characters may be appended to the flag to control
how the database is opened:
@@ -290,21 +289,13 @@ to locate the appropriate header file to simplify 
building this module.
 
The optional *flag* argument must be one of these values:
 
-   +-+---+
-   | Value   | Meaning   |
-   +=+===+
-   | ``'r'`` | Open existing database for reading only   |
-   | | (default) |
-   +-+---+
-   | ``'w'`` | Open existing database for reading and|
-   | | writing   |
-   +-+---+
-   | ``'c'`` | Open database for reading and writing,|
-   | | creating it if it doesn't exist   |
-   +-+---+
-   | ``'n'`` | Always create a new, empty database, open |
-   | | for reading and writing   |
-   +-+--

[Python-checkins] gh-101438: Avoid reference cycle in ElementTree.iterparse. (GH-114269)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/ce01ab536f22a3cf095d621f3b3579c1e3567859
commit: ce01ab536f22a3cf095d621f3b3579c1e3567859
branch: main
author: Sam Gross 
committer: serhiy-storchaka 
date: 2024-01-23T20:14:46Z
summary:

gh-101438: Avoid reference cycle in ElementTree.iterparse. (GH-114269)

The iterator returned by ElementTree.iterparse() may hold on to a file
descriptor. The reference cycle prevented prompt clean-up of the file
descriptor if the returned iterator was not exhausted.

files:
A Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
M Lib/xml/etree/ElementTree.py

diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 42574eefd81beb..ae6575028be11c 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -99,6 +99,7 @@
 import collections
 import collections.abc
 import contextlib
+import weakref
 
 from . import ElementPath
 
@@ -1223,13 +1224,14 @@ def iterparse(source, events=None, parser=None):
 # parser argument of iterparse is removed, this can be killed.
 pullparser = XMLPullParser(events=events, _parser=parser)
 
-def iterator(source):
+if not hasattr(source, "read"):
+source = open(source, "rb")
+close_source = True
+else:
 close_source = False
+
+def iterator(source):
 try:
-if not hasattr(source, "read"):
-source = open(source, "rb")
-close_source = True
-yield None
 while True:
 yield from pullparser.read_events()
 # load event buffer
@@ -1239,18 +1241,23 @@ def iterator(source):
 pullparser.feed(data)
 root = pullparser._close_and_return_root()
 yield from pullparser.read_events()
-it.root = root
+it = wr()
+if it is not None:
+it.root = root
 finally:
 if close_source:
 source.close()
 
 class IterParseIterator(collections.abc.Iterator):
 __next__ = iterator(source).__next__
-it = IterParseIterator()
-it.root = None
-del iterator, IterParseIterator
 
-next(it)
+def __del__(self):
+if close_source:
+source.close()
+
+it = IterParseIterator()
+wr = weakref.ref(it)
+del IterParseIterator
 return it
 
 
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst 
b/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
new file mode 100644
index 00..9b69b5deb1b5a0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
@@ -0,0 +1,4 @@
+Avoid reference cycle in ElementTree.iterparse. The iterator returned by
+``ElementTree.iterparse`` may hold on to a file descriptor. The reference
+cycle prevented prompt clean-up of the file descriptor if the returned
+iterator was not exhausted.

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.12] gh-101438: Avoid reference cycle in ElementTree.iterparse. (GH-114269) (GH-114499)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/f63dec94f6b0249e5376617bec1ecb03da7723b2
commit: f63dec94f6b0249e5376617bec1ecb03da7723b2
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-23T20:48:42Z
summary:

[3.12] gh-101438: Avoid reference cycle in ElementTree.iterparse. (GH-114269) 
(GH-114499)

The iterator returned by ElementTree.iterparse() may hold on to a file
descriptor. The reference cycle prevented prompt clean-up of the file
descriptor if the returned iterator was not exhausted.
(cherry picked from commit ce01ab536f22a3cf095d621f3b3579c1e3567859)

Co-authored-by: Sam Gross 

files:
A Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
M Lib/xml/etree/ElementTree.py

diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 42574eefd81beb..ae6575028be11c 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -99,6 +99,7 @@
 import collections
 import collections.abc
 import contextlib
+import weakref
 
 from . import ElementPath
 
@@ -1223,13 +1224,14 @@ def iterparse(source, events=None, parser=None):
 # parser argument of iterparse is removed, this can be killed.
 pullparser = XMLPullParser(events=events, _parser=parser)
 
-def iterator(source):
+if not hasattr(source, "read"):
+source = open(source, "rb")
+close_source = True
+else:
 close_source = False
+
+def iterator(source):
 try:
-if not hasattr(source, "read"):
-source = open(source, "rb")
-close_source = True
-yield None
 while True:
 yield from pullparser.read_events()
 # load event buffer
@@ -1239,18 +1241,23 @@ def iterator(source):
 pullparser.feed(data)
 root = pullparser._close_and_return_root()
 yield from pullparser.read_events()
-it.root = root
+it = wr()
+if it is not None:
+it.root = root
 finally:
 if close_source:
 source.close()
 
 class IterParseIterator(collections.abc.Iterator):
 __next__ = iterator(source).__next__
-it = IterParseIterator()
-it.root = None
-del iterator, IterParseIterator
 
-next(it)
+def __del__(self):
+if close_source:
+source.close()
+
+it = IterParseIterator()
+wr = weakref.ref(it)
+del IterParseIterator
 return it
 
 
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst 
b/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
new file mode 100644
index 00..9b69b5deb1b5a0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
@@ -0,0 +1,4 @@
+Avoid reference cycle in ElementTree.iterparse. The iterator returned by
+``ElementTree.iterparse`` may hold on to a file descriptor. The reference
+cycle prevented prompt clean-up of the file descriptor if the returned
+iterator was not exhausted.

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.11] gh-101438: Avoid reference cycle in ElementTree.iterparse. (GH-114269) (GH-114500)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/9344edeb75e299baeee51dbc26172977475827ef
commit: 9344edeb75e299baeee51dbc26172977475827ef
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-23T20:49:13Z
summary:

[3.11] gh-101438: Avoid reference cycle in ElementTree.iterparse. (GH-114269) 
(GH-114500)

The iterator returned by ElementTree.iterparse() may hold on to a file
descriptor. The reference cycle prevented prompt clean-up of the file
descriptor if the returned iterator was not exhausted.
(cherry picked from commit ce01ab536f22a3cf095d621f3b3579c1e3567859)

Co-authored-by: Sam Gross 

files:
A Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
M Lib/xml/etree/ElementTree.py

diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 1dc80351bf7ddd..d4b259e31a7de7 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -99,6 +99,7 @@
 import collections
 import collections.abc
 import contextlib
+import weakref
 
 from . import ElementPath
 
@@ -1238,13 +1239,14 @@ def iterparse(source, events=None, parser=None):
 # parser argument of iterparse is removed, this can be killed.
 pullparser = XMLPullParser(events=events, _parser=parser)
 
-def iterator(source):
+if not hasattr(source, "read"):
+source = open(source, "rb")
+close_source = True
+else:
 close_source = False
+
+def iterator(source):
 try:
-if not hasattr(source, "read"):
-source = open(source, "rb")
-close_source = True
-yield None
 while True:
 yield from pullparser.read_events()
 # load event buffer
@@ -1254,18 +1256,23 @@ def iterator(source):
 pullparser.feed(data)
 root = pullparser._close_and_return_root()
 yield from pullparser.read_events()
-it.root = root
+it = wr()
+if it is not None:
+it.root = root
 finally:
 if close_source:
 source.close()
 
 class IterParseIterator(collections.abc.Iterator):
 __next__ = iterator(source).__next__
-it = IterParseIterator()
-it.root = None
-del iterator, IterParseIterator
 
-next(it)
+def __del__(self):
+if close_source:
+source.close()
+
+it = IterParseIterator()
+wr = weakref.ref(it)
+del IterParseIterator
 return it
 
 
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst 
b/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
new file mode 100644
index 00..9b69b5deb1b5a0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-18-22-29-28.gh-issue-101438.1-uUi_.rst
@@ -0,0 +1,4 @@
+Avoid reference cycle in ElementTree.iterparse. The iterator returned by
+``ElementTree.iterparse`` may hold on to a file descriptor. The reference
+cycle prevented prompt clean-up of the file descriptor if the returned
+iterator was not exhausted.

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/d22c066b802592932f9eb18434782299e80ca42e
commit: d22c066b802592932f9eb18434782299e80ca42e
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-01-23T23:27:04+02:00
summary:

gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495)

On Alpine Linux it could leave some field non-initialized.

files:
A Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
M Modules/termios.c

diff --git 
a/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst 
b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
new file mode 100644
index 00..8df8299d0dffcd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
@@ -0,0 +1,2 @@
+Make the result of :func:`termios.tcgetattr` reproducible on Alpine Linux.
+Previously it could leave a random garbage in some fields.
diff --git a/Modules/termios.c b/Modules/termios.c
index c4f0fd9d50044a..69dbd88be5fcc2 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -98,6 +98,8 @@ termios_tcgetattr_impl(PyObject *module, int fd)
 struct termios mode;
 int r;
 
+/* Alpine Linux can leave some fields uninitialized. */
+memset(&mode, 0, sizeof(mode));
 Py_BEGIN_ALLOW_THREADS
 r = tcgetattr(fd, &mode);
 Py_END_ALLOW_THREADS

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.11] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495) (GH-114503)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/666d07f241970482f17dc4bf7a5dff737d9b8357
commit: 666d07f241970482f17dc4bf7a5dff737d9b8357
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-23T21:53:13Z
summary:

[3.11] gh-114492: Initialize struct termios before calling tcgetattr() 
(GH-114495) (GH-114503)

On Alpine Linux it could leave some field non-initialized.
(cherry picked from commit d22c066b802592932f9eb18434782299e80ca42e)

Co-authored-by: Serhiy Storchaka 

files:
A Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
M Modules/termios.c

diff --git 
a/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst 
b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
new file mode 100644
index 00..8df8299d0dffcd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
@@ -0,0 +1,2 @@
+Make the result of :func:`termios.tcgetattr` reproducible on Alpine Linux.
+Previously it could leave a random garbage in some fields.
diff --git a/Modules/termios.c b/Modules/termios.c
index be5d099072c8ee..23771b2ce99f82 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -84,6 +84,8 @@ termios_tcgetattr_impl(PyObject *module, int fd)
 struct termios mode;
 int r;
 
+/* Alpine Linux can leave some fields uninitialized. */
+memset(&mode, 0, sizeof(mode));
 Py_BEGIN_ALLOW_THREADS
 r = tcgetattr(fd, &mode);
 Py_END_ALLOW_THREADS

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.12] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495) (GH-114502)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/386c72d9928c51aa2c855ce592bd8022da3b407f
commit: 386c72d9928c51aa2c855ce592bd8022da3b407f
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-23T22:02:02Z
summary:

[3.12] gh-114492: Initialize struct termios before calling tcgetattr() 
(GH-114495) (GH-114502)

On Alpine Linux it could leave some field non-initialized.
(cherry picked from commit d22c066b802592932f9eb18434782299e80ca42e)

Co-authored-by: Serhiy Storchaka 

files:
A Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
M Modules/termios.c

diff --git 
a/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst 
b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
new file mode 100644
index 00..8df8299d0dffcd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
@@ -0,0 +1,2 @@
+Make the result of :func:`termios.tcgetattr` reproducible on Alpine Linux.
+Previously it could leave a random garbage in some fields.
diff --git a/Modules/termios.c b/Modules/termios.c
index c3d96cc5b2c00d..402e6ac908a176 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -84,6 +84,8 @@ termios_tcgetattr_impl(PyObject *module, int fd)
 struct termios mode;
 int r;
 
+/* Alpine Linux can leave some fields uninitialized. */
+memset(&mode, 0, sizeof(mode));
 Py_BEGIN_ALLOW_THREADS
 r = tcgetattr(fd, &mode);
 Py_END_ALLOW_THREADS

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-112075: Adapt more dict methods to Argument Clinic (#114256)

2024-01-23 Thread DinoV
https://github.com/python/cpython/commit/afe8f376c096d5d6e8b12fbc691ca9b35381470b
commit: afe8f376c096d5d6e8b12fbc691ca9b35381470b
branch: main
author: Dino Viehland 
committer: DinoV 
date: 2024-01-23T22:10:04Z
summary:

gh-112075: Adapt more dict methods to Argument Clinic (#114256)

* Move more dict objects to argument clinic

* Improve doc strings

* More doc string improvements

* Update Objects/dictobject.c

Co-authored-by: Erlend E. Aasland 

* Update Objects/dictobject.c

Co-authored-by: Erlend E. Aasland 

* Update Objects/dictobject.c

Co-authored-by: Erlend E. Aasland 

* Update Objects/dictobject.c

Co-authored-by: Erlend E. Aasland 

* Update Objects/dictobject.c

Co-authored-by: Erlend E. Aasland 

* Update Objects/dictobject.c

Co-authored-by: Erlend E. Aasland 

* Update Objects/dictobject.c

Co-authored-by: Erlend E. Aasland 

-

Co-authored-by: Erlend E. Aasland 

files:
M Objects/clinic/dictobject.c.h
M Objects/dictobject.c

diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h
index 641514235c2341..8f532f454156de 100644
--- a/Objects/clinic/dictobject.c.h
+++ b/Objects/clinic/dictobject.c.h
@@ -38,6 +38,24 @@ dict_fromkeys(PyTypeObject *type, PyObject *const *args, 
Py_ssize_t nargs)
 return return_value;
 }
 
+PyDoc_STRVAR(dict_copy__doc__,
+"copy($self, /)\n"
+"--\n"
+"\n"
+"Return a shallow copy of the dict.");
+
+#define DICT_COPY_METHODDEF\
+{"copy", (PyCFunction)dict_copy, METH_NOARGS, dict_copy__doc__},
+
+static PyObject *
+dict_copy_impl(PyDictObject *self);
+
+static PyObject *
+dict_copy(PyDictObject *self, PyObject *Py_UNUSED(ignored))
+{
+return dict_copy_impl(self);
+}
+
 PyDoc_STRVAR(dict___containsdoc__,
 "__contains__($self, key, /)\n"
 "--\n"
@@ -118,6 +136,24 @@ dict_setdefault(PyDictObject *self, PyObject *const *args, 
Py_ssize_t nargs)
 return return_value;
 }
 
+PyDoc_STRVAR(dict_clear__doc__,
+"clear($self, /)\n"
+"--\n"
+"\n"
+"Remove all items from the dict.");
+
+#define DICT_CLEAR_METHODDEF\
+{"clear", (PyCFunction)dict_clear, METH_NOARGS, dict_clear__doc__},
+
+static PyObject *
+dict_clear_impl(PyDictObject *self);
+
+static PyObject *
+dict_clear(PyDictObject *self, PyObject *Py_UNUSED(ignored))
+{
+return dict_clear_impl(self);
+}
+
 PyDoc_STRVAR(dict_pop__doc__,
 "pop($self, key, default=, /)\n"
 "--\n"
@@ -176,6 +212,24 @@ dict_popitem(PyDictObject *self, PyObject 
*Py_UNUSED(ignored))
 return dict_popitem_impl(self);
 }
 
+PyDoc_STRVAR(dict___sizeofdoc__,
+"__sizeof__($self, /)\n"
+"--\n"
+"\n"
+"Return the size of the dict in memory, in bytes.");
+
+#define DICT___SIZEOF___METHODDEF\
+{"__sizeof__", (PyCFunction)dict___sizeof__, METH_NOARGS, 
dict___sizeofdoc__},
+
+static PyObject *
+dict___sizeof___impl(PyDictObject *self);
+
+static PyObject *
+dict___sizeof__(PyDictObject *self, PyObject *Py_UNUSED(ignored))
+{
+return dict___sizeof___impl(self);
+}
+
 PyDoc_STRVAR(dict___reverseddoc__,
 "__reversed__($self, /)\n"
 "--\n"
@@ -193,4 +247,58 @@ dict___reversed__(PyDictObject *self, PyObject 
*Py_UNUSED(ignored))
 {
 return dict___reversed___impl(self);
 }
-/*[clinic end generated code: output=17c3c4cf9a9b95a7 input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(dict_keys__doc__,
+"keys($self, /)\n"
+"--\n"
+"\n"
+"Return a set-like object providing a view on the dict\'s keys.");
+
+#define DICT_KEYS_METHODDEF\
+{"keys", (PyCFunction)dict_keys, METH_NOARGS, dict_keys__doc__},
+
+static PyObject *
+dict_keys_impl(PyDictObject *self);
+
+static PyObject *
+dict_keys(PyDictObject *self, PyObject *Py_UNUSED(ignored))
+{
+return dict_keys_impl(self);
+}
+
+PyDoc_STRVAR(dict_items__doc__,
+"items($self, /)\n"
+"--\n"
+"\n"
+"Return a set-like object providing a view on the dict\'s items.");
+
+#define DICT_ITEMS_METHODDEF\
+{"items", (PyCFunction)dict_items, METH_NOARGS, dict_items__doc__},
+
+static PyObject *
+dict_items_impl(PyDictObject *self);
+
+static PyObject *
+dict_items(PyDictObject *self, PyObject *Py_UNUSED(ignored))
+{
+return dict_items_impl(self);
+}
+
+PyDoc_STRVAR(dict_values__doc__,
+"values($self, /)\n"
+"--\n"
+"\n"
+"Return an object providing a view on the dict\'s values.");
+
+#define DICT_VALUES_METHODDEF\
+{"values", (PyCFunction)dict_values, METH_NOARGS, dict_values__doc__},
+
+static PyObject *
+dict_values_impl(PyDictObject *self);
+
+static PyObject *
+dict_values(PyDictObject *self, PyObject *Py_UNUSED(ignored))
+{
+return dict_values_impl(self);
+}
+/*[clinic end generated code: output=f3ac47dfbf341b23 input=a9049054013a1b77]*/
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 2482a918ba983b..e608b91679b568 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2641,9 +2641,14 @@ static PyMappingMethods dict_as_mapping = {
 dict_ass_sub, /*mp_ass_subscript*/
 };
 
-static PyObject *
-dict_keys(PyDictObject *mp)
+PyObject *
+PyDict_Keys(PyObject *dict)
 {
+if (dict == NULL ||

[Python-checkins] GH-114456: lower the recursion limit under WASI for debug builds (GH-114457)

2024-01-23 Thread brettcannon
https://github.com/python/cpython/commit/f59f90b5bccb9e7ac522bc779ab1f6bf11bb4aa3
commit: f59f90b5bccb9e7ac522bc779ab1f6bf11bb4aa3
branch: main
author: Brett Cannon 
committer: brettcannon 
date: 2024-01-23T15:48:14-08:00
summary:

GH-114456: lower the recursion limit under WASI for debug builds (GH-114457)

Testing under wasmtime 16.0.0 w/ code from 
https://github.com/python/cpython/issues/114413 is how the value was found.

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-01-22-15-10-01.gh-issue-114456.fBFEJF.rst
M Include/cpython/pystate.h
M Lib/test/test_dynamic.py
M Lib/test/test_pickle.py

diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 60b056bdcc2f1f..1dbf97660f382f 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -217,11 +217,14 @@ struct _ts {
 #ifdef Py_DEBUG
// A debug build is likely built with low optimization level which implies
// higher stack memory usage than a release build: use a lower limit.
-#  define Py_C_RECURSION_LIMIT 500
+#  if defined(__wasi__)
+ // Based on wasmtime 16.
+#define Py_C_RECURSION_LIMIT 150
+#  else
+#define Py_C_RECURSION_LIMIT 500
+#  endif
 #elif defined(__wasi__)
-   // WASI has limited call stack. Python's recursion limit depends on code
-   // layout, optimization, and WASI runtime. Wasmtime can handle about 700
-   // recursions, sometimes less. 500 is a more conservative limit.
+   // Based on wasmtime 16.
 #  define Py_C_RECURSION_LIMIT 500
 #elif defined(__s390x__)
 #  define Py_C_RECURSION_LIMIT 800
diff --git a/Lib/test/test_dynamic.py b/Lib/test/test_dynamic.py
index 0aa3be6a1bde6a..3928bbab4423c2 100644
--- a/Lib/test/test_dynamic.py
+++ b/Lib/test/test_dynamic.py
@@ -4,7 +4,7 @@
 import sys
 import unittest
 
-from test.support import swap_item, swap_attr
+from test.support import is_wasi, Py_DEBUG, swap_item, swap_attr
 
 
 class RebindBuiltinsTests(unittest.TestCase):
@@ -134,6 +134,7 @@ def test_eval_gives_lambda_custom_globals(self):
 
 self.assertEqual(foo(), 7)
 
[email protected](is_wasi and Py_DEBUG, "stack depth too shallow in pydebug 
WASI")
 def test_load_global_specialization_failure_keeps_oparg(self):
 # https://github.com/python/cpython/issues/91625
 class MyGlobals(dict):
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index f6405d6dd44ef6..b2245ddf72f708 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -402,7 +402,9 @@ def recurse(deep):
 check_unpickler(recurse(1), 32, 20)
 check_unpickler(recurse(20), 32, 20)
 check_unpickler(recurse(50), 64, 60)
-check_unpickler(recurse(100), 128, 140)
+if not (support.is_wasi and support.Py_DEBUG):
+# stack depth too shallow in pydebug WASI.
+check_unpickler(recurse(100), 128, 140)
 
 u = unpickler(io.BytesIO(pickle.dumps('a', 0)),
   encoding='ASCII', errors='strict')
diff --git a/Misc/NEWS.d/next/Core and 
Builtins/2024-01-22-15-10-01.gh-issue-114456.fBFEJF.rst b/Misc/NEWS.d/next/Core 
and Builtins/2024-01-22-15-10-01.gh-issue-114456.fBFEJF.rst
new file mode 100644
index 00..2b30ad98fb5c79
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-01-22-15-10-01.gh-issue-114456.fBFEJF.rst 
@@ -0,0 +1 @@
+Lower the recursion limit under a debug build of WASI.

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] Fix a typo in the contextlib documentation (#114507)

2024-01-23 Thread AA-Turner
https://github.com/python/cpython/commit/82cd8fee31823b560e664f81b430a9186d6019dd
commit: 82cd8fee31823b560e664f81b430a9186d6019dd
branch: main
author: Daniel Hollas 
committer: AA-Turner <[email protected]>
date: 2024-01-24T05:16:31+01:00
summary:

Fix a typo in the contextlib documentation (#114507)

files:
M Doc/library/contextlib.rst

diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index b73373bc2363fb..73e53aec9cbf1c 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -185,7 +185,7 @@ Functions and classes provided:
.. note::
 
   Most types managing resources support the :term:`context manager` 
protocol,
-  which closes *thing* on leaving the :keyword:`with` statment.
+  which closes *thing* on leaving the :keyword:`with` statement.
   As such, :func:`!closing` is most useful for third party types that don't
   support context managers.
   This example is purely for illustration purposes,

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.12] Fix a typo in the contextlib documentation (GH-114507) (#114514)

2024-01-23 Thread AA-Turner
https://github.com/python/cpython/commit/2692f5b6d2bda55fa651f1c6b1b36cfabf349231
commit: 2692f5b6d2bda55fa651f1c6b1b36cfabf349231
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-24T04:22:37Z
summary:

[3.12] Fix a typo in the contextlib documentation (GH-114507) (#114514)

files:
M Doc/library/contextlib.rst

diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index b73373bc2363fb..73e53aec9cbf1c 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -185,7 +185,7 @@ Functions and classes provided:
.. note::
 
   Most types managing resources support the :term:`context manager` 
protocol,
-  which closes *thing* on leaving the :keyword:`with` statment.
+  which closes *thing* on leaving the :keyword:`with` statement.
   As such, :func:`!closing` is most useful for third party types that don't
   support context managers.
   This example is purely for illustration purposes,

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.11] Fix a typo in the contextlib documentation (GH-114507) (#114515)

2024-01-23 Thread AA-Turner
https://github.com/python/cpython/commit/018b637a529d9b56eea423c55627cb5cba03954b
commit: 018b637a529d9b56eea423c55627cb5cba03954b
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-24T04:22:38Z
summary:

[3.11] Fix a typo in the contextlib documentation (GH-114507) (#114515)

files:
M Doc/library/contextlib.rst

diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index fd264883c6823c..7f798e03a3f014 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -185,7 +185,7 @@ Functions and classes provided:
.. note::
 
   Most types managing resources support the :term:`context manager` 
protocol,
-  which closes *thing* on leaving the :keyword:`with` statment.
+  which closes *thing* on leaving the :keyword:`with` statement.
   As such, :func:`!closing` is most useful for third party types that don't
   support context managers.
   This example is purely for illustration purposes,

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-113205: test_multiprocessing.test_terminate: Give tasks a chance to start (GH-114249)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/ce75b4c26d18dcd840fd2e7ee362a84209648d06
commit: ce75b4c26d18dcd840fd2e7ee362a84209648d06
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-01-24T09:13:09+02:00
summary:

gh-113205: test_multiprocessing.test_terminate: Give tasks a chance to start 
(GH-114249)

files:
M Lib/test/_test_multiprocessing.py

diff --git a/Lib/test/_test_multiprocessing.py 
b/Lib/test/_test_multiprocessing.py
index 6a050fa541db1e..c0d3ca50f17d69 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -2705,6 +2705,7 @@ def test_terminate(self):
 p = self.Pool(3)
 args = [sleep_time for i in range(10_000)]
 result = p.map_async(time.sleep, args, chunksize=1)
+time.sleep(0.2)  # give some tasks a chance to start
 p.terminate()
 p.join()
 

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-101100: Fix sphinx warnings in `asyncio-task.rst` (#114469)

2024-01-23 Thread hugovk
https://github.com/python/cpython/commit/1e4f00ebd8db44a031b61eed0803b4c3d731aed7
commit: 1e4f00ebd8db44a031b61eed0803b4c3d731aed7
branch: main
author: Nikita Sobolev 
committer: hugovk <[email protected]>
date: 2024-01-24T00:23:34-07:00
summary:

gh-101100: Fix sphinx warnings in `asyncio-task.rst` (#114469)

Co-authored-by: Serhiy Storchaka 

files:
M Doc/library/asyncio-task.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index 797065c8ccf894..24bd36e6431b4f 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -828,23 +828,22 @@ Waiting Primitives
*return_when* indicates when this function should return.  It must
be one of the following constants:
 
-   .. tabularcolumns:: |l|L|
-
-   +-++
-   | Constant| Description|
-   +=++
-   | :const:`FIRST_COMPLETED`| The function will return when any  |
-   | | future finishes or is cancelled.   |
-   +-++
-   | :const:`FIRST_EXCEPTION`| The function will return when any  |
-   | | future finishes by raising an  |
-   | | exception.  If no future raises an |
-   | | exception then it is equivalent to |
-   | | :const:`ALL_COMPLETED`.|
-   +-++
-   | :const:`ALL_COMPLETED`  | The function will return when all  |
-   | | futures finish or are cancelled.   |
-   +-++
+   .. list-table::
+  :header-rows: 1
+
+  * - Constant
+- Description
+
+  * - .. data:: FIRST_COMPLETED
+- The function will return when any future finishes or is cancelled.
+
+  * - .. data:: FIRST_EXCEPTION
+- The function will return when any future finishes by raising an
+  exception. If no future raises an exception
+  then it is equivalent to :const:`ALL_COMPLETED`.
+
+  * - .. data:: ALL_COMPLETED
+- The function will return when all futures finish or are cancelled.
 
Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the
futures when a timeout occurs.
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index 221a1f05c11e49..2114ec6dfacd7d 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -27,7 +27,6 @@ Doc/library/ast.rst
 Doc/library/asyncio-extending.rst
 Doc/library/asyncio-policy.rst
 Doc/library/asyncio-subprocess.rst
-Doc/library/asyncio-task.rst
 Doc/library/bdb.rst
 Doc/library/collections.rst
 Doc/library/concurrent.futures.rst

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.11] gh-113205: test_multiprocessing.test_terminate: Give tasks a chance to start (GH-114249) (GH-114517)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/b39a314edaf15716e9d9a2ff1d11ac79e09d97fa
commit: b39a314edaf15716e9d9a2ff1d11ac79e09d97fa
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-24T07:26:58Z
summary:

[3.11] gh-113205: test_multiprocessing.test_terminate: Give tasks a chance to 
start (GH-114249) (GH-114517)

(cherry picked from commit ce75b4c26d18dcd840fd2e7ee362a84209648d06)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/_test_multiprocessing.py

diff --git a/Lib/test/_test_multiprocessing.py 
b/Lib/test/_test_multiprocessing.py
index 95ef18958e6378..a5c62b9ea645e7 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -2704,6 +2704,7 @@ def test_terminate(self):
 p = self.Pool(3)
 args = [sleep_time for i in range(10_000)]
 result = p.map_async(time.sleep, args, chunksize=1)
+time.sleep(0.2)  # give some tasks a chance to start
 p.terminate()
 p.join()
 

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.11] gh-101100: Fix sphinx warnings in `asyncio-task.rst` (GH-114469) (#114518)

2024-01-23 Thread hugovk
https://github.com/python/cpython/commit/208db89fe66077678e2670ec262ee9cd69c284e7
commit: 208db89fe66077678e2670ec262ee9cd69c284e7
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2024-01-24T00:32:00-07:00
summary:

[3.11] gh-101100: Fix sphinx warnings in `asyncio-task.rst` (GH-114469) 
(#114518)

Co-authored-by: Nikita Sobolev 
Co-authored-by: Serhiy Storchaka 

files:
M Doc/library/asyncio-task.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index 0944aef0ab619d..12d12ffa2e8994 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -775,23 +775,22 @@ Waiting Primitives
*return_when* indicates when this function should return.  It must
be one of the following constants:
 
-   .. tabularcolumns:: |l|L|
-
-   +-++
-   | Constant| Description|
-   +=++
-   | :const:`FIRST_COMPLETED`| The function will return when any  |
-   | | future finishes or is cancelled.   |
-   +-++
-   | :const:`FIRST_EXCEPTION`| The function will return when any  |
-   | | future finishes by raising an  |
-   | | exception.  If no future raises an |
-   | | exception then it is equivalent to |
-   | | :const:`ALL_COMPLETED`.|
-   +-++
-   | :const:`ALL_COMPLETED`  | The function will return when all  |
-   | | futures finish or are cancelled.   |
-   +-++
+   .. list-table::
+  :header-rows: 1
+
+  * - Constant
+- Description
+
+  * - .. data:: FIRST_COMPLETED
+- The function will return when any future finishes or is cancelled.
+
+  * - .. data:: FIRST_EXCEPTION
+- The function will return when any future finishes by raising an
+  exception. If no future raises an exception
+  then it is equivalent to :const:`ALL_COMPLETED`.
+
+  * - .. data:: ALL_COMPLETED
+- The function will return when all futures finish or are cancelled.
 
Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the
futures when a timeout occurs.
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index 1e244bf325b38d..7933382d3911fa 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -27,7 +27,6 @@ Doc/library/ast.rst
 Doc/library/asyncio-extending.rst
 Doc/library/asyncio-policy.rst
 Doc/library/asyncio-subprocess.rst
-Doc/library/asyncio-task.rst
 Doc/library/bdb.rst
 Doc/library/collections.rst
 Doc/library/concurrent.futures.rst

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.12] gh-101100: Fix sphinx warnings in `asyncio-task.rst` (GH-114469) (#114519)

2024-01-23 Thread hugovk
https://github.com/python/cpython/commit/0c42897f8d3bf0fbd4d10463a0628d6074efa7e6
commit: 0c42897f8d3bf0fbd4d10463a0628d6074efa7e6
branch: 3.12
author: Hugo van Kemenade <[email protected]>
committer: hugovk <[email protected]>
date: 2024-01-24T00:40:22-07:00
summary:

[3.12] gh-101100: Fix sphinx warnings in `asyncio-task.rst` (GH-114469) 
(#114519)

Co-authored-by: Nikita Sobolev 
Co-authored-by: Serhiy Storchaka 

files:
M Doc/library/asyncio-task.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index a3ea050c0713ac..a964c8b797ef96 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -825,23 +825,22 @@ Waiting Primitives
*return_when* indicates when this function should return.  It must
be one of the following constants:
 
-   .. tabularcolumns:: |l|L|
-
-   +-++
-   | Constant| Description|
-   +=++
-   | :const:`FIRST_COMPLETED`| The function will return when any  |
-   | | future finishes or is cancelled.   |
-   +-++
-   | :const:`FIRST_EXCEPTION`| The function will return when any  |
-   | | future finishes by raising an  |
-   | | exception.  If no future raises an |
-   | | exception then it is equivalent to |
-   | | :const:`ALL_COMPLETED`.|
-   +-++
-   | :const:`ALL_COMPLETED`  | The function will return when all  |
-   | | futures finish or are cancelled.   |
-   +-++
+   .. list-table::
+  :header-rows: 1
+
+  * - Constant
+- Description
+
+  * - .. data:: FIRST_COMPLETED
+- The function will return when any future finishes or is cancelled.
+
+  * - .. data:: FIRST_EXCEPTION
+- The function will return when any future finishes by raising an
+  exception. If no future raises an exception
+  then it is equivalent to :const:`ALL_COMPLETED`.
+
+  * - .. data:: ALL_COMPLETED
+- The function will return when all futures finish or are cancelled.
 
Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the
futures when a timeout occurs.
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index df34700e285601..cb6e70a6a2b093 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -30,7 +30,6 @@ Doc/library/ast.rst
 Doc/library/asyncio-extending.rst
 Doc/library/asyncio-policy.rst
 Doc/library/asyncio-subprocess.rst
-Doc/library/asyncio-task.rst
 Doc/library/audioop.rst
 Doc/library/bdb.rst
 Doc/library/cgi.rst

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.12] gh-113205: test_multiprocessing.test_terminate: Give tasks a chance to start (GH-114249) (GH-114516)

2024-01-23 Thread serhiy-storchaka
https://github.com/python/cpython/commit/03f8f77885cd1bf802cc8945dfdb308772c471ac
commit: 03f8f77885cd1bf802cc8945dfdb308772c471ac
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-24T07:46:27Z
summary:

[3.12] gh-113205: test_multiprocessing.test_terminate: Give tasks a chance to 
start (GH-114249) (GH-114516)

(cherry picked from commit ce75b4c26d18dcd840fd2e7ee362a84209648d06)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/_test_multiprocessing.py

diff --git a/Lib/test/_test_multiprocessing.py 
b/Lib/test/_test_multiprocessing.py
index 4cadefe40af71e..e42c7ab4bde9af 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -2705,6 +2705,7 @@ def test_terminate(self):
 p = self.Pool(3)
 args = [sleep_time for i in range(10_000)]
 result = p.map_async(time.sleep, args, chunksize=1)
+time.sleep(0.2)  # give some tasks a chance to start
 p.terminate()
 p.join()
 

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]