Bug? Lists cause the Variable Viewer to crash

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

Bug? Lists cause the Variable Viewer to crash

#1 Post by herenvardo »

Maybe this has been reported before, but I think I should mention it: when the Variable Viewer in the Developer Menu attempts to show a variable that contains a python list, the game crashes.

This snippet is enough to show the issue:

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

# The game starts here.
label start:
    e "This is just a test"
    $ myArray = [ 'a', 'b', 'c' ]
    e "The game will crash if I go to 'Variable Viewer' in the Developer Menu!"
    
    return
If, after myArray is assigned, I attempt to go to the Variable Viewer, I get this traceback:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
KeyError: "'a', 'b', 'c'"

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Program Files (x86)\renpy-6.13.7\renpy\execution.py", line 261, in run
  File "C:\Program Files (x86)\renpy-6.13.7\renpy\ast.py", line 630, in execute
  File "C:\Program Files (x86)\renpy-6.13.7\renpy\python.py", line 978, in py_exec_bytecode
  File "common/_developer.rpym", line 85, in <module>
  File "common/00layout.rpy", line 191, in list
  File "C:\Program Files (x86)\renpy-6.13.7\renpy\ui.py", line 435, in __call__
  File "C:\Program Files (x86)\renpy-6.13.7\renpy\text\text.py", line 1033, in __init__
  File "C:\Program Files (x86)\renpy-6.13.7\renpy\text\text.py", line 1076, in set_text
  File "C:\Program Files (x86)\renpy-6.13.7\renpy\substitutions.py", line 218, in substitute
  File "string.pyo", line 549, in vformat
  File "string.pyo", line 571, in _vformat
  File "string.pyo", line 632, in get_field
  File "string.pyo", line 591, in get_value
KeyError: "'a', 'b', 'c'"

Windows-post2008Server-6.1.7601-SP1
Ren'Py 6.13.7.1646
A Ren'Py Game 0.0
As can be inferred from the traceback itself, this was tested with Ren'Py 6.13 on Windows 7.

I have tried replacing the list with a tuple and with a dictionary and in both cases things worked fine.
Knowing that the expected output for the case above would be "[ 'a', 'b', 'c' ]", it looks like the engine is attempting to process that string for interpolation.

EDIT:
I just tested the same sample on Ren'Py 6.12.2 and it worked fine. While correlation doesn't necessarily imply causality, the fact that the []-based syntax for interpolation was added on Ren'Py 6.13 is worth taking in account, at the very least.
The Developer Menu looks like it uses the same GUI functions as games themselves to render the text, so: are the square brackets in the text generated by the variable viewer properly escaped?

EDIT2:
Solved! Indeed, the new interpolation syntax was the culprit.
Changing common/_developer.rpym line 81 from this:

Code: Select all

            entries.append((0, (var + " = " + val).replace("{", "{{")))
to this:

Code: Select all

            entries.append((0, (var + " = " + val).replace("{", "{{").replace("[", "[[")))
fixes the issue.

EDIT3:
Just thought of a minor glitch for the solution above: when a string contains a literal '[' (which needs to be typed in code as '[[' to properly escape it), the variable viewer will show the brackets doubled. IMHO, this shouldn't be a real issue, since other escape sequences such as '\n' are also displayed "as typed", so I think this "doubling" of '[' characters may be even desirable for consistency.
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

Post Reply

Who is online

Users browsing this forum: No registered users