[omd-commits] OMD Git: omd: mod_python: Fix several DeprecationWarning messages when using python 2.6

git version control git at mathias-kettner.de
Fri Dec 30 01:17:47 CET 2011


Module:   omd
Branch:   master
Commit:   71693c0d41d1f94626b3726d62b2e600ef8a52cd
URL:      http://omdistro.org/projects/omd/repository/revisions/71693c0d41d1f94626b3726d62b2e600ef8a52cd

Author:   Lars Michelsen <lm at mathias-kettner.de>
Date:     Fri Dec 30 01:16:47 2011 +0100
Commiter: Lars Michelsen <lm at mathias-kettner.de>
Date:     Fri Dec 30 01:16:47 2011 +0100

mod_python: Fix several DeprecationWarning messages when using python 2.6

This is untested at the moment. Waiting for the next nighlty until
testing this

---

 Changelog                                          |    4 ++-
 packages/mod_python/.f12                           |    2 +-
 .../patches/0006-hashlib-instead-of-md5.dif        |   23 ++++++++++++++++++++
 .../patches/0007-prevent-str-init-warning.dif      |   14 ++++++++++++
 packages/mod_python/patches/README                 |   15 +++++++++++++
 5 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index c0f9613..f33eae6 100644
--- a/Changelog
+++ b/Changelog
@@ -2,7 +2,9 @@ This file documents the revision history for the Open Monitoring Distribution
 0.54
           - omd:
 	    - FIX: Fixed "omd umount" command when running without specific site
-          - mod_python: Fix "omd stop apache", which was sometimes timing out
+          - mod_python:
+	    - Fix "omd stop apache", which was sometimes timing out
+	    - Fix several DeprecationWarning messages when using python 2.6
           - NagVis: Updated to NagVis 1.6.2
 
 0.52     Dec 22 2011
diff --git a/packages/mod_python/.f12 b/packages/mod_python/.f12
index 076548d..58879d8 100644
--- a/packages/mod_python/.f12
+++ b/packages/mod_python/.f12
@@ -1,6 +1,6 @@
 #!/bin/bash
 
 echo '#define OMD_VERSION "$(omd versions | grep default | cut -d' ' -f1)"' > mod_python-*/src/omd_version.h
-$(MAKE) -C mod_python-* clean all
+make -C mod_python-* clean all
 
 make install OMD_ROOT=/omd/versions/default
diff --git a/packages/mod_python/patches/0006-hashlib-instead-of-md5.dif b/packages/mod_python/patches/0006-hashlib-instead-of-md5.dif
new file mode 100644
index 0000000..a5b6a31
--- /dev/null
+++ b/packages/mod_python/patches/0006-hashlib-instead-of-md5.dif
@@ -0,0 +1,23 @@
+--- mod_python-3.3.1/lib/python/mod_python/importer.py
++++ mod_python-3.3.1/lib/python/mod_python/importer.py
+@@ -29,7 +29,10 @@ import new
+ import types
+ import pdb
+ import imp
+-import md5
++try:
++    from hashlib import md5
++except ImportError:
++    from md5 import md5
+ import time
+ import string
+ import StringIO
+@@ -969,7 +972,7 @@ class _ModuleCache:
+         # name which is a filesystem path. Hope MD5 hex
+         # digest is okay.
+ 
+-        return self._prefix + md5.new(file).hexdigest()
++        return self._prefix + md5(file).hexdigest()
+ 
+ 
+ _global_modules_cache = _ModuleCache()
diff --git a/packages/mod_python/patches/0007-prevent-str-init-warning.dif b/packages/mod_python/patches/0007-prevent-str-init-warning.dif
new file mode 100644
index 0000000..91d5cfd
--- /dev/null
+++ b/packages/mod_python/patches/0007-prevent-str-init-warning.dif
@@ -0,0 +1,14 @@
+diff -Nur mod_python-3.3.1.orig/lib/python/mod_python/util.py mod_python-3.3.1/lib/python/mod_python/util.py
+--- mod_python-3.3.1.orig/lib/python/mod_python/util.py	2011-12-30 00:53:57.298287822 +0100
++++ mod_python-3.3.1/lib/python/mod_python/util.py	2011-12-30 01:08:52.474726752 +0100
+@@ -116,7 +116,9 @@
+     # cannot subclass str with a constructor that takes >1 argument)
+     def __init__(self, value):
+         '''Create StringField instance. You'll have to set name yourself.'''
+-        str.__init__(self, value)
++        # This call produces a warning message in at least python 2.6. There seems
++        # to be no real reason to call str.__init__ - so skip it!
++        #str.__init__(self, value)
+         self.value = value
+ 
+     def __getattr__(self, name):
diff --git a/packages/mod_python/patches/README b/packages/mod_python/patches/README
index 0facb9d..1385f01 100644
--- a/packages/mod_python/patches/README
+++ b/packages/mod_python/patches/README
@@ -8,6 +8,21 @@
     ignores the signal until the Python interpreter has exited and
     simply exit the process afterwards.
 
+0006:
+    Stop using the deprecated md5 module. Use hashlib instead.
+    This prevents a deprecation warning exception visible in apache
+    error log.
+    Patch: https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=526062
+
+0007:
+    Prevents a deprecation warning:
+
+    lib/python/mod_python/util.py:119: DeprecationWarning: object.__init__() takes no parameters
+    str.__init__(self, value)
+
+    After my tests & searches the str.__init__(self, value) is useless and
+    can simply be commented out.
+
 The other patches are taken with thanks from the FEDORA mod_python
 package and fix compile problems and RedHat 6.1 (and probably
 other distros as well).



More information about the omd-commits mailing list