diff --git a/core/datatypes.py b/core/datatypes.py index 6b4abcc..b323990 100755 --- a/core/datatypes.py +++ b/core/datatypes.py @@ -1270,7 +1270,12 @@ def execute(self, args: list[Value], kwargs: dict[str, Value]) -> RTResult[Value if res.should_return() and res.func_return_value is None: return res - ret_value = (value if self.should_auto_return else None) or res.func_return_value or Null.null() + if self.should_auto_return: + ret_value = value + else: + ret_value = res.func_return_value + if ret_value is None: + ret_value = Null.null() return res.success(ret_value) def copy(self) -> Function: diff --git a/core/parser.py b/core/parser.py index d2b76d7..a9b5b69 100755 --- a/core/parser.py +++ b/core/parser.py @@ -1586,8 +1586,8 @@ def failure(self, error: Error) -> RTResult[T]: def should_return(self) -> bool: # Note: this will allow you to continue and break outside the current function return bool( - self.error - or self.func_return_value + self.error is not None + or self.func_return_value is not None or self.loop_should_continue or self.loop_should_break or self.should_exit diff --git a/radon.py b/radon.py index db5ae2c..379dd5d 100755 --- a/radon.py +++ b/radon.py @@ -133,7 +133,8 @@ def main(argv: list[str]) -> None: base_core.global_symbol_table.set("argv", base_core.radonify(argv, pos, pos, Context(""))) if source_file is not None: head, tail = os.path.split(source_file) - os.chdir(head) + if head != "": + os.chdir(head) with open(tail, "r") as f: source = f.read() (result, error, should_exit) = base_core.run(source_file, source)