GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `codecs.StreamReader.read()` silently drops an incomplete character at the end of the stream · Issue #160309 · python/cpython Open Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug description
>>> import codecs, io >>> reader = codecs.getreader('utf-8')(io.BytesIO(b'ab\xe2')) >>> reader.read() 'ab' >>> reader.read() '' Every other way of decoding the same bytes either raises or applies the error handler: >>> b'ab\xe2'.decode('utf-8') Traceback (most recent call last): File "<python-input-3>", line 1, in <module> b'ab\xe2'.decode('utf-8') UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 2: unexpected end of data >>> io.TextIOWrapper(io.BytesIO(b'ab\xe2'), encoding='utf-8').read() Traceback (most recent call last): ... UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 2: unexpected end of data >>> codecs.getreader('utf-8')(io.BytesIO(b'ab\xe2'), 'replace').read() 'ab' >>> b'ab\xe2'.decode('utf-8', 'replace') 'ab�' So with The cause is in I realise This is the same mechanism as #56717 (bpo-12508, 2011), which describes it for UTF-8 with Found by the Hypothesis tests in #160155, where it is pinned as CPython versions tested onCPython main (6e1bd24) Operating systems tested onLinux Linked PRsActivity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |