Skip to content

Commit

Permalink
Fix exception: TypeError: can't concat bytes to str
Browse files Browse the repository at this point in the history
```
Traceback (most recent call last):
  File "/usr/lib/python3.6/socketserver.py", line 639, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/socketserver.py", line 696, in __init__
    self.handle()
  File "./pyicap.py", line 443, in handle
    self.handle_one_request()
  File "./pyicap.py", line 500, in handle_one_request
    self.send_error(e.code, e.message[0])
  File "./pyicap.py", line 525, in send_error
    self.set_icap_response(code, message=message)
  File "./pyicap.py", line 267, in set_icap_response
    (message if message else self._responses[code][0])
TypeError: can't concat bytes to str
----------------------------------------
```
  • Loading branch information
ichramm committed May 8, 2017
1 parent 634c352 commit 4066210
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pyicap.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def set_enc_header(self, header, value):
def set_icap_response(self, code, message=None):
"""Sets the ICAP response's status line and response code"""
self.icap_response = b'ICAP/1.0 ' + str(code).encode('utf-8') + b' ' + \
(message if message else self._responses[code][0])
(str.encode(message) if message else self._responses[code][0])
self.icap_response_code = code

def set_icap_header(self, header, value):
Expand Down

0 comments on commit 4066210

Please sign in to comment.