[pypy-issue] Issue #2354: Confusing type message: do_stringformat()-> assert s_str.is_constant() (pypy/pypy)

Sarah Mount issues-reply at bitbucket.org
Mon Jul 25 16:17:24 EDT 2016


New issue 2354: Confusing type message: do_stringformat()-> assert s_str.is_constant()
https://bitbucket.org/pypy/pypy/issues/2354/confusing-type-message-do_stringformat

Sarah Mount:

In the example interpreter below, there is some confusion between class attributes and object attributes. The "bug" here is that the error message that the RPython annotator gives is confusing.

```
#!python

$ cat example2.py

class Interpreter(object):
    help_message = 'usage: %s'

    def __init__(self, name):
        self.name = name

    def get_entry_point(self):
        def entry_point(argv):
            print self.help_message % self.name
            return 0
        return entry_point


class MyInterpreter(Interpreter):
    help_message = 'I WANT MY OWN HELP MESSAGE!!! usage: %s'

    def __init__(self):
        Interpreter.__init__(self, 'myinterp')
        # Fix type error by removing MyInterpreter.help_message
        # and writing:
        #
        # Interpreter.help_message = 'I WANT MY OWN HELP MESSAGE!!! usage: %s'
        #
        # in this constructor instead.

    def get_entry_point(self):
        def entry_point(argv):
            print self.help_message % self.name
            return 0
        return entry_point


def target(driver, args):
    return MyInterpreter().get_entry_point(), None

$ ../pypy/rpython/bin/rpython -Ojit example2.py


[translation:info] Error:
   File "/home/snim2/Desktop/working/pypy/rpython/translator/goal/translate.py", line 317, in main
    drv.proceed(goals)
   File "/home/snim2/Desktop/working/pypy/rpython/translator/driver.py", line 551, in proceed
    result = self._execute(goals, task_skip = self._maybe_skip())
   File "/home/snim2/Desktop/working/pypy/rpython/translator/tool/taskengine.py", line 114, in _execute
    res = self._do(goal, taskcallable, *args, **kwds)
   File "/home/snim2/Desktop/working/pypy/rpython/translator/driver.py", line 278, in _do
    res = func()
   File "/home/snim2/Desktop/working/pypy/rpython/translator/driver.py", line 345, in task_rtype_lltype
    rtyper.specialize(dont_simplify_again=True)
   File "/home/snim2/Desktop/working/pypy/rpython/rtyper/rtyper.py", line 188, in specialize
    self.specialize_more_blocks()
   File "/home/snim2/Desktop/working/pypy/rpython/rtyper/rtyper.py", line 231, in specialize_more_blocks
    self.specialize_block(block)
   File "/home/snim2/Desktop/working/pypy/rpython/rtyper/rtyper.py", line 317, in specialize_block
    self.translate_hl_to_ll(hop, varmapping)
   File "/home/snim2/Desktop/working/pypy/rpython/rtyper/rtyper.py", line 443, in translate_hl_to_ll
    resultvar = hop.dispatch()
   File "/home/snim2/Desktop/working/pypy/rpython/rtyper/rtyper.py", line 660, in dispatch
    return translate_meth(self)
   File "<259-codegen /home/snim2/Desktop/working/pypy/rpython/rtyper/rtyper.py:523>", line 5, in translate_op_mod
    return pair(r_arg1, r_arg2).rtype_mod(hop)
   File "/home/snim2/Desktop/working/pypy/rpython/rtyper/rstr.py", line 554, in rtype_mod
    return r_str.ll.do_stringformat(hop, [(hop.args_v[1], hop.args_r[1])])
   File "/home/snim2/Desktop/working/pypy/rpython/rtyper/lltypesystem/rstr.py", line 1151, in do_stringformat
    assert s_str.is_constant()
[translation:ERROR] AssertionError
[translation] start debugger...
> /home/snim2/Desktop/working/pypy/rpython/rtyper/lltypesystem/rstr.py(1151)do_stringformat()
-> assert s_str.is_constant()
```




More information about the pypy-issue mailing list