[Python-checkins] gh-114101: Correct PyErr_Format arguments in _testcapi module (#114102)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/6c502ba809ff662a5eebf8c6778dec6bd28918fb
commit: 6c502ba809ff662a5eebf8c6778dec6bd28918fb
branch: main
author: AN Long 
committer: erlend-aasland 
date: 2024-01-16T09:32:39+01:00
summary:

gh-114101: Correct PyErr_Format arguments in _testcapi module (#114102)

- use PyErr_SetString() iso. PyErr_Format() in parse_tuple_and_keywords()
- fix misspelled format specifier in CHECK_SIGNNESS() macro

files:
M Modules/_testcapi/getargs.c
M Modules/_testcapimodule.c

diff --git a/Modules/_testcapi/getargs.c b/Modules/_testcapi/getargs.c
index 33e8af7d7bbb39..0d61d8c8969f82 100644
--- a/Modules/_testcapi/getargs.c
+++ b/Modules/_testcapi/getargs.c
@@ -56,9 +56,9 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args)
 keywords[i] = PyBytes_AS_STRING(o);
 }
 else {
-PyErr_Format(PyExc_ValueError,
+PyErr_SetString(PyExc_ValueError,
 "parse_tuple_and_keywords: "
-"keywords must be str or bytes", i);
+"keywords must be str or bytes");
 goto exit;
 }
 }
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index a0b21b7efbd971..6def680190b1a6 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -112,12 +112,12 @@ test_sizeof_c_types(PyObject *self, PyObject 
*Py_UNUSED(ignored))
 return (PyObject*)NULL;  \
 }
 #define IS_SIGNED(TYPE) (((TYPE)-1) < (TYPE)0)
-#define CHECK_SIGNNESS(TYPE, SIGNED) \
-if (IS_SIGNED(TYPE) != SIGNED) { \
-PyErr_Format(get_testerror(self),\
-"%s signness is, instead of %i",  \
-#TYPE, IS_SIGNED(TYPE), SIGNED); \
-return (PyObject*)NULL;  \
+#define CHECK_SIGNNESS(TYPE, SIGNED)\
+if (IS_SIGNED(TYPE) != SIGNED) {\
+PyErr_Format(get_testerror(self),   \
+"%s signness is %i, instead of %i", \
+#TYPE, IS_SIGNED(TYPE), SIGNED);\
+return (PyObject*)NULL; \
 }
 
 /* integer types */

___
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-113655: Lower the C recursion limit on various platforms (GH-113944)

2024-01-16 Thread markshannon
https://github.com/python/cpython/commit/17b73ab99ef12f89d41acec7500a244e68b1aaa4
commit: 17b73ab99ef12f89d41acec7500a244e68b1aaa4
branch: main
author: Mark Shannon 
committer: markshannon 
date: 2024-01-16T09:32:01Z
summary:

GH-113655: Lower the C recursion limit on various platforms (GH-113944)

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-01-11-01-28-25.gh-issue-113655.Mfioxp.rst
M Include/cpython/pystate.h
M Lib/test/support/__init__.py
M Lib/test/test_ast.py
M Lib/test/test_compile.py
M Lib/test/test_functools.py
M Lib/test/test_sys_settrace.py
M Parser/asdl_c.py
M Python/Python-ast.c
M Python/ast.c
M Python/ast_opt.c
M Python/symtable.c
M Python/traceback.c

diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index ed7dd829d4b6f0..10913943c1140d 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -224,10 +224,14 @@ struct _ts {
// recursions, sometimes less. 500 is a more conservative limit.
 #  define Py_C_RECURSION_LIMIT 500
 #elif defined(__s390x__)
-#  define Py_C_RECURSION_LIMIT 1200
+#  define Py_C_RECURSION_LIMIT 800
+#elif defined(_WIN32)
+#  define Py_C_RECURSION_LIMIT 4000
+#elif defined(_Py_ADDRESS_SANITIZER)
+#  define Py_C_RECURSION_LIMIT 4000
 #else
// This value is duplicated in Lib/test/support/__init__.py
-#  define Py_C_RECURSION_LIMIT 8000
+#  define Py_C_RECURSION_LIMIT 1
 #endif
 
 
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index e5fb725a30b5b8..8344dd1849c61d 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -2377,7 +2377,10 @@ def _get_c_recursion_limit():
 return _testcapi.Py_C_RECURSION_LIMIT
 except (ImportError, AttributeError):
 # Originally taken from Include/cpython/pystate.h .
-return 8000
+if sys.platform == 'win32':
+return 4000
+else:
+return 1
 
 # The default C recursion limit.
 Py_C_RECURSION_LIMIT = _get_c_recursion_limit()
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 64fcb02309de77..3789ac22e3899c 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -1126,7 +1126,7 @@ def next(self):
 def test_ast_recursion_limit(self):
 fail_depth = support.EXCEEDS_RECURSION_LIMIT
 crash_depth = 100_000
-success_depth = 1200
+success_depth = int(support.Py_C_RECURSION_LIMIT * 0.8)
 if _testinternalcapi is not None:
 remaining = _testinternalcapi.get_c_recursion_remaining()
 success_depth = min(success_depth, remaining)
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 50629b22822245..9c36f053314f9f 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -623,12 +623,10 @@ def test_yet_more_evil_still_undecodable(self):
 @support.cpython_only
 @unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
 def test_compiler_recursion_limit(self):
-# Expected limit is Py_C_RECURSION_LIMIT * 2
-# Duplicating the limit here is a little ugly.
-# Perhaps it should be exposed somewhere...
-fail_depth = Py_C_RECURSION_LIMIT * 2 + 1
+# Expected limit is Py_C_RECURSION_LIMIT
+fail_depth = Py_C_RECURSION_LIMIT + 1
 crash_depth = Py_C_RECURSION_LIMIT * 100
-success_depth = int(Py_C_RECURSION_LIMIT * 1.8)
+success_depth = int(Py_C_RECURSION_LIMIT * 0.8)
 
 def check_limit(prefix, repeated, mode="single"):
 expect_ok = prefix + repeated * success_depth
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 0ef45d3c670e85..7c66b906d308ba 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1875,8 +1875,14 @@ def fib(n):
 return fib(n-1) + fib(n-2)
 
 if not support.Py_DEBUG:
+depth = support.Py_C_RECURSION_LIMIT*2//7
 with support.infinite_recursion():
-fib(2500)
+fib(depth)
+if self.module == c_functools:
+fib.cache_clear()
+with support.infinite_recursion():
+with self.assertRaises(RecursionError):
+fib(1)
 
 
 @py_functools.lru_cache()
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index fc5ca72236b1fb..ae6e192a7ab6ef 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -3037,10 +3037,8 @@ def test_trace_unpack_long_sequence(self):
 self.assertEqual(counts, {'call': 1, 'line': 301, 'return': 1})
 
 def test_trace_lots_of_globals(self):
-count = 1000
-if _testinternalcapi is not None:
-remaining = _testinternalcapi.get_c_recursion_remaining()
-count = min(count, remaining)
+
+count = min(1000, int(support.Py_C_RECURSION_LIMIT * 0.8))
 
 code = """if 1:
 def f():
diff --git a/Misc/NEWS.d/next/Core and 
Builtins/2024-01-11-01-28-25.gh-issue-113655

[Python-checkins] gh-113358: Fix rendering tracebacks with exceptions with a broken __getattr__ (GH-113359)

2024-01-16 Thread vsajip
https://github.com/python/cpython/commit/04fabe22dd98b4d87f672254b743fbadd5206352
commit: 04fabe22dd98b4d87f672254b743fbadd5206352
branch: main
author: Jérome Perrin 
committer: vsajip 
date: 2024-01-16T09:49:24Z
summary:

gh-113358: Fix rendering tracebacks with exceptions with a broken __getattr__ 
(GH-113359)

Co-authored-by: Irit Katriel <[email protected]>

files:
A Misc/NEWS.d/next/Library/2023-12-21-14-55-06.gh-issue-113358.nRkiSL.rst
M Lib/test/test_traceback.py
M Lib/traceback.py

diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index a6708119b81191..372fc48bf81a6a 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -2209,6 +2209,20 @@ def __repr__(self):
 err_msg = "b'please do not show me as numbers'"
 self.assertEqual(self.get_report(e), vanilla + err_msg + '\n')
 
+# an exception with a broken __getattr__ raising a non expected error
+class BrokenException(Exception):
+broken = False
+def __getattr__(self, name):
+if self.broken:
+raise ValueError(f'no {name}')
+
+e = BrokenException(123)
+vanilla = self.get_report(e)
+e.broken = True
+self.assertEqual(
+self.get_report(e),
+vanilla + "Ignored error getting __notes__: ValueError('no 
__notes__')\n")
+
 def test_exception_with_multiple_notes(self):
 for e in [ValueError(42), SyntaxError('bad syntax')]:
 with self.subTest(e=e):
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 30b42a4f693d95..d27c7a726d2bb6 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -1051,7 +1051,11 @@ def __init__(self, exc_type, exc_value, exc_traceback, 
*, limit=None,
 # Capture now to permit freeing resources: only complication is in the
 # unofficial API _format_final_exc_line
 self._str = _safe_string(exc_value, 'exception')
-self.__notes__ = getattr(exc_value, '__notes__', None)
+try:
+self.__notes__ = getattr(exc_value, '__notes__', None)
+except Exception as e:
+self.__notes__ = [
+f'Ignored error getting __notes__: {_safe_string(e, 
'__notes__', repr)}']
 
 self._is_syntax_error = False
 self._have_exc_type = exc_type is not None
diff --git 
a/Misc/NEWS.d/next/Library/2023-12-21-14-55-06.gh-issue-113358.nRkiSL.rst 
b/Misc/NEWS.d/next/Library/2023-12-21-14-55-06.gh-issue-113358.nRkiSL.rst
new file mode 100644
index 00..76416553a231a0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-12-21-14-55-06.gh-issue-113358.nRkiSL.rst
@@ -0,0 +1 @@
+Fix rendering tracebacks with exceptions with a broken __getattr__

___
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-113238: add Anchor to importlib.resources (#113801)

2024-01-16 Thread FFY00
https://github.com/python/cpython/commit/c85c0026a64c2a902138feeb73a9c66af1af31e0
commit: c85c0026a64c2a902138feeb73a9c66af1af31e0
branch: main
author: Mike Zimin <[email protected]>
committer: FFY00 
date: 2024-01-16T10:55:59Z
summary:

gh-113238: add Anchor to importlib.resources (#113801)

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

files:
A Misc/NEWS.d/next/Library/2024-01-07-23-31-44.gh-issue-113238.wFWBfW.rst
M Lib/importlib/resources/__init__.py

diff --git a/Lib/importlib/resources/__init__.py 
b/Lib/importlib/resources/__init__.py
index e6b60c18caa052..ae83cd07c4d4fb 100644
--- a/Lib/importlib/resources/__init__.py
+++ b/Lib/importlib/resources/__init__.py
@@ -4,6 +4,7 @@
 as_file,
 files,
 Package,
+Anchor,
 )
 
 from .abc import ResourceReader
@@ -11,6 +12,7 @@
 
 __all__ = [
 'Package',
+'Anchor',
 'ResourceReader',
 'as_file',
 'files',
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-07-23-31-44.gh-issue-113238.wFWBfW.rst 
b/Misc/NEWS.d/next/Library/2024-01-07-23-31-44.gh-issue-113238.wFWBfW.rst
new file mode 100644
index 00..51b4d144a94e6d
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-07-23-31-44.gh-issue-113238.wFWBfW.rst
@@ -0,0 +1 @@
+Add ``Anchor`` to ``importlib.resources`` (in order for the code to comply 
with the documentation)

___
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-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB (GH-114079)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/d4dfad2aa9e76038302b0c5a29ebacc2723ed50d
commit: d4dfad2aa9e76038302b0c5a29ebacc2723ed50d
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-01-16T11:31:34Z
summary:

gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB 
(GH-114079)

files:
A Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
M Lib/socket.py

diff --git a/Lib/socket.py b/Lib/socket.py
index 5f0a1f40e25b94..77986fc2e48099 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -382,7 +382,7 @@ def _sendfile_use_sendfile(self, file, offset=0, 
count=None):
 if timeout and not selector_select(timeout):
 raise TimeoutError('timed out')
 if count:
-blocksize = count - total_sent
+blocksize = min(count - total_sent, blocksize)
 if blocksize <= 0:
 break
 try:
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst 
b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
new file mode 100644
index 00..dba086f3a8a484
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
@@ -0,0 +1,2 @@
+Fix possible :exc:`OverflowError` in :meth:`socket.socket.sendfile` when pass
+*count* larger than 2 GiB on 32-bit platform.

___
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-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB (GH-114079) (GH-114110)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/045adb1ad893ce350ac40e180da44523d03361a0
commit: 045adb1ad893ce350ac40e180da44523d03361a0
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-16T13:53:02+02:00
summary:

[3.12] gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB 
(GH-114079) (GH-114110)

(cherry picked from commit d4dfad2aa9e76038302b0c5a29ebacc2723ed50d)

Co-authored-by: Serhiy Storchaka 

files:
A Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
M Lib/socket.py

diff --git a/Lib/socket.py b/Lib/socket.py
index 321fcda51505c1..42ee1307732644 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -382,7 +382,7 @@ def _sendfile_use_sendfile(self, file, offset=0, 
count=None):
 if timeout and not selector_select(timeout):
 raise TimeoutError('timed out')
 if count:
-blocksize = count - total_sent
+blocksize = min(count - total_sent, blocksize)
 if blocksize <= 0:
 break
 try:
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst 
b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
new file mode 100644
index 00..dba086f3a8a484
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
@@ -0,0 +1,2 @@
+Fix possible :exc:`OverflowError` in :meth:`socket.socket.sendfile` when pass
+*count* larger than 2 GiB on 32-bit platform.

___
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-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB (GH-114079) (GH-114111)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/0e922658755a6e62995661f03aca86cda13ba03e
commit: 0e922658755a6e62995661f03aca86cda13ba03e
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-16T13:53:26+02:00
summary:

[3.11] gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB 
(GH-114079) (GH-114111)

(cherry picked from commit d4dfad2aa9e76038302b0c5a29ebacc2723ed50d)

Co-authored-by: Serhiy Storchaka 

files:
A Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
M Lib/socket.py

diff --git a/Lib/socket.py b/Lib/socket.py
index b5d46eb32bda3b..a0567b76bcfe2b 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -381,7 +381,7 @@ def _sendfile_use_sendfile(self, file, offset=0, 
count=None):
 if timeout and not selector_select(timeout):
 raise TimeoutError('timed out')
 if count:
-blocksize = count - total_sent
+blocksize = min(count - total_sent, blocksize)
 if blocksize <= 0:
 break
 try:
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst 
b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
new file mode 100644
index 00..dba086f3a8a484
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
@@ -0,0 +1,2 @@
+Fix possible :exc:`OverflowError` in :meth:`socket.socket.sendfile` when pass
+*count* larger than 2 GiB on 32-bit platform.

___
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: Align multiprocessing.shared_memory docs with Sphinx recommendations (#114103)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/af852740862169cf3e8789a13b86a7b1d03b91db
commit: af852740862169cf3e8789a13b86a7b1d03b91db
branch: main
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-16T12:35:35Z
summary:

Docs: Align multiprocessing.shared_memory docs with Sphinx recommendations 
(#114103)

- add :class: and :mod: markups where needed
- fix incorrect escaping of a star in ShareableList arg spec
- mark up parameters with stars: *val*
- mark up list of built-in types using list markup
- remove unneeded parentheses from :meth: markups

files:
M Doc/library/multiprocessing.shared_memory.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/multiprocessing.shared_memory.rst 
b/Doc/library/multiprocessing.shared_memory.rst
index 671130d9b29fc0..9b5c1c32a91f55 100644
--- a/Doc/library/multiprocessing.shared_memory.rst
+++ b/Doc/library/multiprocessing.shared_memory.rst
@@ -20,8 +20,8 @@ and management of shared memory to be accessed by one or more 
processes
 on a multicore or symmetric multiprocessor (SMP) machine.  To assist with
 the life-cycle management of shared memory especially across distinct
 processes, a :class:`~multiprocessing.managers.BaseManager` subclass,
-:class:`SharedMemoryManager`, is also provided in the
-``multiprocessing.managers`` module.
+:class:`~multiprocessing.managers.SharedMemoryManager`, is also provided in the
+:mod:`multiprocessing.managers` module.
 
 In this module, shared memory refers to "System V style" shared memory blocks
 (though is not necessarily implemented explicitly as such) and does not refer
@@ -47,9 +47,9 @@ copying of data.
As a resource for sharing data across processes, shared memory blocks
may outlive the original process that created them.  When one process
no longer needs access to a shared memory block that might still be
-   needed by other processes, the :meth:`close()` method should be called.
+   needed by other processes, the :meth:`close` method should be called.
When a shared memory block is no longer needed by any process, the
-   :meth:`unlink()` method should be called to ensure proper cleanup.
+   :meth:`unlink` method should be called to ensure proper cleanup.
 
*name* is the unique name for the requested shared memory, specified as
a string.  When creating a new shared memory block, if ``None`` (the
@@ -62,7 +62,7 @@ copying of data.
memory block.  Because some platforms choose to allocate chunks of memory
based upon that platform's memory page size, the exact size of the shared
memory block may be larger or equal to the size requested.  When attaching
-   to an existing shared memory block, the ``size`` parameter is ignored.
+   to an existing shared memory block, the *size* parameter is ignored.
 
*track*, when enabled, registers the shared memory block with a resource
tracker process on platforms where the OS does not do this automatically.
@@ -86,19 +86,19 @@ copying of data.
.. method:: close()
 
   Closes the file descriptor/handle to the shared memory from this
-  instance.  :meth:`close()` should be called once access to the shared
+  instance.  :meth:`close` should be called once access to the shared
   memory block from this instance is no longer needed.  Depending
   on operating system, the underlying memory may or may not be freed
   even if all handles to it have been closed.  To ensure proper cleanup,
-  use the :meth:`unlink()` method.
+  use the :meth:`unlink` method.
 
.. method:: unlink()
 
   Deletes the underlying shared memory block.  This should be called only
   once per shared memory block regardless of the number of handles to it,
   even in other processes.
-  :meth:`unlink()` and :meth:`close()` can be called in any order, but
-  trying to access data inside a shared memory block after :meth:`unlink()`
+  :meth:`unlink` and :meth:`close` can be called in any order, but
+  trying to access data inside a shared memory block after :meth:`unlink`
   may result in memory access errors, depending on platform.
 
   This method has no effect on Windows, where the only way to delete a
@@ -145,7 +145,7 @@ instances::
 
 The following example demonstrates a practical use of the :class:`SharedMemory`
 class with `NumPy arrays `_, accessing the
-same ``numpy.ndarray`` from two distinct Python shells:
+same :class:`!numpy.ndarray` from two distinct Python shells:
 
 .. doctest::
:options: +SKIP
@@ -197,43 +197,43 @@ same ``numpy.ndarray`` from two distinct Python shells:
 .. class:: SharedMemoryManager([address[, authkey]])
:module: multiprocessing.managers
 
-   A subclass of :class:`~multiprocessing.managers.BaseManager` which can be
+   A subclass of :class:`multiprocessing.managers.BaseManager` which can be
used for the management of shared memory blocks across processes.
 
A call to :meth:`~multiprocessing.managers.BaseManager.start` on a
-   :c

[Python-checkins] [3.12] Docs: Align multiprocessing.shared_memory docs with Sphinx recommendations (#114103) (#114112)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/4888db15fe89143740a044267c404b93eb4508eb
commit: 4888db15fe89143740a044267c404b93eb4508eb
branch: 3.12
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-16T12:56:07Z
summary:

[3.12] Docs: Align multiprocessing.shared_memory docs with Sphinx 
recommendations (#114103) (#114112)

(cherry picked from commit af852740862169cf3e8789a13b86a7b1d03b91db)

- add :class: and :mod: markups where needed
- fix incorrect escaping of a star in ShareableList arg spec
- mark up parameters with stars: *val*
- mark up list of built-in types using list markup
- remove unneeded parentheses from :meth: markups

files:
M Doc/library/multiprocessing.shared_memory.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/multiprocessing.shared_memory.rst 
b/Doc/library/multiprocessing.shared_memory.rst
index f453e6403d932d..1771b1589f1cee 100644
--- a/Doc/library/multiprocessing.shared_memory.rst
+++ b/Doc/library/multiprocessing.shared_memory.rst
@@ -20,8 +20,8 @@ and management of shared memory to be accessed by one or more 
processes
 on a multicore or symmetric multiprocessor (SMP) machine.  To assist with
 the life-cycle management of shared memory especially across distinct
 processes, a :class:`~multiprocessing.managers.BaseManager` subclass,
-:class:`SharedMemoryManager`, is also provided in the
-``multiprocessing.managers`` module.
+:class:`~multiprocessing.managers.SharedMemoryManager`, is also provided in the
+:mod:`multiprocessing.managers` module.
 
 In this module, shared memory refers to "System V style" shared memory blocks
 (though is not necessarily implemented explicitly as such) and does not refer
@@ -47,9 +47,9 @@ copying of data.
As a resource for sharing data across processes, shared memory blocks
may outlive the original process that created them.  When one process
no longer needs access to a shared memory block that might still be
-   needed by other processes, the :meth:`close()` method should be called.
+   needed by other processes, the :meth:`close` method should be called.
When a shared memory block is no longer needed by any process, the
-   :meth:`unlink()` method should be called to ensure proper cleanup.
+   :meth:`unlink` method should be called to ensure proper cleanup.
 
*name* is the unique name for the requested shared memory, specified as
a string.  When creating a new shared memory block, if ``None`` (the
@@ -62,28 +62,28 @@ copying of data.
memory block.  Because some platforms choose to allocate chunks of memory
based upon that platform's memory page size, the exact size of the shared
memory block may be larger or equal to the size requested.  When attaching
-   to an existing shared memory block, the ``size`` parameter is ignored.
+   to an existing shared memory block, the *size* parameter is ignored.
 
.. method:: close()
 
   Closes access to the shared memory from this instance.  In order to
   ensure proper cleanup of resources, all instances should call
-  ``close()`` once the instance is no longer needed.  Note that calling
-  ``close()`` does not cause the shared memory block itself to be
+  :meth:`close` once the instance is no longer needed.  Note that calling
+  :meth:`!close` does not cause the shared memory block itself to be
   destroyed.
 
.. method:: unlink()
 
   Requests that the underlying shared memory block be destroyed.  In
-  order to ensure proper cleanup of resources, ``unlink()`` should be
+  order to ensure proper cleanup of resources, :meth:`unlink` should be
   called once (and only once) across all processes which have need
   for the shared memory block.  After requesting its destruction, a
   shared memory block may or may not be immediately destroyed and
   this behavior may differ across platforms.  Attempts to access data
-  inside the shared memory block after ``unlink()`` has been called may
+  inside the shared memory block after :meth:`!unlink` has been called may
   result in memory access errors.  Note: the last process relinquishing
-  its hold on a shared memory block may call ``unlink()`` and
-  :meth:`close()` in either order.
+  its hold on a shared memory block may call :meth:`!unlink` and
+  :meth:`close` in either order.
 
.. attribute:: buf
 
@@ -126,7 +126,7 @@ instances::
 
 The following example demonstrates a practical use of the :class:`SharedMemory`
 class with `NumPy arrays `_, accessing the
-same ``numpy.ndarray`` from two distinct Python shells:
+same :class:`!numpy.ndarray` from two distinct Python shells:
 
 .. doctest::
:options: +SKIP
@@ -178,43 +178,43 @@ same ``numpy.ndarray`` from two distinct Python shells:
 .. class:: SharedMemoryManager([address[, authkey]])
:module: multiprocessing.managers
 
-   A subclass of :class:`~multiprocessing.managers.BaseManager` which can be
+   A subclass of :class:`multiprocessin

[Python-checkins] [3.11] Docs: Align multiprocessing.shared_memory docs with Sphinx recommendations (#114103) (#114114)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/e5ae15f0fe647d6c4fb89c418e759f9ff6efa86d
commit: e5ae15f0fe647d6c4fb89c418e759f9ff6efa86d
branch: 3.11
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-16T13:08:01Z
summary:

[3.11] Docs: Align multiprocessing.shared_memory docs with Sphinx 
recommendations (#114103) (#114114)

(cherry picked from commit af852740862169cf3e8789a13b86a7b1d03b91db)

- add :class: and :mod: markups where needed
- fix incorrect escaping of a star in ShareableList arg spec
- mark up parameters with stars: *val*
- mark up list of built-in types using list markup
- remove unneeded parentheses from :meth: markups

files:
M Doc/library/multiprocessing.shared_memory.rst
M Doc/tools/.nitignore

diff --git a/Doc/library/multiprocessing.shared_memory.rst 
b/Doc/library/multiprocessing.shared_memory.rst
index f453e6403d932d..1771b1589f1cee 100644
--- a/Doc/library/multiprocessing.shared_memory.rst
+++ b/Doc/library/multiprocessing.shared_memory.rst
@@ -20,8 +20,8 @@ and management of shared memory to be accessed by one or more 
processes
 on a multicore or symmetric multiprocessor (SMP) machine.  To assist with
 the life-cycle management of shared memory especially across distinct
 processes, a :class:`~multiprocessing.managers.BaseManager` subclass,
-:class:`SharedMemoryManager`, is also provided in the
-``multiprocessing.managers`` module.
+:class:`~multiprocessing.managers.SharedMemoryManager`, is also provided in the
+:mod:`multiprocessing.managers` module.
 
 In this module, shared memory refers to "System V style" shared memory blocks
 (though is not necessarily implemented explicitly as such) and does not refer
@@ -47,9 +47,9 @@ copying of data.
As a resource for sharing data across processes, shared memory blocks
may outlive the original process that created them.  When one process
no longer needs access to a shared memory block that might still be
-   needed by other processes, the :meth:`close()` method should be called.
+   needed by other processes, the :meth:`close` method should be called.
When a shared memory block is no longer needed by any process, the
-   :meth:`unlink()` method should be called to ensure proper cleanup.
+   :meth:`unlink` method should be called to ensure proper cleanup.
 
*name* is the unique name for the requested shared memory, specified as
a string.  When creating a new shared memory block, if ``None`` (the
@@ -62,28 +62,28 @@ copying of data.
memory block.  Because some platforms choose to allocate chunks of memory
based upon that platform's memory page size, the exact size of the shared
memory block may be larger or equal to the size requested.  When attaching
-   to an existing shared memory block, the ``size`` parameter is ignored.
+   to an existing shared memory block, the *size* parameter is ignored.
 
.. method:: close()
 
   Closes access to the shared memory from this instance.  In order to
   ensure proper cleanup of resources, all instances should call
-  ``close()`` once the instance is no longer needed.  Note that calling
-  ``close()`` does not cause the shared memory block itself to be
+  :meth:`close` once the instance is no longer needed.  Note that calling
+  :meth:`!close` does not cause the shared memory block itself to be
   destroyed.
 
.. method:: unlink()
 
   Requests that the underlying shared memory block be destroyed.  In
-  order to ensure proper cleanup of resources, ``unlink()`` should be
+  order to ensure proper cleanup of resources, :meth:`unlink` should be
   called once (and only once) across all processes which have need
   for the shared memory block.  After requesting its destruction, a
   shared memory block may or may not be immediately destroyed and
   this behavior may differ across platforms.  Attempts to access data
-  inside the shared memory block after ``unlink()`` has been called may
+  inside the shared memory block after :meth:`!unlink` has been called may
   result in memory access errors.  Note: the last process relinquishing
-  its hold on a shared memory block may call ``unlink()`` and
-  :meth:`close()` in either order.
+  its hold on a shared memory block may call :meth:`!unlink` and
+  :meth:`close` in either order.
 
.. attribute:: buf
 
@@ -126,7 +126,7 @@ instances::
 
 The following example demonstrates a practical use of the :class:`SharedMemory`
 class with `NumPy arrays `_, accessing the
-same ``numpy.ndarray`` from two distinct Python shells:
+same :class:`!numpy.ndarray` from two distinct Python shells:
 
 .. doctest::
:options: +SKIP
@@ -178,43 +178,43 @@ same ``numpy.ndarray`` from two distinct Python shells:
 .. class:: SharedMemoryManager([address[, authkey]])
:module: multiprocessing.managers
 
-   A subclass of :class:`~multiprocessing.managers.BaseManager` which can be
+   A subclass of :class:`multiprocessin

[Python-checkins] gh-113858: GH Actions: Limit max ccache size for the asan build (GH-114113)

2024-01-16 Thread encukou
https://github.com/python/cpython/commit/ac44ec6206a1e5479effd91e02e2946b94e98ede
commit: ac44ec6206a1e5479effd91e02e2946b94e98ede
branch: main
author: Petr Viktorin 
committer: encukou 
date: 2024-01-16T14:21:16+01:00
summary:

gh-113858: GH Actions: Limit max ccache size for the asan build (GH-114113)

files:
M .github/workflows/build.yml

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 957882619f3552..cc5ecc09fbc592 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -454,6 +454,7 @@ jobs:
   uses: hendrikmuhs/[email protected]
   with:
 save: ${{ github.event_name == 'push' }}
+max-size: "200M"
 - name: Configure CPython
   run: ./configure --config-cache --with-address-sanitizer 
--without-pymalloc
 - name: Build CPython

___
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-114107: Fix importlib.resources symlink test if symlinks aren't supported (#114108)

2024-01-16 Thread Yhg1s
https://github.com/python/cpython/commit/c361a1f395de9e508b6e1b0a4c5e69204905a7b7
commit: c361a1f395de9e508b6e1b0a4c5e69204905a7b7
branch: main
author: Petr Viktorin 
committer: Yhg1s 
date: 2024-01-16T16:10:03+01:00
summary:

gh-114107: Fix importlib.resources symlink test if symlinks aren't supported 
(#114108)

gh-114107: Fix symlink test if symlinks aren't supported

files:
M Lib/test/test_importlib/test_main.py

diff --git a/Lib/test/test_importlib/test_main.py 
b/Lib/test/test_importlib/test_main.py
index 1d3817151edf64..0a769b89841234 100644
--- a/Lib/test/test_importlib/test_main.py
+++ b/Lib/test/test_importlib/test_main.py
@@ -4,6 +4,7 @@
 import warnings
 import importlib.metadata
 import contextlib
+from test.support import os_helper
 
 try:
 import pyfakefs.fake_filesystem_unittest as ffs
@@ -403,6 +404,7 @@ def test_packages_distributions_all_module_types(self):
 
 assert not any(name.endswith('.dist-info') for name in distributions)
 
+@os_helper.skip_unless_symlink
 def test_packages_distributions_symlinked_top_level(self) -> None:
 """
 Distribution is resolvable from a simple top-level symlink in RECORD.

___
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-102468: Document `PyCFunction_New*` and `PyCMethod_New` (GH-112557)

2024-01-16 Thread encukou
https://github.com/python/cpython/commit/a482bc67ee786e60937a547776fcf9528810e1ce
commit: a482bc67ee786e60937a547776fcf9528810e1ce
branch: main
author: AN Long 
committer: encukou 
date: 2024-01-16T16:17:03+01:00
summary:

gh-102468: Document `PyCFunction_New*` and `PyCMethod_New` (GH-112557)

Co-authored-by: Erlend E. Aasland 

files:
M Doc/c-api/structures.rst
M Doc/data/refcounts.dat

diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst
index 7d82f7839dfcd7..86c779472fd244 100644
--- a/Doc/c-api/structures.rst
+++ b/Doc/c-api/structures.rst
@@ -399,6 +399,40 @@ definition with the same method name.
slot.  This is helpful because calls to PyCFunctions are optimized more
than wrapper object calls.
 
+.. c:function:: PyObject * PyCMethod_New(PyMethodDef *ml, PyObject *self, 
PyObject *module, PyTypeObject *cls)
+
+   Turn *ml* into a Python :term:`callable` object.
+   The caller must ensure that *ml* outlives the :term:`callable`.
+   Typically, *ml* is defined as a static variable.
+
+   The *self* parameter will be passed as the *self* argument
+   to the C function in ``ml->ml_meth`` when invoked.
+   *self* can be ``NULL``.
+
+   The :term:`callable` object's ``__module__`` attribute
+   can be set from the given *module* argument.
+   *module* should be a Python string,
+   which will be used as name of the module the function is defined in.
+   If unavailable, it can be set to :const:`None` or ``NULL``.
+
+   .. seealso:: :attr:`function.__module__`
+
+   The *cls* parameter will be passed as the *defining_class*
+   argument to the C function.
+   Must be set if :c:macro:`METH_METHOD` is set on ``ml->ml_flags``.
+
+   .. versionadded:: 3.9
+
+
+.. c:function:: PyObject * PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, 
PyObject *module)
+
+   Equivalent to ``PyCMethod_New(ml, self, module, NULL)``.
+
+
+.. c:function:: PyObject * PyCFunction_New(PyMethodDef *ml, PyObject *self)
+
+   Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``.
+
 
 Accessing attributes of extension types
 ---
diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat
index 0b48512083ced4..f719ce153b239a 100644
--- a/Doc/data/refcounts.dat
+++ b/Doc/data/refcounts.dat
@@ -402,6 +402,21 @@ PyContextVar_Reset:int:::
 PyContextVar_Reset:PyObject*:var:0:
 PyContextVar_Reset:PyObject*:token:-1:
 
+PyCFunction_New:PyObject*::+1:
+PyCFunction_New:PyMethodDef*:ml::
+PyCFunction_New:PyObject*:self:+1:
+
+PyCFunction_NewEx:PyObject*::+1:
+PyCFunction_NewEx:PyMethodDef*:ml::
+PyCFunction_NewEx:PyObject*:self:+1:
+PyCFunction_NewEx:PyObject*:module:+1:
+
+PyCMethod_New:PyObject*::+1:
+PyCMethod_New:PyMethodDef*:ml::
+PyCMethod_New:PyObject*:self:+1:
+PyCMethod_New:PyObject*:module:+1:
+PyCMethod_New:PyObject*:cls:+1:
+
 PyDate_Check:int:::
 PyDate_Check:PyObject*:ob:0:
 

___
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-113858: GH Actions: Make ccache smaller (GH-113859, GH-113945) (GH-114082)

2024-01-16 Thread encukou
https://github.com/python/cpython/commit/74485c0323f91b32877e71c233570d89bc63fbd5
commit: 74485c0323f91b32877e71c233570d89bc63fbd5
branch: 3.12
author: Petr Viktorin 
committer: encukou 
date: 2024-01-16T16:28:27+01:00
summary:

[3.12] gh-113858: GH Actions: Make ccache smaller (GH-113859, GH-113945) 
(GH-114082)

This backports 3 PRs:

- https://github.com/python/cpython/pull/113859

  Only save ccache on pushes

- https://github.com/python/cpython/pull/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

- https://github.com/python/cpython/pull/114113

  Fixup for the above

Co-authored-by: Hugo van Kemenade 

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 545dd8c15dcf13..6530a90541bd48 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -169,6 +169,8 @@ jobs:
 run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
   - name: Configure ccache action
 uses: hendrikmuhs/[email protected]
+with:
+  save: false
   - name: Check Autoconf and aclocal versions
 run: |
   grep "Generated by GNU Autoconf 2.71" configure
@@ -283,6 +285,8 @@ jobs:
 echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
 - name: Configure ccache action
   uses: hendrikmuhs/[email protected]
+  with:
+save: false
 - name: Configure CPython
   run: ./configure --config-cache --with-pydebug 
--with-openssl=$OPENSSL_DIR
 - name: Build CPython
@@ -326,6 +330,8 @@ jobs:
 echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
 - name: Configure ccache action
   uses: hendrikmuhs/[email protected]
+  with:
+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
@@ -445,6 +451,9 @@ jobs:
 echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
 - name: Configure ccache action
   uses: hendrikmuhs/[email protected]
+  with:
+save: ${{ github.event_name == 'push' }}
+max-size: "200M"
 - name: Configure CPython
   run: ./configure --config-cache --with-address-sanitizer 
--without-pymalloc
 - name: Build CPython
diff --git a/.github/workflows/reusable-ubuntu.yml 
b/.github/workflows/reusable-ubuntu.yml
index 56268c8bfd3419..db4ca4d4667399 100644
--- a/.github/workflows/reusable-ubuntu.yml
+++ b/.github/workflows/reusable-ubuntu.yml
@@ -41,6 +41,9 @@ jobs:
 echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
 - name: Configure ccache action
   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-113626: Add allow_code parameter in marshal functions (GH-113648)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/d2d8332f71ae8059150a9d8d91498493f9b443fc
commit: d2d8332f71ae8059150a9d8d91498493f9b443fc
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-01-16T18:05:15+02:00
summary:

gh-113626: Add allow_code parameter in marshal functions (GH-113648)

Passing allow_code=False prevents serialization and de-serialization of
code objects which is incompatible between Python versions.

files:
A Misc/NEWS.d/next/Library/2024-01-02-12-41-59.gh-issue-113626.i1PPY_.rst
M Doc/library/marshal.rst
M Doc/whatsnew/3.13.rst
M Include/internal/pycore_global_objects_fini_generated.h
M Include/internal/pycore_global_strings.h
M Include/internal/pycore_runtime_init_generated.h
M Include/internal/pycore_unicodeobject_generated.h
M Lib/test/test_marshal.py
M Python/clinic/marshal.c.h
M Python/marshal.c

diff --git a/Doc/library/marshal.rst b/Doc/library/marshal.rst
index 0556f19699dc15..c6a006b7b4028a 100644
--- a/Doc/library/marshal.rst
+++ b/Doc/library/marshal.rst
@@ -23,7 +23,11 @@ transfer of Python objects through RPC calls, see the 
modules :mod:`pickle` and
 :mod:`shelve`.  The :mod:`marshal` module exists mainly to support reading and
 writing the "pseudo-compiled" code for Python modules of :file:`.pyc` files.
 Therefore, the Python maintainers reserve the right to modify the marshal 
format
-in backward incompatible ways should the need arise.  If you're serializing and
+in backward incompatible ways should the need arise.
+The format of code objects is not compatible between Python versions,
+even if the version of the format is the same.
+De-serializing a code object in the incorrect Python version has undefined 
behavior.
+If you're serializing and
 de-serializing Python objects, use the :mod:`pickle` module instead -- the
 performance is comparable, version independence is guaranteed, and pickle
 supports a substantially wider range of objects than marshal.
@@ -40,7 +44,8 @@ Not all Python object types are supported; in general, only 
objects whose value
 is independent from a particular invocation of Python can be written and read 
by
 this module.  The following types are supported: booleans, integers, floating
 point numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, 
sets,
-frozensets, dictionaries, and code objects, where it should be understood that
+frozensets, dictionaries, and code objects (if *allow_code* is true),
+where it should be understood that
 tuples, lists, sets, frozensets and dictionaries are only supported as long as
 the values contained therein are themselves supported.  The
 singletons :const:`None`, :const:`Ellipsis` and :exc:`StopIteration` can also 
be
@@ -54,7 +59,7 @@ bytes-like objects.
 The module defines these functions:
 
 
-.. function:: dump(value, file[, version])
+.. function:: dump(value, file, version=version, /, *, allow_code=True)
 
Write the value on the open file.  The value must be a supported type.  The
file must be a writeable :term:`binary file`.
@@ -62,19 +67,24 @@ The module defines these functions:
If the value has (or contains an object that has) an unsupported type, a
:exc:`ValueError` exception is raised --- but garbage data will also be 
written
to the file.  The object will not be properly read back by :func:`load`.
+   :ref:`Code objects ` are only supported if *allow_code* is 
true.
 
The *version* argument indicates the data format that ``dump`` should use
(see below).
 
.. audit-event:: marshal.dumps value,version marshal.dump
 
+   .. versionchanged:: 3.13
+  Added the *allow_code* parameter.
 
-.. function:: load(file)
+
+.. function:: load(file, /, *, allow_code=True)
 
Read one value from the open file and return it.  If no valid value is read
(e.g. because the data has a different Python version's incompatible marshal
-   format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`.  The
-   file must be a readable :term:`binary file`.
+   format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`.
+   :ref:`Code objects ` are only supported if *allow_code* is 
true.
+   The file must be a readable :term:`binary file`.
 
.. audit-event:: marshal.load "" marshal.load
 
@@ -88,24 +98,32 @@ The module defines these functions:
   This call used to raise a ``code.__new__`` audit event for each code 
object. Now
   it raises a single ``marshal.load`` event for the entire load operation.
 
+   .. versionchanged:: 3.13
+  Added the *allow_code* parameter.
+
 
-.. function:: dumps(value[, version])
+.. function:: dumps(value, version=version, /, *, allow_code=True)
 
Return the bytes object that would be written to a file by ``dump(value, 
file)``.  The
value must be a supported type.  Raise a :exc:`ValueError` exception if 
value
has (or contains an object that has) an unsupported type.
+   :ref:`Code objects ` are only supported if *allow_code* is 
true.
 
The *version* argument indic

[Python-checkins] gh-111968: Use per-thread freelists for PyContext in free-threading (gh-114122)

2024-01-16 Thread corona10
https://github.com/python/cpython/commit/867f59f234a4135901070a386d55327e44ee1b7a
commit: 867f59f234a4135901070a386d55327e44ee1b7a
branch: main
author: Donghee Na 
committer: corona10 
date: 2024-01-16T16:14:56Z
summary:

gh-111968: Use per-thread freelists for PyContext in free-threading (gh-114122)

files:
M Include/internal/pycore_context.h
M Include/internal/pycore_freelist.h
M Include/internal/pycore_gc.h
M Include/internal/pycore_interp.h
M Python/context.c
M Python/gc_free_threading.c
M Python/gc_gil.c
M Python/pylifecycle.c
M Python/pystate.c

diff --git a/Include/internal/pycore_context.h 
b/Include/internal/pycore_context.h
index ec884e9e0f55a9..3284efba2b6f4c 100644
--- a/Include/internal/pycore_context.h
+++ b/Include/internal/pycore_context.h
@@ -5,6 +5,7 @@
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+#include "pycore_freelist.h"  // _PyFreeListState
 #include "pycore_hamt.h"  // PyHamtObject
 
 
@@ -13,7 +14,7 @@ extern PyTypeObject _PyContextTokenMissing_Type;
 /* runtime lifecycle */
 
 PyStatus _PyContext_Init(PyInterpreterState *);
-void _PyContext_Fini(PyInterpreterState *);
+void _PyContext_Fini(_PyFreeListState *);
 
 
 /* other API */
@@ -22,23 +23,6 @@ typedef struct {
 PyObject_HEAD
 } _PyContextTokenMissing;
 
-#ifndef WITH_FREELISTS
-// without freelists
-#  define PyContext_MAXFREELIST 0
-#endif
-
-#ifndef PyContext_MAXFREELIST
-#  define PyContext_MAXFREELIST 255
-#endif
-
-struct _Py_context_state {
-#if PyContext_MAXFREELIST > 0
-// List of free PyContext objects
-PyContext *freelist;
-int numfree;
-#endif
-};
-
 struct _pycontextobject {
 PyObject_HEAD
 PyContext *ctx_prev;
diff --git a/Include/internal/pycore_freelist.h 
b/Include/internal/pycore_freelist.h
index faa0c11a49e798..566d47dbea11af 100644
--- a/Include/internal/pycore_freelist.h
+++ b/Include/internal/pycore_freelist.h
@@ -18,11 +18,13 @@ extern "C" {
 #  define PyTuple_MAXFREELIST 2000
 #  define PyList_MAXFREELIST 80
 #  define PyFloat_MAXFREELIST 100
+#  define PyContext_MAXFREELIST 255
 #else
 #  define PyTuple_NFREELISTS 0
 #  define PyTuple_MAXFREELIST 0
 #  define PyList_MAXFREELIST 0
 #  define PyFloat_MAXFREELIST 0
+#  define PyContext_MAXFREELIST 0
 #endif
 
 struct _Py_list_state {
@@ -67,11 +69,20 @@ struct _Py_slice_state {
 #endif
 };
 
+struct _Py_context_state {
+#ifdef WITH_FREELISTS
+// List of free PyContext objects
+PyContext *freelist;
+int numfree;
+#endif
+};
+
 typedef struct _Py_freelist_state {
 struct _Py_float_state float_state;
 struct _Py_tuple_state tuple_state;
 struct _Py_list_state list_state;
 struct _Py_slice_state slice_state;
+struct _Py_context_state context_state;
 } _PyFreeListState;
 
 #ifdef __cplusplus
diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h
index f8e86a22d0fa58..52e8b39ed0485d 100644
--- a/Include/internal/pycore_gc.h
+++ b/Include/internal/pycore_gc.h
@@ -252,7 +252,7 @@ extern void _PyList_ClearFreeList(_PyFreeListState *state, 
int is_finalization);
 extern void _PySlice_ClearCache(_PyFreeListState *state);
 extern void _PyDict_ClearFreeList(PyInterpreterState *interp);
 extern void _PyAsyncGen_ClearFreeLists(PyInterpreterState *interp);
-extern void _PyContext_ClearFreeList(PyInterpreterState *interp);
+extern void _PyContext_ClearFreeList(_PyFreeListState *state, int 
is_finalization);
 extern void _Py_ScheduleGC(PyInterpreterState *interp);
 extern void _Py_RunGC(PyThreadState *tstate);
 
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 134a882695bbd7..7ec963005aba7e 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -191,7 +191,6 @@ struct _is {
 struct _Py_tuple_state tuple;
 struct _Py_dict_state dict_state;
 struct _Py_async_gen_state async_gen;
-struct _Py_context_state context;
 struct _Py_exc_state exc_state;
 
 struct ast_state ast;
diff --git a/Python/context.c b/Python/context.c
index c94c014219d0e4..1e90811c374ec6 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -64,12 +64,12 @@ static int
 contextvar_del(PyContextVar *var);
 
 
-#if PyContext_MAXFREELIST > 0
+#ifdef WITH_FREELISTS
 static struct _Py_context_state *
 get_context_state(void)
 {
-PyInterpreterState *interp = _PyInterpreterState_GET();
-return &interp->context;
+_PyFreeListState *state = _PyFreeListState_GET();
+return &state->context_state;
 }
 #endif
 
@@ -340,13 +340,9 @@ static inline PyContext *
 _context_alloc(void)
 {
 PyContext *ctx;
-#if PyContext_MAXFREELIST > 0
+#ifdef WITH_FREELISTS
 struct _Py_context_state *state = get_context_state();
-#ifdef Py_DEBUG
-// _context_alloc() must not be called after _PyContext_Fini()
-assert(state->numfree != -1);
-#endif
-if (state->numfree) {
+if (state->numfree > 0) {
 state->numfree--;
 ctx = state->freelist;
 state->freelist = (PyContext *)ctx->ctx_wea

[Python-checkins] gh-114107: test.pythoninfo logs Windows Developer Mode (#114121)

2024-01-16 Thread vstinner
https://github.com/python/cpython/commit/c77f552ec02040dfe14a0a3cb743d96eedffadec
commit: c77f552ec02040dfe14a0a3cb743d96eedffadec
branch: main
author: Victor Stinner 
committer: vstinner 
date: 2024-01-16T17:23:46+01:00
summary:

gh-114107: test.pythoninfo logs Windows Developer Mode (#114121)

Also, don't skip the whole collect_windows() if ctypes is missing.

Log also ctypes.windll.shell32.IsUserAnAdmin().

files:
M Lib/test/pythoninfo.py

diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 6dfb7f37e406a5..814358746d6d8a 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -865,26 +865,36 @@ def collect_subprocess(info_add):
 
 
 def collect_windows(info_add):
-try:
-import ctypes
-except ImportError:
-return
-
-if not hasattr(ctypes, 'WinDLL'):
+if sys.platform != "win32":
+# Code specific to Windows
 return
 
-ntdll = ctypes.WinDLL('ntdll')
-BOOLEAN = ctypes.c_ubyte
-
+# windows.RtlAreLongPathsEnabled: RtlAreLongPathsEnabled()
+# windows.is_admin: IsUserAnAdmin()
 try:
-RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled
-except AttributeError:
-res = ''
+import ctypes
+if not hasattr(ctypes, 'WinDLL'):
+raise ImportError
+except ImportError:
+pass
 else:
-RtlAreLongPathsEnabled.restype = BOOLEAN
-RtlAreLongPathsEnabled.argtypes = ()
-res = bool(RtlAreLongPathsEnabled())
-info_add('windows.RtlAreLongPathsEnabled', res)
+ntdll = ctypes.WinDLL('ntdll')
+BOOLEAN = ctypes.c_ubyte
+try:
+RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled
+except AttributeError:
+res = ''
+else:
+RtlAreLongPathsEnabled.restype = BOOLEAN
+RtlAreLongPathsEnabled.argtypes = ()
+res = bool(RtlAreLongPathsEnabled())
+info_add('windows.RtlAreLongPathsEnabled', res)
+
+shell32 = ctypes.windll.shell32
+IsUserAnAdmin = shell32.IsUserAnAdmin
+IsUserAnAdmin.restype = BOOLEAN
+IsUserAnAdmin.argtypes = ()
+info_add('windows.is_admin', IsUserAnAdmin())
 
 try:
 import _winapi
@@ -893,6 +903,7 @@ def collect_windows(info_add):
 except (ImportError, AttributeError):
 pass
 
+# windows.version_caption: "wmic os get Caption,Version /value" command
 import subprocess
 try:
 # When wmic.exe output is redirected to a pipe,
@@ -919,6 +930,7 @@ def collect_windows(info_add):
 if line:
 info_add('windows.version', line)
 
+# windows.ver: "ver" command
 try:
 proc = subprocess.Popen(["ver"], shell=True,
 stdout=subprocess.PIPE,
@@ -937,6 +949,22 @@ def collect_windows(info_add):
 if line:
 info_add('windows.ver', line)
 
+# windows.developer_mode: get AllowDevelopmentWithoutDevLicense registry
+import winreg
+try:
+key = winreg.OpenKey(
+winreg.HKEY_LOCAL_MACHINE,
+r"SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock")
+subkey = "AllowDevelopmentWithoutDevLicense"
+try:
+value, value_type = winreg.QueryValueEx(key, subkey)
+finally:
+winreg.CloseKey(key)
+except OSError:
+pass
+else:
+info_add('windows.developer_mode', "enabled" if value else "disabled")
+
 
 def collect_fips(info_add):
 try:

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


[Python-checkins] Fix an incorrect comment in iobase_is_closed (GH-102952)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/e454f9383c5ea629a917dfea791da0bb92b90d8e
commit: e454f9383c5ea629a917dfea791da0bb92b90d8e
branch: main
author: Jonathon Reinhart 
committer: serhiy-storchaka 
date: 2024-01-16T18:27:17+02:00
summary:

Fix an incorrect comment in iobase_is_closed (GH-102952)

This comment appears to have been mistakenly copied from what is now
called iobase_check_closed() in commit 4d9aec022063.

Also unite the iobase_check_closed() code with the relevant comment.

Co-authored-by: Serhiy Storchaka 

files:
M Modules/_io/iobase.c

diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index 4da8e5bd572d74..184e0b7d1aa7f1 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -66,12 +66,19 @@ PyDoc_STRVAR(iobase_doc,
 "with open('spam.txt', 'r') as fp:\n"
 "fp.write('Spam and eggs!')\n");
 
-/* Use this macro whenever you want to check the internal `closed` status
+
+/* Internal methods */
+
+/* Use this function whenever you want to check the internal `closed` status
of the IOBase object rather than the virtual `closed` attribute as returned
by whatever subclass. */
 
+static int
+iobase_is_closed(PyObject *self)
+{
+return PyObject_HasAttrWithError(self, &_Py_ID(__IOBase_closed));
+}
 
-/* Internal methods */
 static PyObject *
 iobase_unsupported(_PyIO_State *state, const char *message)
 {
@@ -145,14 +152,6 @@ _io__IOBase_truncate_impl(PyObject *self, PyTypeObject 
*cls,
 return iobase_unsupported(state, "truncate");
 }
 
-static int
-iobase_is_closed(PyObject *self)
-{
-/* This gets the derived attribute, which is *not* __IOBase_closed
-   in most cases! */
-return PyObject_HasAttrWithError(self, &_Py_ID(__IOBase_closed));
-}
-
 /* Flush and close methods */
 
 /*[clinic input]

___
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-114069: Revise Tutorial Methods paragraph (#114127)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/31a2543c80e1e38c97e50533249d9aa00e2f6cae
commit: 31a2543c80e1e38c97e50533249d9aa00e2f6cae
branch: main
author: Terry Jan Reedy 
committer: terryjreedy 
date: 2024-01-16T11:33:05-05:00
summary:

gh-114069: Revise Tutorial Methods paragraph (#114127)

Remove excess words in the first and third sentences.

files:
M Doc/tutorial/classes.rst

diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 3bf138ca225ee5..d1c303ef037027 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -386,12 +386,11 @@ general, calling a method with a list of *n* arguments is 
equivalent to calling
 the corresponding function with an argument list that is created by inserting
 the method's instance object before the first argument.
 
-If you still don't understand how methods work, a look at the implementation 
can
-perhaps clarify matters.  When a non-data attribute of an instance is
-referenced, the instance's class is searched.  If the name denotes a valid 
class
-attribute that is a function object, a method object is created by packing
-(pointers to) the instance object and the function object just found together 
in
-an abstract object: this is the method object.  When the method object is 
called
+In general, methods work as follows.  When a non-data attribute
+of an instance is referenced, the instance's class is searched.
+If the name denotes a valid class attribute that is a function object,
+references to both the instance object and the function object
+are packed into a method object.  When the method object is called
 with an argument list, a new argument list is constructed from the instance
 object and the argument list, and the function object is called with this new
 argument list.

___
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-114096: Restore privileges in _winapi.CreateJunction after creating the junction (GH-114089)

2024-01-16 Thread zooba
https://github.com/python/cpython/commit/de4ced54eb08e8630e3b6c13436d4ecc3fb14708
commit: de4ced54eb08e8630e3b6c13436d4ecc3fb14708
branch: main
author: Steve Dower 
committer: zooba 
date: 2024-01-16T16:40:02Z
summary:

gh-114096: Restore privileges in _winapi.CreateJunction after creating the 
junction (GH-114089)

This avoids impact on later parts of the application which may be able to do 
things they otherwise shouldn't.

files:
A Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
M Modules/_winapi.c

diff --git 
a/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst 
b/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
new file mode 100644
index 00..f28fc04baa7fb1
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
@@ -0,0 +1,3 @@
+Process privileges that are activated for creating directory junctions are
+now restored afterwards, avoiding behaviour changes in other parts of the
+program.
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index a26850e825b492..26302b559817b3 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -532,7 +532,12 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 {
 /* Privilege adjustment */
 HANDLE token = NULL;
-TOKEN_PRIVILEGES tp;
+struct {
+TOKEN_PRIVILEGES base;
+/* overallocate by a few array elements */
+LUID_AND_ATTRIBUTES privs[4];
+} tp, previousTp;
+int previousTpSize = 0;
 
 /* Reparse data buffer */
 const USHORT prefix_len = 4;
@@ -556,17 +561,21 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 
 /* Adjust privileges to allow rewriting directory entry as a
junction point. */
-if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, 
&token))
+if (!OpenProcessToken(GetCurrentProcess(),
+  TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
 goto cleanup;
+}
 
-if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid))
+if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, 
&tp.base.Privileges[0].Luid)) {
 goto cleanup;
+}
 
-tp.PrivilegeCount = 1;
-tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-if (!AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES),
-   NULL, NULL))
+tp.base.PrivilegeCount = 1;
+tp.base.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+if (!AdjustTokenPrivileges(token, FALSE, &tp.base, sizeof(previousTp),
+   &previousTp.base, &previousTpSize)) {
 goto cleanup;
+}
 
 if (GetFileAttributesW(src_path) == INVALID_FILE_ATTRIBUTES)
 goto cleanup;
@@ -647,6 +656,11 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 cleanup:
 ret = GetLastError();
 
+if (previousTpSize) {
+AdjustTokenPrivileges(token, FALSE, &previousTp.base, previousTpSize,
+  NULL, NULL);
+}
+
 if (token != NULL)
 CloseHandle(token);
 if (junction != NULL)

___
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: Improve multiprocessing.SharedMemory reference (#114093)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/b1db6278cf6e60efdeca96244e5d73df4f070bea
commit: b1db6278cf6e60efdeca96244e5d73df4f070bea
branch: main
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-16T16:43:13Z
summary:

Docs: Improve multiprocessing.SharedMemory reference (#114093)

Align the multiprocessing shared memory docs with Diatáxis's
recommendations for references.

- use a parameter list for the SharedMemory.__init__() argument spec
- use the imperative mode
- use versionadded, not versionchanged, for added parameters
- reflow touched lines according to SemBr

files:
M Doc/library/multiprocessing.shared_memory.rst

diff --git a/Doc/library/multiprocessing.shared_memory.rst 
b/Doc/library/multiprocessing.shared_memory.rst
index 9b5c1c32a91f55..2e3f5be4dd2335 100644
--- a/Doc/library/multiprocessing.shared_memory.rst
+++ b/Doc/library/multiprocessing.shared_memory.rst
@@ -38,7 +38,8 @@ copying of data.
 
 .. class:: SharedMemory(name=None, create=False, size=0, *, track=True)
 
-   Creates a new shared memory block or attaches to an existing shared
+   Create an instance of the :class:`!SharedMemory` class for either
+   creating a new shared memory block or attaching to an existing shared
memory block.  Each shared memory block is assigned a unique name.
In this way, one process can create a shared memory block with a
particular name and a different process can attach to that same shared
@@ -51,41 +52,48 @@ copying of data.
When a shared memory block is no longer needed by any process, the
:meth:`unlink` method should be called to ensure proper cleanup.
 
-   *name* is the unique name for the requested shared memory, specified as
-   a string.  When creating a new shared memory block, if ``None`` (the
-   default) is supplied for the name, a novel name will be generated.
-
-   *create* controls whether a new shared memory block is created (``True``)
-   or an existing shared memory block is attached (``False``).
-
-   *size* specifies the requested number of bytes when creating a new shared
-   memory block.  Because some platforms choose to allocate chunks of memory
-   based upon that platform's memory page size, the exact size of the shared
-   memory block may be larger or equal to the size requested.  When attaching
-   to an existing shared memory block, the *size* parameter is ignored.
-
-   *track*, when enabled, registers the shared memory block with a resource
-   tracker process on platforms where the OS does not do this automatically.
-   The resource tracker ensures proper cleanup of the shared memory even
-   if all other processes with access to the memory exit without doing so.
-   Python processes created from a common ancestor using :mod:`multiprocessing`
-   facilities share a single resource tracker process, and the lifetime of
-   shared memory segments is handled automatically among these processes.
-   Python processes created in any other way will receive their own
-   resource tracker when accessing shared memory with *track* enabled.
-   This will cause the shared memory to be deleted by the resource tracker
-   of the first process that terminates.
-   To avoid this issue, users of :mod:`subprocess` or standalone Python
-   processes should set *track* to ``False`` when there is already another
-   process in place that does the bookkeeping.
-   *track* is ignored on Windows, which has its own tracking and
-   automatically deletes shared memory when all handles to it have been closed.
-
-   .. versionchanged:: 3.13 Added *track* parameter.
+   :param name:
+  The unique name for the requested shared memory, specified as a string.
+  When creating a new shared memory block, if ``None`` (the default)
+  is supplied for the name, a novel name will be generated.
+   :type name: str | None
+
+   :param bool create:
+  Control whether a new shared memory block is created (``True``)
+  or an existing shared memory block is attached (``False``).
+
+   :param int size:
+  The requested number of bytes when creating a new shared memory block.
+  Because some platforms choose to allocate chunks of memory
+  based upon that platform's memory page size, the exact size of the shared
+  memory block may be larger or equal to the size requested.
+  When attaching to an existing shared memory block,
+  the *size* parameter is ignored.
+
+   :param bool track:
+  When ``True``, register the shared memory block with a resource
+  tracker process on platforms where the OS does not do this automatically.
+  The resource tracker ensures proper cleanup of the shared memory even
+  if all other processes with access to the memory exit without doing so.
+  Python processes created from a common ancestor using 
:mod:`multiprocessing`
+  facilities share a single resource tracker process, and the lifetime of
+  shared memory segments is handled automatically among these processes.
+  Pyt

[Python-checkins] [3.12] gh-114069: Revise Tutorial Methods paragraph (GH-114127) (#114131)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/3eeab87feba51c7ef6c87a374874a21d11835d6d
commit: 3eeab87feba51c7ef6c87a374874a21d11835d6d
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy 
date: 2024-01-16T16:43:20Z
summary:

[3.12] gh-114069: Revise Tutorial Methods paragraph (GH-114127) (#114131)

gh-114069: Revise Tutorial Methods paragraph (GH-114127)

Remove excess words in the first and third sentences.
(cherry picked from commit 31a2543c80e1e38c97e50533249d9aa00e2f6cae)

Co-authored-by: Terry Jan Reedy 

files:
M Doc/tutorial/classes.rst

diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 3bf138ca225ee5..d1c303ef037027 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -386,12 +386,11 @@ general, calling a method with a list of *n* arguments is 
equivalent to calling
 the corresponding function with an argument list that is created by inserting
 the method's instance object before the first argument.
 
-If you still don't understand how methods work, a look at the implementation 
can
-perhaps clarify matters.  When a non-data attribute of an instance is
-referenced, the instance's class is searched.  If the name denotes a valid 
class
-attribute that is a function object, a method object is created by packing
-(pointers to) the instance object and the function object just found together 
in
-an abstract object: this is the method object.  When the method object is 
called
+In general, methods work as follows.  When a non-data attribute
+of an instance is referenced, the instance's class is searched.
+If the name denotes a valid class attribute that is a function object,
+references to both the instance object and the function object
+are packed into a method object.  When the method object is called
 with an argument list, a new argument list is constructed from the instance
 object and the argument list, and the function object is called with this new
 argument list.

___
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-114069: Revise Tutorial Methods paragraph (GH-114127) (#114132)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/d42e54e9d60b3343b48458faa2ab10ac9de78889
commit: d42e54e9d60b3343b48458faa2ab10ac9de78889
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy 
date: 2024-01-16T16:43:23Z
summary:

[3.11] gh-114069: Revise Tutorial Methods paragraph (GH-114127) (#114132)

gh-114069: Revise Tutorial Methods paragraph (GH-114127)

Remove excess words in the first and third sentences.
(cherry picked from commit 31a2543c80e1e38c97e50533249d9aa00e2f6cae)

Co-authored-by: Terry Jan Reedy 

files:
M Doc/tutorial/classes.rst

diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 734ec2330de0d2..ae3ffd369462fc 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -386,12 +386,11 @@ general, calling a method with a list of *n* arguments is 
equivalent to calling
 the corresponding function with an argument list that is created by inserting
 the method's instance object before the first argument.
 
-If you still don't understand how methods work, a look at the implementation 
can
-perhaps clarify matters.  When a non-data attribute of an instance is
-referenced, the instance's class is searched.  If the name denotes a valid 
class
-attribute that is a function object, a method object is created by packing
-(pointers to) the instance object and the function object just found together 
in
-an abstract object: this is the method object.  When the method object is 
called
+In general, methods work as follows.  When a non-data attribute
+of an instance is referenced, the instance's class is searched.
+If the name denotes a valid class attribute that is a function object,
+references to both the instance object and the function object
+are packed into a method object.  When the method object is called
 with an argument list, a new argument list is constructed from the instance
 object and the argument list, and the function object is called with this new
 argument list.

___
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-114107: test.pythoninfo logs Windows Developer Mode (GH-114121) (#114128)

2024-01-16 Thread vstinner
https://github.com/python/cpython/commit/ddc9e34c53d442d3da9af67759dc3f6707239630
commit: ddc9e34c53d442d3da9af67759dc3f6707239630
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: vstinner 
date: 2024-01-16T16:43:50Z
summary:

[3.11] gh-114107: test.pythoninfo logs Windows Developer Mode (GH-114121) 
(#114128)

gh-114107: test.pythoninfo logs Windows Developer Mode (GH-114121)

Also, don't skip the whole collect_windows() if ctypes is missing.

Log also ctypes.windll.shell32.IsUserAnAdmin().
(cherry picked from commit c77f552ec02040dfe14a0a3cb743d96eedffadec)

Co-authored-by: Victor Stinner 

files:
M Lib/test/pythoninfo.py

diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 998eba4f0812ab..74ebb5e5b8a292 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -864,26 +864,36 @@ def collect_subprocess(info_add):
 
 
 def collect_windows(info_add):
-try:
-import ctypes
-except ImportError:
-return
-
-if not hasattr(ctypes, 'WinDLL'):
+if sys.platform != "win32":
+# Code specific to Windows
 return
 
-ntdll = ctypes.WinDLL('ntdll')
-BOOLEAN = ctypes.c_ubyte
-
+# windows.RtlAreLongPathsEnabled: RtlAreLongPathsEnabled()
+# windows.is_admin: IsUserAnAdmin()
 try:
-RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled
-except AttributeError:
-res = ''
+import ctypes
+if not hasattr(ctypes, 'WinDLL'):
+raise ImportError
+except ImportError:
+pass
 else:
-RtlAreLongPathsEnabled.restype = BOOLEAN
-RtlAreLongPathsEnabled.argtypes = ()
-res = bool(RtlAreLongPathsEnabled())
-info_add('windows.RtlAreLongPathsEnabled', res)
+ntdll = ctypes.WinDLL('ntdll')
+BOOLEAN = ctypes.c_ubyte
+try:
+RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled
+except AttributeError:
+res = ''
+else:
+RtlAreLongPathsEnabled.restype = BOOLEAN
+RtlAreLongPathsEnabled.argtypes = ()
+res = bool(RtlAreLongPathsEnabled())
+info_add('windows.RtlAreLongPathsEnabled', res)
+
+shell32 = ctypes.windll.shell32
+IsUserAnAdmin = shell32.IsUserAnAdmin
+IsUserAnAdmin.restype = BOOLEAN
+IsUserAnAdmin.argtypes = ()
+info_add('windows.is_admin', IsUserAnAdmin())
 
 try:
 import _winapi
@@ -892,6 +902,7 @@ def collect_windows(info_add):
 except (ImportError, AttributeError):
 pass
 
+# windows.version_caption: "wmic os get Caption,Version /value" command
 import subprocess
 try:
 # When wmic.exe output is redirected to a pipe,
@@ -918,6 +929,7 @@ def collect_windows(info_add):
 if line:
 info_add('windows.version', line)
 
+# windows.ver: "ver" command
 try:
 proc = subprocess.Popen(["ver"], shell=True,
 stdout=subprocess.PIPE,
@@ -936,6 +948,22 @@ def collect_windows(info_add):
 if line:
 info_add('windows.ver', line)
 
+# windows.developer_mode: get AllowDevelopmentWithoutDevLicense registry
+import winreg
+try:
+key = winreg.OpenKey(
+winreg.HKEY_LOCAL_MACHINE,
+r"SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock")
+subkey = "AllowDevelopmentWithoutDevLicense"
+try:
+value, value_type = winreg.QueryValueEx(key, subkey)
+finally:
+winreg.CloseKey(key)
+except OSError:
+pass
+else:
+info_add('windows.developer_mode', "enabled" if value else "disabled")
+
 
 def collect_fips(info_add):
 try:

___
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-114107: test.pythoninfo logs Windows Developer Mode (GH-114121) (#114129)

2024-01-16 Thread vstinner
https://github.com/python/cpython/commit/1d5bca65e26419dfc911a636f81b37379b111f8a
commit: 1d5bca65e26419dfc911a636f81b37379b111f8a
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: vstinner 
date: 2024-01-16T16:53:29Z
summary:

[3.12] gh-114107: test.pythoninfo logs Windows Developer Mode (GH-114121) 
(#114129)

gh-114107: test.pythoninfo logs Windows Developer Mode (GH-114121)

Also, don't skip the whole collect_windows() if ctypes is missing.

Log also ctypes.windll.shell32.IsUserAnAdmin().
(cherry picked from commit c77f552ec02040dfe14a0a3cb743d96eedffadec)

Co-authored-by: Victor Stinner 

files:
M Lib/test/pythoninfo.py

diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 998eba4f0812ab..74ebb5e5b8a292 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -864,26 +864,36 @@ def collect_subprocess(info_add):
 
 
 def collect_windows(info_add):
-try:
-import ctypes
-except ImportError:
-return
-
-if not hasattr(ctypes, 'WinDLL'):
+if sys.platform != "win32":
+# Code specific to Windows
 return
 
-ntdll = ctypes.WinDLL('ntdll')
-BOOLEAN = ctypes.c_ubyte
-
+# windows.RtlAreLongPathsEnabled: RtlAreLongPathsEnabled()
+# windows.is_admin: IsUserAnAdmin()
 try:
-RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled
-except AttributeError:
-res = ''
+import ctypes
+if not hasattr(ctypes, 'WinDLL'):
+raise ImportError
+except ImportError:
+pass
 else:
-RtlAreLongPathsEnabled.restype = BOOLEAN
-RtlAreLongPathsEnabled.argtypes = ()
-res = bool(RtlAreLongPathsEnabled())
-info_add('windows.RtlAreLongPathsEnabled', res)
+ntdll = ctypes.WinDLL('ntdll')
+BOOLEAN = ctypes.c_ubyte
+try:
+RtlAreLongPathsEnabled = ntdll.RtlAreLongPathsEnabled
+except AttributeError:
+res = ''
+else:
+RtlAreLongPathsEnabled.restype = BOOLEAN
+RtlAreLongPathsEnabled.argtypes = ()
+res = bool(RtlAreLongPathsEnabled())
+info_add('windows.RtlAreLongPathsEnabled', res)
+
+shell32 = ctypes.windll.shell32
+IsUserAnAdmin = shell32.IsUserAnAdmin
+IsUserAnAdmin.restype = BOOLEAN
+IsUserAnAdmin.argtypes = ()
+info_add('windows.is_admin', IsUserAnAdmin())
 
 try:
 import _winapi
@@ -892,6 +902,7 @@ def collect_windows(info_add):
 except (ImportError, AttributeError):
 pass
 
+# windows.version_caption: "wmic os get Caption,Version /value" command
 import subprocess
 try:
 # When wmic.exe output is redirected to a pipe,
@@ -918,6 +929,7 @@ def collect_windows(info_add):
 if line:
 info_add('windows.version', line)
 
+# windows.ver: "ver" command
 try:
 proc = subprocess.Popen(["ver"], shell=True,
 stdout=subprocess.PIPE,
@@ -936,6 +948,22 @@ def collect_windows(info_add):
 if line:
 info_add('windows.ver', line)
 
+# windows.developer_mode: get AllowDevelopmentWithoutDevLicense registry
+import winreg
+try:
+key = winreg.OpenKey(
+winreg.HKEY_LOCAL_MACHINE,
+r"SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock")
+subkey = "AllowDevelopmentWithoutDevLicense"
+try:
+value, value_type = winreg.QueryValueEx(key, subkey)
+finally:
+winreg.CloseKey(key)
+except OSError:
+pass
+else:
+info_add('windows.developer_mode', "enabled" if value else "disabled")
+
 
 def collect_fips(info_add):
 try:

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


[Python-checkins] Fix 'expresion' typo in IDLE doc (#114130)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/7a24ecc953e1edc9c5bbedbd19cc587c3ff635ea
commit: 7a24ecc953e1edc9c5bbedbd19cc587c3ff635ea
branch: main
author: Terry Jan Reedy 
committer: terryjreedy 
date: 2024-01-16T17:12:59Z
summary:

Fix 'expresion' typo in IDLE doc (#114130)

The substantive change is on line 577/593. Rest is header/footer stuff ignored 
when displaying.

files:
M Lib/idlelib/help.html

diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 722406b81a8ae6..2dc463735d691e 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -1,33 +1,31 @@
-
 
 
 
   
 
-http://docutils.sourceforge.net/"; />
+
 
-IDLE — Python 3.12.0a0 documentation
+IDLE — Python 3.13.0a2 documentation
 
 
-
+
+
 
 
-
-
-
 
+
 
 
 
 
 
 
 
 
 
-
+
 https://docs.python.org/3/library/idle.html"; />
 
 
@@ -41,35 +39,48 @@
 }
   }
 
-
+
+
 
 
+
+
 
   
 
 
 
-
-
-
 
- https://www.python.org/"; class="nav-logo">
- 
- 
-
-
-http://www.w3.org/2000/svg"; width="20" height="20" 
viewBox="0 0 24 24" class="search-icon">
-
-
-
-
-
+
+
+
+
+https://www.python.org/"; class="nav-logo">
+
+
+
+
+http://www.w3.org/2000/svg"; width="20" height="20" 
viewBox="0 0 24 24" class="search-icon">
+
+
+
+
+
+
 
 
 
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+
   
 Table of Contents
 
@@ -123,8 +134,8 @@ Table of Contents
   
   
 Previous topic
-tkinter.tix — 
Extension widgets for Tk
+tkinter.ttk — Tk 
themed widgets
   
   
 Next topic
@@ -160,7 +171,7 @@ Navigation
   next |
 
-  previous |
 
   
@@ -173,7 +184,7 @@ Navigation
 
   
 
-  3.12.0a0 Documentation »
+  3.13.0a2 Documentation »
 
 
   The Python 
Standard Library »
@@ -184,14 +195,21 @@ Navigation
 
 
 
-  
+  
   
-  
-  
 
 
  |
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+ |
 
   
 
@@ -531,16 +549,15 @@ Editor windows¶
 In this section, ‘C’ refers to the Control key on Windows and Unix and
 the Command key on 
macOS.
-
+
 Backspace deletes 
to the left; Del deletes to 
the right
 C-Backspace delete word left; C-Del delete word to the right
-Arrow keys and Page 
Up/Page Down to move around
+Arrow keys and Page 
Up/Page Down to move 
around
 C-LeftArrow and C-RightArrow moves by 
words
 Home/End go to begin/end of 
line
 C-Home/C-End go to begin/end of 
file
 Some useful Emacs bindings are inherited from Tcl/Tk:
-
-
+
 C-a beginning of line
 C-e end of line
 C-k kill line (but doesn’t put it in clipboard)
@@ -553,7 +570,6 @@ Key bindingsC-d delete next character
 
-
 
 
 Standard keybindings (like C-c to copy and C-v to paste)
@@ -574,7 +590,7 @@ Automatic indentationSearch and Replace¶
 Any selection becomes a search target.  However, only selections within
 a line work because searches are only performed within lines with the
-terminal newline removed.  If [x] Regular expresion is checked, the
+terminal newline removed.  If [x] Regular expression is checked, the
 target is interpreted according to the Python re module.
 
 
@@ -1077,8 +1093,8 @@ Table of Contents
   
   
 Previous topic
-tkinter.tix — 
Extension widgets for Tk
+tkinter.ttk — Tk 
themed widgets
   
   
 Next topic
@@ -1117,7 +1133,7 @@ Navigation
   next |
 
-  previous |
 
   
@@ -1130,7 +1146,7 @@ Navigation
 
   
 
-  3.12.0a0 Documentation »
+  3.13.0a2 Documentation »
 
 
   The Python 
Standard Library »
@@ -1141,19 +1157,26 @@ Navigation
 
 
 
-  
+  
   
-  
-  
 
 
  |
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+ |
 
   
 
 
-© Copyright 2001-2022, Python 
Software Foundation.
+© Copyright 2001-2024, Python 
Software Foundation.
 
 This page is licensed under the Python Software Foundation License Version 
2.
 
@@ -1167,11 +1190,11 @@ Navigation
 
 
 
-Last updated on Sep 03, 2022.
+Last updated on Jan 16, 2024 (16:17 UTC).
 Found a bug?
 
 
-Created using https://www.sphinx-doc.org/";>Sphinx 5.0.2.
+Created using https://www.sphinx-doc.org/";>Sphinx 7.0.1.
 
 
   

___
Pyt

[Python-checkins] [3.12] Docs: Improve multiprocessing.SharedMemory reference (#114093) (#114137)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/91739149f04f0e6cd50727edf966e0da2f156276
commit: 91739149f04f0e6cd50727edf966e0da2f156276
branch: 3.12
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-16T17:17:29Z
summary:

[3.12] Docs: Improve multiprocessing.SharedMemory reference (#114093) (#114137)

(cherry picked from b1db6278cf6e60efdeca96244e5d73df4f070bea)

Align the multiprocessing shared memory docs with Diatáxis's
recommendations for references.

- use a parameter list for the SharedMemory.__init__() argument spec
- use the imperative mode
- use versionadded, not versionchanged, for added parameters
- reflow touched lines according to SemBr

files:
M Doc/library/multiprocessing.shared_memory.rst

diff --git a/Doc/library/multiprocessing.shared_memory.rst 
b/Doc/library/multiprocessing.shared_memory.rst
index 1771b1589f1cee..47af64578bd529 100644
--- a/Doc/library/multiprocessing.shared_memory.rst
+++ b/Doc/library/multiprocessing.shared_memory.rst
@@ -38,7 +38,8 @@ copying of data.
 
 .. class:: SharedMemory(name=None, create=False, size=0)
 
-   Creates a new shared memory block or attaches to an existing shared
+   Create an instance of the :class:`!SharedMemory` class for either
+   creating a new shared memory block or attaching to an existing shared
memory block.  Each shared memory block is assigned a unique name.
In this way, one process can create a shared memory block with a
particular name and a different process can attach to that same shared
@@ -51,22 +52,27 @@ copying of data.
When a shared memory block is no longer needed by any process, the
:meth:`unlink` method should be called to ensure proper cleanup.
 
-   *name* is the unique name for the requested shared memory, specified as
-   a string.  When creating a new shared memory block, if ``None`` (the
-   default) is supplied for the name, a novel name will be generated.
+   :param name:
+  The unique name for the requested shared memory, specified as a string.
+  When creating a new shared memory block, if ``None`` (the default)
+  is supplied for the name, a novel name will be generated.
+   :type name: str | None
 
-   *create* controls whether a new shared memory block is created (``True``)
-   or an existing shared memory block is attached (``False``).
+   :param bool create:
+  Control whether a new shared memory block is created (``True``)
+  or an existing shared memory block is attached (``False``).
 
-   *size* specifies the requested number of bytes when creating a new shared
-   memory block.  Because some platforms choose to allocate chunks of memory
-   based upon that platform's memory page size, the exact size of the shared
-   memory block may be larger or equal to the size requested.  When attaching
-   to an existing shared memory block, the *size* parameter is ignored.
+   :param int size:
+  The requested number of bytes when creating a new shared memory block.
+  Because some platforms choose to allocate chunks of memory
+  based upon that platform's memory page size, the exact size of the shared
+  memory block may be larger or equal to the size requested.
+  When attaching to an existing shared memory block,
+  the *size* parameter is ignored.
 
.. method:: close()
 
-  Closes access to the shared memory from this instance.  In order to
+  Close access to the shared memory from this instance.  In order to
   ensure proper cleanup of resources, all instances should call
   :meth:`close` once the instance is no longer needed.  Note that calling
   :meth:`!close` does not cause the shared memory block itself to be
@@ -74,7 +80,7 @@ copying of data.
 
.. method:: unlink()
 
-  Requests that the underlying shared memory block be destroyed.  In
+  Request that the underlying shared memory block be destroyed.  In
   order to ensure proper cleanup of resources, :meth:`unlink` should be
   called once (and only once) across all processes which have need
   for the shared memory block.  After requesting its destruction, a
@@ -258,7 +264,7 @@ finishes execution.
 
 .. class:: ShareableList(sequence=None, *, name=None)
 
-   Provides a mutable list-like object where all values stored within are
+   Provide a mutable list-like object where all values stored within are
stored in a shared memory block.
This constrains storable values to the following built-in data types:
 
@@ -315,12 +321,12 @@ finishes execution.
 
.. method:: count(value)
 
-  Returns the number of occurrences of *value*.
+  Return the number of occurrences of *value*.
 
.. method:: index(value)
 
-  Returns first index position of *value*.  Raises :exc:`ValueError` if
-  *value* is not present.
+  Return first index position of *value*.
+  Raise :exc:`ValueError` if *value* is not present.
 
.. attribute:: format
 

___
Python-checkins mailing 

[Python-checkins] [3.11] Docs: Improve multiprocessing.SharedMemory reference (#114093) (#114138)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/2122e1ee837564042fa0f1ed0021f0e8c69dda0e
commit: 2122e1ee837564042fa0f1ed0021f0e8c69dda0e
branch: 3.11
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-16T17:18:34Z
summary:

[3.11] Docs: Improve multiprocessing.SharedMemory reference (#114093) (#114138)

(cherry picked from b1db6278cf6e60efdeca96244e5d73df4f070bea)

Align the multiprocessing shared memory docs with Diatáxis's
recommendations for references.

- use a parameter list for the SharedMemory.__init__() argument spec
- use the imperative mode
- use versionadded, not versionchanged, for added parameters
- reflow touched lines according to SemBr

files:
M Doc/library/multiprocessing.shared_memory.rst

diff --git a/Doc/library/multiprocessing.shared_memory.rst 
b/Doc/library/multiprocessing.shared_memory.rst
index 1771b1589f1cee..47af64578bd529 100644
--- a/Doc/library/multiprocessing.shared_memory.rst
+++ b/Doc/library/multiprocessing.shared_memory.rst
@@ -38,7 +38,8 @@ copying of data.
 
 .. class:: SharedMemory(name=None, create=False, size=0)
 
-   Creates a new shared memory block or attaches to an existing shared
+   Create an instance of the :class:`!SharedMemory` class for either
+   creating a new shared memory block or attaching to an existing shared
memory block.  Each shared memory block is assigned a unique name.
In this way, one process can create a shared memory block with a
particular name and a different process can attach to that same shared
@@ -51,22 +52,27 @@ copying of data.
When a shared memory block is no longer needed by any process, the
:meth:`unlink` method should be called to ensure proper cleanup.
 
-   *name* is the unique name for the requested shared memory, specified as
-   a string.  When creating a new shared memory block, if ``None`` (the
-   default) is supplied for the name, a novel name will be generated.
+   :param name:
+  The unique name for the requested shared memory, specified as a string.
+  When creating a new shared memory block, if ``None`` (the default)
+  is supplied for the name, a novel name will be generated.
+   :type name: str | None
 
-   *create* controls whether a new shared memory block is created (``True``)
-   or an existing shared memory block is attached (``False``).
+   :param bool create:
+  Control whether a new shared memory block is created (``True``)
+  or an existing shared memory block is attached (``False``).
 
-   *size* specifies the requested number of bytes when creating a new shared
-   memory block.  Because some platforms choose to allocate chunks of memory
-   based upon that platform's memory page size, the exact size of the shared
-   memory block may be larger or equal to the size requested.  When attaching
-   to an existing shared memory block, the *size* parameter is ignored.
+   :param int size:
+  The requested number of bytes when creating a new shared memory block.
+  Because some platforms choose to allocate chunks of memory
+  based upon that platform's memory page size, the exact size of the shared
+  memory block may be larger or equal to the size requested.
+  When attaching to an existing shared memory block,
+  the *size* parameter is ignored.
 
.. method:: close()
 
-  Closes access to the shared memory from this instance.  In order to
+  Close access to the shared memory from this instance.  In order to
   ensure proper cleanup of resources, all instances should call
   :meth:`close` once the instance is no longer needed.  Note that calling
   :meth:`!close` does not cause the shared memory block itself to be
@@ -74,7 +80,7 @@ copying of data.
 
.. method:: unlink()
 
-  Requests that the underlying shared memory block be destroyed.  In
+  Request that the underlying shared memory block be destroyed.  In
   order to ensure proper cleanup of resources, :meth:`unlink` should be
   called once (and only once) across all processes which have need
   for the shared memory block.  After requesting its destruction, a
@@ -258,7 +264,7 @@ finishes execution.
 
 .. class:: ShareableList(sequence=None, *, name=None)
 
-   Provides a mutable list-like object where all values stored within are
+   Provide a mutable list-like object where all values stored within are
stored in a shared memory block.
This constrains storable values to the following built-in data types:
 
@@ -315,12 +321,12 @@ finishes execution.
 
.. method:: count(value)
 
-  Returns the number of occurrences of *value*.
+  Return the number of occurrences of *value*.
 
.. method:: index(value)
 
-  Returns first index position of *value*.  Raises :exc:`ValueError` if
-  *value* is not present.
+  Return first index position of *value*.
+  Raise :exc:`ValueError` if *value* is not present.
 
.. attribute:: format
 

___
Python-checkins mailing 

[Python-checkins] gh-114096: Restore privileges in _winapi.CreateJunction after creating the junction (GH-114089)

2024-01-16 Thread zooba
https://github.com/python/cpython/commit/fb5cec98e2f185b953e7957834487941a88e670d
commit: fb5cec98e2f185b953e7957834487941a88e670d
branch: 3.11
author: Steve Dower 
committer: zooba 
date: 2024-01-16T17:37:17Z
summary:

gh-114096: Restore privileges in _winapi.CreateJunction after creating the 
junction (GH-114089)

This avoids impact on later parts of the application which may be able to do 
things they otherwise shouldn't.

files:
A Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
M Modules/_winapi.c

diff --git 
a/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst 
b/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
new file mode 100644
index 00..f28fc04baa7fb1
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
@@ -0,0 +1,3 @@
+Process privileges that are activated for creating directory junctions are
+now restored afterwards, avoiding behaviour changes in other parts of the
+program.
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 55b37188d24e45..b44f44be0ff419 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -542,7 +542,12 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 {
 /* Privilege adjustment */
 HANDLE token = NULL;
-TOKEN_PRIVILEGES tp;
+struct {
+TOKEN_PRIVILEGES base;
+/* overallocate by a few array elements */
+LUID_AND_ATTRIBUTES privs[4];
+} tp, previousTp;
+int previousTpSize = 0;
 
 /* Reparse data buffer */
 const USHORT prefix_len = 4;
@@ -566,17 +571,21 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 
 /* Adjust privileges to allow rewriting directory entry as a
junction point. */
-if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, 
&token))
+if (!OpenProcessToken(GetCurrentProcess(),
+  TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
 goto cleanup;
+}
 
-if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid))
+if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, 
&tp.base.Privileges[0].Luid)) {
 goto cleanup;
+}
 
-tp.PrivilegeCount = 1;
-tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-if (!AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES),
-   NULL, NULL))
+tp.base.PrivilegeCount = 1;
+tp.base.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+if (!AdjustTokenPrivileges(token, FALSE, &tp.base, sizeof(previousTp),
+   &previousTp.base, &previousTpSize)) {
 goto cleanup;
+}
 
 if (GetFileAttributesW(src_path) == INVALID_FILE_ATTRIBUTES)
 goto cleanup;
@@ -657,8 +666,15 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 cleanup:
 ret = GetLastError();
 
-CloseHandle(token);
-CloseHandle(junction);
+if (previousTpSize) {
+AdjustTokenPrivileges(token, FALSE, &previousTp.base, previousTpSize,
+  NULL, NULL);
+}
+
+if (token != NULL)
+CloseHandle(token);
+if (junction != NULL)
+CloseHandle(junction);
 PyMem_RawFree(rdb);
 
 if (ret != 0)

___
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-114096: Restore privileges in _winapi.CreateJunction after creating the junction (GH-114089)

2024-01-16 Thread zooba
https://github.com/python/cpython/commit/10f00294a083100897bc14dcecf20e1357e22644
commit: 10f00294a083100897bc14dcecf20e1357e22644
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: zooba 
date: 2024-01-16T17:39:59Z
summary:

gh-114096: Restore privileges in _winapi.CreateJunction after creating the 
junction (GH-114089)

This avoids impact on later parts of the application which may be able to do 
things they otherwise shouldn't.
(cherry picked from commit de4ced54eb08e8630e3b6c13436d4ecc3fb14708)

Co-authored-by: Steve Dower 

files:
A Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
M Modules/_winapi.c

diff --git 
a/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst 
b/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
new file mode 100644
index 00..f28fc04baa7fb1
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2024-01-15-23-53-25.gh-issue-114096.G-Myja.rst
@@ -0,0 +1,3 @@
+Process privileges that are activated for creating directory junctions are
+now restored afterwards, avoiding behaviour changes in other parts of the
+program.
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index fdbe3f626fd2a7..bcb003f8216dd4 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -530,7 +530,12 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 {
 /* Privilege adjustment */
 HANDLE token = NULL;
-TOKEN_PRIVILEGES tp;
+struct {
+TOKEN_PRIVILEGES base;
+/* overallocate by a few array elements */
+LUID_AND_ATTRIBUTES privs[4];
+} tp, previousTp;
+int previousTpSize = 0;
 
 /* Reparse data buffer */
 const USHORT prefix_len = 4;
@@ -554,17 +559,21 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 
 /* Adjust privileges to allow rewriting directory entry as a
junction point. */
-if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, 
&token))
+if (!OpenProcessToken(GetCurrentProcess(),
+  TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
 goto cleanup;
+}
 
-if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid))
+if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, 
&tp.base.Privileges[0].Luid)) {
 goto cleanup;
+}
 
-tp.PrivilegeCount = 1;
-tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-if (!AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES),
-   NULL, NULL))
+tp.base.PrivilegeCount = 1;
+tp.base.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+if (!AdjustTokenPrivileges(token, FALSE, &tp.base, sizeof(previousTp),
+   &previousTp.base, &previousTpSize)) {
 goto cleanup;
+}
 
 if (GetFileAttributesW(src_path) == INVALID_FILE_ATTRIBUTES)
 goto cleanup;
@@ -645,6 +654,11 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR 
src_path,
 cleanup:
 ret = GetLastError();
 
+if (previousTpSize) {
+AdjustTokenPrivileges(token, FALSE, &previousTp.base, previousTpSize,
+  NULL, NULL);
+}
+
 if (token != NULL)
 CloseHandle(token);
 if (junction != NULL)

___
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-113659: Skip hidden .pth files (GH-113660)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/74208ed0c440244fb809d8acc97cb9ef51e888e3
commit: 74208ed0c440244fb809d8acc97cb9ef51e888e3
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-01-16T20:23:05+02:00
summary:

gh-113659: Skip hidden .pth files (GH-113660)

Skip .pth files with names starting with a dot or hidden file attribute.

files:
A Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
M Lib/site.py
M Lib/test/test_site.py

diff --git a/Lib/site.py b/Lib/site.py
index eea92dfc194333..0631f3f6115ec0 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -74,6 +74,7 @@
 import builtins
 import _sitebuiltins
 import io
+import stat
 
 # Prefixes for site-packages; add additional prefixes like /usr/local here
 PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -168,6 +169,14 @@ def addpackage(sitedir, name, known_paths):
 else:
 reset = False
 fullname = os.path.join(sitedir, name)
+try:
+st = os.lstat(fullname)
+except OSError:
+return
+if ((getattr(st, 'st_flags', 0) & stat.UF_HIDDEN) or
+(getattr(st, 'st_file_attributes', 0) & stat.FILE_ATTRIBUTE_HIDDEN)):
+_trace(f"Skipping hidden .pth file: {fullname!r}")
+return
 _trace(f"Processing .pth file: {fullname!r}")
 try:
 # locale encoding is not ideal especially on Windows. But we have used
@@ -221,7 +230,8 @@ def addsitedir(sitedir, known_paths=None):
 names = os.listdir(sitedir)
 except OSError:
 return
-names = [name for name in names if name.endswith(".pth")]
+names = [name for name in names
+ if name.endswith(".pth") and not name.startswith(".")]
 for name in sorted(names):
 addpackage(sitedir, name, known_paths)
 if reset:
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index e26b48ee9483d5..0502181854f52b 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -19,6 +19,7 @@
 import os
 import re
 import shutil
+import stat
 import subprocess
 import sys
 import sysconfig
@@ -195,6 +196,45 @@ def test_addsitedir(self):
 finally:
 pth_file.cleanup()
 
+def test_addsitedir_dotfile(self):
+pth_file = PthFile('.dotfile')
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
[email protected](hasattr(os, 'chflags'), 'test needs os.chflags()')
+def test_addsitedir_hidden_flags(self):
+pth_file = PthFile()
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+st = os.stat(pth_file.file_path)
+os.chflags(pth_file.file_path, st.st_flags | stat.UF_HIDDEN)
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
[email protected](sys.platform == 'win32', 'test needs Windows')
[email protected]_subprocess()
+def test_addsitedir_hidden_file_attribute(self):
+pth_file = PthFile()
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+subprocess.check_call(['attrib', '+H', pth_file.file_path])
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
 # This tests _getuserbase, hence the double underline
 # to distinguish from a test for getuserbase
 def test__getuserbase(self):
diff --git 
a/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst 
b/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
new file mode 100644
index 00..744687e72324d1
--- /dev/null
+++ b/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
@@ -0,0 +1 @@
+Skip ``.pth`` files with names starting with a dot or hidden file attribute.

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


[Python-checkins] [3.12] Fix 'expresion' typo in IDLE doc (GH-114130) (#114139)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/60f5f7513fa3513efa308162841a6efee5a34993
commit: 60f5f7513fa3513efa308162841a6efee5a34993
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy 
date: 2024-01-16T18:27:43Z
summary:

[3.12] Fix 'expresion' typo in IDLE doc (GH-114130) (#114139)

The substantive change is on line 577/593. Rest is header/footer stuff ignored 
when displaying.
(cherry picked from commit 7a24ecc953e1edc9c5bbedbd19cc587c3ff635ea)

Co-authored-by: Terry Jan Reedy 

files:
M Lib/idlelib/help.html

diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 722406b81a8ae6..2dc463735d691e 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -1,33 +1,31 @@
-
 
 
 
   
 
-http://docutils.sourceforge.net/"; />
+
 
-IDLE — Python 3.12.0a0 documentation
+IDLE — Python 3.13.0a2 documentation
 
 
-
+
+
 
 
-
-
-
 
+
 
 
 
 
 
 
 
 
 
-
+
 https://docs.python.org/3/library/idle.html"; />
 
 
@@ -41,35 +39,48 @@
 }
   }
 
-
+
+
 
 
+
+
 
   
 
 
 
-
-
-
 
- https://www.python.org/"; class="nav-logo">
- 
- 
-
-
-http://www.w3.org/2000/svg"; width="20" height="20" 
viewBox="0 0 24 24" class="search-icon">
-
-
-
-
-
+
+
+
+
+https://www.python.org/"; class="nav-logo">
+
+
+
+
+http://www.w3.org/2000/svg"; width="20" height="20" 
viewBox="0 0 24 24" class="search-icon">
+
+
+
+
+
+
 
 
 
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+
   
 Table of Contents
 
@@ -123,8 +134,8 @@ Table of Contents
   
   
 Previous topic
-tkinter.tix — 
Extension widgets for Tk
+tkinter.ttk — Tk 
themed widgets
   
   
 Next topic
@@ -160,7 +171,7 @@ Navigation
   next |
 
-  previous |
 
   
@@ -173,7 +184,7 @@ Navigation
 
   
 
-  3.12.0a0 Documentation »
+  3.13.0a2 Documentation »
 
 
   The Python 
Standard Library »
@@ -184,14 +195,21 @@ Navigation
 
 
 
-  
+  
   
-  
-  
 
 
  |
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+ |
 
   
 
@@ -531,16 +549,15 @@ Editor windows¶
 In this section, ‘C’ refers to the Control key on Windows and Unix and
 the Command key on 
macOS.
-
+
 Backspace deletes 
to the left; Del deletes to 
the right
 C-Backspace delete word left; C-Del delete word to the right
-Arrow keys and Page 
Up/Page Down to move around
+Arrow keys and Page 
Up/Page Down to move 
around
 C-LeftArrow and C-RightArrow moves by 
words
 Home/End go to begin/end of 
line
 C-Home/C-End go to begin/end of 
file
 Some useful Emacs bindings are inherited from Tcl/Tk:
-
-
+
 C-a beginning of line
 C-e end of line
 C-k kill line (but doesn’t put it in clipboard)
@@ -553,7 +570,6 @@ Key bindingsC-d delete next character
 
-
 
 
 Standard keybindings (like C-c to copy and C-v to paste)
@@ -574,7 +590,7 @@ Automatic indentationSearch and Replace¶
 Any selection becomes a search target.  However, only selections within
 a line work because searches are only performed within lines with the
-terminal newline removed.  If [x] Regular expresion is checked, the
+terminal newline removed.  If [x] Regular expression is checked, the
 target is interpreted according to the Python re module.
 
 
@@ -1077,8 +1093,8 @@ Table of Contents
   
   
 Previous topic
-tkinter.tix — 
Extension widgets for Tk
+tkinter.ttk — Tk 
themed widgets
   
   
 Next topic
@@ -1117,7 +1133,7 @@ Navigation
   next |
 
-  previous |
 
   
@@ -1130,7 +1146,7 @@ Navigation
 
   
 
-  3.12.0a0 Documentation »
+  3.13.0a2 Documentation »
 
 
   The Python 
Standard Library »
@@ -1141,19 +1157,26 @@ Navigation
 
 
 
-  
+  
   
-  
-  
 
 
  |
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+ |
 
   
 
 
-© Copyright 2001-2022, Python 
Software Foundation.
+© Copyright 2001-2024, Python 
Software Foundation.
 
 This page is licensed under the Python Software Foundation License Version 
2.
 
@@ -1167,11 +1190,11 @@ Navigation
 
 
 
-Last updated on Sep 03, 2022.
+Last updated on Jan 16, 2024 (16:17 UTC).
 Found a bug?
 
 
-Created 

[Python-checkins] [3.11] Fix 'expresion' typo in IDLE doc (GH-114130) (#114140)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/e7dcab355e8b8917861f234f412c7b3213481e29
commit: e7dcab355e8b8917861f234f412c7b3213481e29
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy 
date: 2024-01-16T18:31:25Z
summary:

[3.11] Fix 'expresion' typo in IDLE doc (GH-114130) (#114140)

The substantive change is on line 577/593. Rest is header/footer stuff ignored 
when displaying.
(cherry picked from commit 7a24ecc953e1edc9c5bbedbd19cc587c3ff635ea)

Co-authored-by: Terry Jan Reedy 

files:
M Lib/idlelib/help.html

diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 722406b81a8ae6..2dc463735d691e 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -1,33 +1,31 @@
-
 
 
 
   
 
-http://docutils.sourceforge.net/"; />
+
 
-IDLE — Python 3.12.0a0 documentation
+IDLE — Python 3.13.0a2 documentation
 
 
-
+
+
 
 
-
-
-
 
+
 
 
 
 
 
 
 
 
 
-
+
 https://docs.python.org/3/library/idle.html"; />
 
 
@@ -41,35 +39,48 @@
 }
   }
 
-
+
+
 
 
+
+
 
   
 
 
 
-
-
-
 
- https://www.python.org/"; class="nav-logo">
- 
- 
-
-
-http://www.w3.org/2000/svg"; width="20" height="20" 
viewBox="0 0 24 24" class="search-icon">
-
-
-
-
-
+
+
+
+
+https://www.python.org/"; class="nav-logo">
+
+
+
+
+http://www.w3.org/2000/svg"; width="20" height="20" 
viewBox="0 0 24 24" class="search-icon">
+
+
+
+
+
+
 
 
 
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+
   
 Table of Contents
 
@@ -123,8 +134,8 @@ Table of Contents
   
   
 Previous topic
-tkinter.tix — 
Extension widgets for Tk
+tkinter.ttk — Tk 
themed widgets
   
   
 Next topic
@@ -160,7 +171,7 @@ Navigation
   next |
 
-  previous |
 
   
@@ -173,7 +184,7 @@ Navigation
 
   
 
-  3.12.0a0 Documentation »
+  3.13.0a2 Documentation »
 
 
   The Python 
Standard Library »
@@ -184,14 +195,21 @@ Navigation
 
 
 
-  
+  
   
-  
-  
 
 
  |
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+ |
 
   
 
@@ -531,16 +549,15 @@ Editor windows¶
 In this section, ‘C’ refers to the Control key on Windows and Unix and
 the Command key on 
macOS.
-
+
 Backspace deletes 
to the left; Del deletes to 
the right
 C-Backspace delete word left; C-Del delete word to the right
-Arrow keys and Page 
Up/Page Down to move around
+Arrow keys and Page 
Up/Page Down to move 
around
 C-LeftArrow and C-RightArrow moves by 
words
 Home/End go to begin/end of 
line
 C-Home/C-End go to begin/end of 
file
 Some useful Emacs bindings are inherited from Tcl/Tk:
-
-
+
 C-a beginning of line
 C-e end of line
 C-k kill line (but doesn’t put it in clipboard)
@@ -553,7 +570,6 @@ Key bindingsC-d delete next character
 
-
 
 
 Standard keybindings (like C-c to copy and C-v to paste)
@@ -574,7 +590,7 @@ Automatic indentationSearch and Replace¶
 Any selection becomes a search target.  However, only selections within
 a line work because searches are only performed within lines with the
-terminal newline removed.  If [x] Regular expresion is checked, the
+terminal newline removed.  If [x] Regular expression is checked, the
 target is interpreted according to the Python re module.
 
 
@@ -1077,8 +1093,8 @@ Table of Contents
   
   
 Previous topic
-tkinter.tix — 
Extension widgets for Tk
+tkinter.ttk — Tk 
themed widgets
   
   
 Next topic
@@ -1117,7 +1133,7 @@ Navigation
   next |
 
-  previous |
 
   
@@ -1130,7 +1146,7 @@ Navigation
 
   
 
-  3.12.0a0 Documentation »
+  3.13.0a2 Documentation »
 
 
   The Python 
Standard Library »
@@ -1141,19 +1157,26 @@ Navigation
 
 
 
-  
+  
   
-  
-  
 
 
  |
 
+
+
+Theme
+
+Auto
+Light
+Dark
+
+ |
 
   
 
 
-© Copyright 2001-2022, Python 
Software Foundation.
+© Copyright 2001-2024, Python 
Software Foundation.
 
 This page is licensed under the Python Software Foundation License Version 
2.
 
@@ -1167,11 +1190,11 @@ Navigation
 
 
 
-Last updated on Sep 03, 2022.
+Last updated on Jan 16, 2024 (16:17 UTC).
 Found a bug?
 
 
-Created 

[Python-checkins] [3.11] gh-113659: Skip hidden .pth files (GH-113660) (GH-114144)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/21ab20b3a794ab5f64963706088af21574068f4c
commit: 21ab20b3a794ab5f64963706088af21574068f4c
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-16T18:56:31Z
summary:

[3.11] gh-113659: Skip hidden .pth files (GH-113660) (GH-114144)

Skip .pth files with names starting with a dot or hidden file attribute.
(cherry picked from commit 74208ed0c440244fb809d8acc97cb9ef51e888e3)

Co-authored-by: Serhiy Storchaka 

files:
A Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
M Lib/site.py
M Lib/test/test_site.py

diff --git a/Lib/site.py b/Lib/site.py
index 69670d9d7f2230..2904e44cffd735 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -74,6 +74,7 @@
 import builtins
 import _sitebuiltins
 import io
+import stat
 
 # Prefixes for site-packages; add additional prefixes like /usr/local here
 PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -168,6 +169,14 @@ def addpackage(sitedir, name, known_paths):
 else:
 reset = False
 fullname = os.path.join(sitedir, name)
+try:
+st = os.lstat(fullname)
+except OSError:
+return
+if ((getattr(st, 'st_flags', 0) & stat.UF_HIDDEN) or
+(getattr(st, 'st_file_attributes', 0) & stat.FILE_ATTRIBUTE_HIDDEN)):
+_trace(f"Skipping hidden .pth file: {fullname!r}")
+return
 _trace(f"Processing .pth file: {fullname!r}")
 try:
 # locale encoding is not ideal especially on Windows. But we have used
@@ -221,7 +230,8 @@ def addsitedir(sitedir, known_paths=None):
 names = os.listdir(sitedir)
 except OSError:
 return
-names = [name for name in names if name.endswith(".pth")]
+names = [name for name in names
+ if name.endswith(".pth") and not name.startswith(".")]
 for name in sorted(names):
 addpackage(sitedir, name, known_paths)
 if reset:
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 8d336649eca1d0..427f0b6abe05df 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -19,6 +19,7 @@
 import os
 import re
 import shutil
+import stat
 import subprocess
 import sys
 import sysconfig
@@ -195,6 +196,45 @@ def test_addsitedir(self):
 finally:
 pth_file.cleanup()
 
+def test_addsitedir_dotfile(self):
+pth_file = PthFile('.dotfile')
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
[email protected](hasattr(os, 'chflags'), 'test needs os.chflags()')
+def test_addsitedir_hidden_flags(self):
+pth_file = PthFile()
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+st = os.stat(pth_file.file_path)
+os.chflags(pth_file.file_path, st.st_flags | stat.UF_HIDDEN)
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
[email protected](sys.platform == 'win32', 'test needs Windows')
[email protected]_subprocess()
+def test_addsitedir_hidden_file_attribute(self):
+pth_file = PthFile()
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+subprocess.check_call(['attrib', '+H', pth_file.file_path])
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
 # This tests _getuserbase, hence the double underline
 # to distinguish from a test for getuserbase
 def test__getuserbase(self):
diff --git 
a/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst 
b/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
new file mode 100644
index 00..744687e72324d1
--- /dev/null
+++ b/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
@@ -0,0 +1 @@
+Skip ``.pth`` files with names starting with a dot or hidden file attribute.

___
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-113659: Skip hidden .pth files (GH-113660) (GH-114143)

2024-01-16 Thread serhiy-storchaka
https://github.com/python/cpython/commit/59da12613afd9241e5afed863315081788d1ce00
commit: 59da12613afd9241e5afed863315081788d1ce00
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-01-16T18:57:14Z
summary:

[3.12] gh-113659: Skip hidden .pth files (GH-113660) (GH-114143)

Skip .pth files with names starting with a dot or hidden file attribute.
(cherry picked from commit 74208ed0c440244fb809d8acc97cb9ef51e888e3)

Co-authored-by: Serhiy Storchaka 

files:
A Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
M Lib/site.py
M Lib/test/test_site.py

diff --git a/Lib/site.py b/Lib/site.py
index 672fa7b000ad02..924b2460d96976 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -74,6 +74,7 @@
 import builtins
 import _sitebuiltins
 import io
+import stat
 
 # Prefixes for site-packages; add additional prefixes like /usr/local here
 PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -168,6 +169,14 @@ def addpackage(sitedir, name, known_paths):
 else:
 reset = False
 fullname = os.path.join(sitedir, name)
+try:
+st = os.lstat(fullname)
+except OSError:
+return
+if ((getattr(st, 'st_flags', 0) & stat.UF_HIDDEN) or
+(getattr(st, 'st_file_attributes', 0) & stat.FILE_ATTRIBUTE_HIDDEN)):
+_trace(f"Skipping hidden .pth file: {fullname!r}")
+return
 _trace(f"Processing .pth file: {fullname!r}")
 try:
 # locale encoding is not ideal especially on Windows. But we have used
@@ -221,7 +230,8 @@ def addsitedir(sitedir, known_paths=None):
 names = os.listdir(sitedir)
 except OSError:
 return
-names = [name for name in names if name.endswith(".pth")]
+names = [name for name in names
+ if name.endswith(".pth") and not name.startswith(".")]
 for name in sorted(names):
 addpackage(sitedir, name, known_paths)
 if reset:
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 1aa06131f224ba..1a9c81d0d56aaf 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -18,6 +18,7 @@
 import os
 import re
 import shutil
+import stat
 import subprocess
 import sys
 import sysconfig
@@ -194,6 +195,45 @@ def test_addsitedir(self):
 finally:
 pth_file.cleanup()
 
+def test_addsitedir_dotfile(self):
+pth_file = PthFile('.dotfile')
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
[email protected](hasattr(os, 'chflags'), 'test needs os.chflags()')
+def test_addsitedir_hidden_flags(self):
+pth_file = PthFile()
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+st = os.stat(pth_file.file_path)
+os.chflags(pth_file.file_path, st.st_flags | stat.UF_HIDDEN)
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
[email protected](sys.platform == 'win32', 'test needs Windows')
[email protected]_subprocess()
+def test_addsitedir_hidden_file_attribute(self):
+pth_file = PthFile()
+pth_file.cleanup(prep=True)
+try:
+pth_file.create()
+subprocess.check_call(['attrib', '+H', pth_file.file_path])
+site.addsitedir(pth_file.base_dir, set())
+self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], 
sys.path)
+self.assertIn(pth_file.base_dir, sys.path)
+finally:
+pth_file.cleanup()
+
 # This tests _getuserbase, hence the double underline
 # to distinguish from a test for getuserbase
 def test__getuserbase(self):
diff --git 
a/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst 
b/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
new file mode 100644
index 00..744687e72324d1
--- /dev/null
+++ b/Misc/NEWS.d/next/Security/2024-01-02-19-52-23.gh-issue-113659.DkmnQc.rst
@@ -0,0 +1 @@
+Skip ``.pth`` files with names starting with a dot or hidden file attribute.

___
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] Clean up backslash avoiding code in ast, fix typo (#113605)

2024-01-16 Thread hauntsaninja
https://github.com/python/cpython/commit/3d5df54cdc1e946bd953bc9906da5abf78a48357
commit: 3d5df54cdc1e946bd953bc9906da5abf78a48357
branch: main
author: Shantanu <[email protected]>
committer: hauntsaninja <[email protected]>
date: 2024-01-16T11:24:25-08:00
summary:

Clean up backslash avoiding code in ast, fix typo (#113605)

As of #108553, the `_avoid_backslashes` code path is dead

`scape_newlines` was introduced in #110271. Happy to drop the typo fix
if we don't want it

files:
M Lib/ast.py

diff --git a/Lib/ast.py b/Lib/ast.py
index 7d3cd489942393..43703a8325cc5e 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -728,12 +728,11 @@ class _Unparser(NodeVisitor):
 output source code for the abstract syntax; original formatting
 is disregarded."""
 
-def __init__(self, *, _avoid_backslashes=False):
+def __init__(self):
 self._source = []
 self._precedences = {}
 self._type_ignores = {}
 self._indent = 0
-self._avoid_backslashes = _avoid_backslashes
 self._in_try_star = False
 
 def interleave(self, inter, f, seq):
@@ -1270,14 +1269,14 @@ def visit_JoinedStr(self, node):
 quote_type = quote_types[0]
 self.write(f"{quote_type}{value}{quote_type}")
 
-def _write_fstring_inner(self, node, scape_newlines=False):
+def _write_fstring_inner(self, node, escape_newlines=False):
 if isinstance(node, JoinedStr):
 # for both the f-string itself, and format_spec
 for value in node.values:
-self._write_fstring_inner(value, scape_newlines=scape_newlines)
+self._write_fstring_inner(value, 
escape_newlines=escape_newlines)
 elif isinstance(node, Constant) and isinstance(node.value, str):
 value = node.value.replace("{", "{{").replace("}", "}}")
-if scape_newlines:
+if escape_newlines:
 value = value.replace("\n", "\\n")
 self.write(value)
 elif isinstance(node, FormattedValue):
@@ -1303,7 +1302,7 @@ def unparse_inner(inner):
 self.write(":")
 self._write_fstring_inner(
 node.format_spec,
-scape_newlines=True
+escape_newlines=True
 )
 
 def visit_Name(self, node):
@@ -1324,8 +1323,6 @@ def _write_constant(self, value):
 .replace("inf", _INFSTR)
 .replace("nan", f"({_INFSTR}-{_INFSTR})")
 )
-elif self._avoid_backslashes and isinstance(value, str):
-self._write_str_avoiding_backslashes(value)
 else:
 self.write(repr(value))
 

___
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-114013: fix setting `HOSTRUNNER` for `Tools/wasm/wasi.py` (GH-114097)

2024-01-16 Thread brettcannon
https://github.com/python/cpython/commit/03f78397039760085b8ec07969835c89610bbc6d
commit: 03f78397039760085b8ec07969835c89610bbc6d
branch: main
author: Brett Cannon 
committer: brettcannon 
date: 2024-01-16T11:36:41-08:00
summary:

GH-114013: fix setting `HOSTRUNNER` for `Tools/wasm/wasi.py` (GH-114097)

Also fix tests found failing under a pydebug build of WASI thanks to `make 
test` working due to this change.

files:
A Misc/NEWS.d/next/Build/2024-01-15-16-58-43.gh-issue-114013.FoSeQf.rst
M Lib/test/test_isinstance.py
M Lib/test/test_richcmp.py
M Lib/test/test_typing.py
M Lib/test/test_userdict.py
M Lib/test/test_userlist.py
M Lib/test/test_xml_etree.py
M Tools/wasm/wasi.py

diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index 791981b878b1f2..7f759fb3317146 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -310,7 +310,7 @@ class X:
 @property
 def __bases__(self):
 return self.__bases__
-with support.infinite_recursion():
+with support.infinite_recursion(25):
 self.assertRaises(RecursionError, issubclass, X(), int)
 self.assertRaises(RecursionError, issubclass, int, X())
 self.assertRaises(RecursionError, isinstance, 1, X())
diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py
index 6fb31c80d7e670..5f449cdc05c6ba 100644
--- a/Lib/test/test_richcmp.py
+++ b/Lib/test/test_richcmp.py
@@ -221,7 +221,7 @@ def do(bad):
 self.assertRaises(Exc, func, Bad())
 
 @support.no_tracing
[email protected]_recursion()
[email protected]_recursion(25)
 def test_recursion(self):
 # Check that comparison for recursive objects fails gracefully
 from collections import UserList
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 8edab0cd6e34db..b684af4f33ed71 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -5684,7 +5684,7 @@ def fun(x: a): pass
 def cmp(o1, o2):
 return o1 == o2
 
-with infinite_recursion():
+with infinite_recursion(25):
 r1 = namespace1()
 r2 = namespace2()
 self.assertIsNot(r1, r2)
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index 9a03f2d04ce970..61e79f553e8ec9 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -215,7 +215,7 @@ class G(collections.UserDict):
 
 # Decorate existing test with recursion limit, because
 # the test is for C structure, but `UserDict` is a Python structure.
-test_repr_deep = support.infinite_recursion()(
+test_repr_deep = support.infinite_recursion(25)(
 mapping_tests.TestHashMappingProtocol.test_repr_deep,
 )
 
diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py
index 76d253753528b0..312702c8e398b9 100644
--- a/Lib/test/test_userlist.py
+++ b/Lib/test/test_userlist.py
@@ -69,7 +69,7 @@ def test_userlist_copy(self):
 
 # Decorate existing test with recursion limit, because
 # the test is for C structure, but `UserList` is a Python structure.
-test_repr_deep = support.infinite_recursion()(
+test_repr_deep = support.infinite_recursion(25)(
 list_tests.CommonTest.test_repr_deep,
 )
 
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 80ee064896f59a..b9e7937b0bbc00 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -2535,7 +2535,7 @@ def __eq__(self, o):
 e.extend([ET.Element('bar')])
 self.assertRaises(ValueError, e.remove, X('baz'))
 
[email protected]_recursion()
[email protected]_recursion(25)
 def test_recursive_repr(self):
 # Issue #25455
 e = ET.Element('foo')
diff --git 
a/Misc/NEWS.d/next/Build/2024-01-15-16-58-43.gh-issue-114013.FoSeQf.rst 
b/Misc/NEWS.d/next/Build/2024-01-15-16-58-43.gh-issue-114013.FoSeQf.rst
new file mode 100644
index 00..115050280016f9
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2024-01-15-16-58-43.gh-issue-114013.FoSeQf.rst
@@ -0,0 +1,4 @@
+Fix ``Tools/wasm/wasi.py`` to not include the path to ``python.wasm`` as
+part of ``HOSTRUNNER``. The environment variable is meant to specify how to
+run the WASI host only, having ``python.wasm`` and relevant flags appended
+to the ``HOSTRUNNER``. This fixes ``make test`` work.
diff --git a/Tools/wasm/wasi.py b/Tools/wasm/wasi.py
index 34c0e9375e24c8..36bc70ffd9db7b 100644
--- a/Tools/wasm/wasi.py
+++ b/Tools/wasm/wasi.py
@@ -233,9 +233,10 @@ def configure_wasi_python(context, working_dir):
  env=updated_env(env_additions | wasi_sdk_env(context)),
  quiet=context.quiet)
 
+python_wasm = working_dir / "python.wasm"
 exec_script = working_dir / "python.sh"
 with exec_script.open("w", encoding="utf-8") as file:
-file.write(f'#!/bin/sh\nexec {host_runner} "$@"\n')
+file.write(f'#!/bin/sh\nexec {host_runner} {python_wasm} "$@"\n')
 exec_script.chmo

[Python-checkins] Update copyright years to 2024. (GH-113608)

2024-01-16 Thread ambv
https://github.com/python/cpython/commit/c86571e4c9765a88ba05a7d9b874b40af0e1d6ab
commit: c86571e4c9765a88ba05a7d9b874b40af0e1d6ab
branch: main
author: solya0x <[email protected]>
committer: ambv 
date: 2024-01-16T21:54:05+01:00
summary:

Update copyright years to 2024. (GH-113608)

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

files:
M Doc/copyright.rst
M Doc/license.rst
M LICENSE
M Mac/IDLE/IDLE.app/Contents/Info.plist
M Mac/PythonLauncher/Info.plist.in
M Mac/Resources/app/Info.plist.in
M Mac/Resources/framework/Info.plist.in
M PC/python_ver_rc.h
M Python/getcopyright.c
M README.rst

diff --git a/Doc/copyright.rst b/Doc/copyright.rst
index 9b71683155eebe..8629ed1fc38009 100644
--- a/Doc/copyright.rst
+++ b/Doc/copyright.rst
@@ -4,7 +4,7 @@ Copyright
 
 Python and this documentation is:
 
-Copyright © 2001-2023 Python Software Foundation. All rights reserved.
+Copyright © 2001-2024 Python Software Foundation. All rights reserved.
 
 Copyright © 2000 BeOpen.com. All rights reserved.
 
diff --git a/Doc/license.rst b/Doc/license.rst
index fa0b32c347c914..9fc0ff7161a591 100644
--- a/Doc/license.rst
+++ b/Doc/license.rst
@@ -100,7 +100,7 @@ PSF LICENSE AGREEMENT FOR PYTHON |release|
   analyze, test, perform and/or display publicly, prepare derivative works,
   distribute, and otherwise use Python |release| alone or in any derivative
   version, provided, however, that PSF's License Agreement and PSF's 
notice of
-  copyright, i.e., "Copyright © 2001-2023 Python Software Foundation; All 
Rights
+  copyright, i.e., "Copyright © 2001-2024 Python Software Foundation; All 
Rights
   Reserved" are retained in Python |release| alone or in any derivative 
version
   prepared by Licensee.
 
diff --git a/LICENSE b/LICENSE
index f26bcf4d2de6eb..14603b95c2e23b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -83,10 +83,8 @@ grants Licensee a nonexclusive, royalty-free, world-wide 
license to reproduce,
 analyze, test, perform and/or display publicly, prepare derivative works,
 distribute, and otherwise use Python alone or in any derivative version,
 provided, however, that PSF's License Agreement and PSF's notice of copyright,
-i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 
2010,
-2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 
Python Software Foundation;
-All Rights Reserved" are retained in Python alone or in any derivative version
-prepared by Licensee.
+i.e., "Copyright (c) 2001-2024 Python Software Foundation; All Rights Reserved"
+are retained in Python alone or in any derivative version prepared by Licensee.
 
 3. In the event Licensee prepares a derivative work that is based on
 or incorporates Python or any part thereof, and wants to make
diff --git a/Mac/IDLE/IDLE.app/Contents/Info.plist 
b/Mac/IDLE/IDLE.app/Contents/Info.plist
index 20b97b67f41d1a..8549e405e2a65a 100644
--- a/Mac/IDLE/IDLE.app/Contents/Info.plist
+++ b/Mac/IDLE/IDLE.app/Contents/Info.plist
@@ -37,7 +37,7 @@
CFBundleExecutable
IDLE
CFBundleGetInfoString
-   %version%, © 2001-2023 Python Software Foundation
+   %version%, © 2001-2024 Python Software Foundation
CFBundleIconFile
IDLE.icns
CFBundleIdentifier
diff --git a/Mac/PythonLauncher/Info.plist.in b/Mac/PythonLauncher/Info.plist.in
index b7cddac0729fc2..233694788ac2b7 100644
--- a/Mac/PythonLauncher/Info.plist.in
+++ b/Mac/PythonLauncher/Info.plist.in
@@ -40,9 +40,9 @@
CFBundleExecutable
Python Launcher
NSHumanReadableCopyright
-   Copyright © 2001-2023 Python Software Foundation
+   Copyright © 2001-2024 Python Software Foundation
CFBundleGetInfoString
-   %VERSION%, © 2001-2023 Python Software Foundation
+   %VERSION%, © 2001-2024 Python Software Foundation
CFBundleIconFile
PythonLauncher.icns
CFBundleIdentifier
diff --git a/Mac/Resources/app/Info.plist.in b/Mac/Resources/app/Info.plist.in
index 8362b19b361b62..a1fc1511c40e96 100644
--- a/Mac/Resources/app/Info.plist.in
+++ b/Mac/Resources/app/Info.plist.in
@@ -20,7 +20,7 @@
CFBundleExecutable
Python
CFBundleGetInfoString
-   %version%, (c) 2001-2023 Python Software Foundation.
+   %version%, (c) 2001-2024 Python Software Foundation.
CFBundleHelpBookFolder

Documentation
@@ -37,7 +37,7 @@
CFBundleInfoDictionaryVersion
6.0
CFBundleLongVersionString
-   %version%, (c) 2001-2023 Python Software Foundation.
+   %version%, (c) 2001-2024 Python Software Foundation.
CFBundleName
Python
CFBundlePackageType
@@ -55,7 +55,7 @@
NSAppleScriptEnabled

NSHumanReadableCopyright
-   (c) 2001-2023 Python Software Foundation.
+   (c) 2001-2024 Python Software Foundation.
NSHighResolutionCapable

CFBundleAllowMixedLocalizations
diff

[Python-checkins] gh-112529: Track if debug allocator is used as underlying allocator (#113747)

2024-01-16 Thread DinoV
https://github.com/python/cpython/commit/b331381485c1965d1c88b7aee7ae9604aca05758
commit: b331381485c1965d1c88b7aee7ae9604aca05758
branch: main
author: Sam Gross 
committer: DinoV 
date: 2024-01-16T13:42:15-08:00
summary:

gh-112529: Track if debug allocator is used as underlying allocator (#113747)

* gh-112529: Track if debug allocator is used as underlying allocator

The GC implementation for free-threaded builds will need to accurately
detect if the debug allocator is used because it affects the offset of
the Python object from the beginning of the memory allocation. The
current implementation of `_PyMem_DebugEnabled` only considers if the
debug allocator is the outer-most allocator; it doesn't handle the case
of "hooks" like tracemalloc being used on top of the debug allocator.

This change enables more accurate detection of the debug allocator by
tracking when debug hooks are enabled.

* Simplify _PyMem_DebugEnabled

files:
M Include/internal/pycore_pymem.h
M Include/internal/pycore_pymem_init.h
M Include/internal/pycore_runtime_init.h
M Objects/obmalloc.c

diff --git a/Include/internal/pycore_pymem.h b/Include/internal/pycore_pymem.h
index c49742e177a130..1a72d07b50b738 100644
--- a/Include/internal/pycore_pymem.h
+++ b/Include/internal/pycore_pymem.h
@@ -44,6 +44,7 @@ struct _pymem_allocators {
 debug_alloc_api_t mem;
 debug_alloc_api_t obj;
 } debug;
+int is_debug_enabled;
 PyObjectArenaAllocator obj_arena;
 };
 
@@ -106,6 +107,8 @@ extern int _PyMem_GetAllocatorName(
PYMEM_ALLOCATOR_NOT_SET does nothing. */
 extern int _PyMem_SetupAllocators(PyMemAllocatorName allocator);
 
+/* Is the debug allocator enabled? */
+extern int _PyMem_DebugEnabled(void);
 
 #ifdef __cplusplus
 }
diff --git a/Include/internal/pycore_pymem_init.h 
b/Include/internal/pycore_pymem_init.h
index 360fb9218a9cda..96c49ed7338d6d 100644
--- a/Include/internal/pycore_pymem_init.h
+++ b/Include/internal/pycore_pymem_init.h
@@ -70,6 +70,7 @@ extern void _PyMem_ArenaFree(void *, void *, size_t);
 PYDBGMEM_ALLOC(runtime), \
 PYDBGOBJ_ALLOC(runtime), \
 }
+# define _pymem_is_debug_enabled_INIT 1
 #else
 # define _pymem_allocators_standard_INIT(runtime) \
 { \
@@ -77,6 +78,7 @@ extern void _PyMem_ArenaFree(void *, void *, size_t);
 PYMEM_ALLOC, \
 PYOBJ_ALLOC, \
 }
+# define _pymem_is_debug_enabled_INIT 0
 #endif
 
 #define _pymem_allocators_debug_INIT \
diff --git a/Include/internal/pycore_runtime_init.h 
b/Include/internal/pycore_runtime_init.h
index d324a94278839c..5f47d60de37825 100644
--- a/Include/internal/pycore_runtime_init.h
+++ b/Include/internal/pycore_runtime_init.h
@@ -86,6 +86,7 @@ extern PyTypeObject _PyExc_MemoryError;
 .standard = _pymem_allocators_standard_INIT(runtime), \
 .debug = _pymem_allocators_debug_INIT, \
 .obj_arena = _pymem_allocators_obj_arena_INIT, \
+.is_debug_enabled = _pymem_is_debug_enabled_INIT, \
 }, \
 .obmalloc = _obmalloc_global_state_INIT, \
 .pyhash_state = pyhash_state_INIT, \
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 88ad305ad776b0..16d5bcb53e7eb7 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -439,12 +439,14 @@ set_up_allocators_unlocked(PyMemAllocatorName allocator)
 (void)set_default_allocator_unlocked(PYMEM_DOMAIN_RAW, pydebug, NULL);
 (void)set_default_allocator_unlocked(PYMEM_DOMAIN_MEM, pydebug, NULL);
 (void)set_default_allocator_unlocked(PYMEM_DOMAIN_OBJ, pydebug, NULL);
+_PyRuntime.allocators.is_debug_enabled = pydebug;
 break;
 
 case PYMEM_ALLOCATOR_DEBUG:
 (void)set_default_allocator_unlocked(PYMEM_DOMAIN_RAW, 1, NULL);
 (void)set_default_allocator_unlocked(PYMEM_DOMAIN_MEM, 1, NULL);
 (void)set_default_allocator_unlocked(PYMEM_DOMAIN_OBJ, 1, NULL);
+_PyRuntime.allocators.is_debug_enabled = 1;
 break;
 
 #ifdef WITH_PYMALLOC
@@ -458,7 +460,9 @@ set_up_allocators_unlocked(PyMemAllocatorName allocator)
 set_allocator_unlocked(PYMEM_DOMAIN_MEM, &pymalloc);
 set_allocator_unlocked(PYMEM_DOMAIN_OBJ, &pymalloc);
 
-if (allocator == PYMEM_ALLOCATOR_PYMALLOC_DEBUG) {
+int is_debug = (allocator == PYMEM_ALLOCATOR_PYMALLOC_DEBUG);
+_PyRuntime.allocators.is_debug_enabled = is_debug;
+if (is_debug) {
 set_up_debug_hooks_unlocked();
 }
 break;
@@ -477,7 +481,9 @@ set_up_allocators_unlocked(PyMemAllocatorName allocator)
 PyMemAllocatorEx objmalloc = MIMALLOC_OBJALLOC;
 set_allocator_unlocked(PYMEM_DOMAIN_OBJ, &objmalloc);
 
-if (allocator == PYMEM_ALLOCATOR_MIMALLOC_DEBUG) {
+int is_debug = (allocator == PYMEM_ALLOCATOR_MIMALLOC_DEBUG);
+_PyRuntime.allocators.is_debug_enabled = is_debug;
+if (is_debug) {
 set_up_debug_hooks_unlocked();
 }
 
@@ -493,7 +499,9 @@ set_up_allocators_unlocked(PyMemA

[Python-checkins] gh-113655: Increase default stack size for PGO builds to avoid C stack exhaustion (GH-114148)

2024-01-16 Thread zooba
https://github.com/python/cpython/commit/2e672f7ca67470cbda3346a4b1b532cf5fa61799
commit: 2e672f7ca67470cbda3346a4b1b532cf5fa61799
branch: main
author: Steve Dower 
committer: zooba 
date: 2024-01-16T22:02:20Z
summary:

gh-113655: Increase default stack size for PGO builds to avoid C stack 
exhaustion (GH-114148)

files:
M PCbuild/python.vcxproj
M PCbuild/pythonw.vcxproj

diff --git a/PCbuild/python.vcxproj b/PCbuild/python.vcxproj
index 8b733865962373..fdf573aa5bf983 100644
--- a/PCbuild/python.vcxproj
+++ b/PCbuild/python.vcxproj
@@ -94,8 +94,11 @@
 
 
   Console
-  200
+  200
   1200
+  1200
+  
+  300
 
   
   
diff --git a/PCbuild/pythonw.vcxproj b/PCbuild/pythonw.vcxproj
index e23635e5ea9411..31f21308e25fb3 100644
--- a/PCbuild/pythonw.vcxproj
+++ b/PCbuild/pythonw.vcxproj
@@ -89,8 +89,11 @@
   
   
 
-  200
-  800
+  200
+  1200
+  1200
+  
+  300
 
   
   

___
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-78988: Document `pathlib.Path.glob()` exception propagation. (#114036)

2024-01-16 Thread barneygale
https://github.com/python/cpython/commit/7092b3f1319269accf4c02f08256d51f111b9ca3
commit: 7092b3f1319269accf4c02f08256d51f111b9ca3
branch: main
author: Barney Gale 
committer: barneygale 
date: 2024-01-16T22:28:54Z
summary:

GH-78988: Document `pathlib.Path.glob()` exception propagation. (#114036)

We propagate the `OSError` from the `is_dir()` call on the top-level
directory, and suppress all others.

files:
M Doc/library/pathlib.rst

diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 60791725c2323d..084d8bf4d3ca2b 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -993,6 +993,10 @@ call fails (for example because the path doesn't exist).
   Set *follow_symlinks* to ``True`` or ``False`` to improve performance
   of recursive globbing.
 
+   This method calls :meth:`Path.is_dir` on the top-level directory and
+   propagates any :exc:`OSError` exception that is raised. Subsequent
+   :exc:`OSError` exceptions from scanning directories are suppressed.
+
By default, or when the *case_sensitive* keyword-only argument is set to
``None``, this method matches paths using platform-specific casing rules:
typically, case-sensitive on POSIX, and case-insensitive on Windows.

___
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-94220: Align fnmatch docs with the implementation and amend markup (#114152)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/6e84f3b56f445b56ab48723d636c0a17090298ab
commit: 6e84f3b56f445b56ab48723d636c0a17090298ab
branch: main
author: Erlend E. Aasland 
committer: erlend-aasland 
date: 2024-01-16T22:35:09Z
summary:

gh-94220: Align fnmatch docs with the implementation and amend markup (#114152)

- Align the argument spec for fnmatch functions with the actual
  implementation.
- Update Sphinx markup to recent recommandations.
- Add link to 'iterable' glossary entry.

Co-authored-by: Adam Turner <[email protected]>

files:
M Doc/library/fnmatch.rst

diff --git a/Doc/library/fnmatch.rst b/Doc/library/fnmatch.rst
index aed8991d44772f..7cddecd5e80887 100644
--- a/Doc/library/fnmatch.rst
+++ b/Doc/library/fnmatch.rst
@@ -50,10 +50,10 @@ Also note that :func:`functools.lru_cache` with the 
*maxsize* of 32768 is used t
 cache the compiled regex patterns in the following functions: :func:`fnmatch`,
 :func:`fnmatchcase`, :func:`.filter`.
 
-.. function:: fnmatch(filename, pattern)
+.. function:: fnmatch(name, pat)
 
-   Test whether the *filename* string matches the *pattern* string, returning
-   :const:`True` or :const:`False`.  Both parameters are case-normalized
+   Test whether the filename string *name* matches the pattern string *pat*,
+   returning ``True`` or ``False``.  Both parameters are case-normalized
using :func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a
case-sensitive comparison, regardless of whether that's standard for the
operating system.
@@ -69,22 +69,24 @@ cache the compiled regex patterns in the following 
functions: :func:`fnmatch`,
   print(file)
 
 
-.. function:: fnmatchcase(filename, pattern)
+.. function:: fnmatchcase(name, pat)
 
-   Test whether *filename* matches *pattern*, returning :const:`True` or
-   :const:`False`; the comparison is case-sensitive and does not apply
-   :func:`os.path.normcase`.
+   Test whether the filename string *name* matches the pattern string *pat*,
+   returning ``True`` or ``False``;
+   the comparison is case-sensitive and does not apply 
:func:`os.path.normcase`.
 
 
-.. function:: filter(names, pattern)
+.. function:: filter(names, pat)
 
-   Construct a list from those elements of the iterable *names* that match 
*pattern*. It is the same as
-   ``[n for n in names if fnmatch(n, pattern)]``, but implemented more 
efficiently.
+   Construct a list from those elements of the :term:`iterable` *names*
+   that match pattern *pat*.
+   It is the same as ``[n for n in names if fnmatch(n, pat)]``,
+   but implemented more efficiently.
 
 
-.. function:: translate(pattern)
+.. function:: translate(pat)
 
-   Return the shell-style *pattern* converted to a regular expression for
+   Return the shell-style pattern *pat* converted to a regular expression for
using with :func:`re.match`.
 
Example:

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


[Python-checkins] Fix typo in c_annotations.py comment (#108773)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/1d6989f9b081f936882973e45550663d7956a9d5
commit: 1d6989f9b081f936882973e45550663d7956a9d5
branch: main
author: Kuan-Wei Chiu 
committer: erlend-aasland 
date: 2024-01-16T23:36:01+01:00
summary:

Fix typo in c_annotations.py comment (#108773)

"compatability" => "compatibility"

files:
M Doc/tools/extensions/c_annotations.py

diff --git a/Doc/tools/extensions/c_annotations.py 
b/Doc/tools/extensions/c_annotations.py
index ba37634545c2cf..a8b6d8995e3f40 100644
--- a/Doc/tools/extensions/c_annotations.py
+++ b/Doc/tools/extensions/c_annotations.py
@@ -42,7 +42,7 @@
 }
 
 
-# Monkeypatch nodes.Node.findall for forwards compatability
+# Monkeypatch nodes.Node.findall for forwards compatibility
 # This patch can be dropped when the minimum Sphinx version is 4.4.0
 # or the minimum Docutils version is 0.18.1.
 if docutils.__version_info__ < (0, 18, 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] [3.12] GH-78988: Document `pathlib.Path.glob()` exception propagation. (GH-114036) (#114154)

2024-01-16 Thread barneygale
https://github.com/python/cpython/commit/0ee681a665da36267d9e87ece472b9a9c5da9c13
commit: 0ee681a665da36267d9e87ece472b9a9c5da9c13
branch: 3.12
author: Barney Gale 
committer: barneygale 
date: 2024-01-16T22:39:09Z
summary:

[3.12] GH-78988: Document `pathlib.Path.glob()` exception propagation. 
(GH-114036) (#114154)

We propagate the `OSError` from the `is_dir()` call on the top-level
directory, and suppress all others.

(cherry picked from commit 7092b3f1319269accf4c02f08256d51f111b9ca3)

files:
M Doc/library/pathlib.rst

diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index d8fa4a27a28a0b..46a4d10b11d602 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -916,6 +916,10 @@ call fails (for example because the path doesn't exist).
PosixPath('setup.py'),
PosixPath('test_pathlib.py')]
 
+   This method calls :meth:`Path.is_dir` on the top-level directory and
+   propagates any :exc:`OSError` exception that is raised. Subsequent
+   :exc:`OSError` exceptions from scanning directories are suppressed.
+
By default, or when the *case_sensitive* keyword-only argument is set to
``None``, this method matches paths using platform-specific casing rules:
typically, case-sensitive on POSIX, and case-insensitive on Windows.

___
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-94220: Align fnmatch docs with the implementation and amend markup (GH-114152) (#114155)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/50bb9c69e14f88965564b663d7088633691f5d6a
commit: 50bb9c69e14f88965564b663d7088633691f5d6a
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-16T23:42:29+01:00
summary:

[3.12] gh-94220: Align fnmatch docs with the implementation and amend markup 
(GH-114152) (#114155)

- Align the argument spec for fnmatch functions with the actual
  implementation.
- Update Sphinx markup to recent recommandations.
- Add link to 'iterable' glossary entry.

(cherry picked from commit 6e84f3b56f445b56ab48723d636c0a17090298ab)

Co-authored-by: Erlend E. Aasland 
Co-authored-by: Adam Turner <[email protected]>

files:
M Doc/library/fnmatch.rst

diff --git a/Doc/library/fnmatch.rst b/Doc/library/fnmatch.rst
index aed8991d44772f..7cddecd5e80887 100644
--- a/Doc/library/fnmatch.rst
+++ b/Doc/library/fnmatch.rst
@@ -50,10 +50,10 @@ Also note that :func:`functools.lru_cache` with the 
*maxsize* of 32768 is used t
 cache the compiled regex patterns in the following functions: :func:`fnmatch`,
 :func:`fnmatchcase`, :func:`.filter`.
 
-.. function:: fnmatch(filename, pattern)
+.. function:: fnmatch(name, pat)
 
-   Test whether the *filename* string matches the *pattern* string, returning
-   :const:`True` or :const:`False`.  Both parameters are case-normalized
+   Test whether the filename string *name* matches the pattern string *pat*,
+   returning ``True`` or ``False``.  Both parameters are case-normalized
using :func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a
case-sensitive comparison, regardless of whether that's standard for the
operating system.
@@ -69,22 +69,24 @@ cache the compiled regex patterns in the following 
functions: :func:`fnmatch`,
   print(file)
 
 
-.. function:: fnmatchcase(filename, pattern)
+.. function:: fnmatchcase(name, pat)
 
-   Test whether *filename* matches *pattern*, returning :const:`True` or
-   :const:`False`; the comparison is case-sensitive and does not apply
-   :func:`os.path.normcase`.
+   Test whether the filename string *name* matches the pattern string *pat*,
+   returning ``True`` or ``False``;
+   the comparison is case-sensitive and does not apply 
:func:`os.path.normcase`.
 
 
-.. function:: filter(names, pattern)
+.. function:: filter(names, pat)
 
-   Construct a list from those elements of the iterable *names* that match 
*pattern*. It is the same as
-   ``[n for n in names if fnmatch(n, pattern)]``, but implemented more 
efficiently.
+   Construct a list from those elements of the :term:`iterable` *names*
+   that match pattern *pat*.
+   It is the same as ``[n for n in names if fnmatch(n, pat)]``,
+   but implemented more efficiently.
 
 
-.. function:: translate(pattern)
+.. function:: translate(pat)
 
-   Return the shell-style *pattern* converted to a regular expression for
+   Return the shell-style pattern *pat* converted to a regular expression for
using with :func:`re.match`.
 
Example:

___
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-94220: Align fnmatch docs with the implementation and amend markup (GH-114152) (#114156)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/9351b5ddf13e0cff6e29621c11f2a45db6ff51be
commit: 9351b5ddf13e0cff6e29621c11f2a45db6ff51be
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-16T23:42:57+01:00
summary:

[3.11] gh-94220: Align fnmatch docs with the implementation and amend markup 
(GH-114152) (#114156)

- Align the argument spec for fnmatch functions with the actual
  implementation.
- Update Sphinx markup to recent recommandations.
- Add link to 'iterable' glossary entry.

(cherry picked from commit 6e84f3b56f445b56ab48723d636c0a17090298ab)

Co-authored-by: Erlend E. Aasland 
Co-authored-by: Adam Turner <[email protected]>

files:
M Doc/library/fnmatch.rst

diff --git a/Doc/library/fnmatch.rst b/Doc/library/fnmatch.rst
index aed8991d44772f..7cddecd5e80887 100644
--- a/Doc/library/fnmatch.rst
+++ b/Doc/library/fnmatch.rst
@@ -50,10 +50,10 @@ Also note that :func:`functools.lru_cache` with the 
*maxsize* of 32768 is used t
 cache the compiled regex patterns in the following functions: :func:`fnmatch`,
 :func:`fnmatchcase`, :func:`.filter`.
 
-.. function:: fnmatch(filename, pattern)
+.. function:: fnmatch(name, pat)
 
-   Test whether the *filename* string matches the *pattern* string, returning
-   :const:`True` or :const:`False`.  Both parameters are case-normalized
+   Test whether the filename string *name* matches the pattern string *pat*,
+   returning ``True`` or ``False``.  Both parameters are case-normalized
using :func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a
case-sensitive comparison, regardless of whether that's standard for the
operating system.
@@ -69,22 +69,24 @@ cache the compiled regex patterns in the following 
functions: :func:`fnmatch`,
   print(file)
 
 
-.. function:: fnmatchcase(filename, pattern)
+.. function:: fnmatchcase(name, pat)
 
-   Test whether *filename* matches *pattern*, returning :const:`True` or
-   :const:`False`; the comparison is case-sensitive and does not apply
-   :func:`os.path.normcase`.
+   Test whether the filename string *name* matches the pattern string *pat*,
+   returning ``True`` or ``False``;
+   the comparison is case-sensitive and does not apply 
:func:`os.path.normcase`.
 
 
-.. function:: filter(names, pattern)
+.. function:: filter(names, pat)
 
-   Construct a list from those elements of the iterable *names* that match 
*pattern*. It is the same as
-   ``[n for n in names if fnmatch(n, pattern)]``, but implemented more 
efficiently.
+   Construct a list from those elements of the :term:`iterable` *names*
+   that match pattern *pat*.
+   It is the same as ``[n for n in names if fnmatch(n, pat)]``,
+   but implemented more efficiently.
 
 
-.. function:: translate(pattern)
+.. function:: translate(pat)
 
-   Return the shell-style *pattern* converted to a regular expression for
+   Return the shell-style pattern *pat* converted to a regular expression for
using with :func:`re.match`.
 
Example:

___
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-110109: pathlib docs: bring `from_uri()` and `as_uri()` together. (#110312)

2024-01-16 Thread barneygale
https://github.com/python/cpython/commit/45e527dfb553a5687aad828260cda85f02b9b6f8
commit: 45e527dfb553a5687aad828260cda85f02b9b6f8
branch: main
author: Barney Gale 
committer: barneygale 
date: 2024-01-16T22:51:57Z
summary:

GH-110109: pathlib docs: bring `from_uri()` and `as_uri()` together. (#110312)

This is a very soft deprecation of `PurePath.as_uri()`. We instead document
it as a `Path` method, and add a couple of sentences mentioning that it's
also available in `PurePath`.

Co-authored-by: Adam Turner <[email protected]>

files:
M Doc/library/pathlib.rst

diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 084d8bf4d3ca2b..be207ca74e 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -485,19 +485,6 @@ Pure paths provide the following methods and properties:
   'c:/windows'
 
 
-.. method:: PurePath.as_uri()
-
-   Represent the path as a ``file`` URI.  :exc:`ValueError` is raised if
-   the path isn't absolute.
-
-  >>> p = PurePosixPath('/etc/passwd')
-  >>> p.as_uri()
-  'file:///etc/passwd'
-  >>> p = PureWindowsPath('c:/Windows')
-  >>> p.as_uri()
-  'file:///c:/Windows'
-
-
 .. method:: PurePath.is_absolute()
 
Return whether the path is absolute or not.  A path is considered absolute
@@ -813,6 +800,67 @@ bugs or failures in your application)::
UnsupportedOperation: cannot instantiate 'WindowsPath' on your system
 
 
+File URIs
+^
+
+Concrete path objects can be created from, and represented as, 'file' URIs
+conforming to :rfc:`8089`.
+
+.. note::
+
+   File URIs are not portable across machines with different
+   :ref:`filesystem encodings `.
+
+.. classmethod:: Path.from_uri(uri)
+
+   Return a new path object from parsing a 'file' URI. For example::
+
+  >>> p = Path.from_uri('file:///etc/hosts')
+  PosixPath('/etc/hosts')
+
+   On Windows, DOS device and UNC paths may be parsed from URIs::
+
+  >>> p = Path.from_uri('file:///c:/windows')
+  WindowsPath('c:/windows')
+  >>> p = Path.from_uri('file://server/share')
+  WindowsPath('//server/share')
+
+   Several variant forms are supported::
+
+  >>> p = Path.from_uri('file:server/share')
+  WindowsPath('//server/share')
+  >>> p = Path.from_uri('file:/server/share')
+  WindowsPath('//server/share')
+  >>> p = Path.from_uri('file:c:/windows')
+  WindowsPath('c:/windows')
+  >>> p = Path.from_uri('file:/c|/windows')
+  WindowsPath('c:/windows')
+
+   :exc:`ValueError` is raised if the URI does not start with ``file:``, or
+   the parsed path isn't absolute.
+
+   .. versionadded:: 3.13
+
+
+.. method:: Path.as_uri()
+
+   Represent the path as a 'file' URI.  :exc:`ValueError` is raised if
+   the path isn't absolute.
+
+   .. code-block:: pycon
+
+  >>> p = PosixPath('/etc/passwd')
+  >>> p.as_uri()
+  'file:///etc/passwd'
+  >>> p = WindowsPath('c:/Windows')
+  >>> p.as_uri()
+  'file:///c:/Windows'
+
+   For historical reasons, this method is also available from
+   :class:`PurePath` objects. However, its use of :func:`os.fsencode` makes
+   it strictly impure.
+
+
 Methods
 ^^^
 
@@ -853,42 +901,6 @@ call fails (for example because the path doesn't exist).
.. versionadded:: 3.5
 
 
-.. classmethod:: Path.from_uri(uri)
-
-   Return a new path object from parsing a 'file' URI conforming to
-   :rfc:`8089`. For example::
-
-   >>> p = Path.from_uri('file:///etc/hosts')
-   PosixPath('/etc/hosts')
-
-   On Windows, DOS device and UNC paths may be parsed from URIs::
-
-   >>> p = Path.from_uri('file:///c:/windows')
-   WindowsPath('c:/windows')
-   >>> p = Path.from_uri('file://server/share')
-   WindowsPath('//server/share')
-
-   Several variant forms are supported::
-
-   >>> p = Path.from_uri('file:server/share')
-   WindowsPath('//server/share')
-   >>> p = Path.from_uri('file:/server/share')
-   WindowsPath('//server/share')
-   >>> p = Path.from_uri('file:c:/windows')
-   WindowsPath('c:/windows')
-   >>> p = Path.from_uri('file:/c|/windows')
-   WindowsPath('c:/windows')
-
-   :exc:`ValueError` is raised if the URI does not start with ``file:``, or
-   the parsed path isn't absolute.
-
-   :func:`os.fsdecode` is used to decode percent-escaped byte sequences, and
-   so file URIs are not portable across machines with different
-   :ref:`filesystem encodings `.
-
-   .. versionadded:: 3.13
-
-
 .. method:: Path.stat(*, follow_symlinks=True)
 
Return a :class:`os.stat_result` object containing information about this 
path, like :func:`os.stat`.

___
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-106293: Fix typos in Objects/object_layout.md (#106294)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/60ca37fdee52cc4ff318b6e9ddbb260e8583b33b
commit: 60ca37fdee52cc4ff318b6e9ddbb260e8583b33b
branch: main
author: Mano Sriram 
committer: erlend-aasland 
date: 2024-01-16T23:11:15Z
summary:

gh-106293: Fix typos in Objects/object_layout.md (#106294)

Co-authored-by: Terry Jan Reedy 

files:
M Objects/object_layout.md

diff --git a/Objects/object_layout.md b/Objects/object_layout.md
index 3f7d72eb22f224..4f379bed8d77e2 100644
--- a/Objects/object_layout.md
+++ b/Objects/object_layout.md
@@ -7,7 +7,7 @@ Each Python object starts with two fields:
 * ob_refcnt
 * ob_type
 
-which the form the header common to all Python objects, for all versions,
+which form the header common to all Python objects, for all versions,
 and hold the reference count and class of the object, respectively.
 
 ## Pre-header
@@ -36,7 +36,7 @@ and the ``dict`` field points to the dictionary.
 
 ## 3.12 pre-header
 
-In 3.12 the pointer to the list of weak references is added to the
+In 3.12, the pointer to the list of weak references is added to the
 pre-header. In order to make space for it, the ``dict`` and ``values``
 pointers are combined into a single tagged pointer:
 
@@ -62,7 +62,7 @@ the values pointer, to enable the (legacy) C-API function
 * ob_refcnt
 * ob_type
 
-For a "normal" Python object, that is one that doesn't inherit from a builtin
+For a "normal" Python object, one that doesn't inherit from a builtin
 class or have slots, the header and pre-header form the entire object.
 
 ![Layout of "normal" object in 3.12](./object_layout_312.png)

___
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-106293: Fix typos in Objects/object_layout.md (GH-106294) (#114158)

2024-01-16 Thread erlend-aasland
https://github.com/python/cpython/commit/b201a6a1f107ca3ff4201cb4dc3cd677db6cb52d
commit: b201a6a1f107ca3ff4201cb4dc3cd677db6cb52d
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland 
date: 2024-01-16T23:35:20Z
summary:

[3.12] gh-106293: Fix typos in Objects/object_layout.md (GH-106294) (#114158)

(cherry picked from commit 60ca37fdee52cc4ff318b6e9ddbb260e8583b33b)

Co-authored-by: Mano Sriram 
Co-authored-by: Terry Jan Reedy 

files:
M Objects/object_layout.md

diff --git a/Objects/object_layout.md b/Objects/object_layout.md
index 82483022a01442..894c4129de0327 100644
--- a/Objects/object_layout.md
+++ b/Objects/object_layout.md
@@ -7,7 +7,7 @@ Each Python object starts with two fields:
 * ob_refcnt
 * ob_type
 
-which the form the header common to all Python objects, for all versions,
+which form the header common to all Python objects, for all versions,
 and hold the reference count and class of the object, respectively.
 
 ## Pre-header
@@ -36,7 +36,7 @@ and the ``dict`` field points to the dictionary.
 
 ## 3.12 pre-header
 
-In 3.12 the pointer to the list of weak references is added to the
+In 3.12, the pointer to the list of weak references is added to the
 pre-header. In order to make space for it, the ``dict`` and ``values``
 pointers are combined into a single tagged pointer:
 
@@ -62,7 +62,7 @@ the values pointer, to enable the (legacy) C-API function
 * ob_refcnt
 * ob_type
 
-For a "normal" Python object, that is one that doesn't inherit from a builtin
+For a "normal" Python object, one that doesn't inherit from a builtin
 class or have slots, the header and pre-header form the entire object.
 
 ![Layout of "normal" object in 3.12](./object_layout_312.png)

___
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-88531 Fix dataclass __post_init__/__init__ interplay documentation (gh-107404)

2024-01-16 Thread ericvsmith
https://github.com/python/cpython/commit/05008c27b73da640b63c0d335c65ade517c0eb84
commit: 05008c27b73da640b63c0d335c65ade517c0eb84
branch: main
author: Steffen Zeile <[email protected]>
committer: ericvsmith 
date: 2024-01-16T20:17:34-05:00
summary:

gh-88531 Fix dataclass __post_init__/__init__ interplay documentation 
(gh-107404)

* Simplify __post_init__ example usage. It applies to all base classes, not 
just dataclasses.

files:
M Doc/library/dataclasses.rst

diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index cb00d8fef8..cde147d1cbb501 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -536,10 +536,10 @@ class :meth:`~object.__init__` methods. If the base class 
has an :meth:`~object.
 that has to be called, it is common to call this method in a
 :meth:`__post_init__` method::
 
-@dataclass
 class Rectangle:
-height: float
-width: float
+def __init__(self, height, width):
+  self.height = height
+  self.width = width
 
 @dataclass
 class Square(Rectangle):

___
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-112043: Align concurrent.futures.Executor.map docs with implementation (#114153)

2024-01-16 Thread AA-Turner
https://github.com/python/cpython/commit/8d26db45df479a54eccd2aced7d8a5ea9fd0ffa5
commit: 8d26db45df479a54eccd2aced7d8a5ea9fd0ffa5
branch: main
author: Erlend E. Aasland 
committer: AA-Turner <[email protected]>
date: 2024-01-17T01:31:16Z
summary:

gh-112043: Align concurrent.futures.Executor.map docs with implementation 
(#114153)

The first parameter is named 'fn', not 'func'.

files:
M Doc/library/concurrent.futures.rst

diff --git a/Doc/library/concurrent.futures.rst 
b/Doc/library/concurrent.futures.rst
index deefb8606ead84..760e1196d7cf9a 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -39,14 +39,14 @@ Executor Objects
  future = executor.submit(pow, 323, 1235)
  print(future.result())
 
-   .. method:: map(func, *iterables, timeout=None, chunksize=1)
+   .. method:: map(fn, *iterables, timeout=None, chunksize=1)
 
-  Similar to :func:`map(func, *iterables) ` except:
+  Similar to :func:`map(fn, *iterables) ` except:
 
   * the *iterables* are collected immediately rather than lazily;
 
-  * *func* is executed asynchronously and several calls to
-*func* may be made concurrently.
+  * *fn* is executed asynchronously and several calls to
+*fn* may be made concurrently.
 
   The returned iterator raises a :exc:`TimeoutError`
   if :meth:`~iterator.__next__` is called and the result isn't available
@@ -54,7 +54,7 @@ Executor Objects
   *timeout* can be an int or a float.  If *timeout* is not specified or
   ``None``, there is no limit to the wait time.
 
-  If a *func* call raises an exception, then that exception will be
+  If a *fn* call raises an exception, then that exception will be
   raised when its value is retrieved from the iterator.
 
   When using :class:`ProcessPoolExecutor`, this method chops *iterables*

___
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-88531 Fix dataclass __post_init__/__init__ interplay documentation (gh-107404) (#114163)

2024-01-16 Thread AA-Turner
https://github.com/python/cpython/commit/b21dd364958c7b29893841cf8ec28f33d691cb9a
commit: b21dd364958c7b29893841cf8ec28f33d691cb9a
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-17T01:33:09Z
summary:

[3.11] gh-88531 Fix dataclass __post_init__/__init__ interplay documentation 
(gh-107404) (#114163)

* Simplify __post_init__ example usage. It applies to all base classes, not 
just dataclasses.
(cherry picked from commit 05008c27b73da640b63c0d335c65ade517c0eb84)

Co-authored-by: Steffen Zeile <[email protected]>

files:
M Doc/library/dataclasses.rst

diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index 915ff05d98a711..a1066c748a7762 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -529,10 +529,10 @@ class :meth:`~object.__init__` methods. If the base class 
has an :meth:`~object.
 that has to be called, it is common to call this method in a
 :meth:`!__post_init__` method::
 
-@dataclass
 class Rectangle:
-height: float
-width: float
+def __init__(self, height, width):
+  self.height = height
+  self.width = width
 
 @dataclass
 class Square(Rectangle):

___
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-88531 Fix dataclass __post_init__/__init__ interplay documentation (gh-107404) (#114162)

2024-01-16 Thread AA-Turner
https://github.com/python/cpython/commit/12c6424205561f45edbc1041faa8080de2d8def2
commit: 12c6424205561f45edbc1041faa8080de2d8def2
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-17T01:33:02Z
summary:

[3.12] gh-88531 Fix dataclass __post_init__/__init__ interplay documentation 
(gh-107404) (#114162)

* Simplify __post_init__ example usage. It applies to all base classes, not 
just dataclasses.
(cherry picked from commit 05008c27b73da640b63c0d335c65ade517c0eb84)

Co-authored-by: Steffen Zeile <[email protected]>

files:
M Doc/library/dataclasses.rst

diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index 1b2f6d454dab65..020818a0812f0c 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -534,10 +534,10 @@ class :meth:`~object.__init__` methods. If the base class 
has an :meth:`~object.
 that has to be called, it is common to call this method in a
 :meth:`__post_init__` method::
 
-@dataclass
 class Rectangle:
-height: float
-width: float
+def __init__(self, height, width):
+  self.height = height
+  self.width = width
 
 @dataclass
 class Square(Rectangle):

___
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-112043: Align concurrent.futures.Executor.map docs with implementation (GH-114153) (#114164)

2024-01-16 Thread AA-Turner
https://github.com/python/cpython/commit/5b08b24f895d69f5b981e61f140fe852303c8c0e
commit: 5b08b24f895d69f5b981e61f140fe852303c8c0e
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-17T01:37:30Z
summary:

[3.12] gh-112043: Align concurrent.futures.Executor.map docs with 
implementation (GH-114153) (#114164)

The first parameter is named 'fn', not 'func'.
(cherry picked from commit 8d26db45df479a54eccd2aced7d8a5ea9fd0ffa5)

Co-authored-by: Erlend E. Aasland 

files:
M Doc/library/concurrent.futures.rst

diff --git a/Doc/library/concurrent.futures.rst 
b/Doc/library/concurrent.futures.rst
index 163f170927b719..cc6df06e74cf27 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -39,14 +39,14 @@ Executor Objects
  future = executor.submit(pow, 323, 1235)
  print(future.result())
 
-   .. method:: map(func, *iterables, timeout=None, chunksize=1)
+   .. method:: map(fn, *iterables, timeout=None, chunksize=1)
 
-  Similar to :func:`map(func, *iterables) ` except:
+  Similar to :func:`map(fn, *iterables) ` except:
 
   * the *iterables* are collected immediately rather than lazily;
 
-  * *func* is executed asynchronously and several calls to
-*func* may be made concurrently.
+  * *fn* is executed asynchronously and several calls to
+*fn* may be made concurrently.
 
   The returned iterator raises a :exc:`TimeoutError`
   if :meth:`~iterator.__next__` is called and the result isn't available
@@ -54,7 +54,7 @@ Executor Objects
   *timeout* can be an int or a float.  If *timeout* is not specified or
   ``None``, there is no limit to the wait time.
 
-  If a *func* call raises an exception, then that exception will be
+  If a *fn* call raises an exception, then that exception will be
   raised when its value is retrieved from the iterator.
 
   When using :class:`ProcessPoolExecutor`, this method chops *iterables*

___
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-112043: Align concurrent.futures.Executor.map docs with implementation (GH-114153) (#114165)

2024-01-16 Thread AA-Turner
https://github.com/python/cpython/commit/644b4a1e87b08fb8e67a81cbe474d9c5178ae77c
commit: 644b4a1e87b08fb8e67a81cbe474d9c5178ae77c
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-17T01:38:06Z
summary:

[3.11] gh-112043: Align concurrent.futures.Executor.map docs with 
implementation (GH-114153) (#114165)

The first parameter is named 'fn', not 'func'.
(cherry picked from commit 8d26db45df479a54eccd2aced7d8a5ea9fd0ffa5)

Co-authored-by: Erlend E. Aasland 

files:
M Doc/library/concurrent.futures.rst

diff --git a/Doc/library/concurrent.futures.rst 
b/Doc/library/concurrent.futures.rst
index 8ab2c3a2be2d65..426ff2bf4ccce0 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -39,14 +39,14 @@ Executor Objects
  future = executor.submit(pow, 323, 1235)
  print(future.result())
 
-   .. method:: map(func, *iterables, timeout=None, chunksize=1)
+   .. method:: map(fn, *iterables, timeout=None, chunksize=1)
 
-  Similar to :func:`map(func, *iterables) ` except:
+  Similar to :func:`map(fn, *iterables) ` except:
 
   * the *iterables* are collected immediately rather than lazily;
 
-  * *func* is executed asynchronously and several calls to
-*func* may be made concurrently.
+  * *fn* is executed asynchronously and several calls to
+*fn* may be made concurrently.
 
   The returned iterator raises a :exc:`TimeoutError`
   if :meth:`~iterator.__next__` is called and the result isn't available
@@ -54,7 +54,7 @@ Executor Objects
   *timeout* can be an int or a float.  If *timeout* is not specified or
   ``None``, there is no limit to the wait time.
 
-  If a *func* call raises an exception, then that exception will be
+  If a *fn* call raises an exception, then that exception will be
   raised when its value is retrieved from the iterator.
 
   When using :class:`ProcessPoolExecutor`, this method chops *iterables*

___
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-81479: For Help => IDLE Doc, stop double-spacing some lists. (#114168)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/e07a400c310ad3bdd72bb0ae401991af17435e4d
commit: e07a400c310ad3bdd72bb0ae401991af17435e4d
branch: main
author: Terry Jan Reedy 
committer: terryjreedy 
date: 2024-01-17T05:24:59Z
summary:

gh-81479: For Help => IDLE Doc, stop double-spacing some lists. (#114168)

This matches Firefox format.  Edge double-spaces non-simple
list but I think it looks worse.

files:
M Lib/idlelib/help.py

diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py
index dfccfcb9bda89a..bdf4b2b29f11a2 100644
--- a/Lib/idlelib/help.py
+++ b/Lib/idlelib/help.py
@@ -102,7 +102,7 @@ def handle_starttag(self, tag, attrs):
 if self.level > 0:
 self.nested_dl = True
 elif tag == 'li':
-s = '\n* ' if self.simplelist else '\n\n* '
+s = '\n* '
 elif tag == 'dt':
 s = '\n\n' if not self.nested_dl else '\n'  # Avoid extra line.
 self.nested_dl = False

___
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-81479: For Help => IDLE Doc, stop double-spacing some lists. (GH-114168) (#114170)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/f1f2d204d13cdd541c0c32ee4d6763d49e79ac59
commit: f1f2d204d13cdd541c0c32ee4d6763d49e79ac59
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy 
date: 2024-01-17T01:35:15-05:00
summary:

[3.12] gh-81479: For Help => IDLE Doc, stop double-spacing some lists. 
(GH-114168) (#114170)

This matches Firefox format.  Edge double-spaces non-simple
lists but I think it looks worse.
(cherry picked from commit e07a400c310ad3bdd72bb0ae401991af17435e4d)

Co-authored-by: Terry Jan Reedy 

files:
M Lib/idlelib/help.py

diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py
index dfccfcb9bda89a..bdf4b2b29f11a2 100644
--- a/Lib/idlelib/help.py
+++ b/Lib/idlelib/help.py
@@ -102,7 +102,7 @@ def handle_starttag(self, tag, attrs):
 if self.level > 0:
 self.nested_dl = True
 elif tag == 'li':
-s = '\n* ' if self.simplelist else '\n\n* '
+s = '\n* '
 elif tag == 'dt':
 s = '\n\n' if not self.nested_dl else '\n'  # Avoid extra line.
 self.nested_dl = False

___
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-81479: For Help => IDLE Doc, stop double-spacing some lists. (GH-114168) (#114171)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/069cca7c2bcceb95aaf843bee32780f7720efa33
commit: 069cca7c2bcceb95aaf843bee32780f7720efa33
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy 
date: 2024-01-17T01:35:35-05:00
summary:

[3.11] gh-81479: For Help => IDLE Doc, stop double-spacing some lists. 
(GH-114168) (#114171)

This matches Firefox format.  Edge double-spaces non-simple
list but I think it looks worse.
(cherry picked from commit e07a400c310ad3bdd72bb0ae401991af17435e4d)

Co-authored-by: Terry Jan Reedy 

files:
M Lib/idlelib/help.py

diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py
index dfccfcb9bda89a..bdf4b2b29f11a2 100644
--- a/Lib/idlelib/help.py
+++ b/Lib/idlelib/help.py
@@ -102,7 +102,7 @@ def handle_starttag(self, tag, attrs):
 if self.level > 0:
 self.nested_dl = True
 elif tag == 'li':
-s = '\n* ' if self.simplelist else '\n\n* '
+s = '\n* '
 elif tag == 'dt':
 s = '\n\n' if not self.nested_dl else '\n'  # Avoid extra line.
 self.nested_dl = False

___
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-72284: Revise lists in IDLE doc (#114174)

2024-01-16 Thread terryjreedy
https://github.com/python/cpython/commit/4a32275389d94ba41f8881c32ad4b232effb1c6f
commit: 4a32275389d94ba41f8881c32ad4b232effb1c6f
branch: main
author: Terry Jan Reedy 
committer: terryjreedy 
date: 2024-01-17T07:52:32Z
summary:

gh-72284: Revise lists in IDLE doc  (#114174)

Tkinter is a fact, not necessarily a feature.

Reorganize editor key bindings in a logical order
and remove those that do not work, at least on Windows.

Improve shell bindings list.

files:
A Misc/NEWS.d/next/IDLE/2024-01-17-02-15-33.gh-issue-72284.cAQiYO.rst
M Doc/library/idle.rst
M Lib/idlelib/News3.txt
M Lib/idlelib/help.html

diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index e710d0bacf3fee..249dc0ea6ba735 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -18,8 +18,6 @@ IDLE is Python's Integrated Development and Learning 
Environment.
 
 IDLE has the following features:
 
-* coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit
-
 * cross-platform: works mostly the same on Windows, Unix, and macOS
 
 * Python shell window (interactive interpreter) with colorizing
@@ -422,41 +420,34 @@ and that other files do not.  Run Python code with the 
Run menu.
 Key bindings
 
 
-In this section, 'C' refers to the :kbd:`Control` key on Windows and Unix and
-the :kbd:`Command` key on macOS.
-
-* :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
-
-* :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right
-
-* Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around
-
-* :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words
+The IDLE insertion cursor is a thin vertical bar between character
+positions.  When characters are entered, the insertion cursor and
+everything to its right moves right one character and
+the new character is entered in the new space.
 
-* :kbd:`Home`/:kbd:`End` go to begin/end of line
+Several non-character keys move the cursor and possibly
+delete characters.  Deletion does not puts text on the clipboard,
+but IDLE has an undo list.  Wherever this doc discusses keys,
+'C' refers to the :kbd:`Control` key on Windows and
+Unix and the :kbd:`Command` key on macOS.  (And all such dicussions
+assume that the keys have not been re-bound to something else.)
 
-* :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file
+* Arrow keys move the cursor one character or line.
 
-* Some useful Emacs bindings are inherited from Tcl/Tk:
+* :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves left or right one word.
 
-  * :kbd:`C-a` beginning of line
+* :kbd:`Home` and :kbd:`End` go to the beginning or end of the line.
 
-  * :kbd:`C-e` end of line
+* :kbd:`Page Up` and :kbd:`Page Down` go up or down one screen.
 
-  * :kbd:`C-k` kill line (but doesn't put it in clipboard)
+* :kbd:`C-Home` and :kbd:`C-End` go to beginning or end of the file.
 
-  * :kbd:`C-l` center window around the insertion point
+* :kbd:`Backspace` and :kbd:`Del` (or :kbd:`C-d`) delete the previous
+  or next character.
 
-  * :kbd:`C-b` go backward one character without deleting (usually you can
-also use the cursor key for this)
+* :kbd:`C-Backspace` and :kbd:`C-Del` delete one word left or right.
 
-  * :kbd:`C-f` go forward one character without deleting (usually you can
-also use the cursor key for this)
-
-  * :kbd:`C-p` go up one line (usually you can also use the cursor key for
-this)
-
-  * :kbd:`C-d` delete next character
+* :kbd:`C-k` deletes ('kills') everything to the right.
 
 Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste)
 may work.  Keybindings are selected in the Configure IDLE dialog.
@@ -611,23 +602,18 @@ when one requests a restart on the Shell menu, or when 
one runs code
 in an editor window.
 
 The editing features described in previous subsections work when entering
-code interactively.  IDLE's Shell window also responds to the following keys.
-
-* :kbd:`C-c` interrupts executing command
-
-* :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt
-
-* :kbd:`Alt-/` (Expand word) is also useful to reduce typing
+code interactively.  IDLE's Shell window also responds to the following:
 
-  Command history
+* :kbd:`C-c` attemps to interrupt statement execution (but may fail).
 
-  * :kbd:`Alt-p` retrieves previous command matching what you have typed. On
-macOS use :kbd:`C-p`.
+* :kbd:`C-d` closes Shell if typed at a ``>>>`` prompt.
 
-  * :kbd:`Alt-n` retrieves next. On macOS use :kbd:`C-n`.
+* :kbd:`Alt-p` and :kbd:`Alt-n` (:kbd:`C-p` and :kbd:`C-n` on macOS)
+  retrieve to the current prompt the previous or next previously
+  entered statement that matches anything already typed.
 
-  * :kbd:`Return` while the cursor is on any previous command
-retrieves that command
+* :kbd:`Return` while the cursor is on any previous statement
+  appends the latter to anything already typed at the prompt.
 
 Text colors
 ^^^
diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt
index f6ddbca0e64b0