Backport Python 3.4 update_wrapper changes

Python 3.4 (and 3.3, but broken) improve update_wrapper() and wraps() to
add a __wrapped__ attribute to the wrapper function as it is updated. We
want to be able to rely on that functionality, so we need to make sure
that happens in older versions of Python as well.