question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`del` on local variable `setup_rt` yields `UnboundLocalError: local variable 'setup_rt' referenced before assignment`

See original GitHub issue
  • Nuitka version, full Python version and Platform (Windows, OSX, Linux …)
> /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
  • How did you install Nuitka and Python (pip, anaconda, deb, rpm, from source, what is a virtualenv …), this is very important usually.

/opt/conda/bin/python -m pip install -U "https://github.com/Nuitka/Nuitka/archive/develop.zip"

  • Many times when you get an error from Nuitka, your setup may be so special that even a “hello world” program will not work, please try that and report it instead.

Hello world-style programs and more complex programs work. Commenting out the failing line - line 140 - resolves the issue as well.

  • If possible please supply a Short, Self Contained, Correct, Example that demonstrates the issue i.e a small piece of code which reproduces the issue and can be run with out any other (or as few as possible) external dependencies.

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.bin

No errors running:

  • /opt/conda/bin/python3 -m nuitka --nofollow-imports test.py && ./test.bin
  • /opt/conda/bin/python3 test.py

I tried but was unable to come up with a simpler reproduction that does not involve ruamel.yaml.

  • If this is a regression (used to work in an earlier version of Nuitka), please note what you know about that.

Did not work on 0.6.7 either; same error.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kayhayencommented, May 13, 2020

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.

1reaction
kayhayencommented, May 13, 2020

That’s absolutely perfect @abl and makes a fix easy I believe. Expect one later today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnboundLocalError: local variable referenced before ...
The unboundlocalerror: local variable referenced before assignment is raised when you try to use a variable before it has been assigned in the...
Read more >
Python 3: UnboundLocalError: local variable referenced ...
Naturally, this creates a variable inside the function's scope called ... you try to reference the variable before it is locally assigned.
Read more >
Python local variable referenced before assignment Solution
The UnboundLocalError: local variable referenced before assignment error is raised when you try to assign a value to a local variable before it ......
Read more >
Local Variable Referenced Before Assignment - STechies
The “local variable referenced before assignment” error occurs when you give reference of a local variable without assigning any value. Example:
Read more >
Local variable referenced before assignment in Python
The Python UnboundLocalError: Local variable referenced before assignment occurs when we reference a local variable before assigning a value ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found