From e52ab564da84540a7544cb829f262b0154efccae 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: GH-92897: schedule the check_home deprecation to 3.15 (#129102) --- Doc/deprecations/pending-removal-in-3.15.rst | 5 +++++ Lib/sysconfig/__init__.py | 11 +++++++++-- Lib/test/test_sysconfig.py | 20 +++++++++++++++++--- .../2025-01-20-20-59-26.gh-issue-92897.G0xH8o.rst | 2 ++ 4 files changed, 33 insertions(+), 5 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 3b03e1f..390bbff 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -51,6 +51,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 86dd391..3c3c979 100644 --- a/Lib/sysconfig/__init__.py +++ b/Lib/sysconfig/__init__.py @@ -220,8 +220,15 @@ if "_PYTHON_PROJECT_BASE" in os.environ: 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 a567602..1002d90 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -712,9 +712,9 @@ class MakefileTests(unittest.TestCase): class DeprecationTests(unittest.TestCase): - def deprecated(self, removal_version, deprecation_msg=None, attribute_msg=None): + def deprecated(self, removal_version, deprecation_msg=None, error=Exception, error_msg=None): if sys.version_info >= removal_version: - return self.assertRaises(AttributeError, msg=attribute_msg) + return self.assertRaises(error, msg=error_msg) else: return self.assertWarns(DeprecationWarning, msg=deprecation_msg) @@ -725,10 +725,24 @@ class DeprecationTests(unittest.TestCase): 'sysconfig.expand_makefile_vars is deprecated and will be removed in ' 'Python 3.16. Use sysconfig.get_paths(vars=...) instead.', ), - attribute_msg="module 'sysconfig' has no attribute 'expand_makefile_vars'", + 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 0000000..632ca03 --- /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. -- cgit v0.12