Raising RuntimeError when trying to get empty body encoding#4481
Merged
asvetlov merged 3 commits intoaio-libs:masterfrom Jan 18, 2020
Merged
Raising RuntimeError when trying to get empty body encoding#4481asvetlov merged 3 commits intoaio-libs:masterfrom
asvetlov merged 3 commits intoaio-libs:masterfrom
Conversation
webknjaz
reviewed
Jan 3, 2020
| Vladimir Shulyak | ||
| Vladimir Zakharov | ||
| Vladyslav Bondar | ||
| Vladyslav Bohaichuk |
webknjaz
reviewed
Jan 3, 2020
docs/client_reference.rst
Outdated
| decode a response. Some encodings detected by cchardet are not known by | ||
| Python (e.g. VISCII). | ||
|
|
||
| :raise RuntimeError: if body hasn't been read for :term:`cchardet` usage |
Member
There was a problem hiding this comment.
Suggested change
| :raise RuntimeError: if body hasn't been read for :term:`cchardet` usage | |
| :raise RuntimeError: if called before the body has been read, for :term:`cchardet` usage |
webknjaz
reviewed
Jan 3, 2020
aiohttp/client_reqrep.py
Outdated
| # RFC 7159 states that the default encoding is UTF-8. | ||
| encoding = 'utf-8' | ||
| elif self._body is None: | ||
| raise RuntimeError("Trying to get encoding of not read body") |
Member
There was a problem hiding this comment.
Suggested change
| raise RuntimeError("Trying to get encoding of not read body") | |
| raise RuntimeError('Cannot guess the encoding of a not yet read body') |
webknjaz
reviewed
Jan 3, 2020
tests/test_client_response.py
Outdated
| content = response.content = mock.Mock() | ||
| content.read.side_effect = side_effect | ||
|
|
||
| with pytest.raises(RuntimeError): |
Member
There was a problem hiding this comment.
Suggested change
| with pytest.raises(RuntimeError): | |
| with pytest.raises( | |
| RuntimeError, | |
| match='^Cannot guess the encoding of a not yet read body$', | |
| ): |
Contributor
Author
There was a problem hiding this comment.
Updated PR, thank's for review
Does it always make sense to check exception message?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4481 +/- ##
=======================================
Coverage 97.51% 97.51%
=======================================
Files 43 43
Lines 8865 8867 +2
Branches 1390 1391 +1
=======================================
+ Hits 8645 8647 +2
Misses 96 96
Partials 124 124 ☔ View full report in Codecov by Sentry. |
Member
|
Thanks! |
asvetlov
pushed a commit
that referenced
this pull request
Jan 18, 2020
) (cherry picked from commit 63a0d10) Co-authored-by: Purusah <[email protected]>
asvetlov
added a commit
that referenced
this pull request
Jan 18, 2020
) (#4512) (cherry picked from commit 63a0d10) Co-authored-by: Purusah <[email protected]> Co-authored-by: Purusah <[email protected]>
asvetlov
pushed a commit
that referenced
this pull request
Oct 16, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Function get_encoding raise RuntimeError when user is trying to read not present body and header doesn't provide info about encoding
Are there changes in behavior for the user?
Make error more verbose
Related issue number
Fixes #4214
Checklist
CONTRIBUTORS.txtCHANGESfolder<issue_id>.<type>for example (588.bugfix)issue_idchange it to the pr id after creating the pr.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.