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

use inspect.signature for decorators #539

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 15 additions & 3 deletions spyne/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
decorator is a simple example of this.
"""

import sys

import spyne.const.xml

from copy import copy
Expand All @@ -47,6 +49,17 @@

from spyne.const import add_request_suffix

if sys.version_info >= (3, 3):
from inspect import signature

def _get_args(f):
return tuple(signature(f).parameters)
else:
from inspect import getargspec

def _get_args(f):
return tuple(getargspec(f).args)


def _produce_input_message(f, params, in_message_name, in_variable_names,
no_ctx, no_self, argnames, body_style_str, self_ref_cls):
Expand All @@ -58,10 +71,9 @@ def _produce_input_message(f, params, in_message_name, in_variable_names,

if argnames is None:
try:
argcount = f.__code__.co_argcount
argnames = f.__code__.co_varnames[arg_start:argcount]
argnames = _get_args(f)[arg_start:]

except AttributeError:
except ValueError:
raise TypeError(
"It's not possible to instrospect builtins. You must pass a "
"sequence of argument names as the '_args' argument to the "
Expand Down