Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

six.wraps doesn't ignore non-existing attributes like Python 3 does #250

Closed
immerrr opened this issue Jul 20, 2018 · 1 comment · Fixed by #251
Closed

six.wraps doesn't ignore non-existing attributes like Python 3 does #250

immerrr opened this issue Jul 20, 2018 · 1 comment · Fixed by #251

Comments

@immerrr
Copy link
Contributor

immerrr commented Jul 20, 2018

Here's a repro script that fails in Python 2, but works in Python 3:

import six
class Hello(object):
    def __call__(self):
        return "Hello"
f = Hello()
@six.wraps(f)
def world():
    return f() + ", world"

On Python 2 it fails with

AttributeError: 'Hello' object has no attribute '__name__'

On Python 3 it succeeeds, because it was fixed in in https://bugs.python.org/issue3445. Given the trivial implementation it should be enough to backport the update_wrapper function as-is.

@immerrr
Copy link
Contributor Author

immerrr commented Jul 22, 2018

This is probably a duplicate of #165

benjaminp added a commit that referenced this issue Jan 7, 2020
This is pretty-much a straight backport of Py3 implementations of update_wrapper and (privately) wraps.

Fixes #250 
Fixes #165

Co-authored-by: Benjamin Peterson <benjamin@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant