Kaydet (Commit) 89ca85c7 authored tarafından Yury Selivanov's avatar Yury Selivanov

inspect.Signature.from_function: Use CO_VARARGS & CO_VARKEYWORDS constants

üst 0486f819
...@@ -2109,7 +2109,7 @@ class Signature: ...@@ -2109,7 +2109,7 @@ class Signature:
default=defaults[offset])) default=defaults[offset]))
# *args # *args
if func_code.co_flags & 0x04: if func_code.co_flags & CO_VARARGS:
name = arg_names[pos_count + keyword_only_count] name = arg_names[pos_count + keyword_only_count]
annotation = annotations.get(name, _empty) annotation = annotations.get(name, _empty)
parameters.append(Parameter(name, annotation=annotation, parameters.append(Parameter(name, annotation=annotation,
...@@ -2126,9 +2126,9 @@ class Signature: ...@@ -2126,9 +2126,9 @@ class Signature:
kind=_KEYWORD_ONLY, kind=_KEYWORD_ONLY,
default=default)) default=default))
# **kwargs # **kwargs
if func_code.co_flags & 0x08: if func_code.co_flags & CO_VARKEYWORDS:
index = pos_count + keyword_only_count index = pos_count + keyword_only_count
if func_code.co_flags & 0x04: if func_code.co_flags & CO_VARARGS:
index += 1 index += 1
name = arg_names[index] name = arg_names[index]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment