Author: Ronan Lamy <ronan.l...@gmail.com> Branch: union-side-effects-2 Changeset: r88349:82a591a821b7 Date: 2016-09-02 21:40 +0100 http://bitbucket.org/pypy/pypy/changeset/82a591a821b7/
Log: Use union() instead of unionof() in a few places diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py --- a/rpython/annotator/annrpython.py +++ b/rpython/annotator/annrpython.py @@ -246,7 +246,7 @@ if s_old is not None: if not s_value.contains(s_old): log.WARNING("%s does not contain %s" % (s_value, s_old)) - log.WARNING("%s" % annmodel.unionof(s_value, s_old)) + log.WARNING("%s" % annmodel.union(s_value, s_old)) assert False arg.annotation = s_value diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py --- a/rpython/annotator/binaryop.py +++ b/rpython/annotator/binaryop.py @@ -11,7 +11,7 @@ SomeBuiltinMethod, SomeIterator, SomePBC, SomeNone, SomeFloat, s_None, SomeByteArray, SomeWeakRef, SomeSingleFloat, SomeLongFloat, SomeType, SomeTypeOf, SomeConstantType, unionof, UnionError, - read_can_only_throw, add_knowntypedata, + union, read_can_only_throw, add_knowntypedata, merge_knowntypedata,) from rpython.annotator.bookkeeper import immutablevalue, getbookkeeper from rpython.flowspace.model import Variable, Constant, const @@ -703,13 +703,13 @@ pairtype(SomeException, SomeInstance), pairtype(SomeException, SomeNone)): def union((s_exc, s_inst)): - return unionof(s_exc.as_SomeInstance(), s_inst) + return union(s_exc.as_SomeInstance(), s_inst) class __extend__( pairtype(SomeInstance, SomeException), pairtype(SomeNone, SomeException)): def union((s_inst, s_exc)): - return unionof(s_exc.as_SomeInstance(), s_inst) + return union(s_exc.as_SomeInstance(), s_inst) class __extend__(pairtype(SomeException, SomeException)): def union((s_exc1, s_exc2)): diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py --- a/rpython/annotator/builtin.py +++ b/rpython/annotator/builtin.py @@ -6,7 +6,7 @@ from rpython.annotator.model import ( SomeInteger, SomeChar, SomeBool, SomeString, SomeTuple, - SomeUnicodeCodePoint, SomeFloat, unionof, SomeUnicodeString, + SomeUnicodeCodePoint, SomeFloat, union, SomeUnicodeString, SomePBC, SomeInstance, SomeDict, SomeList, SomeWeakRef, SomeIterator, SomeOrderedDict, SomeByteArray, add_knowntypedata, s_ImpossibleValue,) from rpython.annotator.bookkeeper import ( @@ -166,14 +166,14 @@ s_iter = s_values[0].iter() return s_iter.next() else: - return unionof(*s_values) + return union(*s_values) def builtin_max(*s_values): if len(s_values) == 1: # xxx do we support this? s_iter = s_values[0].iter() return s_iter.next() else: - s = unionof(*s_values) + s = union(*s_values) if type(s) is SomeInteger and not s.nonneg: nonneg = False for s1 in s_values: diff --git a/rpython/annotator/dictdef.py b/rpython/annotator/dictdef.py --- a/rpython/annotator/dictdef.py +++ b/rpython/annotator/dictdef.py @@ -1,5 +1,5 @@ -from rpython.annotator.model import s_ImpossibleValue -from rpython.annotator.model import SomeInteger, s_Bool, unionof +from rpython.annotator.model import ( + s_ImpossibleValue, SomeInteger, s_Bool, union) from rpython.annotator.listdef import ListItem from rpython.rlib.objectmodel import compute_hash @@ -34,8 +34,8 @@ def update_rdict_annotations(self, s_eqfn, s_hashfn, other=None): assert self.custom_eq_hash - s_eqfn = unionof(s_eqfn, self.s_rdict_eqfn) - s_hashfn = unionof(s_hashfn, self.s_rdict_hashfn) + s_eqfn = union(s_eqfn, self.s_rdict_eqfn) + s_hashfn = union(s_hashfn, self.s_rdict_hashfn) self.s_rdict_eqfn = s_eqfn self.s_rdict_hashfn = s_hashfn self.emulate_rdict_calls(other=other) diff --git a/rpython/annotator/test/test_model.py b/rpython/annotator/test/test_model.py --- a/rpython/annotator/test/test_model.py +++ b/rpython/annotator/test/test_model.py @@ -146,14 +146,14 @@ someinst = lambda cls, **kw: SomeInstance(bk.getuniqueclassdef(cls), **kw) s_inst = someinst(Exception) s_exc = bk.new_exception([ValueError, IndexError]) - assert unionof(s_exc, s_inst) == s_inst - assert unionof(s_inst, s_exc) == s_inst - s_nullable = unionof(s_None, bk.new_exception([ValueError])) + assert union(s_exc, s_inst) == s_inst + assert union(s_inst, s_exc) == s_inst + s_nullable = union(s_None, bk.new_exception([ValueError])) assert isinstance(s_nullable, SomeInstance) assert s_nullable.can_be_None s_exc1 = bk.new_exception([ValueError]) s_exc2 = bk.new_exception([IndexError]) - unionof(s_exc1, s_exc2) == unionof(s_exc2, s_exc1) + union(s_exc1, s_exc2) == union(s_exc2, s_exc1) def contains_s(s_a, s_b): if s_b is None: diff --git a/rpython/rtyper/test/test_llannotation.py b/rpython/rtyper/test/test_llannotation.py --- a/rpython/rtyper/test/test_llannotation.py +++ b/rpython/rtyper/test/test_llannotation.py @@ -1,6 +1,6 @@ import py.test from rpython.annotator.model import ( - SomeInteger, SomeBool, SomeChar, unionof, SomeImpossibleValue, + SomeInteger, SomeBool, SomeChar, union, SomeImpossibleValue, UnionError, SomeInstance, SomeSingleFloat) from rpython.rlib.rarithmetic import r_uint, r_singlefloat from rpython.rtyper.llannotation import ( @@ -69,22 +69,22 @@ PA1 = lltype.Ptr(lltype.GcArray()) PA2 = lltype.Ptr(lltype.GcArray()) - assert unionof(SomePtr(PS1), SomePtr(PS1)) == SomePtr(PS1) - assert unionof(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS2) - assert unionof(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS1) + assert union(SomePtr(PS1), SomePtr(PS1)) == SomePtr(PS1) + assert union(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS2) + assert union(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS1) - assert unionof(SomePtr(PA1), SomePtr(PA1)) == SomePtr(PA1) - assert unionof(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA2) - assert unionof(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA1) + assert union(SomePtr(PA1), SomePtr(PA1)) == SomePtr(PA1) + assert union(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA2) + assert union(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA1) - assert unionof(SomePtr(PS1), SomeImpossibleValue()) == SomePtr(PS1) - assert unionof(SomeImpossibleValue(), SomePtr(PS1)) == SomePtr(PS1) + assert union(SomePtr(PS1), SomeImpossibleValue()) == SomePtr(PS1) + assert union(SomeImpossibleValue(), SomePtr(PS1)) == SomePtr(PS1) with py.test.raises(UnionError): - unionof(SomePtr(PA1), SomePtr(PS1)) + union(SomePtr(PA1), SomePtr(PS1)) with py.test.raises(UnionError): - unionof(SomePtr(PS1), SomePtr(PS3)) + union(SomePtr(PS1), SomePtr(PS3)) with py.test.raises(UnionError): - unionof(SomePtr(PS1), SomeInteger()) + union(SomePtr(PS1), SomeInteger()) with py.test.raises(UnionError): - unionof(SomeInteger(), SomePtr(PS1)) + union(SomeInteger(), SomePtr(PS1)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit