Bug with simple persistent data [Solved]

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
Regis
Newbie
Posts: 16
Joined: Tue Jan 10, 2017 6:31 pm
Contact:

Bug with simple persistent data [Solved]

#1 Post by Regis »

I have a trivial code for merging persistent data that exactly same as in RenPy docs:

Code: Select all

    if persistent.gallery is None:
        persistent.gallery = set()

    def merge_gallery(old, new, current):
        current.update(old)
        current.update(new)

    renpy.register_persistent('gallery', merge_gallery)
And yet sometimes (rarely) it produces this exception for some players:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/func_replay.rpy", line 90, in merge_gallery
AttributeError: 'NoneType' object has no attribute 'update'

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

Full traceback:
  File "C:\ZZZ\renpy\bootstrap.py", line 295, in bootstrap
    renpy.main.main()
  File "C:\ZZZ\renpy\main.py", line 490, in main
    renpy.persistent.update(True)
  File "C:\ZZZ\renpy\persistent.py", line 373, in update
    merge(other)
  File "C:\ZZZ\renpy\persistent.py", line 319, in merge
    val = merge_func(old, new, pval)
  File "game/func_replay.rpy", line 90, in merge_gallery
AttributeError: 'NoneType' object has no attribute 'update'

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
1) Any ideas how that can happen? I want to understand what can possibly lead to this situation.
2) Am I doing something wrong? Is there a more proper way to work with set-like persistent object?
Last edited by Regis on Sun Sep 03, 2017 12:03 am, edited 1 time in total.

Regis
Newbie
Posts: 16
Joined: Tue Jan 10, 2017 6:31 pm
Contact:

Re: Bug with simple persistent data

#2 Post by Regis »

Upd: answer from renpytom: there is a bug in the docs. Merge function have to return merged value.

So the correct code should look like this:

Code: Select all

    def merge_gallery(old, new, current):
        current.update(old)
        current.update(new)
        return current

Post Reply

Who is online

Users browsing this forum: Google [Bot], rag_exe21