Comments (8)
Agree on the overall sentiment (MicroPython error messages needing more clarity)
In the meantime, @laffra do you have a code sample that we can use to reproduce?
from pyscript.
from pyscript.
This is not a solution rather a possible workaround to at least understand what kind of object passes through that proxy trap and what is the property name that is accessing it.
This <script>
should be the very first script on the page so on top of the <head>
or surely before any PyScript code gets a chance to execute.
<script>
($Proxy => {
globalThis.Proxy = class Proxy {
constructor(target, handler) {
const { has } = handler;
if (has) handler.has = (target, name) => {
console.warn(`has("${name}") for`, target);
return has.call(handler, target, name);
};
return new $Proxy(target, handler);
}
}
})(Proxy);
// in case you'd like to test this:
// 'test' in new Proxy({}, Object.create(Reflect));
// will warn and it will return false
</script>
We are rather after a rewrite of the MicroPython Proxy and I believe "better errors" will be inherently part of the refactoring as currently we have an explicit throw new Error('not implemented')
in various proxies traps so tha as soon as any JS tries to understand the shape of a Python object that miserably (currently) fails in MicroPython (only).
edit there was a pretty important missing part of the code.
edit 2 I am assuming the issue with MicroPython is on the main thread, not via worker
attribute ... in latter case it's a bit more complicated as I don't think we have a mechanism to patch the JS env there before anything else happens ... but maybe we should in the future for either debugging or fancy patching use cases.
from pyscript.
from pyscript.
that's super odd ... let me try an amend
<script>
($Proxy => {
globalThis.Proxy = class Proxy {
constructor(target, handler) {
const { has } = handler;
if (has) {
handler = Object.create(handler);
handler.has = (target, name, ...rest) => {
if (target._ref)
console.warn(`has("${name}") for`, target);
return has.call(handler, target, name, ...rest);
};
}
return new $Proxy(target, handler);
}
}
})(Proxy);
</script>
This should be less obtrusive and log only on MicroPython proxy cases.
from pyscript.
from pyscript.
Yes, the snippet won't remove the error as that's not possible (as it's backed in MicroPython) but you should read something in console (devtools) ... and by something I mean a warning ... don't you have any warning in console that prints has("...") for
anywhere? It's very hard to help further without having a reproducible project to test against though, apologies if my help is actually not helping much.
from pyscript.
This has been fixed in latest MicroPython so this error should not come up anymore.
from pyscript.
Related Issues (20)
- Cannot create a PyWorker from python using Pyodide HOT 8
- Improve either PyWorker documentation or internals in general HOT 11
- Trouble interacting with files in Pyscript (both virtual and local) HOT 1
- print() function does not work, but display() does HOT 1
- Add a `fetch` function to the `pyscript` namespace in the "standard library"
- PyTerminal not bootstrapping as expected later on ...
- allow `pyscript.fetch` to be separately awaited
- rich terminal broken in 2024.2.1+ HOT 7
- print(...) + input() does not work as expected HOT 7
- cannot use cross origin HOT 17
- TypeError: Promise.withResolvers is not a function HOT 3
- Help with building a briefcase project for the web HOT 3
- Broken registration / login process on pyscript.com HOT 9
- Use of zipped/tgz assets not working in MicroPython HOT 6
- Ka
- ModuleNotFoundError when importing module from local file using [[fetch]] in pyscript_config.toml (in Next.js / React project) HOT 16
- Unable to connect to webpages with the requests library HOT 2
- Unable to use local piodide with worker HOT 3
- Getting RangeError: WebAssembly.Memory(): could not allocate memory HOT 1
- `py-editor` shows error in `2024.5.1` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyscript.