except_handler.py 627 B

1234567891011121314151617181920
  1. # Copyright (c) 2020, 2025 Rocky Bernstein
  2. def except_handler(self, lhs, n: int, rule, ast, tokens: list, first: int, last: int):
  3. end_token = tokens[last - 1]
  4. # print("XXX", first, last)
  5. # for t in range(first, last):
  6. # print(tokens[t])
  7. # print("=" * 30)
  8. # FIXME: Figure out why this doesn't work on
  9. # bytecode-1.4/anydbm.pyc
  10. if self.version[:2] == (1, 4):
  11. return False
  12. # Make sure COME_FROMs froms come from within "except_handler".
  13. if end_token.kind != "COME_FROM":
  14. return False
  15. return end_token.attr is not None and end_token.attr < tokens[first].offset