Author: Armin Rigo <[email protected]>
Branch:
Changeset: r55004:9690a8b51532
Date: 2012-05-10 08:47 +0200
http://bitbucket.org/pypy/pypy/changeset/9690a8b51532/
Log: merge heads
diff --git a/pypy/module/mmap/test/test_mmap.py
b/pypy/module/mmap/test/test_mmap.py
--- a/pypy/module/mmap/test/test_mmap.py
+++ b/pypy/module/mmap/test/test_mmap.py
@@ -548,6 +548,8 @@
assert len(b) == 6
assert b[3] == "b"
assert b[:] == "foobar"
+ m.close()
+ f.close()
def test_offset(self):
from mmap import mmap, ALLOCATIONGRANULARITY
diff --git a/pypy/module/thread/os_local.py b/pypy/module/thread/os_local.py
--- a/pypy/module/thread/os_local.py
+++ b/pypy/module/thread/os_local.py
@@ -1,4 +1,5 @@
import weakref
+from pypy.rlib import jit
from pypy.interpreter.baseobjspace import Wrappable, W_Root
from pypy.interpreter.executioncontext import ExecutionContext
from pypy.interpreter.typedef import (TypeDef, interp2app, GetSetProperty,
@@ -16,6 +17,7 @@
class Local(Wrappable):
"""Thread-local data"""
+ @jit.dont_look_inside
def __init__(self, space, initargs):
self.initargs = initargs
self.dicts = {} # mapping ExecutionContexts to the wraped dict
@@ -36,26 +38,32 @@
ec._thread_local_objs = WRefShrinkList()
ec._thread_local_objs.append(weakref.ref(self))
+ @jit.dont_look_inside
+ def create_new_dict(self, ec):
+ # create a new dict for this thread
+ space = ec.space
+ w_dict = space.newdict(instance=True)
+ self.dicts[ec] = w_dict
+ # call __init__
+ try:
+ w_self = space.wrap(self)
+ w_type = space.type(w_self)
+ w_init = space.getattr(w_type, space.wrap("__init__"))
+ space.call_obj_args(w_init, w_self, self.initargs)
+ except:
+ # failed, forget w_dict and propagate the exception
+ del self.dicts[ec]
+ raise
+ # ready
+ self._register_in_ec(ec)
+ return w_dict
+
def getdict(self, space):
ec = space.getexecutioncontext()
try:
w_dict = self.dicts[ec]
except KeyError:
- # create a new dict for this thread
- w_dict = space.newdict(instance=True)
- self.dicts[ec] = w_dict
- # call __init__
- try:
- w_self = space.wrap(self)
- w_type = space.type(w_self)
- w_init = space.getattr(w_type, space.wrap("__init__"))
- space.call_obj_args(w_init, w_self, self.initargs)
- except:
- # failed, forget w_dict and propagate the exception
- del self.dicts[ec]
- raise
- # ready
- self._register_in_ec(ec)
+ w_dict = self.create_new_dict(ec)
return w_dict
def descr_local__new__(space, w_subtype, __args__):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit