Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #148

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion radon.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def main(argv: list[str]) -> None:
base_core.global_symbol_table.set("argv", base_core.radonify(argv, pos, pos, Context("<global>")))
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)
Expand Down