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

Custom lists not working with PythonMonkey #474

Open
Andereoo opened this issue Mar 7, 2025 · 0 comments
Open

Custom lists not working with PythonMonkey #474

Andereoo opened this issue Mar 7, 2025 · 0 comments

Comments

@Andereoo
Copy link

Andereoo commented Mar 7, 2025

Issue type

Bug

How did you install PythonMonkey?

Installed from pip

OS platform and distribution

Ubuntu

Python version (python --version)

3.12

PythonMonkey version (pip show pythonmonkey)

1.1.0

Bug Description

Hello! Love this project! I have a Python class inheriting from a list with a couple extra methods and am passing that to JavaScript (see the example below). It seems that my added methods don't exist in JavaScript. If the class inherits from set or tuple it works, but then the value is not ordered anymore. I might be doing something wrong, but any help with this would be hugely appreciated!

Standalone code to reproduce the issue

import pythonmonkey as pm


class Collection(list):
    def item(self):
        print("Do something")
            
pm.eval("(function(pyFunc) { globalThis.document = pyFunc; })")(Collection((1,2,3)))

pm.eval("console.log(document.item())")

Relevant log output or backtrace

Traceback (most recent call last):
  File "/home/andrew/Downloads/TkinterWebBrowser.py", line 10, in <module>
    pm.eval("console.log(document.item())")
pythonmonkey.SpiderMonkeyError: Error in file evaluate, on line 1, column 22:
TypeError: document.item is not a function
Stack Trace:
  @evaluate:1:22

Additional info if applicable

What branch of PythonMonkey were you developing on? (If applicable)

No response

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

No branches or pull requests

1 participant