[PR PATCH] [Closed]: Py3 string arg handling

github at samba.org github at samba.org
Fri May 11 03:52:49 UTC 2018


There's a closed pull request on the Samba Samba Github repository

Py3 string arg handling
https://github.com/samba-team/samba/pull/166
Description: Separate out patches from pull request #161 
Many of the python c-modules don't handle unicode as string types when passed say as object. This wasn't really a problem in a python2 only world. With code ported to be python2/python3 compatible it seems (at least in code we are porting) that we now find objects that were previously string in python2 now getting passed as unicode types in python2. This is a side affect of trying to cater for variables returned from functions as 'bytes'  in python3 that are returned as 'string' in python2. We normally do something like

   py2py3compat_var.decode('utf8')

To ensure the bytes provided in python3 are converted to 'str' The same line of code when running under python2 will covert a 'str' type to 'unicode'

We really should handle 'unicode' anyway as it is a 'text type. For example python2 code that use the ParseTuplexxxx functions to handle arguments already automatically handle 'str' or 
'unicode' when passed a 'string' format. 


More information about the samba-technical mailing list