npower-python3-gpo-fix review

Noel Power nopower at suse.com
Sat Oct 27 09:07:01 UTC 2018


Actually io.open seems the correct choice, I somehow got confused, it 
really was too early in the morning :-)

On 26/10/2018 09:25, Noel Power wrote:
> On 26/10/2018 09:17, Noel Power wrote:
>>> but not in 2 (no encoding keyword).
>> hmm maybe using io.open then 
>
> strike that, too early in the morning, anyway I haven't yet looked at 
> your version (hopefully later) hopefully my excuse for a brain may be 
> working a little by then
>
with this change on your branch

diff --git a/python/samba/gp_parse/gp_csv.py 
b/python/samba/gp_parse/gp_csv.py
index c1fd8237d6b..e554528c5cf 100644
--- a/python/samba/gp_parse/gp_csv.py
+++ b/python/samba/gp_parse/gp_csv.py
@@ -95,11 +95,8 @@ class GPAuditCsvParser(GPParser):
                  self.lines.append(line)

      def write_binary(self, filename):
-        if PY3:
-            kwargs = {'encoding': self.encoding}
-        else:
-            kwargs={}
-        with open(filename, 'w', **kwargs) as f:
+       from io import open
+        with open(filename, 'w', self.encoding) as f:
              # In this case "binary" means "utf-8", so we let Python do 
that.
              writer = csv.writer(f, quoting=csv.QUOTE_MINIMAL)
              writer.writerow(self.header)


with

'make test TESTS=samba.tests.samba_tool.gpo'

I get


[...]

ALL OK (20 tests in 2 testsuites)

A summary with detailed information can be found in:
   ./st/summary
TOP 10 slowest tests
samba.tests.samba_tool.gpo(ad_dc:local) -> 17
samba.tests.samba_tool.gpo(ad_dc_ntvfs:local) -> 16

So this looks good (if we are happy with the other changes). I'm out 
monday so if you are happy with the above I'll rewrite my commits with 
this change and the other minor tweaks from review when I return.

Also I'd bet we are are using 'w' or 'r' with other 'open' calls all 
over the code base that could do with some 'io.open' love

Noel



More information about the samba-technical mailing list