Skip to content

Commit

Permalink
compatible with old python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
aisk committed Sep 15, 2023
1 parent f731d4d commit 6e6c57b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions thriftpy2/parser/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import absolute_import

import sys
from warnings import warn


Expand All @@ -17,9 +18,12 @@ class ThriftGrammarError(ThriftParserError):
pass


def __getattr__(name):
if name == "ThriftGrammerError":
warn("'ThriftGrammerError' is a typo of 'ThriftGrammarError'", DeprecationWarning)
return ThriftGrammarError
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))
raise AttributeError("module %r has no attribute %r" % (__name__, name))
else:
ThriftGrammerError = ThriftGrammarError

0 comments on commit 6e6c57b

Please sign in to comment.