                      stored_backend = load_backend(request.session.get(
                          auth.BACKEND_SESSION_KEY, ''))
                      if isinstance(stored_backend, RemoteUserBackend):
                          auth.logout(request)
                  except ImproperlyConfigured as e:
                      # backend failed to load
                      auth.logout(request)
              return
          # If the user is already authenticated and that user is the user we are
          # getting passed in the headers, then the correct user is already
 
</s> remove             backend_cls = import_by_path(backend)
 </s> add             import_by_path(backend) </s> remove         except ValidationError:
 </s> add         except forms.ValidationError: </s> remove     def test_invalid_key_backslash(self):
        # This key should be refused and a new session should be created
        self.assertTrue(self.backend("a\\b\\c").load())

 </s> add  </s> remove             from django.conf import settings
 </s> add  </s> remove         err = self.errors
 </s> add         # This triggers a full clean.
        self.errors
                except ImproperlyConfigured:
                      stored_backend = load_backend(request.session.get(
                          auth.BACKEND_SESSION_KEY, ''))
                      if isinstance(stored_backend, RemoteUserBackend):
                          auth.logout(request)
                except ImproperlyConfigured:
                      # backend failed to load
                      auth.logout(request)
              return
          # If the user is already authenticated and that user is the user we are
          # getting passed in the headers, then the correct user is already
keep keep keep keep replace keep keep keep keep keep
 Fixed a number of flake8 errors -- particularly around unused imports and local variables 
django/contrib/auth/middleware.py