[pypy-svn] pypy fast-forward: Fix the test: ensure that the context is kept alive long enough to compute the digest.
amauryfa
commits-noreply at bitbucket.org
Wed Jan 12 01:46:27 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40615:84bedb44ae4f
Date: 2011-01-12 01:46 +0100
http://bitbucket.org/pypy/pypy/changeset/84bedb44ae4f/
Log: Fix the test: ensure that the context is kept alive long enough to
compute the digest.
diff --git a/pypy/module/_hashlib/interp_hashlib.py b/pypy/module/_hashlib/interp_hashlib.py
--- a/pypy/module/_hashlib/interp_hashlib.py
+++ b/pypy/module/_hashlib/interp_hashlib.py
@@ -5,6 +5,7 @@
from pypy.tool.sourcetools import func_renamer
from pypy.interpreter.baseobjspace import Wrappable, W_Root, ObjSpace
from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rlib.objectmodel import keepalive_until_here
from pypy.rlib import ropenssl
from pypy.rlib.rstring import StringBuilder
@@ -66,7 +67,8 @@
return space.wrap(self._block_size())
def _digest(self, space):
- ctx = self.copy(space).ctx
+ copy = self.copy(space)
+ ctx = copy.ctx
digest_size = self._digest_size()
digest = lltype.malloc(rffi.CCHARP.TO, digest_size, flavor='raw')
@@ -74,6 +76,7 @@
ropenssl.EVP_DigestFinal(ctx, digest, None)
return rffi.charpsize2str(digest, digest_size)
finally:
+ keepalive_until_here(copy)
lltype.free(digest, flavor='raw')
More information about the Pypy-commit
mailing list