Comments (4)
More generally this is a problem with all attributes defined on JsProxy
. The logic we have for JsProxy __getattribute__
is here:
https://github.com/pyodide/pyodide/blob/main/src/core/jsproxy.c#L321-L324
It always gives the C definitions preference over methods on the JavaScript object. Perhaps we could come up with something a bit more sophisticated, or special case "new", or something else.
Interestingly in __setattribute__
we almost always assign through to the JavaScript object:
https://github.com/pyodide/pyodide/blob/main/src/core/jsproxy.c#L374-L397
so that we get the following odd behavior:
from js import Object
Object.new = 6 # assigns to Js Object
print(repr(Object.new)) # <built-in method new of pyodide.ffi.JsProxy>
assert run_js("Object.new") == 6
from pyodide.
For some reason this code has gotten a lot less attention than the corresponding code on PyProxy
.
from pyodide.
To whom it might concern, this is how Function.prototype.new
proposal (or polyfill, if used) would enhance / improve by far the situation (imho) https://es.discourse.group/t/function-prototype-new/1772/40
Here I think there could be issues with 3rd party libraries as one can't assume anything, not even common sense, out there 😅
from pyodide.
I've proposed an alternative that this project might as well use: https://github.com/WebReflection/proxy-class-new#readme
It doesn't land on Function.prototype
and it addresses most known/explored edge cases ... feel free to use it internally to disambiguate classes and instantiate these with .new(....args)
.
from pyodide.
Related Issues (20)
- Add esbuild-py HOT 4
- Add `PyMuPDF` package
- runPython return missing
- cmake -E capabilities is broken HOT 1
- Release 0.26.0 HOT 5
- datasets (huggingface) HOT 6
- Cannot create a WebGL2 context when using SDL HOT 3
- request to add pandasai HOT 1
- request to add llama-index
- request to add langchain HOT 1
- request to add Boto3 HOT 4
- fastobo
- loadPackage() not to access the file system if the cache already exists HOT 2
- cvxpy-base 1.4.3 HOT 2
- html5_canvas_backend no longer works. HOT 1
- RFC Package unvendored stdlibs to sdist / wheel? HOT 3
- `make` in docker container `pyodide/pyodide-env` fails with `could not create work tree dir 'emsdk'` HOT 8
- DOM types in pyodide lead to build issues with Angular and typescript. HOT 3
- Request add to section-properies package
- feat: Resolving CORS Restrictions in Node.js HOT 2
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 pyodide.