Skip to content

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

Merged
lovelydinosaur merged 3 commits into
masterfrom
response-anext
Dec 29, 2019
Merged

Rename 'next' to 'anext' on Response#676
lovelydinosaur merged 3 commits into
masterfrom
response-anext

Conversation

@florimondmanca

Copy link
Copy Markdown
Contributor

Refs #667

@florimondmancaflorimondmanca added the api change PRs that contain breaking public API changes label Dec 21, 2019
@florimondmanca
florimondmanca requested a review from a teamDecember 21, 2019 17:05
Comment threadhttpx/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,

@florimondmancaflorimondmancaDec 21, 2019

Copy link
Copy Markdown
ContributorAuthor

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…
importinspectclassFoo:
asyncdefbar(self):
passfoo=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) isfoo.bar) # False

Even though the unwrapping returns the same underlying function for "non-method" functions…

asyncdeffuncbar():
passpfuncbar=functools.partial(funcbar)
print(functools._unwrap_partial(pfuncbar) isfuncbar) # True

But then I realized this is a property of bound methods themselves…

print(foo.barisfoo.bar) # False

Wtf, Python? 🤷‍♂🤷‍♂🤷‍♂🤷‍♂🤷‍♂

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadhttpx/models.py Outdated
@lovelydinosaurlovelydinosaur added this to the 0.10.0 milestone Dec 23, 2019
@lovelydinosaurlovelydinosaur mentioned this pull request Dec 29, 2019
@lovelydinosaur
lovelydinosaur merged commit 3462999 into masterDec 29, 2019
@lovelydinosaur
lovelydinosaur deleted the response-anext branch December 29, 2019 15:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changePRs that contain breaking public API changes

Development

Successfully merging this pull request may close these issues.

2 participants

@florimondmanca@lovelydinosaur