npower-python3-gpo-fix review

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

Actually 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 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/ 
index c1fd8237d6b..e554528c5cf 100644
--- a/python/samba/gp_parse/
+++ b/python/samba/gp_parse/
@@ -95,11 +95,8 @@ class GPAuditCsvParser(GPParser):

      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 
              writer = csv.writer(f, quoting=csv.QUOTE_MINIMAL)


'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:
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 '' love


More information about the samba-technical mailing list