summaryrefslogtreecommitdiff
path: root/py/parsenum.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-09-18 23:55:36 +1000
committerDamien George <damien@micropython.org>2025-09-30 11:04:05 +1000
commitbeb4c3188f5c26ede14134db1d34f817793b7e46 (patch)
treefa038be682c5fd66e7d3861ce055982606e79b78 /py/parsenum.c
parente3ef68215605938c906196ae37120950d0eb6105 (diff)
py/runtime: Support importing a method from an instance.
This change follows CPython behaviour, allowing use of: from instance import method to import a bound method from a class instance, eg registered via setting `sys.modules["instance"] = instance`. Admittedly this is probably a very rarely used pattern in Python, but it resolves a long standing comment about whether or not this is actually possible (it turns out it is possible!). A test is added to show how it works. The main reason for this change is to fix a problem with imports in the webassembly port: prior to this fix, it was not possible to do `from js_module import function`, where `js_module` is a JavaScript object registered to be visible to Python through the webassembly API function `registerJsModule(js_module)`. But now with this fix that is possible. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/parsenum.c')
0 files changed, 0 insertions, 0 deletions