Skip to content

fix running of set_up_configuration() in Python 3#2723

Merged
bartoldeman merged 9 commits intoeasybuilders:4.xfrom
boegel:py3_set_up_cfg
Jan 16, 2019
Merged

fix running of set_up_configuration() in Python 3#2723
bartoldeman merged 9 commits intoeasybuilders:4.xfrom
boegel:py3_set_up_cfg

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel boegel commented Jan 16, 2019

Just to clarify: this involves changing a bunch of string values ('...') to byte strings (b'...').

In Python 2.6 and 2.7, '...' and b'...' are exactly the same thing, but in Python 3 there's an important distinction between '...' and b'...', see for example https://eli.thegreenplace.net/2012/01/30/the-bytesstr-dichotomy-in-python-3.

In some cases, byte strings are produced in Python 3, and we need to take this into account when working on those values...

@boegel boegel added the python3 Python 3 compatibility label Jan 16, 2019
@boegel boegel added this to the 4.0 milestone Jan 16, 2019
Copy link
Copy Markdown
Contributor

@bartoldeman bartoldeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good to me. Just, when porting code to Python 3 years ago I found it nice to take advantage of iterability of dicts, which behave the same way in 2 and 3, unlike keys() vs iterkeys().
So I generally avoided all use of keys(), items(), values() and iterated over the dict instead, using list to make a copy of the keys if necessary. Sometimes the sorted() function comes in handy too.

Comment thread easybuild/base/generaloption.py Outdated
Comment thread easybuild/tools/configobj.py Outdated
Comment thread easybuild/tools/options.py Outdated
Copy link
Copy Markdown
Contributor

@bartoldeman bartoldeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm now 👍

@bartoldeman bartoldeman merged commit dcb4876 into easybuilders:4.x Jan 16, 2019
@boegel boegel deleted the py3_set_up_cfg branch January 16, 2019 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python3 Python 3 compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants