New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeErrors raised by plugin hooks are sometimes silently ignored #1085
Comments
Oh, and replacing |
You can see the logic that Lektor is using to detect whether the hook supports the
Your example hook throws I think this could be fixed by changing munged_kwargs = {**kwargs, "extra_flags": process_extra_flags(self.extra_flags)}
signature = inspect.signature(handler)
try:
signature.bind(**munged_kwargs)
except TypeError:
munged_kwargs.pop("extra_flags")
rv[plugin.id] = handler(**munged_kwargs)
if "extra_flags" not in munged_kwargs:
warnings.warn(f"The plugin {plugin.id!r} function {funcname!r} does not accept extra_flags. [...]") Footnotes
|
I see, that explains it. Dont be fooled by the contrived example. I was struggling with this because it seemed random when it happens. The In my case, I add an extra attribute to |
TypeError
during AttributeError
is ignoredTypeError
s raised by plugin hooks are sometimes silently ignored
TypeError
s raised by plugin hooks are sometimes silently ignored
Hi, it took a while to identify the culprit of this bug. And I honestly cannot imagine what might cause it.
But this simple plugin example shows what is going wrong:
Instead of showing the callstack with the
TypeError
, lektor somehow forgets the exception and continues happily.The only hint that something gone wrong is this warning:
(which is extra frustrating because ... "c'mon, its there" 😆 )
The text was updated successfully, but these errors were encountered: