Skip to content

Commit

Permalink
use inspect.signature for decorators
Browse files Browse the repository at this point in the history
fixes #538
  • Loading branch information
costela committed Aug 12, 2017
1 parent 44f5fba commit 346c1d8
Showing 1 changed file with 15 additions and 3 deletions.
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

0 comments on commit 346c1d8

Please sign in to comment.