[PATCHES] begone python long

Noel Power nopower at suse.com
Mon Oct 8 09:47:51 UTC 2018


Hi Douglas
On 04/10/2018 03:40, Douglas Bagnall via samba-technical wrote:
> Tim was fixing the (py3-incompatible, py2-wrong) use of Python long() 
> for a C binding that took C longs which it then squeezed into time_t, 
> and I thought I'd look for other python longs. There aren't many, if 
> we neglect third_party/. After this there will be one, but Python 3 
> won't see it. cheers, Douglas
[...]
> @ -831,7 +831,9 @@ def int64range2str(value):
>      :param value: The int64 range
>      :return: A string of the representation of the range
>      """
> -
> -    lvalue = long(value)
> +    if PY3:
> +        lvalue = int(value)
> +    else:
> +        lvalue = long(value)
>      str = "%d-%d" % (lvalue &0xFFFFFFFF, lvalue >>32)
>      return str

I don't think we need the if PY3: above, simply changing the line as follows
-    lvalue = long(value)
+    value = int(value)

afaics should be enough. Python2 int function will return a long if you 
pass it something outside the the integer range. This will avoid another 
PY3 specific test in the code which we try to avoid wherever possible.

With that change RB+ from me

Noel





More information about the samba-technical mailing list