Skip to content

gh-134179: use sys._clear_internal_caches isntead of deprecated sys._clear_type_cache at test_cmd_line #134180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
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
@@ -936,21 +935,15 @@ def test_python_asyncio_debug(self):

@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()
Loading
Oops, something went wrong.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant