DRF UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6

525 views
Skip to first unread message

Kerstin Rohm

unread,
Oct 21, 2019, 8:49:02 AM10/21/19
to Django users

Dear Django Community,


we have a curious encoding error and we are running out of ideas to solve the problem.

We build a Django REST Service with the following packages:

 

dj-database-url 0.5.0

Django 2.2.1

django-filter 2.1.0

django-oauth-toolkit 1.2.0

django-widget-tweaks 1.4.3

djangorestframework 3.9.3

python-decouple 3.1

argon2-cffi 19.1.0

plotly 4.1.1


When we call a specific REST function (e.g.

@api_view(['POST'])

@permission_classes([AllowAny])

def token(request):

    r = requests.post('http://127.0.0.1:8000/rest/oauth2/token/',

                      data={'grant_type' : 'password',

                            'username' : request.data['username'],

                            'password' : request.data['password'],

                            'client_id' : settings.REST_CLIENT_ID,

                            'client_secret' : settings.REST_CLIENT_SECRET,},)

    return Response(r.json())

)


We are getting a UFT8 encoding error (Traceback see below). The content of “data” seems to be ok:


data= {'grant_type': 'password', 'username': 'x', 'password': 'x', 'client_id': 'TQmAHzCM2r9nfkruVQw0eMQ0AziSvLAnf4ufvZ1o', 'client_secret': 'GISUGXxa2e4JHejUCImMMUMJMtZ13byvc8fySUvX7shELNLPE5xZBA3p0cvbXvvrPIWgltSkTNZ9a7JHPQswEKHzZEDkl21ekS3T6NefUrzVFsdyRS0A2qOHL1L4Nra5'}


We have the same error on our testing LINUX system and our development environment on windows. We tried to call the REST function via local testing method, Android app and CURL – same behavior.

The settings of UNICODE_JSON = True/False causes no difference.


We tried it with a REST function without OAUTH Token creation (username and password credentials) – same behavior.


But – when we call the function with the arguments REST_CLIENT_ID and REST_CLIENT_SECRET the function is working fine:

curl -X POST -d "grant_type=password&username=emilia....@email.com&password=qwertzui" -u"VAOpqwqOTl99jRVXY63Bv5uNXs2MpJWUlZSwSZBf:cgrDaIjPyAy45Z1yxarT0iP9UOjw7gvbpnMirgwz24A56EeJGONHYSsqs9eVPHAyLrsPZdwfdQxoGPnM4LFtihltxlrX24hCQIIE57JezwSHIJab9VjTwAjS9LxYFVJm" "127.0.0.1:8000/rest/oauth2/token/"

response: {"access_token": "Fz7yTNSsdUxRaWuMj4Sf4OnPe0Ujf6", "expires_in": 3000, "token_type": "Bearer", "scope": "read write", "refresh_token": "r9H5E8MK5AAy57ZdiFUJaWaJT63kJL"}


But – when we tried to call the other functions with this token and are getting the same encoding error (traceback below):
 

curl -X GET -H "Authorization: Bearer Fz7yTNSsdUxRaWuMj4Sf4OnPe0Ujf6" 127.0.0.1:8000/rest/patient/1

Everything worked fine a few weeks ago, but after a database change the problem occurs. Setting the DB Model to the previous entries was not successful.


It would be really great if some of you would have any idea what is working wrong here!

Thanks in advance!


Kerstin and Romy

 

---
Traceback
 
Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Python37\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Python37\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "C:\Python37\lib\site-packages\django\views\generic\base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "C:\Python37\lib\site-packages\rest_framework\views.py", line 495, in dispatch
    response = self.handle_exception(exc)
  File "C:\Python37\lib\site-packages\rest_framework\views.py", line 455, in handle_exception
    self.raise_uncaught_exception(exc)
  File "C:\Python37\lib\site-packages\rest_framework\views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "C:\Users\andresr\InsisT\Server\insist_rest\views.py", line 93, in get
    return Response(self.serializer_class(patient[0]).data, status=status.HTTP_200_OK)
  File "C:\Python37\lib\site-packages\rest_framework\response.py", line 32, in __init__
    super(Response, self).__init__(None, status=status)
  File "C:\Python37\lib\site-packages\django\template\response.py", line 36, in __init__
    super().__init__('', content_type, status, charset=charset)
  File "C:\Python37\lib\site-packages\django\http\response.py", line 289, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Python37\lib\site-packages\django\http\response.py", line 60, in __init__
    content_type = '%s; charset=%s' % (settings.DEFAULT_CONTENT_TYPE,
  File "C:\Python37\lib\site-packages\django\conf\__init__.py", line 120, in DEFAULT_CONTENT_TYPE
    stack = traceback.extract_stack()
  File "C:\Python37\lib\traceback.py", line 211, in extract_stack
    stack = StackSummary.extract(walk_stack(f), limit=limit)
  File "C:\Python37\lib\traceback.py", line 363, in extract
    f.line
  File "C:\Python37\lib\traceback.py", line 285, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
  File "C:\Python37\lib\linecache.py", line 16, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 47, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 137, in updatecache
    lines = fp.readlines()
  File "C:\Python37\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1110: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python37\lib\site-packages\django\utils\deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\wsgiref\handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Python37\lib\site-packages\django\contrib\staticfiles\handlers.py", line 65, in __call__
    return self.application(environ, start_response)
  File "C:\Python37\lib\site-packages\django\core\handlers\wsgi.py", line 141, in __call__
    response = self.get_response(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\base.py", line 75, in get_response
    response = self._middleware_chain(request)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    text = reporter.get_traceback_text()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 340, in get_traceback_text
    c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 264, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 422, in get_traceback_frames
    filename, lineno, 7, loader, module_name,
  File "C:\Python37\lib\site-packages\django\views\debug.py", line 351, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap_external>", line 783, in get_source
  File "<frozen importlib._bootstrap_external>", line 566, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 9302: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\wsgiref\handlers.py", line 141, in run
    self.handle_error()
  File "C:\Python37\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
    super().handle_error()
  File "C:\Python37\lib\wsgiref\handlers.py", line 365, in handle_error
    self.log_exception(sys.exc_info())
  File "C:\Python37\lib\wsgiref\handlers.py", line 357, in log_exception
    self.traceback_limit, stderr
  File "C:\Python37\lib\traceback.py", line 104, in print_exception
    type(value), value, tb, limit=limit).format(chain=chain):
  File "C:\Python37\lib\traceback.py", line 521, in __init__
    self._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  [Previous line repeated 6 more times]
  File "C:\Python37\lib\traceback.py", line 531, in _load_lines
    frame.line
  File "C:\Python37\lib\traceback.py", line 285, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
  File "C:\Python37\lib\linecache.py", line 16, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 47, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 137, in updatecache
    lines = fp.readlines()
  File "C:\Python37\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1110: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Python37\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Python37\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "C:\Python37\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
    self.handle_one_request()
  File "C:\Python37\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
    handler.run(self.server.get_app())
  File "C:\Python37\lib\wsgiref\handlers.py", line 144, in run
    self.close()
  File "C:\Python37\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
    super().close()
  File "C:\Python37\lib\wsgiref\simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "C:\Python37\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Python37\lib\socketserver.py", line 652, in process_request_thread
    self.handle_error(request, client_address)
  File "C:\Python37\lib\site-packages\django\core\servers\basehttp.py", line 73, in handle_error
    super().handle_error(request, client_address)
  File "C:\Python37\lib\socketserver.py", line 380, in handle_error
    traceback.print_exc()
  File "C:\Python37\lib\traceback.py", line 163, in print_exc
    print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
  File "C:\Python37\lib\traceback.py", line 104, in print_exception
    type(value), value, tb, limit=limit).format(chain=chain):
  File "C:\Python37\lib\traceback.py", line 521, in __init__
    self._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  [Previous line repeated 8 more times]
  File "C:\Python37\lib\traceback.py", line 531, in _load_lines
    frame.line
  File "C:\Python37\lib\traceback.py", line 285, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
  File "C:\Python37\lib\linecache.py", line 16, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 47, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 137, in updatecache
    lines = fp.readlines()
  File "C:\Python37\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1110: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\threading.py", line 885, in _bootstrap
    self._bootstrap_inner()
  File "C:\Python37\lib\threading.py", line 927, in _bootstrap_inner
    (self.name, _format_exc()), file=_sys.stderr)
  File "C:\Python37\lib\traceback.py", line 167, in format_exc
    return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
  File "C:\Python37\lib\traceback.py", line 121, in format_exception
    type(value), value, tb, limit=limit).format(chain=chain))
  File "C:\Python37\lib\traceback.py", line 521, in __init__
    self._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  File "C:\Python37\lib\traceback.py", line 533, in _load_lines
    self.__context__._load_lines()
  [Previous line repeated 9 more times]
  File "C:\Python37\lib\traceback.py", line 531, in _load_lines
    frame.line
  File "C:\Python37\lib\traceback.py", line 285, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
  File "C:\Python37\lib\linecache.py", line 16, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 47, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python37\lib\linecache.py", line 137, in updatecache
    lines = fp.readlines()
  File "C:\Python37\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1110: invalid start byte

Sarah Werker

unread,
Nov 20, 2019, 6:17:53 PM11/20/19
to Django users
On Monday, October 21, 2019 at 8:49:02 AM UTC-4, Kerstin Rohm wrote:
> Dear Django Community,
>
> I think you should call me at 574-217-1330 or text and we can discuss it

Aldian Fazrihady

unread,
Nov 20, 2019, 8:39:05 PM11/20/19
to django...@googlegroups.com
I guess texts in your database is encoded using other than UTF-8.

Please change `getline(self.filename, ..)` to  `getline(self.filename.decode('utf-16'), ..`

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/036fca75-1923-4628-b645-7904c1c1555f%40googlegroups.com.


--
Regards,

Reply all
Reply to author
Forward
0 new messages