Fwd: [patch] use hashlib instead of the deprecated md5 module

View: New views
4 Messages — Rating Filter:   Alert me  

Fwd: [patch] use hashlib instead of the deprecated md5 module

by Matthias Klose-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

should have sent this to java-patches in the first place ...

-------- Original Message --------
Subject: [patch] use hashlib instead of the deprecated md5 module
Date: Thu, 23 Jul 2009 09:53:50 -0400
From: Matthias Klose <doko@...>
To: GCC Patches <gcc-patches@...>

use hashlib (if available) instead of the md5 module, which was deprecated in
python2.5. Ok for the trunk and the 4.4 branch?

    Matthias



2009-07-23  Matthias Klose  <doko@...>

        * contrib/aotcompile.py.in: Use hashlib instead of md5 if available.

Index: contrib/aotcompile.py.in
===================================================================
--- contrib/aotcompile.py.in (revision 149997)
+++ contrib/aotcompile.py.in (working copy)
@@ -15,7 +15,11 @@
 
 import classfile
 import copy
-import md5
+# The md5 module is deprecated in Python 2.5
+try:
+    from hashlib import md5
+except ImportError:
+    from md5 import md5
 import operator
 import os
 import sys
@@ -182,7 +186,7 @@
     def addClass(self, bytes, name):
         """Subclasses call this from their __init__ method for
         every class they find."""
-        digest = md5.new(bytes).digest()
+        digest = md5(bytes).digest()
         self.classes[digest] = bytes
         self.classnames[digest] = name
 


Re: Fwd: [patch] use hashlib instead of the deprecated md5 module

by Andrew Haley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 07/23/2009 04:02 PM, Matthias Klose wrote:

> should have sent this to java-patches in the first place ...
>
> -------- Original Message --------
> Subject: [patch] use hashlib instead of the deprecated md5 module
> Date: Thu, 23 Jul 2009 09:53:50 -0400
> From: Matthias Klose <doko@...>
> To: GCC Patches <gcc-patches@...>
>
> use hashlib (if available) instead of the md5 module, which was
> deprecated in
> python2.5. Ok for the trunk and the 4.4 branch?

I see it falls back to using the MD5 module.  This is OK.

Andrew.


Re: Fwd: [patch] use hashlib instead of the deprecated md5 module

by Andrew Haley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 07/23/2009 04:37 PM, Andrew Haley wrote:

> On 07/23/2009 04:02 PM, Matthias Klose wrote:
>> should have sent this to java-patches in the first place ...
>>
>> -------- Original Message --------
>> Subject: [patch] use hashlib instead of the deprecated md5 module
>> Date: Thu, 23 Jul 2009 09:53:50 -0400
>> From: Matthias Klose <doko@...>
>> To: GCC Patches <gcc-patches@...>
>>
>> use hashlib (if available) instead of the md5 module, which was
>> deprecated in
>> python2.5. Ok for the trunk and the 4.4 branch?
>
> I see it falls back to using the MD5 module.  This is OK.

Incidentally, did you test the fallback?  Should be OK, but...

Andrew.

Re: Fwd: [patch] use hashlib instead of the deprecated md5 module

by Matthias Klose-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 23.07.2009 10:38, Andrew Haley wrote:

> On 07/23/2009 04:37 PM, Andrew Haley wrote:
>> On 07/23/2009 04:02 PM, Matthias Klose wrote:
>>> should have sent this to java-patches in the first place ...
>>>
>>> -------- Original Message --------
>>> Subject: [patch] use hashlib instead of the deprecated md5 module
>>> Date: Thu, 23 Jul 2009 09:53:50 -0400
>>> From: Matthias Klose<doko@...>
>>> To: GCC Patches<gcc-patches@...>
>>>
>>> use hashlib (if available) instead of the md5 module, which was
>>> deprecated in
>>> python2.5. Ok for the trunk and the 4.4 branch?
>>
>> I see it falls back to using the MD5 module.  This is OK.
>
> Incidentally, did you test the fallback?  Should be OK, but...

yes, tested with python2.4

   Matthias