mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
gh-117482: Simplify the Fix For Builtin Types Slot Wrappers (GH-122865)
In gh-121602, I applied a fix to a builtin types initialization bug.
That fix made sense in the context of some broader future changes,
but introduced a little bit of extra complexity. That fix has turned
out to be incomplete for some of the builtin types we haven't
been testing. I found that out while improving the tests.
A while back, @markshannon suggested a simpler fix that doesn't
have that problem, which I've already applied to 3.12 and 3.13.
I'm switching to that here. Given the potential long-term
benefits of the more complex (but still incomplete) approach,
I'll circle back to it in the future, particularly after I've improved
the tests so no corner cases slip through the cracks.
(This is effectively a "forward-port" of 716c677 from 3.13.)
This commit is contained in:
parent
b950831c94
commit
d8f3c1e8f9
5 changed files with 38 additions and 42 deletions
|
|
@ -738,7 +738,7 @@ plain ol' Python and is guaranteed to be available.
|
|||
|
||||
>>> import builtins
|
||||
>>> tests = doctest.DocTestFinder().find(builtins)
|
||||
>>> 830 < len(tests) < 860 # approximate number of objects with docstrings
|
||||
>>> 750 < len(tests) < 800 # approximate number of objects with docstrings
|
||||
True
|
||||
>>> real_tests = [t for t in tests if len(t.examples) > 0]
|
||||
>>> len(real_tests) # objects that actually have doctests
|
||||
|
|
|
|||
|
|
@ -416,7 +416,6 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
out, err = self.run_embedded_interpreter("test_repeated_init_exec", code)
|
||||
self.assertEqual(out, '20000101\n' * INIT_LOOPS)
|
||||
|
||||
@unittest.skip('inheritance across re-init is currently broken; see gh-117482')
|
||||
def test_static_types_inherited_slots(self):
|
||||
script = textwrap.dedent("""
|
||||
import test.support
|
||||
|
|
|
|||
|
|
@ -2410,9 +2410,6 @@ class SubinterpreterTests(unittest.TestCase):
|
|||
def collate_results(raw):
|
||||
results = {}
|
||||
for cls, attr, wrapper in raw:
|
||||
# XXX This should not be necessary.
|
||||
if cls == repr(bool) and attr in self.NUMERIC_METHODS:
|
||||
continue
|
||||
key = cls, attr
|
||||
assert key not in results, (results, key, wrapper)
|
||||
results[key] = wrapper
|
||||
|
|
@ -2433,14 +2430,7 @@ class SubinterpreterTests(unittest.TestCase):
|
|||
cls, attr = key
|
||||
with self.subTest(cls=cls, slotattr=attr):
|
||||
actual = interp_results.pop(key)
|
||||
# XXX This should not be necessary.
|
||||
if cls == "<class 'collections.OrderedDict'>" and attr == '__len__':
|
||||
continue
|
||||
self.assertEqual(actual, expected)
|
||||
# XXX This should not be necessary.
|
||||
interp_results = {k: v for k, v in interp_results.items() if k[1] != '__hash__'}
|
||||
# XXX This should not be necessary.
|
||||
interp_results.pop(("<class 'collections.OrderedDict'>", '__getitem__'), None)
|
||||
self.maxDiff = None
|
||||
self.assertEqual(interp_results, {})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue