GH-65961: Stop setting __cached__ on modules

This commit is contained in:
Brett Cannon 2025-12-01 15:23:16 -08:00
parent e32c975640
commit 28f1334f1a
32 changed files with 93 additions and 240 deletions

View file

@ -198,15 +198,15 @@ def test_5(self):
import t5
self.assertEqual(fixdir(dir(t5)),
['__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__',
'foo', 'string', 't5'])
['__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__', 'foo',
'string', 't5'])
self.assertEqual(fixdir(dir(t5.foo)),
['__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__spec__', 'string'])
['__doc__', '__file__', '__loader__', '__name__',
'__package__', '__spec__', 'string'])
self.assertEqual(fixdir(dir(t5.string)),
['__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__spec__', 'spam'])
['__doc__', '__file__', '__loader__', '__name__',
'__package__', '__spec__', 'spam'])
def test_6(self):
hier = [
@ -221,14 +221,13 @@ def test_6(self):
import t6
self.assertEqual(fixdir(dir(t6)),
['__all__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__path__',
'__spec__'])
['__all__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__'])
s = """
import t6
from t6 import *
self.assertEqual(fixdir(dir(t6)),
['__all__', '__cached__', '__doc__', '__file__',
['__all__', '__doc__', '__file__',
'__loader__', '__name__', '__package__',
'__path__', '__spec__', 'eggs', 'ham', 'spam'])
self.assertEqual(dir(), ['eggs', 'ham', 'self', 'spam', 't6'])
@ -256,20 +255,19 @@ def test_7(self):
t7, sub, subsub = None, None, None
import t7 as tas
self.assertEqual(fixdir(dir(tas)),
['__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__'])
['__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__'])
self.assertFalse(t7)
from t7 import sub as subpar
self.assertEqual(fixdir(dir(subpar)),
['__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__'])
['__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__'])
self.assertFalse(t7)
self.assertFalse(sub)
from t7.sub import subsub as subsubsub
self.assertEqual(fixdir(dir(subsubsub)),
['__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__',
'spam'])
['__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__', 'spam'])
self.assertFalse(t7)
self.assertFalse(sub)
self.assertFalse(subsub)