[pypy-commit] pypy default: Merged pypy/pypy into default
jiaaro
noreply at buildbot.pypy.org
Tue Feb 18 19:34:27 CET 2014
Author: James Robert <jim.mixtake at gmail.com>
Branch:
Changeset: r69204:98186a76751e
Date: 2014-01-23 20:11 -0500
http://bitbucket.org/pypy/pypy/changeset/98186a76751e/
Log: Merged pypy/pypy into default
diff --git a/pypy/interpreter/pyparser/test/test_parsestring.py b/pypy/interpreter/pyparser/test/test_parsestring.py
--- a/pypy/interpreter/pyparser/test/test_parsestring.py
+++ b/pypy/interpreter/pyparser/test/test_parsestring.py
@@ -2,9 +2,9 @@
import py, sys
class TestParsetring:
- def parse_and_compare(self, literal, value):
+ def parse_and_compare(self, literal, value, encoding=None):
space = self.space
- w_ret = parsestring.parsestr(space, None, literal)
+ w_ret = parsestring.parsestr(space, encoding, literal)
if isinstance(value, str):
assert space.type(w_ret) == space.w_str
assert space.str_w(w_ret) == value
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -400,16 +400,16 @@
'_PyObject_CallFunction_SizeT', '_PyObject_CallMethod_SizeT',
'PyBuffer_FromMemory', 'PyBuffer_FromReadWriteMemory', 'PyBuffer_FromObject',
- 'PyBuffer_FromReadWriteObject', 'PyBuffer_New', 'PyBuffer_Type', '_Py_init_bufferobject',
+ 'PyBuffer_FromReadWriteObject', 'PyBuffer_New', 'PyBuffer_Type', '_Py_get_buffer_type',
'PyCObject_FromVoidPtr', 'PyCObject_FromVoidPtrAndDesc', 'PyCObject_AsVoidPtr',
'PyCObject_GetDesc', 'PyCObject_Import', 'PyCObject_SetVoidPtr',
- 'PyCObject_Type', '_Py_init_pycobject',
+ 'PyCObject_Type', '_Py_get_cobject_type',
'PyCapsule_New', 'PyCapsule_IsValid', 'PyCapsule_GetPointer',
'PyCapsule_GetName', 'PyCapsule_GetDestructor', 'PyCapsule_GetContext',
'PyCapsule_SetPointer', 'PyCapsule_SetName', 'PyCapsule_SetDestructor',
- 'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type', '_Py_init_capsule',
+ 'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type', '_Py_get_capsule_type',
'PyObject_AsReadBuffer', 'PyObject_AsWriteBuffer', 'PyObject_CheckReadBuffer',
@@ -691,17 +691,25 @@
prefix = 'PyPy'
else:
prefix = 'cpyexttest'
- init_buffer = rffi.llexternal('_%s_init_bufferobject' % prefix, [], lltype.Void,
- compilation_info=eci, releasegil=False)
- init_pycobject = rffi.llexternal('_%s_init_pycobject' % prefix, [], lltype.Void,
- compilation_info=eci, releasegil=False)
- init_capsule = rffi.llexternal('_%s_init_capsule' % prefix, [], lltype.Void,
- compilation_info=eci, releasegil=False)
- INIT_FUNCTIONS.extend([
- lambda space: init_buffer(),
- lambda space: init_pycobject(),
- lambda space: init_capsule(),
- ])
+ # jump through hoops to avoid releasing the GIL during initialization
+ # of the cpyext module. The C functions are called with no wrapper,
+ # but must not do anything like calling back PyType_Ready(). We
+ # use them just to get a pointer to the PyTypeObjects defined in C.
+ get_buffer_type = rffi.llexternal('_%s_get_buffer_type' % prefix,
+ [], PyTypeObjectPtr,
+ compilation_info=eci, _nowrapper=True)
+ get_cobject_type = rffi.llexternal('_%s_get_cobject_type' % prefix,
+ [], PyTypeObjectPtr,
+ compilation_info=eci, _nowrapper=True)
+ get_capsule_type = rffi.llexternal('_%s_get_capsule_type' % prefix,
+ [], PyTypeObjectPtr,
+ compilation_info=eci, _nowrapper=True)
+ def init_types(space):
+ from pypy.module.cpyext.typeobject import py_type_ready
+ py_type_ready(space, get_buffer_type())
+ py_type_ready(space, get_cobject_type())
+ py_type_ready(space, get_capsule_type())
+ INIT_FUNCTIONS.append(init_types)
from pypy.module.posix.interp_posix import add_fork_hook
reinit_tls = rffi.llexternal('%sThread_ReInitTLS' % prefix, [], lltype.Void,
compilation_info=eci)
diff --git a/pypy/module/cpyext/src/bufferobject.c b/pypy/module/cpyext/src/bufferobject.c
--- a/pypy/module/cpyext/src/bufferobject.c
+++ b/pypy/module/cpyext/src/bufferobject.c
@@ -783,9 +783,9 @@
return size;
}
-void _Py_init_bufferobject(void)
+PyTypeObject *_Py_get_buffer_type(void)
{
- PyType_Ready(&PyBuffer_Type);
+ return &PyBuffer_Type;
}
static PySequenceMethods buffer_as_sequence = {
diff --git a/pypy/module/cpyext/src/capsule.c b/pypy/module/cpyext/src/capsule.c
--- a/pypy/module/cpyext/src/capsule.c
+++ b/pypy/module/cpyext/src/capsule.c
@@ -321,8 +321,7 @@
PyCapsule_Type__doc__ /*tp_doc*/
};
-void _Py_init_capsule()
+PyTypeObject *_Py_get_capsule_type(void)
{
- PyType_Ready(&PyCapsule_Type);
+ return &PyCapsule_Type;
}
-
diff --git a/pypy/module/cpyext/src/cobject.c b/pypy/module/cpyext/src/cobject.c
--- a/pypy/module/cpyext/src/cobject.c
+++ b/pypy/module/cpyext/src/cobject.c
@@ -156,7 +156,7 @@
PyCObject_Type__doc__ /*tp_doc*/
};
-void _Py_init_pycobject()
+PyTypeObject *_Py_get_cobject_type(void)
{
- PyType_Ready(&PyCObject_Type);
+ return &PyCObject_Type;
}
diff --git a/pypy/module/cpyext/test/test_ztranslation.py b/pypy/module/cpyext/test/test_ztranslation.py
--- a/pypy/module/cpyext/test/test_ztranslation.py
+++ b/pypy/module/cpyext/test/test_ztranslation.py
@@ -1,4 +1,4 @@
from pypy.objspace.fake.checkmodule import checkmodule
def test_cpyext_translates():
- checkmodule('cpyext')
+ checkmodule('cpyext', '_rawffi')
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -549,11 +549,14 @@
pto.c_tp_flags |= Py_TPFLAGS_READY
return pto
+def py_type_ready(space, pto):
+ if pto.c_tp_flags & Py_TPFLAGS_READY:
+ return
+ type_realize(space, rffi.cast(PyObject, pto))
+
@cpython_api([PyTypeObjectPtr], rffi.INT_real, error=-1)
def PyType_Ready(space, pto):
- if pto.c_tp_flags & Py_TPFLAGS_READY:
- return 0
- type_realize(space, rffi.cast(PyObject, pto))
+ py_type_ready(space, pto)
return 0
def type_realize(space, py_obj):
diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -98,7 +98,8 @@
modname == '__builtin__.functional' or
modname == '__builtin__.descriptor' or
modname == 'thread.os_local' or
- modname == 'thread.os_thread'):
+ modname == 'thread.os_thread' or
+ modname.startswith('_rawffi.alt')):
return True
if '.' in modname:
modname, rest = modname.split('.', 1)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_weakref.py b/pypy/module/pypyjit/test_pypy_c/test_weakref.py
--- a/pypy/module/pypyjit/test_pypy_c/test_weakref.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_weakref.py
@@ -30,13 +30,13 @@
guard_not_invalidated(descr=...)
p64 = getfield_gc(ConstPtr(ptr40), descr=<FieldP pypy.objspace.std.dictmultiobject.W_DictMultiObject.inst_strategy \d+>)
guard_value(p64, ConstPtr(ptr42), descr=...)
- p65 = getfield_gc(p14, descr=<FieldP pypy.objspace.std.mapdict.W_ObjectObjectSize5.inst_map 48>)
+ p65 = getfield_gc(p14, descr=<FieldP pypy.objspace.std.mapdict.W_ObjectObjectSize5.inst_map \d+>)
guard_value(p65, ConstPtr(ptr45), descr=...)
p66 = getfield_gc(p14, descr=<FieldP pypy.objspace.std.mapdict.W_ObjectObjectSize5.inst__value0 \d+>)
guard_nonnull_class(p66, ..., descr=...)
p67 = force_token()
setfield_gc(p0, p67, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token \d+>)
- p68 = call_may_force(ConstClass(WeakrefLifelineWithCallbacks.make_weakref_with_callback), p66, ConstPtr(ptr50), p14, ConstPtr(ptr51), descr=<Callr 8 rrrr EF=6>)
+ p68 = call_may_force(ConstClass(WeakrefLifelineWithCallbacks.make_weakref_with_callback), p66, ConstPtr(ptr50), p14, ConstPtr(ptr51), descr=<Callr \d rrrr EF=6>)
guard_not_forced(descr=...)
guard_no_exception(descr=...)
guard_nonnull_class(p68, ..., descr=...)
More information about the pypy-commit
mailing list