Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unbound local variable error in section console #1307

Merged
merged 3 commits into from Jul 3, 2018
Merged

Fix unbound local variable error in section console #1307

merged 3 commits into from Jul 3, 2018

Conversation

@c-w
Copy link
Contributor

@c-w c-w commented Jul 3, 2018

Issue found by @taupalosaurus

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

In order to make the fix easier, I first did some refactoring/cleanup in 380d88f. The actual fix is in 2d102b6.

c-w added 2 commits Jul 3, 2018
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
```
Copy link
Member

@colinschoen colinschoen left a comment

LGTM

Thanks.

Loading

@colinschoen colinschoen merged commit c91bea4 into okpy:master Jul 3, 2018
3 checks passed
Loading
@c-w c-w deleted the bug/c-w/section-console-crash branch Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants