8000 [3.13] gh-117482: Simplify the Fix For Builtin Types Slot Wrappers by ericsnowcurrently · Pull Request #121932 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.13] gh-117482: Simplify the Fix For Builtin Types Slot Wrappers #121932

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test for re-init.
  • Loading branch information
ericsnowcurrently committed Jul 23, 2024
commit 3aa9cd2bebf23ddf1549c46dd9b0af1e64da0f84
27 changes: 27 additions & 0 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from collections import namedtuple
import contextlib
import io
import json
import os
import os.path
Expand Down Expand Up @@ -415,6 +416,32 @@ def test_datetime_reset_strptime(self):
out, err = self.run_embedded_interpreter("test_repeated_init_exec", code)
self.assertEqual(out, '20000101\n' * INIT_LOOPS)

def test_static_types_inherited_slots(self):
slots = []
script = ['import sys']
from test.test_types import iter_builtin_types, iter_own_slot_wrappers
for cls in iter_builtin_types():
for slot in iter_own_slot_wrappers(cls):
slots.append((cls, slot))
attr = f'{cls.__name__}.{slot}'
script.append(f'print("{attr}:", {attr}, file=sys.stderr)')
script.append('')
script = os.linesep.join(script)

with contextlib.redirect_stderr(io.StringIO()) as stderr:
exec(script)
expected = stderr.getvalue().splitlines()

out, err = self.run_embedded_interpreter("test_repeated_init_exec", script)
results = err.split('--- Loop #')[1:]
results = [res.rpartition(' ---\n')[-1] for res in results]

self.maxDiff = None
for i, result in enumerate(results, start=1):
with self.subTest(loop=i):
self.assertEqual(result.splitlines(), expected)
self.assertEqual(out, '')


@unittest.skipIf(_testinternalcapi is None, "requires _testinternalcapi")
class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
Expand Down
Loading
0