#15671: hasattr in RemoteUserMiddleware hides true errors and exceptions
-------------------------------------+-------------------------------------
               Reporter:  metzen     |          Owner:
                   Type:  Bug        |         Status:  new
              Milestone:             |      Component:  contrib.auth
                Version:  SVN        |       Severity:  Normal
             Resolution:             |       Keywords:
           Triage Stage:  Ready for  |      Has patch:  1
  checkin                            |    Needs tests:  0
    Needs documentation:  0          |  Easy pickings:  0
Patch needs improvement:  0          |
-------------------------------------+-------------------------------------

Comment (by metzen):

 Ah sorry, it won't conceal all errors like `hasattr`, but it ''will''
 conceal `AttributeErrors`, much like the solution in patch 1 and 2.

 {{{
 >>> class C(object):
 ...   @property
 ...   def x(self):
 ...     raise AttributeError
 ...
 >>> c = C()
 >>> getattr(c, 'x')
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 4, in x
 AttributeError
 >>> getattr(c, 'x', None) is None
 True
 }}}

 This would actually be correct behavior for `getattr`, but it would be
 better if the solution used here was robust enough to allow those errors
 to bubble up.  I've run into this while working on a custom db backend,
 and it's quite painful to keep seeing your true coding errors concealed
 behind a message stating that you need to correct your
 `MIDDLEWARE_CLASSES`.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15671#comment:17>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to