From 07e1079f280a9426d61c1d93ef987c7a9f0b8f84 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Thu, 11 Nov 2021 14:18:52 +0800 Subject: [PATCH] nac3artiq: avoid using py.eval to get id of class virtual --- nac3artiq/src/lib.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 9e7cae5e..83a52a1d 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -281,11 +281,17 @@ impl Nac3 { let typing_mod = PyModule::import(py, "typing").unwrap(); let types_mod = PyModule::import(py, "types").unwrap(); let primitive_ids = PrimitivePythonId { - virtual_id: py.eval( - "id(virtual)", - Some(builtins_mod.getattr("globals").unwrap().call0().unwrap().extract().unwrap()), - None - ).unwrap().extract().unwrap(), + virtual_id: id_fn + .call1((builtins_mod + .getattr("globals") + .unwrap() + .call0() + .unwrap() + .get_item("virtual") + .unwrap(), + )).unwrap() + .extract() + .unwrap(), generic_alias: ( id_fn .call1((typing_mod.getattr("_GenericAlias").unwrap(),))