New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serve crash with python3 #222

Merged
merged 1 commit into from Jun 18, 2016

Conversation

Projects
None yet
2 participants
@touilleMan
Contributor

touilleMan commented Jun 4, 2016

Hi,

lektor server crashes while serving the quickstart default app with python<3.5 because it cannot use % operand for a bytes string.

Traceback (most recent call last):
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 149, in serve_artifact
    return serve_up_artifact(path)
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 143, in serve_up_artifact
    return send_file(filename)
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 89, in send_file
    edit_url=posixpath.join('/', request.script_root, 'admin/edit'))
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 65, in rewrite_html_for_editing
    b'edit_url': edit_url.encode('utf-8'),
TypeError: unsupported operand type(s) for %: 'bytes' and 'dict'
Traceback (most recent call last):
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/emmanuel/projects/touilleman.xyz/venv/lib/python3.4/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 149, in serve_artifact
    return serve_up_artifact(path)
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 143, in serve_up_artifact
    return send_file(filename)
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 89, in send_file
    edit_url=posixpath.join('/', request.script_root, 'admin/edit'))
  File "/home/emmanuel/projects/lektor/lektor/admin/modules/serve.py", line 65, in rewrite_html_for_editing
    b'edit_url': edit_url.encode('utf-8'),
TypeError: unsupported operand type(s) for %: 'bytes' and 'dict'

@singingwolfboy singingwolfboy self-assigned this Jun 17, 2016

@singingwolfboy

This comment has been minimized.

Member

singingwolfboy commented Jun 18, 2016

Tested and verified on Python 3.4. Thank you! I'll merge this.

As an aside, can you tell me what versions of Python 3 you think Lektor needs to support? The more different versions we try to support, the harder it will be to provide support for all of them.

@singingwolfboy singingwolfboy merged commit a077fa3 into lektor:master Jun 18, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@touilleMan

This comment has been minimized.

Contributor

touilleMan commented Jun 19, 2016

@singingwolfboy I personally think Python 3.4 should be supported along with 3.5 given it's the current version shipped with Debian jessie.

However I understand lektor comes from 2.7 which is much more compatible with 3.5 than 3.4 (as showed by PR). So maybe we just need to make this clear in the documentation (both README and lektor website which currently presents all 3.x as incompatible).

@singingwolfboy

This comment has been minimized.

Member

singingwolfboy commented Jun 19, 2016

There's a pull request to update the website and indicate Python 3 support, but that shouldn't be merged until Lektor 3.0 comes out. The latest stable version of Lektor does not have Python 3 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment