diff --git a/cms/djangoapps/contentstore/views/import_export.py b/cms/djangoapps/contentstore/views/import_export.py index 91dc1f8d3c..a71140cbc1 100644 --- a/cms/djangoapps/contentstore/views/import_export.py +++ b/cms/djangoapps/contentstore/views/import_export.py @@ -152,7 +152,7 @@ def import_handler(request, course_key_string): }] }) # Send errors to client with stage at which error occurred. - except Exception as exception: # pylint: disable=W0703 + except Exception as exception: # pylint: disable=broad-except _save_request_status(request, key, -1) if course_dir.isdir(): shutil.rmtree(course_dir) @@ -251,7 +251,7 @@ def import_handler(request, course_key_string): _save_request_status(request, key, 4) # Send errors to client with stage at which error occurred. - except Exception as exception: # pylint: disable=W0703 + except Exception as exception: # pylint: disable=broad-except log.exception( "error importing course" ) diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index d80b334269..4428d7c087 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -221,7 +221,7 @@ def xblock_view_handler(request, usage_key_string, view_name): # catch exceptions indiscriminately, since after this point they escape the # dungeon and surface as uneditable, unsaveable, and undeletable # component-goblins. - except Exception as exc: # pylint: disable=w0703 + except Exception as exc: # pylint: disable=broad-except log.debug("unable to render studio_view for %r", xblock, exc_info=True) fragment = Fragment(render_to_string('html_error.html', {'message': str(exc)})) diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 3e292827b1..772fc4c264 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -227,7 +227,7 @@ def get_preview_fragment(request, descriptor, context): try: fragment = module.render(preview_view, context) - except Exception as exc: # pylint: disable=W0703 + except Exception as exc: # pylint: disable=broad-except log.warning("Unable to render %s for %r", preview_view, module, exc_info=True) fragment = Fragment(render_to_string('html_error.html', {'message': str(exc)})) return fragment diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 6bcf7f1d54..3ba560342b 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -2229,7 +2229,7 @@ class ExternalResponse(LoncapaResponse): cmap = CorrectMap() try: submission = [student_answers[k] for k in idset] - except Exception as err: # pylint: disable=W0703 + except Exception as err: # pylint: disable=broad-except log.error( 'Error %s: cannot get student answer for %s; student_answers=%s', err, @@ -2244,7 +2244,7 @@ class ExternalResponse(LoncapaResponse): try: rxml = self.do_external_request('get_score', extra_payload) - except Exception as err: # pylint: disable=W0703 + except Exception as err: # pylint: disable=broad-except log.error('Error %s', err) if self.capa_system.DEBUG: cmap.set_dict(dict(zip(sorted( @@ -2276,7 +2276,7 @@ class ExternalResponse(LoncapaResponse): try: rxml = self.do_external_request('get_answers', {}) exans = json.loads(rxml.find('expected').text) - except Exception as err: # pylint: disable=W0703 + except Exception as err: # pylint: disable=broad-except log.error('Error %s', err) if self.capa_system.DEBUG: msg = '%s' % str( @@ -2486,7 +2486,7 @@ class FormulaResponse(LoncapaResponse): name = hxml.get('name') correct_answer = contextualize_text( hxml.get('answer'), self.context) - # pylint: disable=W0703 + # pylint: disable=broad-except try: correctness = self.check_formula( correct_answer, diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 92a0bb28bd..4f89249415 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -605,7 +605,7 @@ def _import_course_draft( drafts.append(draft) - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except logging.exception('Error while parsing course xml.') # sort drafts by `index_in_children_list` attribute @@ -614,7 +614,7 @@ def _import_course_draft( for draft in get_draft_subtree_roots(drafts): try: _import_module(draft.module) - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except logging.exception('while importing draft descriptor %s', draft.module) diff --git a/lms/djangoapps/courseware/management/commands/clean_history.py b/lms/djangoapps/courseware/management/commands/clean_history.py index 2a3a28592f..6478c07568 100644 --- a/lms/djangoapps/courseware/management/commands/clean_history.py +++ b/lms/djangoapps/courseware/management/commands/clean_history.py @@ -81,7 +81,7 @@ class StudentModuleHistoryCleaner(object): for smid in self.module_ids_to_check(batch_size): try: self.clean_one_student_module(smid) - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except trace = traceback.format_exc() self.say("Couldn't clean student_module_id {}:\n{}".format(smid, trace)) if not self.dry_run: diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index ffcb49a889..e1c6659a1b 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -261,7 +261,7 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man try: upload_file = request.FILES.get('students_list') students = [row for row in csv.reader(upload_file.read().splitlines())] - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except general_errors.append({ 'username': '', 'email': '', 'response': _('Could not read uploaded file.') }) @@ -488,7 +488,7 @@ def students_update_enrollment(request, course_id): 'invalidIdentifier': True, }) - except Exception as exc: # pylint: disable=W0703 + except Exception as exc: # pylint: disable=broad-except # catch and log any exceptions # so that one error doesn't cause a 500. log.exception("Error while #{}ing student") diff --git a/lms/djangoapps/shoppingcart/models.py b/lms/djangoapps/shoppingcart/models.py index 3a769aa706..ac2d40eda5 100644 --- a/lms/djangoapps/shoppingcart/models.py +++ b/lms/djangoapps/shoppingcart/models.py @@ -421,7 +421,7 @@ class Order(models.Model): } }) - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except # Capturing all exceptions thrown while tracking analytics events. We do not want # an operation to fail because of an analytics event, so we will capture these # errors in the logs. diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 81b2085e52..6362057849 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -552,7 +552,7 @@ class SoftwareSecurePhotoVerification(PhotoVerification): attempt = attempts[0] if attempt.status != "approved": return False - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except return False return True diff --git a/pavelib/assets.py b/pavelib/assets.py index 5e8e6045fb..a27aa2d164 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -60,7 +60,7 @@ class CoffeeScriptWatcher(PatternMatchingEventHandler): print('\tCHANGED:', event.src_path) try: compile_coffeescript(event.src_path) - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except traceback.print_exc() @@ -89,7 +89,7 @@ class SassWatcher(PatternMatchingEventHandler): print('\tCHANGED:', event.src_path) try: compile_sass() - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except traceback.print_exc() @@ -110,7 +110,7 @@ class XModuleSassWatcher(SassWatcher): print('\tCHANGED:', event.src_path) try: process_xmodule_assets() - except Exception: # pylint: disable=W0703 + except Exception: # pylint: disable=broad-except traceback.print_exc()