From 016cbf2b9028c554c67da01238156ce2e7c682ff Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 6 Nov 2021 14:29:23 +0800 Subject: [PATCH] nac3artiq: return bytes in compile_method_to_mem --- nac3artiq/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 62dbd0a5..7ac86c10 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -9,7 +9,7 @@ use inkwell::{ OptimizationLevel, }; use pyo3::prelude::*; -use pyo3::{exceptions, types::PyList}; +use pyo3::{exceptions, types::PyList, types::PyBytes}; use nac3parser::{ ast::{self, StrRef}, parser::{self, parse_program}, @@ -495,11 +495,11 @@ impl Nac3 { method_name: &str, args: Vec<&PyAny>, py: Python, - ) -> PyResult> { + ) -> PyResult { let filename_path = self.working_directory.path().join("module.elf"); let filename = filename_path.to_str().unwrap(); self.compile_method_to_file(obj, method_name, args, filename, py)?; - Ok(fs::read(filename).unwrap()) + Ok(PyBytes::new(py, &fs::read(filename).unwrap()).into()) } }