diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2019-01-25 11:32:25 +0000 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2019-02-12 09:38:12 +0000 |
commit | fa21127a646b8d2a61fe412728762250ca38ecd2 (patch) | |
tree | 8f0c21351c0e7c7e30b1c03a81c3d4f122f566c5 /src/python/m5/util/grammar.py | |
parent | 6ba4545b1f9553e68e992305c92cf46246a79dae (diff) | |
download | gem5-fa21127a646b8d2a61fe412728762250ca38ecd2.tar.xz |
python: Make exception handling Python 3 safe
Change-Id: I9c2cdfad20deb1ddfa224320cf93f2105d126652
Reviewed-on: https://gem5-review.googlesource.com/c/15980
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Diffstat (limited to 'src/python/m5/util/grammar.py')
-rw-r--r-- | src/python/m5/util/grammar.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/python/m5/util/grammar.py b/src/python/m5/util/grammar.py index 07702cfad..bb3429866 100644 --- a/src/python/m5/util/grammar.py +++ b/src/python/m5/util/grammar.py @@ -37,18 +37,17 @@ class ParseError(Exception): class Grammar(object): def setupLexerFactory(self, **kwargs): if 'module' in kwargs: - raise AttributeError, "module is an illegal attribute" + raise AttributeError("module is an illegal attribute") self.lex_kwargs = kwargs def setupParserFactory(self, **kwargs): if 'module' in kwargs: - raise AttributeError, "module is an illegal attribute" + raise AttributeError("module is an illegal attribute") if 'output' in kwargs: dir,tab = os.path.split(output) if not tab.endswith('.py'): - raise AttributeError, \ - 'The output file must end with .py' + raise AttributeError('The output file must end with .py') kwargs['outputdir'] = dir kwargs['tabmodule'] = tab[:-3] @@ -90,13 +89,13 @@ class Grammar(object): return -1 return self.current_lexer.lineno - raise AttributeError, \ - "'%s' object has no attribute '%s'" % (type(self), attr) + raise AttributeError( + "'%s' object has no attribute '%s'" % (type(self), attr)) def parse_string(self, data, source='<string>', debug=None, tracking=0): if not isinstance(data, basestring): - raise AttributeError, \ - "argument must be a string, was '%s'" % type(f) + raise AttributeError( + "argument must be a string, was '%s'" % type(f)) import new lexer = self.lex.clone() @@ -120,8 +119,8 @@ class Grammar(object): elif isinstance(f, file): source = f.name else: - raise AttributeError, \ - "argument must be either a string or file, was '%s'" % type(f) + raise AttributeError( + "argument must be either a string or file, was '%s'" % type(f)) return self.parse_string(f.read(), source, **kwargs) |