From 3850b51282006e34eede211a33c061fd5439a449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns=20=F0=9F=87=B5=F0=9F=87=B8?= Date: Mon, 20 Jan 2025 21:25:14 +0000 Subject: [PATCH 1/4] [3.13] GH-92897: schedule the check_home deprecation to 3.15 (GH-129102) (cherry picked from commit e52ab564da84540a7544cb829f262b0154efccae) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Filipe Laíns 🇵🇸 --- Doc/deprecations/pending-removal-in-3.15.rst | 5 +++ Lib/sysconfig/__init__.py | 11 +++++-- Lib/test/test_sysconfig.py | 33 +++++++++++++++++++ ...5-01-20-20-59-26.gh-issue-92897.G0xH8o.rst | 2 ++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-01-20-20-59-26.gh-issue-92897.G0xH8o.rst diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index 7e63567ce2ec0f..9c5f8950270858 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -55,6 +55,11 @@ Pending Removal in Python 3.15 This function is only useful for Jython support, has a confusing API, and is largely untested. +* :mod:`sysconfig`: + + * The ``check_home`` argument of :func:`sysconfig.is_python_build` has been + deprecated since Python 3.12. + * :mod:`threading`: * :func:`~threading.RLock` will take no arguments in Python 3.15. diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py index 7bcb737ff2cca3..510c7b9568a808 100644 --- a/Lib/sysconfig/__init__.py +++ b/Lib/sysconfig/__init__.py @@ -220,8 +220,15 @@ def _safe_realpath(path): def is_python_build(check_home=None): if check_home is not None: import warnings - warnings.warn("check_home argument is deprecated and ignored.", - DeprecationWarning, stacklevel=2) + warnings.warn( + ( + 'The check_home argument of sysconfig.is_python_build is ' + 'deprecated and its value is ignored. ' + 'It will be removed in Python 3.15.' + ), + DeprecationWarning, + stacklevel=2, + ) for fn in ("Setup", "Setup.local"): if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)): return True diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index bf534130212482..aedd0866585aa5 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -689,5 +689,38 @@ def test_parse_makefile(self): }) +class DeprecationTests(unittest.TestCase): + def deprecated(self, removal_version, deprecation_msg=None, error=Exception, error_msg=None): + if sys.version_info >= removal_version: + return self.assertRaises(error, msg=error_msg) + else: + return self.assertWarns(DeprecationWarning, msg=deprecation_msg) + + def test_expand_makefile_vars(self): + with self.deprecated( + removal_version=(3, 16), + deprecation_msg=( + 'sysconfig.expand_makefile_vars is deprecated and will be removed in ' + 'Python 3.16. Use sysconfig.get_paths(vars=...) instead.', + ), + error=AttributeError, + error_msg="module 'sysconfig' has no attribute 'expand_makefile_vars'", + ): + sysconfig.expand_makefile_vars('', {}) + + def test_is_python_build_check_home(self): + with self.deprecated( + removal_version=(3, 15), + deprecation_msg=( + 'The check_home argument of sysconfig.is_python_build is ' + 'deprecated and its value is ignored. ' + 'It will be removed in Python 3.15.' + ), + error=TypeError, + error_msg="is_python_build() takes 0 positional arguments but 1 were given", + ): + sysconfig.is_python_build('foo') + + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS.d/next/Library/2025-01-20-20-59-26.gh-issue-92897.G0xH8o.rst b/Misc/NEWS.d/next/Library/2025-01-20-20-59-26.gh-issue-92897.G0xH8o.rst new file mode 100644 index 00000000000000..632ca03bbf8dd2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-01-20-20-59-26.gh-issue-92897.G0xH8o.rst @@ -0,0 +1,2 @@ +Scheduled the deprecation of the ``check_home`` argument of +:func:`sysconfig.is_python_build` to Python 3.15. From ce7a0d2ba051fced505126b7acd67d0cd4348610 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 26 Feb 2025 16:10:19 +0200 Subject: [PATCH 2/4] Don't backport test_expand_makefile_vars --- Lib/test/test_sysconfig.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index aedd0866585aa5..aca02c06bc0438 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -696,18 +696,6 @@ def deprecated(self, removal_version, deprecation_msg=None, error=Exception, err else: return self.assertWarns(DeprecationWarning, msg=deprecation_msg) - def test_expand_makefile_vars(self): - with self.deprecated( - removal_version=(3, 16), - deprecation_msg=( - 'sysconfig.expand_makefile_vars is deprecated and will be removed in ' - 'Python 3.16. Use sysconfig.get_paths(vars=...) instead.', - ), - error=AttributeError, - error_msg="module 'sysconfig' has no attribute 'expand_makefile_vars'", - ): - sysconfig.expand_makefile_vars('', {}) - def test_is_python_build_check_home(self): with self.deprecated( removal_version=(3, 15), From a4b349a0ae329cb482f6e645d5bbf3cf17cfdf4c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 26 Feb 2025 16:44:47 +0200 Subject: [PATCH 3/4] Doc: the check_home deprecation has been scheduled for 3.15 --- Doc/deprecations/pending-removal-in-future.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/Doc/deprecations/pending-removal-in-future.rst b/Doc/deprecations/pending-removal-in-future.rst index fdca65c341209d..e3922d24fc6dd7 100644 --- a/Doc/deprecations/pending-removal-in-future.rst +++ b/Doc/deprecations/pending-removal-in-future.rst @@ -105,9 +105,6 @@ although there is currently no date scheduled for their removal. * ``ssl.TLSVersion.TLSv1`` * ``ssl.TLSVersion.TLSv1_1`` -* :func:`sysconfig.is_python_build` *check_home* parameter is deprecated and - ignored. - * :mod:`threading` methods: * :meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition.notify_all`. From 2b548a0b09463748368c3f6038d9c890c2fba100 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 26 Feb 2025 16:51:02 +0200 Subject: [PATCH 4/4] Formatting --- Doc/deprecations/pending-removal-in-3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index 9c5f8950270858..b607703b30bfff 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -57,7 +57,7 @@ Pending Removal in Python 3.15 * :mod:`sysconfig`: - * The ``check_home`` argument of :func:`sysconfig.is_python_build` has been + * The *check_home* argument of :func:`sysconfig.is_python_build` has been deprecated since Python 3.12. * :mod:`threading`: