Open dunkmann00 opened 4 years ago
Sorry, i misunderstood and posted an incorrect response, which I've deleted.
Reproduced. I also tried a third layer of class nesting (not shown), and got the same off-by-1 error (as opposed to, say, off by 2).
This bug is also present in MicroPython, so I'll file an issue there.
class A:
def __init__(self):
pass
class B(A):
def __init__(self):
super().__init__()
try:
print("A(1)")
A(1)
except Exception as e:
print(e)
try:
print("B(1)")
B(1)
except Exception as e:
print(e)
Adafruit CircuitPython 6.0.0-alpha.0-6-g11cb3e3b4-dirty on 2020-07-01; [...]
>>> import args
A(1)
function takes 1 positional arguments but 3 were given
B(1)
function takes 2 positional arguments but 3 were given
>>>
Sounds good!
When initializing an object, the error that is produced when the wrong number of positional arguments is given shows the wrong number of arguments given and required. It is off by +1. From my testing, this only happens when the object being initialized is a subclass.
Example:
Output:
Expected Output:
I tested this on an itsybitsy_m4_express running CP 5.3.0 and 5.4.0-beta.1