Author: Armin Rigo <[email protected]>
Branch: use-gc-del-3
Changeset: r84247:ec939870c9dc
Date: 2016-05-06 09:02 +0200
http://bitbucket.org/pypy/pypy/changeset/ec939870c9dc/
Log: Fix _hashlib
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
@@ -65,7 +65,8 @@
# and use a custom lock only when needed.
self.lock = Lock(space)
- ctx = lltype.malloc(ropenssl.EVP_MD_CTX.TO, flavor='raw')
+ ctx = lltype.malloc(ropenssl.EVP_MD_CTX.TO, flavor='raw',
+ track_allocation=False)
rgc.add_memory_pressure(ropenssl.HASH_MALLOC_SIZE + self.digest_size)
try:
if copy_from:
@@ -74,13 +75,16 @@
ropenssl.EVP_DigestInit(ctx, digest_type)
self.ctx = ctx
except:
- lltype.free(ctx, flavor='raw')
+ lltype.free(ctx, flavor='raw', track_allocation=False)
raise
+ self.register_finalizer(space)
- def __del__(self):
- if self.ctx:
- ropenssl.EVP_MD_CTX_cleanup(self.ctx)
- lltype.free(self.ctx, flavor='raw')
+ def _finalize_(self):
+ ctx = self.ctx
+ if ctx:
+ self.ctx = lltype.nullptr(ropenssl.EVP_MD_CTX.TO)
+ ropenssl.EVP_MD_CTX_cleanup(ctx)
+ lltype.free(ctx, flavor='raw', track_allocation=False)
def digest_type_by_name(self, space):
digest_type = ropenssl.EVP_get_digestbyname(self.name)
diff --git a/rpython/annotator/classdesc.py b/rpython/annotator/classdesc.py
--- a/rpython/annotator/classdesc.py
+++ b/rpython/annotator/classdesc.py
@@ -584,8 +584,8 @@
not getattr(cls.__del__, '_must_be_light_finalizer_', False)):
raise AnnotatorError(
"Class %r is in a class hierarchy with "
- "_must_be_light_finalizer_ = True, but it has a "
- "destructor without @rgc.must_be_light_finalizer" % (cls,))
+ "_must_be_light_finalizer_ = True: it cannot have a "
+ "finalizer without @rgc.must_be_light_finalizer" % (cls,))
def add_source_attribute(self, name, value, mixin=False):
if isinstance(value, property):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit