bytecodealliance / bytecodealliance/componentize-py
Allow dynamic imports in sandbox example
- Lenguaje dominante
- Rust
- Estrellas
- 277
- Forks
- 51
- Merge medio
- 12 h 10 min
- PR fusionados (30 d)
- 10
Descripción
I'd like to execute code using the sandbox example, but am running into an issue. I want to allow exec'd code to import packages, but if I don't import packages in the host script, the guest code won't run.
```python
# Guest code
import json
print(json.dumps({"message": "Hello"}))
```
```python
# Works
import sys
import json
from command import exports
class Run(exports.Run):
def run(self):
with open(sys.argv[1]) as f:
code = f.read()
exec(code)
```
```python
# Fails
import sys
from command import exports
class Run(exports.Run):
def run(self):
with open(sys.argv[1]) as f:
code = f.read()
exec(code)
```
Guía de contribución
Línea de trabajo
Start at the sandbox example's Run.run entry point, especially where it reads the guest code and calls exec. Run the shown guest program with and without the host-side json import, then trace the import behavior. Done means guest code can dynamically import json without requiring the host script to import it first.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- security
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100