Skip to content

Commit 75befab

Browse files
authored
Improve Python version handling (#4726)
Checking just the second element of a version tuple is never good style, and it makes it less clear what actual versions of Python are in question. Signed-off-by: Colin Watson <[email protected]>
1 parent 933c4e0 commit 75befab

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

runtime/Python3/src/antlr4/Lexer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from io import StringIO
1212

1313
import sys
14-
if sys.version_info[1] > 5:
14+
if sys.version_info >= (3, 6):
1515
from typing import TextIO
1616
else:
1717
from typing.io import TextIO

runtime/Python3/src/antlr4/Parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Use of this file is governed by the BSD 3-clause license that
44
# can be found in the LICENSE.txt file in the project root.
55
import sys
6-
if sys.version_info[1] > 5:
6+
if sys.version_info >= (3, 6):
77
from typing import TextIO
88
else:
99
from typing.io import TextIO

tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ParserFile(file, parser, namedActions, contextSuperClass) ::= <<
5252
from antlr4 import *
5353
from io import StringIO
5454
import sys
55-
if sys.version_info[1] > 5:
55+
if sys.version_info >= (3, 6):
5656
from typing import TextIO
5757
else:
5858
from typing.io import TextIO
@@ -761,7 +761,7 @@ LexerFile(lexerFile, lexer, namedActions) ::= <<
761761
from antlr4 import *
762762
from io import StringIO
763763
import sys
764-
if sys.version_info[1] > 5:
764+
if sys.version_info >= (3, 6):
765765
from typing import TextIO
766766
else:
767767
from typing.io import TextIO

0 commit comments

Comments
 (0)