Opened 11 years ago

Closed 11 years ago

#4751 closed (fixed)

anonymous user cannot be converted to string

Reported by: canburak@… Owned by: Jacob
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Malcolm Tredinnick)

the code:

class SomeMiddleware:
    def process_request(self, req):
        print type(req.user)
        print type(req.user.__str__())
        print req.user.__str__().__class__
        print req.user
        return None

prints out

<class 'django.contrib.auth.models.AnonymousUser'>
<type 'instance'>
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/core/servers/", line 272, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/lib/python2.5/site-packages/django/core/servers/", line 614, in __call__
    return self.application(environ, start_response)
  File "/usr/lib/python2.5/site-packages/django/core/handlers/", line 189, in __call__
    response = self.get_response(request)
  File "/usr/lib/python2.5/site-packages/django/core/handlers/", line 59, in get_response
    response = middleware_method(request)
  File "/home/can/vc/darcs/baklava/baklava/../baklava/reiloy/", line 13, in process_request
    print req.user
TypeError: __str__ returned non-string (type instance)

Change History (2)

comment:1 Changed 11 years ago by Malcolm Tredinnick

Description: modified (diff)
Triage Stage: UnreviewedAccepted

(Fixed description formatting.)

I thought we'd fixed this. Apparently I am confused, though, and it is only fixed on the Unicode branch.

comment:2 Changed 11 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [5590]) Fixed #4751 -- Fixed that AnonymousUser.str to always return a string
object, as required by Python.

Note: See TracTickets for help on using tickets.
Back to Top