Re: [patch] Py3 compat for create_certs.py

2020-03-31 Thread James McCoy
On Tue, Mar 31, 2020 at 09:39:12AM -0400, Justin Erenkrantz wrote:
> In reviewing your Python 3.x patches, I noticed a change to build/gen_def.py ;
> in my local tests, it didn't seem to be required; plus, trunk/1.4.x has a
> slightly different patch.

The changes for gen_def.py in the 1.3.x patch I provided weren't
strictly necessary for Python 3, but it's better management of
resources (ensuring the fname filehandle gets closed).  Not a big deal
in this case, since it's a short-lived script but better practice in
general.

> I'm leaning towards just backporting the change
> below; but, it doesn't seem to make a material difference either way as far as
> I can tell.  Do you (or anyone else) have any additional backstory here as to
> why the change is required?

Based on r1699621, it looks like that was general cleanup so
extract_exports() didn't need to create a list that was going to be
turned into a set anyway -- just deal with a set from the start.

Cheers,
-- 
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7  2D23 DFE6 91AE 331B A3DB


Re: [patch] Py3 compat for create_certs.py

2020-03-31 Thread Justin Erenkrantz
James,

Thanks.  I've backported the requisite changes to the 1.3.x branch to
support Python 3.x and scons - I tested on Ubuntu 18.04 and Debian Sid.
(Bert and Andreas had already reviewed those changes.)

In reviewing your Python 3.x patches, I noticed a change to
build/gen_def.py ; in my local tests, it didn't seem to be required; plus,
trunk/1.4.x has a slightly different patch.  I'm leaning towards just
backporting the change below; but, it doesn't seem to make a material
difference either way as far as I can tell.  Do you (or anyone else) have
any additional backstory here as to why the change is required?

I'll continue to do a sweep of the other pending changes and hope to cut a
1.3.10 release for review this week.

Cheers.  -- justin

Index: build/gen_def.py
===
--- build/gen_def.py(revision 1875932)
+++ build/gen_def.py(working copy)
@@ -53,11 +53,11 @@

 def extract_exports(fname):
   content = open(fname).read()
-  exports = [ ]
+  exports = set()
   for name in _funcs.findall(content):
-exports.append(name)
+exports.add(name)
   for name in _types.findall(content):
-exports.append(name)
+exports.add(name)
   return exports

 # Blacklist the serf v2 API for now


On Wed, Mar 25, 2020 at 8:29 PM James McCoy  wrote:

> On Sun, Dec 29, 2019 at 12:03:55AM +0100, Branko Čibej wrote:
> > On 28.12.2019 17:49, James McCoy wrote:
> > > On Wed, Dec 04, 2019 at 10:34:00PM -0500, James McCoy wrote:
> > >> I use create_certs.py at build time in the Debian packaging to avoid
> > >> dealing with expired certs.  Since Debian is in the process of trying
> to
> > >> remove Python 2, I've updated the script to work with Python 3.
> > >>
> > >> It would also be useful if 1.4 were released, so I could switch to the
> > >> CMake build.
> > > These are both becoming more important issues.  As an alternative, is
> > > current trunk in decent enough shape to be used, even without an
> > > official release?
> > >
> > > I can also look into more of the Python3 issues (like SyntaxErrors in
> > > SConstruct) if there's a desire to release another 1.3.x version (or to
> > > carry the patches locally until a new release happens).
> >
> > Sorry for not getting back to you sooner.
>
> No worries.  I ended up with two patches.  One that I've applied to the
> packaging of 1.3.9, since that was the immediate need.
>
> The other is for trunk and only covers a couple of the helper scripts.
> I got distracted by other priorities and didn't get around to finishing
> the work, but it should at least be a starting point.
>
> Cheers,
> --
> James
> GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7  2D23 DFE6 91AE 331B A3DB
>


Re: [patch] Py3 compat for create_certs.py

2020-03-25 Thread James McCoy
On Sun, Dec 29, 2019 at 12:03:55AM +0100, Branko Čibej wrote:
> On 28.12.2019 17:49, James McCoy wrote:
> > On Wed, Dec 04, 2019 at 10:34:00PM -0500, James McCoy wrote:
> >> I use create_certs.py at build time in the Debian packaging to avoid
> >> dealing with expired certs.  Since Debian is in the process of trying to
> >> remove Python 2, I've updated the script to work with Python 3.
> >>
> >> It would also be useful if 1.4 were released, so I could switch to the
> >> CMake build.
> > These are both becoming more important issues.  As an alternative, is
> > current trunk in decent enough shape to be used, even without an
> > official release?
> >
> > I can also look into more of the Python3 issues (like SyntaxErrors in
> > SConstruct) if there's a desire to release another 1.3.x version (or to
> > carry the patches locally until a new release happens).
> 
> Sorry for not getting back to you sooner.

No worries.  I ended up with two patches.  One that I've applied to the
packaging of 1.3.9, since that was the immediate need.

The other is for trunk and only covers a couple of the helper scripts.
I got distracted by other priorities and didn't get around to finishing
the work, but it should at least be a starting point.

Cheers,
-- 
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7  2D23 DFE6 91AE 331B A3DB
diff --git i/SConstruct w/SConstruct
index 4358a23..7f3cc94 100644
--- i/SConstruct
+++ w/SConstruct
@@ -20,6 +20,8 @@
 # 
 #
 
+from __future__ import print_function
+
 import sys
 import os
 import re
@@ -163,9 +165,9 @@ env.Append(BUILDERS = {
   suffix='.def', src_suffix='.h')
   })
 
-match = re.search('SERF_MAJOR_VERSION ([0-9]+).*'
-  'SERF_MINOR_VERSION ([0-9]+).*'
-  'SERF_PATCH_VERSION ([0-9]+)',
+match = re.search(b'SERF_MAJOR_VERSION ([0-9]+).*'
+  b'SERF_MINOR_VERSION ([0-9]+).*'
+  b'SERF_PATCH_VERSION ([0-9]+)',
   env.File('serf.h').get_contents(),
   re.DOTALL)
 MAJOR, MINOR, PATCH = [int(x) for x in match.groups()]
@@ -183,7 +185,7 @@ CALLOUT_OKAY = not (env.GetOption('clean') or env.GetOption('help'))
 
 unknown = opts.UnknownVariables()
 if unknown:
-  print 'Warning: Used unknown variables:', ', '.join(unknown.keys())
+  print('Warning: Used unknown variables:', ', '.join(unknown.keys()))
 
 apr = str(env['APR'])
 apu = str(env['APU'])
diff --git i/build/check.py w/build/check.py
index 2dacb4c..76945af 100755
--- i/build/check.py
+++ w/build/check.py
@@ -22,6 +22,8 @@
 # ===
 #
 
+from __future__ import print_function
+
 import sys
 import glob
 import subprocess
@@ -52,16 +54,16 @@ if __name__ == '__main__':
 
   # Find test responses and run them one by one
   for case in glob.glob(testdir + "/testcases/*.response"):
-print "== Testing %s ==" % (case)
+print("== Testing %s ==" % (case))
 try:
   subprocess.check_call([SERF_RESPONSE_EXE, case])
 except subprocess.CalledProcessError:
-  print "ERROR: test case %s failed" % (case)
+  print("ERROR: test case %s failed" % (case))
   sys.exit(1)
 
-  print "== Running the unit tests =="
+  print("== Running the unit tests ==")
   try:
 subprocess.check_call(TEST_ALL_EXE)
   except subprocess.CalledProcessError:
-print "ERROR: test(s) failed in test_all"
+print("ERROR: test(s) failed in test_all")
 sys.exit(1)
diff --git i/build/gen_def.py w/build/gen_def.py
index ad0..1e006ee 100755
--- i/build/gen_def.py
+++ w/build/gen_def.py
@@ -52,12 +52,13 @@ _types = re.compile(r'^extern const serf_bucket_type_t (serf_[a-z_]*);',
 
 
 def extract_exports(fname):
-  content = open(fname).read()
   exports = [ ]
-  for name in _funcs.findall(content):
-exports.append(name)
-  for name in _types.findall(content):
-exports.append(name)
+  with open(fname) as fd:
+content = fd.read()
+for name in _funcs.findall(content):
+  exports.append(name)
+for name in _types.findall(content):
+  exports.append(name)
   return exports
 
 # Blacklist the serf v2 API for now
Index: buckets/hpack_huffman.py
===
--- buckets/hpack_huffman.py	(revision 1875679)
+++ buckets/hpack_huffman.py	(working copy)
@@ -29,6 +29,8 @@
 # The following script parses the table to a C struct to be used
 # by the hpack huffman decoder and encoder in serf.
 
+from __future__ import print_function
+
 import re
 
 rfc_text = """
@@ -391,13 +393,13 @@
 bits = int(m.group(4))
 
 if len(bitvals) != bits:
-  print '%d vs %d (%s)' %(len(bitvals), bits, bitvals)
+  print('{d} vs {d} ({})'.format(len(bitvals), bits, bitvals))
   continue
 
 shift = hex << (32 - bits)
 
 if '{0:032b}'.format(shift)[0:bits] != bitvals:
-  print '%s vs %s' % ('{0:032b}'.format(shift)[0:bits], bitvals)
+  

Re: [patch] Py3 compat for create_certs.py

2019-12-28 Thread Branko Čibej
On 28.12.2019 17:49, James McCoy wrote:
> On Wed, Dec 04, 2019 at 10:34:00PM -0500, James McCoy wrote:
>> I use create_certs.py at build time in the Debian packaging to avoid
>> dealing with expired certs.  Since Debian is in the process of trying to
>> remove Python 2, I've updated the script to work with Python 3.
>>
>> It would also be useful if 1.4 were released, so I could switch to the
>> CMake build.
> These are both becoming more important issues.  As an alternative, is
> current trunk in decent enough shape to be used, even without an
> official release?
>
> I can also look into more of the Python3 issues (like SyntaxErrors in
> SConstruct) if there's a desire to release another 1.3.x version (or to
> carry the patches locally until a new release happens).


Sorry for not getting back to you sooner.

Trunk is, in my opinion, in decent enough shape to be used. But we
should still create  1.4, with full support for Python 3. I'll be happy
to apply any patches towards that goal.

-- Brane


Re: [patch] Py3 compat for create_certs.py

2019-12-28 Thread James McCoy
On Wed, Dec 04, 2019 at 10:34:00PM -0500, James McCoy wrote:
> I use create_certs.py at build time in the Debian packaging to avoid
> dealing with expired certs.  Since Debian is in the process of trying to
> remove Python 2, I've updated the script to work with Python 3.
> 
> It would also be useful if 1.4 were released, so I could switch to the
> CMake build.

These are both becoming more important issues.  As an alternative, is
current trunk in decent enough shape to be used, even without an
official release?

I can also look into more of the Python3 issues (like SyntaxErrors in
SConstruct) if there's a desire to release another 1.3.x version (or to
carry the patches locally until a new release happens).

Cheers,
-- 
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7  2D23 DFE6 91AE 331B A3DB