diff --git a/src/makefun/main.py b/src/makefun/main.py index 22cd52e..e682155 100644 --- a/src/makefun/main.py +++ b/src/makefun/main.py @@ -466,7 +466,7 @@ def _signature_symbol_needs_protection(symbol, evaldict): :param symbol: :return: """ - if symbol is not None and symbol is not Parameter.empty and not isinstance(symbol, TYPES_WITH_SAFE_REPR): + if symbol is not None and symbol is not Parameter.empty and type(symbol) not in TYPES_WITH_SAFE_REPR: try: # check if the repr() of the default value is equal to itself. return eval(repr(symbol), evaldict) != symbol # noqa # we cannot use ast.literal_eval, too restrictive diff --git a/tests/test_issues.py b/tests/test_issues.py index d314d6e..ed32a9b 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -280,3 +280,19 @@ def test_issue_91(): """This test should work also in python 2 ! """ assert is_identifier("_results_bag") assert is_identifier("hello__bag") + + +def test_issue_98(): + class A(str): + def __str__(self): + return 'custom str' + + def __repr__(self): + return 'custom repr' + + def foo(a=A()): + pass + + @wraps(foo) + def test(*args, **kwargs): + return foo(*args, **kwargs)