UnboundLocalError: local variable 'res' referenced before assignment
See original GitHub issueI get an sporadically error/stacktrace after multiple use of the command “ykman slot calculate -T 2”. Have you any ideas why?
Python Version: 3.6.0 OS: macOS 10.12.3
➜ ~ ykman -v
YubiKey Manager (ykman) version: 0.3.1
Libraries:
libykpers 1.17.3
libu2f-host 1.1.3
libusb 1.0.21
➜ ~ ykman slot calculate -T 2
Touch your YubiKey...
722158
➜ ~ ykman slot calculate -T 2
Touch your YubiKey...
722158
➜ ~ ykman slot calculate -T 2
Touch your YubiKey...
Traceback (most recent call last):
File "/usr/local/bin/ykman", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/ykman/cli/__main__.py", line 116, in main
cli(obj={})
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/ykman/cli/slot.py", line 359, in calculate
click.echo(res)
UnboundLocalError: local variable 'res' referenced before assignment
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Python 3: UnboundLocalError: local variable referenced ...
In your case, Var1 is considered as a local variable, and it's used before being set, thus the error. To solve this problem,...
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 to it in a ......
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 >[SOLVED] Local Variable Referenced Before Assignment
Unboundlocalerror: local variable referenced before assignment occurs when a variable is used before its created. Python does not have the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The error handling does look wrong though. The inner try catches the error, but if the error code isn’t 4, it falls though to .echo(res) (which is undefined). it should give you a nicer error based on the error code from ykpers.
The actual error should be printed now, feel free to install ykman from the repo or wait for the next release to try it out.