gh-65961: Do not rely solely on __cached__ (GH-97990)

Make sure `__spec__.cached` (at minimum) can be used.
This commit is contained in:
Brett Cannon 2022-10-06 15:40:22 -07:00 committed by GitHub
parent f8edc6ff53
commit e1c4d56fdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 130 additions and 35 deletions

View file

@ -702,7 +702,7 @@ class PydocDocTest(unittest.TestCase):
def test_synopsis_sourceless(self):
os = import_helper.import_fresh_module('os')
expected = os.__doc__.splitlines()[0]
filename = os.__cached__
filename = os.__spec__.cached
synopsis = pydoc.synopsis(filename)
self.assertEqual(synopsis, expected)