Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r69052:220c588360e5
Date: 2014-02-02 16:35 -0800
http://bitbucket.org/pypy/pypy/changeset/220c588360e5/
Log: merge default
diff --git a/pypy/module/_cffi_backend/test/test_handle.py
b/pypy/module/_cffi_backend/test/test_handle.py
--- a/pypy/module/_cffi_backend/test/test_handle.py
+++ b/pypy/module/_cffi_backend/test/test_handle.py
@@ -1,20 +1,5 @@
import random
-from pypy.module._cffi_backend.handle import CffiHandles, reduced_value
-
-
-def test_reduced_value():
- assert reduced_value(0) == 0
- assert reduced_value(1) == 0
- assert reduced_value(2) == 1
- assert reduced_value(3) == 0
- assert reduced_value(4) == 2
- assert reduced_value(5) == 1
- assert reduced_value(6) == 3
- assert reduced_value(7) == 0
- assert reduced_value(8) == 4
- assert reduced_value(9) == 2
- assert reduced_value(10) == 5
- assert reduced_value(11) == 1
+from pypy.module._cffi_backend.handle import CffiHandles
class PseudoWeakRef(object):
diff --git a/pypy/module/_csv/interp_reader.py
b/pypy/module/_csv/interp_reader.py
--- a/pypy/module/_csv/interp_reader.py
+++ b/pypy/module/_csv/interp_reader.py
@@ -39,6 +39,7 @@
field_builder.append(c)
def save_field(self, field_builder):
+ space = self.space
field = field_builder.build()
if self.numeric_field:
from rpython.rlib.rstring import ParseStringError
@@ -46,12 +47,12 @@
self.numeric_field = False
try:
ff = string_to_float(field)
- except ParseStringError, e:
- raise OperationError(self.space.w_ValueError,
- self.space.wrap(e.msg))
- w_obj = self.space.wrap(ff)
+ except ParseStringError as e:
+ from pypy.objspace.std.inttype import wrap_parsestringerror
+ raise wrap_parsestringerror(space, e, space.wrap(field))
+ w_obj = space.wrap(ff)
else:
- w_obj = self.space.wrap(field)
+ w_obj = space.wrap(field)
self.fields_w.append(w_obj)
def next_w(self):
diff --git a/pypy/module/micronumpy/interp_boxes.py
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -251,6 +251,10 @@
value = space.is_true(self)
return get_dtype_cache(space).w_booldtype.box(value)
+ def descr_zero(self, space):
+ from pypy.module.micronumpy.interp_dtype import get_dtype_cache
+ return get_dtype_cache(space).w_longdtype.box(0)
+
def descr_ravel(self, space):
from pypy.module.micronumpy.base import convert_to_array
w_values = space.newtuple([self])
@@ -582,6 +586,12 @@
__hash__ = interp2app(W_GenericBox.descr_hash),
tolist = interp2app(W_GenericBox.item),
+ min = interp2app(W_GenericBox.descr_self),
+ max = interp2app(W_GenericBox.descr_self),
+ argmin = interp2app(W_GenericBox.descr_zero),
+ argmax = interp2app(W_GenericBox.descr_zero),
+ sum = interp2app(W_GenericBox.descr_self),
+ prod = interp2app(W_GenericBox.descr_self),
any = interp2app(W_GenericBox.descr_any),
all = interp2app(W_GenericBox.descr_all),
ravel = interp2app(W_GenericBox.descr_ravel),
diff --git a/pypy/module/micronumpy/test/test_scalar.py
b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -102,6 +102,16 @@
assert b == a
assert b is not a
+ def test_methods(self):
+ import numpy as np
+ for a in [np.int32(2), np.float64(2.0), np.complex64(42)]:
+ for op in ['min', 'max', 'sum', 'prod']:
+ assert getattr(a, op)() == a
+ for op in ['argmin', 'argmax']:
+ b = getattr(a, op)()
+ assert type(b) is np.int_
+ assert b == 0
+
def test_buffer(self):
import numpy as np
a = np.int32(123)
diff --git a/pypy/objspace/std/floattype.py b/pypy/objspace/std/floattype.py
--- a/pypy/objspace/std/floattype.py
+++ b/pypy/objspace/std/floattype.py
@@ -34,20 +34,11 @@
value = space.float_w(w_obj)
elif (space.isinstance_w(w_value, space.w_str) or
space.isinstance_w(w_value, space.w_bytearray)):
- strvalue = space.bufferstr_w(w_value)
- try:
- value = rfloat.string_to_float(strvalue.decode('latin-1'))
- except ParseStringError, e:
- raise OperationError(space.w_ValueError,
- space.wrap(e.msg))
+ value = _string_to_float(space, w_value, space.bufferstr_w(w_value))
elif space.isinstance_w(w_value, space.w_unicode):
from unicodeobject import unicode_to_decimal_w
- strvalue = unicode_to_decimal_w(space, w_value)
- try:
- value = rfloat.string_to_float(strvalue)
- except ParseStringError, e:
- raise OperationError(space.w_ValueError,
- space.wrap(e.msg))
+ value = _string_to_float(space, w_value,
+ unicode_to_decimal_w(space, w_value))
else:
value = space.float_w(w_x)
w_obj = space.allocate_instance(W_FloatObject, w_floattype)
@@ -55,6 +46,14 @@
return w_obj
+def _string_to_float(space, w_source, string):
+ try:
+ return rfloat.string_to_float(string)
+ except ParseStringError as e:
+ from pypy.objspace.std.inttype import wrap_parsestringerror
+ raise wrap_parsestringerror(space, e, w_source)
+
+
def detect_floatformat():
from rpython.rtyper.lltypesystem import rffi, lltype
buf = lltype.malloc(rffi.CCHARP.TO, 8, flavor='raw')
diff --git a/pypy/objspace/std/inttype.py b/pypy/objspace/std/inttype.py
--- a/pypy/objspace/std/inttype.py
+++ b/pypy/objspace/std/inttype.py
@@ -9,7 +9,8 @@
from rpython.rlib.rarithmetic import r_uint, string_to_int
from rpython.rlib.objectmodel import instantiate
from rpython.rlib.rbigint import rbigint
-from rpython.rlib.rstring import ParseStringError, ParseStringOverflowError
+from rpython.rlib.rstring import (
+ InvalidBaseError, ParseStringError, ParseStringOverflowError)
from rpython.rlib import jit
# ____________________________________________________________
@@ -70,27 +71,33 @@
# ____________________________________________________________
## @jit.elidable
-## def string_to_int_or_long(space, string, base=10):
+## def string_to_int_or_long(space, w_source, string, base=10):
## w_longval = None
## value = 0
## try:
## value = string_to_int(string, base)
-## except ParseStringError, e:
-## raise OperationError(space.w_ValueError,
-## space.wrap(e.msg))
+## except ParseStringError as e:
+## raise wrap_parsestringerror(space, e, w_source)
## except ParseStringOverflowError, e:
-## w_longval = retry_to_w_long(space, e.parser)
+## w_longval = retry_to_w_long(space, e.parser, w_source)
## return value, w_longval
-## def retry_to_w_long(space, parser):
+## def retry_to_w_long(space, parser, w_source):
## parser.rewind()
## try:
## bigint = rbigint._from_numberstring_parser(parser)
-## except ParseStringError, e:
-## raise OperationError(space.w_ValueError,
-## space.wrap(e.msg))
+## except ParseStringError as e:
+## raise wrap_parsestringerror(space, e, w_source)
## return space.newlong_from_rbigint(bigint)
+def wrap_parsestringerror(space, e, w_source):
+ if isinstance(e, InvalidBaseError):
+ w_msg = space.wrap(e.msg)
+ else:
+ w_msg = space.wrap('%s: %s' % (e.msg,
+ space.str_w(space.repr(w_source))))
+ return OperationError(space.w_ValueError, w_msg)
+
## @unwrap_spec(w_x = WrappedDefault(0))
## def descr__new__(space, w_inttype, w_x, w_base=None):
## from pypy.objspace.std.intobject import W_IntObject
@@ -117,11 +124,12 @@
## # an overflowing long
## value = space.int_w(w_obj)
## elif space.isinstance_w(w_value, space.w_str):
-## value, w_longval = string_to_int_or_long(space,
space.str_w(w_value))
+## value, w_longval = string_to_int_or_long(space, w_value,
+## space.str_w(w_value))
## elif space.isinstance_w(w_value, space.w_unicode):
## from pypy.objspace.std.unicodeobject import unicode_to_decimal_w
## string = unicode_to_decimal_w(space, w_value)
-## value, w_longval = string_to_int_or_long(space, string)
+## value, w_longval = string_to_int_or_long(space, w_value, string)
## else:
## # If object supports the buffer interface
## try:
@@ -134,7 +142,8 @@
## w_value)
## else:
## buf = space.interp_w(Buffer, w_buffer)
-## value, w_longval = string_to_int_or_long(space,
buf.as_str())
+## value, w_longval = string_to_int_or_long(space, w_value,
+## buf.as_str())
## else:
## base = space.int_w(w_base)
@@ -149,7 +158,7 @@
## space.wrap("int() can't convert
non-string "
## "with explicit base"))
-## value, w_longval = string_to_int_or_long(space, s, base)
+## value, w_longval = string_to_int_or_long(space, w_value, s, base)
## if w_longval is not None:
## if not space.is_w(w_inttype, space.w_int):
diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py
--- a/pypy/objspace/std/longtype.py
+++ b/pypy/objspace/std/longtype.py
@@ -35,12 +35,12 @@
return _from_intlike(space, w_longtype, w_obj)
elif space.isinstance_w(w_value, space.w_unicode):
from pypy.objspace.std.unicodeobject import unicode_to_decimal_w
- return string_to_w_long(space, w_longtype,
+ return string_to_w_long(space, w_longtype, w_value,
unicode_to_decimal_w(space, w_value))
elif (space.isinstance_w(w_value, space.w_bytearray) or
space.isinstance_w(w_value, space.w_bytes)):
- strvalue = space.bufferstr_w(w_value)
- return string_to_w_long(space, w_longtype,
strvalue.decode('latin-1'))
+ return string_to_w_long(space, w_longtype, w_value,
+ space.bufferstr_w(w_value))
else:
try:
w_buffer = space.buffer(w_value)
@@ -52,8 +52,8 @@
w_value)
else:
buf = space.interp_w(Buffer, w_buffer)
- return string_to_w_long(space, w_longtype,
- buf.as_str().decode('latin-1'))
+ return string_to_w_long(space, w_longtype, w_value,
+ buf.as_str())
else:
try:
base = space.int_w(w_base)
@@ -73,7 +73,7 @@
raise OperationError(space.w_TypeError,
space.wrap("int() can't convert
non-string "
"with explicit base"))
- return string_to_w_long(space, w_longtype, s, base)
+ return string_to_w_long(space, w_longtype, w_value, s, base)
def _from_intlike(space, w_longtype, w_intlike):
@@ -83,12 +83,13 @@
return newbigint(space, w_longtype, space.bigint_w(w_obj))
-def string_to_w_long(space, w_longtype, s, base=10):
+def string_to_w_long(space, w_longtype, w_source, string, base=10):
try:
- bigint = rbigint.fromstr(s, base, ignore_l_suffix=True, fname=u'int')
- except ParseStringError, e:
- raise OperationError(space.w_ValueError,
- space.wrap(e.msg))
+ bigint = rbigint.fromstr(string, base, ignore_l_suffix=True,
+ fname=u'int')
+ except ParseStringError as e:
+ from pypy.objspace.std.inttype import wrap_parsestringerror
+ raise wrap_parsestringerror(space, e, w_source)
return newbigint(space, w_longtype, bigint)
string_to_w_long._dont_inline_ = True
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -57,7 +57,7 @@
return True
def delete(self, obj, selector):
- return None
+ pass
def find_map_attr(self, selector):
if jit.we_are_jitted():
@@ -291,6 +291,7 @@
def delete(self, obj, selector):
if selector == self.selector:
# ok, attribute is deleted
+ self.ever_mutated = True
return self.back.copy(obj)
new_obj = self.back.delete(obj, selector)
if new_obj is not None:
diff --git a/pypy/objspace/std/test/test_intobject.py
b/pypy/objspace/std/test/test_intobject.py
--- a/pypy/objspace/std/test/test_intobject.py
+++ b/pypy/objspace/std/test/test_intobject.py
@@ -1,3 +1,4 @@
+# encoding: utf-8
import py
import sys
from pypy.objspace.std import intobject as iobj
@@ -492,6 +493,18 @@
assert str(e.value) == (
"int() argument must be a string or a number, not 'list'")
+ def test_invalid_literal_message(self):
+ import sys
+ if '__pypy__' not in sys.builtin_module_names:
+ skip('PyPy 2.x/CPython 3.4 only')
+ for value in b' 1j ', u' 1٢٣٤j ':
+ try:
+ int(value)
+ except ValueError as e:
+ assert repr(value) in str(e)
+ else:
+ assert False, value
+
class AppTestIntOptimizedAdd(AppTestInt):
spaceconfig = {"objspace.std.optimized_int_add": True}
diff --git a/pypy/objspace/std/test/test_mapdict.py
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -144,7 +144,15 @@
assert obj2.map.back.ever_mutated == True
assert obj2.map is obj.map
-
+def test_attr_immutability_delete(monkeypatch):
+ cls = Class()
+ obj = cls.instantiate()
+ obj.setdictvalue(space, "a", 10)
+ map1 = obj.map
+ obj.deldictvalue(space, "a")
+ obj.setdictvalue(space, "a", 20)
+ assert obj.map.ever_mutated == True
+ assert obj.map is map1
def test_delete():
for i, dattr in enumerate(["a", "b", "c"]):
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -24,7 +24,6 @@
def __init__(self, translator=None, policy=None, bookkeeper=None):
import rpython.rtyper.extfuncregistry # has side effects
- import rpython.rlib.nonconst # has side effects
if translator is None:
# interface for tests
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -4,7 +4,6 @@
from __future__ import absolute_import
-from types import MethodType
from rpython.flowspace.operation import op
from rpython.annotator.model import (SomeObject, SomeInteger, SomeBool,
SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue,
@@ -757,63 +756,6 @@
# This should probably never happen
raise AnnotatorError("Cannot call len on a pbc")
-# annotation of low-level types
-from rpython.rtyper.llannotation import (
- SomePtr, SomeLLADTMeth, ll_to_annotation, lltype_to_annotation,
- annotation_to_lltype)
-
-class __extend__(SomePtr):
-
- def getattr(self, s_attr):
- assert s_attr.is_constant(), "getattr on ptr %r with non-constant
field-name" % self.ll_ptrtype
- example = self.ll_ptrtype._example()
- try:
- v = example._lookup_adtmeth(s_attr.const)
- except AttributeError:
- v = getattr(example, s_attr.const)
- return ll_to_annotation(v)
- else:
- if isinstance(v, MethodType):
- from rpython.rtyper.lltypesystem import lltype
- ll_ptrtype = lltype.typeOf(v.im_self)
- assert isinstance(ll_ptrtype, (lltype.Ptr, lltype.InteriorPtr))
- return SomeLLADTMeth(ll_ptrtype, v.im_func)
- return getbookkeeper().immutablevalue(v)
- getattr.can_only_throw = []
-
- def len(self):
- length = self.ll_ptrtype._example()._fixedlength()
- if length is None:
- return SomeObject.len(self)
- else:
- return immutablevalue(length)
-
- def setattr(self, s_attr, s_value): # just doing checking
- assert s_attr.is_constant(), "setattr on ptr %r with non-constant
field-name" % self.ll_ptrtype
- example = self.ll_ptrtype._example()
- if getattr(example, s_attr.const) is not None: # ignore Void s_value
- v_lltype = annotation_to_lltype(s_value)
- setattr(example, s_attr.const, v_lltype._defl())
-
- def call(self, args):
- args_s, kwds_s = args.unpack()
- if kwds_s:
- raise Exception("keyword arguments to call to a low-level fn ptr")
- info = 'argument to ll function pointer call'
- llargs = [annotation_to_lltype(s_arg,info)._defl() for s_arg in args_s]
- v = self.ll_ptrtype._example()(*llargs)
- return ll_to_annotation(v)
-
- def bool(self):
- return s_Bool
-
-class __extend__(SomeLLADTMeth):
-
- def call(self, args):
- bookkeeper = getbookkeeper()
- s_func = bookkeeper.immutablevalue(self.func)
- return s_func.call(args.prepend(lltype_to_annotation(self.ll_ptrtype)))
-
#_________________________________________
# weakrefs
diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py
--- a/rpython/rlib/rarithmetic.py
+++ b/rpython/rlib/rarithmetic.py
@@ -691,9 +691,8 @@
characters of 's'. Raises ParseStringError in case of error.
Raises ParseStringOverflowError in case the result does not fit.
"""
- from rpython.rlib.rstring import NumberStringParser, \
- ParseStringOverflowError, \
- ParseStringError, strip_spaces
+ from rpython.rlib.rstring import (
+ NumberStringParser, ParseStringOverflowError, strip_spaces)
s = literal = strip_spaces(s)
p = NumberStringParser(s, literal, base, u'int')
base = p.base
diff --git a/rpython/rlib/rfloat.py b/rpython/rlib/rfloat.py
--- a/rpython/rlib/rfloat.py
+++ b/rpython/rlib/rfloat.py
@@ -25,7 +25,8 @@
globals().update(rffi_platform.configure(CConfig))
[email protected](unicode)
+INVALID_MSG = "invalid literal for float()"
+
def string_to_float(s):
"""
Conversion of string to float.
@@ -37,10 +38,8 @@
from rpython.rlib.rstring import strip_spaces, ParseStringError
s = strip_spaces(s)
-
if not s:
- raise ParseStringError(u"empty string for float()")
-
+ raise ParseStringError(INVALID_MSG)
try:
ascii_s = s.encode('ascii')
@@ -72,9 +71,7 @@
try:
return rstring_to_float(ascii_s)
except ValueError:
- # note that we still put the original unicode string in the error
- # message, not ascii_s
- raise ParseStringError(u"invalid literal for float(): '%s'" % s)
+ raise ParseStringError(INVALID_MSG)
def rstring_to_float(s):
from rpython.rlib.rdtoa import strtod
diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py
--- a/rpython/rlib/rstring.py
+++ b/rpython/rlib/rstring.py
@@ -282,6 +282,9 @@
def __init__(self, msg):
self.msg = msg
+class InvalidBaseError(ParseStringError):
+ """Signals an invalid base argument"""
+
class ParseStringOverflowError(Exception):
def __init__(self, parser):
self.parser = parser
@@ -290,13 +293,12 @@
class NumberStringParser:
def error(self):
- raise ParseStringError(u"invalid literal for %s() with base %d: '%s'" %
- (self.fname, self.original_base, self.literal))
+ raise ParseStringError("invalid literal for %s() with base %d" %
+ (self.fname, self.original_base))
@enforceargs(None, unicode, unicode, int, unicode)
@with_unicode_literals
def __init__(self, s, literal, base, fname):
- self.literal = literal
self.fname = fname
sign = 1
if s.startswith('-'):
@@ -317,7 +319,7 @@
else:
base = 10
elif base < 2 or base > 36:
- raise ParseStringError, u"%s() base must be >= 2 and <= 36" %
(fname,)
+ raise InvalidBaseError("%s() base must be >= 2 and <= 36" % fname)
self.base = base
if base == 16 and (s.startswith('0x') or s.startswith('0X')):
diff --git a/rpython/rlib/test/test_rweaklist.py
b/rpython/rlib/test/test_rweaklist.py
--- a/rpython/rlib/test/test_rweaklist.py
+++ b/rpython/rlib/test/test_rweaklist.py
@@ -1,5 +1,20 @@
import gc
-from rpython.rlib.rweaklist import RWeakListMixin
+from rpython.rlib.rweaklist import RWeakListMixin, _reduced_value as
reduced_value
+
+
+def test_reduced_value():
+ assert reduced_value(0) == 0
+ assert reduced_value(1) == 0
+ assert reduced_value(2) == 1
+ assert reduced_value(3) == 0
+ assert reduced_value(4) == 2
+ assert reduced_value(5) == 1
+ assert reduced_value(6) == 3
+ assert reduced_value(7) == 0
+ assert reduced_value(8) == 4
+ assert reduced_value(9) == 2
+ assert reduced_value(10) == 5
+ assert reduced_value(11) == 1
class A(object):
diff --git a/rpython/rtyper/llannotation.py b/rpython/rtyper/llannotation.py
--- a/rpython/rtyper/llannotation.py
+++ b/rpython/rtyper/llannotation.py
@@ -1,6 +1,7 @@
"""
Code for annotating low-level thingies.
"""
+from types import MethodType
from rpython.tool.pairtype import pair, pairtype
from rpython.annotator.model import (
SomeObject, SomeSingleFloat, SomeFloat, SomeLongFloat, SomeChar,
@@ -108,6 +109,54 @@
def can_be_none(self):
return False
+ def getattr(self, s_attr):
+ from rpython.annotator.bookkeeper import getbookkeeper
+ if not s_attr.is_constant():
+ raise AnnotatorError("getattr on ptr %r with non-constant "
+ "field-name" % self.ll_ptrtype)
+ example = self.ll_ptrtype._example()
+ try:
+ v = example._lookup_adtmeth(s_attr.const)
+ except AttributeError:
+ v = getattr(example, s_attr.const)
+ return ll_to_annotation(v)
+ else:
+ if isinstance(v, MethodType):
+ ll_ptrtype = lltype.typeOf(v.im_self)
+ assert isinstance(ll_ptrtype, (lltype.Ptr, lltype.InteriorPtr))
+ return SomeLLADTMeth(ll_ptrtype, v.im_func)
+ return getbookkeeper().immutablevalue(v)
+ getattr.can_only_throw = []
+
+ def len(self):
+ from rpython.annotator.bookkeeper import getbookkeeper
+ length = self.ll_ptrtype._example()._fixedlength()
+ if length is None:
+ return SomeObject.len(self)
+ else:
+ return getbookkeeper().immutablevalue(length)
+
+ def setattr(self, s_attr, s_value): # just doing checking
+ if not s_attr.is_constant():
+ raise AnnotatorError("setattr on ptr %r with non-constant "
+ "field-name" % self.ll_ptrtype)
+ example = self.ll_ptrtype._example()
+ if getattr(example, s_attr.const) is not None: # ignore Void s_value
+ v_lltype = annotation_to_lltype(s_value)
+ setattr(example, s_attr.const, v_lltype._defl())
+
+ def call(self, args):
+ args_s, kwds_s = args.unpack()
+ if kwds_s:
+ raise Exception("keyword arguments to call to a low-level fn ptr")
+ info = 'argument to ll function pointer call'
+ llargs = [annotation_to_lltype(s_arg, info)._defl() for s_arg in
args_s]
+ v = self.ll_ptrtype._example()(*llargs)
+ return ll_to_annotation(v)
+
+ def bool(self):
+ return s_Bool
+
class SomeInteriorPtr(SomePtr):
def __init__(self, ll_ptrtype):
@@ -125,6 +174,13 @@
def can_be_none(self):
return False
+ def call(self, args):
+ from rpython.annotator.bookkeeper import getbookkeeper
+ bookkeeper = getbookkeeper()
+ s_func = bookkeeper.immutablevalue(self.func)
+ return s_func.call(args.prepend(lltype_to_annotation(self.ll_ptrtype)))
+
+
class __extend__(pairtype(SomePtr, SomePtr)):
def union((p1, p2)):
if p1.ll_ptrtype != p2.ll_ptrtype:
diff --git a/rpython/translator/c/test/test_standalone.py
b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -16,6 +16,20 @@
from rpython.conftest import cdir
from rpython.conftest import option
+def setup_module(module):
+ if os.name == 'nt':
+ # Do not open dreaded dialog box on segfault
+ import ctypes
+ SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN
+ old_err_mode = ctypes.windll.kernel32.GetErrorMode()
+ new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX
+ ctypes.windll.kernel32.SetErrorMode(new_err_mode)
+ module.old_err_mode = old_err_mode
+
+def teardown_module(module):
+ if os.name == 'nt':
+ import ctypes
+ ctypes.windll.kernel32.SetErrorMode(module.old_err_mode)
class StandaloneTests(object):
config = None
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit