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

Conversation

Projects
None yet
2 participants
@c-w
Copy link
Contributor

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 some commits Jul 3, 2018

Fix unbound local variable error
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
```
@colinschoen
Copy link
Member

left a comment

LGTM

Thanks.

@colinschoen colinschoen merged commit c91bea4 into okpy:master Jul 3, 2018

3 checks passed

Travis CI - Pull Request Build Passed
Details
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@c-w c-w deleted the c-w: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
You can’t perform that action at this time.