[PR PATCH] Some py2 p3 bulk compat changes

Noel Power nopower at suse.com
Fri Apr 27 09:45:55 UTC 2018


Hi Alexander
On 27/04/18 10:12, Alexander Bokovoy wrote:
[...]
>> @@ -3110,7 +3110,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
>>  					char *_msg = NULL;
>>  					result = PyBytes_AsStringAndSize(item, &_msg, &size);
>>  					msg = _msg;
>> -				} else if (PyStr_Check(item)) {
>> +				} else if (PyUnicode_Check(item)) {
> Why not both PyStr_Check()/PyUnicode_Check()?
It's already covered in the previous else if (not shown in the context)
e.g the diff (with more context) would show
-                        if (PyBytes_Check(obj)) {
-                                    /* do stuff */
-                        } else if (PyStr_Check(obj)) {
-                                    /* do stuff */1
-                        } else {

+                        if (PyBytes_Check(obj)) {
+                                   /* do stuff */
+                        } else if (PyUnicode_Check(obj)) {
+                                    /* do stuff */1
+                        } else {
[...]
>
>> index 6cdd2ef77ed..25711028dda 100644
>> --- a/python/samba/graph.py
>> +++ b/python/samba/graph.py
>> @@ -39,8 +39,8 @@ def reformat_graph_label(s):
>>              if '-' in p[2:20]:
>>                  q, p = p.split('-', 1)
>>              else:
>> -                n = len(p) / 12
>> -                b = len(p) / n
>> +                n = len(p) // 12
>> +                b = len(p) // n
> I wonder if we should also do
>
> from __future__ import division
>
> to enforce PEP238 in py2 too.
>
sure, I'll try it and resubmit the branch, thanks alot for the review!

Noel



More information about the samba-technical mailing list