Jonathan Goble added the comment:

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.

----------
versions: +Python 3.7 -Python 3.5
Added file: http://bugs.python.org/file46854/userstringerror.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25652>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to