Why a transition to Python 3?

Python 2.x is legacy; it has an end-of-life set for 2020.
Python 3.x is the present and future of the language. Version 3.0 was released on (11 years ago).

Python 3 has many new exciting features, for example:

Support of Python 3 in WeeChat

WeeChat supports Python 3 since version 0.3.7, which was released on (7 years, 9 months ago).

The support of Python 3 is optional: the WeeChat python plugin can be compiled with Python 2.7 or Python 3.x, but not both at same time.
As of , it is recommended to compile with Python 2.7 because many scripts won't work at all with Python 3.x, while all scripts should run fine with Python 2.7.

To compile with Python 3.x support and enable quick switch between Python 2.7 and 3.x, see: Compile and test with Python 2.7 and 3.x

Transition roadmap

Here is the roadmap for the transition to Python 3 in WeeChat:

Transition to Python 3 starts.
All scripts that are not yet compatible with both Python 2.7 and Python 3.x can be updated to support both versions (see the status below).
You can help by converting existing scripts (see how to help below).
An e-mail is sent to the authors of Python scripts which are not compatible with Python 3 (at least they are not marked as compatible in database).
All authors are encouraged to make their scripts compatible with Python 3.x as soon as possible. Help from other people is welcome as well.
All new scripts must be compatible with both Python 2.7 and Python 3.x.
Script updates are still allowed to be compatible with Python 2.7 only.
All new scripts as well as script updates must be compatible with both Python 2.7 and Python 3.x.
Scripts must be properly tested with Python 2.7 and a Python 3.x version (if possible the latest stable).
New versions of WeeChat are compiled with Python 3 by default, which becomes the recommended Python version to use in WeeChat.
All new scripts as well as script updates must still be compatible with Python 2.7 and Python 3.x, time for the users to upgrade to the latest version of WeeChat which is Python 3 only.
Unfortunately, at this date, only 42% of Python scripts (96 out of 226) are compatible with Python 3. Compiling by default with Python 3 should speed up the update of scripts.
All new scripts as well as script updates must be compatible with Python 3.x. Extra support of Python 2.x is optional.
Hopefully, at this date, all scripts should be compatible with Python 3.
Important: at this date, all scripts that are not compatible with Python 3 are disabled: still visible on the scripts list page, but marked as "disabled" and these scripts can not be installed in WeeChat.

Transition status

The scripts which are compatible with Python 3 have tag "py3k-ok".
Transition status at various dates:

Date Scripts Python scripts Compatible with Python 3 Not yet compatible Notes
347 216 (62%) 43 (19%) 173 (81%)
362 226 (62%) 96 (42%) 130 (58%)
(today) 364   [ list ] 228 (62%)   [ list ] 124 (54%)   [ list ] 104 (46%)   [ list ]
370 * 233 (62%) * 137 (58%) * 96 (42%) * * Estimates

How to help

If possible, the author of script should make the necessary changes to make the script compatible with both Python 2.7 and 3.x.

Here's a list of some resources that can help to port scripts to Python 3:

Compile and test with Python 2.7 and 3.x

You can not use Python 2.7 and 3.x at same time in WeeChat, but you could compile both versions of the Python plugin and switch the Python plugin with aliases.

First check that you have both Python 2.7 and 3.x libraries installed to compile WeeChat with both versions.

Compile WeeChat with Python 3.x and install it in home directory. From the cloned git repository:

$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dev/weechat -DENABLE_PYTHON3=ON
$ make install
$ mv ~/dev/weechat/lib/weechat/plugins/python.so ~/dev/weechat/python3.so
$ rm -f CMakeCache.txt
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dev/weechat -DENABLE_PYTHON3=OFF
$ make install

Run WeeChat:

$ ~/dev/weechat/bin/weechat

Check that Python version is 2.7:

/debug libs

Libs:
(…)
  python: 2.7.16rc1

Add aliases to quickly switch between Python 2.7 and 3.x:

/alias add py2 /plugin unload python; /plugin load python
/alias add py3 /plugin unload python; /plugin load ~/dev/weechat/python3.so

Now you can type /py2 or /py3 to switch the Python version.
Note: this unloads all scripts because the Python plugin is reloaded.

To switch to Python 3.x:

/py3

Check that Python version is 3.x:

/debug libs

Libs:
(…)
  python: 3.7.2+