From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 9 Feb 2026 15:06:28 +0000 (+0100) Subject: [3.14] gh-134179: Use sys._clear_internal_caches() at test_cmd_line (GH-134180) ... X-Git-Tag: v3.14.4~312 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9cc8e4948c868f6199630256cc2bddb04ed33327;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-134179: Use sys._clear_internal_caches() at test_cmd_line (GH-134180) (#144631) gh-134179: Use sys._clear_internal_caches() at test_cmd_line (GH-134180) Use sys._clear_internal_caches() instead of deprecated sys._clear_type_cache() at test_cmd_line. (cherry picked from commit dd2da42ea479c32a4260463b47e1b58877d07bdc) Co-authored-by: alexey semenyuk --- diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index c17d749d4a17..ab65342f6208 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -9,7 +9,6 @@ import sysconfig import tempfile import textwrap import unittest -import warnings from test import support from test.support import os_helper from test.support import force_not_colorized @@ -937,21 +936,15 @@ class CmdLineTest(unittest.TestCase): @unittest.skipUnless(sysconfig.get_config_var('Py_TRACE_REFS'), "Requires --with-trace-refs build option") def test_python_dump_refs(self): - code = 'import sys; sys._clear_type_cache()' - # TODO: Remove warnings context manager once sys._clear_type_cache is removed - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFS='1') + code = 'import sys; sys._clear_internal_caches()' + rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFS='1') self.assertEqual(rc, 0) @unittest.skipUnless(sysconfig.get_config_var('Py_TRACE_REFS'), "Requires --with-trace-refs build option") def test_python_dump_refs_file(self): with tempfile.NamedTemporaryFile() as dump_file: - code = 'import sys; sys._clear_type_cache()' - # TODO: Remove warnings context manager once sys._clear_type_cache is removed - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFSFILE=dump_file.name) + code = 'import sys; sys._clear_internal_caches()' + rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFSFILE=dump_file.name) self.assertEqual(rc, 0) with open(dump_file.name, 'r') as file: contents = file.read()