[PR PATCH] [Updated] More py2 py3 compat

github at samba.org github at samba.org
Sun May 6 10:09:01 UTC 2018


There is an updated pull request by noelpower against master on the Samba Samba Github repository

https://github.com/noelpower/samba more_py2_py3_compat
https://github.com/samba-team/samba/pull/176

More py2 py3 compat
Some general py2/py3 compatibility fixes.
* b64encode results in bytes in python3 but we invariably treat the result in our code as string. This changes converts all usage of b64encode to decode the result, this will result in unicode in python2. Treating text as a text type (e.g. in python2) should ensure some sanity down the line (and should expose anywhere we don't really treat the result as a string)
* keys() now returns 'dict' class not a list, enclose result of .keys with list() function where it seems that makes sense
* xrange -> range Note: there is one instance of this where it might make a difference (see commit message) due to the potential amount of items in the range. Advice needed here, might need to drop one of these patches at the moment. Six apparently has a wrapper we could use instead (but CI doesn't support yet... I think) 
* md5 takes bytes in python3, some patches to make sure this is the case
* StringIO has moved to 'io' in python3, use the compat wrapper
* some missed exception compatibility fixes
* .next() method not longer exists in python3

A patch file from https://github.com/samba-team/samba/pull/176.patch is attached
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: github-pr-more_py2_py3_compat-176.patch
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180506/9ed2b8ab/github-pr-more_py2_py3_compat-176-0001.patch>


More information about the samba-technical mailing list