summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe Laíns 🇵🇸 <lains@riseup.net>2025-01-20 17:03:44 (GMT)
committerGitHub <noreply@github.com>2025-01-20 17:03:44 (GMT)
commit0a6412f9cc9e694e76299cfbd73ec969b7d47af6 (patch)
treefbdfd878c0e331412ebe6cce137f53323192a072
parent38a99568763604ccec5d5027f0658100ad76876f (diff)
downloadcpython-0a6412f9cc9e694e76299cfbd73ec969b7d47af6.zip
cpython-0a6412f9cc9e694e76299cfbd73ec969b7d47af6.tar.gz
cpython-0a6412f9cc9e694e76299cfbd73ec969b7d47af6.tar.bz2
GH-129064: deprecate sysconfig.expand_makefile_vars (#129082)
-rw-r--r--Doc/deprecations/pending-removal-in-3.16.rst6
-rw-r--r--Lib/sysconfig/__init__.py9
-rw-r--r--Lib/test/test_sysconfig.py19
-rw-r--r--Misc/NEWS.d/next/Library/2025-01-20-16-02-38.gh-issue-129064.JXasgJ.rst2
4 files changed, 36 insertions, 0 deletions
diff --git a/Doc/deprecations/pending-removal-in-3.16.rst b/Doc/deprecations/pending-removal-in-3.16.rst
index 41b30de..58f7c01 100644
--- a/Doc/deprecations/pending-removal-in-3.16.rst
+++ b/Doc/deprecations/pending-removal-in-3.16.rst
@@ -80,6 +80,12 @@ Pending removal in Python 3.16
has been deprecated since Python 3.13.
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
+* :mod:`sysconfig`:
+
+ * The ``~sysconfig.expand_makefile_vars`` function
+ has been deprecated since Python 3.14.
+ Use the ``vars`` argument of :func:`sysconfig.get_paths` instead.
+
* :mod:`tarfile`:
* The undocumented and unused :attr:`!TarFile.tarfile` attribute
diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py
index ec9bb70..86dd391 100644
--- a/Lib/sysconfig/__init__.py
+++ b/Lib/sysconfig/__init__.py
@@ -716,6 +716,15 @@ def expand_makefile_vars(s, vars):
variable expansions; if 'vars' is the output of 'parse_makefile()',
you're fine. Returns a variable-expanded version of 's'.
"""
+
+ import warnings
+ warnings.warn(
+ 'sysconfig.expand_makefile_vars is deprecated and will be removed in '
+ 'Python 3.16. Use sysconfig.get_paths(vars=...) instead.',
+ DeprecationWarning,
+ stacklevel=2,
+ )
+
import re
_findvar1_rx = r"\$\(([A-Za-z][A-Za-z0-9_]*)\)"
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index ce504dc..a567602 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -711,5 +711,24 @@ class MakefileTests(unittest.TestCase):
})
+class DeprecationTests(unittest.TestCase):
+ def deprecated(self, removal_version, deprecation_msg=None, attribute_msg=None):
+ if sys.version_info >= removal_version:
+ return self.assertRaises(AttributeError, msg=attribute_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.',
+ ),
+ attribute_msg="module 'sysconfig' has no attribute 'expand_makefile_vars'",
+ ):
+ sysconfig.expand_makefile_vars('', {})
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Misc/NEWS.d/next/Library/2025-01-20-16-02-38.gh-issue-129064.JXasgJ.rst b/Misc/NEWS.d/next/Library/2025-01-20-16-02-38.gh-issue-129064.JXasgJ.rst
new file mode 100644
index 0000000..5939fdc
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-01-20-16-02-38.gh-issue-129064.JXasgJ.rst
@@ -0,0 +1,2 @@
+Deprecate ``sysconfig.expand_makefile_vars``, in favor of using
+:func:`sysconfig.get_paths` with the ``vars`` argument.