-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-129027: Raise DeprecationWarning for sys._clear_type_cache #129043
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
Changes from 1 commit
bac8a24
3d2bca7
4b45930
8366a2d
0310eb2
c98e6dc
da4c9c1
bc1844e
bb4d5e4
160f0f7
aa1cc67
a19ea6b
edb99cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| import unittest | ||
| from test import support | ||
| from test.support import os_helper | ||
| from test.support import force_not_colorized | ||
| from test.support import force_not_colorized, warnings_helper | ||
| from test.support import threading_helper | ||
| from test.support.script_helper import ( | ||
| spawn_python, kill_python, assert_python_ok, assert_python_failure, | ||
|
|
@@ -932,12 +932,14 @@ def test_python_asyncio_debug(self): | |
| self.assertIn(b'True', out) | ||
|
|
||
| @unittest.skipUnless(sysconfig.get_config_var('Py_TRACE_REFS'), "Requires --with-trace-refs build option") | ||
| @warnings_helper.ignore_warnings(category=DeprecationWarning) | ||
|
||
| def test_python_dump_refs(self): | ||
| code = 'import sys; sys._clear_type_cache()' | ||
| 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") | ||
| @warnings_helper.ignore_warnings(category=DeprecationWarning) | ||
|
||
| def test_python_dump_refs_file(self): | ||
| with tempfile.NamedTemporaryFile() as dump_file: | ||
| code = 'import sys; sys._clear_type_cache()' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,10 @@ | |
| import unittest | ||
| import dis | ||
| from test import support | ||
| from test.support import import_helper, requires_specialization, requires_specialization_ft | ||
| from test.support import ( | ||
| import_helper, requires_specialization, | ||
| requires_specialization_ft, warnings_helper | ||
| ) | ||
| try: | ||
| from sys import _clear_type_cache | ||
| except ImportError: | ||
|
|
@@ -15,11 +18,13 @@ | |
| type_assign_specific_version_unsafe = _testinternalcapi.type_assign_specific_version_unsafe | ||
| type_assign_version = _testcapi.type_assign_version | ||
| type_modified = _testcapi.type_modified | ||
| ignore_deprecation = warnings_helper.ignore_warnings(category=DeprecationWarning) | ||
|
||
|
|
||
|
|
||
| @support.cpython_only | ||
| @unittest.skipIf(_clear_type_cache is None, "requires sys._clear_type_cache") | ||
| class TypeCacheTests(unittest.TestCase): | ||
| @ignore_deprecation | ||
srinivasreddy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def test_tp_version_tag_unique(self): | ||
| """tp_version_tag should be unique assuming no overflow, even after | ||
| clearing type cache. | ||
|
|
@@ -61,6 +66,7 @@ class C: | |
| self.assertNotEqual(type_get_version(C), 0) | ||
| self.assertNotEqual(type_get_version(C), c_ver) | ||
|
|
||
| @ignore_deprecation | ||
|
||
| def test_type_assign_specific_version(self): | ||
| """meta-test for type_assign_specific_version_unsafe""" | ||
| class C: | ||
|
|
@@ -111,6 +117,8 @@ class HolderSub(Holder): | |
|
|
||
| @support.cpython_only | ||
| class TypeCacheWithSpecializationTests(unittest.TestCase): | ||
|
|
||
| @ignore_deprecation | ||
| def tearDown(self): | ||
| _clear_type_cache() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Raise DeprecationWarning for :func:`sys._clear_type_cache`. This function was deprecated in Python 3.13 | ||
srinivasreddy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| but it didn't raise a runtime warning. | ||
Uh oh!
There was an error while loading. Please reload this page.