Skip to content

Commit

Permalink
Use ast.Constant for recent Python versions (#526)
Browse files Browse the repository at this point in the history
ast.Str is planned to removed in Python 3.14, use ast.Constant instead
whenever the later is available.
  • Loading branch information
wdhongtw authored Aug 9, 2024
1 parent e9f49b0 commit a59f6ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fire/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@

import argparse
import ast
import sys

if sys.version_info[0:2] < (3, 8):
_StrNode = ast.Str
else:
_StrNode = ast.Constant

def CreateParser():
parser = argparse.ArgumentParser(add_help=False)
Expand Down Expand Up @@ -127,4 +132,4 @@ def _Replacement(node):
# These are the only builtin constants supported by literal_eval.
if value in ('True', 'False', 'None'):
return node
return ast.Str(value)
return _StrNode(value)

0 comments on commit a59f6ba

Please sign in to comment.