Revert UserDict.__init__ changes, new passing test of UserList

This commit is contained in:
Chris Moradi committed 2021-10-25 22:41:59 -07:00
1 parent ec247e0d4f
commit 6abfc3a00c
2 files changed
+17 -4

No files matched your search

+17 -2
View File
@@ -1073,11 +1073,26 @@ class ChainMap(_collections_abc.MutableMapping):
class UserDict(_collections_abc.MutableMapping):
# Start by filling-out the abstract methods
def __init__(self, dict=None, /, **kwargs):
def __init__(*args, **kwargs):
if not args:
raise TypeError("descriptor '__init__' of 'UserDict' object "
"needs an argument")
self, *args = args
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
if args:
dict = args[0]
elif 'dict' in kwargs:
dict = kwargs.pop('dict')
import warnings
warnings.warn("Passing 'dict' as keyword argument is deprecated",
DeprecationWarning, stacklevel=2)
else:
dict = None
self.data = {}
if dict is not None:
self.update(dict)
if kwargs:
if len(kwargs):
self.update(kwargs)
def __len__(self):
-2
View File
@@ -27,8 +27,6 @@ class UserListTest(list_tests.CommonTest):
for j in range(-3, 6):
self.assertEqual(u[i:j], l[i:j])
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_slice_type(self):
l = [0, 1, 2, 3, 4]
u = UserList(l)