← Back to team overview

divmod-dev team mailing list archive

[Merge] lp:~divmod-dev/divmod.org/fix-deprecation-warnings into lp:divmod.org

 

Tristan Seligmann has proposed merging lp:~divmod-dev/divmod.org/fix-deprecation-warnings into lp:divmod.org.

Requested reviews:
  Divmod-dev (divmod-dev)

For more details, see:
https://code.launchpad.net/~divmod-dev/divmod.org/fix-deprecation-warnings/+merge/68280

There are some deprecation warnings still left over, but those are harder to fix. Also there are some test failures but those fail on trunk too :/
-- 
https://code.launchpad.net/~divmod-dev/divmod.org/fix-deprecation-warnings/+merge/68280
Your team Divmod-dev is requested to review the proposed merge of lp:~divmod-dev/divmod.org/fix-deprecation-warnings into lp:divmod.org.
=== modified file 'Epsilon/epsilon/ampauth.py'
--- Epsilon/epsilon/ampauth.py	2008-11-10 20:26:55 +0000
+++ Epsilon/epsilon/ampauth.py	2011-07-18 16:49:29 +0000
@@ -6,7 +6,7 @@
 L{cred<twisted.cred>}.
 """
 
-from sha import sha
+from hashlib import sha1
 
 from zope.interface import implements
 
@@ -76,7 +76,7 @@
     @rtype: C{str}
     @return: A hash constructed from the three parameters.
     """
-    return sha('%s %s %s' % (challenge, nonce, password)).digest()
+    return sha1('%s %s %s' % (challenge, nonce, password)).digest()
 
 
 

=== modified file 'Epsilon/epsilon/process.py'
--- Epsilon/epsilon/process.py	2009-06-29 14:01:43 +0000
+++ Epsilon/epsilon/process.py	2011-07-18 16:49:29 +0000
@@ -5,7 +5,7 @@
 Process and stdio related functionality.
 """
 
-import os, sys, imp, sets
+import os, sys, imp
 
 from zope.interface import implements
 
@@ -35,7 +35,7 @@
         if p.startswith(os.path.join(sys.prefix, 'lib')):
             continue
         pythonpath.append(p)
-    pythonpath = list(sets.Set(pythonpath))
+    pythonpath = list(set(pythonpath))
     pythonpath.extend(env.get('PYTHONPATH', '').split(os.pathsep))
     env['PYTHONPATH'] = os.pathsep.join(pythonpath)
 

=== modified file 'Epsilon/epsilon/test/test_ampauth.py'
--- Epsilon/epsilon/test/test_ampauth.py	2008-11-10 20:26:55 +0000
+++ Epsilon/epsilon/test/test_ampauth.py	2011-07-18 16:49:29 +0000
@@ -7,7 +7,7 @@
 import epsilon.hotfix
 epsilon.hotfix.require('twisted', 'loopbackasync_reentrancy')
 
-from sha import sha
+from hashlib import sha1
 
 from zope.interface import implements
 from zope.interface.verify import verifyObject
@@ -186,7 +186,7 @@
         challenge = self.server.passwordLogin(self.username)['challenge']
         cnonce = '123abc'
         cleartext = '%s %s %s' % (challenge, cnonce, self.password)
-        response = sha(cleartext).digest()
+        response = sha1(cleartext).digest()
         d = self.server.passwordChallengeResponse(cnonce, response)
         def cbLoggedIn(result):
             self.assertEqual(result, {})

=== modified file 'Mantissa/xmantissa/cachejs.py'
--- Mantissa/xmantissa/cachejs.py	2009-07-08 01:51:14 +0000
+++ Mantissa/xmantissa/cachejs.py	2011-07-18 16:49:29 +0000
@@ -6,7 +6,7 @@
 L{xmantissa.website.MantissaLivePage}.
 """
 
-import sha
+import hashlib
 
 from zope.interface import implements
 
@@ -65,7 +65,7 @@
         if self.wasModified():
             self.lastModified = self.filePath.getmtime()
             self.fileContents = self.filePath.getContent()
-            self.hashValue = sha.new(self.fileContents).hexdigest()
+            self.hashValue = hashlib.sha1(self.fileContents).hexdigest()
 
 
 

=== modified file 'Mantissa/xmantissa/signup.py'
--- Mantissa/xmantissa/signup.py	2008-07-15 21:47:11 +0000
+++ Mantissa/xmantissa/signup.py	2011-07-18 16:49:29 +0000
@@ -1,6 +1,6 @@
 # -*- test-case-name: xmantissa.test.test_signup,xmantissa.test.test_password_reset -*-
 
-import os, rfc822, md5, time, random
+import os, rfc822, hashlib, time, random
 from itertools import chain
 
 from zope.interface import Interface, implements
@@ -225,7 +225,7 @@
         Make a new, probably unique key. This key will be sent in an email to
         the user and is used to access the password change form.
         """
-        return unicode(md5.new(str((usern, time.time(), random.random()))).hexdigest())
+        return unicode(hashlib.md5(str((usern, time.time(), random.random()))).hexdigest())
 
 
     def newAttemptForUser(self, user):

=== modified file 'Mantissa/xmantissa/terminal.py'
--- Mantissa/xmantissa/terminal.py	2009-06-01 16:46:29 +0000
+++ Mantissa/xmantissa/terminal.py	2011-07-18 16:49:29 +0000
@@ -8,7 +8,7 @@
 L{ITerminalServerFactory} powerups to create L{ITerminalProtocol} providers.
 """
 
-from md5 import md5
+from hashlib import md5
 
 from Crypto.PublicKey import RSA
 

=== modified file 'Mantissa/xmantissa/test/test_cachejs.py'
--- Mantissa/xmantissa/test/test_cachejs.py	2009-07-08 01:51:14 +0000
+++ Mantissa/xmantissa/test/test_cachejs.py	2011-07-18 16:49:29 +0000
@@ -1,4 +1,4 @@
-import sha
+from hashlib import sha1
 
 from twisted.trial.unittest import TestCase
 from twisted.python.filepath import FilePath
@@ -61,7 +61,7 @@
         self.moduleProvider.moduleCache[self.MODULE_NAME] = CachedJSModule(
             self.MODULE_NAME, FilePath(self.moduleFile))
         d, segs = self.moduleProvider.locateChild(None,
-                                     [sha.new(self.MODULE_CONTENT).hexdigest(),
+                                     [sha1(self.MODULE_CONTENT).hexdigest(),
                                       self.MODULE_NAME])
         self.assertEqual([], segs)
         d.time = lambda: 12345

=== modified file 'Quotient/xquotient/test/util.py'
--- Quotient/xquotient/test/util.py	2008-02-29 16:19:04 +0000
+++ Quotient/xquotient/test/util.py	2011-07-18 16:49:29 +0000
@@ -78,7 +78,7 @@
         elif major == 'image':
             p = MI.MIMEImage(self.body, minor)
         else:
-            assert (False,
+            raise ValueError(
                     "Must be 'multipart', 'text' or 'image' (got %r)"
                     % (major,))
 

=== modified file 'Sine/sine/sip.py'
--- Sine/sine/sip.py	2008-12-01 23:08:43 +0000
+++ Sine/sine/sip.py	2011-07-18 16:49:29 +0000
@@ -5,7 +5,7 @@
 # telephone. My wish has come true. I no longer know how to use my
 # telephone." - Bjarne Stroustrup
 
-import socket, random, md5, sys, urllib
+import socket, random, hashlib, sys, urllib
 
 from twisted.python import log, util
 from twisted.internet import protocol, defer, reactor, abstract
@@ -129,7 +129,7 @@
     pszNonce,
     pszCNonce,
 ):
-    m = md5.md5()
+    m = hashlib.md5()
     m.update(pszUserName)
     m.update(":")
     m.update(pszRealm)
@@ -137,7 +137,7 @@
     m.update(pszPassword)
     HA1 = m.digest()
     if pszAlg == "md5-sess":
-        m = md5.md5()
+        m = hashlib.md5()
         m.update(HA1)
         m.update(":")
         m.update(pszNonce)
@@ -156,7 +156,7 @@
     pszDigestUri,
     pszHEntity,
 ):
-    m = md5.md5()
+    m = hashlib.md5()
     m.update(pszMethod)
     m.update(":")
     m.update(pszDigestUri)
@@ -165,7 +165,7 @@
         m.update(pszHEntity)
     HA2 = m.digest().encode('hex')
 
-    m = md5.md5()
+    m = hashlib.md5()
     m.update(HA1)
     m.update(":")
     m.update(pszNonce)
@@ -994,7 +994,7 @@
             oldvia = msg.headers['via'][0]
         else:
             oldvia = ''
-        return VIA_COOKIE + md5.new((parseAddress(msg.headers['to'][0])[2].get('tag','') +
+        return VIA_COOKIE + hashlib.md5((parseAddress(msg.headers['to'][0])[2].get('tag','') +
                                     parseAddress(msg.headers['from'][0])[2].get('tag','')+
                                    msg.headers['call-id'][0] +
                                    msg.uri.toString() +
@@ -1626,7 +1626,7 @@
 
         r.addHeader("to", "%s:%s" % (addr))
         # see RFC3261 8.1.1.7, 16.6.8
-        r.addHeader("via", Via(host=self.host, port=self.port, branch=VIA_COOKIE+ md5.new(repr(addr)).hexdigest()).toString())
+        r.addHeader("via", Via(host=self.host, port=self.port, branch=VIA_COOKIE+ hashlib.md5(repr(addr)).hexdigest()).toString())
         self.transport.write(r, addr)
 
     def _fixupNAT(self, message, (srcHost, srcPort)):
@@ -2439,7 +2439,7 @@
         return defer.succeed(True)
 
     def register(self, username, password, domain):
-        self.callid = "%s@%s" % (md5.md5(str(random.random())).hexdigest(),
+        self.callid = "%s@%s" % (hashlib.md5(str(random.random())).hexdigest(),
                                  domain)
         uri = URL(domain, username)
         r = self._makeRegisterMessage(self.callid, domain, uri)
@@ -2475,11 +2475,11 @@
 
     def _getHashingImplementation(self, algorithm):
         #from shtoom.sip
-        import md5, sha
+        import hashlib
         if algorithm.lower() == 'md5':
-            H = lambda x: md5.new(x).hexdigest()
+            H = lambda x: hashlib.md5(x).hexdigest()
         elif algorithm.lower() == 'sha':
-            H = lambda x: sha.new(x).hexdigest()
+            H = lambda x: hashlib.sha1(x).hexdigest()
         # XXX MD5-sess
         KD = lambda s, d, H=H: H("%s:%s" % (s, d))
         return H, KD

=== modified file 'Sine/sine/useragent.py'
--- Sine/sine/useragent.py	2008-11-06 01:33:02 +0000
+++ Sine/sine/useragent.py	2011-07-18 16:49:29 +0000
@@ -16,7 +16,7 @@
 from twisted.python import log
 from axiom import batch
 from axiom.errors import NoSuchUser
-import random, wave, md5
+import random, wave, hashlib
 from zope.interface import Interface, implements
 from epsilon import juice
 
@@ -378,7 +378,7 @@
         invite.addHeader("to", formatAddress(uri))
         invite.addHeader("from", formatAddress((fromName, URL(contacturi.host, contacturi.username), {'tag': self.genTag()})))
         invite.addHeader("call-id",
-                         "%s@%s" % (md5.md5(str(random.random())).hexdigest(),
+                         "%s@%s" % (hashlib.md5(str(random.random())).hexdigest(),
                                     contacturi.host))
         invite.addHeader("cseq", "%s INVITE" % self.localCSeq)
         invite.addHeader("user-agent", "Divmod Sine")

=== modified file 'Sine/xshtoom/digestauth.py'
--- Sine/xshtoom/digestauth.py	2006-01-06 01:27:48 +0000
+++ Sine/xshtoom/digestauth.py	2011-07-18 16:49:29 +0000
@@ -1,11 +1,11 @@
-import md5, sha, time, random
+import hashlib, time, random
 
 
 def generate_nonce(bits, randomness=None):
     "This could be stronger"
     if bits%8 != 0:
         raise ValueError, "bits must be a multiple of 8"
-    nonce = sha.new(str(randomness) + str(time.time()) +
+    nonce = hashlib.sha1(str(randomness) + str(time.time()) +
             str(random.random()) ).hexdigest()
     nonce = nonce[:bits/4]
     return nonce
@@ -34,9 +34,9 @@
         if algorithm is None:
             algorithm = self.algorithm
         if algorithm == 'MD5':
-            H = lambda x: md5.new(x).hexdigest()
+            H = lambda x: hashlib.md5(x).hexdigest()
         elif algorithm == 'SHA':
-            H = lambda x: sha.new(x).hexdigest()
+            H = lambda x: hashlib.sha1(x).hexdigest()
         # XXX MD5-sess
         KD = lambda s, d, H=H: H("%s:%s" % (s, d))
         return H, KD

=== modified file 'Sine/xshtoom/rtp/protocol.py'
--- Sine/xshtoom/rtp/protocol.py	2006-04-14 20:18:55 +0000
+++ Sine/xshtoom/rtp/protocol.py	2011-07-18 16:49:29 +0000
@@ -3,7 +3,7 @@
 # $Id: rtp.py,v 1.40 2004/03/07 14:41:39 anthony Exp $
 #
 
-import random, os, md5, socket
+import random, os, hashlib, socket
 from time import time
 
 from twisted.internet import reactor, defer
@@ -327,7 +327,7 @@
 
     def genSSRC(self):
         # Python-ish hack at RFC1889, Appendix A.6
-        m = md5.new()
+        m = hashlib.md5()
         m.update(str(time()))
         m.update(str(id(self)))
         if hasattr(os, 'getuid'):
@@ -344,7 +344,7 @@
 
     def genInitTS(self):
         # Python-ish hack at RFC1889, Appendix A.6
-        m = md5.new()
+        m = hashlib.md5()
         m.update(str(self.genSSRC()))
         m.update(str(time()))
         hex = m.hexdigest()
@@ -367,7 +367,7 @@
         if os.path.exists("/dev/urandom"):
             hex = open('/dev/urandom').read(16).encode("hex")
         else:
-            m = md5.new()
+            m = hashlib.md5()
             m.update(str(time()))
             m.update(str(random.random()))
             m.update(str(id(self.dest)))

=== modified file 'Vertex/vertex/q2q.py'
--- Vertex/vertex/q2q.py	2009-07-06 11:40:18 +0000
+++ Vertex/vertex/q2q.py	2011-07-18 16:49:29 +0000
@@ -7,7 +7,7 @@
 
 # stdlib
 import itertools
-import md5
+from hashlib import md5
 import struct
 
 from pprint import pformat
@@ -1974,7 +1974,7 @@
 
 
     def genSerial(self, name):
-        return abs(struct.unpack('!i', md5.md5(name).digest()[:4])[0])
+        return abs(struct.unpack('!i', md5(name).digest()[:4])[0])
 
     def addPrivateCertificate(self, subjectName, existingCertificate=None):
         """


Follow ups