[PR PATCH] Some py2 p3 bulk compat changes

Alexander Bokovoy ab at samba.org
Fri Apr 27 09:12:56 UTC 2018


On pe, 27 huhti 2018, Noel Power via samba-technical wrote:
> Hi Alexander
> On 27/04/18 08:48, Alexander Bokovoy via samba-technical wrote:
> > On pe, 27 huhti 2018, Github bot account via samba-technical wrote:
> >> There is a new pull request by noelpower against master on the Samba Samba Github repository
> >>
> >> https://github.com/noelpower/samba some-py2-p3-bulk-compat-changes
> >> https://github.com/samba-team/samba/pull/171
> >>
> >> Some py2 p3 bulk compat changes
> >> This patchset rolls up
> >> * some patches from the WIP branch mentioned in #161 
> >> * #166
> >> * #170 
> >> and some additional small changes.
> >>
> >>
> >> A patch file from https://github.com/samba-team/samba/pull/171.patch is attached
> > Not commenting on the patchset itself but the github gate seems to be
> > broken as it attached an html page instead of a patch.
> Thanks for spotting that, haven't a clue why that is happening
> (hopefully someone does and/or can fix)
> Attached is the patch set anyway
> 
> Noel

> @@ -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()?

> From 08fe5590f190cf444056d322b1b1e45119bd93c2 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 13 Apr 2018 17:17:20 +0100
> Subject: [PATCH 02/14] lib/tevent: Additionally accept unicode as string param
>  in Py2
ACK for this one.

> From 0cf4bdf13493b3d07c976c0cf9a31fafeb497e60 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 13 Apr 2018 17:32:15 +0100
> Subject: [PATCH 03/14] libcli/nbt: Additionally accept unicode as string param
>  in Py2
ACK for this one.

> From 4517cd7b8de013ffaea37d7eb73dfb332e8c6b72 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 13 Apr 2018 17:33:10 +0100
> Subject: [PATCH 04/14] s4/auth: Additionally accept unicode as string param in
>  Py2
ACK for this one.

> From c4fbae86ef880e6eff5015a3e846686a530685cc Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 13 Apr 2018 17:33:47 +0100
> Subject: [PATCH 05/14] s4/dsdb: Additionally accept unicode as string param in
>  Py2
ACK for this one.

> From defe82e5b81996ec2c99a4faf0904580d95a9851 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 13 Apr 2018 17:34:19 +0100
> Subject: [PATCH 06/14] s4/librpc: Additionally accept unicode as string param
>  in Py2
ACK for this one.

> From 813331aefeee5c1e4d214551939f3d5a40d8811d Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 13 Apr 2018 17:34:40 +0100
> Subject: [PATCH 07/14] s4/param: Additionally accept unicode as string param
>  in Py2
ACK for this one.

> From 793b4084ec3da24b44cb962f17ded6ef0c595b6e Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 13 Apr 2018 11:19:10 +0100
> Subject: [PATCH 08/14] python/samba: Add some compatability PY2/PY3 functions
ACK for this one.

> From 8d054c52ec11e37a4841fbec4357664b4aeb2b44 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Tue, 17 Apr 2018 13:52:58 +0100
> Subject: [PATCH 09/14] Add aliases for StringIO.StringIO
ACK for this one.

> From 2dd5aedaafd9859cb07679397010b2ce89633308 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Tue, 24 Apr 2018 16:28:41 +0100
> Subject: [PATCH 10/14] python/samba: Add binary_type for p2/p3 testing.
ACK for this one.

> From dbdd153607c5421f5a2fcadaa43c47b51b748184 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Wed, 25 Apr 2018 18:28:30 +0100
> Subject: [PATCH 11/14] python/samba: bulk conversion of caller to dsdb_Dn 2nd
>  param.
ACK for this one.

> From 4989e188968c9523cd01de62553fd8bb6eddfd0c Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Wed, 25 Apr 2018 20:01:49 +0100
> Subject: [PATCH 12/14] python: Bulk conversion callers of ldb.Dn second param
ACK for this one.

> From e351470d31a2163bcd18f0d3a59c2082174f6c62 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Thu, 26 Apr 2018 10:38:57 +0100
> Subject: [PATCH 13/14] python/samba: port some isinstance str checks (to cater
>  for unicode)
ACK for this one.

> From c5ab297174c2c2bc4897ec4f21aa3cfe5f0e84a9 Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Fri, 27 Apr 2018 08:15:28 +0100
> Subject: [PATCH 14/14] python/samba: Py2/Py3 compat change '/' to '//' to
>  ensure int result
> 
> Signed-off-by: Noel Power <noel.power at suse.com>
> ---
>  python/samba/graph.py          | 4 ++--
>  python/samba/netcmd/domain.py  | 2 +-
>  python/samba/upgradehelpers.py | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/python/samba/graph.py b/python/samba/graph.py
> 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.

$ python
Python 2.7.14 (default, Mar 14 2018, 13:36:31)
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 10/2
5
>>> 10//2
5
>>> from __future__ import division
>>> 10/2
5.0
>>> 10//2
5
>>>

-- 
/ Alexander Bokovoy



More information about the samba-technical mailing list