pyodide/pytest-pyodide

pickle.loads fails if pyodide code throws exception

nicornk opened this issue · 2 comments

result = pickle.loads(b64decode(result)) in decorator.py fails for me with the following message:

{AttributeError}Can't get attribute 'JsException' on <module 'pyodide' (<_frozen_importlib_external._NamespaceLoader object at 0x1112554e0>)>

The pickle payload starts with this:

b'\x80\x04\x95\x90\x06\x00\x00\x00\x00\x00\x00\x8c\x16tblib.pickling_support\x94\x8c\x12unpickle_exception\x94\x93\x94(\x8c\x07pyodide\x94\x8c\x0bJsException\x94\x93\x94\x8ckNetworkError: Failed to execute \'send\' on \'XMLHttpRequest\': Failed to load \'http://localhost:54082/foobar\'.\x94\x85\x94Nh\x00\x8c\x12unpickle_traceback\x94\x93\x94\x8c\x05tblib\x94\x8c\x05Frame\x94\x93\x94)\x81\x94}\x94(\x8c\x08f_locals\x94}\x94\x8c\tf_globals\x94}\x94\x8c

I am assuming that pyodide.JsException has been moved to pyodide.ffi.JsException

rth commented

Thanks for the report. This will be resolved in #44

Just as a note: just spend an hour to find out the ModuleNotFoundError: No module named 'requests' exception was raised during unpickling. My pyodide environment had requests installed, my host didn't. I'll create a PR which throw a meaningful exception on the host to point the user in the right direction.