Porting to Python 3 - the reload function

129 views
Skip to first unread message

Vincent Le Goff

unread,
Aug 14, 2012, 8:47:21 AM8/14/12
to lettuce-d...@googlegroups.com
Hi everyone.

Those last days, I tried to port the current code to Python 3 which I
currently use. I ended up with something which runs with Python 3,
which is good: there is still some unavailbale functions and some that
I didn't test, yet. But it was a first try.

Anyway, I have some questions about the reload built-in function which
doesn't exist (or not under the same name) on Python 3. It is used in
the package main file (lettuce/__init__.py) and the core file
(lettuce/core.py). If I understand it well, it's used to reload a
module which was previously imported (sometimes the line just before).

The two cases that really puzzle me:

* When we import terrain (the user configuration I guess), it's
realoded just after the first import
* When the output verbosity (and plugin) was found and imported, the
plugin is reloaded as well.

So my question is: why reload it? It's not very likely these files
were modified between their import and reload but these lines are not
here for no reason, I think. I can write a "reload" function for
Python 3 but before doing it, I'd like to know and understand the real
need.

Thanks for your job, BDD is a good development style and Lettuce does
allow to use it with Python.

Happy hacking,

Vincent

Vincent Le Goff

unread,
Aug 22, 2012, 11:25:55 AM8/22/12
to lettuce-d...@googlegroups.com
Hi everyone.

The last commit '1ef90cf0771...' does help. In case someone want to
use my work to port to Python 3:

I used the 2to3 tool which is usually pretty efficient. There are
still some pieces of code that has to be fixed manually, but it's
usually no big deal.

I also deleted the lettuce/django directory (and the one in the
integrations, too) as Django is not ported to Python 3 yet... and
won't be by the official developers I guess.

I had to comment the call to the fuzzywuzzy module (I didn't check yet
if it existed under Python 3).

The first real problem I m et was a difference that 2to3 cannot
correct that easily: the bytes and string on Python 2 and Python 3
doesn't have the same destination and the same use. The traceback is
very useful but I didn't have the time, yet, to find the breaking
point... or, to be more specific, I did correct it but another error
occured because of that correction.

Maybe other problems will appear, maybe the porting will be more
difficult than I think, but I believe with enough time it can be done
and not that difficultly.

If someone want to try it, I recommend to use 2to3 (there are not much
things to change to run the script) and see what happens.

Happy hacking,

Vincent

2012/8/14, Vincent Le Goff <vincent.l...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages