[PATCH] a couple of python patches

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Wed Oct 24 22:38:08 UTC 2018


This time with the patch.

On 25/10/18 11:27 AM, Douglas Bagnall via samba-technical wrote:
> These are a couple of patches derived from my "one hundred python
> patches" set that I warned about recently:
> 
>> Re: One hundred python patches
>> On 12/10/2018 07:04, Alexander Bokovoy via samba-technical wrote:
>>> On pe, 12 loka 2018, Douglas Bagnall via samba-technical wrote:
>>>> I have about 100 patches to python files here:
>>>>
>>>> https://gitlab.com/samba-team/devel/samba/commits/pyflake3-fixes
>>>>
>>>> They are WIP. Most of them are probably correct, though collectively
>>>> they don't like to pass CI.
>>> Thanks for this effort, Douglas.
>>>
>>> May be you can submit them in groups that are smaller and pass the
>>> tests? They aren't dependent on each other in most cases.
>>>
>> yep, please do these in bite sized portions if only to save my sanity (another large patchset brewing here..... https://gitlab.com/samba-team/devel/samba/commits/npower-pure-py3build) This one currently passes all (*manually*, note: *no* CI job yet) 
> 
> Noel's patches are in, and these two fall out of the merge conflicts.
> 
> The first one tries to maintain the original intention of the Python 2
> test, and the second removes a file of historical interest only.
> 
> CI: https://gitlab.com/samba-team/devel/samba/pipelines/34091930
> 
> More subsets of the hundred will be forthcoming.
> 
> cheers,
> Douglas
> 

-------------- next part --------------
From f102ffb2161779df5d7433d2aa0d00c88c148d47 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Thu, 11 Oct 2018 18:31:09 +1300
Subject: [PATCH 1/2] pytest/dcerpc.integer: force py2 long int without
 incompatible syntax

Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
---
 python/samba/tests/dcerpc/integer.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/python/samba/tests/dcerpc/integer.py b/python/samba/tests/dcerpc/integer.py
index 682edc1a67e..42308b657ce 100644
--- a/python/samba/tests/dcerpc/integer.py
+++ b/python/samba/tests/dcerpc/integer.py
@@ -68,7 +68,13 @@ class IntegerTests(samba.tests.TestCase):
 
     def test_long_into_int32(self):
         s = srvsvc.NetRemoteTODInfo()
-        s.timezone = 5
+        # here we force python2 to convert its 32/64 bit python int into
+        # an arbitrarily long python long, then reduce the number back
+        # down to something that would fit in an int anyway. In a pure
+        # python2 world, you could achieve the same thing by writing
+        #    s.timezone = 5L
+        # but that is a syntax error in py3.
+        s.timezone = (5 << 65) >> 65
         self.assertEquals(s.timezone, 5)
 
     def test_larger_long_int_into_int32(self):
-- 
2.17.1


From be20709b770deee9763f0d8cc466a9801ad08366 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed, 24 Oct 2018 15:56:20 +1300
Subject: [PATCH 2/2] python tests: always use Python's unicodedata

We had our own special version with very few entries, but only
used it in one place.

Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
---
 python/samba/tests/strings.py      | 12 ++++--------
 python/samba/tests/unicodenames.py | 28 ----------------------------
 2 files changed, 4 insertions(+), 36 deletions(-)
 delete mode 100644 python/samba/tests/unicodenames.py

diff --git a/python/samba/tests/strings.py b/python/samba/tests/strings.py
index 3ce778ddd00..657d99496fc 100644
--- a/python/samba/tests/strings.py
+++ b/python/samba/tests/strings.py
@@ -23,18 +23,14 @@
 # best way to do that yet.
 #
 # -- mbp
-from samba.compat import PY3
-if PY3:
-    import unicodedata
-    KATAKANA_LETTER_A = unicodedata.lookup("KATAKANA LETTER A")
-else:
-    from unicodenames import KATAKANA_LETTER_A as KATAKANA_LETTER_A
-
-
+import unicodedata
 import samba.tests
 from samba import strcasecmp_m, strstr_m
 
 
+KATAKANA_LETTER_A = unicodedata.lookup("KATAKANA LETTER A")
+
+
 def signum(a):
     if a < 0:
         return -1
diff --git a/python/samba/tests/unicodenames.py b/python/samba/tests/unicodenames.py
deleted file mode 100644
index d4a84e8c8f7..00000000000
--- a/python/samba/tests/unicodenames.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) 2003 by Martin Pool <mbp at samba.org>
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-"""Symbolic names for unicode characters.
-
-Defines symbolic names for a few UNICODE characters, to make test
-source code more readable on machines that don't have all the
-necessary fonts.
-"""
-
-LATIN_CAPITAL_LETTER_N_WITH_TILDE         = u'\u004e'
-LATIN_CAPITAL_LETTER_O_WITH_DIARESIS      = u'\u00d6'
-LATIN_SMALL_LETTER_O_WITH_DIARESIS        = u'\u00f6'
-
-KATAKANA_LETTER_A                         = u'\u30a2'
-- 
2.17.1



More information about the samba-technical mailing list