diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-09-27 14:42:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 14:42:37 (GMT) |
commit | 3f22811fef73aec848d961593d95fa877f77ecbf (patch) | |
tree | 025ca176b2993e8d85a0961f994794c3f9801032 /Lib/inspect.py | |
parent | a94ee12c26aa8dd7dce01373779df8055aff765b (diff) | |
download | cpython-3f22811fef73aec848d961593d95fa877f77ecbf.zip cpython-3f22811fef73aec848d961593d95fa877f77ecbf.tar.gz cpython-3f22811fef73aec848d961593d95fa877f77ecbf.tar.bz2 |
bpo-32892: Use ast.Constant instead of specific constant AST types. (GH-9445)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index e799a83..5b7f526 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2005,14 +2005,8 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True): except NameError: raise RuntimeError() - if isinstance(value, str): - return ast.Str(value) - if isinstance(value, (int, float)): - return ast.Num(value) - if isinstance(value, bytes): - return ast.Bytes(value) - if value in (True, False, None): - return ast.NameConstant(value) + if isinstance(value, (str, int, float, bytes, bool, type(None))): + return ast.Constant(value) raise RuntimeError() class RewriteSymbolics(ast.NodeTransformer): |