[pypy-svn] r46970 - in pypy/dist/pypy: module/md5 rlib
arigo at codespeak.net
arigo at codespeak.net
Thu Sep 27 18:57:19 CEST 2007
Author: arigo
Date: Thu Sep 27 18:57:19 2007
New Revision: 46970
Modified:
pypy/dist/pypy/module/md5/interp_md5.py
pypy/dist/pypy/rlib/rmd5.py
Log:
fix: RMD5.copy() returned a RMD5 instance instead of a W_MD5 one.
Modified: pypy/dist/pypy/module/md5/interp_md5.py
==============================================================================
--- pypy/dist/pypy/module/md5/interp_md5.py (original)
+++ pypy/dist/pypy/module/md5/interp_md5.py Thu Sep 27 18:57:19 2007
@@ -9,10 +9,9 @@
A subclass of RMD5 that can be exposed to app-level.
"""
- def __init__(self, space, initialdata=''):
+ def __init__(self, space):
self.space = space
self._init()
- self.update(initialdata)
def update_w(self, string):
self.update(string)
@@ -24,7 +23,9 @@
return self.space.wrap(self.hexdigest())
def copy_w(self):
- return self.space.wrap(self.copy())
+ clone = W_MD5(self.space)
+ clone._copyfrom(self)
+ return self.space.wrap(clone)
def W_MD5___new__(space, w_subtype, initialdata=''):
@@ -33,7 +34,8 @@
"""
w_md5 = space.allocate_instance(W_MD5, w_subtype)
md5 = space.interp_w(W_MD5, w_md5)
- W_MD5.__init__(md5, space, initialdata)
+ W_MD5.__init__(md5, space)
+ md5.update(initialdata)
return w_md5
Modified: pypy/dist/pypy/rlib/rmd5.py
==============================================================================
--- pypy/dist/pypy/rlib/rmd5.py (original)
+++ pypy/dist/pypy/rlib/rmd5.py Thu Sep 27 18:57:19 2007
@@ -352,14 +352,18 @@
a common initial substring.
"""
clone = RMD5()
- clone.count = self.count
- clone.input = self.input
- clone.A = self.A
- clone.B = self.B
- clone.C = self.C
- clone.D = self.D
+ clone._copyfrom(self)
return clone
+ def _copyfrom(self, other):
+ """Copy all state from 'other' into 'self'.
+ """
+ self.count = other.count
+ self.input = other.input
+ self.A = other.A
+ self.B = other.B
+ self.C = other.C
+ self.D = other.D
# synonyms to build new RMD5 objects, for compatibility with the
# CPython md5 module interface.
More information about the Pypy-commit
mailing list