[PATCHES] begone python long
abartlet at samba.org
Wed Oct 10 08:46:28 UTC 2018
On Wed, 2018-10-10 at 17:44 +1300, Douglas Bagnall via samba-technical
> On 8/10/18 10:47 PM, Noel Power wrote:
> > 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.
> Yep, that's obviously better. I somehow had the idea that Python 2.6
> would not do that, but it does (since 2.4 or so).
> > With that change RB+ from me
BTW: When we finally go pure py3 there is some boilerplate at the top
of each PIDL generated py_ file to work out if a value fits in a python
int. It would be lovely to see that go away.
That is what the dcerpc.integer test is trying to be for, to check it
got the right answer and made small ints an int, and long ones a long.
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Catalyst IT http://catalyst.net.nz/services/samba
More information about the samba-technical