INNER CODE UNIT · Python
read_kind_defs
stp/stp · lib/AST/genkinds.py:88
def read_kind_defs(fname):
try:
# surrogateescape keeps any byte round-trippable, so an odd encoding
# in the input cannot make us fail where the Perl version did not.
with open(fname, "r", encoding="utf-8", errors="surrogateescape") as f:
return f.readlines()
except OSError as e:
sys.exit("Cannot open .kinds file %s: %s\n" % (fname, e.strerror))
def split_fields(kindlines):
"""Create the lists of things indexed by kinds."""
kindnames = []
cat_bits = []
category_names = []
cat_index = {}
for line in kindlines: