mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-105020: Share tp_bases and tp_mro Between Interpreters For All Static Builtin Types (gh-105115) (gh-105124)
In gh-103912 we added tp_bases and tp_mro to each PyInterpreterState.types.builtins entry. However, doing so ignored the fact that both PyTypeObject fields are public API, and not documented as internal (as opposed to tp_subclasses). We address that here by reverting back to shared objects, making them immortal in the process.
(cherry picked from commit 7be667d
)
Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
This commit is contained in:
parent
83c7386cee
commit
c38ceb032d
7 changed files with 26544 additions and 26462 deletions
|
@ -1593,6 +1593,39 @@ class SubinterpreterTest(unittest.TestCase):
|
|||
self.assertEqual(main_attr_id, subinterp_attr_id)
|
||||
|
||||
|
||||
class BuiltinStaticTypesTests(unittest.TestCase):
|
||||
|
||||
TYPES = [
|
||||
object,
|
||||
type,
|
||||
int,
|
||||
str,
|
||||
dict,
|
||||
type(None),
|
||||
bool,
|
||||
BaseException,
|
||||
Exception,
|
||||
Warning,
|
||||
DeprecationWarning, # Warning subclass
|
||||
]
|
||||
|
||||
def test_tp_bases_is_set(self):
|
||||
# PyTypeObject.tp_bases is documented as public API.
|
||||
# See https://github.com/python/cpython/issues/105020.
|
||||
for typeobj in self.TYPES:
|
||||
with self.subTest(typeobj):
|
||||
bases = _testcapi.type_get_tp_bases(typeobj)
|
||||
self.assertIsNot(bases, None)
|
||||
|
||||
def test_tp_mro_is_set(self):
|
||||
# PyTypeObject.tp_bases is documented as public API.
|
||||
# See https://github.com/python/cpython/issues/105020.
|
||||
for typeobj in self.TYPES:
|
||||
with self.subTest(typeobj):
|
||||
mro = _testcapi.type_get_tp_mro(typeobj)
|
||||
self.assertIsNot(mro, None)
|
||||
|
||||
|
||||
class TestThreadState(unittest.TestCase):
|
||||
|
||||
@threading_helper.reap_threads
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue