mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
bpo-44712: Replace "type(literal)" with corresponding builtin types (GH-27294)
I suppose it is a remnants of very old code written when str, int, list, dict, etc were functions and not classes.
This commit is contained in:
parent
c826867b7c
commit
3680ebed7f
19 changed files with 41 additions and 39 deletions
|
|
@ -426,7 +426,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
|
|||
def __getitem__(self, key):
|
||||
return self.get(key, 0)
|
||||
def __setitem__(self_local, key, value):
|
||||
self.assertIsInstance(key, type(0))
|
||||
self.assertIsInstance(key, int)
|
||||
dict.__setitem__(self_local, key, value)
|
||||
def setstate(self, state):
|
||||
self.state = state
|
||||
|
|
@ -871,7 +871,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
|
|||
self.assertEqual(a.getstate(), 10)
|
||||
class D(dict, C):
|
||||
def __init__(self):
|
||||
type({}).__init__(self)
|
||||
dict.__init__(self)
|
||||
C.__init__(self)
|
||||
d = D()
|
||||
self.assertEqual(list(d.keys()), [])
|
||||
|
|
@ -3288,7 +3288,7 @@ order (MRO) for bases """
|
|||
cant(True, int)
|
||||
cant(2, bool)
|
||||
o = object()
|
||||
cant(o, type(1))
|
||||
cant(o, int)
|
||||
cant(o, type(None))
|
||||
del o
|
||||
class G(object):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue