-
-
Notifications
You must be signed in to change notification settings - Fork 906
Rename 'next' to 'anext' on Response #676
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
Conversation
httpx/client.py
Outdated
# NOTE: not using 'self.send_handling_redirects' here, because | ||
# 'call_next' must reference a function (instead | ||
# of a method). This ensures that 'inspect.iscoroutinefunction()' | ||
# checks behave properly. | ||
Client.send_handling_redirects, | ||
self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's surprising, and possibly related to python/cpython#16600 — details below…
Details (click to expand)
Essentially boils down to…import inspect
class Foo:
async def bar(self):
pass
foo = Foo()
bar = functools.partial(foo.bar)
print(inspect.iscoroutinefunction(bar)) # False
Strangely though, the non-partial'd method behaves just fine…
print(inspect.iscoroutinefunction(foo.bar)) # True
functools.partial
is definitely doing something weird here, because…
print(functools._unwrap_partial(bar) is foo.bar) # False
Even though the unwrapping returns the same underlying function for "non-method" functions…
async def funcbar():
pass
pfuncbar = functools.partial(funcbar)
print(functools._unwrap_partial(pfuncbar) is funcbar) # True
But then I realized this is a property of bound methods themselves…
print(foo.bar is foo.bar) # False
Wtf, Python? 🤷♂🤷♂🤷♂🤷♂🤷♂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strangely, this workaround doesn't work on 3.6 and 3.7 — CI is failing for those versions. 😕
04b035f
to
ae310e3
Compare
Refs #667