brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not import "local files" in webworker code. Throwing: SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

shlomil opened this issue · comments

Since version 3.12.3 trying to import a simple local .py file in webworker code doesn't work anymore throwing:

JavascriptError: undefined: undefined
Uncaught (in promise) Error in worker worker
SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

Code:

<script type="text/python" class="webworker" id="worker">
from browser import bind, self
from some_module import some_func

@bind(self, "message")
def message(evt):
    result = 'pong' if evt.data == 'ping' else evt.data
    workerResult = f'Result: {result}'
    self.send(workerResult)
</script>

Once the some_module import line is added the code will throw the exception above
This issue doesn't accur in version 3.12.2
Full reproduction example is in the attached files.
wworker_issue.zip

Thanks for the detailed report, there was indeed a regression in the latest version.

Thank you @PierreQuentel for addressing it so quickly! I tested again with latest HEAD (commit 8854978) and it seems that the issue still persists. For some reason I don't have a "reopen bug" option in here.

@PierreQuentel
I checked again with commit 70a2145 . The issue still occurs.