= Python 3 support in GRASS == Python versions * keep compatibility with 2.7 (may still work with 2.6, but we don't care) * port to work with 3.5 == Python components include: * Python Scripting Library * PyGRASS * Temporal Library * ctypes * wxGUI == Python Scripting Library == Possible approach: * functions need to accept unicode and return unicode * functions wrapping Python Popen class (read_command, run_command, ...) will have parameter encoding * encoding=None means expects and returns bytes (the current state) * encoding='default' means it takes current encoding using utils._get_encoding() * encoding='utf-8' takes whatever encoding user specifies, e.g., utf-8 in this case * this is similar to [https://docs.python.org/3.6/library/subprocess.html#subprocess.Popen Popen class in Python3.6] * by default encoding='default' to enable expected behavior by users, the following example shows Python3 behavior if we keep using bytes instead of unicode: {{{ # return bytes ret = read_command('r.what', encoding=None, ... for item in ret.splitlines(): line = item.split('|')[3:] Traceback (most recent call last): File "", line 1, in TypeError: a bytes-like object is required, not 'str' # we would have to use: for item in ret.splitlines(): line = item.split(b'|')[3:] }}}