8000 `py-editor` shows error in `2024.5.1` · Issue #2056 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

py-editor shows error in 2024.5.1 #2056

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

Closed
JeffersGlass opened this issue May 12, 2024 · 4 comments · Fixed by #2058
Closed

py-editor shows error in 2024.5.1 #2056

JeffersGlass opened this issue May 12, 2024 · 4 comments · Fixed by #2058

Comments

@JeffersGlass
Copy link
Contributor

Try the following:

<script type="module" src="https://pyscript.net/releases/2024.5.1/core.js"></script>    
<link rel="stylesheet" href="https://pyscript.net/releases/2024.5.1/core.css">
<script type="py-editor">
  print("Hello!")
</script>

You will get an error

Error: Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 501, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 339, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "", line 32, in 
  File "/home/pyodide/pyscript/__init__.py", line 32, in 
    from pyscript.display import HTML, display
  File "/home/pyodide/pyscript/display.py", line 6, in 
    from pyscript.magic_js import current_target, document, window
  File "/home/pyodide/pyscript/magic_js.py", line 11, in 
    config = json.loads(globalThis.JSON.stringify(_config))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

Hello!

If you use mpy-editor, a slightly different error occurs:

Error: Traceback (most recent call last):
  File "", line 32, in 
  File "pyscript/__init__.py", line 32, in 
  File "pyscript/display.py", line 6, in 
  File "pyscript/magic_js.py", line 11, in 
TypeError: object with buffer protocol required

Hello!

Note that in both cases, "Hello!" prints successfully.

Maybe something related to trying to load a non-existent config?

This does not occur with PyScript 2024.4.2.

@JeffersGlass JeffersGlass changed the title py-editor shows error in 12024.5.1 py-editor shows error in 2024.5.1 May 12, 2024
@nasrin1748
Copy link
Contributor

JFI the error is gone if it's run twice.

@ntoll
Copy link
Member
ntoll commented May 13, 2024

@JeffersGlass thank you so much for reporting this!

I can reproduce this on Firefox with MicroPython. On Firefox with Pyodide I see this error instead (when clicking the "run" button):

💀🔒 - Possible deadlock if proxy.runAsync(...args) is awaited

@WebReflection - any ideas?

On PSDC: https://pyscript.com/@ntoll/orange-field/latest

@WebReflection
Copy link
Contributor

live on npm as:

  • JS https://cdn.jsdelivr.net/npm/@pyscript/core@0.4.32/dist/core.js
  • CSS https://cdn.jsdelivr.net/npm/@pyscript/core@0.4.32/dist/core.css

The issue was silly (my bad) but luckily easy to solve and spot. Thanks a lot for the report, apologies for the missing integration test without config.

@ntoll
Copy link
Member
ntoll commented May 13, 2024

Bravo @WebReflection - I've just checked out the npm version and it all works again. Let's get a release cut with this fix in.

< 7395 div class="TimelineItem-break mb-0 height-full">
WebReflection added a commit that referenced this issue May 13, 2024
* Fix #2056 - Provide a default empty config per editor env

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0