https://github.com/python/cpython/commit/328187cc4fcdd578db42cf6a16c197c338…
commit: 328187cc4fcdd578db42cf6a16c197c3382157a7
branch: main
author: Barney Gale <barney.gale(a)gmail.com>
committer: barneygale <barney.gale(a)gmail.com>
date: 2024-11-30T18:39:39Z
summary:
GH-127381: pathlib ABCs: remove `PathBase.cwd()` and `home()` (#127427)
These classmethods presume that the user has retained the original
`__init__()` signature, which may not be the case. Also, many virtual
filesystems don't provide current or home directories.
files:
M Lib/pathlib/_abc.py
M Lib/pathlib/_local.py
M Lib/test/test_pathlib/test_pathlib_abc.py
diff --git a/Lib/pathlib/_abc.py b/Lib/pathlib/_abc.py
index 697f32985ff652..2b314b6c9a16bf 100644
--- a/Lib/pathlib/_abc.py
+++ b/Lib/pathlib/_abc.py
@@ -735,27 +735,12 @@ def absolute(self):
# Treat the root directory as the current working directory.
return self.with_segments('/', *self._raw_paths)
- @classmethod
- def cwd(cls):
- """Return a new path pointing to the current working directory."""
- # We call 'absolute()' rather than using 'os.getcwd()' directly to
- # enable users to replace the implementation of 'absolute()' in a
- # subclass and benefit from the new behaviour here. This works because
- # os.path.abspath('.') == os.getcwd().
- return cls().absolute()
-
def expanduser(self):
""" Return a new path with expanded ~ and ~user constructs
(as returned by os.path.expanduser)
"""
raise UnsupportedOperation(self._unsupported_msg('expanduser()'))
- @classmethod
- def home(cls):
- """Return a new path pointing to expanduser('~').
- """
- return cls("~").expanduser()
-
def readlink(self):
"""
Return the path to which the symbolic link points.
diff --git a/Lib/pathlib/_local.py b/Lib/pathlib/_local.py
index 25c1e3f44ea7e8..b5d9dc49f58463 100644
--- a/Lib/pathlib/_local.py
+++ b/Lib/pathlib/_local.py
@@ -726,6 +726,14 @@ def absolute(self):
tail.extend(self._tail)
return self._from_parsed_parts(drive, root, tail)
+ @classmethod
+ def cwd(cls):
+ """Return a new path pointing to the current working directory."""
+ cwd = os.getcwd()
+ path = cls(cwd)
+ path._str = cwd # getcwd() returns a normalized path
+ return path
+
def resolve(self, strict=False):
"""
Make the path absolute, resolving all symlinks on the way and also
@@ -907,6 +915,15 @@ def expanduser(self):
return self
+ @classmethod
+ def home(cls):
+ """Return a new path pointing to expanduser('~').
+ """
+ homedir = os.path.expanduser("~")
+ if homedir == "~":
+ raise RuntimeError("Could not determine home directory.")
+ return cls(homedir)
+
@classmethod
def from_uri(cls, uri):
"""Return a new path from the given 'file' URI."""
diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py
index 7ca35e3dc7ee00..af94ac039808f0 100644
--- a/Lib/test/test_pathlib/test_pathlib_abc.py
+++ b/Lib/test/test_pathlib/test_pathlib_abc.py
@@ -1371,9 +1371,7 @@ def test_unsupported_operation(self):
self.assertRaises(e, p.rglob, '*')
self.assertRaises(e, lambda: list(p.walk()))
self.assertRaises(e, p.absolute)
- self.assertRaises(e, P.cwd)
self.assertRaises(e, p.expanduser)
- self.assertRaises(e, p.home)
self.assertRaises(e, p.readlink)
self.assertRaises(e, p.symlink_to, 'foo')
self.assertRaises(e, p.hardlink_to, 'foo')
https://github.com/python/cpython/commit/c54b9ae199758713a96945c5ee5e50036a…
commit: c54b9ae199758713a96945c5ee5e50036a015413
branch: 3.13
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: hugovk <1324225+hugovk(a)users.noreply.github.com>
date: 2024-11-30T16:32:13Z
summary:
[3.13] summarize: Fix typo in stats (GH-127450) (#127454)
Co-authored-by: alm <alonme(a)users.noreply.github.com>
files:
M Tools/scripts/summarize_stats.py
diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py
index ffbc40e6a37f3d..a48a9fba48c5c2 100644
--- a/Tools/scripts/summarize_stats.py
+++ b/Tools/scripts/summarize_stats.py
@@ -477,7 +477,7 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
): (trace_too_long, attempts),
Doc(
"Trace too short",
- "A potential trace is abandoced because it it too short.",
+ "A potential trace is abandoned because it it too short.",
): (trace_too_short, attempts),
Doc(
"Inner loop found", "A trace is truncated because it has an inner loop"
https://github.com/python/cpython/commit/4e0a4cafe8d8ecb43db62aed1d5671af58…
commit: 4e0a4cafe8d8ecb43db62aed1d5671af583104e7
branch: main
author: alm <alonme(a)users.noreply.github.com>
committer: hugovk <1324225+hugovk(a)users.noreply.github.com>
date: 2024-11-30T18:07:54+02:00
summary:
summarize: Fix typo in stats (#127450)
files:
M Tools/scripts/summarize_stats.py
diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py
index 5793e5c649d6b3..abfdea78253760 100644
--- a/Tools/scripts/summarize_stats.py
+++ b/Tools/scripts/summarize_stats.py
@@ -483,7 +483,7 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
): (trace_too_long, attempts),
Doc(
"Trace too short",
- "A potential trace is abandoced because it it too short.",
+ "A potential trace is abandoned because it it too short.",
): (trace_too_short, attempts),
Doc(
"Inner loop found", "A trace is truncated because it has an inner loop"
https://github.com/python/cpython/commit/33ce8dcf791721fea563715f681dc1593a…
commit: 33ce8dcf791721fea563715f681dc1593a35b83b
branch: main
author: Yuki Kobayashi <drsuaimqjgar(a)gmail.com>
committer: Eclips4 <kirill.bast9(a)mail.ru>
date: 2024-11-30T15:01:15Z
summary:
Docs: Fix incorrect indents in `c-api/type.rst` (#127449)
files:
M Doc/c-api/type.rst
diff --git a/Doc/c-api/type.rst b/Doc/c-api/type.rst
index 86d3967d9fb577..444b3456f051d8 100644
--- a/Doc/c-api/type.rst
+++ b/Doc/c-api/type.rst
@@ -529,19 +529,19 @@ The following functions and structs are used to create
The following “offset” fields cannot be set using :c:type:`PyType_Slot`:
- * :c:member:`~PyTypeObject.tp_weaklistoffset`
- (use :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)
- * :c:member:`~PyTypeObject.tp_dictoffset`
- (use :c:macro:`Py_TPFLAGS_MANAGED_DICT` instead if possible)
- * :c:member:`~PyTypeObject.tp_vectorcall_offset`
- (use ``"__vectorcalloffset__"`` in
- :ref:`PyMemberDef <pymemberdef-offsets>`)
-
- If it is not possible to switch to a ``MANAGED`` flag (for example,
- for vectorcall or to support Python older than 3.12), specify the
- offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
- See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
- for details.
+ * :c:member:`~PyTypeObject.tp_weaklistoffset`
+ (use :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)
+ * :c:member:`~PyTypeObject.tp_dictoffset`
+ (use :c:macro:`Py_TPFLAGS_MANAGED_DICT` instead if possible)
+ * :c:member:`~PyTypeObject.tp_vectorcall_offset`
+ (use ``"__vectorcalloffset__"`` in
+ :ref:`PyMemberDef <pymemberdef-offsets>`)
+
+ If it is not possible to switch to a ``MANAGED`` flag (for example,
+ for vectorcall or to support Python older than 3.12), specify the
+ offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
+ See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
+ for details.
The following internal fields cannot be set at all when creating a heap
type:
@@ -557,20 +557,18 @@ The following functions and structs are used to create
To avoid issues, use the *bases* argument of
:c:func:`PyType_FromSpecWithBases` instead.
- .. versionchanged:: 3.9
-
- Slots in :c:type:`PyBufferProcs` may be set in the unlimited API.
+ .. versionchanged:: 3.9
+ Slots in :c:type:`PyBufferProcs` may be set in the unlimited API.
- .. versionchanged:: 3.11
- :c:member:`~PyBufferProcs.bf_getbuffer` and
- :c:member:`~PyBufferProcs.bf_releasebuffer` are now available
- under the :ref:`limited API <limited-c-api>`.
+ .. versionchanged:: 3.11
+ :c:member:`~PyBufferProcs.bf_getbuffer` and
+ :c:member:`~PyBufferProcs.bf_releasebuffer` are now available
+ under the :ref:`limited API <limited-c-api>`.
- .. versionchanged:: 3.14
-
- The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
- using ``Py_tp_vectorcall``. See the field's documentation
- for details.
+ .. versionchanged:: 3.14
+ The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
+ using ``Py_tp_vectorcall``. See the field's documentation
+ for details.
.. c:member:: void *pfunc
https://github.com/python/cpython/commit/ea8a85bb9eb54b9edee1a815cff797310e…
commit: ea8a85bb9eb54b9edee1a815cff797310ec13f13
branch: 3.12
author: Bénédikt Tran <10796600+picnixz(a)users.noreply.github.com>
committer: kumaraditya303 <kumaraditya(a)python.org>
date: 2024-11-30T10:02:07Z
summary:
[3.12] Link to correct class methods in asyncio primitives docs (GH-127270) (#127438)
files:
M Doc/library/asyncio-sync.rst
diff --git a/Doc/library/asyncio-sync.rst b/Doc/library/asyncio-sync.rst
index 05bdf5488af143..4caa8b9b47564a 100644
--- a/Doc/library/asyncio-sync.rst
+++ b/Doc/library/asyncio-sync.rst
@@ -262,8 +262,9 @@ Condition
Wait until a predicate becomes *true*.
The predicate must be a callable which result will be
- interpreted as a boolean value. The final value is the
- return value.
+ interpreted as a boolean value. The method will repeatedly
+ :meth:`~Condition.wait` until the predicate evaluates to *true*.
+ The final value is the return value.
Semaphore
@@ -428,7 +429,7 @@ Barrier
.. coroutinemethod:: abort()
Put the barrier into a broken state. This causes any active or future
- calls to :meth:`wait` to fail with the :class:`BrokenBarrierError`.
+ calls to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`.
Use this for example if one of the tasks needs to abort, to avoid infinite
waiting tasks.