New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Py2/Py3 porting (not for review) #161
Conversation
gah, seems like future module is not available from the ci machine :/ I think six, future etc. are essential to write python2/python3 compatible code. Otherwise we will just be reinventing the wheel here. |
Indeed, Samba has chosen to reinvent the wheel with a smaller python2/3 layer. There is a text_type in python/samba/compat.py that may be of assistance. |
six is essential but 'future' can be omitted. In this case you can replace future.iteritems by a native key iteration which will work in both py2 and py3: - for key, val in global_settings.iteritems():
+ for key in global_settings:
f.write("\t%s = %s\n" % (key, global_settings[key]))
f.write("\n") I'd also recommend following a Conservative Porting Guide that was developed when porting many Python applications, including majority of Samba code: http://portingguide.readthedocs.io/en/latest/index.html |
thanks for the pointer to the guide (trying to wrap my head around it)
hadn't come across this one
…On 10/04/18 19:53, Alexander Bokovoy wrote:
six is essential but 'future' can be omitted. In this case you can
replace future.iteritems by a native key iteration which will work in
both py2 and py3:
- for key, val in global_settings.iteritems():
+ for key in global_settings:
f.write("\t%s = %s\n" % (key, global_settings[key]))
f.write("\n")
I'd also recommend following a Conservative Porting Guide that was
developed when porting many Python applications, including majority of
Samba code: http://portingguide.readthedocs.io/en/latest/index.html
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#161 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGIDVNeCkcGITnRYqG_eN5nqEERFrZk7ks5tnP-ugaJpZM4TOpHv>.
|
ca0f72a
to
fb65c26
Compare
8ba51f2
to
7732997
Compare
Changing the name of this patch set, using this branch for visibility/testing purposes. I'll try to keep this branch up to date (and will rebase as necessary) with current WIP patches from my own work. |
b7c2ae5
to
f7c9139
Compare
Signed-off-by: Noel Power <noel.power@suse.com>
replace (foo, bar) = e with (foo, bar) = e.args while will run in with both python2 and python3 Signed-off-by: Noel Power <noel.power@suse.com>
Fix some missed conversions of except Exception, e: to except Exception as e: Signed-off-by: Noel Power <noel.power@suse.com>
Signed-off-by: Noel Power <noel.power@suse.com>
Signed-off-by: Noel Power <noel.power@suse.com>
To allow code run in both python3 and python2 we have to ensure that md5 always receives bytes Signed-off-by: Noel Power <noel.power@suse.com>
Signed-off-by: Noel Power <noel.power@suse.com>
This one might be a better candidate for using six.moves as there are perhaps issues with the amount of elements involved Signed-off-by: Noel Power <noel.power@suse.com>
…cted Signed-off-by: Noel Power <noel.power@suse.com>
…code Signed-off-by: Noel Power <noel.power@suse.com>
…encode Signed-off-by: Noel Power <noel.power@suse.com>
Python 2 code works with str(policy["nTSecurityDescriptor"]) however this cannot work with Python 3. One could argue even the str method doesn't make sense at all (returning a string) for data. Signed-off-by: Noel Power <noel.power@suse.com>
Signed-off-by: Noel Power <noel.power@suse.com>
getpass returns str (e.g. bytes) in python2 and str (unicode) in py3. Adapt code to so we don't do illegal things (like try and decode) a string in python3 Signed-off-by: Noel Power <noel.power@suse.com>
…or py3 Signed-off-by: Noel Power <noel.power@suse.com>
…type Tests in python3 are intermingling bytes and strings types. Adjust code to ensure bytes are converted to str as appropriate
Port code to allow this test run with either py2 or py3 Signed-off-by: Noel Power <noel.power@suse.com>
Signed-off-by: Noel Power <noel.power@suse.com>
specifically this allows samba.tests.samba_tool.user_virtualCryptSHA to run py2/p3 compat
Although these tests run they don't work against the current docker CI image which needs to be updated with python3-pycrypto to work.
Changes to allow samba.tests.dsdb_lock is py2/py3 compatible. This tests a bit more some of the previous modules already ported