Rewrite to python3 #10

Closed
opened 2021-01-13 01:04:31 +01:00 by muppeth · 1 comment
Owner

Since the mailgate is still written in python2 we should start by rewritting to python3

Since the mailgate is still written in python2 we should start by rewritting to python3
muppeth added this to the Python3 rewrite milestone 2021-01-13 01:04:31 +01:00
Collaborator

Python comes with a module lib2to3 that can be used to automatically port Python 2.x source to Python 3.x. I've just tried it out and the result was one step away from compiling as Python 3.7.

Auto-porting:

cd $repo
find . -type f -name '*.py' \
  -exec python -m lib2to3 --add-suffix=3 -n -w '{}' '+'

(Above command produces a bumch of *.py3 files.)

Then, I just had to clean up indentation (tabs mixed with spaces are not allowed), and it compiled with no other issues.

Before using this tool, I would just write some unit tests to make sure nothing breaks during the process of auto-porting (or at any later time).

Python comes with a module `lib2to3` that can be used to automatically port Python 2.x source to Python 3.x. I've just tried it out and the result was one step away from compiling as Python 3.7. Auto-porting: ```shell cd $repo find . -type f -name '*.py' \ -exec python -m lib2to3 --add-suffix=3 -n -w '{}' '+' ``` (Above command produces a bumch of `*.py3` files.) Then, I just had to clean up indentation (tabs mixed with spaces are not allowed), and it compiled with no other issues. Before using this tool, I would just write some [unit tests](https://docs.python.org/3.8/library/unittest.html) to make sure nothing breaks during the process of auto-porting (or at any later time).
pfm added a new dependency 2022-01-08 13:14:28 +01:00
pfm added a new dependency 2022-01-08 13:15:53 +01:00
Sign in to join this conversation.
No description provided.