Skip to content

Commit

Permalink
Merge pull request #123 from truebit/master
Browse files Browse the repository at this point in the history
Fix typo word
  • Loading branch information
ethe authored Sep 27, 2023
2 parents d0e9e50 + 0c0c0f7 commit 2a6f591
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_e_dead_include():
def test_e_grammer_error_at_eof():
with pytest.raises(ThriftGrammerError) as excinfo:
load('parser-cases/e_grammer_error_at_eof.thrift')
assert str(excinfo.value) == 'Grammer error at EOF'
assert str(excinfo.value) == 'Grammar error at EOF'


def test_e_use_thrift_reserved_keywords():
Expand Down
16 changes: 15 additions & 1 deletion thriftpy2/parser/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from __future__ import absolute_import

import sys
from warnings import warn


class ThriftParserError(Exception):
pass
Expand All @@ -11,5 +14,16 @@ class ThriftLexerError(ThriftParserError):
pass


class ThriftGrammerError(ThriftParserError):
class ThriftGrammarError(ThriftParserError):
pass


if sys.version_info >= (3, 7):
def __getattr__(name):
if name == "ThriftGrammerError":
warn("'ThriftGrammerError' is a typo of 'ThriftGrammarError'", DeprecationWarning)
return ThriftGrammarError

raise AttributeError("module %r has no attribute %r" % (__name__, name))
else:
ThriftGrammerError = ThriftGrammarError
12 changes: 6 additions & 6 deletions thriftpy2/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import types
from ply import lex, yacc
from .lexer import * # noqa
from .exc import ThriftParserError, ThriftGrammerError
from .exc import ThriftParserError, ThriftGrammarError
from thriftpy2._compat import urlopen, urlparse, PY3
from ..thrift import gen_init, TType, TPayload, TException

Expand All @@ -23,8 +23,8 @@

def p_error(p):
if p is None:
raise ThriftGrammerError('Grammer error at EOF')
raise ThriftGrammerError('Grammer error %r at line %d' %
raise ThriftGrammarError('Grammar error at EOF')
raise ThriftGrammarError('Grammar error %r at line %d' %
(p.value, p.lineno))


Expand Down Expand Up @@ -667,7 +667,7 @@ def _add_thrift_meta(key, val):
meta = getattr(thrift, '__thrift_meta__')

if key != 'consts' and val.__name__ in [x.__name__ for x in meta[key]]:
raise ThriftGrammerError(('\'%s\' type is already defined in '
raise ThriftGrammarError(('\'%s\' type is already defined in '
'\'%s\'') % (val.__name__, key))

meta[key].append(val)
Expand Down Expand Up @@ -869,7 +869,7 @@ def _fill_in_struct(cls, fields, _gen_init=True):

for field in fields:
if field[0] in thrift_spec or field[3] in _tspec:
raise ThriftGrammerError(('\'%d:%s\' field identifier/name has '
raise ThriftGrammarError(('\'%d:%s\' field identifier/name has '
'already been used') % (field[0],
field[3]))
ttype = field[2]
Expand Down Expand Up @@ -901,7 +901,7 @@ def _make_service(name, funcs, extends):
for func in funcs:
func_name = func[2]
if func_name in thrift_services:
raise ThriftGrammerError(('\'%s\' function is already defined in '
raise ThriftGrammarError(('\'%s\' function is already defined in '
'service \'%s\'') % (func_name,
name))
# args payload cls
Expand Down

0 comments on commit 2a6f591

Please sign in to comment.