homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Increase coverage of base64
Type: enhancement Stage: patch review
Components: Tests Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, leecannon, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017年05月27日 20:45 by leecannon, last changed 2022年04月11日 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 1837 closed leecannon, 2017年05月27日 20:51
PR 21913 open ZackerySpytz, 2020年08月18日 00:20
Messages (3)
msg294611 - (view) Author: Lee Cannon (leecannon) * Date: 2017年05月27日 20:45
Added tests to ensure a85decode correctly handles the 'y' character within the byte like object when foldspaces is true.
While attempting to increase coverage I found two lines of code within base64.py that appear to never execute:
 - line 472
 - line 501
Line 472:
The only time the TypeError except block (line 467) executes is when _b85dec[c] resolves to None for one of the c (characters) in chunk.
Then within the except block the c (characters) within chunk are iterated through until the None is hit then a ValueError is raised (line 470). Making it impossible for line 472 to execute.
Line 501:
s is assigned a value in the expression `s = input.read(MAXBINSIZE)` (line 494), due to this len(s) is only ever not equal to MAXBINSIZE if the end of input has been reached and nothing was read or the last chunk of data was read from input which has a len less than MAXBINSIZE but non-zero.
Therefore the only way to enter into the while loop (line 497) is if there are no more characters left to be read from input, yet all that happens in the while loop is the read function is called on input with a non zero parameter (`MAXBINSIZE-len(s)` must be greater than zero for the while to have executed) then when it returns nothing (it always will) execution breaks out of the while loop without modifiying s.
msg294614 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017年05月27日 22:06
Please don't change the code of base64. It is correct.
1. Python is a dynamically-typed language. Arbitrary exceptions can be raised in unexpected places. For example TypeError can be raised if `b[i:i + 5]` return non-iterable object.
2. `read(n)` of unbuffered object (like sys.stdin.buffer.raw or socket) can return less than n bytes.
msg294646 - (view) Author: Lee Cannon (leecannon) * Date: 2017年05月28日 13:34
Suggested changes have been applied to the PR.
History
Date User Action Args
2022年04月11日 14:58:47adminsetgithub: 74678
2020年08月18日 00:20:47ZackerySpytzsetkeywords: + patch
nosy: + ZackerySpytz

pull_requests: + pull_request21029
stage: patch review
2017年05月28日 13:34:07leecannonsetmessages: + msg294646
2017年05月27日 22:06:29serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg294614
2017年05月27日 20:51:24leecannonsetpull_requests: + pull_request1921
2017年05月27日 20:45:48leecannoncreate

AltStyle によって変換されたページ (->オリジナル) /