On Wed, Apr 5, 2017 at 11:45 AM, vitalije <[email protected]> wrote:
> # from leoPlugins.py file > > def registerOneHandler(self, tag, fn): > > """Register one handler""" > > try: > > moduleName = self.loadingModuleNameStack[-1] > > except IndexError: > > moduleName = '<no module>' > > ... > > items = self.handlers.get(tag, []) > > if fn not in items: > > bunch = g.Bunch(fn=fn, moduleName=moduleName, tag='handler') > > items.append(bunch) > > self.handlers[tag] = items > > It looks like the above code checks to see if given function has already > been registered, (`if fn not in items:`) but then it puts a bunch instance > in items not the handler function. Unless I am mistaken, it will never be > the case that the above condition is False, because handler function will > never be added to items array. > ​Good catch. The test above looks like mistaken defensive programming. We could eliminate the test entirely, or test each bunch in items: if bunch.fn == fn:... Care to change this yourself? Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
