Hi William,

Good catch! I was just trying to get something to work, but it seems like you found another bug. I am now checking if it is None:

        # union flags in w_1 and w_2 and propagate to result
        if isinstance(w_result, W_Root) and w_result is not None:
            rb_results = {}
            if isinstance(w_1, W_Root) and w_1 is not None:
                w_1_rbflags = w_1.get_rbflags()
                rb_results.update(w_1_rbflags)
            if isinstance(w_2, W_Root) and w_2 is not None:
                w_2_rbflags = w_2.get_rbflags()
                rb_results.update(w_2_rbflags)
            w_result.set_rbflags(rb_results)

I now get this error:

[translation:ERROR] UnionError:

Offending annotations:
  SomeInstance(can_be_None=False, classdef=pypy.interpreter.baseobjspace.W_Root)
  SomeOrderedDict(dictdef=<{SomeImpossibleValue(): SomeImpossibleValue()}>)


Occurred processing the following simple_call:
  <MethodDesc 'set_rbflags' of <ClassDef 'pypy.interpreter.baseobjspace.W_Root'> bound to <ClassDef 'pypy.interpreter.baseobjspace.W_Root'> {}> returning

    v831 = simple_call(v830, rb_results_0)

In <FunctionGraph of (pypy.interpreter.pyopcode:40)opcode_impl_for_div__star_2 at 0x1c190b10>:
Happened at file /home/ubuntu/pypy2-v5.3.1-src/pypy/interpreter/pyopcode.py line 55

==>             w_result.set_rbflags(rb_results)

Known variable annotations:
 v830 = SomePBC(can_be_None=False, descriptions={...1...}, knowntype=method, subset_of=None)
 rb_results_0 = SomeOrderedDict(dictdef=<{SomeImpossibleValue(): SomeImpossibleValue()}>)

Processing block:
 block@203 is a <class 'rpython.flowspace.flowcontext.SpamBlock'>
 in (pypy.interpreter.pyopcode:40)opcode_impl_for_div__star_2
 containing the following operations:
       v830 = getattr(w_result_0, ('set_rbflags'))
       v831 = simple_call(v830, rb_results_0)
 --end--

I assume this happens because w_result can be a "subset" of None. What is the proper way to check if it's None? 

Frank

On Wed, Jan 11, 2017 at 3:00 PM, William ML Leslie <william.leslie.ttg@gmail.com> wrote:
On 12 January 2017 at 09:08, Frank Wang <frankw@mit.edu> wrote:
> def binaryoperation(operationname):
>     """NOT_RPYTHON"""
>     def opimpl(self, *ignored):
>         operation = getattr(self.space, operationname)
>         w_2 = self.popvalue()
>         w_1 = self.popvalue()
>         w_result = operation(w_1, w_2)
>
>         # union flags in w_1 and w_2 and propagate to result
>         w_1_rbflags = w_1.get_rbflags()
>         w_2_rbflags = w_2.get_rbflags()
>         w_1_rbflags.update(w_2_rbflags)
>         w_result.set_rbflags(w_1_rbflags)
>
>         self.pushvalue(w_result)

It looks like, if an app-level exception is in progress, w_result may
be None.  Try checking for that before setting the flags.

Also:  did you mean to alter w_1's rbflags?  Seems strange that you'd
alter w_1 but not w_2.

--
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely MAY reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
prior contractual agreement.