286 @rtype tuple of (dict, dict, None) or tuple of (None, None, ast.Module) |
286 @rtype tuple of (dict, dict, None) or tuple of (None, None, ast.Module) |
287 """ |
287 """ |
288 src = "".join(source) |
288 src = "".join(source) |
289 |
289 |
290 try: |
290 try: |
291 if sys.version_info >= (3, 8): |
291 tree = ( |
|
292 ast.parse(src, filename, 'exec', type_comments=True) |
292 # need the 'type_comments' parameter to include type annotations |
293 # need the 'type_comments' parameter to include type annotations |
293 tree = ast.parse(src, filename, 'exec', type_comments=True) |
294 if sys.version_info >= (3, 8) else |
294 else: |
295 ast.parse(src, filename, 'exec') |
295 tree = ast.parse(src, filename, 'exec') |
296 ) |
296 return None, None, tree |
297 return None, None, tree |
297 except (SyntaxError, TypeError): |
298 except (SyntaxError, TypeError): |
298 exc_type, exc = sys.exc_info()[:2] |
299 exc_type, exc = sys.exc_info()[:2] |
299 if len(exc.args) > 1: |
300 if len(exc.args) > 1: |
300 offset = exc.args[1] |
301 offset = exc.args[1] |