Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-99815: remove unused 'invalid' sentinel value and code that checks for it in inspect.signature parsing #21104

Merged
merged 2 commits into from
Nov 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,6 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):

parameters = []
empty = Parameter.empty
invalid = object()

module = None
module_dict = {}
Expand Down Expand Up @@ -2235,17 +2234,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
Expand Down