﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34891	force_str(urlsafe_base64_decode(uidb64)) returns object not value	Jeff Lovern	nobody	"{{{ #!pycon
>>> from django.utils.encoding import force_str
>>> from django.utils.http import urlsafe_base64_decode
>>> uidb64 = 'PHByb3BlcnR5IG9iamVjdCBhdCAweDAwMDAwMjU1M0ZBNTlEQTA-bvlp6u-9b15d1fd6d30b90e81623812e9bc8d74'
>>> result = urlsafe_base64_decode(uidb64)
>>> result
b'<property object at 0x000002553FA59DA0>n\xf9i\xea\xef\xbdo^]\xd5\xf7zw}\x1b\xf7G\xbc\xd7\xad\xb7\xf3]\x9e\xf5\xb7<w\xbe'

>>> force_str(result)
Traceback (most recent call last):
  File ""/home/tim/code/django/django/utils/encoding.py"", line 70, in force_str
    s = str(s, encoding, errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 40: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/home/tim/code/django/django/utils/encoding.py"", line 74, in force_str
    raise DjangoUnicodeDecodeError(s, *e.args)
django.utils.encoding.DjangoUnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 40: invalid start byte. You passed in b'<property object at 0x000002553FA59DA0>n\xf9i\xea\xef\xbdo^]\xd5\xf7zw}\x1b\xf7G\xbc\xd7\xad\xb7\xf3]\x9e\xf5\xb7<w\xbe' (<class 'bytes'>)
}}}

Code:
{{{ #!python
def activate(request, uidb64, token):
    try:
        uid = force_str(urlsafe_base64_decode(uidb64))
        user = CustomUser.objects.get(pk=uid)

    except (TypeError, ValueError, OverflowError, CustomUser.DoesNotExist):
        user = None

    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.save()
        login(request, user)
        return redirect('account_activation_complete')
    else:
        return HttpResponseBadRequest('Activation link is invalid!')
}}}"	Bug	closed	Utilities	4.2	Normal	invalid	django.utils.encoding		Unreviewed	0	0	0	0	0	0
