From 58c6a07e43b959b85ca4966b9f877801d502d51d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 5 Sep 2020 20:09:39 +0100 Subject: [PATCH] Errors fetch scripts ported to Python 3 --- scripts/make_errorcodes.py | 8 ++++---- scripts/make_errors.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/make_errorcodes.py b/scripts/make_errorcodes.py index 1370ec84..26269c7e 100755 --- a/scripts/make_errorcodes.py +++ b/scripts/make_errorcodes.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Generate the errorcodes module starting from PostgreSQL documentation. The script can be run at a new PostgreSQL release to refresh the module. @@ -20,7 +20,7 @@ from __future__ import print_function import re import sys -import urllib2 +from urllib.request import urlopen from collections import defaultdict @@ -57,10 +57,10 @@ def parse_errors_txt(url): classes = {} errors = defaultdict(dict) - page = urllib2.urlopen(url) + page = urlopen(url) for line in page: # Strip comments and skip blanks - line = line.split('#')[0].strip() + line = line.decode("ascii").split('#')[0].strip() if not line: continue diff --git a/scripts/make_errors.py b/scripts/make_errors.py index 91ed2757..d88ca20f 100755 --- a/scripts/make_errors.py +++ b/scripts/make_errors.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Generate the errors module from PostgreSQL source code. The script can be run at a new PostgreSQL release to refresh the module. @@ -21,7 +21,7 @@ from __future__ import print_function import os import re import sys -import urllib2 +from urllib.request import urlopen from collections import defaultdict @@ -43,10 +43,10 @@ def parse_errors_txt(url): classes = {} errors = defaultdict(dict) - page = urllib2.urlopen(url) + page = urlopen(url) for line in page: # Strip comments and skip blanks - line = line.split('#')[0].strip() + line = line.decode('ascii').split('#')[0].strip() if not line: continue