From ac115b51e71c24374682e2a9e6663f99d2faf000 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 27 Nov 2022 06:01:02 -0500 Subject: [PATCH] gh-99815: remove unused 'invalid' sentinel value and code that checks for it in inspect.signature parsing (GH-21104) --- Lib/inspect.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Lib/inspect.py b/Lib/inspect.py index 311a3f7e04b6a3..a896fcda31d1dd 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2184,7 +2184,6 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True): parameters = [] empty = Parameter.empty - invalid = object() module = None module_dict = {} @@ -2234,17 +2233,12 @@ def visit_Name(self, node): def p(name_node, default_node, default=empty): name = parse_name(name_node) - if name is invalid: - return None if default_node and default_node is not _empty: try: default_node = RewriteSymbolics().visit(default_node) - o = ast.literal_eval(default_node) + default = ast.literal_eval(default_node) except ValueError: - o = invalid - if o is invalid: return None - default = o if o is not invalid else default parameters.append(Parameter(name, kind, default=default, annotation=empty)) # non-keyword-only parameters