[Python-checkins] gh-113858: Cut down ccache size (GH-113945)

2024-01-12 Thread encukou
https://github.com/python/cpython/commit/fcb4c8d31a4b1c60ed9990db3eacd1db9cac4df2
commit: fcb4c8d31a4b1c60ed9990db3eacd1db9cac4df2
branch: main
author: Petr Viktorin 
committer: encukou 
date: 2024-01-12T10:48:25+01:00
summary:

gh-113858: Cut down ccache size (GH-113945)

Cut down ccache size

- Only save the ccache in the main reusable builds, not on builds that
  don't use special build options:
  - Generated files check
  - OpenSSL tests
  - Hypothesis tests
- Halve the max cache size, to 200M

files:
M .github/workflows/build.yml
M .github/workflows/reusable-ubuntu.yml

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a3b1d7786ee914..957882619f3552 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -143,7 +143,7 @@ jobs:
   - name: Configure ccache action
 uses: hendrikmuhs/[email protected]
 with:
-  save: ${{ github.event_name == 'push' }}
+  save: false
   - name: Check Autoconf and aclocal versions
 run: |
   grep "Generated by GNU Autoconf 2.71" configure
@@ -287,7 +287,7 @@ jobs:
 - name: Configure ccache action
   uses: hendrikmuhs/[email protected]
   with:
-save: ${{ github.event_name == 'push' }}
+save: false
 - name: Configure CPython
   run: ./configure --config-cache --with-pydebug 
--with-openssl=$OPENSSL_DIR
 - name: Build CPython
@@ -332,7 +332,7 @@ jobs:
 - name: Configure ccache action
   uses: hendrikmuhs/[email protected]
   with:
-save: ${{ github.event_name == 'push' }}
+save: false
 - name: Setup directory envs for out-of-tree builds
   run: |
 echo "CPYTHON_RO_SRCDIR=$(realpath -m 
${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
diff --git a/.github/workflows/reusable-ubuntu.yml 
b/.github/workflows/reusable-ubuntu.yml
index f208064767d42f..c2194280c0a50f 100644
--- a/.github/workflows/reusable-ubuntu.yml
+++ b/.github/workflows/reusable-ubuntu.yml
@@ -43,6 +43,7 @@ jobs:
   uses: hendrikmuhs/[email protected]
   with:
 save: ${{ github.event_name == 'push' }}
+max-size: "200M"
 - name: Setup directory envs for out-of-tree builds
   run: |
 echo "CPYTHON_RO_SRCDIR=$(realpath -m 
${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV

___
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-108364: In sqlite3, disable foreign keys before dumping SQL schema (#113957)

2024-01-12 Thread erlend-aasland
https://github.com/python/cpython/commit/de777e490fb356d7bcc7c907141c20a5135d97df
commit: de777e490fb356d7bcc7c907141c20a5135d97df
branch: main
author: Mariusz Felisiak 
committer: erlend-aasland 
date: 2024-01-12T10:50:37+01:00
summary:

gh-108364: In sqlite3, disable foreign keys before dumping SQL schema (#113957)

sqlite3.Connection.iterdump now ensures that foreign key support is
disabled before dumping the database schema, if there is any foreign key
violation.

Co-authored-by: Erlend E. Aasland 

files:
A Misc/NEWS.d/next/Library/2024-01-11-22-22-51.gh-issue-108364.QH7C-1.rst
M Lib/sqlite3/dump.py
M Lib/test/test_sqlite3/test_dump.py

diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py
index ead3360ce67608..719dfc8947697d 100644
--- a/Lib/sqlite3/dump.py
+++ b/Lib/sqlite3/dump.py
@@ -26,6 +26,10 @@ def _iterdump(connection):
 
 writeable_schema = False
 cu = connection.cursor()
+# Disable foreign key constraints, if there is any foreign key violation.
+violations = cu.execute("PRAGMA foreign_key_check").fetchall()
+if violations:
+yield('PRAGMA foreign_keys=OFF;')
 yield('BEGIN TRANSACTION;')
 
 # sqlite_master table contains the SQL CREATE statements for the database.
diff --git a/Lib/test/test_sqlite3/test_dump.py 
b/Lib/test/test_sqlite3/test_dump.py
index 14a18c1ad37102..2e1f0b80c10f46 100644
--- a/Lib/test/test_sqlite3/test_dump.py
+++ b/Lib/test/test_sqlite3/test_dump.py
@@ -20,7 +20,8 @@ def test_table_dump(self):
 ,
 "CREATE TABLE t1(id integer primary key, s1 text, " \
 "t1_i1 integer not null, i2 integer, unique (s1), " \
-"constraint t1_idx1 unique (i2));"
+"constraint t1_idx1 unique (i2), " \
+"constraint t1_i1_idx1 unique (t1_i1));"
 ,
 "INSERT INTO \"t1\" VALUES(1,'foo',10,20);"
 ,
@@ -30,6 +31,9 @@ def test_table_dump(self):
 "t2_i2 integer, primary key (id)," \
 "foreign key(t2_i1) references t1(t1_i1));"
 ,
+# Foreign key violation.
+"INSERT INTO \"t2\" VALUES(1,2,3);"
+,
 "CREATE TRIGGER trigger_1 update of t1_i1 on t1 " \
 "begin " \
 "update t2 set t2_i1 = new.t1_i1 where t2_i1 = old.t1_i1; " \
@@ -41,8 +45,12 @@ def test_table_dump(self):
 [self.cu.execute(s) for s in expected_sqls]
 i = self.cx.iterdump()
 actual_sqls = [s for s in i]
-expected_sqls = ['BEGIN TRANSACTION;'] + expected_sqls + \
-['COMMIT;']
+expected_sqls = [
+"PRAGMA foreign_keys=OFF;",
+"BEGIN TRANSACTION;",
+*expected_sqls,
+"COMMIT;",
+]
 [self.assertEqual(expected_sqls[i], actual_sqls[i])
 for i in range(len(expected_sqls))]
 
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-11-22-22-51.gh-issue-108364.QH7C-1.rst 
b/Misc/NEWS.d/next/Library/2024-01-11-22-22-51.gh-issue-108364.QH7C-1.rst
new file mode 100644
index 00..943a74db18d053
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-11-22-22-51.gh-issue-108364.QH7C-1.rst
@@ -0,0 +1,3 @@
+:meth:`sqlite3.Connection.iterdump` now ensures that foreign key support is
+disabled before dumping the database schema, if there is any foreign key
+violation. Patch by Erlend E. Aasland and Mariusz Felisiak.

___
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-113027: Fix timezone check in test_variable_tzname in test_email (GH-113835)

2024-01-12 Thread encukou
https://github.com/python/cpython/commit/29e2839cd6af5c90cfd7abe800b045b6dcee0c05
commit: 29e2839cd6af5c90cfd7abe800b045b6dcee0c05
branch: main
author: Pablo Galindo Salgado 
committer: encukou 
date: 2024-01-12T11:46:17+01:00
summary:

gh-113027: Fix timezone check in test_variable_tzname in test_email (GH-113835)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/test_email/test_utils.py

diff --git a/Lib/test/test_email/test_utils.py 
b/Lib/test/test_email/test_utils.py
index 0f1c3a84e61abd..d04b3909efa643 100644
--- a/Lib/test/test_email/test_utils.py
+++ b/Lib/test/test_email/test_utils.py
@@ -147,7 +147,7 @@ def test_localtime_epoch_notz_daylight_false(self):
 def test_variable_tzname(self):
 t0 = datetime.datetime(1984, 1, 1, tzinfo=datetime.timezone.utc)
 t1 = utils.localtime(t0)
-if t1.tzname() == 'Europe':
+if t1.tzname() in ('Europe', 'UTC'):
 self.skipTest("Can't find a Kyiv timezone database")
 self.assertEqual(t1.tzname(), 'MSK')
 t0 = datetime.datetime(1994, 1, 1, tzinfo=datetime.timezone.utc)

___
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-113860: Get rid of `_PyUOpExecutorObject` (GH-113954)

2024-01-12 Thread markshannon
https://github.com/python/cpython/commit/30e6cbdba22d946dacc3f2e19c884b2e1891d58c
commit: 30e6cbdba22d946dacc3f2e19c884b2e1891d58c
branch: main
author: Brandt Bucher 
committer: markshannon 
date: 2024-01-12T11:58:23Z
summary:

GH-113860: Get rid of `_PyUOpExecutorObject` (GH-113954)

files:
D Include/internal/pycore_uops.h
M Include/cpython/optimizer.h
M Include/internal/pycore_optimizer.h
M Makefile.pre.in
M PCbuild/pythoncore.vcxproj
M PCbuild/pythoncore.vcxproj.filters
M Python/bytecodes.c
M Python/ceval.c
M Python/executor_cases.c.h
M Python/generated_cases.c.h
M Python/optimizer.c
M Python/optimizer_analysis.c

diff --git a/Include/cpython/optimizer.h b/Include/cpython/optimizer.h
index 0e7bc9fdd7a07d..96e829f8fbe97d 100644
--- a/Include/cpython/optimizer.h
+++ b/Include/cpython/optimizer.h
@@ -29,10 +29,17 @@ typedef struct {
 _PyExecutorLinkListNode links;
 } _PyVMData;
 
+typedef struct {
+uint16_t opcode;
+uint16_t oparg;
+uint32_t target;
+uint64_t operand;  // A cache entry
+} _PyUOpInstruction;
+
 typedef struct _PyExecutorObject {
 PyObject_VAR_HEAD
 _PyVMData vm_data; /* Used by the VM, but opaque to the optimizer */
-/* Data needed by the executor goes here, but is opaque to the VM */
+_PyUOpInstruction trace[1];
 } _PyExecutorObject;
 
 typedef struct _PyOptimizerObject _PyOptimizerObject;
diff --git a/Include/internal/pycore_optimizer.h 
b/Include/internal/pycore_optimizer.h
index b052460b44b791..31f30c673f207a 100644
--- a/Include/internal/pycore_optimizer.h
+++ b/Include/internal/pycore_optimizer.h
@@ -8,8 +8,6 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-#include "pycore_uops.h"  // _PyUOpInstruction
-
 int _Py_uop_analyze_and_optimize(PyCodeObject *code,
 _PyUOpInstruction *trace, int trace_len, int curr_stackentries);
 
diff --git a/Include/internal/pycore_uops.h b/Include/internal/pycore_uops.h
deleted file mode 100644
index eb10002d34ce51..00
--- a/Include/internal/pycore_uops.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef Py_INTERNAL_UOPS_H
-#define Py_INTERNAL_UOPS_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef Py_BUILD_CORE
-#  error "this header requires Py_BUILD_CORE define"
-#endif
-
-#include "pycore_frame.h" // _PyInterpreterFrame
-
-#define _Py_UOP_MAX_TRACE_LENGTH 512
-
-typedef struct {
-uint16_t opcode;
-uint16_t oparg;
-uint32_t target;
-uint64_t operand;  // A cache entry
-} _PyUOpInstruction;
-
-typedef struct {
-_PyExecutorObject base;
-_PyUOpInstruction trace[1];
-} _PyUOpExecutorObject;
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !Py_INTERNAL_UOPS_H */
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 15d419b930c181..289ab97666e902 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1895,7 +1895,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_unionobject.h \
$(srcdir)/Include/internal/pycore_unicodeobject.h \
$(srcdir)/Include/internal/pycore_unicodeobject_generated.h \
-   $(srcdir)/Include/internal/pycore_uops.h \
$(srcdir)/Include/internal/pycore_uop_metadata.h \
$(srcdir)/Include/internal/pycore_warnings.h \
$(srcdir)/Include/internal/pycore_weakref.h \
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index a8b753ca489ab7..64738b1bbf235d 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -295,7 +295,6 @@
 
 
 
-
 
 
 
diff --git a/PCbuild/pythoncore.vcxproj.filters 
b/PCbuild/pythoncore.vcxproj.filters
index 965efa2e3d34b9..b37ca2dfed55ab 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -804,9 +804,6 @@
 
   Include\internal
 
-
-  Include\internal
-
 
   Include\internal\mimalloc
 
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 2011d963e3687c..b346fe73f76fe4 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -68,7 +68,7 @@ static size_t jump;
 static uint16_t invert, counter, index, hint;
 #define unused 0  // Used in a macro def, can't be static
 static uint32_t type_version;
-static _PyUOpExecutorObject *current_executor;
+static _PyExecutorObject *current_executor;
 
 static PyObject *
 dummy_func(
@@ -2369,10 +2369,10 @@ dummy_func(
 CHECK_EVAL_BREAKER();
 
 PyCodeObject *code = _PyFrame_GetCode(frame);
-_PyExecutorObject *executor = (_PyExecutorObject 
*)code->co_executors->executors[oparg&255];
+_PyExecutorObject *executor = code->co_executors->executors[oparg 
& 255];
 if (executor->vm_data.valid) {
 Py_INCREF(executor);
-current_executor = (_PyUOpExecutorObject *)executor;
+current_executor = executor;
 GOTO_TIER_TWO();
 }
 else {
@@ -4063,7 +4063,7 @@ dummy_func(
 
 op(_CHECK_VA

[Python-checkins] [3.11] gh-113027: Fix test_variable_tzname in test_email (GH-113821) (GH-113832)

2024-01-12 Thread serhiy-storchaka
https://github.com/python/cpython/commit/64d8f39a12821adc24f899790b6d03e4599949f4
commit: 64d8f39a12821adc24f899790b6d03e4599949f4
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-12T11:59:23Z
summary:

[3.11] gh-113027: Fix test_variable_tzname in test_email (GH-113821) (GH-113832)

Determine the support of the Kyiv timezone by checking the result of
astimezone() which uses the system tz database and not the one
populated by zoneinfo.
(cherry picked from commit 931d7e052e22aa01e18fcc67ed71b6ea305aff71)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/test_email/test_utils.py

diff --git a/Lib/test/test_email/test_utils.py 
b/Lib/test/test_email/test_utils.py
index 81109a7508ac0d..342b8507355d71 100644
--- a/Lib/test/test_email/test_utils.py
+++ b/Lib/test/test_email/test_utils.py
@@ -143,12 +143,12 @@ def test_localtime_epoch_notz_daylight_false(self):
 t2 = utils.localtime(t0.replace(tzinfo=None))
 self.assertEqual(t1, t2)
 
[email protected]("Europe/Kyiv" in zoneinfo.available_timezones(),
- "Can't find a Kyiv timezone database")
 @test.support.run_with_tz('Europe/Kyiv')
 def test_variable_tzname(self):
 t0 = datetime.datetime(1984, 1, 1, tzinfo=datetime.timezone.utc)
 t1 = utils.localtime(t0)
+if t1.tzname() in ('Europe', 'UTC'):
+self.skipTest("Can't find a Kyiv timezone database")
 self.assertEqual(t1.tzname(), 'MSK')
 t0 = datetime.datetime(1994, 1, 1, tzinfo=datetime.timezone.utc)
 t1 = utils.localtime(t0)

___
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-113027: Fix test_variable_tzname in test_email (GH-113821) (GH-113831)

2024-01-12 Thread serhiy-storchaka
https://github.com/python/cpython/commit/8046eb0cc89a66b93616501c1d7d199a59e998d4
commit: 8046eb0cc89a66b93616501c1d7d199a59e998d4
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-12T12:00:17Z
summary:

[3.12] gh-113027: Fix test_variable_tzname in test_email (GH-113821) (GH-113831)

Determine the support of the Kyiv timezone by checking the result of
astimezone() which uses the system tz database and not the one
populated by zoneinfo.
(cherry picked from commit 931d7e052e22aa01e18fcc67ed71b6ea305aff71)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/test_email/test_utils.py

diff --git a/Lib/test/test_email/test_utils.py 
b/Lib/test/test_email/test_utils.py
index c9d973df0a2192..d04b3909efa643 100644
--- a/Lib/test/test_email/test_utils.py
+++ b/Lib/test/test_email/test_utils.py
@@ -143,12 +143,12 @@ def test_localtime_epoch_notz_daylight_false(self):
 t2 = utils.localtime(t0.replace(tzinfo=None))
 self.assertEqual(t1, t2)
 
[email protected]("Europe/Kyiv" in zoneinfo.available_timezones(),
- "Can't find a Kyiv timezone database")
 @test.support.run_with_tz('Europe/Kyiv')
 def test_variable_tzname(self):
 t0 = datetime.datetime(1984, 1, 1, tzinfo=datetime.timezone.utc)
 t1 = utils.localtime(t0)
+if t1.tzname() in ('Europe', 'UTC'):
+self.skipTest("Can't find a Kyiv timezone database")
 self.assertEqual(t1.tzname(), 'MSK')
 t0 = datetime.datetime(1994, 1, 1, tzinfo=datetime.timezone.utc)
 t1 = utils.localtime(t0)

___
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: Amend codeobject.co_lines docs; end number is exclusive (#113970)

2024-01-12 Thread erlend-aasland
https://github.com/python/cpython/commit/e68806c7122070078507b370b13bb225f8501ff8
commit: e68806c7122070078507b370b13bb225f8501ff8
branch: main
author: Ned Batchelder 
committer: erlend-aasland 
date: 2024-01-12T16:04:14+01:00
summary:

Docs: Amend codeobject.co_lines docs; end number is exclusive (#113970)

The end number should be exclusive, not inclusive.

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index ddfcb00fd788d7..62e3ddab759944 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1263,20 +1263,20 @@ Methods on code objects
 
* ``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
+   * ``end`` (an :class:`int`) represents the offset (exclusive) 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 items yielded 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
+   * The last :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

___
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: Amend codeobject.co_lines docs; end number is exclusive (GH-113970) (#113988)

2024-01-12 Thread erlend-aasland
https://github.com/python/cpython/commit/f8dd29030d497f975f2551d33b179156838ebd7b
commit: f8dd29030d497f975f2551d33b179156838ebd7b
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-12T15:10:33Z
summary:

[3.11] Docs: Amend codeobject.co_lines docs; end number is exclusive 
(GH-113970) (#113988)

The end number should be exclusive, not inclusive.
(cherry picked from commit e68806c7122070078507b370b13bb225f8501ff8)

Co-authored-by: Ned Batchelder 

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 54ba171ec7696c..efa24acb5db5e0 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1246,20 +1246,20 @@ Methods on code objects
 
* ``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
+   * ``end`` (an :class:`int`) represents the offset (exclusive) 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 items yielded 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
+   * The last :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

___
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] Docs: Amend codeobject.co_lines docs; end number is exclusive (GH-113970) (#113987)

2024-01-12 Thread erlend-aasland
https://github.com/python/cpython/commit/eb22afb0042b09f05de5077c1947053dfbf7a5c0
commit: eb22afb0042b09f05de5077c1947053dfbf7a5c0
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-12T15:10:43Z
summary:

[3.12] Docs: Amend codeobject.co_lines docs; end number is exclusive 
(GH-113970) (#113987)

The end number should be exclusive, not inclusive.
(cherry picked from commit e68806c7122070078507b370b13bb225f8501ff8)

Co-authored-by: Ned Batchelder 

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index fe39b82846039f..b4d404696940c3 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1263,20 +1263,20 @@ Methods on code objects
 
* ``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
+   * ``end`` (an :class:`int`) represents the offset (exclusive) 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 items yielded 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
+   * The last :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

___
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-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)

2024-01-12 Thread zooba
https://github.com/python/cpython/commit/ed066481c76c6888ff5709f5b9f93b92c232a4a6
commit: ed066481c76c6888ff5709f5b9f93b92c232a4a6
branch: main
author: Steve Dower 
committer: zooba 
date: 2024-01-12T15:27:56Z
summary:

gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)

files:
A Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst
M Lib/test/test_os.py
M Modules/posixmodule.c

diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index bff6e604cccdd6..98b30d2108a1a1 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -3085,6 +3085,66 @@ def test_stat_unlink_race(self):
 except subprocess.TimeoutExpired:
 proc.terminate()
 
[email protected]_subprocess()
+def test_stat_inaccessible_file(self):
+filename = os_helper.TESTFN
+ICACLS = os.path.expandvars(r"%SystemRoot%\System32\icacls.exe")
+
+with open(filename, "wb") as f:
+f.write(b'Test data')
+
+stat1 = os.stat(filename)
+
+try:
+# Remove all permissions from the file
+subprocess.check_output([ICACLS, filename, "/inheritance:r"],
+stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as ex:
+if support.verbose:
+print(ICACLS, filename, "/inheritance:r", "failed.")
+print(ex.stdout.decode("oem", "replace").rstrip())
+try:
+os.unlink(filename)
+except OSError:
+pass
+self.skipTest("Unable to create inaccessible file")
+
+def cleanup():
+# Give delete permission. We are the file owner, so we can do this
+# even though we removed all permissions earlier.
+subprocess.check_output([ICACLS, filename, "/grant", 
"Everyone:(D)"],
+stderr=subprocess.STDOUT)
+os.unlink(filename)
+
+self.addCleanup(cleanup)
+
+if support.verbose:
+print("File:", filename)
+print("stat with access:", stat1)
+
+# First test - we shouldn't raise here, because we still have access to
+# the directory and can extract enough information from its metadata.
+stat2 = os.stat(filename)
+
+if support.verbose:
+print(" without access:", stat2)
+
+# We cannot get st_dev/st_ino, so ensure those are 0 or else our test
+# is not set up correctly
+self.assertEqual(0, stat2.st_dev)
+self.assertEqual(0, stat2.st_ino)
+
+# st_mode and st_size should match (for a normal file, at least)
+self.assertEqual(stat1.st_mode, stat2.st_mode)
+self.assertEqual(stat1.st_size, stat2.st_size)
+
+# st_ctime and st_mtime should be the same
+self.assertEqual(stat1.st_ctime, stat2.st_ctime)
+self.assertEqual(stat1.st_mtime, stat2.st_mtime)
+
+# st_atime should be the same or later
+self.assertGreaterEqual(stat1.st_atime, stat2.st_atime)
+
 
 @os_helper.skip_unless_symlink
 class NonLocalSymlinkTests(unittest.TestCase):
diff --git 
a/Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst 
b/Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst
new file mode 100644
index 00..99ed8d34af7cc2
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst
@@ -0,0 +1,2 @@
+:func:`os.stat` calls were returning incorrect time values for files that
+could not be accessed directly.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 179497a21b5a95..007fc1cb116f84 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1886,8 +1886,9 @@ win32_xstat_slow_impl(const wchar_t *path, struct 
_Py_stat_struct *result,
 HANDLE hFile;
 BY_HANDLE_FILE_INFORMATION fileInfo;
 FILE_BASIC_INFO basicInfo;
+FILE_BASIC_INFO *pBasicInfo = NULL;
 FILE_ID_INFO idInfo;
-FILE_ID_INFO *pIdInfo = &idInfo;
+FILE_ID_INFO *pIdInfo = NULL;
 FILE_ATTRIBUTE_TAG_INFO tagInfo = { 0 };
 DWORD fileType, error;
 BOOL isUnhandledTag = FALSE;
@@ -2038,14 +2039,17 @@ win32_xstat_slow_impl(const wchar_t *path, struct 
_Py_stat_struct *result,
 retval = -1;
 goto cleanup;
 }
-}
 
-if (!GetFileInformationByHandleEx(hFile, FileIdInfo, &idInfo, 
sizeof(idInfo))) {
-/* Failed to get FileIdInfo, so do not pass it along */
-pIdInfo = NULL;
+/* Successfully got FileBasicInfo, so we'll pass it along */
+pBasicInfo = &basicInfo;
+
+if (GetFileInformationByHandleEx(hFile, FileIdInfo, &idInfo, 
sizeof(idInfo))) {
+/* Successfully got FileIdInfo, so pass it along */
+pIdInfo = &idInfo;
+}
 }
 
-_Py_attribute_data_to_stat(&fileInfo, tagInfo.ReparseTag, &basicInfo, 
pIdInfo, result);
+_Py_attribute_data_to_stat(&fileInfo, tagInfo

[Python-checkins] gh-113980: Fix resource warnings in test_asyncgen (GH-113984)

2024-01-12 Thread serhiy-storchaka
https://github.com/python/cpython/commit/e02c15b3f13d9d83032ada72c6773f8a3b2d34dc
commit: e02c15b3f13d9d83032ada72c6773f8a3b2d34dc
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-01-12T17:30:26+02:00
summary:

gh-113980: Fix resource warnings in test_asyncgen (GH-113984)

files:
M Lib/test/test_asyncgen.py

diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py
index 7fa0a85100a581..39605dca3886c8 100644
--- a/Lib/test/test_asyncgen.py
+++ b/Lib/test/test_asyncgen.py
@@ -379,7 +379,10 @@ async def async_gen_wrapper():
 
 def test_async_gen_exception_12(self):
 async def gen():
-await anext(me)
+with self.assertWarnsRegex(RuntimeWarning,
+f"coroutine method 'asend' of '{gen.__qualname__}' "
+f"was never awaited"):
+await anext(me)
 yield 123
 
 me = gen()
@@ -395,7 +398,12 @@ async def gen():
 yield 123
 
 with self.assertWarns(DeprecationWarning):
-gen().athrow(GeneratorExit, GeneratorExit(), None)
+x = gen().athrow(GeneratorExit, GeneratorExit(), None)
+with self.assertWarnsRegex(RuntimeWarning,
+f"coroutine method 'athrow' of '{gen.__qualname__}' "
+f"was never awaited"):
+del x
+gc_collect()
 
 def test_async_gen_api_01(self):
 async def gen():
@@ -1564,6 +1572,11 @@ async def main():
 self.assertIsInstance(message['exception'], ZeroDivisionError)
 self.assertIn('unhandled exception during asyncio.run() shutdown',
   message['message'])
+with self.assertWarnsRegex(RuntimeWarning,
+f"coroutine method 'aclose' of '{async_iterate.__qualname__}' "
+f"was never awaited"):
+del message, messages
+gc_collect()
 
 def test_async_gen_expression_01(self):
 async def arange(n):
@@ -1617,6 +1630,10 @@ async def main():
 asyncio.run(main())
 
 self.assertEqual([], messages)
+with self.assertWarnsRegex(RuntimeWarning,
+f"coroutine method 'aclose' of '{async_iterate.__qualname__}' "
+f"was never awaited"):
+gc_collect()
 
 def test_async_gen_await_same_anext_coro_twice(self):
 async def async_iterate():

___
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-107901: duplicate blocks with no lineno that have an eval break and multiple predecessors (#113950)

2024-01-12 Thread iritkatriel
https://github.com/python/cpython/commit/8aa0088ea2422ed6b95076fe48a13df7562a4355
commit: 8aa0088ea2422ed6b95076fe48a13df7562a4355
branch: main
author: Irit Katriel <[email protected]>
committer: iritkatriel <[email protected]>
date: 2024-01-12T15:38:09Z
summary:

gh-107901: duplicate blocks with no lineno that have an eval break and multiple 
predecessors (#113950)

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-01-11-16-54-55.gh-issue-107901.Td3JPI.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 45fd30987760cb..50629b22822245 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1098,6 +1098,21 @@ async def test(aseq):
 code_lines = self.get_code_lines(test.__code__)
 self.assertEqual(expected_lines, code_lines)
 
+def test_line_number_synthetic_jump_multiple_predecessors(self):
+def f():
+for x in it:
+try:
+if C1:
+yield 2
+except OSError:
+pass
+
+# Ensure that all JUMP_BACKWARDs have line number
+code = f.__code__
+for inst in dis.Bytecode(code):
+if inst.opname == 'JUMP_BACKWARD':
+self.assertIsNotNone(inst.positions.lineno)
+
 def test_lineno_of_backward_jump(self):
 # Issue gh-107901
 def f():
diff --git a/Misc/NEWS.d/next/Core and 
Builtins/2024-01-11-16-54-55.gh-issue-107901.Td3JPI.rst b/Misc/NEWS.d/next/Core 
and Builtins/2024-01-11-16-54-55.gh-issue-107901.Td3JPI.rst
new file mode 100644
index 00..ce59ef55b5ee60
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-01-11-16-54-55.gh-issue-107901.Td3JPI.rst 
@@ -0,0 +1 @@
+Compiler duplicates basic blocks that have an eval breaker check, no line 
number, and multiple predecessors.
diff --git a/Python/flowgraph.c b/Python/flowgraph.c
index dad945761a4a58..4778f89e19b143 100644
--- a/Python/flowgraph.c
+++ b/Python/flowgraph.c
@@ -316,6 +316,16 @@ basicblock_exits_scope(const basicblock *b) {
 return last && IS_SCOPE_EXIT_OPCODE(last->i_opcode);
 }
 
+static inline int
+basicblock_has_eval_break(const basicblock *b) {
+for (int i = 0; i < b->b_iused; i++) {
+if (OPCODE_HAS_EVAL_BREAK(b->b_instr[i].i_opcode)) {
+return true;
+}
+}
+return false;
+}
+
 static bool
 cfg_builder_current_block_is_terminated(cfg_builder *g)
 {
@@ -2246,16 +2256,18 @@ convert_pseudo_ops(basicblock *entryblock)
 }
 
 static inline bool
-is_exit_without_lineno(basicblock *b) {
-if (!basicblock_exits_scope(b)) {
-return false;
-}
-for (int i = 0; i < b->b_iused; i++) {
-if (b->b_instr[i].i_loc.lineno >= 0) {
-return false;
+is_exit_or_eval_check_without_lineno(basicblock *b) {
+if (basicblock_exits_scope(b) || basicblock_has_eval_break(b)) {
+for (int i = 0; i < b->b_iused; i++) {
+if (b->b_instr[i].i_loc.lineno >= 0) {
+return false;
+}
 }
+return true;
+}
+else {
+return false;
 }
-return true;
 }
 
 
@@ -2283,7 +2295,7 @@ duplicate_exits_without_lineno(cfg_builder *g)
 }
 if (is_jump(last)) {
 basicblock *target = next_nonempty_block(last->i_target);
-if (is_exit_without_lineno(target) && target->b_predecessors > 1) {
+if (is_exit_or_eval_check_without_lineno(target) && 
target->b_predecessors > 1) {
 basicblock *new_target = copy_basicblock(g, target);
 if (new_target == NULL) {
 return ERROR;
@@ -2303,7 +2315,7 @@ duplicate_exits_without_lineno(cfg_builder *g)
  * fall through, and thus can only have a single predecessor */
 for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
 if (BB_HAS_FALLTHROUGH(b) && b->b_next && b->b_iused > 0) {
-if (is_exit_without_lineno(b->b_next)) {
+if (is_exit_or_eval_check_without_lineno(b->b_next)) {
 cfg_instr *last = basicblock_last_instr(b);
 assert(last != NULL);
 b->b_next->b_instr[0].i_loc = last->i_loc;

___
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-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)

2024-01-12 Thread zooba
https://github.com/python/cpython/commit/7b7cf75c027ba453c6b6e20d245e7338c70f0a03
commit: 7b7cf75c027ba453c6b6e20d245e7338c70f0a03
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: zooba 
date: 2024-01-12T15:53:27Z
summary:

gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)

(cherry picked from commit ed066481c76c6888ff5709f5b9f93b92c232a4a6)

Co-authored-by: Steve Dower 

files:
A Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst
M Lib/test/test_os.py
M Modules/posixmodule.c

diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 2d94951bf27f08..fc58f8d2dcd7a3 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -3077,6 +3077,66 @@ def test_stat_unlink_race(self):
 except subprocess.TimeoutExpired:
 proc.terminate()
 
[email protected]_subprocess()
+def test_stat_inaccessible_file(self):
+filename = os_helper.TESTFN
+ICACLS = os.path.expandvars(r"%SystemRoot%\System32\icacls.exe")
+
+with open(filename, "wb") as f:
+f.write(b'Test data')
+
+stat1 = os.stat(filename)
+
+try:
+# Remove all permissions from the file
+subprocess.check_output([ICACLS, filename, "/inheritance:r"],
+stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as ex:
+if support.verbose:
+print(ICACLS, filename, "/inheritance:r", "failed.")
+print(ex.stdout.decode("oem", "replace").rstrip())
+try:
+os.unlink(filename)
+except OSError:
+pass
+self.skipTest("Unable to create inaccessible file")
+
+def cleanup():
+# Give delete permission. We are the file owner, so we can do this
+# even though we removed all permissions earlier.
+subprocess.check_output([ICACLS, filename, "/grant", 
"Everyone:(D)"],
+stderr=subprocess.STDOUT)
+os.unlink(filename)
+
+self.addCleanup(cleanup)
+
+if support.verbose:
+print("File:", filename)
+print("stat with access:", stat1)
+
+# First test - we shouldn't raise here, because we still have access to
+# the directory and can extract enough information from its metadata.
+stat2 = os.stat(filename)
+
+if support.verbose:
+print(" without access:", stat2)
+
+# We cannot get st_dev/st_ino, so ensure those are 0 or else our test
+# is not set up correctly
+self.assertEqual(0, stat2.st_dev)
+self.assertEqual(0, stat2.st_ino)
+
+# st_mode and st_size should match (for a normal file, at least)
+self.assertEqual(stat1.st_mode, stat2.st_mode)
+self.assertEqual(stat1.st_size, stat2.st_size)
+
+# st_ctime and st_mtime should be the same
+self.assertEqual(stat1.st_ctime, stat2.st_ctime)
+self.assertEqual(stat1.st_mtime, stat2.st_mtime)
+
+# st_atime should be the same or later
+self.assertGreaterEqual(stat1.st_atime, stat2.st_atime)
+
 
 @os_helper.skip_unless_symlink
 class NonLocalSymlinkTests(unittest.TestCase):
diff --git 
a/Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst 
b/Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst
new file mode 100644
index 00..99ed8d34af7cc2
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2024-01-04-21-16-31.gh-issue-111877.fR-B4c.rst
@@ -0,0 +1,2 @@
+:func:`os.stat` calls were returning incorrect time values for files that
+could not be accessed directly.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 3468ab4632d811..1c230619679efc 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1864,8 +1864,9 @@ win32_xstat_slow_impl(const wchar_t *path, struct 
_Py_stat_struct *result,
 HANDLE hFile;
 BY_HANDLE_FILE_INFORMATION fileInfo;
 FILE_BASIC_INFO basicInfo;
+FILE_BASIC_INFO *pBasicInfo = NULL;
 FILE_ID_INFO idInfo;
-FILE_ID_INFO *pIdInfo = &idInfo;
+FILE_ID_INFO *pIdInfo = NULL;
 FILE_ATTRIBUTE_TAG_INFO tagInfo = { 0 };
 DWORD fileType, error;
 BOOL isUnhandledTag = FALSE;
@@ -2016,14 +2017,17 @@ win32_xstat_slow_impl(const wchar_t *path, struct 
_Py_stat_struct *result,
 retval = -1;
 goto cleanup;
 }
-}
 
-if (!GetFileInformationByHandleEx(hFile, FileIdInfo, &idInfo, 
sizeof(idInfo))) {
-/* Failed to get FileIdInfo, so do not pass it along */
-pIdInfo = NULL;
+/* Successfully got FileBasicInfo, so we'll pass it along */
+pBasicInfo = &basicInfo;
+
+if (GetFileInformationByHandleEx(hFile, FileIdInfo, &idInfo, 
sizeof(idInfo))) {
+/* Successfully got FileIdInfo, so pass it along */
+pIdInfo = &idInfo;
+

[Python-checkins] gh-113868: Add a number of MAP_* flags from macOS to module mmap (#113869)

2024-01-12 Thread ronaldoussoren
https://github.com/python/cpython/commit/79970792fd2c70f77c38e08c7b3a9daf6a11bde1
commit: 79970792fd2c70f77c38e08c7b3a9daf6a11bde1
branch: main
author: Ronald Oussoren 
committer: ronaldoussoren 
date: 2024-01-12T16:56:18+01:00
summary:

gh-113868: Add a number of MAP_* flags from macOS to module mmap (#113869)

The new flags were extracted from the macOS 14.2 SDK.

Co-authored-by: Serhiy Storchaka 

files:
A Misc/NEWS.d/next/Library/2024-01-09-18-07-08.gh-issue-113868.DlZG2r.rst
M Doc/library/mmap.rst
M Modules/mmapmodule.c

diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
index 1e8bfdf251e7da..ef6631ddcc68c8 100644
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -372,14 +372,25 @@ MAP_* Constants
 
 .. data:: MAP_SHARED
   MAP_PRIVATE
-  MAP_DENYWRITE
-  MAP_EXECUTABLE
+  MAP_32BIT
+  MAP_ALIGNED_SUPER
   MAP_ANON
   MAP_ANONYMOUS
+  MAP_CONCEAL
+  MAP_DENYWRITE
+  MAP_EXECUTABLE
+  MAP_HASSEMAPHORE
+  MAP_JIT
+  MAP_NOCACHE
+  MAP_NOEXTEND
+  MAP_NORESERVE
   MAP_POPULATE
+  MAP_RESILIENT_CODESIGN
+  MAP_RESILIENT_MEDIA
   MAP_STACK
-  MAP_ALIGNED_SUPER
-  MAP_CONCEAL
+  MAP_TPRO
+  MAP_TRANSLATED_ALLOW_EXECUTE
+  MAP_UNIX03
 
 These are the various flags that can be passed to :meth:`mmap.mmap`.  
:data:`MAP_ALIGNED_SUPER`
 is only available at FreeBSD and :data:`MAP_CONCEAL` is only available at 
OpenBSD.  Note
@@ -392,5 +403,12 @@ MAP_* Constants
Added :data:`MAP_STACK` constant.
 
 .. versionadded:: 3.12
-   Added :data:`MAP_ALIGNED_SUPER` constant.
-   Added :data:`MAP_CONCEAL` constant.
+   Added :data:`MAP_ALIGNED_SUPER` and :data:`MAP_CONCEAL` constants.
+
+.. versionadded:: 3.13
+   Added :data:`MAP_32BIT`, :data:`MAP_HASSEMAPHORE`, :data:`MAP_JIT`,
+   :data:`MAP_NOCACHE`, :data:`MAP_NOEXTEND`, :data:`MAP_NORESERVE`,
+   :data:`MAP_RESILIENT_CODESIGN`, :data:`MAP_RESILIENT_MEDIA`,
+   :data:`MAP_TPRO`, :data:`MAP_TRANSLATED_ALLOW_EXECUTE`, and
+   :data:`MAP_UNIX03` constants.
+
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-09-18-07-08.gh-issue-113868.DlZG2r.rst 
b/Misc/NEWS.d/next/Library/2024-01-09-18-07-08.gh-issue-113868.DlZG2r.rst
new file mode 100644
index 00..3fe18217d7a346
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-09-18-07-08.gh-issue-113868.DlZG2r.rst
@@ -0,0 +1,6 @@
+Added :data:`mmap.MAP_NORESERVE`, :data:`mmap.MAP_NOEXTEND`,
+:data:`mmap.MAP_HASSEMAPHORE`, :data:`mmap.MAP_NOCACHE`,
+:data:`mmap.MAP_JIT`, :data:`mmap.MAP_RESILIENT_CODESIGN`,
+:data:`mmap.MAP_RESILIENT_MEDIA`, :data:`mmap.MAP_32BIT`,
+:data:`mmap.MAP_TRANSLATED_ALLOW_EXECUTE`, :data:`mmap.MAP_UNIX03` and
+:data:`mmap.MAP_TPRO`. All of them are ``mmap(2)`` flags on macOS.
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index d0014e3a0429e4..48902fb3547c9a 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1653,6 +1653,39 @@ mmap_exec(PyObject *module)
 #endif
 #ifdef MAP_CONCEAL
 ADD_INT_MACRO(module, MAP_CONCEAL);
+#endif
+#ifdef MAP_NORESERVE
+ADD_INT_MACRO(module, MAP_NORESERVE);
+#endif
+#ifdef MAP_NOEXTEND
+ADD_INT_MACRO(module, MAP_NOEXTEND);
+#endif
+#ifdef MAP_HASSEMAPHORE
+ADD_INT_MACRO(module, MAP_HASSEMAPHORE);
+#endif
+#ifdef MAP_NOCACHE
+ADD_INT_MACRO(module, MAP_NOCACHE);
+#endif
+#ifdef MAP_JIT
+ADD_INT_MACRO(module, MAP_JIT);
+#endif
+#ifdef MAP_RESILIENT_CODESIGN
+ADD_INT_MACRO(module, MAP_RESILIENT_CODESIGN);
+#endif
+#ifdef MAP_RESILIENT_MEDIA
+ADD_INT_MACRO(module, MAP_RESILIENT_MEDIA);
+#endif
+#ifdef MAP_32BIT
+ADD_INT_MACRO(module, MAP_32BIT);
+#endif
+#ifdef MAP_TRANSLATED_ALLOW_EXECUTE
+ADD_INT_MACRO(module, MAP_TRANSLATED_ALLOW_EXECUTE);
+#endif
+#ifdef MAP_UNIX03
+ADD_INT_MACRO(module, MAP_UNIX03);
+#endif
+#ifdef MAP_TPRO
+ADD_INT_MACRO(module, MAP_TPRO);
 #endif
 if (PyModule_AddIntConstant(module, "PAGESIZE", (long)my_getpagesize()) < 
0 ) {
 return -1;

___
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-113710: Add types to the interpreter DSL (#113711)

2024-01-12 Thread Fidget-Spinner
https://github.com/python/cpython/commit/ac92527c08d917dffdb9c0a218d06f21114614a2
commit: ac92527c08d917dffdb9c0a218d06f21114614a2
branch: main
author: Ken Jin 
committer: Fidget-Spinner 
date: 2024-01-13T01:30:27+08:00
summary:

gh-113710: Add types to the interpreter DSL (#113711)

Co-authored-by: Jules <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-01-09-23-01-00.gh-issue-113710.pe3flY.rst
M Include/internal/pycore_opcode_metadata.h
M Include/internal/pycore_uop_ids.h
M Include/internal/pycore_uop_metadata.h
M Lib/test/test_generated_cases.py
M Python/bytecodes.c
M Python/executor_cases.c.h
M Tools/cases_generator/analyzer.py
M Tools/cases_generator/generators_common.py
M Tools/cases_generator/interpreter_definition.md
M Tools/cases_generator/lexer.py
M Tools/cases_generator/opcode_metadata_generator.py
M Tools/cases_generator/parsing.py
M Tools/cases_generator/stack.py

diff --git a/Include/internal/pycore_opcode_metadata.h 
b/Include/internal/pycore_opcode_metadata.h
index a9d698da25a1db..fbb448f663369a 100644
--- a/Include/internal/pycore_opcode_metadata.h
+++ b/Include/internal/pycore_opcode_metadata.h
@@ -909,6 +909,8 @@ enum InstructionFormat {
 #define HAS_DEOPT_FLAG (128)
 #define HAS_ERROR_FLAG (256)
 #define HAS_ESCAPES_FLAG (512)
+#define HAS_PURE_FLAG (1024)
+#define HAS_PASSTHROUGH_FLAG (2048)
 #define OPCODE_HAS_ARG(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_ARG_FLAG))
 #define OPCODE_HAS_CONST(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_CONST_FLAG))
 #define OPCODE_HAS_NAME(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_NAME_FLAG))
@@ -919,6 +921,8 @@ enum InstructionFormat {
 #define OPCODE_HAS_DEOPT(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_DEOPT_FLAG))
 #define OPCODE_HAS_ERROR(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_ERROR_FLAG))
 #define OPCODE_HAS_ESCAPES(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_ESCAPES_FLAG))
+#define OPCODE_HAS_PURE(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_PURE_FLAG))
+#define OPCODE_HAS_PASSTHROUGH(OP) (_PyOpcode_opcode_metadata[OP].flags & 
(HAS_PASSTHROUGH_FLAG))
 
 #define OPARG_FULL 0
 #define OPARG_CACHE_1 1
@@ -996,7 +1000,7 @@ const struct opcode_metadata 
_PyOpcode_opcode_metadata[268] = {
 [COMPARE_OP_STR] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG | 
HAS_ESCAPES_FLAG },
 [CONTAINS_OP] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | 
HAS_ESCAPES_FLAG },
 [CONVERT_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG },
-[COPY] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
+[COPY] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_PURE_FLAG },
 [COPY_FREE_VARS] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
 [DELETE_ATTR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | 
HAS_ERROR_FLAG | HAS_ESCAPES_FLAG },
 [DELETE_DEREF] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | 
HAS_ERROR_FLAG | HAS_ESCAPES_FLAG },
@@ -1007,8 +1011,8 @@ const struct opcode_metadata 
_PyOpcode_opcode_metadata[268] = {
 [DICT_MERGE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | 
HAS_ESCAPES_FLAG },
 [DICT_UPDATE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | 
HAS_ESCAPES_FLAG },
 [END_ASYNC_FOR] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG 
},
-[END_FOR] = { true, INSTR_FMT_IX, 0 },
-[END_SEND] = { true, INSTR_FMT_IX, 0 },
+[END_FOR] = { true, INSTR_FMT_IX, HAS_PURE_FLAG },
+[END_SEND] = { true, INSTR_FMT_IX, HAS_PURE_FLAG },
 [ENTER_EXECUTOR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | 
HAS_EVAL_BREAK_FLAG },
 [EXIT_INIT_CHECK] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | 
HAS_ESCAPES_FLAG },
 [EXTENDED_ARG] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
@@ -1067,9 +1071,9 @@ const struct opcode_metadata 
_PyOpcode_opcode_metadata[268] = {
 [LOAD_ATTR_SLOT] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | 
HAS_DEOPT_FLAG },
 [LOAD_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | 
HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG },
 [LOAD_BUILD_CLASS] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | 
HAS_ESCAPES_FLAG },
-[LOAD_CONST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_CONST_FLAG },
+[LOAD_CONST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_CONST_FLAG | 
HAS_PURE_FLAG },
 [LOAD_DEREF] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | 
HAS_ERROR_FLAG | HAS_ESCAPES_FLAG },
-[LOAD_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG },
+[LOAD_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG | 
HAS_PURE_FLAG },
 [LOAD_FAST_AND_CLEAR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | 
HAS_LOCAL_FLAG },
 [LOAD_FAST_CHECK] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG | 
HAS_ERROR_FLAG },
 [LOAD_FAST_LOAD_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | 
HAS_LOCAL_FLAG },
@@ -1096,9 +1100,9 @@ const struct opcode_metadata 
_PyOpcode_opcode_me

[Python-checkins] gh-113971: Make `zipfile.ZipInfo._compresslevel` public as `.compress_level` (#113969)

2024-01-12 Thread gpshead
https://github.com/python/cpython/commit/b44b9d99004f096619c962a8b42a19322f6a441b
commit: b44b9d99004f096619c962a8b42a19322f6a441b
branch: main
author: Gregory P. Smith 
committer: gpshead 
date: 2024-01-12T20:15:05Z
summary:

gh-113971: Make `zipfile.ZipInfo._compresslevel` public as `.compress_level` 
(#113969)

Make zipfile.ZipInfo.compress_level public.

A property is used to retain the behavior of the ._compresslevel.

People constructing zipfile.ZipInfo instances to pass into existing APIs to 
control per-file compression levels already treat this as public, there was 
never a reason for it not to be.

I used the more modern name compress_level instead of compresslevel as the 
keyword argument on other ZipFile APIs is called to be consistent with 
compress_type and a general long term preference of not runningwordstogether 
without a separator in names.

files:
A Misc/NEWS.d/next/Library/2024-01-11-16-58-10.gh-issue-113971.skJZ4g.rst
M Doc/library/zipfile.rst
M Lib/test/test_zipfile/test_core.py
M Lib/zipfile/__init__.py

diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index a77e49a7643826..c70f2ec561de8f 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -79,6 +79,11 @@ The module defines the following items:
of the last modification to the file; the fields are described in section
:ref:`zipinfo-objects`.
 
+   .. versionadded:: 3.13
+  A public ``.compress_level`` attribute has been added to expose the
+  formerly protected ``._compresslevel``.  The older protected name
+  continues to work as a property for backwards compatibility.
+
 .. function:: is_zipfile(filename)
 
Returns ``True`` if *filename* is a valid ZIP file based on its magic 
number,
diff --git a/Lib/test/test_zipfile/test_core.py 
b/Lib/test/test_zipfile/test_core.py
index f7b6db465b4bc7..9bdb08aeabb781 100644
--- a/Lib/test/test_zipfile/test_core.py
+++ b/Lib/test/test_zipfile/test_core.py
@@ -315,7 +315,7 @@ def test_writestr_compresslevel(self):
 # Compression level follows the constructor.
 a_info = zipfp.getinfo('a.txt')
 self.assertEqual(a_info.compress_type, self.compression)
-self.assertEqual(a_info._compresslevel, 1)
+self.assertEqual(a_info.compress_level, 1)
 
 # Compression level is overridden.
 b_info = zipfp.getinfo('b.txt')
@@ -408,7 +408,7 @@ def test_per_file_compresslevel(self):
 one_info = zipfp.getinfo('compress_1')
 nine_info = zipfp.getinfo('compress_9')
 self.assertEqual(one_info._compresslevel, 1)
-self.assertEqual(nine_info._compresslevel, 9)
+self.assertEqual(nine_info.compress_level, 9)
 
 def test_writing_errors(self):
 class BrokenFile(io.BytesIO):
@@ -3011,6 +3011,17 @@ def test_from_dir(self):
 self.assertEqual(zi.compress_type, zipfile.ZIP_STORED)
 self.assertEqual(zi.file_size, 0)
 
+def test_compresslevel_property(self):
+zinfo = zipfile.ZipInfo("xxx")
+self.assertFalse(zinfo._compresslevel)
+self.assertFalse(zinfo.compress_level)
+zinfo._compresslevel = 99  # test the legacy @property.setter
+self.assertEqual(zinfo.compress_level, 99)
+self.assertEqual(zinfo._compresslevel, 99)
+zinfo.compress_level = 8
+self.assertEqual(zinfo.compress_level, 8)
+self.assertEqual(zinfo._compresslevel, 8)
+
 
 class CommandLineTest(unittest.TestCase):
 
diff --git a/Lib/zipfile/__init__.py b/Lib/zipfile/__init__.py
index 1d8a607fc728c8..8005b4b34ccf76 100644
--- a/Lib/zipfile/__init__.py
+++ b/Lib/zipfile/__init__.py
@@ -371,7 +371,7 @@ def _sanitize_filename(filename):
 return filename
 
 
-class ZipInfo (object):
+class ZipInfo:
 """Class with attributes describing each file in the ZIP archive."""
 
 __slots__ = (
@@ -379,7 +379,7 @@ class ZipInfo (object):
 'filename',
 'date_time',
 'compress_type',
-'_compresslevel',
+'compress_level',
 'comment',
 'extra',
 'create_system',
@@ -413,7 +413,7 @@ def __init__(self, filename="NoName", 
date_time=(1980,1,1,0,0,0)):
 
 # Standard values:
 self.compress_type = ZIP_STORED # Type of compression for the file
-self._compresslevel = None  # Level for the compressor
+self.compress_level = None  # Level for the compressor
 self.comment = b""  # Comment for each file
 self.extra = b""# ZIP extra data
 if sys.platform == 'win32':
@@ -435,6 +435,15 @@ def __init__(self, filename="NoName", 
date_time=(1980,1,1,0,0,0)):
 # header_offset Byte offset to the file header
 # CRC   CRC-32 of the uncompressed file
 
+# Maintain backward compatibility with the old protected attribute name.
+@property
+def _compresslevel(self):
+return self.compress_level
+
+@_compresslevel.setter
+

[Python-checkins] GH-111802: set a low recursion limit for `test_bad_getattr()` in `test.pickletester` (GH-113996)

2024-01-12 Thread brettcannon
https://github.com/python/cpython/commit/8aa126354d93d7c928fb35b842cb3a4bd6e1881f
commit: 8aa126354d93d7c928fb35b842cb3a4bd6e1881f
branch: main
author: Brett Cannon 
committer: brettcannon 
date: 2024-01-12T14:14:09-08:00
summary:

GH-111802: set a low recursion limit for `test_bad_getattr()` in 
`test.pickletester` (GH-113996)

files:
A Misc/NEWS.d/next/Tests/2024-01-12-12-45-24.gh-issue-111802.gN41vt.rst
M Lib/test/pickletester.py

diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 74b82caf742f20..93e7dbbd103934 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -2437,7 +2437,7 @@ def test_bad_getattr(self):
 # Issue #3514: crash when there is an infinite loop in __getattr__
 x = BadGetattr()
 for proto in range(2):
-with support.infinite_recursion():
+with support.infinite_recursion(25):
 self.assertRaises(RuntimeError, self.dumps, x, proto)
 for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
 s = self.dumps(x, proto)
diff --git 
a/Misc/NEWS.d/next/Tests/2024-01-12-12-45-24.gh-issue-111802.gN41vt.rst 
b/Misc/NEWS.d/next/Tests/2024-01-12-12-45-24.gh-issue-111802.gN41vt.rst
new file mode 100644
index 00..7ebcbff1b9b80d
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2024-01-12-12-45-24.gh-issue-111802.gN41vt.rst
@@ -0,0 +1,3 @@
+Specify a low recursion depth for ``test_bad_getattr()`` in
+``test.pickletester`` to avoid exhausting the stack under a pydebug build
+for 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] gh-95649: Document that asyncio contains uvloop code (#107536)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/dce30c9cbc212e5455e100f35ac6afeb30dfd23e
commit: dce30c9cbc212e5455e100f35ac6afeb30dfd23e
branch: main
author: Alois Klink 
committer: AA-Turner <[email protected]>
date: 2024-01-12T22:21:13Z
summary:

gh-95649: Document that asyncio contains uvloop code (#107536)

Some of the asyncio SSL changes in GH-31275 [1] were taken from
v0.16.0 of the uvloop project [2]. In order to comply with the MIT
license, we need to just need to document the copyright information.

[1]: https://github.com/python/cpython/pull/31275
[2]: https://github.com/MagicStack/uvloop/tree/v0.16.0

files:
A Misc/NEWS.d/next/Documentation/2023-08-01-13-11-39.gh-issue-95649.F4KhPS.rst
M Doc/license.rst
M Lib/asyncio/constants.py
M Lib/asyncio/events.py
M Lib/asyncio/sslproto.py
M Lib/test/test_asyncio/test_ssl.py
M Misc/ACKS

diff --git a/Doc/license.rst b/Doc/license.rst
index 8aad93062a5a88..fa0b32c347c914 100644
--- a/Doc/license.rst
+++ b/Doc/license.rst
@@ -1066,3 +1066,32 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
+
+
+asyncio
+--
+
+Parts of the :mod:`asyncio` module are incorporated from
+`uvloop 0.16 `_,
+which is distributed under the MIT license::
+
+  Copyright (c) 2015-2021 MagicStack Inc.  http://magic.io
+
+  Permission is hereby granted, free of charge, to any person obtaining
+  a copy of this software and associated documentation files (the
+  "Software"), to deal in the Software without restriction, including
+  without limitation the rights to use, copy, modify, merge, publish,
+  distribute, sublicense, and/or sell copies of the Software, and to
+  permit persons to whom the Software is furnished to do so, subject to
+  the following conditions:
+
+  The above copyright notice and this permission notice shall be
+  included in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Lib/asyncio/constants.py b/Lib/asyncio/constants.py
index f0ce0433a7a8a6..b60c1e4236af1f 100644
--- a/Lib/asyncio/constants.py
+++ b/Lib/asyncio/constants.py
@@ -1,3 +1,7 @@
+# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0
+# SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0)
+# SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc.  
http://magic.io
+
 import enum
 
 # After the connection is lost, log warnings after this many write()s.
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index ebc3836bdc0c4d..072a99fee123c3 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -1,5 +1,9 @@
 """Event loop and event loop policy."""
 
+# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0
+# SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0)
+# SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc.  
http://magic.io
+
 __all__ = (
 'AbstractEventLoopPolicy',
 'AbstractEventLoop', 'AbstractServer',
diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py
index cbb6527d0b28e0..599e91ba0003d1 100644
--- a/Lib/asyncio/sslproto.py
+++ b/Lib/asyncio/sslproto.py
@@ -1,3 +1,7 @@
+# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0
+# SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0)
+# SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc.  
http://magic.io
+
 import collections
 import enum
 import warnings
diff --git a/Lib/test/test_asyncio/test_ssl.py 
b/Lib/test/test_asyncio/test_ssl.py
index e9cc735613fb8e..e072ede29ee3c7 100644
--- a/Lib/test/test_asyncio/test_ssl.py
+++ b/Lib/test/test_asyncio/test_ssl.py
@@ -1,3 +1,7 @@
+# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0
+# SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0)
+# SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc.  
http://magic.io
+
 import asyncio
 import contextlib
 import gc
diff --git a/Misc/ACKS b/Misc/ACKS
index 541f41f680efc8..466023f390a421 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -964,6 +964,7 @@ Carsten Klein
 Bastian Kleineidam
 Joel Klimont
 Bob Kline
+Alois Klink
 Matthias Klose
 Jeremy Kloth
 Thomas Kluyver
diff --git 
a/Misc/NEWS.d/next/Documentation/2023-08-01-13-11-39.gh-issue-95649.F4KhPS.rst 
b/Misc/NEWS.d/next/Documentation/2023-08-01-13-11-39.gh-issue-95649.F4KhPS.rst
new file mode 

[Python-checkins] gh-101100: Fix Sphinx Lint warnings in `Misc/` (#113946)

2024-01-12 Thread hugovk
https://github.com/python/cpython/commit/794983cd610958f44147664b6ab31071c6107ffb
commit: 794983cd610958f44147664b6ab31071c6107ffb
branch: main
author: Hugo van Kemenade <[email protected]>
committer: hugovk <[email protected]>
date: 2024-01-13T00:25:04+02:00
summary:

gh-101100: Fix Sphinx Lint warnings in `Misc/` (#113946)

Fix Sphinx Lint warnings in Misc/

files:
M .pre-commit-config.yaml
M Misc/NEWS.d/3.10.0a1.rst
M Misc/NEWS.d/3.10.0a2.rst
M Misc/NEWS.d/3.10.0a3.rst
M Misc/NEWS.d/3.10.0a4.rst
M Misc/NEWS.d/3.10.0a7.rst
M Misc/NEWS.d/3.10.0b1.rst
M Misc/NEWS.d/3.11.0a1.rst
M Misc/NEWS.d/3.11.0a2.rst
M Misc/NEWS.d/3.11.0a3.rst
M Misc/NEWS.d/3.11.0a4.rst
M Misc/NEWS.d/3.11.0a5.rst
M Misc/NEWS.d/3.11.0a6.rst
M Misc/NEWS.d/3.11.0b1.rst
M Misc/NEWS.d/3.5.0a1.rst
M Misc/NEWS.d/3.5.0b4.rst
M Misc/NEWS.d/3.5.2rc1.rst
M Misc/NEWS.d/3.6.0a1.rst
M Misc/NEWS.d/3.6.0b1.rst
M Misc/NEWS.d/3.6.3.rst
M Misc/NEWS.d/3.6.3rc1.rst
M Misc/NEWS.d/3.6.4rc1.rst
M Misc/NEWS.d/3.6.5rc1.rst
M Misc/NEWS.d/3.6.6rc1.rst
M Misc/NEWS.d/3.7.0a1.rst
M Misc/NEWS.d/3.7.0a2.rst
M Misc/NEWS.d/3.7.0a3.rst
M Misc/NEWS.d/3.7.0a4.rst
M Misc/NEWS.d/3.7.0b2.rst
M Misc/NEWS.d/3.7.0b4.rst
M Misc/NEWS.d/3.7.0b5.rst
M Misc/NEWS.d/3.8.0a1.rst
M Misc/NEWS.d/3.8.0a2.rst
M Misc/NEWS.d/3.8.0a3.rst
M Misc/NEWS.d/3.8.0a4.rst
M Misc/NEWS.d/3.8.0b1.rst
M Misc/NEWS.d/3.9.0a1.rst
M Misc/NEWS.d/3.9.0a2.rst
M Misc/NEWS.d/3.9.0a3.rst
M Misc/NEWS.d/3.9.0a4.rst
M Misc/NEWS.d/3.9.0a5.rst
M Misc/NEWS.d/3.9.0a6.rst
M Misc/NEWS.d/3.9.0b1.rst

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9bd9c59a1ddc74..19033ce243d9d3 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -28,7 +28,7 @@ repos:
 hooks:
   - id: sphinx-lint
 args: [--enable=default-role]
-files: ^Doc/|^Misc/NEWS.d/next/
+files: ^Doc/|^Misc/NEWS.d/
 
   - repo: meta
 hooks:
diff --git a/Misc/NEWS.d/3.10.0a1.rst b/Misc/NEWS.d/3.10.0a1.rst
index 3186de75efd9c5..c55bc3c8b5749a 100644
--- a/Misc/NEWS.d/3.10.0a1.rst
+++ b/Misc/NEWS.d/3.10.0a1.rst
@@ -4,7 +4,7 @@
 .. release date: 2020-10-05
 .. section: Security
 
-Fixes `python3x._pth` being ignored on Windows, caused by the fix for
+Fixes ``python3x._pth`` being ignored on Windows, caused by the fix for
 :issue:`29778` (CVE-2020-15801).
 
 ..
@@ -217,7 +217,7 @@ Port the :mod:`_opcode` extension module to multi-phase 
initialization
 .. nonce: 3-VJiH
 .. section: Core and Builtins
 
-Fixes the wrong error description in the error raised by using 2 `,` in
+Fixes the wrong error description in the error raised by using 2 ``,`` in
 format string in f-string and :meth:`str.format`.
 
 ..
@@ -747,7 +747,7 @@ Galindo.
 
 Fix a bug where a line with only a line continuation character is not
 considered a blank line at tokenizer level. In such cases, more than a
-single `NEWLINE` token was emitted. The old parser was working around the
+single ``NEWLINE`` token was emitted. The old parser was working around the
 issue, but the new parser threw a :exc:`SyntaxError` for valid input due to
 this. For example, an empty line following a line continuation character was
 interpreted as a :exc:`SyntaxError`.
@@ -1157,7 +1157,7 @@ The :class:`threading.Thread` constructor now uses the 
target name if the
 .. nonce: bnh-VG
 .. section: Library
 
-fix `tkinter.EventType` Enum so all members are strings, and none are tuples
+fix ``tkinter.EventType`` Enum so all members are strings, and none are tuples
 
 ..
 
@@ -1229,8 +1229,8 @@ Previously there was no way to check that without using 
private API. See the
 .. nonce: pI_uZQ
 .. section: Library
 
-Honor `object` overrides in `Enum` class creation (specifically, `__str__`,
-`__repr__`, `__format__`, and `__reduce_ex__`).
+Honor ``object`` overrides in ``Enum`` class creation (specifically, 
``__str__``,
+``__repr__``, ``__format__``, and ``__reduce_ex__``).
 
 ..
 
@@ -1239,7 +1239,7 @@ Honor `object` overrides in `Enum` class creation 
(specifically, `__str__`,
 .. nonce: IpYkEe
 .. section: Library
 
-`enum.Flag` and `enum.IntFlag` members are now iterable
+``enum.Flag`` and ``enum.IntFlag`` members are now iterable.
 
 ..
 
@@ -1557,7 +1557,7 @@ activation.
 .. nonce: wqrj8C
 .. section: Library
 
-Recursive evaluation of `typing.ForwardRef` in `get_type_hints`.
+Recursive evaluation of ``typing.ForwardRef`` in ``get_type_hints``.
 
 ..
 
@@ -1851,8 +1851,8 @@ Merry.
 .. nonce: 1dk8Bu
 .. section: Library
 
-:mod:`ensurepip` now disables the use of `pip` cache when installing the
-bundled versions of `pip` and `setuptools`.  Patch by Krzysztof Konopko.
+:mod:`ensurepip` now disables the use of ``pip`` cache when installing the
+bundled versions of ``pip`` and ``setuptools``.  Patch by Krzysztof Konopko.
 
 ..
 
@@ -1933,7 +1933,7 @@ Smith and Tal Einat.
 .. nonce: n7fOwS
 .. section: Library
 
-Added a `defaults` parameter to :class:`logging.Formatter`, to allow
+Added a ``defaults`` parameter to :class:`log

[Python-checkins] Fix a grammatical error in `pycore_pymem.h` (#112993)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/9a71750a2930ebeac4080a378966aa7fdd4a9b34
commit: 9a71750a2930ebeac4080a378966aa7fdd4a9b34
branch: main
author: Joseph Pearson <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T22:25:52Z
summary:

Fix a grammatical error in `pycore_pymem.h` (#112993)

files:
M Include/internal/pycore_pymem.h

diff --git a/Include/internal/pycore_pymem.h b/Include/internal/pycore_pymem.h
index 8631ca34a5e616..c49742e177a130 100644
--- a/Include/internal/pycore_pymem.h
+++ b/Include/internal/pycore_pymem.h
@@ -64,7 +64,7 @@ extern int _PyMem_SetDefaultAllocator(
- PYMEM_FORBIDDENBYTE: untouchable bytes at each end of a block
 
Byte patterns 0xCB, 0xDB and 0xFB have been replaced with 0xCD, 0xDD and
-   0xFD to use the same values than Windows CRT debug malloc() and free().
+   0xFD to use the same values as Windows CRT debug malloc() and free().
If modified, _PyMem_IsPtrFreed() should be updated as well. */
 #define PYMEM_CLEANBYTE  0xCD
 #define PYMEM_DEADBYTE   0xDD

___
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] Tutorial: Clarify 'nonzero exit status' in the appendix (#112039)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/32f3684b8f18d757945eee67a697cb4a95c697db
commit: 32f3684b8f18d757945eee67a697cb4a95c697db
branch: main
author: Andrew Zipperer <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T22:42:51Z
summary:

Tutorial: Clarify 'nonzero exit status' in the appendix (#112039)

files:
M Doc/tutorial/appendix.rst

diff --git a/Doc/tutorial/appendix.rst b/Doc/tutorial/appendix.rst
index 588591fcdb726f..4bea0d8a49ce20 100644
--- a/Doc/tutorial/appendix.rst
+++ b/Doc/tutorial/appendix.rst
@@ -20,7 +20,7 @@ In interactive mode, it then returns to the primary prompt; 
when input came from
 a file, it exits with a nonzero exit status after printing the stack trace.
 (Exceptions handled by an :keyword:`except` clause in a :keyword:`try` 
statement
 are not errors in this context.)  Some errors are unconditionally fatal and
-cause an exit with a nonzero exit; this applies to internal inconsistencies and
+cause an exit with a nonzero exit status; this applies to internal 
inconsistencies and
 some cases of running out of memory.  All error messages are written to the
 standard error stream; normal output from executed commands is written to
 standard output.

___
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] Tutorial: Clarify 'nonzero exit status' in the appendix (GH-112039) (#114000)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/e276743682d52f3e4b6b9ff5332821473f3de0fc
commit: e276743682d52f3e4b6b9ff5332821473f3de0fc
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T22:48:32Z
summary:

[3.11] Tutorial: Clarify 'nonzero exit status' in the appendix (GH-112039) 
(#114000)

Tutorial: Clarify 'nonzero exit status' in the appendix (GH-112039)
(cherry picked from commit 32f3684b8f18d757945eee67a697cb4a95c697db)

Co-authored-by: Andrew Zipperer <[email protected]>

files:
M Doc/tutorial/appendix.rst

diff --git a/Doc/tutorial/appendix.rst b/Doc/tutorial/appendix.rst
index 588591fcdb726f..4bea0d8a49ce20 100644
--- a/Doc/tutorial/appendix.rst
+++ b/Doc/tutorial/appendix.rst
@@ -20,7 +20,7 @@ In interactive mode, it then returns to the primary prompt; 
when input came from
 a file, it exits with a nonzero exit status after printing the stack trace.
 (Exceptions handled by an :keyword:`except` clause in a :keyword:`try` 
statement
 are not errors in this context.)  Some errors are unconditionally fatal and
-cause an exit with a nonzero exit; this applies to internal inconsistencies and
+cause an exit with a nonzero exit status; this applies to internal 
inconsistencies and
 some cases of running out of memory.  All error messages are written to the
 standard error stream; normal output from executed commands is written to
 standard output.

___
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] Tutorial: Clarify 'nonzero exit status' in the appendix (GH-112039) (#113999)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/68d1e30c946d003fdcfe2a4bbf76feeef6ebfa48
commit: 68d1e30c946d003fdcfe2a4bbf76feeef6ebfa48
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T22:48:59Z
summary:

[3.12] Tutorial: Clarify 'nonzero exit status' in the appendix (GH-112039) 
(#113999)

Tutorial: Clarify 'nonzero exit status' in the appendix (GH-112039)
(cherry picked from commit 32f3684b8f18d757945eee67a697cb4a95c697db)

Co-authored-by: Andrew Zipperer <[email protected]>

files:
M Doc/tutorial/appendix.rst

diff --git a/Doc/tutorial/appendix.rst b/Doc/tutorial/appendix.rst
index 588591fcdb726f..4bea0d8a49ce20 100644
--- a/Doc/tutorial/appendix.rst
+++ b/Doc/tutorial/appendix.rst
@@ -20,7 +20,7 @@ In interactive mode, it then returns to the primary prompt; 
when input came from
 a file, it exits with a nonzero exit status after printing the stack trace.
 (Exceptions handled by an :keyword:`except` clause in a :keyword:`try` 
statement
 are not errors in this context.)  Some errors are unconditionally fatal and
-cause an exit with a nonzero exit; this applies to internal inconsistencies and
+cause an exit with a nonzero exit status; this applies to internal 
inconsistencies and
 some cases of running out of memory.  All error messages are written to the
 standard error stream; normal output from executed commands is written to
 standard output.

___
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] Link to the glossary for "magic methods" in ``MagicMock`` (#111292)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/e97da8677f7bbc6d970e230d334cd646ab662af1
commit: e97da8677f7bbc6d970e230d334cd646ab662af1
branch: main
author: Pierre Equoy 
committer: AA-Turner <[email protected]>
date: 2024-01-12T22:54:36Z
summary:

Link to the glossary for "magic methods" in ``MagicMock`` (#111292)

The MagicMock documentation mentions magic methods several times without
actually pointing to the term in the glossary. This can be helpful for
people to fully understand what those magic methods are.

files:
M Doc/library/unittest.mock.rst

diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index f1cc482c5cfe2a..eca20b94ec8e74 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -2009,8 +2009,8 @@ Mocking Magic Methods
 ~
 
 :class:`Mock` supports mocking the Python protocol methods, also known as
-"magic methods". This allows mock objects to replace containers or other
-objects that implement Python protocols.
+:term:`"magic methods" `. This allows mock objects to replace
+containers or other objects that implement Python protocols.
 
 Because magic methods are looked up differently from normal methods [#]_, this
 support has been specially implemented. This means that only specific magic
@@ -2108,8 +2108,8 @@ There are two ``MagicMock`` variants: :class:`MagicMock` 
and :class:`NonCallable
 .. class:: MagicMock(*args, **kw)
 
``MagicMock`` is a subclass of :class:`Mock` with default implementations
-   of most of the magic methods. You can use ``MagicMock`` without having to
-   configure the magic methods yourself.
+   of most of the :term:`magic methods `. You can use
+   ``MagicMock`` without having to configure the magic methods yourself.
 
The constructor parameters have the same meaning as for :class:`Mock`.
 

___
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 Lint warnings in `Misc/` (GH-113946) (#114001)

2024-01-12 Thread hugovk
https://github.com/python/cpython/commit/4bd4367a97cf217faf984113104631630a59a96b
commit: 4bd4367a97cf217faf984113104631630a59a96b
branch: 3.11
author: Hugo van Kemenade <[email protected]>
committer: hugovk <[email protected]>
date: 2024-01-12T15:58:26-07:00
summary:

[3.11] gh-101100: Fix Sphinx Lint warnings in `Misc/` (GH-113946) (#114001)

files:
M .pre-commit-config.yaml
M Misc/NEWS.d/3.10.0a1.rst
M Misc/NEWS.d/3.10.0a2.rst
M Misc/NEWS.d/3.10.0a3.rst
M Misc/NEWS.d/3.10.0a4.rst
M Misc/NEWS.d/3.10.0a7.rst
M Misc/NEWS.d/3.10.0b1.rst
M Misc/NEWS.d/3.11.0a1.rst
M Misc/NEWS.d/3.11.0a2.rst
M Misc/NEWS.d/3.11.0a3.rst
M Misc/NEWS.d/3.11.0a4.rst
M Misc/NEWS.d/3.11.0a5.rst
M Misc/NEWS.d/3.11.0a6.rst
M Misc/NEWS.d/3.11.0b1.rst
M Misc/NEWS.d/3.11.0b5.rst
M Misc/NEWS.d/3.5.0a1.rst
M Misc/NEWS.d/3.5.0b4.rst
M Misc/NEWS.d/3.5.2rc1.rst
M Misc/NEWS.d/3.6.0a1.rst
M Misc/NEWS.d/3.6.0b1.rst
M Misc/NEWS.d/3.6.3.rst
M Misc/NEWS.d/3.6.3rc1.rst
M Misc/NEWS.d/3.6.4rc1.rst
M Misc/NEWS.d/3.6.5rc1.rst
M Misc/NEWS.d/3.6.6rc1.rst
M Misc/NEWS.d/3.7.0a1.rst
M Misc/NEWS.d/3.7.0a2.rst
M Misc/NEWS.d/3.7.0a3.rst
M Misc/NEWS.d/3.7.0a4.rst
M Misc/NEWS.d/3.7.0b2.rst
M Misc/NEWS.d/3.7.0b4.rst
M Misc/NEWS.d/3.7.0b5.rst
M Misc/NEWS.d/3.8.0a1.rst
M Misc/NEWS.d/3.8.0a2.rst
M Misc/NEWS.d/3.8.0a3.rst
M Misc/NEWS.d/3.8.0a4.rst
M Misc/NEWS.d/3.8.0b1.rst
M Misc/NEWS.d/3.9.0a1.rst
M Misc/NEWS.d/3.9.0a2.rst
M Misc/NEWS.d/3.9.0a3.rst
M Misc/NEWS.d/3.9.0a4.rst
M Misc/NEWS.d/3.9.0a5.rst
M Misc/NEWS.d/3.9.0a6.rst
M Misc/NEWS.d/3.9.0b1.rst

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 438a1149d44e9c..ecf5d93f9b2be6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -21,7 +21,7 @@ repos:
 hooks:
   - id: sphinx-lint
 args: [--enable=default-role]
-files: ^Doc/|^Misc/NEWS.d/next/
+files: ^Doc/|^Misc/NEWS.d/
 
   - repo: meta
 hooks:
diff --git a/Misc/NEWS.d/3.10.0a1.rst b/Misc/NEWS.d/3.10.0a1.rst
index 564da0b4f74675..52b6a51ea8fb2c 100644
--- a/Misc/NEWS.d/3.10.0a1.rst
+++ b/Misc/NEWS.d/3.10.0a1.rst
@@ -4,7 +4,7 @@
 .. release date: 2020-10-05
 .. section: Security
 
-Fixes `python3x._pth` being ignored on Windows, caused by the fix for
+Fixes ``python3x._pth`` being ignored on Windows, caused by the fix for
 :issue:`29778` (CVE-2020-15801).
 
 ..
@@ -217,7 +217,7 @@ Port the :mod:`_opcode` extension module to multi-phase 
initialization
 .. nonce: 3-VJiH
 .. section: Core and Builtins
 
-Fixes the wrong error description in the error raised by using 2 `,` in
+Fixes the wrong error description in the error raised by using 2 ``,`` in
 format string in f-string and :meth:`str.format`.
 
 ..
@@ -747,7 +747,7 @@ Galindo.
 
 Fix a bug where a line with only a line continuation character is not
 considered a blank line at tokenizer level. In such cases, more than a
-single `NEWLINE` token was emitted. The old parser was working around the
+single ``NEWLINE`` token was emitted. The old parser was working around the
 issue, but the new parser threw a :exc:`SyntaxError` for valid input due to
 this. For example, an empty line following a line continuation character was
 interpreted as a :exc:`SyntaxError`.
@@ -1157,7 +1157,7 @@ The :class:`threading.Thread` constructor now uses the 
target name if the
 .. nonce: bnh-VG
 .. section: Library
 
-fix `tkinter.EventType` Enum so all members are strings, and none are tuples
+fix ``tkinter.EventType`` Enum so all members are strings, and none are tuples
 
 ..
 
@@ -1229,8 +1229,8 @@ Previously there was no way to check that without using 
private API. See the
 .. nonce: pI_uZQ
 .. section: Library
 
-Honor `object` overrides in `Enum` class creation (specifically, `__str__`,
-`__repr__`, `__format__`, and `__reduce_ex__`).
+Honor ``object`` overrides in ``Enum`` class creation (specifically, 
``__str__``,
+``__repr__``, ``__format__``, and ``__reduce_ex__``).
 
 ..
 
@@ -1239,7 +1239,7 @@ Honor `object` overrides in `Enum` class creation 
(specifically, `__str__`,
 .. nonce: IpYkEe
 .. section: Library
 
-`enum.Flag` and `enum.IntFlag` members are now iterable
+``enum.Flag`` and ``enum.IntFlag`` members are now iterable.
 
 ..
 
@@ -1557,7 +1557,7 @@ activation.
 .. nonce: wqrj8C
 .. section: Library
 
-Recursive evaluation of `typing.ForwardRef` in `get_type_hints`.
+Recursive evaluation of ``typing.ForwardRef`` in ``get_type_hints``.
 
 ..
 
@@ -1851,8 +1851,8 @@ Merry.
 .. nonce: 1dk8Bu
 .. section: Library
 
-:mod:`ensurepip` now disables the use of `pip` cache when installing the
-bundled versions of `pip` and `setuptools`.  Patch by Krzysztof Konopko.
+:mod:`ensurepip` now disables the use of ``pip`` cache when installing the
+bundled versions of ``pip`` and ``setuptools``.  Patch by Krzysztof Konopko.
 
 ..
 
@@ -1933,7 +1933,7 @@ Smith and Tal Einat.
 .. nonce: n7fOwS
 .. section: Library
 
-Added a `defaults` parameter to :class:`logging.Formatter`, to allow
+Added a ``defaults`` parameter to 

[Python-checkins] datamodel: Fix a typo in ``object.__init_subclass__`` (#111599)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/a47353d587b78bb5501b21343d9bca739c49a43a
commit: a47353d587b78bb5501b21343d9bca739c49a43a
branch: main
author: InSync <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T22:59:24Z
summary:

datamodel: Fix a typo in ``object.__init_subclass__`` (#111599)

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 62e3ddab759944..ca29a3712dfa38 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2308,7 +2308,7 @@ class defining the method.
this method is implicitly converted to a class method.
 
Keyword arguments which are given to a new class are passed to
-   the parent's class ``__init_subclass__``. For compatibility with
+   the parent class's ``__init_subclass__``. For compatibility with
other classes using ``__init_subclass__``, one should take out the
needed keyword arguments and pass the others over to the base
class, as in::

___
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 Lint warnings in `Misc/` (GH-113946) (#113998)

2024-01-12 Thread hugovk
https://github.com/python/cpython/commit/27f7f3712f976c619fb99b321fa5e2883212f077
commit: 27f7f3712f976c619fb99b321fa5e2883212f077
branch: 3.12
author: Hugo van Kemenade <[email protected]>
committer: hugovk <[email protected]>
date: 2024-01-12T15:58:16-07:00
summary:

[3.12] gh-101100: Fix Sphinx Lint warnings in `Misc/` (GH-113946) (#113998)

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

files:
M .pre-commit-config.yaml
M Misc/NEWS.d/3.10.0a1.rst
M Misc/NEWS.d/3.10.0a2.rst
M Misc/NEWS.d/3.10.0a3.rst
M Misc/NEWS.d/3.10.0a4.rst
M Misc/NEWS.d/3.10.0a7.rst
M Misc/NEWS.d/3.10.0b1.rst
M Misc/NEWS.d/3.11.0a1.rst
M Misc/NEWS.d/3.11.0a2.rst
M Misc/NEWS.d/3.11.0a3.rst
M Misc/NEWS.d/3.11.0a4.rst
M Misc/NEWS.d/3.11.0a5.rst
M Misc/NEWS.d/3.11.0a6.rst
M Misc/NEWS.d/3.11.0b1.rst
M Misc/NEWS.d/3.12.0b4.rst
M Misc/NEWS.d/3.12.0rc1.rst
M Misc/NEWS.d/3.5.0a1.rst
M Misc/NEWS.d/3.5.0b4.rst
M Misc/NEWS.d/3.5.2rc1.rst
M Misc/NEWS.d/3.6.0a1.rst
M Misc/NEWS.d/3.6.0b1.rst
M Misc/NEWS.d/3.6.3.rst
M Misc/NEWS.d/3.6.3rc1.rst
M Misc/NEWS.d/3.6.4rc1.rst
M Misc/NEWS.d/3.6.5rc1.rst
M Misc/NEWS.d/3.6.6rc1.rst
M Misc/NEWS.d/3.7.0a1.rst
M Misc/NEWS.d/3.7.0a2.rst
M Misc/NEWS.d/3.7.0a3.rst
M Misc/NEWS.d/3.7.0a4.rst
M Misc/NEWS.d/3.7.0b2.rst
M Misc/NEWS.d/3.7.0b4.rst
M Misc/NEWS.d/3.7.0b5.rst
M Misc/NEWS.d/3.8.0a1.rst
M Misc/NEWS.d/3.8.0a2.rst
M Misc/NEWS.d/3.8.0a3.rst
M Misc/NEWS.d/3.8.0a4.rst
M Misc/NEWS.d/3.8.0b1.rst
M Misc/NEWS.d/3.9.0a1.rst
M Misc/NEWS.d/3.9.0a2.rst
M Misc/NEWS.d/3.9.0a3.rst
M Misc/NEWS.d/3.9.0a4.rst
M Misc/NEWS.d/3.9.0a5.rst
M Misc/NEWS.d/3.9.0a6.rst
M Misc/NEWS.d/3.9.0b1.rst

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9bd9c59a1ddc74..19033ce243d9d3 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -28,7 +28,7 @@ repos:
 hooks:
   - id: sphinx-lint
 args: [--enable=default-role]
-files: ^Doc/|^Misc/NEWS.d/next/
+files: ^Doc/|^Misc/NEWS.d/
 
   - repo: meta
 hooks:
diff --git a/Misc/NEWS.d/3.10.0a1.rst b/Misc/NEWS.d/3.10.0a1.rst
index 765d6fefe1b2da..82a2a8d21bcf74 100644
--- a/Misc/NEWS.d/3.10.0a1.rst
+++ b/Misc/NEWS.d/3.10.0a1.rst
@@ -4,7 +4,7 @@
 .. release date: 2020-10-05
 .. section: Security
 
-Fixes `python3x._pth` being ignored on Windows, caused by the fix for
+Fixes ``python3x._pth`` being ignored on Windows, caused by the fix for
 :issue:`29778` (CVE-2020-15801).
 
 ..
@@ -217,7 +217,7 @@ Port the :mod:`_opcode` extension module to multi-phase 
initialization
 .. nonce: 3-VJiH
 .. section: Core and Builtins
 
-Fixes the wrong error description in the error raised by using 2 `,` in
+Fixes the wrong error description in the error raised by using 2 ``,`` in
 format string in f-string and :meth:`str.format`.
 
 ..
@@ -747,7 +747,7 @@ Galindo.
 
 Fix a bug where a line with only a line continuation character is not
 considered a blank line at tokenizer level. In such cases, more than a
-single `NEWLINE` token was emitted. The old parser was working around the
+single ``NEWLINE`` token was emitted. The old parser was working around the
 issue, but the new parser threw a :exc:`SyntaxError` for valid input due to
 this. For example, an empty line following a line continuation character was
 interpreted as a :exc:`SyntaxError`.
@@ -1157,7 +1157,7 @@ The :class:`threading.Thread` constructor now uses the 
target name if the
 .. nonce: bnh-VG
 .. section: Library
 
-fix `tkinter.EventType` Enum so all members are strings, and none are tuples
+fix ``tkinter.EventType`` Enum so all members are strings, and none are tuples
 
 ..
 
@@ -1229,8 +1229,8 @@ Previously there was no way to check that without using 
private API. See the
 .. nonce: pI_uZQ
 .. section: Library
 
-Honor `object` overrides in `Enum` class creation (specifically, `__str__`,
-`__repr__`, `__format__`, and `__reduce_ex__`).
+Honor ``object`` overrides in ``Enum`` class creation (specifically, 
``__str__``,
+``__repr__``, ``__format__``, and ``__reduce_ex__``).
 
 ..
 
@@ -1239,7 +1239,7 @@ Honor `object` overrides in `Enum` class creation 
(specifically, `__str__`,
 .. nonce: IpYkEe
 .. section: Library
 
-`enum.Flag` and `enum.IntFlag` members are now iterable
+``enum.Flag`` and ``enum.IntFlag`` members are now iterable.
 
 ..
 
@@ -1557,7 +1557,7 @@ activation.
 .. nonce: wqrj8C
 .. section: Library
 
-Recursive evaluation of `typing.ForwardRef` in `get_type_hints`.
+Recursive evaluation of ``typing.ForwardRef`` in ``get_type_hints``.
 
 ..
 
@@ -1851,8 +1851,8 @@ Merry.
 .. nonce: 1dk8Bu
 .. section: Library
 
-:mod:`ensurepip` now disables the use of `pip` cache when installing the
-bundled versions of `pip` and `setuptools`.  Patch by Krzysztof Konopko.
+:mod:`ensurepip` now disables the use of ``pip`` cache when installing the
+bundled versions of ``pip`` and ``setuptools``.  Patch by Krzysztof Konopko.
 
 ..
 
@@ -1933,7 +1933,7 @@ Smith and Tal Einat.
 .. nonce: n7fOwS
 .. section: Library
 

[Python-checkins] [3.12] Link to the glossary for "magic methods" in ``MagicMock`` (GH-111292) (#114002)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/b9e15bef829040510543433f68f08af65610a34e
commit: b9e15bef829040510543433f68f08af65610a34e
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T23:00:50Z
summary:

[3.12] Link to the glossary for "magic methods" in ``MagicMock`` (GH-111292) 
(#114002)

Link to the glossary for "magic methods" in ``MagicMock`` (GH-111292)

The MagicMock documentation mentions magic methods several times without
actually pointing to the term in the glossary. This can be helpful for
people to fully understand what those magic methods are.
(cherry picked from commit e97da8677f7bbc6d970e230d334cd646ab662af1)

Co-authored-by: Pierre Equoy 

files:
M Doc/library/unittest.mock.rst

diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 27adfd9ae01095..d11307447b26a3 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -1960,8 +1960,8 @@ Mocking Magic Methods
 ~
 
 :class:`Mock` supports mocking the Python protocol methods, also known as
-"magic methods". This allows mock objects to replace containers or other
-objects that implement Python protocols.
+:term:`"magic methods" `. This allows mock objects to replace
+containers or other objects that implement Python protocols.
 
 Because magic methods are looked up differently from normal methods [#]_, this
 support has been specially implemented. This means that only specific magic
@@ -2059,8 +2059,8 @@ There are two ``MagicMock`` variants: :class:`MagicMock` 
and :class:`NonCallable
 .. class:: MagicMock(*args, **kw)
 
``MagicMock`` is a subclass of :class:`Mock` with default implementations
-   of most of the magic methods. You can use ``MagicMock`` without having to
-   configure the magic methods yourself.
+   of most of the :term:`magic methods `. You can use
+   ``MagicMock`` without having to configure the magic methods yourself.
 
The constructor parameters have the same meaning as for :class:`Mock`.
 

___
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] Link to the glossary for "magic methods" in ``MagicMock`` (GH-111292) (#114003)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/2d184b26df0c6996a1b0617820b6807def8d53b4
commit: 2d184b26df0c6996a1b0617820b6807def8d53b4
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T23:01:09Z
summary:

[3.11] Link to the glossary for "magic methods" in ``MagicMock`` (GH-111292) 
(#114003)

Link to the glossary for "magic methods" in ``MagicMock`` (GH-111292)

The MagicMock documentation mentions magic methods several times without
actually pointing to the term in the glossary. This can be helpful for
people to fully understand what those magic methods are.
(cherry picked from commit e97da8677f7bbc6d970e230d334cd646ab662af1)

Co-authored-by: Pierre Equoy 

files:
M Doc/library/unittest.mock.rst

diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 098ba2d7827ab1..75d8a6c9bdee3f 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -1958,8 +1958,8 @@ Mocking Magic Methods
 ~
 
 :class:`Mock` supports mocking the Python protocol methods, also known as
-"magic methods". This allows mock objects to replace containers or other
-objects that implement Python protocols.
+:term:`"magic methods" `. This allows mock objects to replace
+containers or other objects that implement Python protocols.
 
 Because magic methods are looked up differently from normal methods [#]_, this
 support has been specially implemented. This means that only specific magic
@@ -2057,8 +2057,8 @@ There are two ``MagicMock`` variants: :class:`MagicMock` 
and :class:`NonCallable
 .. class:: MagicMock(*args, **kw)
 
``MagicMock`` is a subclass of :class:`Mock` with default implementations
-   of most of the magic methods. You can use ``MagicMock`` without having to
-   configure the magic methods yourself.
+   of most of the :term:`magic methods `. You can use
+   ``MagicMock`` without having to configure the magic methods yourself.
 
The constructor parameters have the same meaning as for :class:`Mock`.
 

___
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] datamodel: Fix a typo in ``object.__init_subclass__`` (GH-111599) (#114004)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/d577225104f1696e30e9cc5fd93d80c7d437946f
commit: d577225104f1696e30e9cc5fd93d80c7d437946f
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T23:05:48Z
summary:

[3.12] datamodel: Fix a typo in ``object.__init_subclass__`` (GH-111599) 
(#114004)

datamodel: Fix a typo in ``object.__init_subclass__`` (GH-111599)
(cherry picked from commit a47353d587b78bb5501b21343d9bca739c49a43a)

Co-authored-by: InSync <[email protected]>

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index b4d404696940c3..03dc1d69852127 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2303,7 +2303,7 @@ class defining the method.
this method is implicitly converted to a class method.
 
Keyword arguments which are given to a new class are passed to
-   the parent's class ``__init_subclass__``. For compatibility with
+   the parent class's ``__init_subclass__``. For compatibility with
other classes using ``__init_subclass__``, one should take out the
needed keyword arguments and pass the others over to the base
class, as in::

___
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] datamodel: Fix a typo in ``object.__init_subclass__`` (GH-111599) (#114005)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/cd8fd2292e7ad029d030eff88eda7d14d92dbdf7
commit: cd8fd2292e7ad029d030eff88eda7d14d92dbdf7
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T23:06:14Z
summary:

[3.11] datamodel: Fix a typo in ``object.__init_subclass__`` (GH-111599) 
(#114005)

datamodel: Fix a typo in ``object.__init_subclass__`` (GH-111599)
(cherry picked from commit a47353d587b78bb5501b21343d9bca739c49a43a)

Co-authored-by: InSync <[email protected]>

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index efa24acb5db5e0..1f9bb82c8db846 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2286,7 +2286,7 @@ class defining the method.
this method is implicitly converted to a class method.
 
Keyword arguments which are given to a new class are passed to
-   the parent's class ``__init_subclass__``. For compatibility with
+   the parent class's ``__init_subclass__``. For compatibility with
other classes using ``__init_subclass__``, one should take out the
needed keyword arguments and pass the others over to the base
class, as in::

___
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-111801: set a lower recursion limit for `test_infintely_many_bases()` in `test_isinstance` (#113997)

2024-01-12 Thread brettcannon
https://github.com/python/cpython/commit/3c19ee0422e9b9f1582fb74931c174a84583bca0
commit: 3c19ee0422e9b9f1582fb74931c174a84583bca0
branch: main
author: Brett Cannon 
committer: brettcannon 
date: 2024-01-12T15:19:21-08:00
summary:

GH-111801: set a lower recursion limit for `test_infintely_many_bases()` in 
`test_isinstance` (#113997)

files:
A Misc/NEWS.d/next/Tests/2024-01-12-13-19-12.gh-issue-111801.9hh9DY.rst
M Lib/test/test_isinstance.py

diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index bf9332e40aeaf2..791981b878b1f2 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -344,7 +344,7 @@ class B:
 pass
 A.__getattr__ = B.__getattr__ = X.__getattr__
 return (A(), B())
-with support.infinite_recursion():
+with support.infinite_recursion(25):
 self.assertRaises(RecursionError, issubclass, X(), int)
 
 
diff --git 
a/Misc/NEWS.d/next/Tests/2024-01-12-13-19-12.gh-issue-111801.9hh9DY.rst 
b/Misc/NEWS.d/next/Tests/2024-01-12-13-19-12.gh-issue-111801.9hh9DY.rst
new file mode 100644
index 00..660fddd4a93038
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2024-01-12-13-19-12.gh-issue-111801.9hh9DY.rst
@@ -0,0 +1,3 @@
+Lower the recursion limit in ``test_isinstance`` for
+``test_infinitely_many_bases()``. This prevents a stack overflow on a
+pydebug 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] gh-89159: Document missing TarInfo members (#91564)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/3aa4b839e4aa01d4e8bc5c7685fd0eb17c4609b8
commit: 3aa4b839e4aa01d4e8bc5c7685fd0eb17c4609b8
branch: main
author: Stanley <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T23:19:57Z
summary:

gh-89159: Document missing TarInfo members (#91564)

files:
M Doc/library/tarfile.rst

diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
index 7ba29d4a40dedb..34a738a7f1c41f 100644
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -837,6 +837,36 @@ A ``TarInfo`` object has the following public data 
attributes:
   :meth:`~TarFile.extractall`, causing extraction to skip applying this
   attribute.
 
+.. attribute:: TarInfo.chksum
+
+   Header checksum.
+
+
+.. attribute:: TarInfo.devmajor
+
+   Device major number.
+
+
+.. attribute:: TarInfo.devminor
+
+   Device minor number.
+
+
+.. attribute:: TarInfo.offset
+
+   The tar header starts here.
+
+
+.. attribute:: TarInfo.offset_data
+
+   The file's data starts here.
+
+
+.. attribute:: TarInfo.sparse
+
+   Sparse member information.
+
+
 .. attribute:: TarInfo.pax_headers
:type: dict
 

___
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-89159: Document missing TarInfo members (GH-91564) (#114007)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/d7a544ad3b575d93353c9c755e57e5435ab2730d
commit: d7a544ad3b575d93353c9c755e57e5435ab2730d
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T23:26:03Z
summary:

[3.11] gh-89159: Document missing TarInfo members (GH-91564) (#114007)

gh-89159: Document missing TarInfo members (GH-91564)
(cherry picked from commit 3aa4b839e4aa01d4e8bc5c7685fd0eb17c4609b8)

Co-authored-by: Stanley <[email protected]>

files:
M Doc/library/tarfile.rst

diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
index dadbc6ea87f843..cd2df3e69e3729 100644
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -829,6 +829,36 @@ A ``TarInfo`` object has the following public data 
attributes:
   :meth:`~TarFile.extractall`, causing extraction to skip applying this
   attribute.
 
+.. attribute:: TarInfo.chksum
+
+   Header checksum.
+
+
+.. attribute:: TarInfo.devmajor
+
+   Device major number.
+
+
+.. attribute:: TarInfo.devminor
+
+   Device minor number.
+
+
+.. attribute:: TarInfo.offset
+
+   The tar header starts here.
+
+
+.. attribute:: TarInfo.offset_data
+
+   The file's data starts here.
+
+
+.. attribute:: TarInfo.sparse
+
+   Sparse member information.
+
+
 .. attribute:: TarInfo.pax_headers
:type: dict
 

___
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-89159: Document missing TarInfo members (GH-91564) (#114006)

2024-01-12 Thread AA-Turner
https://github.com/python/cpython/commit/1ea6658342af217570c24b6f00859ec30bbed72e
commit: 1ea6658342af217570c24b6f00859ec30bbed72e
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-12T23:26:08Z
summary:

[3.12] gh-89159: Document missing TarInfo members (GH-91564) (#114006)

gh-89159: Document missing TarInfo members (GH-91564)
(cherry picked from commit 3aa4b839e4aa01d4e8bc5c7685fd0eb17c4609b8)

Co-authored-by: Stanley <[email protected]>

files:
M Doc/library/tarfile.rst

diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
index 6e34158084eb5c..dbbcb127f6f209 100644
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -832,6 +832,36 @@ A ``TarInfo`` object has the following public data 
attributes:
   :meth:`~TarFile.extractall`, causing extraction to skip applying this
   attribute.
 
+.. attribute:: TarInfo.chksum
+
+   Header checksum.
+
+
+.. attribute:: TarInfo.devmajor
+
+   Device major number.
+
+
+.. attribute:: TarInfo.devminor
+
+   Device minor number.
+
+
+.. attribute:: TarInfo.offset
+
+   The tar header starts here.
+
+
+.. attribute:: TarInfo.offset_data
+
+   The file's data starts here.
+
+
+.. attribute:: TarInfo.sparse
+
+   Sparse member information.
+
+
 .. attribute:: TarInfo.pax_headers
:type: dict
 

___
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-111798: skip `test_super_deep()` from `test_call` under pydebug builds on WASI (GH-114010)

2024-01-12 Thread brettcannon
https://github.com/python/cpython/commit/dac1da21218a406652b35919aa2118cc32d4c65a
commit: dac1da21218a406652b35919aa2118cc32d4c65a
branch: main
author: Brett Cannon 
committer: brettcannon 
date: 2024-01-12T16:29:16-08:00
summary:

GH-111798: skip `test_super_deep()` from `test_call` under pydebug builds on 
WASI (GH-114010)

files:
A Misc/NEWS.d/next/Tests/2024-01-12-14-34-24.gh-issue-111798.hd9B_-.rst
M Lib/test/test_call.py

diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index b1c78d7136fc9b..3c8fc35e3c116d 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -1,5 +1,6 @@
 import unittest
-from test.support import cpython_only, requires_limited_api, skip_on_s390x
+from test.support import (cpython_only, is_wasi, requires_limited_api, 
Py_DEBUG,
+  set_recursion_limit, skip_on_s390x)
 try:
 import _testcapi
 except ImportError:
@@ -990,6 +991,7 @@ def case_change_over_substitution(BLuch=None, Luch = None, 
fluch = None):
 class TestRecursion(unittest.TestCase):
 
 @skip_on_s390x
[email protected](is_wasi and Py_DEBUG, "requires deep stack")
 def test_super_deep(self):
 
 def recurse(n):
@@ -1010,9 +1012,7 @@ def c_py_recurse(m):
 if m:
 _testcapi.pyobject_vectorcall(py_recurse, (1000, m), ())
 
-depth = sys.getrecursionlimit()
-sys.setrecursionlimit(100_000)
-try:
+with set_recursion_limit(100_000):
 recurse(90_000)
 with self.assertRaises(RecursionError):
 recurse(101_000)
@@ -1022,8 +1022,6 @@ def c_py_recurse(m):
 c_py_recurse(90)
 with self.assertRaises(RecursionError):
 c_py_recurse(100_000)
-finally:
-sys.setrecursionlimit(depth)
 
 
 class TestFunctionWithManyArgs(unittest.TestCase):
diff --git 
a/Misc/NEWS.d/next/Tests/2024-01-12-14-34-24.gh-issue-111798.hd9B_-.rst 
b/Misc/NEWS.d/next/Tests/2024-01-12-14-34-24.gh-issue-111798.hd9B_-.rst
new file mode 100644
index 00..8cf04b2d8561e0
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2024-01-12-14-34-24.gh-issue-111798.hd9B_-.rst
@@ -0,0 +1,2 @@
+Disable ``test_super_deep()`` from ``test_call`` under pydebug builds on
+WASI; the stack depth is too small to make the test useful.

___
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-44626, GH-105476: Fix `ntpath.isabs()` handling of part-absolute paths (#113829)

2024-01-12 Thread barneygale
https://github.com/python/cpython/commit/e4ff131e01184b68d868cfd241a03f8b7d2e0ff9
commit: e4ff131e01184b68d868cfd241a03f8b7d2e0ff9
branch: main
author: Barney Gale 
committer: barneygale 
date: 2024-01-13T07:36:05Z
summary:

GH-44626, GH-105476: Fix `ntpath.isabs()` handling of part-absolute paths 
(#113829)

On Windows, `os.path.isabs()` now returns `False` when given a path that
starts with exactly one (back)slash. This is more compatible with other
functions in `os.path`, and with Microsoft's own documentation.

Also adjust `pathlib.PureWindowsPath.is_absolute()` to call
`ntpath.isabs()`, which corrects its handling of partial UNC/device paths
like `//foo`.

Co-authored-by: Jon Foster 

files:
A Misc/NEWS.d/next/Tests/2024-01-08-21-15-48.gh-issue-44626.DRq-PR.rst
M Doc/library/os.path.rst
M Doc/whatsnew/3.13.rst
M Lib/ntpath.py
M Lib/pathlib/_abc.py
M Lib/test/test_ntpath.py
M Lib/test/test_pathlib/test_pathlib.py
M Lib/test/test_unittest/test_program.py
M Lib/test/test_zoneinfo/test_zoneinfo.py

diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
index 95933f56d50542..3cab7a260df008 100644
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -239,12 +239,16 @@ the :mod:`glob` module.)
 .. function:: isabs(path)
 
Return ``True`` if *path* is an absolute pathname.  On Unix, that means it
-   begins with a slash, on Windows that it begins with a (back)slash after 
chopping
-   off a potential drive letter.
+   begins with a slash, on Windows that it begins with two (back)slashes, or a
+   drive letter, colon, and (back)slash together.
 
.. versionchanged:: 3.6
   Accepts a :term:`path-like object`.
 
+   .. versionchanged:: 3.13
+  On Windows, returns ``False`` if the given path starts with exactly one
+  (back)slash.
+
 
 .. function:: isfile(path)
 
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index 59b9281e6d2b89..05b9b87a63252f 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -307,6 +307,13 @@ os
   :c:func:`!posix_spawn_file_actions_addclosefrom_np`.
   (Contributed by Jakub Kulik in :gh:`113117`.)
 
+os.path
+---
+
+* On Windows, :func:`os.path.isabs` no longer considers paths starting with
+  exactly one (back)slash to be absolute.
+  (Contributed by Barney Gale and Jon Foster in :gh:`44626`.)
+
 pathlib
 ---
 
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 3061a4a5ef4c56..aa0e018eb668c2 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -77,12 +77,6 @@ def normcase(s):
 return s.replace('/', '\\').lower()
 
 
-# Return whether a path is absolute.
-# Trivial in Posix, harder on Windows.
-# For Windows it is absolute if it starts with a slash or backslash (current
-# volume), or if a pathname after the volume-letter-and-colon or UNC-resource
-# starts with a slash or backslash.
-
 def isabs(s):
 """Test whether a path is absolute"""
 s = os.fspath(s)
@@ -90,16 +84,15 @@ def isabs(s):
 sep = b'\\'
 altsep = b'/'
 colon_sep = b':\\'
+double_sep = b''
 else:
 sep = '\\'
 altsep = '/'
 colon_sep = ':\\'
+double_sep = ''
 s = s[:3].replace(altsep, sep)
 # Absolute: UNC, device, and paths with a drive and root.
-# LEGACY BUG: isabs("/x") should be false since the path has no drive.
-if s.startswith(sep) or s.startswith(colon_sep, 1):
-return True
-return False
+return s.startswith(colon_sep, 1) or s.startswith(double_sep)
 
 
 # Join two (or more) paths.
diff --git a/Lib/pathlib/_abc.py b/Lib/pathlib/_abc.py
index 2fc087d13aee85..d2a31ed643979a 100644
--- a/Lib/pathlib/_abc.py
+++ b/Lib/pathlib/_abc.py
@@ -1,5 +1,4 @@
 import functools
-import ntpath
 import posixpath
 from errno import ENOENT, ENOTDIR, EBADF, ELOOP, EINVAL
 from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, 
S_ISFIFO
@@ -373,10 +372,7 @@ def parents(self):
 def is_absolute(self):
 """True if the path is absolute (has both a root and, if applicable,
 a drive)."""
-if self.pathmod is ntpath:
-# ntpath.isabs() is defective - see GH-44626.
-return bool(self.drive and self.root)
-elif self.pathmod is posixpath:
+if self.pathmod is posixpath:
 # Optimization: work with raw paths on POSIX.
 for path in self._raw_paths:
 if path.startswith('/'):
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index bf990ed36fbcae..aefcb98f1c30eb 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -227,10 +227,18 @@ def test_split(self):
 tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint/', 
''))
 
 def test_isabs(self):
+tester('ntpath.isabs("foo\\bar")', 0)
+tester('ntpath.isabs("foo/bar")', 0)
 tester('ntpath.isabs("c:\\")', 1)
+tester('ntpath.isabs("c:\\foo\\bar")', 1)
+tester('ntpath.isabs("c:/foo/bar")', 1)
 tester('ntpa