[PATCH 6 of 8] import-checker: handle ast.parse SyntaxErrors

Yuya Nishihara yuya at tcha.org
Thu Mar 31 10:34:21 EDT 2016


On Wed, 30 Mar 2016 04:24:06 -0500, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1459325470 0
> #      Wed Mar 30 08:11:10 2016 +0000
> # Node ID d8be8db8119d2d716ad9ddaaaa077cf278f6273c
> # Parent  54b962661f75e4a55c213c0eeb30f5d6024f7dbe
> import-checker: handle ast.parse SyntaxErrors
> 
> diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> --- a/contrib/import-checker.py
> +++ b/contrib/import-checker.py
> @@ -233,6 +233,13 @@
>  
>  stdlib_modules = set(list_stdlib_modules())
>  
> +def parse(source):
> +    """Wrapper around ast.parse()"""
> +    try:
> +        return ast.parse(source)
> +    except SyntaxError:
> +        return ast.parse("'SyntaxError'")

Doesn't it just bury a SyntaxError? I think it should be reported as an
error like other messages.


More information about the Mercurial-devel mailing list