#!/usr/bin/python3 # Python decorator oddity with functools.wraps import functools def some_decorator(f): @functools.wraps(f) def THIS_SHOULD_NEVER_BE_SEEN(x): return f(x + 1) return THIS_SHOULD_NEVER_BE_SEEN @some_decorator def some_function(x): return x ** 2 try: some_function(5, "bogus extra argument") except TypeError as e: assert not 'THIS_SHOULD_NEVER_BE_SEEN' in str(e), str(e) # CPython 3.3.1 uses the old __name__ in the error message # TypeError: THIS_SHOULD_NEVER_BE_SEEN() takes 1 positional argument but 2 were given