Skip to content

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

Merged
merged 3 commits into from
Dec 29, 2019
Merged

Rename 'next' to 'anext' on Response #676

merged 3 commits into from
Dec 29, 2019

Conversation

florimondmanca
Copy link
Member

Refs #667

@florimondmanca florimondmanca added the api change PRs that contain breaking public API changes label Dec 21, 2019
@florimondmanca florimondmanca requested a review from a team December 21, 2019 17:05
httpx/client.py Outdated
Comment on lines 479 to 484
# 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,
Copy link
Member Author

@florimondmanca florimondmanca Dec 21, 2019

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? 🤷‍♂🤷‍♂🤷‍♂🤷‍♂🤷‍♂

Copy link
Member Author

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. 😕

@tomchristie tomchristie mentioned this pull request Dec 22, 2019
7 tasks
@tomchristie tomchristie added this to the 0.10.0 milestone Dec 23, 2019
@tomchristie tomchristie mentioned this pull request Dec 29, 2019
@tomchristie tomchristie merged commit 3462999 into master Dec 29, 2019
@tomchristie tomchristie deleted the response-anext branch December 29, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change PRs that contain breaking public API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants