[Python-checkins] GH-113595: Don't enter invalid executor (GH-113596)

2024-01-03 Thread markshannon
https://github.com/python/cpython/commit/dc8df6e84024b79aa96e85a64f354bf8e827bcba
commit: dc8df6e84024b79aa96e85a64f354bf8e827bcba
branch: main
author: Mark Shannon 
committer: markshannon 
date: 2024-01-03T11:01:13Z
summary:

GH-113595: Don't enter invalid executor (GH-113596)

files:
M Python/bytecodes.c
M Python/generated_cases.c.h

diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 29e1dab184ef4e..2eeeac53e1dd7e 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -2364,17 +2364,27 @@ dummy_func(
 
 PyCodeObject *code = _PyFrame_GetCode(frame);
 _PyExecutorObject *executor = (_PyExecutorObject 
*)code->co_executors->executors[oparg&255];
-Py_INCREF(executor);
-if (executor->execute == _PyUOpExecute) {
-current_executor = (_PyUOpExecutorObject *)executor;
-GOTO_TIER_TWO();
+if (executor->vm_data.valid) {
+Py_INCREF(executor);
+if (executor->execute == _PyUOpExecute) {
+current_executor = (_PyUOpExecutorObject *)executor;
+GOTO_TIER_TWO();
+}
+next_instr = executor->execute(executor, frame, stack_pointer);
+frame = tstate->current_frame;
+if (next_instr == NULL) {
+goto resume_with_error;
+}
+stack_pointer = _PyFrame_GetStackPointer(frame);
 }
-next_instr = executor->execute(executor, frame, stack_pointer);
-frame = tstate->current_frame;
-if (next_instr == NULL) {
-goto resume_with_error;
+else {
+opcode = this_instr->op.code = executor->vm_data.opcode;
+this_instr->op.arg = executor->vm_data.oparg;
+oparg = (oparg & (~255)) | executor->vm_data.oparg;
+code->co_executors->executors[oparg&255] = NULL;
+Py_DECREF(executor);
+DISPATCH_GOTO();
 }
-stack_pointer = _PyFrame_GetStackPointer(frame);
 }
 
 replaced op(_POP_JUMP_IF_FALSE, (cond -- )) {
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index ce31967b7912d7..99fd169ca4fec3 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -2371,24 +2371,34 @@
 }
 
 TARGET(ENTER_EXECUTOR) {
-frame->instr_ptr = next_instr;
+_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
 next_instr += 1;
 INSTRUCTION_STATS(ENTER_EXECUTOR);
 TIER_ONE_ONLY
 CHECK_EVAL_BREAKER();
 PyCodeObject *code = _PyFrame_GetCode(frame);
 _PyExecutorObject *executor = (_PyExecutorObject 
*)code->co_executors->executors[oparg&255];
-Py_INCREF(executor);
-if (executor->execute == _PyUOpExecute) {
-current_executor = (_PyUOpExecutorObject *)executor;
-GOTO_TIER_TWO();
+if (executor->vm_data.valid) {
+Py_INCREF(executor);
+if (executor->execute == _PyUOpExecute) {
+current_executor = (_PyUOpExecutorObject *)executor;
+GOTO_TIER_TWO();
+}
+next_instr = executor->execute(executor, frame, stack_pointer);
+frame = tstate->current_frame;
+if (next_instr == NULL) {
+goto resume_with_error;
+}
+stack_pointer = _PyFrame_GetStackPointer(frame);
 }
-next_instr = executor->execute(executor, frame, stack_pointer);
-frame = tstate->current_frame;
-if (next_instr == NULL) {
-goto resume_with_error;
+else {
+opcode = this_instr->op.code = executor->vm_data.opcode;
+this_instr->op.arg = executor->vm_data.oparg;
+oparg = (oparg & (~255)) | executor->vm_data.oparg;
+code->co_executors->executors[oparg&255] = NULL;
+Py_DECREF(executor);
+DISPATCH_GOTO();
 }
-stack_pointer = _PyFrame_GetStackPointer(frame);
 DISPATCH();
 }
 

___
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-113637: Let c_annotations.py to handle the spacing of Limited/Unstable API & Stable ABI translation strings (#113638)

2024-01-03 Thread hugovk
https://github.com/python/cpython/commit/ea978c645edd7bc29d811c61477dff766d7318b6
commit: ea978c645edd7bc29d811c61477dff766d7318b6
branch: main
author: Ege Akman 
committer: hugovk 
date: 2024-01-03T13:22:38+02:00
summary:

gh-113637: Let c_annotations.py to handle the spacing of Limited/Unstable API & 
Stable ABI translation strings (#113638)

files:
M Doc/tools/extensions/c_annotations.py
M Doc/tools/templates/dummy.html
M Misc/ACKS

diff --git a/Doc/tools/extensions/c_annotations.py 
b/Doc/tools/extensions/c_annotations.py
index 42c2f10e0be260..ba37634545c2cf 100644
--- a/Doc/tools/extensions/c_annotations.py
+++ b/Doc/tools/extensions/c_annotations.py
@@ -126,7 +126,8 @@ def add_annotations(self, app, doctree):
 f"Object type mismatch in limited API annotation "
 f"for {name}: {record['role']!r} != {objtype!r}")
 stable_added = record['added']
-message = sphinx_gettext(' Part of the ')
+message = sphinx_gettext('Part of the')
+message = message.center(len(message) + 2)
 emph_node = nodes.emphasis(message, message,
classes=['stableabi'])
 ref_node = addnodes.pending_xref(
@@ -139,27 +140,27 @@ def add_annotations(self, app, doctree):
 ref_node += nodes.Text(sphinx_gettext('Stable ABI'))
 emph_node += ref_node
 if struct_abi_kind == 'opaque':
-emph_node += nodes.Text(sphinx_gettext(' (as an opaque 
struct)'))
+emph_node += nodes.Text(' ' + sphinx_gettext('(as an 
opaque struct)'))
 elif struct_abi_kind == 'full-abi':
-emph_node += nodes.Text(sphinx_gettext(' (including all 
members)'))
+emph_node += nodes.Text(' ' + sphinx_gettext('(including 
all members)'))
 if record['ifdef_note']:
 emph_node += nodes.Text(' ' + record['ifdef_note'])
 if stable_added == '3.2':
 # Stable ABI was introduced in 3.2.
 pass
 else:
-emph_node += nodes.Text(sphinx_gettext(' since version 
%s') % stable_added)
+emph_node += nodes.Text(' ' + sphinx_gettext('since 
version %s') % stable_added)
 emph_node += nodes.Text('.')
 if struct_abi_kind == 'members':
 emph_node += nodes.Text(
-sphinx_gettext(' (Only some members are part of the 
stable ABI.)'))
+' ' + sphinx_gettext('(Only some members are part of 
the stable ABI.)'))
 node.insert(0, emph_node)
 
 # Unstable API annotation.
 if name.startswith('PyUnstable'):
 warn_node = nodes.admonition(
 classes=['unstable-c-api', 'warning'])
-message = sphinx_gettext('This is ')
+message = sphinx_gettext('This is') + ' '
 emph_node = nodes.emphasis(message, message)
 ref_node = addnodes.pending_xref(
 'Unstable API', refdomain="std",
diff --git a/Doc/tools/templates/dummy.html b/Doc/tools/templates/dummy.html
index 3a0acab8836b11..49c2a71a5e40cf 100644
--- a/Doc/tools/templates/dummy.html
+++ b/Doc/tools/templates/dummy.html
@@ -9,14 +9,14 @@
 
 In extensions/c_annotations.py:
 
-{% trans %} Part of the {% endtrans %}
+{% trans %}Part of the{% endtrans %}
 {% trans %}Limited API{% endtrans %}
 {% trans %}Stable ABI{% endtrans %}
-{% trans %} (as an opaque struct){% endtrans %}
-{% trans %} (including all members){% endtrans %}
-{% trans %} since version %s{% endtrans %}
-{% trans %} (Only some members are part of the stable ABI.){% endtrans %}
-{% trans %}This is {% endtrans %}
+{% trans %}(as an opaque struct){% endtrans %}
+{% trans %}(including all members){% endtrans %}
+{% trans %}since version %s{% endtrans %}
+{% trans %}(Only some members are part of the stable ABI.){% endtrans %}
+{% trans %}This is{% endtrans %}
 {% trans %}Unstable API{% endtrans %}
 {% trans %}. It may change without warning in minor releases.{% endtrans %}
 {% trans %}Return value: Always NULL.{% endtrans %}
diff --git a/Misc/ACKS b/Misc/ACKS
index 6b98be32905391..ab1255be2d58fa 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -31,6 +31,7 @@ Farhan Ahmad
 Matthew Ahrens
 Nir Aides
 Akira
+Ege Akman
 Yaniv Aknin
 Jyrki Alakuijala
 Tatiana Al-Chueyr

___
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] `functools.partial` docs: Use the more common spelling for "referenceable" (#113675)

2024-01-03 Thread AlexWaygood
https://github.com/python/cpython/commit/4de468cce106221968d7ac08ddd94571b903c194
commit: 4de468cce106221968d7ac08ddd94571b903c194
branch: main
author: Rodrigo Girão Serrão 
<[email protected]>
committer: AlexWaygood 
date: 2024-01-03T12:50:44Z
summary:

`functools.partial` docs: Use the more common spelling for "referenceable" 
(#113675)

files:
M Doc/library/functools.rst

diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index 69ec1eb3ecd89d..6749a5137b446f 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -742,7 +742,7 @@ have three read-only attributes:
called.
 
 :class:`partial` objects are like :class:`function` objects in that they are
-callable, weak referencable, and can have attributes.  There are some important
+callable, weak referenceable, and can have attributes.  There are some 
important
 differences.  For instance, the :attr:`~definition.__name__` and 
:attr:`__doc__` attributes
 are not created automatically.  Also, :class:`partial` objects defined in
 classes behave like static methods and do not transform into bound methods

___
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] `functools.partial` docs: Use the more common spelling for "referenceable" (GH-113675) (#113677)

2024-01-03 Thread AlexWaygood
https://github.com/python/cpython/commit/c267901289404ddb731806778e1aee4806d926b5
commit: c267901289404ddb731806778e1aee4806d926b5
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AlexWaygood 
date: 2024-01-03T12:57:05Z
summary:

[3.12] `functools.partial` docs: Use the more common spelling for 
"referenceable" (GH-113675) (#113677)

`functools.partial` docs: Use the more common spelling for "referenceable" 
(GH-113675)
(cherry picked from commit 4de468cce106221968d7ac08ddd94571b903c194)

Co-authored-by: Rodrigo Girão Serrão 
<[email protected]>

files:
M Doc/library/functools.rst

diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index f736eb0aca1ac5..f28fc8499139f1 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -740,7 +740,7 @@ have three read-only attributes:
called.
 
 :class:`partial` objects are like :class:`function` objects in that they are
-callable, weak referencable, and can have attributes.  There are some important
+callable, weak referenceable, and can have attributes.  There are some 
important
 differences.  For instance, the :attr:`~definition.__name__` and 
:attr:`__doc__` attributes
 are not created automatically.  Also, :class:`partial` objects defined in
 classes behave like static methods and do not transform into bound methods

___
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-113637: Let c_annotations.py to handle the spacing of Limited/Unstable API & Stable ABI translation strings (GH-113638) (#113676)

2024-01-03 Thread hugovk
https://github.com/python/cpython/commit/5f3fe8448c30ec44c545b3d8f98cb240188c08d4
commit: 5f3fe8448c30ec44c545b3d8f98cb240188c08d4
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: hugovk 
date: 2024-01-03T14:57:32+02:00
summary:

[3.12] gh-113637: Let c_annotations.py to handle the spacing of 
Limited/Unstable API & Stable ABI translation strings (GH-113638) (#113676)

Co-authored-by: Ege Akman 

files:
M Doc/tools/extensions/c_annotations.py
M Doc/tools/templates/dummy.html
M Misc/ACKS

diff --git a/Doc/tools/extensions/c_annotations.py 
b/Doc/tools/extensions/c_annotations.py
index 42c2f10e0be260..ba37634545c2cf 100644
--- a/Doc/tools/extensions/c_annotations.py
+++ b/Doc/tools/extensions/c_annotations.py
@@ -126,7 +126,8 @@ def add_annotations(self, app, doctree):
 f"Object type mismatch in limited API annotation "
 f"for {name}: {record['role']!r} != {objtype!r}")
 stable_added = record['added']
-message = sphinx_gettext(' Part of the ')
+message = sphinx_gettext('Part of the')
+message = message.center(len(message) + 2)
 emph_node = nodes.emphasis(message, message,
classes=['stableabi'])
 ref_node = addnodes.pending_xref(
@@ -139,27 +140,27 @@ def add_annotations(self, app, doctree):
 ref_node += nodes.Text(sphinx_gettext('Stable ABI'))
 emph_node += ref_node
 if struct_abi_kind == 'opaque':
-emph_node += nodes.Text(sphinx_gettext(' (as an opaque 
struct)'))
+emph_node += nodes.Text(' ' + sphinx_gettext('(as an 
opaque struct)'))
 elif struct_abi_kind == 'full-abi':
-emph_node += nodes.Text(sphinx_gettext(' (including all 
members)'))
+emph_node += nodes.Text(' ' + sphinx_gettext('(including 
all members)'))
 if record['ifdef_note']:
 emph_node += nodes.Text(' ' + record['ifdef_note'])
 if stable_added == '3.2':
 # Stable ABI was introduced in 3.2.
 pass
 else:
-emph_node += nodes.Text(sphinx_gettext(' since version 
%s') % stable_added)
+emph_node += nodes.Text(' ' + sphinx_gettext('since 
version %s') % stable_added)
 emph_node += nodes.Text('.')
 if struct_abi_kind == 'members':
 emph_node += nodes.Text(
-sphinx_gettext(' (Only some members are part of the 
stable ABI.)'))
+' ' + sphinx_gettext('(Only some members are part of 
the stable ABI.)'))
 node.insert(0, emph_node)
 
 # Unstable API annotation.
 if name.startswith('PyUnstable'):
 warn_node = nodes.admonition(
 classes=['unstable-c-api', 'warning'])
-message = sphinx_gettext('This is ')
+message = sphinx_gettext('This is') + ' '
 emph_node = nodes.emphasis(message, message)
 ref_node = addnodes.pending_xref(
 'Unstable API', refdomain="std",
diff --git a/Doc/tools/templates/dummy.html b/Doc/tools/templates/dummy.html
index 3a0acab8836b11..49c2a71a5e40cf 100644
--- a/Doc/tools/templates/dummy.html
+++ b/Doc/tools/templates/dummy.html
@@ -9,14 +9,14 @@
 
 In extensions/c_annotations.py:
 
-{% trans %} Part of the {% endtrans %}
+{% trans %}Part of the{% endtrans %}
 {% trans %}Limited API{% endtrans %}
 {% trans %}Stable ABI{% endtrans %}
-{% trans %} (as an opaque struct){% endtrans %}
-{% trans %} (including all members){% endtrans %}
-{% trans %} since version %s{% endtrans %}
-{% trans %} (Only some members are part of the stable ABI.){% endtrans %}
-{% trans %}This is {% endtrans %}
+{% trans %}(as an opaque struct){% endtrans %}
+{% trans %}(including all members){% endtrans %}
+{% trans %}since version %s{% endtrans %}
+{% trans %}(Only some members are part of the stable ABI.){% endtrans %}
+{% trans %}This is{% endtrans %}
 {% trans %}Unstable API{% endtrans %}
 {% trans %}. It may change without warning in minor releases.{% endtrans %}
 {% trans %}Return value: Always NULL.{% endtrans %}
diff --git a/Misc/ACKS b/Misc/ACKS
index 7438debc4af8c6..f951d810669fcc 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -31,6 +31,7 @@ Farhan Ahmad
 Matthew Ahrens
 Nir Aides
 Akira
+Ege Akman
 Yaniv Aknin
 Jyrki Alakuijala
 Tatiana Al-Chueyr

___
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 for removed dead batteries (#113669)

2024-01-03 Thread hugovk
https://github.com/python/cpython/commit/fab7ad62ceca1f88767bca4e1f06f8e4b1faef2f
commit: fab7ad62ceca1f88767bca4e1f06f8e4b1faef2f
branch: main
author: Hugo van Kemenade 
committer: hugovk 
date: 2024-01-03T13:04:26Z
summary:

gh-101100: Fix Sphinx warnings for removed dead batteries (#113669)

Co-authored-by: Alex Waygood 

files:
M Doc/whatsnew/2.4.rst
M Doc/whatsnew/2.6.rst
M Doc/whatsnew/3.10.rst
M Doc/whatsnew/3.11.rst
M Doc/whatsnew/3.2.rst
M Doc/whatsnew/3.3.rst
M Doc/whatsnew/3.4.rst
M Doc/whatsnew/3.5.rst
M Doc/whatsnew/3.6.rst
M Doc/whatsnew/3.7.rst
M Doc/whatsnew/3.8.rst
M Doc/whatsnew/3.9.rst
M Misc/NEWS.d/3.10.0a1.rst
M Misc/NEWS.d/3.11.0a1.rst
M Misc/NEWS.d/3.11.0a7.rst
M Misc/NEWS.d/3.12.0a1.rst
M Misc/NEWS.d/3.12.0a2.rst
M Misc/NEWS.d/3.8.0a1.rst
M Misc/NEWS.d/3.8.0a4.rst

diff --git a/Doc/whatsnew/2.4.rst b/Doc/whatsnew/2.4.rst
index 6df59dd245ff55..e9a59f4a62551a 100644
--- a/Doc/whatsnew/2.4.rst
+++ b/Doc/whatsnew/2.4.rst
@@ -995,7 +995,7 @@ fixes.  Here's a partial list of the most notable changes, 
sorted alphabetically
 by module name. Consult the :file:`Misc/NEWS` file in the source tree for a 
more
 complete list of changes, or look through the CVS logs for all the details.
 
-* The :mod:`asyncore` module's :func:`loop` function now has a *count* 
parameter
+* The :mod:`!asyncore` module's :func:`!loop` function now has a *count* 
parameter
   that lets you perform a limited number of passes through the polling loop.  
The
   default is still to loop forever.
 
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst
index e8c1709c42abac..d947f61b50cfe0 100644
--- a/Doc/whatsnew/2.6.rst
+++ b/Doc/whatsnew/2.6.rst
@@ -1789,7 +1789,7 @@ changes, sorted alphabetically by module name. Consult the
 :file:`Misc/NEWS` file in the source tree for a more complete list of
 changes, or look through the Subversion logs for all the details.
 
-* The :mod:`asyncore` and :mod:`asynchat` modules are
+* The :mod:`!asyncore` and :mod:`!asynchat` modules are
   being actively maintained again, and a number of patches and bugfixes
   were applied.  (Maintained by Josiah Carlson; see :issue:`1736190` for
   one patch.)
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 2da90b7ed55744..a8a27bfd3dc1bc 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -1278,7 +1278,7 @@ Add negative indexing support to :attr:`PurePath.parents
 (Contributed by Yaroslav Pankovych in :issue:`21041`.)
 
 Add :meth:`Path.hardlink_to ` method that
-supersedes :meth:`~pathlib.Path.link_to`. The new method has the same argument
+supersedes :meth:`!link_to`. The new method has the same argument
 order as :meth:`~pathlib.Path.symlink_to`.
 (Contributed by Barney Gale in :issue:`39950`.)
 
@@ -1740,7 +1740,7 @@ Deprecated
 
   (Contributed by Jelle Zijlstra in :gh:`87889`.)
 
-* :meth:`pathlib.Path.link_to` is deprecated and slated for removal in
+* :meth:`!pathlib.Path.link_to` is deprecated and slated for removal in
   Python 3.12. Use :meth:`pathlib.Path.hardlink_to` instead.
   (Contributed by Barney Gale in :issue:`39950`.)
 
@@ -1771,7 +1771,7 @@ Deprecated
   * NPN features like :meth:`ssl.SSLSocket.selected_npn_protocol` and
 :meth:`ssl.SSLContext.set_npn_protocols` are replaced by ALPN.
 
-* The threading debug (:envvar:`PYTHONTHREADDEBUG` environment variable) is
+* The threading debug (:envvar:`!PYTHONTHREADDEBUG` environment variable) is
   deprecated in Python 3.10 and will be removed in Python 3.12. This feature
   requires a :ref:`debug build of Python `.
   (Contributed by Victor Stinner in :issue:`44584`.)
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index ce4c98eba71443..cb646a54df3607 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -1747,7 +1747,7 @@ Modules
   (Contributed by Brett Cannon in :issue:`47061` and Victor Stinner in
   :gh:`68966`.)
 
-* The :mod:`asynchat`, :mod:`asyncore` and  :mod:`smtpd` modules have been
+* The :mod:`!asynchat`, :mod:`!asyncore` and  :mod:`!smtpd` modules have been
   deprecated since at least Python 3.6. Their documentation and deprecation
   warnings have now been updated to note they will be removed in Python 3.12.
   (Contributed by Hugo van Kemenade in :issue:`47022`.)
@@ -1877,8 +1877,8 @@ and will be removed in Python 3.12.
 C APIs pending removal are
 :ref:`listed separately `.
 
-* The :mod:`asynchat` module
-* The :mod:`asyncore` module
+* The :mod:`!asynchat` module
+* The :mod:`!asyncore` module
 * The :ref:`entire distutils package `
 * The :mod:`!imp` module
 * The :class:`typing.io ` namespace
@@ -1902,10 +1902,10 @@ C APIs pending removal are
 * :func:`!importlib.util.set_package_wrapper`
 * :class:`!pkgutil.ImpImporter`
 * :class:`!pkgutil.ImpLoader`
-* :meth:`pathlib.Path.link_to`
+* :meth:`!pathlib.Path.link_to`
 * :func:`!sqlite3.enable_shared_cache`
 * :func:`!sqlite3.OptimizedUnicode`
-* :envvar:`PYTHONTHREADDEBUG` environment variable
+* :envvar:`!PYTHONTHREADDEBUG` environment variable
 * The

[Python-checkins] [3.11] gh-113637: Let c_annotations.py to handle the spacing of Limited/Unstable API & Stable ABI translation strings (#113638) (#113679)

2024-01-03 Thread hugovk
https://github.com/python/cpython/commit/d4a28ec89c4f3f527c368066f633d4a4bbfa46a7
commit: d4a28ec89c4f3f527c368066f633d4a4bbfa46a7
branch: 3.11
author: Ege Akman 
committer: hugovk 
date: 2024-01-03T15:05:54+02:00
summary:

[3.11] gh-113637: Let c_annotations.py to handle the spacing of 
Limited/Unstable API & Stable ABI translation strings (#113638) (#113679)

files:
M Doc/tools/extensions/c_annotations.py
M Doc/tools/templates/dummy.html
M Misc/ACKS

diff --git a/Doc/tools/extensions/c_annotations.py 
b/Doc/tools/extensions/c_annotations.py
index 26202228d8756e..453cdf22f6b1d1 100644
--- a/Doc/tools/extensions/c_annotations.py
+++ b/Doc/tools/extensions/c_annotations.py
@@ -126,7 +126,8 @@ def add_annotations(self, app, doctree):
 f"Object type mismatch in limited API annotation "
 f"for {name}: {record['role']!r} != {objtype!r}")
 stable_added = record['added']
-message = sphinx_gettext(' Part of the ')
+message = sphinx_gettext('Part of the')
+message = message.center(len(message) + 2)
 emph_node = nodes.emphasis(message, message,
classes=['stableabi'])
 ref_node = addnodes.pending_xref(
@@ -139,20 +140,20 @@ def add_annotations(self, app, doctree):
 ref_node += nodes.Text(sphinx_gettext('Stable ABI'))
 emph_node += ref_node
 if struct_abi_kind == 'opaque':
-emph_node += nodes.Text(sphinx_gettext(' (as an opaque 
struct)'))
+emph_node += nodes.Text(' ' + sphinx_gettext('(as an 
opaque struct)'))
 elif struct_abi_kind == 'full-abi':
-emph_node += nodes.Text(sphinx_gettext(' (including all 
members)'))
+emph_node += nodes.Text(' ' + sphinx_gettext('(including 
all members)'))
 if record['ifdef_note']:
 emph_node += nodes.Text(' ' + record['ifdef_note'])
 if stable_added == '3.2':
 # Stable ABI was introduced in 3.2.
 pass
 else:
-emph_node += nodes.Text(sphinx_gettext(' since version 
%s') % stable_added)
+emph_node += nodes.Text(' ' + sphinx_gettext('since 
version %s') % stable_added)
 emph_node += nodes.Text('.')
 if struct_abi_kind == 'members':
 emph_node += nodes.Text(
-sphinx_gettext(' (Only some members are part of the 
stable ABI.)'))
+' ' + sphinx_gettext('(Only some members are part of 
the stable ABI.)'))
 node.insert(0, emph_node)
 
 # Return value annotation
diff --git a/Doc/tools/templates/dummy.html b/Doc/tools/templates/dummy.html
index 4cbc75cb66d1ba..8a278c2e35aea3 100644
--- a/Doc/tools/templates/dummy.html
+++ b/Doc/tools/templates/dummy.html
@@ -9,13 +9,13 @@
 
 In extensions/c_annotations.py:
 
-{% trans %} Part of the {% endtrans %}
+{% trans %}Part of the{% endtrans %}
 {% trans %}Limited API{% endtrans %}
 {% trans %}Stable ABI{% endtrans %}
-{% trans %} (as an opaque struct){% endtrans %}
-{% trans %} (including all members){% endtrans %}
-{% trans %} since version %s{% endtrans %}
-{% trans %} (Only some members are part of the stable ABI.){% endtrans %}
+{% trans %}(as an opaque struct){% endtrans %}
+{% trans %}(including all members){% endtrans %}
+{% trans %}since version %s{% endtrans %}
+{% trans %}(Only some members are part of the stable ABI.){% endtrans %}
 {% trans %}Return value: Always NULL.{% endtrans %}
 {% trans %}Return value: New reference.{% endtrans %}
 {% trans %}Return value: Borrowed reference.{% endtrans %}
diff --git a/Misc/ACKS b/Misc/ACKS
index 7efa01db59e7ea..e7e4bb0a6db931 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -31,6 +31,7 @@ Farhan Ahmad
 Matthew Ahrens
 Nir Aides
 Akira
+Ege Akman
 Yaniv Aknin
 Jyrki Alakuijala
 Tatiana Al-Chueyr

___
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] `functools.partial` docs: Use the more common spelling for "referenceable" (GH-113675) (#113678)

2024-01-03 Thread AlexWaygood
https://github.com/python/cpython/commit/3a9bf03ac9a9c403a0b71af4b8ea97147d9b4dc4
commit: 3a9bf03ac9a9c403a0b71af4b8ea97147d9b4dc4
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AlexWaygood 
date: 2024-01-03T13:19:49Z
summary:

[3.11] `functools.partial` docs: Use the more common spelling for 
"referenceable" (GH-113675) (#113678)

`functools.partial` docs: Use the more common spelling for "referenceable" 
(GH-113675)
(cherry picked from commit 4de468cce106221968d7ac08ddd94571b903c194)

Co-authored-by: Rodrigo Girão Serrão 
<[email protected]>

files:
M Doc/library/functools.rst

diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index 9dadbb69fc2f24..11bd891f410276 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -725,7 +725,7 @@ have three read-only attributes:
called.
 
 :class:`partial` objects are like :class:`function` objects in that they are
-callable, weak referencable, and can have attributes.  There are some important
+callable, weak referenceable, and can have attributes.  There are some 
important
 differences.  For instance, the :attr:`~definition.__name__` and 
:attr:`__doc__` attributes
 are not created automatically.  Also, :class:`partial` objects defined in
 classes behave like static methods and do not transform into bound methods

___
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-111926: Set up basic sementics of weakref API for freethreading (gh-113621)

2024-01-03 Thread corona10
https://github.com/python/cpython/commit/0c3455a9693cfabcd991c4c33db7cccb1387de58
commit: 0c3455a9693cfabcd991c4c33db7cccb1387de58
branch: main
author: Donghee Na 
committer: corona10 
date: 2024-01-03T13:25:27Z
summary:

gh-111926: Set up basic sementics of weakref API for freethreading (gh-113621)

-

Co-authored-by: Sam Gross 

files:
M Include/internal/pycore_weakref.h

diff --git a/Include/internal/pycore_weakref.h 
b/Include/internal/pycore_weakref.h
index eacbe14c903289..dea267b49039e7 100644
--- a/Include/internal/pycore_weakref.h
+++ b/Include/internal/pycore_weakref.h
@@ -9,48 +9,66 @@ extern "C" {
 #endif
 
 #include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION()
+#include "pycore_object.h"   // _Py_REF_IS_MERGED()
 
-static inline PyObject* _PyWeakref_GET_REF(PyObject *ref_obj) {
+static inline int _is_dead(PyObject *obj)
+{
+// Explanation for the Py_REFCNT() check: when a weakref's target is part
+// of a long chain of deallocations which triggers the trashcan mechanism,
+// clearing the weakrefs can be delayed long after the target's refcount
+// has dropped to zero.  In the meantime, code accessing the weakref will
+// be able to "see" the target object even though it is supposed to be
+// unreachable.  See issue gh-60806.
+#if defined(Py_GIL_DISABLED)
+Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&obj->ob_ref_shared);
+return shared == _Py_REF_SHARED(0, _Py_REF_MERGED);
+#else
+return (Py_REFCNT(obj) == 0);
+#endif
+}
+
+static inline PyObject* _PyWeakref_GET_REF(PyObject *ref_obj)
+{
 assert(PyWeakref_Check(ref_obj));
+PyObject *ret = NULL;
+Py_BEGIN_CRITICAL_SECTION(ref_obj);
 PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj);
 PyObject *obj = ref->wr_object;
 
 if (obj == Py_None) {
 // clear_weakref() was called
-return NULL;
+goto end;
 }
 
-// Explanation for the Py_REFCNT() check: when a weakref's target is part
-// of a long chain of deallocations which triggers the trashcan mechanism,
-// clearing the weakrefs can be delayed long after the target's refcount
-// has dropped to zero.  In the meantime, code accessing the weakref will
-// be able to "see" the target object even though it is supposed to be
-// unreachable.  See issue gh-60806.
-Py_ssize_t refcnt = Py_REFCNT(obj);
-if (refcnt == 0) {
-return NULL;
+if (_is_dead(obj)) {
+goto end;
 }
-
-assert(refcnt > 0);
-return Py_NewRef(obj);
+#if !defined(Py_GIL_DISABLED)
+assert(Py_REFCNT(obj) > 0);
+#endif
+ret = Py_NewRef(obj);
+end:
+Py_END_CRITICAL_SECTION();
+return ret;
 }
 
-static inline int _PyWeakref_IS_DEAD(PyObject *ref_obj) {
+static inline int _PyWeakref_IS_DEAD(PyObject *ref_obj)
+{
 assert(PyWeakref_Check(ref_obj));
-int is_dead;
+int ret = 0;
 Py_BEGIN_CRITICAL_SECTION(ref_obj);
 PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj);
 PyObject *obj = ref->wr_object;
 if (obj == Py_None) {
 // clear_weakref() was called
-is_dead = 1;
+ret = 1;
 }
 else {
 // See _PyWeakref_GET_REF() for the rationale of this test
-is_dead = (Py_REFCNT(obj) == 0);
+ret = _is_dead(obj);
 }
 Py_END_CRITICAL_SECTION();
-return is_dead;
+return ret;
 }
 
 extern Py_ssize_t _PyWeakref_GetWeakrefCount(PyWeakReference *head);

___
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 for removed dead batteries (GH-113669) (#113681)

2024-01-03 Thread hugovk
https://github.com/python/cpython/commit/d2cdc6717a4a03f5fc7a7b3a5d3e55973b1ff9d5
commit: d2cdc6717a4a03f5fc7a7b3a5d3e55973b1ff9d5
branch: 3.12
author: Hugo van Kemenade 
committer: hugovk 
date: 2024-01-03T15:50:10+02:00
summary:

[3.12] gh-101100: Fix Sphinx warnings for removed dead batteries (GH-113669) 
(#113681)

Co-authored-by: Alex Waygood .
Co-authored-by: Hugo van Kemenade 

files:
M Doc/whatsnew/2.4.rst
M Doc/whatsnew/2.6.rst
M Doc/whatsnew/3.10.rst
M Doc/whatsnew/3.11.rst
M Doc/whatsnew/3.2.rst
M Doc/whatsnew/3.3.rst
M Doc/whatsnew/3.4.rst
M Doc/whatsnew/3.5.rst
M Doc/whatsnew/3.6.rst
M Doc/whatsnew/3.7.rst
M Doc/whatsnew/3.8.rst
M Doc/whatsnew/3.9.rst
M Misc/NEWS.d/3.10.0a1.rst
M Misc/NEWS.d/3.11.0a1.rst
M Misc/NEWS.d/3.11.0a7.rst
M Misc/NEWS.d/3.12.0a1.rst
M Misc/NEWS.d/3.12.0a2.rst
M Misc/NEWS.d/3.8.0a1.rst
M Misc/NEWS.d/3.8.0a4.rst

diff --git a/Doc/whatsnew/2.4.rst b/Doc/whatsnew/2.4.rst
index 7236be8a58d6cb..4d1268d7278c49 100644
--- a/Doc/whatsnew/2.4.rst
+++ b/Doc/whatsnew/2.4.rst
@@ -995,7 +995,7 @@ fixes.  Here's a partial list of the most notable changes, 
sorted alphabetically
 by module name. Consult the :file:`Misc/NEWS` file in the source tree for a 
more
 complete list of changes, or look through the CVS logs for all the details.
 
-* The :mod:`asyncore` module's :func:`loop` function now has a *count* 
parameter
+* The :mod:`!asyncore` module's :func:`!loop` function now has a *count* 
parameter
   that lets you perform a limited number of passes through the polling loop.  
The
   default is still to loop forever.
 
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst
index b292b2e45ebfff..52ad89632c1038 100644
--- a/Doc/whatsnew/2.6.rst
+++ b/Doc/whatsnew/2.6.rst
@@ -1789,7 +1789,7 @@ changes, sorted alphabetically by module name. Consult the
 :file:`Misc/NEWS` file in the source tree for a more complete list of
 changes, or look through the Subversion logs for all the details.
 
-* The :mod:`asyncore` and :mod:`asynchat` modules are
+* The :mod:`!asyncore` and :mod:`!asynchat` modules are
   being actively maintained again, and a number of patches and bugfixes
   were applied.  (Maintained by Josiah Carlson; see :issue:`1736190` for
   one patch.)
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index ad25e16583f194..7d4a2e05532f1c 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -1278,7 +1278,7 @@ Add negative indexing support to :attr:`PurePath.parents
 (Contributed by Yaroslav Pankovych in :issue:`21041`.)
 
 Add :meth:`Path.hardlink_to ` method that
-supersedes :meth:`~pathlib.Path.link_to`. The new method has the same argument
+supersedes :meth:`!link_to`. The new method has the same argument
 order as :meth:`~pathlib.Path.symlink_to`.
 (Contributed by Barney Gale in :issue:`39950`.)
 
@@ -1740,7 +1740,7 @@ Deprecated
 
   (Contributed by Jelle Zijlstra in :gh:`87889`.)
 
-* :meth:`pathlib.Path.link_to` is deprecated and slated for removal in
+* :meth:`!pathlib.Path.link_to` is deprecated and slated for removal in
   Python 3.12. Use :meth:`pathlib.Path.hardlink_to` instead.
   (Contributed by Barney Gale in :issue:`39950`.)
 
@@ -1771,7 +1771,7 @@ Deprecated
   * NPN features like :meth:`ssl.SSLSocket.selected_npn_protocol` and
 :meth:`ssl.SSLContext.set_npn_protocols` are replaced by ALPN.
 
-* The threading debug (:envvar:`PYTHONTHREADDEBUG` environment variable) is
+* The threading debug (:envvar:`!PYTHONTHREADDEBUG` environment variable) is
   deprecated in Python 3.10 and will be removed in Python 3.12. This feature
   requires a :ref:`debug build of Python `.
   (Contributed by Victor Stinner in :issue:`44584`.)
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index c2e590d88c25b1..4cfd6281a4186d 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -1747,7 +1747,7 @@ Modules
   (Contributed by Brett Cannon in :issue:`47061` and Victor Stinner in
   :gh:`68966`.)
 
-* The :mod:`asynchat`, :mod:`asyncore` and  :mod:`smtpd` modules have been
+* The :mod:`!asynchat`, :mod:`!asyncore` and  :mod:`!smtpd` modules have been
   deprecated since at least Python 3.6. Their documentation and deprecation
   warnings have now been updated to note they will be removed in Python 3.12.
   (Contributed by Hugo van Kemenade in :issue:`47022`.)
@@ -1877,8 +1877,8 @@ and will be removed in Python 3.12.
 C APIs pending removal are
 :ref:`listed separately `.
 
-* The :mod:`asynchat` module
-* The :mod:`asyncore` module
+* The :mod:`!asynchat` module
+* The :mod:`!asyncore` module
 * The :ref:`entire distutils package `
 * The :mod:`!imp` module
 * The :class:`typing.io ` namespace
@@ -1902,10 +1902,10 @@ C APIs pending removal are
 * :func:`!importlib.util.set_package_wrapper`
 * :class:`!pkgutil.ImpImporter`
 * :class:`!pkgutil.ImpLoader`
-* :meth:`pathlib.Path.link_to`
+* :meth:`!pathlib.Path.link_to`
 * :func:`!sqlite3.enable_shared_cache`
 * :func:`!sqlite3.OptimizedUnicode`
-* :envvar:`PYTHONTHREADDEBUG` environment variabl

[Python-checkins] gh-113603: Compiler no longer tries to maintain the no-empty-block invariant (#113636)

2024-01-03 Thread iritkatriel
https://github.com/python/cpython/commit/7d01fb48089872155e1721ba0a8cc27ee5c4fecd
commit: 7d01fb48089872155e1721ba0a8cc27ee5c4fecd
branch: main
author: Irit Katriel <[email protected]>
committer: iritkatriel <[email protected]>
date: 2024-01-03T16:57:48Z
summary:

gh-113603: Compiler no longer tries to maintain the no-empty-block invariant 
(#113636)

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-01-01-23-57-24.gh-issue-113603.ySwovr.rst
M Lib/test/test_compile.py
M Python/flowgraph.c

diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 906e16cc9437fb..7850977428985f 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -448,6 +448,19 @@ def 
test_condition_expression_with_dead_blocks_compiles(self):
 # See gh-113054
 compile('if (5 if 5 else T): 0', '', 'exec')
 
+def test_condition_expression_with_redundant_comparisons_compiles(self):
+# See gh-113054
+compile('if 9<9<9and 9or 9:9', '', 'exec')
+
+def test_dead_code_with_except_handler_compiles(self):
+compile(textwrap.dedent("""
+if None:
+with CM:
+x = 1
+else:
+x = 2
+   """), '', 'exec')
+
 def test_compile_invalid_namedexpr(self):
 # gh-109351
 m = ast.Module(
diff --git a/Misc/NEWS.d/next/Core and 
Builtins/2024-01-01-23-57-24.gh-issue-113603.ySwovr.rst b/Misc/NEWS.d/next/Core 
and Builtins/2024-01-01-23-57-24.gh-issue-113603.ySwovr.rst
new file mode 100644
index 00..5fe6d80dedd19d
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-01-01-23-57-24.gh-issue-113603.ySwovr.rst 
@@ -0,0 +1 @@
+Fixed bug where a redundant NOP is not removed, causing an assertion to fail 
in the compiler in debug mode.
diff --git a/Python/flowgraph.c b/Python/flowgraph.c
index 0e6ffbc32e1526..5bb11980b8ca37 100644
--- a/Python/flowgraph.c
+++ b/Python/flowgraph.c
@@ -449,6 +449,15 @@ _PyCfgBuilder_Addop(cfg_builder *g, int opcode, int oparg, 
location loc)
 }
 
 
+static basicblock *
+next_nonempty_block(basicblock *b)
+{
+while (b && b->b_iused == 0) {
+b = b->b_next;
+}
+return b;
+}
+
 /* debugging helpers */
 
 #ifndef NDEBUG
@@ -464,24 +473,16 @@ no_redundant_nops(cfg_builder *g) {
 return true;
 }
 
-static bool
-no_empty_basic_blocks(cfg_builder *g) {
-for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
-if (b->b_iused == 0) {
-return false;
-}
-}
-return true;
-}
-
 static bool
 no_redundant_jumps(cfg_builder *g) {
 for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
 cfg_instr *last = basicblock_last_instr(b);
 if (last != NULL) {
 if (IS_UNCONDITIONAL_JUMP_OPCODE(last->i_opcode)) {
-assert(last->i_target != b->b_next);
-if (last->i_target == b->b_next) {
+basicblock *next = next_nonempty_block(b->b_next);
+basicblock *jump_target = next_nonempty_block(last->i_target);
+assert(jump_target != next);
+if (jump_target == next) {
 return false;
 }
 }
@@ -961,42 +962,6 @@ mark_reachable(basicblock *entryblock) {
 return SUCCESS;
 }
 
-static void
-eliminate_empty_basic_blocks(cfg_builder *g) {
-/* Eliminate empty blocks */
-for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
-basicblock *next = b->b_next;
-while (next && next->b_iused == 0) {
-next = next->b_next;
-}
-b->b_next = next;
-}
-while(g->g_entryblock && g->g_entryblock->b_iused == 0) {
-g->g_entryblock = g->g_entryblock->b_next;
-}
-int next_lbl = get_max_label(g->g_entryblock) + 1;
-for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
-assert(b->b_iused > 0);
-for (int i = 0; i < b->b_iused; i++) {
-cfg_instr *instr = &b->b_instr[i];
-if (HAS_TARGET(instr->i_opcode)) {
-basicblock *target = instr->i_target;
-while (target->b_iused == 0) {
-target = target->b_next;
-}
-if (instr->i_target != target) {
-if (!IS_LABEL(target->b_label)) {
-target->b_label.id = next_lbl++;
-}
-instr->i_target = target;
-instr->i_oparg = target->b_label.id;
-}
-assert(instr->i_target && instr->i_target->b_iused > 0);
-}
-}
-}
-}
-
 static int
 remove_redundant_nops(basicblock *bb) {
 /* Remove NOPs when legal to do so. */
@@ -1025,10 +990,7 @@ remove_redundant_nops(basicblock *bb) {
 }
 }
 else {
-basicblock* next = bb->b_ne

[Python-checkins] gh-113258: Write frozen modules to the build tree on Windows (GH-113303)

2024-01-03 Thread zooba
https://github.com/python/cpython/commit/178919cf2132a67bc03ae5994769d93cfb7e2cd3
commit: 178919cf2132a67bc03ae5994769d93cfb7e2cd3
branch: main
author: Itamar Oren 
committer: zooba 
date: 2024-01-03T17:30:20Z
summary:

gh-113258: Write frozen modules to the build tree on Windows (GH-113303)

This ensures the source directory is not modified at build time, and different 
builds (e.g. different versions or GIL vs no-GIL) do not have conflicts.

files:
A Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst
M PCbuild/_freeze_module.vcxproj
M PCbuild/pyproject.props
M PCbuild/pythoncore.vcxproj
M Tools/build/freeze_modules.py

diff --git 
a/Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst 
b/Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst
new file mode 100644
index 00..e7256ea423b3e0
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst
@@ -0,0 +1,2 @@
+Changed the Windows build to write out generated frozen modules into the
+build tree instead of the source tree.
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index f8c5fafa561efa..292bfa76519507 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -266,117 +266,117 @@
 
   importlib._bootstrap
   $(IntDir)importlib._bootstrap.g.h
-  
$(PySourcePath)Python\frozen_modules\importlib._bootstrap.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\importlib._bootstrap.h
 
 
   importlib._bootstrap_external
   $(IntDir)importlib._bootstrap_external.g.h
-  
$(PySourcePath)Python\frozen_modules\importlib._bootstrap_external.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\importlib._bootstrap_external.h
 
 
   zipimport
   $(IntDir)zipimport.g.h
-  $(PySourcePath)Python\frozen_modules\zipimport.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\zipimport.h
 
 
   abc
   $(IntDir)abc.g.h
-  $(PySourcePath)Python\frozen_modules\abc.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\abc.h
 
 
   codecs
   $(IntDir)codecs.g.h
-  $(PySourcePath)Python\frozen_modules\codecs.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\codecs.h
 
 
   io
   $(IntDir)io.g.h
-  $(PySourcePath)Python\frozen_modules\io.h
+  $(GeneratedFrozenModulesDir)Python\frozen_modules\io.h
 
 
   _collections_abc
   $(IntDir)_collections_abc.g.h
-  
$(PySourcePath)Python\frozen_modules\_collections_abc.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\_collections_abc.h
 
 
   _sitebuiltins
   $(IntDir)_sitebuiltins.g.h
-  $(PySourcePath)Python\frozen_modules\_sitebuiltins.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\_sitebuiltins.h
 
 
   genericpath
   $(IntDir)genericpath.g.h
-  $(PySourcePath)Python\frozen_modules\genericpath.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\genericpath.h
 
 
   ntpath
   $(IntDir)ntpath.g.h
-  $(PySourcePath)Python\frozen_modules\ntpath.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\ntpath.h
 
 
   posixpath
   $(IntDir)posixpath.g.h
-  $(PySourcePath)Python\frozen_modules\posixpath.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\posixpath.h
 
 
   os
   $(IntDir)os.g.h
-  $(PySourcePath)Python\frozen_modules\os.h
+  $(GeneratedFrozenModulesDir)Python\frozen_modules\os.h
 
 
   site
   $(IntDir)site.g.h
-  $(PySourcePath)Python\frozen_modules\site.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\site.h
 
 
   stat
   $(IntDir)stat.g.h
-  $(PySourcePath)Python\frozen_modules\stat.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\stat.h
 
 
   importlib.util
   $(IntDir)importlib.util.g.h
-  $(PySourcePath)Python\frozen_modules\importlib.util.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\importlib.util.h
 
 
   importlib.machinery
   $(IntDir)importlib.machinery.g.h
-  
$(PySourcePath)Python\frozen_modules\importlib.machinery.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\importlib.machinery.h
 
 
   runpy
   $(IntDir)runpy.g.h
-  $(PySourcePath)Python\frozen_modules\runpy.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\runpy.h
 
 
   __hello__
   $(IntDir)__hello__.g.h
-  $(PySourcePath)Python\frozen_modules\__hello__.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\__hello__.h
 
 
   __phello__
   $(IntDir)__phello__.g.h
-  $(PySourcePath)Python\frozen_modules\__phello__.h
+  
$(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.h
 
 
   __phello__.ham
   $(IntDir)__phello__.ham.g.h
-  $(PySourcePath)Python\frozen_m

[Python-checkins] Document the `co_lines` method on code objects (#113682)

2024-01-03 Thread AlexWaygood
https://github.com/python/cpython/commit/f1f839243251fef7422c31d6a7c3c747e0b5e27c
commit: f1f839243251fef7422c31d6a7c3c747e0b5e27c
branch: main
author: Alex Waygood 
committer: AlexWaygood 
date: 2024-01-03T19:29:24Z
summary:

Document the `co_lines` method on code objects (#113682)

Co-authored-by: Hugo van Kemenade 

files:
M Doc/library/dis.rst
M Doc/reference/datamodel.rst
M Doc/whatsnew/3.10.rst
M Doc/whatsnew/3.13.rst
M Misc/NEWS.d/3.12.0a4.rst
M Objects/lnotab_notes.txt

diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 5823142cc75998..7492ae85c4ea46 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -342,17 +342,18 @@ operation is being performed, so the intermediate 
analysis object isn't useful:
 
 .. function:: findlinestarts(code)
 
-   This generator function uses the ``co_lines`` method
-   of the code object *code* to find the offsets which are starts of
+   This generator function uses the :meth:`~codeobject.co_lines` method
+   of the :ref:`code object ` *code* to find the offsets which
+   are starts of
lines in the source code.  They are generated as ``(offset, lineno)`` pairs.
 
.. versionchanged:: 3.6
   Line numbers can be decreasing. Before, they were always increasing.
 
.. versionchanged:: 3.10
-  The :pep:`626` ``co_lines`` method is used instead of the
+  The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the
   :attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab`
-  attributes of the code object.
+  attributes of the :ref:`code object `.
 
.. versionchanged:: 3.13
   Line numbers can be ``None`` for bytecode that does not map to source 
lines.
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index b3af5c6298d02d..d611bda298b509 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1219,8 +1219,8 @@ If a code object represents a function, the first item in
 :attr:`~codeobject.co_consts` is
 the documentation string of the function, or ``None`` if undefined.
 
-The :meth:`!co_positions` method
-
+Methods on code objects
+~~~
 
 .. method:: codeobject.co_positions()
 
@@ -1255,6 +1255,41 @@ The :meth:`!co_positions` method
   :option:`-X` ``no_debug_ranges`` command line flag or the 
:envvar:`PYTHONNODEBUGRANGES`
   environment variable can be used.
 
+.. method:: codeobject.co_lines()
+
+   Returns an iterator that yields information about successive ranges of
+   :term:`bytecode`\s. Each item yielded is a ``(start, end, lineno)``
+   :class:`tuple`:
+
+   * ``start`` (an :class:`int`) represents the offset (inclusive) of the start
+ of the :term:`bytecode` range
+   * ``end`` (an :class:`int`) represents the offset (inclusive) of the end of
+ the :term:`bytecode` range
+   * ``lineno`` is an :class:`int` representing the line number of the
+ :term:`bytecode` range, or ``None`` if the bytecodes in the given range
+ have no line number
+
+   The items yielded generated will have the following properties:
+
+   * The first range yielded will have a ``start`` of 0.
+   * The ``(start, end)`` ranges will be non-decreasing and consecutive. That
+ is, for any pair of :class:`tuple`\s, the ``start`` of the second will be
+ equal to the ``end`` of the first.
+   * No range will be backwards: ``end >= start`` for all triples.
+   * The :class:`tuple` yielded will have ``end`` equal to the size of the
+ :term:`bytecode`.
+
+   Zero-width ranges, where ``start == end``, are allowed. Zero-width ranges
+   are used for lines that are present in the source code, but have been
+   eliminated by the :term:`bytecode` compiler.
+
+   .. versionadded:: 3.10
+
+   .. seealso::
+
+  :pep:`626` - Precise line numbers for debugging and other tools.
+ The PEP that introduced the :meth:`!co_lines` method.
+
 
 .. _frame-objects:
 
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index a8a27bfd3dc1bc..cd86c82caffc56 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -402,9 +402,11 @@ Tracing events, with the correct line number, are 
generated for all lines of cod
 The :attr:`~frame.f_lineno` attribute of frame objects will always contain the
 expected line number.
 
-The :attr:`~codeobject.co_lnotab` attribute of code objects is deprecated and
+The :attr:`~codeobject.co_lnotab` attribute of
+:ref:`code objects ` is deprecated and
 will be removed in 3.12.
-Code that needs to convert from offset to line number should use the new 
``co_lines()`` method instead.
+Code that needs to convert from offset to line number should use the new
+:meth:`~codeobject.co_lines` method instead.
 
 PEP 634: Structural Pattern Matching
 
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index 888ebd0402d0e7..3ab6d1ddc6ef21 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -816,7 +816,8 @@ although

[Python-checkins] gh-52161: Enhance Cmd support for docstrings (#110987)

2024-01-03 Thread gvanrossum
https://github.com/python/cpython/commit/4c4b08dd2bd5f2cad4e41bf29119a3daa2956f6e
commit: 4c4b08dd2bd5f2cad4e41bf29119a3daa2956f6e
branch: main
author: Filip Łapkiewicz <[email protected]>
committer: gvanrossum 
date: 2024-01-03T19:37:34Z
summary:

gh-52161: Enhance Cmd support for docstrings (#110987)

In `cmd.Cmd.do_help` call `inspect.cleandoc()`,
to clean indentation and remove leading/trailing empty
lines from a dosctring before printing.

files:
A Misc/NEWS.d/next/Library/2023-10-17-16-11-03.gh-issue-52161.WBYyCJ.rst
M Lib/cmd.py

diff --git a/Lib/cmd.py b/Lib/cmd.py
index 2e358d6cd5a02d..a37d16cd7bde16 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -42,7 +42,7 @@
 functions respectively.
 """
 
-import string, sys
+import inspect, string, sys
 
 __all__ = ["Cmd"]
 
@@ -305,6 +305,7 @@ def do_help(self, arg):
 except AttributeError:
 try:
 doc=getattr(self, 'do_' + arg).__doc__
+doc = inspect.cleandoc(doc)
 if doc:
 self.stdout.write("%s\n"%str(doc))
 return
diff --git 
a/Misc/NEWS.d/next/Library/2023-10-17-16-11-03.gh-issue-52161.WBYyCJ.rst 
b/Misc/NEWS.d/next/Library/2023-10-17-16-11-03.gh-issue-52161.WBYyCJ.rst
new file mode 100644
index 00..3f598d40e4ae93
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-10-17-16-11-03.gh-issue-52161.WBYyCJ.rst
@@ -0,0 +1,2 @@
+:meth:`cmd.Cmd.do_help` now cleans docstrings with :func:`inspect.cleandoc`
+before writing them. Patch by Filip Łapkiewicz.

___
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] Document the `co_lines` method on code objects (#113682) (#113687)

2024-01-03 Thread AlexWaygood
https://github.com/python/cpython/commit/c828dbc196519f942418953aa9758e2df3a0bd9b
commit: c828dbc196519f942418953aa9758e2df3a0bd9b
branch: 3.11
author: Alex Waygood 
committer: AlexWaygood 
date: 2024-01-03T19:59:10Z
summary:

[3.11] Document the `co_lines` method on code objects (#113682) (#113687)

(cherry-picked from commit f1f839243251fef7422c31d6a7c3c747e0b5e27c)

Co-authored-by: Hugo van Kemenade 

files:
M Doc/library/dis.rst
M Doc/reference/datamodel.rst
M Doc/whatsnew/3.10.rst
M Objects/lnotab_notes.txt

diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 0a699346d09533..2c7a87d4b25d40 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -314,17 +314,18 @@ operation is being performed, so the intermediate 
analysis object isn't useful:
 
 .. function:: findlinestarts(code)
 
-   This generator function uses the ``co_lines`` method
-   of the code object *code* to find the offsets which are starts of
+   This generator function uses the :meth:`~codeobject.co_lines` method
+   of the :ref:`code object ` *code* to find the offsets which
+   are starts of
lines in the source code.  They are generated as ``(offset, lineno)`` pairs.
 
.. versionchanged:: 3.6
   Line numbers can be decreasing. Before, they were always increasing.
 
.. versionchanged:: 3.10
-  The :pep:`626` ``co_lines`` method is used instead of the
+  The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the
   :attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab`
-  attributes of the code object.
+  attributes of the :ref:`code object `.
 
 
 .. function:: findlabels(code)
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 1c2324d77cd484..e04827e34f7927 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1202,8 +1202,8 @@ If a code object represents a function, the first item in
 :attr:`~codeobject.co_consts` is
 the documentation string of the function, or ``None`` if undefined.
 
-The :meth:`!co_positions` method
-
+Methods on code objects
+~~~
 
 .. method:: codeobject.co_positions()
 
@@ -1238,6 +1238,41 @@ The :meth:`!co_positions` method
   :option:`-X` ``no_debug_ranges`` command line flag or the 
:envvar:`PYTHONNODEBUGRANGES`
   environment variable can be used.
 
+.. method:: codeobject.co_lines()
+
+   Returns an iterator that yields information about successive ranges of
+   :term:`bytecode`\s. Each item yielded is a ``(start, end, lineno)``
+   :class:`tuple`:
+
+   * ``start`` (an :class:`int`) represents the offset (inclusive) of the start
+ of the :term:`bytecode` range
+   * ``end`` (an :class:`int`) represents the offset (inclusive) of the end of
+ the :term:`bytecode` range
+   * ``lineno`` is an :class:`int` representing the line number of the
+ :term:`bytecode` range, or ``None`` if the bytecodes in the given range
+ have no line number
+
+   The items yielded generated will have the following properties:
+
+   * The first range yielded will have a ``start`` of 0.
+   * The ``(start, end)`` ranges will be non-decreasing and consecutive. That
+ is, for any pair of :class:`tuple`\s, the ``start`` of the second will be
+ equal to the ``end`` of the first.
+   * No range will be backwards: ``end >= start`` for all triples.
+   * The :class:`tuple` yielded will have ``end`` equal to the size of the
+ :term:`bytecode`.
+
+   Zero-width ranges, where ``start == end``, are allowed. Zero-width ranges
+   are used for lines that are present in the source code, but have been
+   eliminated by the :term:`bytecode` compiler.
+
+   .. versionadded:: 3.10
+
+   .. seealso::
+
+  :pep:`626` - Precise line numbers for debugging and other tools.
+ The PEP that introduced the :meth:`!co_lines` method.
+
 
 .. _frame-objects:
 
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 1fce4cfcbc6c5a..87982c1e380eb5 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -402,9 +402,11 @@ Tracing events, with the correct line number, are 
generated for all lines of cod
 The :attr:`~frame.f_lineno` attribute of frame objects will always contain the
 expected line number.
 
-The :attr:`~codeobject.co_lnotab` attribute of code objects is deprecated and
+The :attr:`~codeobject.co_lnotab` attribute of
+:ref:`code objects ` is deprecated and
 will be removed in 3.12.
-Code that needs to convert from offset to line number should use the new 
``co_lines()`` method instead.
+Code that needs to convert from offset to line number should use the new
+:meth:`~codeobject.co_lines` method instead.
 
 PEP 634: Structural Pattern Matching
 
diff --git a/Objects/lnotab_notes.txt b/Objects/lnotab_notes.txt
index 362b87a86a481f..a11ad937ec90e5 100644
--- a/Objects/lnotab_notes.txt
+++ b/Objects/lnotab_notes.txt
@@ -57,7 +57,7 @@ Final form:
 Iterating over the table.
 --

[Python-checkins] [3.12] Document the `co_lines` method on code objects (#113682) (#113686)

2024-01-03 Thread AlexWaygood
https://github.com/python/cpython/commit/d3f2051eec6039811ae42e4382e8b292a983edc1
commit: d3f2051eec6039811ae42e4382e8b292a983edc1
branch: 3.12
author: Alex Waygood 
committer: AlexWaygood 
date: 2024-01-03T20:09:15Z
summary:

[3.12] Document the `co_lines` method on code objects (#113682) (#113686)

(cherry-picked from commit f1f839243251fef7422c31d6a7c3c747e0b5e27c)

Co-authored-by: Hugo van Kemenade 

files:
M Doc/library/dis.rst
M Doc/reference/datamodel.rst
M Doc/whatsnew/3.10.rst
M Misc/NEWS.d/3.12.0a4.rst
M Objects/lnotab_notes.txt

diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 6ad57740ffefc2..ba7e13e2a19b8e 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -316,17 +316,18 @@ operation is being performed, so the intermediate 
analysis object isn't useful:
 
 .. function:: findlinestarts(code)
 
-   This generator function uses the ``co_lines`` method
-   of the code object *code* to find the offsets which are starts of
+   This generator function uses the :meth:`~codeobject.co_lines` method
+   of the :ref:`code object ` *code* to find the offsets which
+   are starts of
lines in the source code.  They are generated as ``(offset, lineno)`` pairs.
 
.. versionchanged:: 3.6
   Line numbers can be decreasing. Before, they were always increasing.
 
.. versionchanged:: 3.10
-  The :pep:`626` ``co_lines`` method is used instead of the
+  The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the
   :attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab`
-  attributes of the code object.
+  attributes of the :ref:`code object `.
 
 
 .. function:: findlabels(code)
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index bbdff00c8d965f..7308dcde1fafe3 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1219,8 +1219,8 @@ If a code object represents a function, the first item in
 :attr:`~codeobject.co_consts` is
 the documentation string of the function, or ``None`` if undefined.
 
-The :meth:`!co_positions` method
-
+Methods on code objects
+~~~
 
 .. method:: codeobject.co_positions()
 
@@ -1255,6 +1255,41 @@ The :meth:`!co_positions` method
   :option:`-X` ``no_debug_ranges`` command line flag or the 
:envvar:`PYTHONNODEBUGRANGES`
   environment variable can be used.
 
+.. method:: codeobject.co_lines()
+
+   Returns an iterator that yields information about successive ranges of
+   :term:`bytecode`\s. Each item yielded is a ``(start, end, lineno)``
+   :class:`tuple`:
+
+   * ``start`` (an :class:`int`) represents the offset (inclusive) of the start
+ of the :term:`bytecode` range
+   * ``end`` (an :class:`int`) represents the offset (inclusive) of the end of
+ the :term:`bytecode` range
+   * ``lineno`` is an :class:`int` representing the line number of the
+ :term:`bytecode` range, or ``None`` if the bytecodes in the given range
+ have no line number
+
+   The items yielded generated will have the following properties:
+
+   * The first range yielded will have a ``start`` of 0.
+   * The ``(start, end)`` ranges will be non-decreasing and consecutive. That
+ is, for any pair of :class:`tuple`\s, the ``start`` of the second will be
+ equal to the ``end`` of the first.
+   * No range will be backwards: ``end >= start`` for all triples.
+   * The :class:`tuple` yielded will have ``end`` equal to the size of the
+ :term:`bytecode`.
+
+   Zero-width ranges, where ``start == end``, are allowed. Zero-width ranges
+   are used for lines that are present in the source code, but have been
+   eliminated by the :term:`bytecode` compiler.
+
+   .. versionadded:: 3.10
+
+   .. seealso::
+
+  :pep:`626` - Precise line numbers for debugging and other tools.
+ The PEP that introduced the :meth:`!co_lines` method.
+
 
 .. _frame-objects:
 
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 7d4a2e05532f1c..f4b891e722641d 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -402,9 +402,11 @@ Tracing events, with the correct line number, are 
generated for all lines of cod
 The :attr:`~frame.f_lineno` attribute of frame objects will always contain the
 expected line number.
 
-The :attr:`~codeobject.co_lnotab` attribute of code objects is deprecated and
+The :attr:`~codeobject.co_lnotab` attribute of
+:ref:`code objects ` is deprecated and
 will be removed in 3.12.
-Code that needs to convert from offset to line number should use the new 
``co_lines()`` method instead.
+Code that needs to convert from offset to line number should use the new
+:meth:`~codeobject.co_lines` method instead.
 
 PEP 634: Structural Pattern Matching
 
diff --git a/Misc/NEWS.d/3.12.0a4.rst b/Misc/NEWS.d/3.12.0a4.rst
index 75246f3f13503e..ce2814bbe2e5ab 100644
--- a/Misc/NEWS.d/3.12.0a4.rst
+++ b/Misc/NEWS.d/3.12.0a4.rst
@@ -147,8 +147,8 @@ clinic.
 .. n