contrib/check-py3-compat.py
changeset 41554 01417ca7f2e2
parent 32421 778dc37ce683
child 41555 ba7eaff26474
equal deleted inserted replaced
41553:eb14ab7db33e 41554:01417ca7f2e2
    43     """Check Python 3 compatibility of a file with Python 3."""
    43     """Check Python 3 compatibility of a file with Python 3."""
    44     with open(f, 'rb') as fh:
    44     with open(f, 'rb') as fh:
    45         content = fh.read()
    45         content = fh.read()
    46 
    46 
    47     try:
    47     try:
    48         ast.parse(content)
    48         ast.parse(content, filename=f)
    49     except SyntaxError as e:
    49     except SyntaxError as e:
    50         print('%s: invalid syntax: %s' % (f, e))
    50         print('%s: invalid syntax: %s' % (f, e))
    51         return
    51         return
    52 
    52 
    53     # Try to import the module.
    53     # Try to import the module.