Tin mới
GitHub CopilotWrite better code with AI
GitHub Copilot appDirect agents from issue to merge
CodespacesInstant dev environments
Code ReviewManage code changes
Code QualityEnforce quality at merge
GitHub Advanced SecurityFind and fix vulnerabilities
Code securitySecure your code as you build
Secret protectionStop leaks before they start
GitHub SponsorsFund open source developers
Copilot for BusinessEnterprise-grade AI features
Premium SupportEnterprise-grade 24/7 support
io.BytesIO does not have peek() #90533
Implement with the help of read_bytes()
Update docs, factor out peek_bytes, semantics
Update Misc/NEWS.d/next/Library/2022-04-10-20-10-59.
Use SemBr Co-authored-by: Erlend E. Aasland <[email protected]>
Apply suggestions from code review
Use a context manager around memio in test_peek
Add more tests for tell() after peek()
Document why size < 0 can happen
Do not update pos if peek_bytes failed
Size can be negative after truncate or seek
Test with size<0 and size>len(buf)
Document BufferedReader.peek and BytesIO.peek similarly
Make it more explicit that size is ignored
Return an empty bytes object for size=0
Learn more about hiding disruptive comments
The reason will be displayed to describe this comment to others. Learn more.