Python: Support super().__new__(cls)

This commit is contained in:
Rasmus Wriedt Larsen
2022-10-24 15:35:53 +02:00
parent 2b76964f7f
commit 8a56b48357
3 changed files with 23 additions and 3 deletions

View File

@@ -21,6 +21,9 @@ pointsTo_found_typeTracker_notFound
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
typeTracker_found_pointsTo_notFound
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |
| code/class_construction.py:44:9:44:26 | ControlFlowNode for Attribute() | WithNew.some_method |
| code/class_construction.py:61:9:61:26 | ControlFlowNode for Attribute() | WithNew.some_method |
| code/class_construction.py:75:9:75:27 | ControlFlowNode for Attribute() | ExtraCallToInit.__init__ |
| code/class_special_methods.py:22:9:22:16 | ControlFlowNode for self() | Base.__call__ |
| code/class_special_methods.py:22:9:22:16 | ControlFlowNode for self() | Sub.__call__ |
| code/class_special_methods.py:33:1:33:5 | ControlFlowNode for b() | Base.__call__ |

View File

@@ -41,7 +41,7 @@ class WithNew(object):
print("WithNew.__new__", arg)
inst = super().__new__(cls)
assert isinstance(inst, cls)
inst.some_method() # $ MISSING: pt,tt=WithNew.some_method
inst.some_method() # $ tt=WithNew.some_method
return inst
def __init__(self, arg=None):
@@ -58,7 +58,7 @@ class WithNewSub(WithNew):
print("WithNewSub.__new__")
inst = super().__new__(cls, 44.1) # $ pt,tt=WithNew.__new__
assert isinstance(inst, cls)
inst.some_method() # $ MISSING: pt,tt=WithNew.some_method
inst.some_method() # $ tt=WithNew.some_method
return inst
WithNewSub() # $ tt=WithNewSub.__new__ tt=WithNew.__init__
@@ -72,7 +72,7 @@ class ExtraCallToInit(object):
inst = super().__new__(cls)
assert isinstance(inst, cls)
# you're not supposed to do this, since it will cause the __init__ method will be run twice.
inst.__init__(1001) # $ MISSING: pt,tt=ExtraCallToInit.__init__
inst.__init__(1001) # $ tt=ExtraCallToInit.__init__
return inst
def __init__(self, arg):