From f23fd5c0c56b07cabf8841872bb115bfe05207c0 Mon Sep 17 00:00:00 2001 From: Cody Maloney Date: Sun, 5 Jul 2026 18:18:39 -0700 Subject: [PATCH 1/3] Docs: Link os.chdir to context manager contextlib.chdir --- Doc/library/os.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 7b043f257ca0b57..dadc959eae49345 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -2180,6 +2180,11 @@ features: .. audit-event:: os.chdir path os.chdir + .. seealso:: + + Context manager :func:`contextlib.chdir` + Changes the working directory and restores the previous one on exit. + .. versionchanged:: 3.3 Added support for specifying *path* as a file descriptor on some platforms. From 4e1a54577f4fd8fabb2111b7396fb97727ac765f Mon Sep 17 00:00:00 2001 From: Cody Maloney Date: Sun, 5 Jul 2026 20:47:15 -0700 Subject: [PATCH 2/3] Tweak wording --- Doc/library/os.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index dadc959eae49345..17ba0d73f5454d0 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -2183,7 +2183,8 @@ features: .. seealso:: Context manager :func:`contextlib.chdir` - Changes the working directory and restores the previous one on exit. + Changes the working directory on entering and restores the previous one + on exit. .. versionchanged:: 3.3 Added support for specifying *path* as a file descriptor From e8f8768a64540602953eba5a9a3bee09262327bc Mon Sep 17 00:00:00 2001 From: Cody Maloney Date: Mon, 6 Jul 2026 08:31:32 -0700 Subject: [PATCH 3/3] Move to paragraph style Co-authored-by: Stan Ulbrych --- Doc/library/os.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 17ba0d73f5454d0..6331ba4a034c5c6 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -2182,9 +2182,8 @@ features: .. seealso:: - Context manager :func:`contextlib.chdir` - Changes the working directory on entering and restores the previous one - on exit. + The :func:`contextlib.chdir` context manager, which changes the current + working directory on entering and restores the previous one on exit. .. versionchanged:: 3.3 Added support for specifying *path* as a file descriptor