Skip to content

error if checked program calls quit() #41

@stgm

Description

@stgm

This code:

if __name__ == '__main__':
    time = str(input("Hoe laat is het? "))
    if meal(time) == 'ontbijt':
        x = 'ontbijt'
    elif meal(time) == 'lunch':
        x = 'lunch'
    elif meal(time) == 'avondeten':
        x = 'avondeten'
    elif meal(time) == None:
        quit(1)
    print(f"het is tijd voor {x}")

yields ExitError -> exit(1) while trying to import the code as a check result.
I think this is expected behaviour from CheckPy.

The phrase while trying to import the code is somewhat misleading for students; it is clearly running the code as main or it would not have reached the quit() call. Would be good if the error correctly reports this context.


Now, when doing quit() without an exit code, which was actually what this student submitted, the CheckPy code crashes internally:

  File "checkpy/lib/basic.py", line 205, in _getModuleAndOutputOf
    message = "exit({}) while trying to import the code".format(int(e.args[0])),
                                                                ~~~^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

Would be nice if it handles quit() without an exit code, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions