[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-14 Thread Terry J. Reedy
Terry J. Reedy added the comment: When reporting a failure please copy and paste the exception and message and when non-trivial, the traceback. In this case: "TypeError: 'test' is an invalid keyword argument for complex()". The difference between int and complex versus float is that the

[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-13 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread Dennis Sweeney
Dennis Sweeney added the comment: Here's an example: class A(complex): def __init__(self, *args, test): self.test = test def __new__(cls, *args, test): return super().__new__(cls, *args) >>> a = A(1, test="TEST") >>> a (1+0j) >>> a.test 'TEST' >>> b = A(1, 1,

[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is because int, str, and complex are immutable. If I have class MyInt(int): def __init__(self, stuff): pass then when I call MyInt("19"), the string "19" is passed to the constructor int.__new__ before the overridden

[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread autospamfighter
autospamfighter added the comment: I tried some more classes and str is weird, but dict and set work fine. very weird -- ___ Python tracker ___

[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread autospamfighter
New submission from autospamfighter : I was trying to make a custom complex class that looked something like this and it failed. I replaced complex with int and it also failed, but I tried float and it worked. ---fail class A(complex): def __init__(self, test): super().__init__()