mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-43827: Make arguments to abc.ABCMeta.__new__ pos-only (#25385)
To avoid conflicts with `__init__subclass__`.
This commit is contained in:
parent
a95138b2c5
commit
42fee931d0
4 changed files with 16 additions and 1 deletions
|
|
@ -668,6 +668,19 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
|||
class Receiver(ReceivesClassKwargs, abc_ABC, x=1, y=2, z=3):
|
||||
pass
|
||||
self.assertEqual(saved_kwargs, dict(x=1, y=2, z=3))
|
||||
|
||||
def test_positional_only_and_kwonlyargs_with_init_subclass(self):
|
||||
saved_kwargs = {}
|
||||
|
||||
class A:
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
super().__init_subclass__()
|
||||
saved_kwargs.update(kwargs)
|
||||
|
||||
class B(A, metaclass=abc_ABCMeta, name="test"):
|
||||
pass
|
||||
self.assertEqual(saved_kwargs, dict(name="test"))
|
||||
|
||||
return TestLegacyAPI, TestABC, TestABCWithInitSubclass
|
||||
|
||||
TestLegacyAPI_Py, TestABC_Py, TestABCWithInitSubclass_Py = test_factory(abc.ABCMeta,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue