{"action":"created","issue":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2108","labels_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2108/labels{/name}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2108/comments","events_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2108/events","html_url":"https://github.com/tomchristie/django-rest-framework/issues/2108","id":49692871,"number":2108,"title":"Usage of both @property and __getattr__ can lead to obscure and hard to debug errors","user":{"login":"skrivanos","id":87463,"avatar_url":"https://avatars.githubusercontent.com/u/87463?v=3","gravatar_id":"","url":"https://api.github.com/users/skrivanos","html_url":"https://github.com/skrivanos","followers_url":"https://api.github.com/users/skrivanos/followers","following_url":"https://api.github.com/users/skrivanos/following{/other_user}","gists_url":"https://api.github.com/users/skrivanos/gists{/gist_id}","starred_url":"https://api.github.com/users/skrivanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skrivanos/subscriptions","organizations_url":"https://api.github.com/users/skrivanos/orgs","repos_url":"https://api.github.com/users/skrivanos/repos","events_url":"https://api.github.com/users/skrivanos/events{/privacy}","received_events_url":"https://api.github.com/users/skrivanos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/labels/Bug","name":"Bug","color":"e10c02"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/milestones/19","labels_url":"https://api.github.com/repos/tomchristie/django-rest-framework/milestones/19/labels","id":945336,"number":19,"title":"3.0.5 Release","description":"","creator":{"login":"tomchristie","id":647359,"avatar_url":"https://avatars.githubusercontent.com/u/647359?v=3","gravatar_id":"","url":"https://api.github.com/users/tomchristie","html_url":"https://github.com/tomchristie","followers_url":"https://api.github.com/users/tomchristie/followers","following_url":"https://api.github.com/users/tomchristie/following{/other_user}","gists_url":"https://api.github.com/users/tomchristie/gists{/gist_id}","starred_url":"https://api.github.com/users/tomchristie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomchristie/subscriptions","organizations_url":"https://api.github.com/users/tomchristie/orgs","repos_url":"https://api.github.com/users/tomchristie/repos","events_url":"https://api.github.com/users/tomchristie/events{/privacy}","received_events_url":"https://api.github.com/users/tomchristie/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":13,"state":"open","created_at":"2015-01-21T14:41:03Z","updated_at":"2015-02-09T20:42:12Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2014-11-21T12:59:41Z","updated_at":"2015-02-09T21:14:08Z","closed_at":"2015-02-09T17:56:25Z","body":"Encountered this error when accessing request.DATA in a view:\r\n\r\n```python\r\n  File \"views.py\", line 146, in put\r\n    if request.DATA is not None:\r\n  File \"/usr/local/lib/python2.7/dist-packages/rest_framework/request.py\", line 453, in __getattr__\r\n    return getattr(self._request, attr)\r\nAttributeError: 'WSGIRequest' object has no attribute 'DATA'\r\n```\r\n\r\nThis was mind-boggling. I couldn't understand why ```__getattr__``` was ever called on the request object, since a property called DATA already exists (confirmed this via dir(request) before accessing DATA), and as we all know, getattr is only used for undefined properties. \r\n\r\nAfter an intense debugging session it turned out that this is caused by a \"feature\" in python. This may be common knowledge, but it definitely was new news to me: if a property getter raises an AttributeError, python (`__getattribute__`) falls back to using `__getattr__`. The issue is that the traceback is lost, which makes it extremely hard to debug, since the actual exception raised isn't shown anywhere. So, the __actual__ error was:\r\n\r\n```\r\nAttributeError: 'TemporaryFileUploadHandler' object has no attribute 'file'\r\n```\r\n\r\nFurther explanation/discussion: https://groups.google.com/forum/#!topic/comp.lang.python/BZf-d0rLP8U\r\n\r\nI'm not sure if this is an issue that you can/want to address, but I wanted to make people aware of it since it was a pain to track down and others might stumble into the same situation.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/comments/73591358","html_url":"https://github.com/tomchristie/django-rest-framework/issues/2108#issuecomment-73591358","issue_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2108","id":73591358,"user":{"login":"foresmac","id":3628189,"avatar_url":"https://avatars.githubusercontent.com/u/3628189?v=3","gravatar_id":"","url":"https://api.github.com/users/foresmac","html_url":"https://github.com/foresmac","followers_url":"https://api.github.com/users/foresmac/followers","following_url":"https://api.github.com/users/foresmac/following{/other_user}","gists_url":"https://api.github.com/users/foresmac/gists{/gist_id}","starred_url":"https://api.github.com/users/foresmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foresmac/subscriptions","organizations_url":"https://api.github.com/users/foresmac/orgs","repos_url":"https://api.github.com/users/foresmac/repos","events_url":"https://api.github.com/users/foresmac/events{/privacy}","received_events_url":"https://api.github.com/users/foresmac/received_events","type":"User","site_admin":false},"created_at":"2015-02-09T21:14:08Z","updated_at":"2015-02-09T21:14:08Z","body":"I finally found my problem; I was using `settings.AUTH_USER_MODEL` where I should have been using `get_user_model()`. So the actual error was that I was trying to call `.objects.get()` on a string object instead of the user class."}}