Skip to content

JS object get is always shadowed #306

Closed

Description

@YarnSaw

Issue type

Bug

How did you install PythonMonkey?

Source

OS platform and distribution

Linux Ubuntu 20.04

Python version (python --version)

3.11.8

PythonMonkey version (pip show pythonmonkey)

0.3.1.dev353+ae2b7a0

Bug Description

A 'get' property on a js object is always shadowed by the built-in 'get' method from dict objects when brought to python. For dicts created directly in python, accessing using the dot operator returns the built-in 'get' method while accessing with square brackets returns the value in the dict for the key of 'get'.

Standalone code to reproduce the issue

import pythonmonkey as pm

jsObj = pm.eval("({get: 'value'})")
print(jsObj.get)      # get method of dict object
print(jsObj['get'])   # get method of dict object
################
pyDict = {"get": "value"}
print(pyDict.get)     # get method of dict object
print(pyDict['get'])  # 'value'


### Relevant log output or backtrace

```shell
$ python test.py
<built-in method get of dict object at 0x7fb8370eb380>
<built-in method get of dict object at 0x7fb8370eb380>
<built-in method get of dict object at 0x7fb837080080>
value

Additional info if applicable

No response

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

wes/DCP-4054/make-dcp-client-grok-pythonmonkey

Activity

  1. moved this from Backlog to In progress in PythonMonkey Kanban Boardon Mar 20, 2024
  2. philippedistributive commented on Mar 20, 2024

    @philippedistributive
    Contributor

    we can't distinguish between the . operator and the [] (unexpected), but we can make it possible to fetch the get property's value indeed

  3. philippedistributive commented on Mar 20, 2024

    @philippedistributive
    Contributor

    ok found the way to distinguish between the . and the []

  4. philippedistributive commented on Mar 28, 2024

    @philippedistributive
    Contributor

    PR has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions