diff options
author | Andy Fiddaman <omnios@citrus-it.co.uk> | 2018-11-15 10:17:46 +0000 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2019-01-10 11:09:52 -0500 |
commit | ca13eaa51ee900abba73dfb6624e492f7e48863e (patch) | |
tree | 0e42badd7d21d429fb2cb02f823c20d30f90b113 /usr/src/tools/scripts/mapfilechk.py | |
parent | 9b40c3052b9b0d91120c568df0c5211c131c8da1 (diff) | |
download | illumos-gate-ca13eaa51ee900abba73dfb6624e492f7e48863e.tar.gz |
9979 Support python3 for in-gate tools
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Alexander Pyhalov <apyhalov@gmail.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/tools/scripts/mapfilechk.py')
-rw-r--r-- | usr/src/tools/scripts/mapfilechk.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/usr/src/tools/scripts/mapfilechk.py b/usr/src/tools/scripts/mapfilechk.py index 0e3ba283a5..7429eba099 100644 --- a/usr/src/tools/scripts/mapfilechk.py +++ b/usr/src/tools/scripts/mapfilechk.py @@ -1,4 +1,4 @@ -#!@PYTHON@ +#!@TOOLS_PYTHON@ # # CDDL HEADER START # @@ -22,13 +22,14 @@ # # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # # # Check for valid link-editor mapfile comment blocks in source files. # -import sys, os, getopt, fnmatch +import sys, os, io, getopt, fnmatch sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib", "python%d.%d" % sys.version_info[:2])) @@ -48,7 +49,7 @@ class ExceptionList(object): fh = None try: fh = open(exfile, 'r') - except IOError, e: + except IOError as e: sys.stderr.write('Failed to open exception list: ' '%s: %s\n' % (e.filename, e.strerror)) sys.exit(2) @@ -90,14 +91,14 @@ def usage(): def check(filename, opts): try: - fh = open(filename, 'r') - except IOError, e: + with io.open(filename, encoding='utf-8', + errors='replace') as fh: + return mapfilechk(fh, verbose=opts['verbose'], + output=sys.stdout) + except IOError as e: sys.stderr.write("failed to open '%s': %s\n" % (e.filename, e.strerror)) return 1 - else: - return mapfilechk(fh, verbose=opts['verbose'], - output=sys.stdout) def walker(opts, dirname, fnames): for f in fnames: |