bpo-25652: Fix rmod of UserString by isidentical · Pull Request #13326 · python/cpython (original) (raw)
As the person who originally filed the bpo issue, I stand by my statement that it's better to fix the bug rather than just remove the method. As demonstrated by my userstringerror.py
attachment on the issue, a subclass of a subclass of UserString
can be bitten by this due to Python allowing a subclass to override a dunder of the parent class, even when the subclass object is the right-hand operand. (For example, the sub-subclass may be for a specialized case where pre-processing or normalization is required before formatting.)
Therefore __rmod__
is useful, and removing it would force subclass authors to write the implementation themselves rather than extending the UserString method..