You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least one type of global variable that a plugin might reasonably want to keep around (to reduce overhead from constructing a new object every time a command is called) can cause a loading error.
Reproduction steps
Create a plugin file containing a global ServerProxy like this:
Sopel will fail to load the plugin with a cryptic TypeError pointing at its own plugin system internals (see "Logs" section below).
Expected behavior
Sopel loads the plugin with no error, of course.
Logs
[2020-08-29 07:13:57,746] sopel.bot ERROR - Error in globalproxy setup: '_Method' object is not iterable
Traceback (most recent call last):
File "/mnt/c/Users/dgw/github/sopel/sopel/bot.py", line 307, in setup_plugins
plugin.register(self)
File "/mnt/c/Users/dgw/github/sopel/sopel/plugins/handlers.py", line 276, in register
bot.add_plugin(self, *relevant_parts)
File "/mnt/c/Users/dgw/github/sopel/sopel/bot.py", line 394, in add_plugin
self.register_jobs(jobs)
File "/mnt/c/Users/dgw/github/sopel/sopel/bot.py", line 554, in register_jobs
job = sopel.tools.jobs.Job.from_callable(self.settings, func)
File "/mnt/c/Users/dgw/github/sopel/sopel/tools/jobs.py", line 290, in from_callable
set(handler.interval),
TypeError: '_Method' object is not iterable
I think I traced it back to clean_module() returning the ServerProxy object as a job, erroneously:
> /mnt/c/Users/dgw/github/sopel/sopel/loader.py(248)clean_module()->([<function pyp...x7fca513e6a60>], [<ServerProxy ...pypi.org/pypi>], [], [<function pyp...x7fca513e69d8>])
-> return callables, jobs, shutdowns, urls
(Pdb) jobs
[<ServerProxy for pypi.org/pypi>]
It seems that a ServerProxy is callable, for some reason (I haven't figured out what is supposed to be retrievable that way; I've only managed to get a lot of AttributeErrors)—and has an (undocumented?) interval attribute that contains some xmlrpc.client._Method (internal class) instance, obviously conflicting with the criteria Sopel uses to figure out if something it found in a module is a job.
It might be time time to add some sanity checks for the attributes Sopel uses when loading plugins, and ignore callables with invalid types. Like, the obvious solution here is to skip returning any callable as a job from clean_module() if it has an interval attribute that isn't a list (optional: of ints).
Opening with no milestone: Not yet clear to me that this is important enough to spend time on for 7.1.
The text was updated successfully, but these errors were encountered:
dgw
added
the
Bug
Things to squish; generally used for issues
label
Aug 29, 2020
Description
At least one type of global variable that a plugin might reasonably want to keep around (to reduce overhead from constructing a new object every time a command is called) can cause a loading error.
Reproduction steps
Create a plugin file containing a global ServerProxy like this:
Sopel will fail to load the plugin with a cryptic
TypeError
pointing at its own plugin system internals (see "Logs" section below).Expected behavior
Sopel loads the plugin with no error, of course.
Logs
I think I traced it back to
clean_module()
returning the ServerProxy object as a job, erroneously:Environment
.version
: 7.1.0-dev (master
branch @ 5525ed2)Notes
It seems that a ServerProxy is callable, for some reason (I haven't figured out what is supposed to be retrievable that way; I've only managed to get a lot of
AttributeError
s)—and has an (undocumented?)interval
attribute that contains somexmlrpc.client._Method
(internal class) instance, obviously conflicting with the criteria Sopel uses to figure out if something it found in a module is a job.It might be time time to add some sanity checks for the attributes Sopel uses when loading plugins, and ignore callables with invalid types. Like, the obvious solution here is to skip returning any callable as a job from
clean_module()
if it has aninterval
attribute that isn't a list (optional: of ints).Opening with no milestone: Not yet clear to me that this is important enough to spend time on for 7.1.
The text was updated successfully, but these errors were encountered: