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.

Author mfmain
Recipients ezio.melotti, mfmain, vstinner
Date 2016-05-10.03:34:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1462851273.73.0.390821132844.issue26990@psf.upfronthosting.co.za>
In-reply-to
Content
C:\tmp>hexdump badtell.txt

    000000: 61 20 6B 0D 0A D2 BB B0-E3                       a k......

C:\tmp>type test.py

    with open(r'c:\tmp\badtell.txt', "r", encoding='gbk') as f:
        while True:
            pos = f.tell()
            line = f.readline();
            if not line: break
            print(line)

C:\tmp>python test.py

    a k
    
    Traceback (most recent call last):
      File "test.py", line 4, in <module>
        line = f.readline();
    UnicodeDecodeError: 'gbk' codec can't decode byte 0xd2 in position 0:  incomplete multibyte sequence


When I remove f.tell() statement, it decoded successfully.
I tried python3.4/3.5 x64 on win7/win10, it is all the same.
History
Date User Action Args
2016-05-10 03:34:33mfmainsetrecipients: + mfmain, vstinner, ezio.melotti
2016-05-10 03:34:33mfmainsetmessageid: <1462851273.73.0.390821132844.issue26990@psf.upfronthosting.co.za>
2016-05-10 03:34:33mfmainlinkissue26990 messages
2016-05-10 03:34:32mfmaincreate