[
https://issues.apache.org/jira/browse/MESOS-8770?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16480290#comment-16480290
]
Benjamin Bannier commented on MESOS-8770:
-----------------------------------------
{noformat}
commit 89db66e3df831eaa50fffb4149a3894097505c14
Author: Armand Grillet <[email protected]>
Date: Fri May 18 09:13:48 2018 +0200
Updated cpplint to be compatible with Python 3.
This patch keeps the bundled cpplint at upstream `43d512b`.
Cpplint now works with Python 2 and 3 by adding part of the
content of https://github.com/google/styleguide/pull/349.
After aliasing `unicode` to `str`, and replacing `iteritems` and
`itervalues`, `cpplint.py` can work well with Python 3 if the linted
file does not have any issues. If there is even only one style
violation in the linted file, `cpplint.py` will need to an output
error message, then exceptions like `TypeError: write() argument must
be str, not bytes` will appear.
This is due to differing Unicode support between Python 2 and 3. In
Python 2 `str` is a byte sequence and `unicode` is used to handle
Unicode strings, but in Python 3 `str` is a Unicode sequence and
`unicode` does not exist. Type `bytes` is introduced to handle bytes
sequences, thus Python 3 `bytes` is equal to Python 2 `str`.
The type of the argument of `sys.stderr.write()` is kept the same
between Python 2 and 3, but the arguments of `sys.stderr.write()` are
changed. It receives a byte sequence in Python 2 and a Unicode
sequence in Python 3. As a result, `sys.stderr` should not be wrapped
by a UTF-8 stream reader and writer of codecs when using Python 3.
Review: https://reviews.apache.org/r/67055/
{noformat}
> Use Python3 for Mesos support scripts
> -------------------------------------
>
> Key: MESOS-8770
> URL: https://issues.apache.org/jira/browse/MESOS-8770
> Project: Mesos
> Issue Type: Task
> Reporter: Benjamin Bannier
> Assignee: Armand Grillet
> Priority: Major
>
> Our Python scripts under {{support/}} currently implicitly assume that
> developers have a python2 environment as their primary Python installation.
> We should consider updating these scripts so that they can be used with a
> python3 installation as well. There exist [some
> resources|http://python-future.org/overview.html#automatic-conversion-to-py2-3-compatible-code]
> on the web documenting best practices and tools for automatic rewrites which
> should get us a long way.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)