You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is a known limitation that Robot Framework does not support Python 3. This is due to Python 2 and 3 being incompatible and Robot being developed for the former.
With some effort it is relatively easy to write Python code that is compatible with Python 2.7 and 3.3. Supporting also Python 2.6 wouldn't be that big a task but other releases would be either require lot of extra work (2.5) or not be worth the effort due to limited installation base (3.0-3.2).
With Robot Framework the main problem is that the latest stable Jython release is 2.5.3 and we cannot drop Jython support. Jython 2.7 is under development, beta1 was released already in Feb 2013, but unfortunately the development is rather slow. If/when Jython 2.7 is released, or gets at least to the release candidate phase, dropping support from older releases is not an issue. People that need to keep using Python 2.5 can also keep on using older Robot versions.
Another main problem regarding to this issue is that the current core development team doesn't have resources to look at this during 2013.
Originally submitted to Google Code by zimmermann.code on 30 Sep 2013
Hi. I've also wanted to use Robot Framework with Python 3 for a while. Last week I found some time and just took a look at how hard it could get. And then I just couldn't stop... ;)
I created a robotframework-python3 fork on Bitbucket:
It's already working really well. Only 109/3111 critical atests still failing, mainly because some std libs like OS and some atests themselves need some further changes. It remains fully compatible with Python 2.5+. I use a combination of 2to3 and manual changes and tried to make the latter as small and unugly as possible.
I prepended some further explanations to the README.txt. For a complete diff look at:
If you like my approach I would be happy about some discussion regarding the missing changes. Especially the _Process communication bytes/str issues in OS lib. Better run Popen in text mode or better decode/encode stdin/stdout on demand?...
Originally submitted to Google Code by zimmermann.code on 30 Sep 2013
Dealing with issue 1531 I realized that with my current approach you can only run the acceptance tests for Python 3 if you also run the run_atests.py script with Python 3. I need to add more flexibility for that...
Great to hear you have got that far with Python 3 support rather easily. Have you continued the work from 109 failing tests?
I have always been thinking that we should implement Python 3 support by having a common code base. Based on your work it seems that 2to3 would be a viable option too. Did you do manual changes to the original code or to the converted? In the latter case keeping them in sync with future changes to the original code would probably be complicated.
Did you try that or are you interested to try the common code base option too? In my opinion only Python 2.7 and 3.3 are must versions to support, but it would be nice to support also 2.6. Supporting 2.5 would be hard because it doesn't support except Exception as e, and 3.0-3.2 do not support u'string with u prefix'.
The problem with dropping support from Python 2.5 is that it also drops Jython 2.5 which is the latest stable Jython release. Luckily Jython 2.7 development has been picking up some steam lately. There should be Jython 2.7 beta 2 in November with pip support and other such goodies. If this beta or future beta/rc releases are stable enough, we might be able to drop Python/Jython 2.5 support in the next RF major release.
Originally submitted to Google Code by user.stefanz on 5 Nov 2013
yes. i am still working on it :) and doing regular merges.
currently 59/3146 atests fail.
but they only need further workarounds in the atests themselves.
i did not care about the utests so far.
i also have to add the 2to3 stuff to run_utests.py.
but the code is working fine with the atests... so that should be no problem.
i only made manual changes in the original code.
2to3 is used on demand in setup.py and run_atests.py.
the changes to the atests are also partly manual and partly automated.
i created Run on python 2.x and Run on python 3.x switches
i made the Evaluate code compatible
(mostly adding ()s to print statements).
i wrote automated on-demand-conversions for log/output checking
like removing the u prefixes from unicode literals,
removing the L suffixes from long literals,
and substituting \x.. and \u.... with the actual unicode chars
(python 3 always prints them auto-encoded).
i think of 2to3 as an intermediate solution.
my goal is also common code which doesn't need 2to3 anymore.
i just want to get the tests completely working first.
then i want to add further manual compatibility changes
by going through the complete 2to3 diff step by step...
limiting support to 2.7+ and 3.3+ is also useful in my opinion.
and using six for the cases where really no common syntax exists.
like metaclasses...
most of the current manual changes are of course related to bytes/str/unicode/encode/decode issues.
i also added some new features to the standard test libraries to deal with that:
BuiltIn.Create Bytes \xabyte\x57ring
to explicity create python 3 bytes objects.
is it a good keyword name for that?
OperatingSystem.Start Process textio=True
to open the process io streams in text mode with Popen(unverasal_newlines=True)
to make them accept str instead of bytes in python 3.
or better make this default and add a bytesio= switch?
i would really like to get in some further discussion about the whole approach
if you see it as a suitable base for further official development...
Great progress! Having Python 3 compatible version based on 2to3 would be great. I agree we can work towards common codebase in the future. Comments to your questions below:
Is BuiltIn.Create Bytes needed when we now support \x escapes ( issue 1524 ) and there is String.Encode String To Bytes?
I would like to touch OperatingSystem.Start Process on Python 2 because it is in practice deprecated by Process.Start Process. Python 3 specific changes obviously can be done.
Would you like to discuss this stuff further on #robotframework IRC channel?
Originally submitted to Google Code by zimmermann.code on 5 Nov 2013
Encode String To Bytes also works but always needs an explicit encoding=iso8859
to result in the same byte values as defined in the input argument.
and you get UnicodeEncodeErrors.
i think that is not very intuitive if you just want to deal with bytes.
what do you think about changing Create Bytes
to acutally do an iso8859 encoding of the input string
so you don't need double \ before x?
maybe rename it to Convert To Bytes.
maybe make it also accept an integer sequence
or other input supported by the python 3 bytes constructor?
maybe additionally provide an Evaluate To Bytes
which behaves like the current Create Bytes?
irc. yes. i am always somehow present in #robotframework.
and mostly active during working hours :) ~ 9-18 cet
I don't think we need separate "Create Bytes" or "Convert To Bytes" when we already have "Encode String To Bytes". That keyword, and its decoding counterpart, definitely could get default encoding, though. I was initially thinking the default encoding should be UTF-8 that we use also elsewhere, but in order to be able to create bytes 0-255 by default, it apparently needs to be ISO-8859-1. If you think this is a good change, please submit a separate enhancement about it.
What kind of use cases you would have for other keywords for creating bytes?
Originally submitted to Google Code by zimmermann.code on 6 Nov 2013
initially i implemented Create Bytes as a workaround for
atest/testdata/standard_libraries/string/encode_decode.txt.
it uses Evaluate "...\x..." to create bytes
and Decode Bytes To String with a string argument.
both don't work in python 3.
i also thought of using Encode String To Bytes.
but it needs the explicit latin encoding.
and as a default encoding utf8 really makes more sense.
in that Decode... case i also thought it looks a bit strange
to first encode something and then decode when you actually only want to decode.
i thought about adding explicit internal str-->bytes argument conversions
to keywords if actually bytes are needed.
but finally i decided that special Bytes Keywords are a cleaner way
to deal with the missing implicit bytes<-->str convertibility in python 3.
and also a cleaner way to deal with pure binary data
for writing stuff to or checking input from binary file, device or process streams.
for me encoding/decoding always implies working with textual data.
and Create Bytes could provide these additional python 3 bytes() like features
like creation from number sequences.
I can see Create Bytes could be useful in some cases, especially when not dealing with textual data. It probably should work both with string (Unicode) and integer inputs and look something like below:
>>> def create_bytes(*args):
... return ''.join(''.join(chr(ord(c)) for c in arg) if isinstance(arg, basestring) else chr(arg) for arg in args)
...
>>> create_bytes(0, 1, 80, 228)
'\x00\x01P\xe4'
>>> create_bytes(u'hyv\xe4', 32, '\xe4iti', '!')
'hyv\xe4 \xe4iti!'
This should be submitted as a separate issue, though.
Originally submitted to Google Code by zimmermann.code on 27 Nov 2013
I merged with 2.8.2, made some additional changes, and everything still works fine.
In fact even better :)
Only 36/3249 critical atests still failing.
I removed my original Create Bytes keyword
and replaced it with (now Python 3 compatible) Convert To Bytes in the atests.
The Get Dictionary * keywords caused a lot of problems in the atests,
because the keys are sorted() and Python 3 doesn't support comparison
of values with different basic types like int and str.
I just removed the sorting in Python 3 as a first workaround.
But this now causes the fail of 10 other critical atests (10 out of the 36 above)
due to different order in output checks.
Maybe always sort the keys the Python 2 way with some custom robot.utils.sorted?
Where's this Get Dictionary? We probably could change it to use custom sorter that handles also different values somehow.
Do you think it would make sense to make a separate Python 3 compatible release at some point? I hope we can drop Jython 2.5 support and make the core project Python 3 compatible before next summer, but it would be awesome to have a separate release already before that.
Originally submitted to Google Code by zimmermann.code on 28 Nov 2013
I mean Collections.Get Dictionary Keys.
(And Get Dictionary Values/Items which rely on Keys)
I also thought about a separate robotframework-python3 package as a temporary solution.
(But not unofficial...)
I really would like to drop the 2.5 support asap.
To start fully porting to 2/3 compatible code without the need for 2to3.
And to remove some (for 2.6+) unnecessary version checks and try...excepts :)
1 design question is still open:
How to handle the different Python 3 Popen invocations needed for opening process streams
as either BytesIO or TextIO (universal_newlines=False/True)?
As described in comment #6 I added the boolean textio= argument to OperatingSystem.Start Process,
using TextIO on request instead of default BytesIO.
Is this a useful approach?
Change the default?
Handle it completely different? :)
Originally submitted to Google Code by zimmermann.code on 28 Nov 2013
Just a little addition:
Releasing for Python 3 is technically already possible.
I also made setup.py (using 2to3) fully work with Python 3.
And the installation result works too ;)
I only need to handle the few remaining atest fails and add the 2to3 stuff to run_utests.py.
And maybe make some manual changes in the utests code.
Just to make it complete in its current approach.
And the docs could need some updates for things that behave a bit different in Python 3 (mainly bytes/str related stuff).
Official Python 3 support is very close. All acceptance tests pass on Linux, OSX and Windows, and installation with Python 3 seems to work fine. Final tasks to do before this issue can be considered done:
setup.py must be updated to list Python 3 as a supported version.
Go through TODOs and FIXMEs in code and see is there anything Python 3 related.
Document supported Python versions (2.6, 2.7, 3.3->) in User Guide, README.rst, and INSTALL.rst. UPDATE: Partly done. Remaining tasks tracked by Update installation instructions #2222.
Decide do we want to create pybot3 script to avoid overwriting pybot script created by Python 2. Alternatively we could start using generic robot script with all interpreters. UPDATE: We decoded to go with the generic robot script. Issue New robot start-up script to replace pybot, jybot and ipybot #2216 covers that.
Final tasks listed in my previous comment are all either done or handed by other issues. I guess we can consider this issued finally done! Go Python 3!!!!!!!!!!!!!!!!!!
Activity
spooning commentedon Jun 30, 2014
It is a known limitation that Robot Framework does not support Python 3. This is due to Python 2 and 3 being incompatible and Robot being developed for the former.
With some effort it is relatively easy to write Python code that is compatible with Python 2.7 and 3.3. Supporting also Python 2.6 wouldn't be that big a task but other releases would be either require lot of extra work (2.5) or not be worth the effort due to limited installation base (3.0-3.2).
With Robot Framework the main problem is that the latest stable Jython release is 2.5.3 and we cannot drop Jython support. Jython 2.7 is under development, beta1 was released already in Feb 2013, but unfortunately the development is rather slow. If/when Jython 2.7 is released, or gets at least to the release candidate phase, dropping support from older releases is not an issue. People that need to keep using Python 2.5 can also keep on using older Robot versions.
Another main problem regarding to this issue is that the current core development team doesn't have resources to look at this during 2013.
spooning commentedon Jun 30, 2014
Hi. I've also wanted to use Robot Framework with Python 3 for a while. Last week I found some time and just took a look at how hard it could get. And then I just couldn't stop... ;)
I created a robotframework-python3 fork on Bitbucket:
https://bitbucket.org/userzimmermann/robotframework-python3
It's already working really well. Only 109/3111 critical atests still failing, mainly because some std libs like OS and some atests themselves need some further changes. It remains fully compatible with Python 2.5+. I use a combination of 2to3 and manual changes and tried to make the latter as small and unugly as possible.
I prepended some further explanations to the README.txt. For a complete diff look at:
https://bitbucket.org/userzimmermann/robotframework-python3/compare/default..c148e32#diff
If you like my approach I would be happy about some discussion regarding the missing changes. Especially the _Process communication bytes/str issues in OS lib. Better run Popen in text mode or better decode/encode stdin/stdout on demand?...
spooning commentedon Jun 30, 2014
Dealing with issue 1531 I realized that with my current approach you can only run the acceptance tests for Python 3 if you also run the run_atests.py script with Python 3. I need to add more flexibility for that...
spooning commentedon Jun 30, 2014
Great to hear you have got that far with Python 3 support rather easily. Have you continued the work from 109 failing tests?
I have always been thinking that we should implement Python 3 support by having a common code base. Based on your work it seems that 2to3 would be a viable option too. Did you do manual changes to the original code or to the converted? In the latter case keeping them in sync with future changes to the original code would probably be complicated.
Did you try that or are you interested to try the common code base option too? In my opinion only Python 2.7 and 3.3 are must versions to support, but it would be nice to support also 2.6. Supporting 2.5 would be hard because it doesn't support
except Exception as e, and 3.0-3.2 do not supportu'string with u prefix'.The problem with dropping support from Python 2.5 is that it also drops Jython 2.5 which is the latest stable Jython release. Luckily Jython 2.7 development has been picking up some steam lately. There should be Jython 2.7 beta 2 in November with pip support and other such goodies. If this beta or future beta/rc releases are stable enough, we might be able to drop Python/Jython 2.5 support in the next RF major release.
spooning commentedon Jun 30, 2014
Issue 1298 has been merged into this issue.
spooning commentedon Jun 30, 2014
yes. i am still working on it :) and doing regular merges.
currently 59/3146 atests fail.
but they only need further workarounds in the atests themselves.
i did not care about the utests so far.
i also have to add the 2to3 stuff to run_utests.py.
but the code is working fine with the atests... so that should be no problem.
i only made manual changes in the original code.
2to3 is used on demand in setup.py and run_atests.py.
the changes to the atests are also partly manual and partly automated.
i created Run on python 2.x and Run on python 3.x switches
i made the Evaluate code compatible
(mostly adding ()s to print statements).
i wrote automated on-demand-conversions for log/output checking
like removing the u prefixes from unicode literals,
removing the L suffixes from long literals,
and substituting \x.. and \u.... with the actual unicode chars
(python 3 always prints them auto-encoded).
i think of 2to3 as an intermediate solution.
my goal is also common code which doesn't need 2to3 anymore.
i just want to get the tests completely working first.
then i want to add further manual compatibility changes
by going through the complete 2to3 diff step by step...
limiting support to 2.7+ and 3.3+ is also useful in my opinion.
and using six for the cases where really no common syntax exists.
like metaclasses...
most of the current manual changes are of course related to bytes/str/unicode/encode/decode issues.
i also added some new features to the standard test libraries to deal with that:
BuiltIn.Create Bytes \xabyte\x57ring
to explicity create python 3 bytes objects.
is it a good keyword name for that?
OperatingSystem.Start Process textio=True
to open the process io streams in text mode with Popen(unverasal_newlines=True)
to make them accept str instead of bytes in python 3.
or better make this default and add a bytesio= switch?
i would really like to get in some further discussion about the whole approach
if you see it as a suitable base for further official development...
you can view the current complete fork diff at:
https://bitbucket.org/userzimmermann/robotframework-python3/compare/default..523e395#diff
spooning commentedon Jun 30, 2014
Great progress! Having Python 3 compatible version based on 2to3 would be great. I agree we can work towards common codebase in the future. Comments to your questions below:
Is
BuiltIn.Create Bytesneeded when we now support \x escapes ( issue 1524 ) and there isString.Encode String To Bytes?I would like to touch
OperatingSystem.Start Processon Python 2 because it is in practice deprecated byProcess.Start Process. Python 3 specific changes obviously can be done.Would you like to discuss this stuff further on #robotframework IRC channel?
spooning commentedon Jun 30, 2014
to result in the same byte values as defined in the input argument.
and you get UnicodeEncodeErrors.
i think that is not very intuitive if you just want to deal with bytes.
what do you think about changing Create Bytes
to acutally do an iso8859 encoding of the input string
so you don't need double \ before x?
maybe rename it to Convert To Bytes.
maybe make it also accept an integer sequence
or other input supported by the python 3 bytes constructor?
maybe additionally provide an Evaluate To Bytes
which behaves like the current Create Bytes?
irc. yes. i am always somehow present in #robotframework.
and mostly active during working hours :) ~ 9-18 cet
spooning commentedon Jun 30, 2014
I don't think we need separate "Create Bytes" or "Convert To Bytes" when we already have "Encode String To Bytes". That keyword, and its decoding counterpart, definitely could get default encoding, though. I was initially thinking the default encoding should be UTF-8 that we use also elsewhere, but in order to be able to create bytes 0-255 by default, it apparently needs to be ISO-8859-1. If you think this is a good change, please submit a separate enhancement about it.
What kind of use cases you would have for other keywords for creating bytes?
spooning commentedon Jun 30, 2014
initially i implemented Create Bytes as a workaround for
atest/testdata/standard_libraries/string/encode_decode.txt.
it uses Evaluate "...\x..." to create bytes
and Decode Bytes To String with a string argument.
both don't work in python 3.
i also thought of using Encode String To Bytes.
but it needs the explicit latin encoding.
and as a default encoding utf8 really makes more sense.
in that Decode... case i also thought it looks a bit strange
to first encode something and then decode when you actually only want to decode.
i thought about adding explicit internal str-->bytes argument conversions
to keywords if actually bytes are needed.
but finally i decided that special Bytes Keywords are a cleaner way
to deal with the missing implicit bytes<-->str convertibility in python 3.
and also a cleaner way to deal with pure binary data
for writing stuff to or checking input from binary file, device or process streams.
for me encoding/decoding always implies working with textual data.
and Create Bytes could provide these additional python 3 bytes() like features
like creation from number sequences.
spooning commentedon Jun 30, 2014
I can see Create Bytes could be useful in some cases, especially when not dealing with textual data. It probably should work both with string (Unicode) and integer inputs and look something like below:
>>> def create_bytes(*args):
... return ''.join(''.join(chr(ord(c)) for c in arg) if isinstance(arg, basestring) else chr(arg) for arg in args)
...
>>> create_bytes(0, 1, 80, 228)
'\x00\x01P\xe4'
>>> create_bytes(u'hyv\xe4', 32, '\xe4iti', '!')
'hyv\xe4 \xe4iti!'
This should be submitted as a separate issue, though.
spooning commentedon Jun 30, 2014
I merged with 2.8.2, made some additional changes, and everything still works fine.
In fact even better :)
Only 36/3249 critical atests still failing.
I removed my original Create Bytes keyword
and replaced it with (now Python 3 compatible) Convert To Bytes in the atests.
The Get Dictionary * keywords caused a lot of problems in the atests,
because the keys are sorted() and Python 3 doesn't support comparison
of values with different basic types like int and str.
I just removed the sorting in Python 3 as a first workaround.
But this now causes the fail of 10 other critical atests (10 out of the 36 above)
due to different order in output checks.
Maybe always sort the keys the Python 2 way with some custom robot.utils.sorted?
Current complete diff:
https://bitbucket.org/userzimmermann/robotframework-python3/compare/default..1fd297b#diff
spooning commentedon Jun 30, 2014
Where's this Get Dictionary? We probably could change it to use custom sorter that handles also different values somehow.
Do you think it would make sense to make a separate Python 3 compatible release at some point? I hope we can drop Jython 2.5 support and make the core project Python 3 compatible before next summer, but it would be awesome to have a separate release already before that.
spooning commentedon Jun 30, 2014
I mean Collections.Get Dictionary Keys.
(And Get Dictionary Values/Items which rely on Keys)
I also thought about a separate robotframework-python3 package as a temporary solution.
(But not unofficial...)
I really would like to drop the 2.5 support asap.
To start fully porting to 2/3 compatible code without the need for 2to3.
And to remove some (for 2.6+) unnecessary version checks and try...excepts :)
1 design question is still open:
How to handle the different Python 3 Popen invocations needed for opening process streams
as either BytesIO or TextIO (universal_newlines=False/True)?
As described in comment #6 I added the boolean textio= argument to OperatingSystem.Start Process,
using TextIO on request instead of default BytesIO.
Is this a useful approach?
Change the default?
Handle it completely different? :)
spooning commentedon Jun 30, 2014
Just a little addition:
Releasing for Python 3 is technically already possible.
I also made setup.py (using 2to3) fully work with Python 3.
And the installation result works too ;)
I only need to handle the few remaining atest fails and add the 2to3 stuff to run_utests.py.
And maybe make some manual changes in the utests code.
Just to make it complete in its current approach.
And the docs could need some updates for things that behave a bit different in Python 3 (mainly bytes/str related stuff).
25 remaining items
Initial Python 3 support. Tests are not working with python 3 yet. #1506
Cleanup tests to make it possible to run them with python3. #1506
Change to use print() in tests. #1506
fixes for unic unit tests for py3. #1506
utest py3 compatibility fixed. #1506
Use class decorator to map __unicode__ to __str__ and __nonzero__ to …
Fix libdoc tests for py3. #1506
pekkaklarck commentedon Nov 10, 2015
Official Python 3 support is very close. All acceptance tests pass on Linux, OSX and Windows, and installation with Python 3 seems to work fine. Final tasks to do before this issue can be considered done:
pybot3script to avoid overwritingpybotscript created by Python 2. Alternatively we could start using genericrobotscript with all interpreters. UPDATE: We decoded to go with the genericrobotscript. Issue Newrobotstart-up script to replacepybot,jybotandipybot#2216 covers that.setup.py: Specify we support Python 3. #1506
pekkaklarck commentedon Nov 18, 2015
Final tasks listed in my previous comment are all either done or handed by other issues. I guess we can consider this issued finally done! Go Python 3!!!!!!!!!!!!!!!!!!