]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-134179: Use sys._clear_internal_caches() at test_cmd_line (#134180)
authoralexey semenyuk <alexsemenyuk88@gmail.com>
Mon, 9 Feb 2026 14:40:17 +0000 (19:40 +0500)
committerGitHub <noreply@github.com>
Mon, 9 Feb 2026 14:40:17 +0000 (15:40 +0100)
Use sys._clear_internal_caches() instead of deprecated sys._clear_type_cache() at test_cmd_line.

Lib/test/test_cmd_line.py

index 3ed7a360d64e3c5accf077943ffad7c4731deb4c..55e5f06c8071ea2cd3d6adc64455be80021120d3 100644 (file)
@@ -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
@@ -943,21 +942,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()