piranna / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

ZipFS inserts extra '\r' characters to binary files on Windows #109

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the attached test case under Windows

What is the expected output?
The unit test passes. This happens on Linux.

What do you see instead?
The unit test fails with:
AssertionError: ' \r\n' != ' \n'

(writing binary file on ZipFS has inserted extra '\r' character)

What version of the product are you using? On what operating system?
fs-0.4.0.1-py2.6.egg, Windows 7 64-bit

Original issue reported on code.google.com by make...@gmail.com on 30 Jan 2012 at 2:41

Attachments:

GoogleCodeExporter commented 9 years ago
Forgot to add, that I tested Python 2.6 zipfile module functionality with 
similar test case and it seems to work ok - no line ending conversion happening.

Original comment by make...@gmail.com on 30 Jan 2012 at 2:43

GoogleCodeExporter commented 9 years ago
Ah, simple patch like this fixes the issue:

diff -Naur fs-0.4.0.1-py2.6.egg/fs/zipfs.py fs-0.4.0.1-py2.6.new/fs/zipfs.py
--- fs-0.4.0.1-py2.6.egg/fs/zipfs.py    2012-01-30 10:20:00.368608813 +0200
+++ fs-0.4.0.1-py2.6.new/fs/zipfs.py    2012-01-30 16:51:51.000000000 +0200
@@ -37,7 +37,7 @@
     def __init__(self, fs, filename, close_callback):
         self.fs = fs
         self.filename = filename
-        self._file = self.fs.open(filename, 'w+')
+        self._file = self.fs.open(filename, 'wb+')
         self.close_callback = close_callback

     def write(self, data):

Original comment by make...@gmail.com on 30 Jan 2012 at 2:54

GoogleCodeExporter commented 9 years ago
That looks as though it has already been fixed in trunk. Have added your test 
though. Thanks.

Original comment by willmcgugan on 30 Jan 2012 at 3:13

GoogleCodeExporter commented 9 years ago
It was fixed here :)
http://code.google.com/p/pyfilesystem/issues/detail?id=80

Original comment by gc...@loowis.durge.org on 30 Jan 2012 at 3:19