Closed acjh closed 1 year ago
In relation to other issues that currently is being solved (#74), I don't think this this PR will land into master. And generally pickling objects that are not supposed to be pickled - is not a good idea. Plugin objects should never be serialized. Why is that needed?
I can't read #74 and it doesn't make sense when Google-translated.
For why, see the linked Stack Overflow question. Note that it's not my question and I don't use Kutana, so I can't strongly justify the use case.
Regardless of whether pickling is supported, this fixes the incorrect and incomplete import helpers.
Sorry for mixed languages. I'm in process of rewriting loaders.py
, where importing will be implemented properly (so that classes inside loaded modules will be available to pickle). That's what what basically means #74
Description
name
of the module to be imported inload_plugins_from_file
.import_module
that inserts the module intosys.modules
as shown in the recipe https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly.Motivation and Context
Pickling a plugin that has a reference to a function or class defined within the plugin module fails.
See https://stackoverflow.com/questions/74841508/cant-pickle-class-import-of-module-failed.
How Has This Been Tested?
Added
test_pickle_dumps
in test_loaders.py, which fails before this fix and passes after this fix.Limitations:
load_plugins
from relative path.on_match
is incompatible withpickle
, but works withcloudpickle
.Types of changes
New feature (non-breaking change which adds functionality)Checklist:
My change requires a change to the documentation.I have updated the documentation accordingly.