[Checkins] SVN: zc.buildout/branches/tlotze-bugfix-md5/ fixed MD5 calculation under Windows: open files as binary to get their exact content

Thomas Lotze tl at gocept.com
Thu Sep 3 03:18:47 EDT 2009


Log message for revision 103497:
  fixed MD5 calculation under Windows: open files as binary to get their exact content

Changed:
  U   zc.buildout/branches/tlotze-bugfix-md5/CHANGES.txt
  U   zc.buildout/branches/tlotze-bugfix-md5/src/zc/buildout/download.py
  U   zc.buildout/branches/tlotze-bugfix-md5/src/zc/buildout/download.txt

-=-
Modified: zc.buildout/branches/tlotze-bugfix-md5/CHANGES.txt
===================================================================
--- zc.buildout/branches/tlotze-bugfix-md5/CHANGES.txt	2009-09-03 07:17:12 UTC (rev 103496)
+++ zc.buildout/branches/tlotze-bugfix-md5/CHANGES.txt	2009-09-03 07:18:47 UTC (rev 103497)
@@ -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/branches/tlotze-bugfix-md5/src/zc/buildout/download.py
===================================================================
--- zc.buildout/branches/tlotze-bugfix-md5/src/zc/buildout/download.py	2009-09-03 07:17:12 UTC (rev 103496)
+++ zc.buildout/branches/tlotze-bugfix-md5/src/zc/buildout/download.py	2009-09-03 07:18:47 UTC (rev 103497)
@@ -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/branches/tlotze-bugfix-md5/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/branches/tlotze-bugfix-md5/src/zc/buildout/download.txt	2009-09-03 07:17:12 UTC (rev 103496)
+++ zc.buildout/branches/tlotze-bugfix-md5/src/zc/buildout/download.txt	2009-09-03 07:18:47 UTC (rev 103497)
@@ -523,6 +523,19 @@
 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.\nSecond line.\n'
+>>> write(server_data, 'foo.txt', text)
+>>> path, is_temp = Download()(server_url+'foo.txt', md5(text).hexdigest())
+>>> remove(path)
+
+
 Clean up
 --------
 



More information about the checkins mailing list