Conditionally use functools.wraps if there is a __name__

This is a work around to https://bugs.pypy.org/issue1452