diff options
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: |