From 31d7393cae89af033100e3c4b523938c2c5c820d Mon Sep 17 00:00:00 2001 From: Roy Williams Date: Mon, 26 Jun 2017 19:06:17 -0700 Subject: [PATCH] Support calling eval and ast module with unicode in Python 2 (#1440) --- stdlib/2/__builtin__.pyi | 2 +- stdlib/2/ast.pyi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index a3bd488ca..bb2eb3a21 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -939,7 +939,7 @@ class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... class ResourceWarning(Warning): ... -def eval(s: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... +def eval(s: Union[str, unicode], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... def exec(object: str, globals: Optional[Dict[str, Any]] = None, locals: Optional[Dict[str, Any]] = None) -> Any: ... # TODO code object as source diff --git a/stdlib/2/ast.pyi b/stdlib/2/ast.pyi index 244b23092..d22a6f8b6 100644 --- a/stdlib/2/ast.pyi +++ b/stdlib/2/ast.pyi @@ -21,7 +21,7 @@ __version__ = ... # type: str PyCF_ONLY_AST = ... # type: int -def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> Module: ... +def parse(source: Union[str, unicode], filename: Union[str, unicode] = ..., mode: Union[str, unicode] = ...) -> Module: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ... @@ -29,7 +29,7 @@ def get_docstring(node: AST, clean: bool = ...) -> str: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: Union[str, AST]) -> Any: ... +def literal_eval(node_or_string: Union[str, unicode, AST]) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... class NodeVisitor():