mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
Disallow class assignment completely unless both old and new are heap
types. This prevents nonsense like 2.__class__ = bool or True.__class__ = int.
This commit is contained in:
parent
e05f65a0c6
commit
40af889081
2 changed files with 14 additions and 6 deletions
|
|
@ -2478,6 +2478,11 @@ def setclass():
|
|||
cant(C(), object)
|
||||
cant(object(), list)
|
||||
cant(list(), object)
|
||||
class Int(int): __slots__ = []
|
||||
cant(2, Int)
|
||||
cant(Int(), int)
|
||||
cant(True, int)
|
||||
cant(2, bool)
|
||||
|
||||
def setdict():
|
||||
if verbose: print "Testing __dict__ assignment..."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue