From 7ec561b741678a2d217cee58ff9956d33c884706 Mon Sep 17 00:00:00 2001 From: "Nicholas H.Tollervey" Date: Thu, 7 Aug 2025 08:21:48 +0100 Subject: [PATCH 1/3] Bump version number. --- docs/beginning-pyscript.md | 8 ++++---- docs/user-guide/first-steps.md | 4 ++-- docs/user-guide/plugins.md | 10 +++++----- docs/user-guide/pygame-ce.md | 4 ++-- docs/user-guide/workers.md | 4 ++-- version.json | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/beginning-pyscript.md b/docs/beginning-pyscript.md index b51916b..db47f44 100644 --- a/docs/beginning-pyscript.md +++ b/docs/beginning-pyscript.md @@ -117,8 +117,8 @@ module in the document's `` tag: 🦜 Polyglot - Piratical PyScript - - + + @@ -168,8 +168,8 @@ In the end, our HTML should look like this: 🦜 Polyglot - Piratical PyScript - - + +

Polyglot 🦜 💬 🇬🇧 ➡️ 🏴‍☠️

diff --git a/docs/user-guide/first-steps.md b/docs/user-guide/first-steps.md index 110b332..ad1bbd5 100644 --- a/docs/user-guide/first-steps.md +++ b/docs/user-guide/first-steps.md @@ -20,9 +20,9 @@ CSS: - + - + diff --git a/docs/user-guide/plugins.md b/docs/user-guide/plugins.md index 63fd3cc..ce1efa9 100644 --- a/docs/user-guide/plugins.md +++ b/docs/user-guide/plugins.md @@ -100,7 +100,7 @@ For example, this will work because all references are contained within the registered function: ```js -import { hooks } from "https://pyscript.net/releases/2025.7.3/core.js"; +import { hooks } from "https://pyscript.net/releases/2025.8.1/core.js"; hooks.worker.onReady.add(() => { // NOT suggested, just an example! @@ -114,7 +114,7 @@ hooks.worker.onReady.add(() => { However, due to the outer reference to the variable `i`, this will fail: ```js -import { hooks } from "https://pyscript.net/releases/2025.7.3/core.js"; +import { hooks } from "https://pyscript.net/releases/2025.8.1/core.js"; // NO NO NO NO NO! ☠️ let i = 0; @@ -147,7 +147,7 @@ the page. ```js title="log.js - a plugin that simply logs to the console." // import the hooks from PyScript first... -import { hooks } from "https://pyscript.net/releases/2025.7.3/core.js"; +import { hooks } from "https://pyscript.net/releases/2025.8.1/core.js"; // The `hooks.main` attribute defines plugins that run on the main thread. hooks.main.onReady.add((wrap, element) => { @@ -197,8 +197,8 @@ hooks.worker.onAfterRun.add(() => { - - + + + + diff --git a/docs/user-guide/workers.md b/docs/user-guide/workers.md index af0d895..bea5c79 100644 --- a/docs/user-guide/workers.md +++ b/docs/user-guide/workers.md @@ -282,9 +282,9 @@ Here's how: - + - + PyWorker - mpy bootstrapping pyodide example diff --git a/version.json b/version.json index 6a40855..3e74fe4 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2025.7.3" + "version": "2025.8.1" } From 69e85e3bead7724d525a519d635723cbdb22ccca Mon Sep 17 00:00:00 2001 From: webreflection Date: Thu, 7 Aug 2025 08:37:23 +0200 Subject: [PATCH 2/3] Added documentation for `ffi.is_none(ref)` --- docs/user-guide/ffi.md | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/user-guide/ffi.md b/docs/user-guide/ffi.md index a874599..6ad6537 100644 --- a/docs/user-guide/ffi.md +++ b/docs/user-guide/ffi.md @@ -16,6 +16,7 @@ Our `pyscript.ffi` offers the following utilities: counterpart. * `ffi.create_proxy(def_or_lambda)` proxies a generic Python function into a JavaScript one, without destroying its reference right away. +* `ffi.is_none(reference)` to check if a specific value is either `None` or `JsNull` Should you require access to Pyodide or MicroPython's specific version of the FFI you'll find them under the `pyodide.ffi` and `micropython.ffi` namespaces. @@ -209,3 +210,49 @@ only in Pyodide can we then destroy such proxy: js.setTimeout(proxy, 1000, "success"); ``` + +## is_none + +Starting from *Pyodide* version `0.28`, there is a new *nullish* value in town that is +meant to represent exactly the *JS* `null` value. + +Previously, both `null` and `undefined` would have been converted into `None` +but some *API* behaves differently if one value is absent or explicitly `null`. + +In *JSON*, `null` would also survive serialization while `undefined` would +vanish. To preserve that distinction also in *Python*, the conversion +between *JS* and *Python* now has a new `pyodide.ffi.jsnull` as showed in +[pyodide documentation](https://pyodide.org/en/stable/usage/type-conversions.html#javascript-to-python). + +In general, there should be no surprise but, specially when dealing with the *DOM* +world, most utilities and methods would return `null`. + +To simplify and smooth-out this distinction, we decided to introduce `is_null` +as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/latest?files=main.py): + +```html title="pyscript.ffi.is_none" + + +``` + +Please note that in *MicroPython* the method works the same but, as we try to +reach features-parity among runtimes, it is suggested to use `is_none(ref)` +even if right now there is not such distinction between `null` and `undefined`. From 2332f4f13245c7f4b0eab38036d62ab4ddfa2dd5 Mon Sep 17 00:00:00 2001 From: "Nicholas H.Tollervey" Date: Thu, 7 Aug 2025 08:55:11 +0100 Subject: [PATCH 3/3] Minor edits. --- docs/user-guide/ffi.md | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/docs/user-guide/ffi.md b/docs/user-guide/ffi.md index 6ad6537..1470e67 100644 --- a/docs/user-guide/ffi.md +++ b/docs/user-guide/ffi.md @@ -16,7 +16,7 @@ Our `pyscript.ffi` offers the following utilities: counterpart. * `ffi.create_proxy(def_or_lambda)` proxies a generic Python function into a JavaScript one, without destroying its reference right away. -* `ffi.is_none(reference)` to check if a specific value is either `None` or `JsNull` +* `ffi.is_none(reference)` to check if a specific value is either `None` or `JsNull`. Should you require access to Pyodide or MicroPython's specific version of the FFI you'll find them under the `pyodide.ffi` and `micropython.ffi` namespaces. @@ -213,22 +213,24 @@ only in Pyodide can we then destroy such proxy: ## is_none -Starting from *Pyodide* version `0.28`, there is a new *nullish* value in town that is -meant to represent exactly the *JS* `null` value. +*Pyodide* version `0.28` onwards has introduced a new *nullish* value that +precisely represents JavaScript's `null` value. -Previously, both `null` and `undefined` would have been converted into `None` -but some *API* behaves differently if one value is absent or explicitly `null`. +Previously, both JavaScript `null` and `undefined` would have been converted +into Python's `None` but, alas, some APIs behave differently if a value is +`undefined` or explicitly `null`. -In *JSON*, `null` would also survive serialization while `undefined` would -vanish. To preserve that distinction also in *Python*, the conversion -between *JS* and *Python* now has a new `pyodide.ffi.jsnull` as showed in +For example, in *JSON*, `null` would survive serialization while `undefined` +would vanish. To preserve that distinction in *Python*, the conversion +between *JS* and *Python* now has a new `pyodide.ffi.jsnull` as explained in +the [pyodide documentation](https://pyodide.org/en/stable/usage/type-conversions.html#javascript-to-python). -In general, there should be no surprise but, specially when dealing with the *DOM* -world, most utilities and methods would return `null`. +In general, there should be no surprises. But, especially when dealing with the +*DOM* world, most utilities and methods return `null`. -To simplify and smooth-out this distinction, we decided to introduce `is_null` -as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/latest?files=main.py): +To simplify and smooth-out this distinction, we decided to introduce `is_null`, +as [demoed here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/latest?files=main.py): ```html title="pyscript.ffi.is_none" @@ -243,7 +245,7 @@ as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/ print(js_null) # jsnull print(js_null is None) # False - # JsNull is still "falsy" as value + # JsNull is still a "falsy" value if (js_null): print("this will not be shown") @@ -254,5 +256,6 @@ as [demoed live in here](https://pyscript.com/@agiammarchi/pyscript-ffi-is-none/ ``` Please note that in *MicroPython* the method works the same but, as we try to -reach features-parity among runtimes, it is suggested to use `is_none(ref)` -even if right now there is not such distinction between `null` and `undefined`. +reach feature-parity among runtimes, it is suggested to use `is_none(ref)` +even if, right now, there is no such distinction between `null` and +`undefined` in MicroPython.