[pypy-dev] Fwd: Re: Adding init/variables to W_Root

Frank Wang frankw at mit.edu
Mon Dec 19 19:29:09 EST 2016


This also seems to happen in a lot of classes because W_Root is the parent
class for many classes. Is there a way to universally turn off this
immutable flag (assuming it's okay) in all classes?

Frank

On Mon, Dec 19, 2016 at 3:55 PM, Frank Wang <frankw at mit.edu> wrote:

> Hi Carl,
>
> Thanks for the tip! It's mostly working. I get this error:
>
> [translation:ERROR] ImmutableConflictError: class <InstanceRepr for
> pypy.module._cffi_backend.libraryobj.W_Library> has _immutable_=True, but
> parent class <InstanceRepr for pypy.interpreter.baseobjspace.W_Root>
> defines (at least) the mutable field 'rb_flags'
>
> I'm tempted to set the flag to be False. Is there any reason that W_Root
> or any of its subclasses cannot contain immutable variables?
>
> Frank
>
> On Mon, Dec 19, 2016 at 9:00 AM, Carl Friedrich Bolz <cfbolz at gmx.de>
> wrote:
>
>> Oops, forgot to cc pypy-dev...
>>
>>
>> Carl Friedrich
>>
>> ------------------------------
>> *From:* Carl Friedrich Bolz <cfbolz at gmx.de>
>> *Sent:* December 19, 2016 5:59:01 PM GMT+01:00
>> *To:* Frank Wang <frankw at mit.edu>
>> *Subject:* Re: [pypy-dev] Adding init/variables to W_Root
>>
>> Hi Frank,
>>
>> The solution is to add an _attrs_ = ('__weakref__', 'rb_flags',)
>> declaration to the body of W_Root. It's like  __slots__, but only for
>> RPython.
>>
>> Cheers,
>>
>> Carl Friedrich
>>
>> On December 19, 2016 5:42:12 PM GMT+01:00, Frank Wang <frankw at mit.edu>
>> wrote:
>>>
>>> Hi Armin,
>>>
>>> If I modify the line to __slots__ = ('__weakref__', 'rb_flags',), I get
>>> the following error:
>>>
>>> [translation:ERROR] AssertionError: <pypy.interpreter.generator.GeneratorIterator
>>> object at 0x00000000073e87c8>: to run register_finalizer() untranslated,
>>> the object must not have __slots__
>>>
>>> If I remove that line completely, I get the following error,
>>>
>>> [translation:ERROR] Exception: <class 'pypy.objspace.std.dictmultiobject.W_DictMultiObject'>
>>> has slots or _attrs_, but not its base class
>>> Processing block:
>>>  block at 3 is a <class 'rpython.flowspace.flowcontext.SpamBlock'>
>>>  in (pypy.interpreter.mixedmodule:83)MixedModule.getdictvalue
>>>  containing the following operations:
>>>        v0 = getattr(space_0, ('finditem_str'))
>>>        v1 = getattr(self_0, ('w_dict'))
>>>        w_value_0 = simple_call(v0, v1, name_0)
>>>        v2 = getattr(self_0, ('lazy'))
>>>        v3 = bool(v2)
>>>  --end--
>>>
>>> I wonder what error in your opinion is easier to get around.
>>>
>>> Thanks for the help!
>>>
>>> Frank
>>>
>>> On Mon, Dec 19, 2016 at 2:26 AM, Armin Rigo <armin.rigo at gmail.com>
>>> wrote:
>>>
>>>> Hi Frank,
>>>>
>>>> On 19 December 2016 at 05:29, Frank Wang <frankw at mit.edu> wrote:
>>>> > Attribute 'rb_flags' on <ClassDef 'pypy.interpreter.baseobjspace
>>>> .W_Root'>
>>>> > should be read-only.
>>>>
>>>> Ah, did you adapt or remove this line in class W_Root?
>>>>
>>>>     __slots__ = ('__weakref__',)
>>>>
>>>> The annotator complains, I think, because 'rb_flags' is forbidden by
>>>> this line (which is useful to avoid having random attributes
>>>> accidentally move up to W_Root).
>>>>
>>>>
>>>> A bientôt,
>>>>
>>>> Armin.
>>>>
>>>
>>> ------------------------------
>>>
>>> pypy-dev mailing list
>>> pypy-dev at python.org
>>> https://mail.python.org/mailman/listinfo/pypy-dev
>>>
>>>
>> _______________________________________________
>> pypy-dev mailing list
>> pypy-dev at python.org
>> https://mail.python.org/mailman/listinfo/pypy-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20161219/29609be2/attachment.html>


More information about the pypy-dev mailing list