-
-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
Expected Behavior
When parsing a singularity definition with comments before the bootstrap line, the file should be successfully parsed
Actual Behavior
The parsing throws an UnboundLocalError: local variable 'comments' referenced before assignment
Steps to Reproduce
- Create a definition file with the following content:
# Minimal Example - This comment line is important for reproduction purposes
Bootstrap: docker
From: ubuntu:16.04
- Start a python interpreter in that directory, with
spythoninstalled - Execute
from spython.main.parse.parsers import SingularityParser
SingularityParser("minimal.def")in that directory
Context
- Operating System: Arch Linux
- singularity version: not installed
- spython version: 0.1.15
- python version: 3.9.7
Failure Logs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/singularity.py", line 30, in __init__
super(SingularityParser, self).__init__(filename, load)
File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/base.py", line 56, in __init__
self.parse()
File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/singularity.py", line 41, in parse
self.load_recipe()
File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/singularity.py", line 333, in load_recipe
elif stripped.startswith("#") and stripped not in comments:
UnboundLocalError: local variable 'comments' referenced before assignment
Possible Fix
https://github.com/singularityhub/singularity-cli/blob/master/spython/main/parse/parsers/singularity.py#L318
That comments definition could to be repeated somewhere above
Metadata
Metadata
Assignees
Labels
No labels