# HG changeset patch # User Adrien Di Mascio # Date 1525358871 -7200 # Node ID aa999699e5047da7512ececd8ead42a2f1b15e4b # Parent 48e763ad3b3f6d2a16b8d87de1c3c46ff352342a [python3] make sure staticcontroller returns a bytes instance The ``publish()`` method of controller is supposed to return a bytes intsance. Returning a text_type instance will crash later on in the Pyramid response handler when assigning content to ``response.body`` (at least in Python3):: >>> from pyramid.response import Response >>> r = Response() >>> r.body = '' Traceback (most recent call last): File "", line 1, in File "/home/adim/.virtualenvs/…/response.py", line 562, in _body__set raise TypeError(msg) TypeError: You cannot set Response.body to a text object (use Response.text) diff -r 48e763ad3b3f -r aa999699e504 cubicweb/web/views/staticcontrollers.py --- a/cubicweb/web/views/staticcontrollers.py Thu May 03 14:05:26 2018 +0200 +++ b/cubicweb/web/views/staticcontrollers.py Thu May 03 16:47:51 2018 +0200 @@ -58,7 +58,7 @@ debugmode = self._cw.vreg.config.debugmode if osp.isdir(path): if self.directory_listing_allowed: - return u'' + return b'' raise Forbidden(path) if not osp.isfile(path): raise NotFound() @@ -79,7 +79,7 @@ # Real production environment should use dedicated static file serving. self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime)) if self._cw.is_client_cache_valid(): - return '' + return b'' mimetype, encoding = mimetypes.guess_type(path) if mimetype is None: mimetype = 'application/octet-stream'