diff --git a/callable.mbt b/callable.mbt index 2d7157b..622846f 100644 --- a/callable.mbt +++ b/callable.mbt @@ -35,6 +35,11 @@ fn PyCallable::create_by_ref_unchecked( PyCallable::{ obj: PyObject::create(obj) } } +///| +test { + ignore(PyCallable::create_by_ref_unchecked) +} + ///| pub fn PyCallable::dump(self : PyCallable) -> Unit { self.obj.dump() diff --git a/cpython/context.mbt b/cpython/context.mbt index bed934d..5cc7b3c 100644 --- a/cpython/context.mbt +++ b/cpython/context.mbt @@ -23,20 +23,20 @@ pub extern "C" fn py_context_var_new( ///| pub extern "C" fn py_context_var_get( - var : PyObjectRef, + pyvar : PyObjectRef, default_value : PyObjectRef, value : ArrayPyObjectRef ) -> Int = "PyContextVar_Get" ///| pub extern "C" fn py_context_var_set( - var : PyObjectRef, + pyvar : PyObjectRef, value : PyObjectRef ) -> PyObjectRef = "PyContextVar_Set" ///| pub extern "C" fn py_context_var_reset( - var : PyObjectRef, + pyvar : PyObjectRef, token : PyObjectRef ) -> Int = "PyContextVar_Reset" diff --git a/cpython/core.mbt b/cpython/core.mbt index 6295f4d..b07538d 100644 --- a/cpython/core.mbt +++ b/cpython/core.mbt @@ -55,6 +55,12 @@ fn CStr::to_string_with_length(self : CStr, len : UInt) -> String { c_str_to_moonbit_str_with_length(self, len) } +///| +test { + ignore(CStr::to_string_with_length) + ignore(CWStr::from) +} + ///| fn CWStr::from(s : String) -> CWStr { moonbit_str_to_cw_str(s) @@ -70,6 +76,12 @@ fn CWStr::to_string_with_length(self : CWStr, len : UInt) -> String { cw_str_to_moonbit_str_with_length(self, len) } +///| +test { + ignore(CWStr::to_string_with_length) + ignore(CWStr::to_string) +} + ///| extern "C" fn py_object_is_null(obj : PyObjectRef) -> Int = "Moonbit_PyObjectRef_is_null" diff --git a/float.mbt b/float.mbt index 3bbec35..a23c0a3 100644 --- a/float.mbt +++ b/float.mbt @@ -29,6 +29,11 @@ fn PyFloat::create_by_ref_unchecked(obj : @cpython.PyObjectRef) -> PyFloat { PyFloat::{ obj: PyObject::create(obj) } } +///| +test { + ignore(PyFloat::create_by_ref_unchecked) +} + ///| Create a PyFloat from a Double value. /// /// ## Example diff --git a/integer.mbt b/integer.mbt index 704a8ba..79c8b99 100644 --- a/integer.mbt +++ b/integer.mbt @@ -32,6 +32,11 @@ fn PyInteger::create_by_ref_unchecked(obj : @cpython.PyObjectRef) -> PyInteger { PyInteger::{ obj: PyObject::create(obj) } } +///| +test { + ignore(PyInteger::create_by_ref_unchecked) +} + ///| Create a PyInteger from an integer. /// /// ## Example diff --git a/list.mbt b/list.mbt index bd57d60..b24bd49 100644 --- a/list.mbt +++ b/list.mbt @@ -251,7 +251,9 @@ pub fn[T : IsPyObject] PyList::op_set( idx : Int, item : T ) -> Unit { - self.set?(idx, item).unwrap() + self.set(idx, item) catch { + _ => panic() + } } ///| Let python interpreter print the list directly. diff --git a/main/main.mbt b/main/main.mbt index 9033e5a..265c8c8 100644 --- a/main/main.mbt +++ b/main/main.mbt @@ -17,7 +17,7 @@ fn main { args..set(0, py_nums) // It's equivalent to `cnt = Counter(nums)` - guard counter.invoke?(args~) is Ok(Some(cnt)) + guard (try? counter.invoke(args~)) is Ok(Some(cnt)) guard cnt is PyDict(cnt) // `print(cnt)` diff --git a/module.mbt b/module.mbt index f1165ae..ab67540 100644 --- a/module.mbt +++ b/module.mbt @@ -35,6 +35,10 @@ fn PyModule::create_by_ref_unchecked( PyModule::{ obj: PyObject::create(obj_ref), name: None, attrs: Map::new() } } +///| +test { + ignore(PyModule::create_by_ref_unchecked) +} // REVIEW: what if user call pyimport twice or more? ///| Import a python module diff --git a/str.mbt b/str.mbt index c735c91..a5c19b0 100644 --- a/str.mbt +++ b/str.mbt @@ -35,6 +35,11 @@ fn PyString::create_by_ref_unchecked( PyString::{ obj: PyObject::create(obj_ref) } } +///| +test { + ignore(PyString::create_by_ref_unchecked) +} + ///| Create a PyString from a string /// /// ## Example diff --git a/test/object_test.mbt b/test/object_test.mbt index 2d09691..912be8f 100644 --- a/test/object_test.mbt +++ b/test/object_test.mbt @@ -123,6 +123,6 @@ test "PyDict Test" { inspect(dict, content="{1: 1, 2: 4, 3: 9}") let list = PyList::new() list..append(PyInteger::from(3))..append(PyInteger::from(2)) - let e = dict.setByObj?(list, PyInteger::from(42)) + let e = try? dict.setByObj(list, PyInteger::from(42)) inspect(e, content="Err(KeyIsUnHashableError)") } diff --git a/time/lib.mbt b/time/lib.mbt index 84cd714..e3966dc 100644 --- a/time/lib.mbt +++ b/time/lib.mbt @@ -25,9 +25,8 @@ let singleton : () -> TimeModule = get_lib() ///| fn get_lib() -> () -> TimeModule { @python.init_py() - let lib = match new?() { - Ok(lib) => lib - Err(e) => { + let lib = new() catch { + e => { println(e) panic() } @@ -41,7 +40,7 @@ pub fn sleep(seconds : Double) -> Unit { guard lib.time.get_attr("sleep") is Some(PyCallable(f)) let args = PyTuple::new(1) args..set(0, PyFloat::from(seconds)) - let _ = f.invoke?(args~) + let _ = try? f.invoke(args~) () } @@ -54,7 +53,7 @@ pub fn time() -> Double { println("Error: Could not get time.time function") // Placeholder error value return 0.0 } - guard f.invoke?().unwrap() is Some(PyFloat(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyFloat(t)) else { println("Error: time.time did not return a float") // Placeholder error value return 0.0 } @@ -69,7 +68,7 @@ pub fn time_ns() -> Int64 { println("Error: Could not get time.time_ns function") // Placeholder error value return 0L } - guard f.invoke?().unwrap() is Some(PyInteger(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyInteger(t)) else { println("Error: time.time_ns did not return an integer") // Placeholder error value return 0L } @@ -84,7 +83,7 @@ pub fn monotonic() -> Double { println("Error: Could not get time.monotonic function") return 0.0 } - guard f.invoke?().unwrap() is Some(PyFloat(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyFloat(t)) else { println("Error: time.monotonic did not return a float") return 0.0 } @@ -99,7 +98,7 @@ pub fn monotonic_ns() -> Int64 { println("Error: Could not get time.monotonic_ns function") return 0L } - guard f.invoke?().unwrap() is Some(PyInteger(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyInteger(t)) else { println("Error: time.monotonic_ns did not return an integer") return 0L } @@ -114,7 +113,7 @@ pub fn perf_counter() -> Double { println("Error: Could not get time.perf_counter function") return 0.0 } - guard f.invoke?().unwrap() is Some(PyFloat(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyFloat(t)) else { println("Error: time.perf_counter did not return a float") return 0.0 } @@ -129,7 +128,7 @@ pub fn perf_counter_ns() -> Int64 { println("Error: Could not get time.perf_counter_ns function") return 0L } - guard f.invoke?().unwrap() is Some(PyInteger(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyInteger(t)) else { println("Error: time.perf_counter_ns did not return an integer") return 0L } @@ -144,7 +143,7 @@ pub fn process_time() -> Double { println("Error: Could not get time.process_time function") return 0.0 } - guard f.invoke?().unwrap() is Some(PyFloat(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyFloat(t)) else { println("Error: time.process_time did not return a float") return 0.0 } @@ -159,7 +158,7 @@ pub fn process_time_ns() -> Int64 { println("Error: Could not get time.process_time_ns function") return 0L } - guard f.invoke?().unwrap() is Some(PyInteger(t)) else { + guard (try? f.invoke()).unwrap() is Some(PyInteger(t)) else { println("Error: time.process_time_ns did not return an integer") return 0L } @@ -179,9 +178,9 @@ pub fn ctime(secs_option : Double?) -> String { Some(secs) => { let args = PyTuple::new(1) args..set(0, PyFloat::from(secs)) - f.invoke?(args~).unwrap() + (try? f.invoke(args~)).unwrap() } - None => f.invoke?().unwrap() // Call without arguments + None => (try? f.invoke()).unwrap() // Call without arguments } guard result is Some(PyString(s)) else { println("Error: time.ctime did not return a string") // Placeholder error value diff --git a/tkinter/tkinter.mbt b/tkinter/tkinter.mbt index 6e6f6f0..e573d1e 100644 --- a/tkinter/tkinter.mbt +++ b/tkinter/tkinter.mbt @@ -49,9 +49,8 @@ let singleton : () -> Tkinter = get_lib() ///| fn get_lib() -> () -> Tkinter { @python.init_py() - let lib = match new?() { - Ok(lib) => lib - Err(e) => { + let lib = new() catch { + e => { println(e) panic() } @@ -63,7 +62,7 @@ fn get_lib() -> () -> Tkinter { pub fn Window::new() -> Window { let lib = singleton() guard lib.tkinter.get_attr("Tk") is Some(PyCallable(createWindow)) - guard createWindow.invoke?().unwrap() is Some(PyClass(window)) + guard (try? createWindow.invoke()).unwrap() is Some(PyClass(window)) Window::{ window, } } @@ -72,14 +71,14 @@ pub fn Window::set_title(self : Window, title : String) -> Unit { guard self.window.get_attr("title") is Some(PyCallable(setTitle)) let args = PyTuple::new(1) args..set(0, PyString::from(title)) - let _ = setTitle.invoke?(args~) + let _ = try? setTitle.invoke(args~) } ///| pub fn Window::mainloop(self : Window) -> Unit { guard self.window.get_attr("mainloop") is Some(PyCallable(mainloop)) - let _ = mainloop.invoke?() + let _ = try? mainloop.invoke() } @@ -91,13 +90,14 @@ pub fn Label::new(window : Window, text : String) -> Label { args..set(0, window.window) let kwargs = PyDict::new() kwargs..set("text", PyString::from(text)) - guard createLabel.invoke?(args~, kwargs~).unwrap() is Some(PyClass(label)) + guard (try? createLabel.invoke(args~, kwargs~)).unwrap() + is Some(PyClass(label)) Label::{ label, } } ///| pub fn Label::pack(self : Label) -> Unit { guard self.label.get_attr("pack") is Some(PyCallable(pack)) - let _ = pack.invoke?() + let _ = try? pack.invoke() } diff --git a/tuple.mbt b/tuple.mbt index 21dc263..8df9b31 100644 --- a/tuple.mbt +++ b/tuple.mbt @@ -54,6 +54,11 @@ fn PyTuple::create_by_ref_unchecked(obj_ref : @cpython.PyObjectRef) -> PyTuple { PyTuple::{ obj: PyObject::create(obj_ref) } } +///| +test { + ignore(PyTuple::create_by_ref_unchecked) +} + ///| Return the size of the tuple. /// /// ## Example: diff --git a/turtle/lib.mbt b/turtle/lib.mbt index c3d5483..4a1ec3f 100644 --- a/turtle/lib.mbt +++ b/turtle/lib.mbt @@ -34,9 +34,8 @@ let singleton : () -> Turtle = get_lib() ///| fn get_lib() -> () -> Turtle { @python.init_py() - let lib = match new?() { - Ok(lib) => lib - Err(e) => { + let lib = new() catch { + e => { println(e) panic() } @@ -50,6 +49,6 @@ pub fn bgcolor(color : Color) -> Unit { guard lib.turtle.get_attr("bgcolor") is Some(PyCallable(bgcolor)) let args = PyTuple::new(1) args..set(0, PyString::from(color.to_string())) - let _ = bgcolor.invoke?(args~) + let _ = try? bgcolor.invoke(args~) () } diff --git a/turtle/pen2.mbt b/turtle/pen2.mbt index 42fe3c0..97bb003 100644 --- a/turtle/pen2.mbt +++ b/turtle/pen2.mbt @@ -28,7 +28,7 @@ fn Pen::get_method(self : Pen, name : String) -> PyCallable? { pub fn Pen::new() -> Pen { let lib = singleton() guard lib.turtle.get_attr("Pen") is Some(PyCallable(createPen)) - guard createPen.invoke?().unwrap() is Some(PyClass(pen)) + guard (try? createPen.invoke()).unwrap() is Some(PyClass(pen)) Pen::{ pen, methods: Map::new() } } @@ -39,7 +39,7 @@ pub fn Pen::home(self : Pen) -> Unit { println("Failed to get Pen::home method") panic() } - let _ = func.invoke?() + let _ = try? func.invoke() () } @@ -57,7 +57,7 @@ pub fn Pen::pensize(self : Pen, size : Double) -> Unit { } let args = PyTuple::new(1) args..set(0, PyFloat::from(size)) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -68,7 +68,7 @@ pub fn Pen::xcor(self : Pen) -> Double { println("Failed to get Pen::xcor method") // Return a default value return 0.0 } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyFloat(x)) x.to_double() } @@ -80,7 +80,7 @@ pub fn Pen::ycor(self : Pen) -> Double { println("Failed to get Pen::ycor method") // Return a default value return 0.0 } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyFloat(y)) y.to_double() } @@ -92,7 +92,7 @@ pub fn Pen::position(self : Pen) -> (Double, Double) { println("Failed to get Pen::position method") return (0.0, 0.0) // Return a default value } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyTuple(tup)) else { println("Pen::position did not return a tuple") return (0.0, 0.0) // Return a default value @@ -121,7 +121,7 @@ pub fn Pen::heading(self : Pen) -> Double { println("Failed to get Pen::heading method") // Return a default value return 0.0 } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyFloat(h)) else { println("Pen::heading did not return a float") // Return a default value return 0.0 @@ -139,7 +139,7 @@ pub fn Pen::radians(self : Pen) -> Double { println("Failed to get Pen::radians method") // Return a default value return 0.0 } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyFloat(r)) else { println("Pen::radians did not return a float") // Return a default value return 0.0 @@ -157,7 +157,7 @@ pub fn Pen::speed(self : Pen, speed : Speed) -> Unit { } let args = PyTuple::new(1) args..set(0, speed.to_pynum()) // speed.to_pynum() converts enum to PyInteger - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -171,7 +171,7 @@ pub fn Pen::pencolor(self : Pen, color : Color) -> Unit { } let args = PyTuple::new(1) args..set(0, PyString::from(color.to_string().to_lower())) // Ensure lowercase - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -189,7 +189,7 @@ pub fn Pen::width(self : Pen, width : Double) -> Unit { } let args = PyTuple::new(1) args..set(0, PyFloat::from(width)) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -207,7 +207,7 @@ pub fn Pen::forward(self : Pen, distance : Double) -> Unit { } let args = PyTuple::new(1) args..set(0, PyFloat::from(distance)) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -226,7 +226,7 @@ pub fn Pen::backward(self : Pen, distance : Double) -> Unit { } let args = PyTuple::new(1) args..set(0, PyFloat::from(distance)) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -240,7 +240,7 @@ pub fn Pen::left(self : Pen, angle : Double) -> Unit { } let args = PyTuple::new(1) args..set(0, PyFloat::from(angle)) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -254,7 +254,7 @@ pub fn Pen::right(self : Pen, angle : Double) -> Unit { } let args = PyTuple::new(1) args..set(0, PyFloat::from(angle)) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -269,7 +269,7 @@ pub fn Pen::goto(self : Pen, x : Double, y : Double) -> Unit { } let args = PyTuple::new(2) args..set(0, PyFloat::from(x))..set(1, PyFloat::from(y)) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -280,7 +280,7 @@ pub fn Pen::hide(self : Pen) -> Unit { println("Failed to get Pen::hideturtle method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -291,7 +291,7 @@ pub fn Pen::penup(self : Pen) -> Unit { println("Failed to get Pen::penup method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -302,7 +302,7 @@ pub fn Pen::pendown(self : Pen) -> Unit { println("Failed to get Pen::pendown method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -325,7 +325,7 @@ pub fn Pen::dot(self : Pen, size : Double, color : Color) -> Unit { ..set(1, PyString::from(color.to_string().to_lower())) // Ensure lowercase // The return value of dot is the turtle object itself, which we ignore and drop. // The original code had a 'guard func.invoke(args~) is Some(PyClass(r)) r.drop()', which is correct for ignoring the return value. - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) // Simpler way to ignore return value } @@ -336,7 +336,7 @@ pub fn Pen::clear(self : Pen) -> Unit { println("Failed to get Pen::clear method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -352,7 +352,7 @@ pub fn Pen::fillcolor(self : Pen, color : Color) -> Unit { } let args = PyTuple::new(1) args..set(0, PyString::from(color.to_string().to_lower())) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -366,7 +366,7 @@ pub fn Pen::color(self : Pen, color : Color) -> Unit { } let args = PyTuple::new(1) args..set(0, PyString::from(color.to_string().to_lower())) - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -377,7 +377,7 @@ pub fn Pen::isdown(self : Pen) -> Bool { println("Failed to get Pen::isdown method") // Return a default value return false } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyBool(b)) b.to_bool() } @@ -389,7 +389,7 @@ pub fn Pen::show(self : Pen) -> Unit { println("Failed to get Pen::showturtle method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -400,7 +400,7 @@ pub fn Pen::isvisible(self : Pen) -> Bool { println("Failed to get Pen::isvisible method") // Return a default value return false } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyBool(b)) b.to_bool() } @@ -412,7 +412,7 @@ pub fn Pen::begin_fill(self : Pen) -> Unit { println("Failed to get Pen::begin_fill method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -423,7 +423,7 @@ pub fn Pen::end_fill(self : Pen) -> Unit { println("Failed to get Pen::end_fill method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -453,7 +453,7 @@ pub fn Pen::circle( Some(s) => kwargs.set("steps", PyInteger::from(s.to_int64())) None => () } - let _ = func.invoke?(args~, kwargs~) + let _ = try? func.invoke(args~, kwargs~) } @@ -466,7 +466,7 @@ pub fn Pen::stamp(self : Pen) -> Int { println("Failed to get Pen::stamp method") // Return a default error value return -1 } - let res = func.invoke?().unwrap() + let res = (try? func.invoke()).unwrap() guard res is Some(PyInteger(i)) else { println("Pen::stamp did not return an integer") // Return a default error value return -1 @@ -484,7 +484,7 @@ pub fn Pen::clearstamp(self : Pen, stamp_id : Int) -> Unit { } let args = PyTuple::new(1) args..set(0, PyInteger::from(stamp_id.to_int64())) - let _ = func.invoke?(args~).unwrap() + let _ = (try? func.invoke(args~)).unwrap() } @@ -505,7 +505,7 @@ pub fn Pen::clearstamps(self : Pen, n~ : Int? = None) -> Unit { // Although Python's clearstamps takes n as positional or keyword, // passing it as keyword is safer with Option handling. // We invoke with an empty args tuple and the kwargs dictionary. - let _ = func.invoke?(kwargs~).unwrap() + let _ = (try? func.invoke(kwargs~)).unwrap() } @@ -516,7 +516,7 @@ pub fn Pen::reset(self : Pen) -> Unit { println("Failed to get Pen::reset method") return } - let _ = func.invoke?() + let _ = try? func.invoke() } @@ -530,7 +530,7 @@ pub fn Pen::shape(self : Pen, name : Shape) -> Unit { } let args = PyTuple::new(1) args..set(0, PyString::from(name.to_string().to_lower())) // Assuming Shape enum with Show derived - let _ = func.invoke?(args~) + let _ = try? func.invoke(args~) } @@ -562,6 +562,6 @@ pub fn Pen::shapesize( Some(o) => kwargs.set("outline", PyInteger::from(o.to_int64())) None => () } - let _ = func.invoke?(kwargs~) + let _ = try? func.invoke(kwargs~) } diff --git a/turtle/screen.mbt b/turtle/screen.mbt index b664da6..b7cb671 100644 --- a/turtle/screen.mbt +++ b/turtle/screen.mbt @@ -7,7 +7,7 @@ pub struct Screen { pub fn Screen::new() -> Screen { let lib = singleton() guard lib.turtle.get_attr("Screen") is Some(PyCallable(createScreen)) - guard createScreen.invoke?().unwrap() is Some(PyClass(screen)) + guard (try? createScreen.invoke()).unwrap() is Some(PyClass(screen)) Screen::{ screen, } } @@ -16,7 +16,7 @@ pub fn Screen::setup(self : Screen, width : Double, height : Double) -> Unit { guard self.screen.get_attr("setup") is Some(PyCallable(setup)) let args = PyTuple::new(2) args..set(0, PyFloat::from(width))..set(1, PyFloat::from(height)) - let _ = setup.invoke?(args~) + let _ = try? setup.invoke(args~) } @@ -25,7 +25,7 @@ pub fn Screen::title(self : Screen, text : String) -> Unit { guard self.screen.get_attr("title") is Some(PyCallable(title)) let args = PyTuple::new(1) args..set(0, PyString::from(text)) - let _ = title.invoke?(args~) + let _ = try? title.invoke(args~) } @@ -34,14 +34,14 @@ pub fn Screen::tracer(self : Screen, n : Int) -> Unit { guard self.screen.get_attr("tracer") is Some(PyCallable(tracer)) let args = PyTuple::new(1) args..set(0, PyInteger::from(n.to_int64())) - let _ = tracer.invoke?(args~) + let _ = try? tracer.invoke(args~) } ///| pub fn Screen::update(self : Screen) -> Unit { guard self.screen.get_attr("update") is Some(PyCallable(update)) - let _ = update.invoke?() + let _ = try? update.invoke() } @@ -50,6 +50,6 @@ pub fn Screen::bgcolor(self : Screen, color : Color) -> Unit { guard self.screen.get_attr("bgcolor") is Some(PyCallable(bgcolor)) let args = PyTuple::new(1) args..set(0, PyString::from(color.to_string())) - let _ = bgcolor.invoke?(args~) + let _ = try? bgcolor.invoke(args~) }