getindex(::PyObject, ::Union{Symbol, AbstractString}) should not call getproperty
- Lingua principale
- Julia
- Stelle
- 1.5k
- Fork
- 186
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Sometimes the Python object that underlies your PyObject needs to be accessed with a slice-like notation with a string rather than dot notation. `dict`s would be one example, but since they're converted to Julia `Dict`s, they don't really highlight the issue. Here is where I'm running into it. Unfortunately I don't have a better example than this (this one requires having MATLAB installed to run):
```julia
julia> using PyCall
```
```julia
julia> py"""
import matlab.engine
eng = matlab.engine.start_matlab()
"""
```
```julia
julia> eng = py"eng"
PyObject
```
```julia
julia> py"""
eng.workspace['a'] = 0.0
"""
```
```julia
julia> eng.workspace
Name Size Bytes Class Attributes
a 1x1 8 double
PyObject
```
```julia
julia> eng.workspace["a"]
ERROR: KeyError: key "a" not found
...
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Start by locating the getindex(::PyObject, ::Union{Symbol, AbstractString}) implementation and reproduce the reported eng.workspace["a"] failure if MATLAB is available. Done means string indexing accesses the underlying Python object correctly instead of following getproperty and no longer raises KeyError for the shown example.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- julia, python
- Ambito
- backend-api-design
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100