[Checkins] SVN: zc.buildout/trunk/ fixed: The download API computed MD5 checksums of text files wrong on Windows.

Thomas Lotze tl at gocept.com
Tue Sep 15 07:59:38 EDT 2009


Log message for revision 104041:
  fixed: The download API computed MD5 checksums of text files wrong on Windows.

Changed:
  U   zc.buildout/trunk/CHANGES.txt
  U   zc.buildout/trunk/src/zc/buildout/download.py
  U   zc.buildout/trunk/src/zc/buildout/download.txt

-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt	2009-09-15 11:57:38 UTC (rev 104040)
+++ zc.buildout/trunk/CHANGES.txt	2009-09-15 11:59:38 UTC (rev 104041)
@@ -9,6 +9,8 @@
 - Incrementing didn't work properly when extending multiple files.
   https://bugs.launchpad.net/zc.buildout/+bug/421022
 
+- The download API computed MD5 checksums of text files wrong on Windows.
+
 1.4.1 (2009-08-27)
 ==================
 

Modified: zc.buildout/trunk/src/zc/buildout/download.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/download.py	2009-09-15 11:57:38 UTC (rev 104040)
+++ zc.buildout/trunk/src/zc/buildout/download.py	2009-09-15 11:59:38 UTC (rev 104041)
@@ -223,7 +223,7 @@
     if md5sum is None:
         return True
 
-    f = open(path)
+    f = open(path, 'rb')
     checksum = md5()
     try:
         chunk = f.read(2**16)

Modified: zc.buildout/trunk/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/download.txt	2009-09-15 11:57:38 UTC (rev 104040)
+++ zc.buildout/trunk/src/zc/buildout/download.txt	2009-09-15 11:59:38 UTC (rev 104041)
@@ -523,6 +523,21 @@
 True
 
 
+Regressions
+-----------
+
+MD5 checksum calculation needs to be reliable on all supported systems, which
+requires text files to be treated as binary to avoid implicit line-ending
+conversions:
+
+>>> text = 'First line of text.\r\nSecond line.\r\n'
+>>> f = open(join(server_data, 'foo.txt'), 'wb')
+>>> f.write(text)
+>>> f.close()
+>>> path, is_temp = Download()(server_url+'foo.txt', md5(text).hexdigest())
+>>> remove(path)
+
+
 Clean up
 --------
 



More information about the checkins mailing list