Skip to content
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

Closed
wants to merge 73 commits into from

Conversation

noelpower
Copy link
Contributor

Changes to allow samba.tests.dsdb_lock is py2/py3 compatible. This tests a bit more some of the previous modules already ported

@noelpower
Copy link
Contributor Author

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.

@abartlet
Copy link
Member

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.

@abbra
Copy link
Contributor

abbra commented Apr 10, 2018

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

@noelpower
Copy link
Contributor Author

noelpower commented Apr 12, 2018 via email

@noelpower noelpower force-pushed the py3_dsdb_lock branch 3 times, most recently from 8ba51f2 to 7732997 Compare April 13, 2018 20:03
@noelpower noelpower changed the title Py3 dsdb lock WIP Py3 dsdb lock Apr 18, 2018
@noelpower
Copy link
Contributor Author

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.
Currently I am in the process of porting individual tests, I am trying to identify wider and more generic changes from the changes necessary to get the tests to run, as I do that I am pulling those changes out into separate pull requests)

@noelpower noelpower changed the title WIP Py3 dsdb lock WIP Py2/Py3 porting Apr 27, 2018
@noelpower noelpower changed the title WIP Py2/Py3 porting WIP Py2/Py3 porting (not for review) Apr 27, 2018
@noelpower noelpower force-pushed the py3_dsdb_lock branch 2 times, most recently from b7c2ae5 to f7c9139 Compare May 1, 2018 19:03
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.
@noelpower noelpower closed this Jun 1, 2018
@noelpower noelpower deleted the py3_dsdb_lock branch June 1, 2018 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants