Message265224
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. |
|
Date |
User |
Action |
Args |
2016-05-10 03:34:33 | mfmain | set | recipients:
+ mfmain, vstinner, ezio.melotti |
2016-05-10 03:34:33 | mfmain | set | messageid: <1462851273.73.0.390821132844.issue26990@psf.upfronthosting.co.za> |
2016-05-10 03:34:33 | mfmain | link | issue26990 messages |
2016-05-10 03:34:32 | mfmain | create | |
|