[PATCH 1 of 4 py3] error: wrap super() init call in try/except

Yuya Nishihara yuya at tcha.org
Fri Nov 11 09:52:50 EST 2016


On Fri, 11 Nov 2016 13:29:31 +0000, Martijn Pieters wrote:
> > On 11 Nov 2016, at 12:54, Yuya Nishihara <yuya at tcha.org> wrote:
> > On Thu, 10 Nov 2016 17:01:22 +0000, Martijn Pieters wrote:
> >> super(Hint, self).__init__ will find the *next class* after Hint in the MRO for type(self). Depending on how Hint was used as a base class in *another class*, the next class in the MRO for self may or may not be object. Since object.__init__() doesn't take any arguments (not even *args or **kwargs), if either args or kw is non-empty you'd get a TypeError here.
> > 
> > In which case, I think the previous class of Hint must consume *args and **kw.
> 
> Probably, yes, still having a non-empty args / kw dataset by the time you reach `object` could be a bug.
> 
> But might there be a situation where extensions may have to deal with *potential* mixins? There are scenarios possible where one extension can't know what other extensions are installed and must always assume that certain arguments are needed.
> 
> I'm not familiar enough with where `Hint` is used, and it is probably better to only plug in a `try:...except:` at the end when the situation actually arises.

I hope there isn't a use of the Hint mixin in complex MRO tree. If we hit the
problem in future, I'd rather wanna remove the Hint class entirely. It's no
more than saving 3 lines of code.


More information about the Mercurial-devel mailing list