Fix unbound local variable error in section console#1307
Merged
Conversation
Full stacktrace:
```
[2018-07-03 16:54:18,984] ERROR in app: Exception on /admin/course/1/section/ [GET]
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.5/site-packages/flask_restful/__init__.py", line 271, in error_router
return original_handler(e)
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1518, in handle_user_exception
return handler(e)
File "/usr/local/lib/python3.5/site-packages/applicationinsights/flask/ext.py", line 167, in exception_handler
raise exception
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.5/site-packages/flask_login/utils.py", line 228, in decorated_view
return func(*args, **kwargs)
File "/code/server/controllers/admin.py", line 56, in wrapper
return func(*args, **kwargs)
File "/code/server/controllers/admin.py", line 494, in section_console
enrollments=enrollments, staff=staff, emails=student_emails_str)
UnboundLocalError: local variable 'enrollments' referenced before assignment
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue found by @taupalosaurus
Full stacktrace:
In order to make the fix easier, I first did some refactoring/cleanup in 380d88f. The actual fix is in 2d102b6.