Skip to content

Commit 6abfc3a

Browse files
committed
Revert UserDict.__init__ changes, new passing test of UserList
1 parent ec247e0 commit 6abfc3a

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Lib/collections/__init__.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -1073,11 +1073,26 @@ def __ror__(self, other):
10731073
class UserDict(_collections_abc.MutableMapping):
10741074

10751075
# Start by filling-out the abstract methods
1076-
def __init__(self, dict=None, /, **kwargs):
1076+
def __init__(*args, **kwargs):
1077+
if not args:
1078+
raise TypeError("descriptor '__init__' of 'UserDict' object "
1079+
"needs an argument")
1080+
self, *args = args
1081+
if len(args) > 1:
1082+
raise TypeError('expected at most 1 arguments, got %d' % len(args))
1083+
if args:
1084+
dict = args[0]
1085+
elif 'dict' in kwargs:
1086+
dict = kwargs.pop('dict')
1087+
import warnings
1088+
warnings.warn("Passing 'dict' as keyword argument is deprecated",
1089+
DeprecationWarning, stacklevel=2)
1090+
else:
1091+
dict = None
10771092
self.data = {}
10781093
if dict is not None:
10791094
self.update(dict)
1080-
if kwargs:
1095+
if len(kwargs):
10811096
self.update(kwargs)
10821097

10831098
def __len__(self):

Lib/test/test_userlist.py

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def test_getslice(self):
2727
for j in range(-3, 6):
2828
self.assertEqual(u[i:j], l[i:j])
2929

30-
# TODO: RUSTPYTHON
31-
@unittest.expectedFailure
3230
def test_slice_type(self):
3331
l = [0, 1, 2, 3, 4]
3432
u = UserList(l)

0 commit comments

Comments
 (0)