This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jcgoble3
Recipients jcgoble3, martin.panter, pitrou, r.david.murray, rhettinger, serhiy.storchaka, xiang.zhang
Date 2017-05-10.00:35:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1494376519.28.0.12887154602.issue25652@psf.upfronthosting.co.za>
In-reply-to
Content
Any decision on this? I recently played around and found a reasonable use case where UserString.__rmod__ does get called; run the attached userstringerror.py to see it in action.

Basically, it seems the idea of UserString is to subclass it, tweak as desired, and use your subclass as necessary. If you then subclass your subclass (e.g. for a portion of your code with a specialized need) and extend __mod__ and __rmod__ in that sub-subclass (calling the parent method with super()), then any case of "subclass instance % sub-subclass instance" results in Python calling the sub-subclass's __rmod__ method directly without trying a __mod__ method. If that method then calls super().__rmod__ (e.g. it just needed to pre-process the data, such as to normalize it, before the formatting operation), then UserString.__rmod__ will be called and result in the NameError.
History
Date User Action Args
2017-05-10 00:35:19jcgoble3setrecipients: + jcgoble3, rhettinger, pitrou, r.david.murray, martin.panter, serhiy.storchaka, xiang.zhang
2017-05-10 00:35:19jcgoble3setmessageid: <1494376519.28.0.12887154602.issue25652@psf.upfronthosting.co.za>
2017-05-10 00:35:19jcgoble3linkissue25652 messages
2017-05-10 00:35:19jcgoble3create