URL: https://github.com/SSSD/sssd/pull/369
Title: #369: pysss_nss_idmap: remove unnecessary python2/3 ifdef

lslebodn commented:
"""
>Of course strings can be used, but I like bytes more because they better 
>indicate that to access the values not the string 'name' should be used but 
>pysss_nss_idmap.NAME_KEY

But it does not work in python2. Because type of pysss_nss_idmap.SID_KEY is 
string.
And it is also returned in dictionary.
```
sh$ python
Python 2.7.13 (default, Aug 16 2017, 12:56:26) 
[GCC 7.1.1 20170802 (Red Hat 7.1.1-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysss_nss_idmap
>>> type(pysss_nss_idmap.SID_KEY)
<type 'str'>
```

This is because bytes/unicode in python2 and python3 are handled differently.
```
sh$ python
Python 2.7.5 (default, Nov  6 2016, 00:28:07) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> type(b'sid')
<type 'str'>
>>> type(u'sid')
<type 'unicode'>
```

```
sh$ python3
Python 3.6.2 (default, Sep  1 2017, 12:03:48) 
[GCC 7.1.1 20170802 (Red Hat 7.1.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> type(b'sid')
<class 'bytes'>
>>> type(u'sid')
<class 'str'>
```

@sumit-bose so I think it would be better to be consistent and return string in 
python2 and also in python3.
Do you agree?
"""

See the full comment at 
https://github.com/SSSD/sssd/pull/369#issuecomment-327228883
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org

Reply via email to