Message270139
Jonathon: Do you have a use case for __rmod__(), or did you find this bug by code analysis?
UserString.__rmod__() was added as part of Issue 22189. The main reason seems to be so that UserString has all the methods listed by dir(str). The result was that UserString.__rmod__() is documented as existing since 3.5.
Ideally I would agree with removing UserString.__rmod__(), but perhaps it would be safer to just have it return NotImplemented. As long as UserString properly supports all combinations of user_string_a % (user_string_b, user_string_c) etc, whether or how __rmod__() is implemented is an implementation detail. The existance of str.__rmod__() does not seem to be documented. It just seems to be a side-effect of how the C-level nb_remainder slot works.
For Serhiy’s F class, which explicitly only works with a single str argument, I think it is reasonable that using UserString instead would raise TypeError. This is what Python 2’s UserString does. |
|
Date |
User |
Action |
Args |
2016-07-10 23:23:34 | martin.panter | set | recipients:
+ martin.panter, rhettinger, pitrou, r.david.murray, serhiy.storchaka, xiang.zhang, jcgoble3 |
2016-07-10 23:23:34 | martin.panter | set | messageid: <1468193014.92.0.370454824453.issue25652@psf.upfronthosting.co.za> |
2016-07-10 23:23:34 | martin.panter | link | issue25652 messages |
2016-07-10 23:23:34 | martin.panter | create | |
|