> /opt/conda/bin/python -m nuitka --version
0.6.9rc1
Python: 3.7.4 (default, Aug 13 2019, 15:17:50)
Executable: /opt/conda/bin/python
OS: Darwin
Arch: x86_64
/opt/conda/bin/python -m pip install -U "https://github.com/Nuitka/Nuitka/archive/develop.zip"
Hello world-style programs and more complex programs work. Commenting out the failing line - line 140 - resolves the issue as well.
First install ruamel.yaml version 0.16.10 and then create the following test.py:
from ruamel.yaml import YAML
if __name__ == "__main__":
print(YAML())
Compiled using /opt/conda/bin/python3 -m nuitka --no-pyi-file --python-flag=no_site --plugin-enable=pylint-warnings --remove-output --nofollow-imports --show-scons --standalone --clang --include-module=ruamel.yaml test.py
This yields the following output when running test.dist/test:
Traceback (most recent call last):
File "/Users/alash/git/minimal/test.dist/test.py", line 4, in <module>
File "/Users/alash/git/minimal/test.dist/ruamel/yaml/main.py", line 140, in __init__
UnboundLocalError: local variable 'setup_rt' referenced before assignment
The same error is yielded with:
/opt/conda/bin/python3 -m nuitka --follow-import-to=ruamel.yaml --follow-import-to=ruamel test.py && ./test.binNo errors running:
/opt/conda/bin/python3 -m nuitka --nofollow-imports test.py && ./test.bin/opt/conda/bin/python3 test.pyI tried but was unable to come up with a simpler reproduction that does not involve ruamel.yaml.
Did not work on 0.6.7 either; same error.
https://sourceforge.net/p/ruamel-yaml/code/ci/default/tree/main.py#l140 the failing line; it seems that setup_rt should unconditionally exist at that line.
In case it helps, I generated the c with the del and with a blank line instead, yielding the following diff:
diff -r with_del.build/module.ruamel.yaml.main.c without_del.build/module.ruamel.yaml.main.c
4843,4858d4842
< tmp_result = var_setup_rt == NUITKA_BOOL_UNASSIGNED;
< var_setup_rt = NUITKA_BOOL_UNASSIGNED;
< if (tmp_result == false) {
<
< exception_type = PyExc_UnboundLocalError;
< Py_INCREF(exception_type);
< exception_value = PyUnicode_FromFormat("local variable '%s' referenced before assignment", "setup_rt");
< exception_tb = NULL;
< NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
< CHAIN_EXCEPTION(exception_value);
<
< exception_lineno = 140;
< type_description_1 = "ooooooooobo";
< goto frame_exception_exit_1;
< }
<
It seems that tmp_result = var_setup_rt == NUITKA_BOOL_UNASSIGNED; should be tmp_result = var_setup_rt != NUITKA_BOOL_UNASSIGNED; - i.e. the exception should be raised iff var_setup_rt is unassigned?
That's absolutely perfect @abl and makes a fix easy I believe. Expect one later today.
This must be a recent regression, I think previously a del precluded from C boolean shape, and therefore the buggy code was dead. I pushed a fix to factory and will consider making a hotfix later today.
This is release as part of 0.6.8.1 hotfix.