#35530: `django.contrib.auth.login` inconsistently guards `request.user`
------------------------------------------------+------------------------
               Reporter:  Jaap Roes             |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  contrib.auth          |        Version:  dev
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 In
 
https://github.com/django/django/blob/a0c44d4e23f8f509757f97f28fbbb1ced3382361/django/contrib/auth/__init__.py#L102-L152
 `request.user` is accessed twice.

 The first time here:

 
https://github.com/django/django/blob/a0c44d4e23f8f509757f97f28fbbb1ced3382361/django/contrib/auth/__init__.py#L109-L110

 The second time here:

 
https://github.com/django/django/blob/a0c44d4e23f8f509757f97f28fbbb1ced3382361/django/contrib/auth/__init__.py#L149-L150

 The first time there is no `hasattr` guard to verify if the `request`
 object has a `user` attribute. The second time there is.

 Is the `hasattr` check in the second case redundant? Or should the first
 case be guarded as well?
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35530>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701902ade15e2-8c60d4e6-ccb7-46ee-8614-00ad7ba2a54c-000000%40eu-central-1.amazonses.com.

Reply via email to