[Checkins] SVN: zope.app.security/trunk/ Don't load security declarations for `sha` and `md5` modules on Python 2.6, as they were deprecated there. This is done pretty the same way, like the check for Python 2.5

Dan Korostelev nadako at gmail.com
Wed Mar 4 19:03:53 EST 2009


Log message for revision 97503:
  Don't load security declarations for `sha` and `md5` modules on Python 2.6, as they were deprecated there. This is done pretty the same way, like the check for Python 2.5
  for excluding `gopherlib` in previous releases. However, it's quite an ugly way, it
  works and anyway, modules behind security proxies are not used much, so I believe that
  it's okay. :-)

Changed:
  U   zope.app.security/trunk/CHANGES.txt
  U   zope.app.security/trunk/src/zope/app/security/globalmodules.zcml

-=-
Modified: zope.app.security/trunk/CHANGES.txt
===================================================================
--- zope.app.security/trunk/CHANGES.txt	2009-03-05 00:03:16 UTC (rev 97502)
+++ zope.app.security/trunk/CHANGES.txt	2009-03-05 00:03:53 UTC (rev 97503)
@@ -5,6 +5,14 @@
 3.6.1 (unreleased)
 ------------------
 
+- Bug: The `sha` and `md5` modules has been deprecated in Python 2.6.
+  Whenever the ZCML of this package was included when using Python 2.6,
+  a deprecation warning had been raised stating that `md5` and `sha` have
+  been deprecated. Provided a simple condition to check whether Python 2.6
+  or later is installed by checking for the presense of `json` module
+  thas was added only in Python 2.6 and thus optionally load the security
+  declaration for `md5` and `sha`.
+
 - Remove deprecated code, thus removing explicit dependency on
   zope.deprecation and zope.deferredimport.
 

Modified: zope.app.security/trunk/src/zope/app/security/globalmodules.zcml
===================================================================
--- zope.app.security/trunk/src/zope/app/security/globalmodules.zcml	2009-03-05 00:03:16 UTC (rev 97502)
+++ zope.app.security/trunk/src/zope/app/security/globalmodules.zcml	2009-03-05 00:03:53 UTC (rev 97503)
@@ -418,11 +418,16 @@
     <allow attributes="new" />
   </module>
 
-  <module module="md5">
+  <!-- These packages has been deprecated in Python 2.6 in favor of hashlib;
+       let's use a cheap way of detecting Python<=2.5 by checking whether the
+       package "json" is not available, which has been added only in Python 2.6. -->
+  <module module="md5"
+          zcml:condition="not-installed json">
     <allow attributes="new digest_size" />
   </module>
 
-  <module module="sha">
+  <module module="sha"
+          zcml:condition="not-installed json">
     <allow attributes="new blocksize digest_size" />
   </module>
 



More information about the Checkins mailing list