Hi ironpython,

Here's your Daily Digest of new issues for project "IronPython".

In today's digest:ISSUES

1. [New issue] reading a file using codecs can fail
2. [New comment] reading a file using codecs can fail

----------------------------------------------

ISSUES

1. [New issue] reading a file using codecs can fail
http://ironpython.codeplex.com/workitem/34951
User paweljasinski has proposed the issue:

"the following will fail given attached file:
import codecs

lines = []
with codecs.open("text-utf8-with-bom.txt", encoding="utf-8-sig") as file_obj:
    for line in file_obj: # fails here
        lines.append(line)

exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\IronPython 2.7\Lib\encodings\utf_8_sig.py", line 
100, in decode
  File "decode-bug.py", line 5, in <module>
  File "C:\Program Files (x86)\IronPython 2.7\Lib\codecs.py", line 684, in next
  File "C:\Program Files (x86)\IronPython 2.7\Lib\codecs.py", line 615, in next
  File "C:\Program Files (x86)\IronPython 2.7\Lib\codecs.py", line 530, in 
readline
  File "C:\Program Files (x86)\IronPython 2.7\Lib\codecs.py", line 477, in read
UnicodeEncodeError: ('unknown', '\x00', 0, 1, 'failed to decode bytes at index 
65')

It will not fail on linux/cpython.
Removing one character from the first line of text-utf8-with-bom.txt file will 
make it work."-----------------

2. [New comment] reading a file using codecs can fail
http://ironpython.codeplex.com/workitem/34951
User paweljasinski has commented on the issue:

"<p>a better test:<br>```<br>import 
codecs</p><p>f=open(&quot;text-utf8-with-bom.txt&quot;, 
&quot;rb&quot;)<br>b=f.read()<br>codecs.utf_8_decode(b)</p><p># remove last 
character of the file (0x0d)<br>b=b[:-1]<br>print 
codecs.utf_8_decode(b)[1]</p><p># remove last character of euro code 
(0x0c)<br>b=b[:-1]<br>print 
codecs.utf_8_decode(b)[1]</p><p>```<br>produces:<br>```<br>70<br>Traceback 
(most recent call last):<br>  File &quot;d2_test.py&quot;, line 13, in 
&lt;module&gt;<br>UnicodeEncodeError: ('unknown', '\x00', 0, 1, 'failed to 
decode bytes at index 65')<br>```<br>where on linux/cpython it 
is:<br>73<br>70</p><p></p>"
----------------------------------------------



----------------------------------------------
You are receiving this email because you subscribed to notifications on 
CodePlex.

To report a bug, request a feature, or add a comment, visit IronPython Issue 
Tracker. You can unsubscribe or change your issue notification settings on 
CodePlex.com.
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
https://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to