[pypy-svn] r73344 - in pypy/branch/cpython-extension: . dotviewer lib-python pypy pypy/interpreter pypy/interpreter/test pypy/jit/backend/x86/test pypy/jit/metainterp pypy/module/_locale/test pypy/module/_ssl pypy/module/exceptions pypy/module/pyexpat pypy/module/pyexpat/test pypy/objspace/flow pypy/objspace/std pypy/objspace/std/test pypy/rlib pypy/rpython/lltypesystem pypy/rpython/lltypesystem/test pypy/tool pypy/translator/c pypy/translator/c/test pypy/translator/platform
benjamin at codespeak.net
benjamin at codespeak.net
Sun Apr 4 01:11:48 CEST 2010
Author: benjamin
Date: Sun Apr 4 01:11:46 2010
New Revision: 73344
Modified:
pypy/branch/cpython-extension/ (props changed)
pypy/branch/cpython-extension/dotviewer/ (props changed)
pypy/branch/cpython-extension/lib-python/ (props changed)
pypy/branch/cpython-extension/pypy/ (props changed)
pypy/branch/cpython-extension/pypy/interpreter/function.py
pypy/branch/cpython-extension/pypy/interpreter/gateway.py
pypy/branch/cpython-extension/pypy/interpreter/pyframe.py
pypy/branch/cpython-extension/pypy/interpreter/pyopcode.py
pypy/branch/cpython-extension/pypy/interpreter/test/test_function.py
pypy/branch/cpython-extension/pypy/jit/backend/x86/test/test_gc_integration.py (props changed)
pypy/branch/cpython-extension/pypy/jit/metainterp/logger.py (props changed)
pypy/branch/cpython-extension/pypy/module/_locale/test/test_locale.py
pypy/branch/cpython-extension/pypy/module/_ssl/interp_ssl.py
pypy/branch/cpython-extension/pypy/module/exceptions/ (props changed)
pypy/branch/cpython-extension/pypy/module/pyexpat/interp_pyexpat.py
pypy/branch/cpython-extension/pypy/module/pyexpat/test/test_build.py
pypy/branch/cpython-extension/pypy/objspace/flow/objspace.py
pypy/branch/cpython-extension/pypy/objspace/std/objspace.py
pypy/branch/cpython-extension/pypy/objspace/std/register_all.py
pypy/branch/cpython-extension/pypy/objspace/std/test/test_setobject.py (props changed)
pypy/branch/cpython-extension/pypy/rlib/rcoroutine.py
pypy/branch/cpython-extension/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py
pypy/branch/cpython-extension/pypy/rpython/lltypesystem/test/test_rffi.py
pypy/branch/cpython-extension/pypy/tool/runsubprocess.py
pypy/branch/cpython-extension/pypy/translator/c/database.py
pypy/branch/cpython-extension/pypy/translator/c/test/test_refcount.py (props changed)
pypy/branch/cpython-extension/pypy/translator/platform/__init__.py
pypy/branch/cpython-extension/pypy/translator/platform/maemo.py
pypy/branch/cpython-extension/pypy/translator/platform/posix.py
pypy/branch/cpython-extension/pypy/translator/platform/windows.py
Log:
merge from trunk
Modified: pypy/branch/cpython-extension/pypy/interpreter/function.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/interpreter/function.py (original)
+++ pypy/branch/cpython-extension/pypy/interpreter/function.py Sun Apr 4 01:11:46 2010
@@ -295,8 +295,13 @@
def descr_function__setstate__(self, space, w_args):
from pypy.interpreter.pycode import PyCode
args_w = space.unpackiterable(w_args)
- (w_name, w_doc, w_code, w_func_globals, w_closure, w_defs_w,
- w_func_dict, w_module) = args_w
+ try:
+ (w_name, w_doc, w_code, w_func_globals, w_closure, w_defs_w,
+ w_func_dict, w_module) = args_w
+ except ValueError:
+ # wrong args
+ raise OperationError(space.w_ValueError,
+ space.wrap("Wrong arguments to function.__setstate__"))
self.space = space
self.name = space.str_w(w_name)
Modified: pypy/branch/cpython-extension/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/interpreter/gateway.py (original)
+++ pypy/branch/cpython-extension/pypy/interpreter/gateway.py Sun Apr 4 01:11:46 2010
@@ -576,6 +576,8 @@
except rstackovf.StackOverflow, e:
rstackovf.check_stack_overflow()
raise space.prebuilt_recursion_error
+ except RuntimeError: # not on top of py.py
+ raise OperationError(space.w_RuntimeError, space.w_None)
# (verbose) performance hack below
Modified: pypy/branch/cpython-extension/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/interpreter/pyframe.py (original)
+++ pypy/branch/cpython-extension/pypy/interpreter/pyframe.py Sun Apr 4 01:11:46 2010
@@ -7,18 +7,18 @@
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.executioncontext import ExecutionContext
from pypy.interpreter import pytraceback
-import opcode
from pypy.rlib.objectmodel import we_are_translated, instantiate
from pypy.rlib.jit import hint
from pypy.rlib.debug import make_sure_not_resized
from pypy.rlib import jit
+from pypy.tool import stdlib_opcode
# Define some opcodes used
g = globals()
for op in '''DUP_TOP POP_TOP SETUP_LOOP SETUP_EXCEPT SETUP_FINALLY
POP_BLOCK END_FINALLY'''.split():
- g[op] = opcode.opmap[op]
-HAVE_ARGUMENT = opcode.HAVE_ARGUMENT
+ g[op] = stdlib_opcode.opmap[op]
+HAVE_ARGUMENT = stdlib_opcode.HAVE_ARGUMENT
class PyFrame(eval.Frame):
"""Represents a frame for a regular Python function
@@ -541,7 +541,7 @@
if delta_iblock < min_delta_iblock:
min_delta_iblock = delta_iblock
- if op >= opcode.HAVE_ARGUMENT:
+ if op >= stdlib_opcode.HAVE_ARGUMENT:
addr += 3
else:
addr += 1
Modified: pypy/branch/cpython-extension/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/interpreter/pyopcode.py (original)
+++ pypy/branch/cpython-extension/pypy/interpreter/pyopcode.py Sun Apr 4 01:11:46 2010
@@ -7,18 +7,16 @@
import sys
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.baseobjspace import UnpackValueError, Wrappable
-from pypy.interpreter import gateway, function, eval
-from pypy.interpreter import pyframe, pytraceback
+from pypy.interpreter import gateway, function, eval, pyframe, pytraceback
from pypy.interpreter.pycode import PyCode
from pypy.tool.sourcetools import func_with_new_name
from pypy.rlib.objectmodel import we_are_translated
-from pypy.rlib import jit
+from pypy.rlib import jit, rstackovf
from pypy.rlib.rarithmetic import r_uint, intmask
-from pypy.tool.stdlib_opcode import opcodedesc, HAVE_ARGUMENT
-from pypy.tool.stdlib_opcode import unrolling_opcode_descs
-from pypy.tool.stdlib_opcode import opcode_method_names
from pypy.rlib.unroll import unrolling_iterable
-from pypy.rlib import rstackovf
+from pypy.tool.stdlib_opcode import (opcodedesc, HAVE_ARGUMENT,
+ unrolling_opcode_descs,
+ opcode_method_names)
def unaryoperation(operationname):
"""NOT_RPYTHON"""
Modified: pypy/branch/cpython-extension/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/interpreter/test/test_function.py (original)
+++ pypy/branch/cpython-extension/pypy/interpreter/test/test_function.py Sun Apr 4 01:11:46 2010
@@ -288,6 +288,11 @@
f = lambda: 42
assert f.func_doc is None
+ def test_setstate_called_with_wrong_args(self):
+ f = lambda: 42
+ # not sure what it should raise, since CPython doesn't have setstate
+ # on function types
+ raises(ValueError, type(f).__setstate__, f, (1, 2, 3))
class AppTestMethod:
def test_simple_call(self):
Modified: pypy/branch/cpython-extension/pypy/module/_locale/test/test_locale.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/_locale/test/test_locale.py (original)
+++ pypy/branch/cpython-extension/pypy/module/_locale/test/test_locale.py Sun Apr 4 01:11:46 2010
@@ -22,8 +22,15 @@
current = _locale.setlocale(_locale.LC_ALL)
try:
try:
- _locale.setlocale(_locale.LC_ALL,
- space.str_w(cls.w_language_en))
+ # some systems are only UTF-8 oriented
+ try:
+ _locale.setlocale(_locale.LC_ALL,
+ space.str_w(cls.w_language_en))
+ except _locale.Error:
+ _locale.setlocale(_locale.LC_ALL,
+ space.str_w(cls.w_language_utf8))
+ cls.w_language_en = cls.w_language_utf8
+
_locale.setlocale(_locale.LC_ALL,
space.str_w(cls.w_language_pl))
except _locale.Error:
@@ -111,10 +118,11 @@
assert string.lowercase == lcase
assert string.uppercase == ucase
- _locale.setlocale(_locale.LC_ALL, self.language_en)
+ if self.language_en != self.language_utf8:
+ _locale.setlocale(_locale.LC_ALL, self.language_en)
- assert string.lowercase != lcase
- assert string.uppercase != ucase
+ assert string.lowercase != lcase
+ assert string.uppercase != ucase
def test_localeconv(self):
import _locale
Modified: pypy/branch/cpython-extension/pypy/module/_ssl/interp_ssl.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/_ssl/interp_ssl.py (original)
+++ pypy/branch/cpython-extension/pypy/module/_ssl/interp_ssl.py Sun Apr 4 01:11:46 2010
@@ -18,10 +18,11 @@
# need of winsock2. Remove this when separate compilation is
# available...
'winsock2.h',
- 'openssl/ssl.h']
+ 'openssl/ssl.h',
+ 'openssl/err.h']
else:
libraries = ['ssl', 'crypto']
- includes = ['openssl/ssl.h']
+ includes = ['openssl/ssl.h', 'openssl/err.h']
eci = ExternalCompilationInfo(
libraries = libraries,
@@ -140,7 +141,7 @@
ssl_external('SSL_get_error', [SSL_P, rffi.INT], rffi.INT)
ssl_external('ERR_get_error', [], rffi.INT)
-ssl_external('ERR_error_string', [rffi.INT, rffi.CCHARP], rffi.CCHARP)
+ssl_external('ERR_error_string', [rffi.ULONG, rffi.CCHARP], rffi.CCHARP)
ssl_external('SSL_get_peer_certificate', [SSL_P], X509_P)
ssl_external('X509_get_subject_name', [X509_P], X509_NAME_P)
ssl_external('X509_get_issuer_name', [X509_P], X509_NAME_P)
Modified: pypy/branch/cpython-extension/pypy/module/pyexpat/interp_pyexpat.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/pyexpat/interp_pyexpat.py (original)
+++ pypy/branch/cpython-extension/pypy/module/pyexpat/interp_pyexpat.py Sun Apr 4 01:11:46 2010
@@ -33,7 +33,7 @@
])
XML_Content_Ptr = lltype.Ptr(lltype.ForwardReference())
-XML_Parser = rffi.VOIDP # an opaque pointer
+XML_Parser = rffi.COpaquePtr(typedef='XML_Parser')
class CConfigure:
_compilation_info_ = eci
@@ -475,7 +475,7 @@
global_storage.get_nonmoving_id(
CallbackData(space, parser),
id=rffi.cast(lltype.Signed, parser.itself))
- XML_SetUserData(parser.itself, parser.itself)
+ XML_SetUserData(parser.itself, rffi.cast(rffi.VOIDP, parser.itself))
# copy handlers from self
for i in range(NB_HANDLERS):
@@ -621,7 +621,7 @@
global_storage.get_nonmoving_id(
CallbackData(space, parser),
id=rffi.cast(lltype.Signed, parser.itself))
- XML_SetUserData(parser.itself, parser.itself)
+ XML_SetUserData(parser.itself, rffi.cast(rffi.VOIDP, parser.itself))
return space.wrap(parser)
ParserCreate.unwrap_spec = [ObjSpace, W_Root, W_Root, W_Root]
Modified: pypy/branch/cpython-extension/pypy/module/pyexpat/test/test_build.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/pyexpat/test/test_build.py (original)
+++ pypy/branch/cpython-extension/pypy/module/pyexpat/test/test_build.py Sun Apr 4 01:11:46 2010
@@ -18,6 +18,8 @@
def test_build():
def entry_point(argv):
+ parser = interp_pyexpat.XML_ParserCreate("test")
+ interp_pyexpat.XML_ParserFree(parser)
res = interp_pyexpat.XML_ErrorString(3)
os.write(1, rffi.charp2str(res))
return 0
Modified: pypy/branch/cpython-extension/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/objspace/flow/objspace.py (original)
+++ pypy/branch/cpython-extension/pypy/objspace/flow/objspace.py Sun Apr 4 01:11:46 2010
@@ -457,7 +457,7 @@
# XXX same as w_KeyboardInterrupt()
raise RuntimeError("the interpreter raises RuntimeError during "
"flow graph construction")
- w_RuntimeError = property(w_RuntimeError)
+ w_RuntimeError = prebuilt_recursion_error = property(w_RuntimeError)
# the following gives us easy access to declare more for applications:
NOT_REALLY_CONST = {
Modified: pypy/branch/cpython-extension/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/objspace/std/objspace.py (original)
+++ pypy/branch/cpython-extension/pypy/objspace/std/objspace.py Sun Apr 4 01:11:46 2010
@@ -89,7 +89,6 @@
def _install_multimethods(self):
"""Install all the MultiMethods into the space instance."""
- model.add_extra_comparisons()
for name, mm in model.MM.__dict__.items():
if not isinstance(mm, model.StdObjSpaceMultiMethod):
continue
Modified: pypy/branch/cpython-extension/pypy/objspace/std/register_all.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/objspace/std/register_all.py (original)
+++ pypy/branch/cpython-extension/pypy/objspace/std/register_all.py Sun Apr 4 01:11:46 2010
@@ -44,6 +44,8 @@
func = hack_func_by_name(funcname, namespaces)
func.register(obj, *l)
+ model.add_extra_comparisons()
+
def hack_func_by_name(funcname, namespaces):
for ns in namespaces:
Modified: pypy/branch/cpython-extension/pypy/rlib/rcoroutine.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/rlib/rcoroutine.py (original)
+++ pypy/branch/cpython-extension/pypy/rlib/rcoroutine.py Sun Apr 4 01:11:46 2010
@@ -111,7 +111,7 @@
self.temp_exc = exc
def check_for_zombie(self, obj):
- return co in self.to_delete
+ return obj in self.to_delete
def postpone_deletion(self, obj):
self.to_delete.append(obj)
Modified: pypy/branch/cpython-extension/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/branch/cpython-extension/pypy/rpython/lltypesystem/ll2ctypes.py Sun Apr 4 01:11:46 2010
@@ -114,8 +114,17 @@
assert max_n >= 0
ITEM = A.OF
ctypes_item = get_ctypes_type(ITEM, delayed_builders)
- MAX_SIZE = sys.maxint/64
- PtrType = ctypes.POINTER(MAX_SIZE * ctypes_item)
+ # Python 2.5 ctypes can raise OverflowError on 64-bit builds
+ for n in [sys.maxint, 2**31]:
+ MAX_SIZE = n/64
+ try:
+ PtrType = ctypes.POINTER(MAX_SIZE * ctypes_item)
+ except OverflowError, e:
+ pass
+ else:
+ break
+ else:
+ raise e
class CArray(ctypes.Structure):
if not A._hints.get('nolength'):
Modified: pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py (original)
+++ pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py Sun Apr 4 01:11:46 2010
@@ -449,7 +449,7 @@
return lltype.Ptr(lltype.FuncType(args, res))
CCallback._annspecialcase_ = 'specialize:memo'
-def COpaque(name, hints=None, compilation_info=None):
+def COpaque(name=None, ptr_typedef=None, hints=None, compilation_info=None):
if compilation_info is None:
compilation_info = ExternalCompilationInfo()
if hints is None:
@@ -457,7 +457,10 @@
else:
hints = hints.copy()
hints['external'] = 'C'
- hints['c_name'] = name
+ if name is not None:
+ hints['c_name'] = name
+ if ptr_typedef is not None:
+ hints['c_pointer_typedef'] = ptr_typedef
def lazy_getsize(cache={}):
from pypy.rpython.tool import rffi_platform
try:
@@ -471,7 +474,8 @@
return lltype.OpaqueType(name, hints)
def COpaquePtr(*args, **kwds):
- return lltype.Ptr(COpaque(*args, **kwds))
+ typedef = kwds.pop('typedef', None)
+ return lltype.Ptr(COpaque(ptr_typedef=typedef, *args, **kwds))
def CExternVariable(TYPE, name, eci, _CConstantClass=CConstant,
sandboxsafe=False, _nowrapper=False,
Modified: pypy/branch/cpython-extension/pypy/rpython/lltypesystem/test/test_rffi.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/rpython/lltypesystem/test/test_rffi.py (original)
+++ pypy/branch/cpython-extension/pypy/rpython/lltypesystem/test/test_rffi.py Sun Apr 4 01:11:46 2010
@@ -280,6 +280,28 @@
f1 = self.compile(f, [])
assert f1() == 'a'
+ def test_opaque_typedef(self):
+ code = """
+ #include <stddef.h>
+ struct stuff;
+ typedef struct stuff *stuff_ptr;
+ static int get(stuff_ptr ptr) { return (ptr != NULL); }
+ """
+
+ eci = ExternalCompilationInfo(
+ post_include_bits = [code]
+ )
+
+ STUFFP = COpaquePtr(typedef='stuff_ptr', compilation_info=eci)
+ ll_get = llexternal('get', [STUFFP], lltype.Signed,
+ compilation_info=eci)
+
+ def f():
+ return ll_get(lltype.nullptr(STUFFP.TO))
+
+ f1 = self.compile(f, [])
+ assert f1() == 0
+
def return_char(self, signed):
ctype_pref = ["un", ""][signed]
rffi_type = [UCHAR, SIGNEDCHAR][signed]
Modified: pypy/branch/cpython-extension/pypy/tool/runsubprocess.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/tool/runsubprocess.py (original)
+++ pypy/branch/cpython-extension/pypy/tool/runsubprocess.py Sun Apr 4 01:11:46 2010
@@ -47,8 +47,8 @@
_source = os.path.dirname(os.path.abspath(__file__))
_source = os.path.join(_source, 'runsubprocess.py') # and not e.g. '.pyc'
# Let's not hear about os.popen2's deprecation.
- warnings.filterwarnings("ignore", "popen2", DeprecationWarning,
- "runsubprocess")
+ warnings.filterwarnings("ignore", ".*popen2.*", DeprecationWarning,
+ "pypy.tool.runsubprocess")
_child_stdin, _child_stdout = os.popen2(
"'%s' '%s'" % (sys.executable, _source))
Modified: pypy/branch/cpython-extension/pypy/translator/c/database.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/translator/c/database.py (original)
+++ pypy/branch/cpython-extension/pypy/translator/c/database.py Sun Apr 4 01:11:46 2010
@@ -101,6 +101,9 @@
if isinstance(T, Primitive) or T == GCREF:
return PrimitiveType[T]
elif isinstance(T, Ptr):
+ if (isinstance(T.TO, OpaqueType) and
+ T.TO.hints.get('c_pointer_typedef') is not None):
+ return '%s @' % T.TO.hints['c_pointer_typedef']
try:
node = self.gettypedefnode(T.TO)
except NoCorrespondingNode:
Modified: pypy/branch/cpython-extension/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/translator/platform/__init__.py (original)
+++ pypy/branch/cpython-extension/pypy/translator/platform/__init__.py Sun Apr 4 01:11:46 2010
@@ -114,9 +114,12 @@
for line in stderr.splitlines():
log.WARNING(line)
-
+ def _preprocess_include_dirs(self, include_dirs):
+ # hook for maemo
+ return include_dirs
+
def _compile_args_from_eci(self, eci, standalone):
- include_dirs = self._preprocess_dirs(eci.include_dirs)
+ include_dirs = self._preprocess_include_dirs(eci.include_dirs)
args = self._includedirs(include_dirs)
if standalone:
extra = self.standalone_only
Modified: pypy/branch/cpython-extension/pypy/translator/platform/maemo.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/translator/platform/maemo.py (original)
+++ pypy/branch/cpython-extension/pypy/translator/platform/maemo.py Sun Apr 4 01:11:46 2010
@@ -42,7 +42,7 @@
self.copied_cache[dir_from] = new_dirpath
return new_dirpath
- def _preprocess_dirs(self, include_dirs):
+ def _preprocess_include_dirs(self, include_dirs):
""" Tweak includedirs so they'll be available through scratchbox
"""
res_incl_dirs = []
Modified: pypy/branch/cpython-extension/pypy/translator/platform/posix.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/translator/platform/posix.py (original)
+++ pypy/branch/cpython-extension/pypy/translator/platform/posix.py Sun Apr 4 01:11:46 2010
@@ -45,10 +45,6 @@
cwd=str(exe_name.dirpath()))
return exe_name
- def _preprocess_dirs(self, include_dirs):
- # hook for maemo
- return include_dirs
-
def _pkg_config(self, lib, opt, default):
try:
ret, out, err = _run_subprocess("pkg-config", [lib, opt])
@@ -88,7 +84,7 @@
m.cfiles = rel_cfiles
rel_includedirs = [pypyrel(incldir) for incldir in
- self._preprocess_dirs(eci.include_dirs)]
+ self._preprocess_include_dirs(eci.include_dirs)]
m.comment('automatically generated makefile')
definitions = [
Modified: pypy/branch/cpython-extension/pypy/translator/platform/windows.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/translator/platform/windows.py (original)
+++ pypy/branch/cpython-extension/pypy/translator/platform/windows.py Sun Apr 4 01:11:46 2010
@@ -116,17 +116,6 @@
# The following symbol is used in c/src/stack.h
self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024))
- if hasattr(sys, 'exec_prefix'):
- self.add_cpython_dirs = True
- else:
- # We are certainly running pypy-c
- self.add_cpython_dirs = False
-
- def _preprocess_dirs(self, include_dirs):
- if self.add_cpython_dirs:
- return include_dirs + (py.path.local(sys.exec_prefix).join('PC'),)
- return include_dirs
-
def _includedirs(self, include_dirs):
return ['/I%s' % (idir,) for idir in include_dirs]
More information about the Pypy-commit
mailing list