Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp309925ybl; Fri, 23 Aug 2019 00:58:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHzaiOjhthPQhCuQcfygJGS+IgaT0aNKVBrIRGcspjMf5YOaQJ4Itqn3Hg/9S0advkptCh X-Received: by 2002:a63:2043:: with SMTP id r3mr2807464pgm.311.1566547104534; Fri, 23 Aug 2019 00:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566547104; cv=none; d=google.com; s=arc-20160816; b=IaMqpO7hK8wTbKP/D+w9fjNR+d+rqsMToZKEB7HaFopufjO4SaGS8y4MQrAXiHUCT2 hopraKhcVYtSGgnV3eSLPwnfo8ajCQR0zqx8TA3bctb9DaNil7Fypknhgnb02OsURCHm zjr+HyLUbh5ys2ZiEVh/6bg32rt9zmQspOqpY8xsH5Sc4QyMizs+5iXcGiwq+P5rxgJy WR2iC1qD2Sh1E6IVNWItCIH10cqRwCVA1ok2sJWtNqCeyOB7MSDlke5ntvRttcMNCz52 upmozlVddgqCMVneWgoqUh2cBlDlQYfi+xcWBCNNHJkWLCRpYfqdeiKAchK/xTapEcj7 8/Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jSihI3iA1lEgE5zwFZm9Pf8rZ2m70mHaseRHcEqqmvA=; b=hJ1t6WOAMprEB5wOUi6zkuYKUIgnf1Lui2MYAL6usZnD1kMO/Xbf6X+QgHRCXYWqNI 2wY/AGBHFnUqRi58RjFF5lzogXH40J21/XUJPjk31uh10woU1A76z5AgUtlRABltB32r ZjtKfwswkhrYZQVBWWuQdk5fxtNCa2tNiORbtMG3wqAiX/zEVodVXyMlNC2TOcpDiSnM balksS5JLY2z9Zhd4aWHfnAuq0f6qGQ4pW4H10SHyoMp9uhZ6MuvwjiRicOSINONgOja ieFEfqEICmJytakEWrDDc6uMEKOzEQfIXgun3vmQ/DMRF5jB6X7xys85pyq1mrL11eXE wi8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si1818381pla.351.2019.08.23.00.57.57; Fri, 23 Aug 2019 00:58:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730339AbfHVTqp (ORCPT + 99 others); Thu, 22 Aug 2019 15:46:45 -0400 Received: from s3.sipsolutions.net ([144.76.43.62]:40534 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728782AbfHVTqp (ORCPT ); Thu, 22 Aug 2019 15:46:45 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1i0t2h-0007Wo-3h; Thu, 22 Aug 2019 21:46:43 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org, Seth Forshee Cc: Johannes Berg Subject: [PATCH] regdb: fix compatibility with python2 Date: Thu, 22 Aug 2019 21:46:27 +0200 Message-Id: <20190822194628.4910-1-johannes@sipsolutions.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Various changes in the commit mentioned below broke compatibility with python2. Restore it in a way that makes it worth with both versions. Fixes: f3c4969c2485 ("wireless-regdb: make scripts compatible with Python 3") Signed-off-by: Johannes Berg --- db2bin.py | 2 +- db2fw.py | 2 +- dbparse.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/db2bin.py b/db2bin.py index 28cd7d2ed373..29ae3136d5cb 100755 --- a/db2bin.py +++ b/db2bin.py @@ -118,7 +118,7 @@ reg_country_ptr.set() for alpha2 in countrynames: coll = countries[alpha2] # struct regdb_file_reg_country - output.write(struct.pack('>BBxBI', alpha2[0], alpha2[1], coll.dfs_region, reg_rules_collections[coll.permissions])) + output.write(struct.pack('>2sxBI', alpha2, coll.dfs_region, reg_rules_collections[coll.permissions])) if len(sys.argv) > 3: diff --git a/db2fw.py b/db2fw.py index 0c0f030c0c63..3affd5a8e0fa 100755 --- a/db2fw.py +++ b/db2fw.py @@ -85,7 +85,7 @@ countrynames = list(countries) countrynames.sort() for alpha2 in countrynames: coll = countries[alpha2] - output.write(struct.pack('>BB', alpha2[0], alpha2[1])) + output.write(struct.pack('>2s', alpha2)) country_ptrs[alpha2] = PTR(output) output.write(b'\x00' * 4) diff --git a/dbparse.py b/dbparse.py index 993f757b2cb1..5f7e08200fa0 100755 --- a/dbparse.py +++ b/dbparse.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from builtins import bytes from functools import total_ordering import sys, math from math import ceil, log @@ -359,7 +358,7 @@ class DBParser(object): for cname in cnames: if len(cname) != 2: self._warn("country '%s' not alpha2" % cname) - cname = bytes(cname, 'ascii') + cname = cname.encode('ascii') if not cname in self._countries: self._countries[cname] = Country(dfs_region, comments=self._comments) self._current_countries[cname] = self._countries[cname] -- 2.20.1