JuliaPy / JuliaPy/PyCall.jl

getindex(::PyObject, ::Union{Symbol, AbstractString}) should not call getproperty

Ouverte
#820 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Julia
Étoiles
1.5k
Forks
186
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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
...
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par localiser l’implémentation de getindex(::PyObject, ::Union{Symbol, AbstractString}) et reproduisez l’échec signalé de eng.workspace["a"] si MATLAB est disponible. Le travail est terminé lorsque l’indexation par chaîne accède correctement à l’objet Python sous-jacent au lieu de suivre getproperty et ne lève plus de KeyError pour l’exemple présenté.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
julia, python
Domaine
backend-api-design
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.