@@ -1939,27 +1939,33 @@ def test_fromkeys(self):
19391939 # Subclass which overrides the constructor
19401940 created = frozendict (x = 1 )
19411941 class FrozenDictSubclass (frozendict ):
1942- def __new__ (self ):
1943- return created
1942+ def __new__ (cls , * args , ** kwargs ):
1943+ if args or kwargs :
1944+ return super ().__new__ (cls , * args , ** kwargs )
1945+ else :
1946+ return created
19441947
19451948 fd = FrozenDictSubclass .fromkeys ("abc" )
19461949 self .assertEqual (fd , frozendict (x = 1 , a = None , b = None , c = None ))
1947- self .assertEqual (type (fd ), frozendict )
1950+ self .assertEqual (type (fd ), FrozenDictSubclass )
19481951 self .assertEqual (created , frozendict (x = 1 ))
19491952
19501953 fd = FrozenDictSubclass .fromkeys (frozendict (y = 2 ))
19511954 self .assertEqual (fd , frozendict (x = 1 , y = None ))
1952- self .assertEqual (type (fd ), frozendict )
1955+ self .assertEqual (type (fd ), FrozenDictSubclass )
19531956 self .assertEqual (created , frozendict (x = 1 ))
19541957
19551958 # Dict subclass which overrides the constructor
19561959 class DictSubclass (dict ):
1957- def __new__ (self ):
1958- return created
1960+ def __new__ (cls , * args , ** kwargs ):
1961+ if args or kwargs :
1962+ return super ().__new__ (cls , * args , ** kwargs )
1963+ else :
1964+ return created
19591965
19601966 fd = DictSubclass .fromkeys ("abc" )
19611967 self .assertEqual (fd , frozendict (x = 1 , a = None , b = None , c = None ))
1962- self .assertEqual (type (fd ), frozendict )
1968+ self .assertEqual (type (fd ), DictSubclass )
19631969 self .assertEqual (created , frozendict (x = 1 ))
19641970
19651971 # Subclass which doesn't override the constructor
0 commit comments