From 63914b95b8aa1153fc44c7cc5b6a4ca1eb2bbc39 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 26 Dec 2018 12:11:17 -0500 Subject: [PATCH] lib/wind: PY3 gen-punycode-examples.py Update gen-punycode-examples.py for python 3. gen-punycode-examples.py parses the Sample strings from section 7.1 of rfc3492.txt and generates the punycode_examples.[ch] sources containing the punycode_examples[]. Python 3 requires that print output be surrounded by parentheses and the split and join operations have been moved from the "string" class to built-ins. This change adds the missing parentheses and switches to the built-in split and join str operations. The "string" class is no longer required as an import. Change-Id: Ic5f341080d2ff2feef692c89e0b28dcbf4e48cb4 --- lib/wind/gen-punycode-examples.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/wind/gen-punycode-examples.py b/lib/wind/gen-punycode-examples.py index 44f5dafe5..c7d6381d0 100644 --- a/lib/wind/gen-punycode-examples.py +++ b/lib/wind/gen-punycode-examples.py @@ -35,13 +35,12 @@ # SUCH DAMAGE. import re -import string import sys import generate if len(sys.argv) != 3: - print "usage: %s rfc3492.txt" % sys.argv[0] + print("usage: %s rfc3492.txt" % sys.argv[0]) sys.exit(1) f = open(sys.argv[1], 'r') @@ -72,7 +71,7 @@ while True: else: m = re.search('^ *([uU]+.*) *$', l) if m: - codes.extend(string.split(m.group(1), ' ')) + codes.extend(m.group(1).split(' ')) else: m = re.search('^ *Punycode: (.*) *$', l) if m: @@ -115,7 +114,7 @@ for x in cases: examples_c.file.write( " {%u, {%s}, \"%s\", \"%s\"},\n" % (len(cp), - string.join([re.sub('[uU]\+', '0x', x) for x in cp], ', '), + ",".join([re.sub('[uU]\+', '0x', x) for x in cp]), pc, desc))