summaryrefslogtreecommitdiffstatshomepage
path: root/docs/esp8266/tutorial/filesystem.rst
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-06-24 13:03:44 +1000
committerDamien George <damien@micropython.org>2024-06-28 11:40:24 +1000
commit95c19e05ffd204f8f375b6e04e4ae45770ec0dbc (patch)
treed95ec6d7fa695d85527015699b3c7dff2b0ae260 /docs/esp8266/tutorial/filesystem.rst
parent5dff78f38edc0354e854e6c73af61c5064afe9d3 (diff)
downloadmicropython-95c19e05ffd204f8f375b6e04e4ae45770ec0dbc.tar.gz
micropython-95c19e05ffd204f8f375b6e04e4ae45770ec0dbc.zip
webassembly/objjsproxy: Lookup attributes without testing they exist.
In JavaScript when accessing an attribute such as `obj.attr` a value of `undefined` is returned if the attribute does not exist. This is unlike Python semantics where an `AttributeError` is raised. Furthermore, in some cases in JavaScript (eg a Proxy instance) `attr in obj` can return false yet `obj.attr` is still valid and returns something other than `undefined`. So the source of truth for whether a JavaScript attribute exists is to just right away attempt `obj.attr`. To more closely match these JavaScript semantics when proxying a JavaScript object through to Python, change the attribute lookup logic on a `JsProxy` so that it immediately attempts `obj.attr` instead of first testing if the attribute exists via `attr in obj`. This allows JavaScript objects which dynamically create attributes to work correctly on the Python side, with both `obj.attr` and `obj["attr"]`. Note that `obj["attr"]` already works in all cases because it immediately does the subscript access without first testing if the attribute exists. As a benefit, this new behaviour matches the Pyodide behaviour. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs/esp8266/tutorial/filesystem.rst')
0 files changed, 0 insertions, 0 deletions