Author: Maciej Fijalkowski <[email protected]>
Branch: kill-someobject
Changeset: r58061:a67e4ca4ea5a
Date: 2012-10-12 16:59 +0200
http://bitbucket.org/pypy/pypy/changeset/a67e4ca4ea5a/
Log: merge default
diff --git a/py/_io/capture.py b/py/_io/capture.py
--- a/py/_io/capture.py
+++ b/py/_io/capture.py
@@ -176,7 +176,7 @@
class StdCaptureFD(Capture):
- """ This class allows to capture writes to FD1 and FD2
+ """ This class allows capturing writes to FD1 and FD2
and may connect a NULL file to FD0 (and prevent
reads from sys.stdin). If any of the 0,1,2 file descriptors
is invalid it will not be captured.
@@ -267,8 +267,8 @@
return l
class StdCapture(Capture):
- """ This class allows to capture writes to sys.stdout|stderr "in-memory"
- and will raise errors on tries to read from sys.stdin. It only
+ """ This class allows capturing writes to sys.stdout|stderr "in-memory"
+ and will raise errors on read attempts from sys.stdin. It only
modifies sys.stdout|stderr|stdin attributes and does not
touch underlying File Descriptors (use StdCaptureFD for that).
"""
diff --git a/pypy/bin/reportstaticdata.py b/pypy/bin/reportstaticdata.py
--- a/pypy/bin/reportstaticdata.py
+++ b/pypy/bin/reportstaticdata.py
@@ -2,9 +2,9 @@
"""
Usage: reportstaticdata.py [-m1|-m2|-t] [OPTION]... FILENAME
-Print a report for the static data informations contained in FILENAME
+Print a report for the static data information contained in FILENAME
-The static data informations are saved in the file staticdata.info when
+The static data information is saved in the file staticdata.info when
passing --dump_static_data_info to translate.py.
Options:
diff --git a/pypy/doc/architecture.rst b/pypy/doc/architecture.rst
--- a/pypy/doc/architecture.rst
+++ b/pypy/doc/architecture.rst
@@ -238,7 +238,7 @@
interpreter`_.
.. _`documentation index`: index.html#project-documentation
-.. _`getting-started`: getting-started.html
+.. _`getting-started`: getting-started-dev.html
.. _`PyPy's approach to virtual machine construction`:
https://bitbucket.org/pypy/extradoc/raw/tip/talk/dls2006/pypy-vm-construction.pdf
.. _`the translation document`: translation.html
.. _`RPython toolchain`: translation.html
diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -2,7 +2,6 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter.pyopcode import LoopBlock
from pypy.rlib import jit
-from pypy.rlib.objectmodel import specialize
class GeneratorIterator(Wrappable):
diff --git a/pypy/interpreter/unicodehelper.py
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -1,10 +1,62 @@
+from pypy.interpreter.error import OperationError
+from pypy.rlib.objectmodel import specialize
+from pypy.rlib import runicode
from pypy.module._codecs import interp_codecs
[email protected]()
+def decode_error_handler(space):
+ def raise_unicode_exception_decode(errors, encoding, msg, s,
+ startingpos, endingpos):
+ raise OperationError(space.w_UnicodeDecodeError,
+ space.newtuple([space.wrap(encoding),
+ space.wrap(s),
+ space.wrap(startingpos),
+ space.wrap(endingpos),
+ space.wrap(msg)]))
+ return raise_unicode_exception_decode
+
[email protected]()
+def encode_error_handler(space):
+ def raise_unicode_exception_encode(errors, encoding, msg, u,
+ startingpos, endingpos):
+ raise OperationError(space.w_UnicodeEncodeError,
+ space.newtuple([space.wrap(encoding),
+ space.wrap(u),
+ space.wrap(startingpos),
+ space.wrap(endingpos),
+ space.wrap(msg)]))
+ return raise_unicode_exception_encode
+
+# ____________________________________________________________
+
def PyUnicode_AsEncodedString(space, w_data, w_encoding):
return interp_codecs.encode(space, w_data, w_encoding)
# These functions take and return unwrapped rpython strings and unicodes
-PyUnicode_DecodeUnicodeEscape =
interp_codecs.make_raw_decoder('unicode_escape')
-PyUnicode_DecodeRawUnicodeEscape =
interp_codecs.make_raw_decoder('raw_unicode_escape')
-PyUnicode_DecodeUTF8 = interp_codecs.make_raw_decoder('utf_8')
-PyUnicode_EncodeUTF8 = interp_codecs.make_raw_encoder('utf_8')
+def PyUnicode_DecodeUnicodeEscape(space, string):
+ state = space.fromcache(interp_codecs.CodecState)
+ unicodedata_handler = state.get_unicodedata_handler(space)
+ result, consumed = runicode.str_decode_unicode_escape(
+ string, len(string), "strict",
+ final=True, errorhandler=decode_error_handler(space),
+ unicodedata_handler=unicodedata_handler)
+ return result
+
+def PyUnicode_DecodeRawUnicodeEscape(space, string):
+ result, consumed = runicode.str_decode_raw_unicode_escape(
+ string, len(string), "strict",
+ final=True, errorhandler=decode_error_handler(space))
+ return result
+
+def PyUnicode_DecodeUTF8(space, string):
+ result, consumed = runicode.str_decode_utf_8(
+ string, len(string), "strict",
+ final=True, errorhandler=decode_error_handler(space),
+ allow_surrogates=True)
+ return result
+
+def PyUnicode_EncodeUTF8(space, uni):
+ return runicode.unicode_encode_utf_8(
+ uni, len(uni), "strict",
+ errorhandler=encode_error_handler(space),
+ allow_surrogates=True)
diff --git a/pypy/jit/backend/cli/methodfactory.py
b/pypy/jit/backend/cli/methodfactory.py
--- a/pypy/jit/backend/cli/methodfactory.py
+++ b/pypy/jit/backend/cli/methodfactory.py
@@ -27,7 +27,7 @@
return self.dynmeth.CreateDelegate(delegatetype, consts)
-# the assemblyData singleton contains the informations about the
+# the assemblyData singleton contains the information about the
# assembly we are currently writing to
class AssemblyData:
assembly = None
diff --git a/pypy/jit/backend/model.py b/pypy/jit/backend/model.py
--- a/pypy/jit/backend/model.py
+++ b/pypy/jit/backend/model.py
@@ -97,7 +97,7 @@
The FailDescr is the descr of the original guard that failed.
Optionally, return a ``ops_offset`` dictionary. See the docstring of
- ``compiled_loop`` for more informations about it.
+ ``compiled_loop`` for more information about it.
"""
raise NotImplementedError
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py
b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -317,7 +317,7 @@
except BadVirtualState:
raise InvalidLoop('The state of the optimizer at the end of ' +
'peeled loop is inconsistent with the ' +
- 'VirtualState at the begining of the peeled ' +
+ 'VirtualState at the beginning of the peeled ' +
'loop')
jumpop.initarglist(jumpargs)
diff --git a/pypy/module/__builtin__/operation.py
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -44,8 +44,8 @@
# string to the rest of the code. XXX not entirely sure if these three
# functions are the only way for non-string objects to reach
# space.{get,set,del}attr()...
- # Note that if w_name is already a string (or a subclass of str),
- # it must be returned unmodified (and not e.g. unwrapped-rewrapped).
+ # Note that if w_name is already an exact string it must be returned
+ # unmodified (and not e.g. unwrapped-rewrapped).
if not space.is_w(space.type(w_name), space.w_str):
name = space.str_w(w_name) # typecheck
w_name = space.wrap(name) # rewrap as a real string
diff --git a/pypy/module/__builtin__/test/test_builtin.py
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -172,28 +172,6 @@
assert f() == {}
assert g() == {'a':0, 'b':0, 'c':0}
- def test_getattr(self):
- class a(object):
- i = 5
- assert getattr(a, 'i') == 5
- raises(AttributeError, getattr, a, 'k')
- assert getattr(a, 'k', 42) == 42
- assert getattr(a, u'i') == 5
- raises(AttributeError, getattr, a, u'k')
- assert getattr(a, u'k', 42) == 42
-
- def test_getattr_typecheck(self):
- class A(object):
- def __getattribute__(self, name):
- pass
- def __setattr__(self, name, value):
- pass
- def __delattr__(self, name):
- pass
- raises(TypeError, getattr, A(), 42)
- raises(TypeError, setattr, A(), 42, 'x')
- raises(TypeError, delattr, A(), 42)
-
def test_sum(self):
assert sum([]) ==0
assert sum([42]) ==42
@@ -661,6 +639,39 @@
assert vars(C_get_vars()) == {'a':2}
+class AppTestGetattr:
+ OPTIONS = {}
+
+ def setup_class(cls):
+ cls.space = conftest.gettestobjspace(**cls.OPTIONS)
+
+ def test_getattr(self):
+ class a(object):
+ i = 5
+ assert getattr(a, 'i') == 5
+ raises(AttributeError, getattr, a, 'k')
+ assert getattr(a, 'k', 42) == 42
+ assert getattr(a, u'i') == 5
+ raises(AttributeError, getattr, a, u'k')
+ assert getattr(a, u'k', 42) == 42
+
+ def test_getattr_typecheck(self):
+ class A(object):
+ def __getattribute__(self, name):
+ pass
+ def __setattr__(self, name, value):
+ pass
+ def __delattr__(self, name):
+ pass
+ raises(TypeError, getattr, A(), 42)
+ raises(TypeError, setattr, A(), 42, 'x')
+ raises(TypeError, delattr, A(), 42)
+
+
+class AppTestGetattrWithGetAttributeShortcut(AppTestGetattr):
+ OPTIONS = {"objspace.std.getattributeshortcut": True}
+
+
class TestInternal:
def test_execfile(self, space):
from pypy.tool.udir import udir
diff --git a/pypy/module/_cffi_backend/newtype.py
b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -248,7 +248,17 @@
raise OperationError(space.w_ValueError,
space.wrap("tuple args must have the same size"))
enumerators = [space.str_w(w) for w in enumerators_w]
- enumvalues = [space.int_w(w) for w in enumvalues_w]
+ enumvalues = []
+ try:
+ for w in enumvalues_w:
+ enumvalues.append(space.c_int_w(w))
+ except OperationError, e:
+ if not e.match(space, space.w_OverflowError):
+ raise
+ i = len(enumvalues)
+ raise operationerrfmt(space.w_OverflowError,
+ "enum '%s' declaration for '%s' does not fit an int",
+ name, enumerators[i])
ctype = ctypeenum.W_CTypeEnum(space, name, enumerators, enumvalues)
return ctype
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -1156,6 +1156,13 @@
e = py.test.raises(TypeError, newp, BStructPtr, [None])
assert "must be a str or int, not NoneType" in str(e.value)
+def test_enum_overflow():
+ for ovf in (2**63, -2**63-1, 2**31, -2**31-1):
+ e = py.test.raises(OverflowError, new_enum_type, "foo", ('a', 'b'),
+ (5, ovf))
+ assert str(e.value) == (
+ "enum 'foo' declaration for 'b' does not fit an int")
+
def test_callback_returning_enum():
BInt = new_primitive_type("int")
BEnum = new_enum_type("foo", ('def', 'c', 'ab'), (0, 1, -20))
@@ -2123,9 +2130,9 @@
py.test.raises(OverflowError, newp, BBoolP, 2)
py.test.raises(OverflowError, newp, BBoolP, -1)
BCharP = new_pointer_type(new_primitive_type("char"))
- p = newp(BCharP, 'X')
+ p = newp(BCharP, b'X')
q = cast(BBoolP, p)
- assert q[0] == ord('X')
+ assert q[0] == ord(b'X')
py.test.raises(TypeError, string, cast(BBool, False))
BDouble = new_primitive_type("double")
assert int(cast(BBool, cast(BDouble, 0.1))) == 1
diff --git a/pypy/module/_codecs/interp_codecs.py
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -338,38 +338,6 @@
from pypy.rlib import runicode
-def make_raw_encoder(name):
- rname = "unicode_encode_%s" % (name.replace("_encode", ""), )
- assert hasattr(runicode, rname)
- def raw_encoder(space, uni):
- state = space.fromcache(CodecState)
- func = getattr(runicode, rname)
- errors = "strict"
- return func(uni, len(uni), errors, state.encode_error_handler)
- raw_encoder.func_name = rname
- return raw_encoder
-
-def make_raw_decoder(name):
- rname = "str_decode_%s" % (name.replace("_decode", ""), )
- assert hasattr(runicode, rname)
- def raw_decoder(space, string):
- final = True
- errors = "strict"
- state = space.fromcache(CodecState)
- func = getattr(runicode, rname)
- kwargs = {}
- if name == 'unicode_escape':
- unicodedata_handler = state.get_unicodedata_handler(space)
- result, consumed = func(string, len(string), errors,
- final, state.decode_error_handler,
- unicodedata_handler=unicodedata_handler)
- else:
- result, consumed = func(string, len(string), errors,
- final, state.decode_error_handler)
- return result
- raw_decoder.func_name = rname
- return raw_decoder
-
def make_encoder_wrapper(name):
rname = "unicode_encode_%s" % (name.replace("_encode", ""), )
assert hasattr(runicode, rname)
diff --git a/pypy/module/marshal/test/test_marshal.py
b/pypy/module/marshal/test/test_marshal.py
--- a/pypy/module/marshal/test/test_marshal.py
+++ b/pypy/module/marshal/test/test_marshal.py
@@ -163,6 +163,7 @@
def test_unicode(self):
import marshal, sys
self.marshal_check(u'\uFFFF')
+ self.marshal_check(u'\ud800')
self.marshal_check(unichr(sys.maxunicode))
diff --git a/pypy/module/micronumpy/compile.py
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -111,6 +111,9 @@
def newlist(self, items):
return ListObject(items)
+ def newcomplex(self, r, i):
+ return ComplexObject(r, i)
+
def listview(self, obj):
assert isinstance(obj, ListObject)
return obj.items
@@ -135,6 +138,11 @@
raise OperationError(self.w_TypeError, self.wrap("slice."))
raise NotImplementedError
+ def unpackcomplex(self, w_obj):
+ if isinstance(w_obj, ComplexObject):
+ return w_obj.r, w_obj.i
+ raise NotImplementedError
+
def index(self, w_obj):
return self.wrap(self.int_w(w_obj))
@@ -230,6 +238,12 @@
def __init__(self, v):
self.v = v
+class ComplexObject(W_Root):
+ tp = FakeSpace.w_complex
+ def __init__(self, r, i):
+ self.r = r
+ self.i = i
+
class InterpreterState(object):
def __init__(self, code):
self.code = code
@@ -347,6 +361,20 @@
def execute(self, interp):
return interp.space.wrap(self.v)
+class ComplexConstant(Node):
+ def __init__(self, r, i):
+ self.r = float(r)
+ self.i = float(i)
+
+ def __repr__(self):
+ return 'ComplexConst(%s, %s)' % (self.r, self.i)
+
+ def wrap(self, space):
+ return space.newcomplex(self.r, self.i)
+
+ def execute(self, interp):
+ return self.wrap(interp.space)
+
class RangeConstant(Node):
def __init__(self, v):
self.v = int(v)
@@ -377,8 +405,7 @@
def execute(self, interp):
w_list = self.wrap(interp.space)
- dtype = get_dtype_cache(interp.space).w_float64dtype
- return array(interp.space, w_list, w_dtype=dtype, w_order=None)
+ return array(interp.space, w_list)
def __repr__(self):
return "[" + ", ".join([repr(item) for item in self.items]) + "]"
@@ -611,6 +638,8 @@
stack.append(RangeConstant(tokens.pop().v))
end = tokens.pop()
assert end.name == 'pipe'
+ elif token.name == 'paren_left':
+ stack.append(self.parse_complex_constant(tokens))
elif accept_comma and token.name == 'comma':
continue
else:
@@ -634,6 +663,15 @@
args += self.parse_expression(tokens, accept_comma=True)
return FunctionCall(name, args)
+ def parse_complex_constant(self, tokens):
+ r = tokens.pop()
+ assert r.name == 'number'
+ assert tokens.pop().name == 'comma'
+ i = tokens.pop()
+ assert i.name == 'number'
+ assert tokens.pop().name == 'paren_right'
+ return ComplexConstant(r.v, i.v)
+
def parse_array_const(self, tokens):
elems = []
while True:
@@ -642,6 +680,8 @@
elems.append(FloatConstant(token.v))
elif token.name == 'array_left':
elems.append(ArrayConstant(self.parse_array_const(tokens)))
+ elif token.name == 'paren_left':
+ elems.append(self.parse_complex_constant(tokens))
else:
raise BadToken()
token = tokens.pop()
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
@@ -43,9 +43,6 @@
self.imag = imag
def convert_to(self, dtype):
- from pypy.module.micronumpy.types import ComplexFloating
- if not isinstance(dtype.itemtype, ComplexFloating):
- raise TypeError('cannot convert %r to complex' % dtype)
return dtype.box_complex(self.real, self.imag)
def convert_real_to(self, dtype):
@@ -77,12 +74,7 @@
return space.wrap(box.value)
def descr_float(self, space):
- try:
- box = self.convert_to(W_Float64Box._get_dtype(space))
- except TypeError:
- raise OperationError(space.w_TypeError,
- space.wrap("Cannot convert %s to float" %
self._get_dtype(space).name))
-
+ box = self.convert_to(W_Float64Box._get_dtype(space))
assert isinstance(box, W_Float64Box)
return space.wrap(box.value)
diff --git a/pypy/module/micronumpy/interp_ufuncs.py
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -17,15 +17,18 @@
return not dtype.itemtype.bool(val)
class W_Ufunc(Wrappable):
- _attrs_ = ["name", "promote_to_float", "promote_bools", "identity",
"allow_complex"]
- _immutable_fields_ = ["promote_to_float", "promote_bools", "name",
"allow_complex"]
+ _attrs_ = ["name", "promote_to_float", "promote_bools", "identity",
+ "allow_complex", "complex_to_float"]
+ _immutable_fields_ = ["promote_to_float", "promote_bools", "name",
+ "allow_complex", "complex_to_float"]
def __init__(self, name, promote_to_float, promote_bools, identity,
- int_only, allow_complex):
+ int_only, allow_complex, complex_to_float):
self.name = name
self.promote_to_float = promote_to_float
self.promote_bools = promote_bools
self.allow_complex = allow_complex
+ self.complex_to_float = complex_to_float
self.identity = identity
self.int_only = int_only
@@ -216,10 +219,11 @@
_immutable_fields_ = ["func", "name"]
def __init__(self, func, name, promote_to_float=False, promote_bools=False,
- identity=None, bool_result=False, int_only=False, allow_complex=True):
+ identity=None, bool_result=False, int_only=False,
+ allow_complex=True, complex_to_float=False):
W_Ufunc.__init__(self, name, promote_to_float, promote_bools, identity,
- int_only, allow_complex)
+ int_only, allow_complex, complex_to_float)
self.func = func
self.bool_result = bool_result
@@ -248,6 +252,11 @@
res_dtype = interp_dtype.get_dtype_cache(space).w_booldtype
else:
res_dtype = calc_dtype
+ if self.complex_to_float and calc_dtype.is_complex_type():
+ if calc_dtype.name == 'complex64':
+ res_dtype =
interp_dtype.get_dtype_cache(space).w_float32dtype
+ else:
+ res_dtype =
interp_dtype.get_dtype_cache(space).w_float64dtype
if w_obj.is_scalar():
w_val = self.func(calc_dtype,
w_obj.get_scalar_value().convert_to(calc_dtype))
@@ -269,10 +278,11 @@
argcount = 2
def __init__(self, func, name, promote_to_float=False, promote_bools=False,
- identity=None, comparison_func=False, int_only=False,
allow_complex=True):
+ identity=None, comparison_func=False, int_only=False,
+ allow_complex=True, complex_to_float=False):
W_Ufunc.__init__(self, name, promote_to_float, promote_bools, identity,
- int_only, allow_complex)
+ int_only, allow_complex, complex_to_float)
self.func = func
self.comparison_func = comparison_func
if name == 'logical_and':
@@ -534,14 +544,14 @@
("positive", "pos", 1),
("negative", "neg", 1),
- ("absolute", "abs", 1),
+ ("absolute", "abs", 1, {"complex_to_float": True}),
("sign", "sign", 1, {"promote_bools": True}),
("signbit", "signbit", 1, {"bool_result": True,
"allow_complex": False}),
("reciprocal", "reciprocal", 1),
("conjugate", "conj", 1),
- ("real", "real", 1),
- ("imag", "imag", 1),
+ ("real", "real", 1, {"complex_to_float": True}),
+ ("imag", "imag", 1, {"complex_to_float": True}),
("fabs", "fabs", 1, {"promote_to_float": True,
"allow_complex": False}),
diff --git a/pypy/module/micronumpy/test/test_compile.py
b/pypy/module/micronumpy/test/test_compile.py
--- a/pypy/module/micronumpy/test/test_compile.py
+++ b/pypy/module/micronumpy/test/test_compile.py
@@ -281,3 +281,13 @@
d -> 1
''')
assert interp.results[0].value == 0
+
+ def test_complex(self):
+ interp = self.run('''
+ a = (0, 1)
+ b = [(0, 1), (1, 0)]
+ b -> 0
+ ''')
+ assert interp.results[0].real == 0
+ assert interp.results[0].imag == 1
+
diff --git a/pypy/module/micronumpy/test/test_complex.py
b/pypy/module/micronumpy/test/test_complex.py
--- a/pypy/module/micronumpy/test/test_complex.py
+++ b/pypy/module/micronumpy/test/test_complex.py
@@ -468,13 +468,16 @@
assert c[i] == max(a[i], b[i])
def test_basic(self):
- from _numpypy import (complex128, complex64, add,
+ from _numpypy import (complex128, complex64, add, array, dtype,
subtract as sub, multiply, divide, negative, abs, floor_divide,
- reciprocal, real, imag, sign)
+ real, imag, sign)
from _numpypy import (equal, not_equal, greater, greater_equal, less,
less_equal, isnan)
assert real(4.0) == 4.0
assert imag(0.0) == 0.0
+ a = array([complex(3.0, 4.0)])
+ b = a.real
+ assert b.dtype == dtype(float)
for complex_ in complex64, complex128:
O = complex(0, 0)
diff --git a/pypy/module/micronumpy/test/test_zjit.py
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -18,6 +18,7 @@
def setup_class(cls):
default = """
a = [1,2,3,4]
+ z = (1, 2)
c = a + b
sum(c) -> 1::1
a -> 3:1:2
@@ -490,4 +491,3 @@
'new_with_vtable': 1,
'int_add': 2,
'float_ne': 1})
-
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1274,8 +1274,8 @@
@complex_unary_op
def expm1(self, v):
- #Duplicate exp() so in the future it will be easier
- # to implement seterr
+ # duplicate exp() so in the future it will be easier
+ # to implement seterr
if rfloat.isinf(v[1]):
if rfloat.isinf(v[0]):
if v[0] < 0:
@@ -1286,8 +1286,8 @@
return rfloat.NAN, rfloat.NAN
try:
res = rcomplex.c_exp(*v)
- res = (res[0]-1, res[1])
- return res
+ res = (res[0]-1, res[1])
+ return res
except OverflowError:
if v[1] == 0:
return rfloat.INFINITY, 0.0
diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py
--- a/pypy/module/posix/app_posix.py
+++ b/pypy/module/posix/app_posix.py
@@ -198,7 +198,7 @@
def wait3(options):
""" wait3(options) -> (pid, status, rusage)
- Wait for completion of a child process and provides resource usage
informations
+ Wait for completion of a child process and provides resource usage
information
"""
from _pypy_wait import wait3
return wait3(options)
@@ -206,7 +206,7 @@
def wait4(pid, options):
""" wait4(pid, options) -> (pid, status, rusage)
- Wait for completion of the child process "pid" and provides resource
usage informations
+ Wait for completion of the child process "pid" and provides resource
usage information
"""
from _pypy_wait import wait4
return wait4(pid, options)
diff --git a/pypy/module/pypyjit/interp_resop.py
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -63,7 +63,7 @@
""" set_optimize_hook(hook)
Set a compiling hook that will be called each time a loop is optimized,
- but before assembler compilation. This allows to add additional
+ but before assembler compilation. This allows adding additional
optimizations on Python level.
The hook will be called with the pypyjit.JitLoopInfo object. Refer to it's
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -1,5 +1,4 @@
import operator
-import sys
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
from pypy.objspace.std import model, newformat
@@ -13,7 +12,6 @@
isinf, isnan, isfinite, INFINITY, NAN, copysign, formatd,
DTSF_ADD_DOT_0, DTSF_STR_PRECISION)
from pypy.rlib.rbigint import rbigint
-from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib import rfloat
from pypy.tool.sourcetools import func_with_new_name
@@ -292,8 +290,6 @@
return space.wrap(_hash_float(space, w_value.floatval))
def _hash_float(space, v):
- from pypy.objspace.std.longobject import hash__Long
-
if isnan(v):
return 0
diff --git a/pypy/objspace/std/unicodetype.py b/pypy/objspace/std/unicodetype.py
--- a/pypy/objspace/std/unicodetype.py
+++ b/pypy/objspace/std/unicodetype.py
@@ -1,5 +1,6 @@
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
+from pypy.interpreter import unicodehelper
from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.basestringtype import basestring_typedef
@@ -186,32 +187,6 @@
# ____________________________________________________________
-def decode_error_handler(space):
- def raise_unicode_exception_decode(errors, encoding, msg, s,
- startingpos, endingpos):
- raise OperationError(space.w_UnicodeDecodeError,
- space.newtuple([space.wrap(encoding),
- space.wrap(s),
- space.wrap(startingpos),
- space.wrap(endingpos),
- space.wrap(msg)]))
- return raise_unicode_exception_decode
-decode_error_handler._annspecialcase_ = 'specialize:memo'
-
-def encode_error_handler(space):
- def raise_unicode_exception_encode(errors, encoding, msg, u,
- startingpos, endingpos):
- raise OperationError(space.w_UnicodeEncodeError,
- space.newtuple([space.wrap(encoding),
- space.wrap(u),
- space.wrap(startingpos),
- space.wrap(endingpos),
- space.wrap(msg)]))
- return raise_unicode_exception_encode
-encode_error_handler._annspecialcase_ = 'specialize:memo'
-
-# ____________________________________________________________
-
def getdefaultencoding(space):
return space.sys.defaultencoding
@@ -235,12 +210,12 @@
if errors is None or errors == 'strict':
if encoding == 'ascii':
u = space.unicode_w(w_object)
- eh = encode_error_handler(space)
+ eh = unicodehelper.encode_error_handler(space)
return space.wrap(unicode_encode_ascii(
u, len(u), None, errorhandler=eh))
if encoding == 'utf-8':
u = space.unicode_w(w_object)
- eh = encode_error_handler(space)
+ eh = unicodehelper.encode_error_handler(space)
return space.wrap(unicode_encode_utf_8(
u, len(u), None, errorhandler=eh,
allow_surrogates=True))
@@ -265,12 +240,12 @@
if encoding == 'ascii':
# XXX error handling
s = space.bufferstr_w(w_obj)
- eh = decode_error_handler(space)
+ eh = unicodehelper.decode_error_handler(space)
return space.wrap(str_decode_ascii(
s, len(s), None, final=True, errorhandler=eh)[0])
if encoding == 'utf-8':
s = space.bufferstr_w(w_obj)
- eh = decode_error_handler(space)
+ eh = unicodehelper.decode_error_handler(space)
return space.wrap(str_decode_utf_8(
s, len(s), None, final=True, errorhandler=eh,
allow_surrogates=True)[0])
diff --git a/pypy/rlib/rcomplex.py b/pypy/rlib/rcomplex.py
--- a/pypy/rlib/rcomplex.py
+++ b/pypy/rlib/rcomplex.py
@@ -1,12 +1,12 @@
import math
from math import fabs, pi, e
-from pypy.rlib.rfloat import copysign, asinh, log1p, isinf, isnan
+from pypy.rlib.rfloat import copysign, asinh, log1p, isfinite, isinf, isnan
from pypy.rlib.constant import DBL_MIN, CM_SCALE_UP, CM_SCALE_DOWN
from pypy.rlib.constant import CM_LARGE_DOUBLE, DBL_MANT_DIG
from pypy.rlib.constant import M_LN2, M_LN10
from pypy.rlib.constant import CM_SQRT_LARGE_DOUBLE, CM_SQRT_DBL_MIN
from pypy.rlib.constant import CM_LOG_LARGE_DOUBLE
-from pypy.rlib.special_value import isfinite, special_type, INF, NAN
+from pypy.rlib.special_value import special_type, INF, NAN
from pypy.rlib.special_value import sqrt_special_values
from pypy.rlib.special_value import acos_special_values
from pypy.rlib.special_value import acosh_special_values
diff --git a/pypy/rlib/special_value.py b/pypy/rlib/special_value.py
--- a/pypy/rlib/special_value.py
+++ b/pypy/rlib/special_value.py
@@ -32,9 +32,6 @@
else:
return ST_NZERO
-def isfinite(d):
- return not isinf(d) and not isnan(d)
-
P = math.pi
P14 = 0.25 * math.pi
diff --git a/pypy/tool/bench/htmlreport.py b/pypy/tool/bench/htmlreport.py
--- a/pypy/tool/bench/htmlreport.py
+++ b/pypy/tool/bench/htmlreport.py
@@ -226,7 +226,7 @@
)
def render_revision_header(self, sample):
- """return a header for a report with informations about
+ """return a header for a report with information about
committer, messages, revision date.
"""
revision_id = pyhtml.li('Revision ID: %s' % (sample.revision_id,))
diff --git a/pypy/tool/bench/result.py b/pypy/tool/bench/result.py
--- a/pypy/tool/bench/result.py
+++ b/pypy/tool/bench/result.py
@@ -13,7 +13,7 @@
class PerfResultCollection(object):
- """Holds informations about several PerfResult objects. The
+ """Holds information about several PerfResult objects. The
objects should have the same test_id and revision_id"""
def __init__(self, results=None):
@@ -166,7 +166,7 @@
count = py.std.itertools.count()
def annotate(self, result):
"""Try to put extra information for each revision on the
- PerfResult objects. These informations are retrieved from a
+ PerfResult objects. These information are retrieved from a
branch object.
"""
#if self.branch is None:
diff --git a/pypy/tool/memusage/log2gnumeric.py
b/pypy/tool/memusage/log2gnumeric.py
--- a/pypy/tool/memusage/log2gnumeric.py
+++ b/pypy/tool/memusage/log2gnumeric.py
@@ -7,7 +7,7 @@
$ PYPYLOG=gc-collect,jit-mem:logfile pypy your-program.py
-This will produce "logfile", containing informations about the memory used by
+This will produce "logfile", containing information about the memory used by
the GC and the number of loops created/freed by the JIT.
If you want, you can also measure the amout of used memory as seen by the OS
diff --git a/pypy/tool/sourcetools.py b/pypy/tool/sourcetools.py
--- a/pypy/tool/sourcetools.py
+++ b/pypy/tool/sourcetools.py
@@ -120,7 +120,7 @@
# various helper functions
#
class MyStr(str):
- """ custom string which allows to add attributes. """
+ """ custom string which allows adding attributes. """
def newcode(fromcode, **kwargs):
names = [x for x in dir(fromcode) if x[:3] == 'co_']
diff --git a/pypy/translator/goal/timing.py b/pypy/translator/goal/timing.py
--- a/pypy/translator/goal/timing.py
+++ b/pypy/translator/goal/timing.py
@@ -1,5 +1,5 @@
-""" Module for keeping detailed informations about
+""" Module for keeping detailed information about
times of certain driver parts
"""
diff --git a/pypy/translator/microbench/pybench/platform.py
b/pypy/translator/microbench/pybench/platform.py
--- a/pypy/translator/microbench/pybench/platform.py
+++ b/pypy/translator/microbench/pybench/platform.py
@@ -811,7 +811,7 @@
split=re.compile('[\s,]').split):
""" Queries the given executable (defaults to the Python interpreter
- binary) for various architecture informations.
+ binary) for various architecture information.
Returns a tuple (bits,linkage) which contain information about
the bit architecture and the linkage format used for the
diff --git a/pypy/translator/platform/__init__.py
b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -215,7 +215,7 @@
largs = self._link_args_from_eci(eci, standalone)
return self._link(cc_link, ofiles, largs, standalone, exe_name)
- # below are some detailed informations for platforms
+ # below are some detailed information for platforms
def include_dirs_for_libffi(self):
dirs = self._include_dirs_for_libffi()
diff --git a/pypy/translator/tool/staticsizereport.py
b/pypy/translator/tool/staticsizereport.py
--- a/pypy/translator/tool/staticsizereport.py
+++ b/pypy/translator/tool/staticsizereport.py
@@ -201,7 +201,7 @@
f = infofile.open('w')
pickle.dump(info, f)
f.close()
- log.info('static data informations dumped to %s' % infofile)
+ log.info('static data information dumped to %s' % infofile)
return infofile
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit