Skip to content

use inspect instead of f.__code__ #538

@costela

Description

@costela

Hi there,

Currently the decorator._produce_input_message function uses "home-grown" introspection via f.__code__.(...) to get the parameters of the method being wrapped.
This doesn't work if the method has some other decorator, because the introspection tries to find the arguments of the decorator, instead of the decorated method.

Here's a simple example:

from functools import wraps

def deco(f):
	@wraps(f)
	def wrapped(*args, *kwargs):
		return f(*args, **kwargs)
	return wrapped

class SomeService(ServiceBase):
	@rpc(Unicode)
	@deco
	def someAction(ctx, some_argument):
		pass

Using inspect.signature(f) instead of reading f.__code__ might be a nice way to work around this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions