-
Notifications
You must be signed in to change notification settings - Fork 763
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
Can't pickle <class 'builtins.RustClass'>: attribute lookup RustClass on builtins failed #1517
Comments
Hi @jafioti, while we don't have an official solution or documentation, what you're doing is mostly correct. Looking at the error, you need to make sure You can do this with |
Thanks for the response, now I have a new error: Since this class is in a submodule, should I set the module to "RustModule.RustSubmodule" or just "RustModule"? It fails either way, but when I use "RustModule" it gives a different error: |
I found out that when I try to directly do Here is my top-level module implementation:
|
The reason it works for That would indicate that the |
So - some experimentation results: on Python 3.7, the error message for your case is
Adding a
so it does make Python regard the top module as a package, but still doesn't find the submodule. This is probably because it does not care that the submodule is already present in the module's namespace and rather wants to look for some file on the filesystem. It seems that what you need to do in addition is to pretend the module has already been imported, by placing it in
|
@davidhewitt if this use case is to be supported properly, I think there should be a helper API to do this easily, maybe even in |
@birkenfeld nice find - I'd looked at the submodule import problem before but hadn't managed to find that placing it in Agreed we should implement first-class support for this case. It would be nice if the module path was computed automatically rather than having to provide the full path to |
Well, I can't promise it's the correct solution, but it works because it bypasses the import machinery. I didn't remember an example of such a module hierarchy entirely implemented in C to look up how others are doing it. |
@birkenfeld @davidhewitt Thanks for the solution, although hacky it works! |
via `from spk.solve import ...` PyO3/pyo3#1517 (comment) Signed-off-by: J Robert Ray <[email protected]>
via `from spk.solve import ...` PyO3/pyo3#1517 (comment) Signed-off-by: J Robert Ray <[email protected]>
via `from spk.solve import ...` PyO3/pyo3#1517 (comment) Signed-off-by: J Robert Ray <[email protected]>
via `from spk.solve import ...` PyO3/pyo3#1517 (comment) Signed-off-by: J Robert Ray <[email protected]>
When attempting to pickle a PyO3 class, I am getting an error:
Can't pickle <class 'builtins.RustClass'>: attribute lookup RustClass on builtins failed
I have copied everything from this example here:
https://gist.github.com/ethanhs/fd4123487974c91c7e5960acc9aa2a77
Is pickle a supported feature or is this simply unavailable?
The text was updated successfully, but these errors were encountered: