Skip to content

[interop] Iterables exposed as arrays, but not accessible #130

@fniephaus

Description

@fniephaus

The pycountry package exposes a list of all countries as an pycountry.ExistingCountries which implements __iter__ and __len__. The following TruffleSqueak screenshot demonstrates that pycountry.countries appears correctly as an array-like object. However, it is not possible to access its values through the interop API. Either, iterables should not be exposed like this, or InteropLibrary#readArrayElement is not allowed to fail.

TruffleSqueak screenshot

image

Python workspace

import pycountry

pycountry.countries => ForeignObject[arraySize=249,memberSize=41]

str(type(pycountry.countries)) => '<class ''pycountry.ExistingCountries''>'

pycountry.countries[1] => `Error: TypeError: 'ExistingCountries' object is not subscriptable` (this is expected)

list(pycountry.countries)[1] => ForeignObject[memberSize=26]

Smalltalk workspace

(Polyglot eval: 'python' string: 'pycountry.countries') => ForeignObject[arraySize=249,memberSize=41]
(Polyglot eval: 'python' string: 'pycountry.countries') at: 1

/cc @timfel

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions