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

spack-python does not exit failure on exceptions #34489

Closed
3 tasks done
Jordan474 opened this issue Dec 13, 2022 · 0 comments · Fixed by #34547
Closed
3 tasks done

spack-python does not exit failure on exceptions #34489

Jordan474 opened this issue Dec 13, 2022 · 0 comments · Fixed by #34547
Assignees
Labels
bug Something isn't working impact-medium
Milestone

Comments

@Jordan474
Copy link
Contributor

Steps to reproduce

Spack-python could be powerful tool to easily write scripts, but it ignores exceptions, which makes writing reliable scripts impossible.

For example:

$ cat myscript
#!/usr/bin/env spack-python
import badimport

$ chmod +x myscript

$ source share/spack/setup-env.sh
$ ./myscript; echo $?
Traceback (most recent call last):
  File "/usr/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "./myscript", line 2, in <module>
    import badimport
ModuleNotFoundError: No module named 'badimport'
0

Its exit status is 0 instead of non-zero.

It seems spack-python actually runs an interactive console, I'm not sure this is appropriate for this use-case (described in bin/spack-python file) ?

Error message

Spack-python should exit with a non-zero status on errors.

Information on your system

  • Spack: 0.20.0.dev0 (f5fd7e5109b24bfb5e5e5321091d083fa32cae17)
  • Python: 3.10.6
  • Platform: linux-ubuntu22.04-skylake
  • Concretizer: clingo

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output
@Jordan474 Jordan474 added bug Something isn't working triage The issue needs to be prioritized labels Dec 13, 2022
@Jordan474 Jordan474 changed the title spack-python does not report exceptions spack-python does not exit failure on exceptions Dec 13, 2022
@alalazo alalazo added this to the v0.19.1 milestone Dec 13, 2022
@alalazo alalazo added impact-medium and removed triage The issue needs to be prioritized labels Dec 15, 2022
alalazo added a commit to alalazo/spack that referenced this issue Dec 15, 2022
fixes spack#34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
@alalazo alalazo self-assigned this Dec 15, 2022
alalazo added a commit that referenced this issue Dec 15, 2022
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
benkirk pushed a commit to benkirk/spack that referenced this issue Dec 16, 2022
fixes spack#34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
haampie pushed a commit that referenced this issue Dec 22, 2022
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
haampie pushed a commit that referenced this issue Dec 23, 2022
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
haampie pushed a commit that referenced this issue Jan 18, 2023
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
haampie pushed a commit that referenced this issue Jan 24, 2023
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
haampie pushed a commit that referenced this issue Feb 7, 2023
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
alalazo added a commit that referenced this issue Feb 7, 2023
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
amd-toolchain-support pushed a commit to amd-toolchain-support/spack that referenced this issue Feb 16, 2023
fixes spack#34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working impact-medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants