Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isinstance not working with JS arrays #2325

Open
Tracked by #2250
denis-migdal opened this issue Nov 15, 2023 · 3 comments
Open
Tracked by #2250

isinstance not working with JS arrays #2325

denis-migdal opened this issue Nov 15, 2023 · 3 comments

Comments

@denis-migdal
Copy link
Contributor

isinstance(arr, list)/isinstance(arr, tuple) doesn't work properly on JS arrays (one of them should be true.

Maybe will be fixed by the PR I made a few time back.

@PierreQuentel
Copy link
Contributor

I don't agree that either test should return True, a Javascript Array is not the same type as a Python list or tuple

from browser import window

t = window.js_list
print(hasattr(t, 'push')) # True

t = [1]
print(hasattr(t, 'push')) # False

@denis-migdal
Copy link
Contributor Author

Shouldn't they convert to one in jsobj2pyobj ?

@denis-migdal
Copy link
Contributor Author

Or to be put in a wrapper JSList inheriting from List, or JSTuple inheriting from Tuple, depending on what Object.isFrozen(jsarray) returns ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants