edgewall / genshi

Python toolkit for generation of output for the web
http://genshi.edgewall.org
Other
86 stars 35 forks source link

stop using 2to3 for Python 3 compatibility #24

Closed FelixSchwarz closed 4 years ago

FelixSchwarz commented 4 years ago

While working on #23 I noticed that Genshi still uses 2to3 which made experimenting with the source code quite annoying. Therefore I started converting the source code so that the same code works with Python 2(.7) and Python 3(.4+).

I tried to break down the changes into self-contained chunks so they are easier to review.

Drop support for Python 2.4/2.5 and maybe 2.6

Python 2.6 may or may not work. Travis only offers Python 2.7 so I was unable to test Python 2.6. Anyway I don't think it matters much because these are all ancient releases and I doubt there are many users who run the latest Genshi on these versions.

I did not want to remove Python 2 support entirely as there are a few projects still relying on Python 2 (still supported in RHEL 7 for example).

Use six to provide single-source compatibility

I think six is a very simple dependency and using it is a good step to "highlight" the differences between Python 2 and Python 3 in Genshi. We can drop the dependency on six once we stop supporting Python 2 but I'm not interested in doing that right now.

This change set is not really useful on its own because it does not fix any bugs and it does not add any new features but I'm posting this anyway to gather some feedback on my work. I hope this helps me adding Python 3.9 compatibility for Genshi (see #23). Comments welcome.

Warning: The test suite is passing for me but so far I did not try this version with my real-world projects which use Genshi in production. I guess there should be no major issues but of course I may have added some new bugs...