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

Compat python 3.8 #4056

Merged
merged 7 commits into from
Sep 17, 2019
Merged

Compat python 3.8 #4056

merged 7 commits into from
Sep 17, 2019

Conversation

Hanaasagi
Copy link
Member

@Hanaasagi Hanaasagi commented Sep 12, 2019

What do these changes do?

Compat Python 3.8.

  • fix import path, because asyncio related exceptions are moved to asyncio.exceptions in 3.8.
  • fix make_mocked_coro
  • fix the mock patch, because 3.8 adds empty slots to abstract asyncio protocols
  • fix some deprecated usage:
    • loop argument is deprecated in asyncio.sleep
    • asyncio.coroutine
    • asyncio.open_connection

Are there changes in behavior for the user?

I think not.

Related issue number

It will resolve #3776

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@Hanaasagi
Copy link
Member Author

Hanaasagi commented Sep 12, 2019

This pull request is still work in process. Test with Python 3.8.0b4 in my local environment.

run make test

9 failed, 2418 passed, 14 skipped, 3 xfailed, 27 error in 156.87s (0:02:36)

Most errors are due to Python 3.8 adds empty slots to abstract asyncio protocols, please see python/cpython#10889

屏幕快照 2019-09-12 10 04 33

We can not do something like srv._drain_helper = mock.Mock() directly.

@codecov-io
Copy link

codecov-io commented Sep 12, 2019

Codecov Report

Merging #4056 into master will decrease coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4056      +/-   ##
==========================================
- Coverage   97.77%   97.72%   -0.05%     
==========================================
  Files          43       43              
  Lines        8760     8763       +3     
  Branches     1373     1374       +1     
==========================================
- Hits         8565     8564       -1     
- Misses         82       85       +3     
- Partials      113      114       +1
Impacted Files Coverage Δ
aiohttp/base_protocol.py 96.92% <ø> (ø) ⬆️
aiohttp/streams.py 97.92% <100%> (ø) ⬆️
aiohttp/helpers.py 97.54% <100%> (ø) ⬆️
aiohttp/test_utils.py 99.67% <100%> (ø) ⬆️
aiohttp/web_fileresponse.py 96.59% <0%> (-1.14%) ⬇️
aiohttp/connector.py 96.93% <0%> (-0.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc39183...d09d203. Read the comment docs.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Sep 15, 2019
@webknjaz webknjaz changed the title Compact python 3.8 Compat python 3.8 Sep 16, 2019
@Hanaasagi
Copy link
Member Author

@Hanaasagi Hanaasagi marked this pull request as ready for review September 16, 2019 10:14
@Hanaasagi Hanaasagi requested a review from asvetlov as a code owner September 16, 2019 10:14
Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.
Please fix my note

@@ -137,7 +137,7 @@ class RequestHandler(BaseProtocol):
'_waiter', '_error_handler', '_task_handler',
'_upgrade', '_payload_parser', '_request_parser',
'_reading_paused', 'logger', 'access_log',
'access_logger', '_close', '_force_close')
'access_logger', '_close', '_force_close', 'handle_request')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks irrelevant.

Copy link
Member Author

@Hanaasagi Hanaasagi Sep 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many tests mock the handle_request(not _handle_request), but I could not find where call the handle_request in aiohttp. Only some docstring mentions it.

RequestHandler handles incoming HTTP request. It reads request line,
request headers and request payload and calls handle_request() method.
By default it always returns with 404 response.

Is it an old interface?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, it is an excellent demonstration of mocks weakness.

handle_request is self._manager.request_handler I guess.
But our mocked tests didn't fail despite the API was changed.

The fix should be done in a separate PR, this not existing yet pull request is a blocker for your work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the asyncio changes, we could not assign a value to handle_request. Actually this block my progress. I need to fix all like

srv.handle_request = handle

change above to

with mock.patch.object(web.RequestHandler, 'handle_request', create=True, new=handle):
    pass

@asvetlov asvetlov merged commit 6dedbca into aio-libs:master Sep 17, 2019
@asvetlov
Copy link
Member

Thanks!

asvetlov pushed a commit that referenced this pull request Sep 17, 2019
(cherry picked from commit 6dedbca)

Co-authored-by: 秋葉 <[email protected]>
webknjaz pushed a commit that referenced this pull request Sep 18, 2019
(cherry picked from commit 6dedbca)

Co-authored-by: 秋葉 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asyncio.coroutine is deprecated in 3.8
3 participants