New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typeobject provides incorrect __mul__ #37666
Comments
type __mul__ is wierd: >> 'a'.__mul__(3.4)
'aaa'
>>> [1].__mul__(3.4)
[1, 1, 1] Floating point numbers with fractions should not be Should also check __imul__ __add__ __iadd__. |
Logged In: YES I think the problem is that wrap_intargfunc and >>> "Python"[1.2]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: sequence index must be integer
>>> "Python".__getitem__(1.2)
'y' I think the right fix is to use explictly only allow only |
Logged In: YES This is an age-old problem that crops up whenever "i" and The problem is that on the one hand you want "i" to accept I think the "i" format code has to be fixe, but I'm not sure |
Logged In: YES Would this be a change for the 2.3 release? I tried adding |
Logged In: YES Yes, this should go into 2.3a2. Your attachment upload failed somehow. |
Logged In: YES The small patch is attached. I only added the checking for |
Logged In: YES Looks like a good patch. And yes, the other types should be |
Logged In: YES I added the check for the other integer codes. All the |
Logged In: YES Neil, If this is fixed in this way (disallowing floats where integers are expected) it should at least be done with a DeprecationWarning for one release cycle. I think the fix probably is a good idea in the long run, but it will break large bodies of code... |
Logged In: YES Attached is a patch that signals a DepreciationWarning |
Logged In: YES Loosk good -- please check it in. Probably requires |
Logged In: YES Checked in as getargs.c 2.96 with NEWS. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: