AttributeError: ‘NoneType’ object has no attribute ‘split’ [How to Solve]

Error reporting scenario

social_ Django component has better support for native Django, but because the verification in DRF is JWT mode, it is different from Django

Therefore, we need to make changes to support the addition of verification information in JWT mode

The following error occurs when the third party login is verified after the change

Detailed error report

[29/Apr/2019 15:12:02] "GET/HTTP/1.1" 200 6992
[29/Apr/2019 15:12:11] "GET /login/weibo/ HTTP/1.1" 302 0
[29/Apr/2019 15:12:13] "GET /complete/weibo/?state=cpNja8cxhyV9GPSKvjVfWnwogNskNjob&code=ba1e4f6fd32f32d0b57094eecd0e7d1b HTTP/1.1" 302 0
Traceback (most recent call last):
  File "C:\Python36\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
    self._write(bytes(self.headers))
  File "C:\Python36\lib\wsgiref\headers.py", line 142, in __bytes__
    return str(self).encode('iso-8859-1')
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 251-253: ordinal not in range(256)
[29/Apr/2019 15:12:13] "GET /complete/weibo/?state=cpNja8cxhyV9GPSKvjVfWnwogNskNjob&code=ba1e4f6fd32f32d0b57094eecd0e7d1b HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 11977)
Traceback (most recent call last):
  File "C:\Python36\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
    self._write(bytes(self.headers))
  File "C:\Python36\lib\wsgiref\headers.py", line 142, in __bytes__
    return str(self).encode('iso-8859-1')
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 251-253: ordinal not in range(256)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python36\lib\wsgiref\handlers.py", line 141, in run
    self.handle_error()
  File "C:\Python36\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
    super(ServerHandler, self).handle_error()
  File "C:\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
    self.finish_response()
  File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "C:\Python36\lib\wsgiref\handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

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

Solutions

For the time being, this can be solved, but I don’t know if it will have a bad impact

Similar Posts: