Can't Save // Attribute Error: 'NoneType object has no attribute 'encode'

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
decocloud
Newbie
Posts: 11
Joined: Fri May 13, 2022 7:15 pm
Contact:

Can't Save // Attribute Error: 'NoneType object has no attribute 'encode'

#1 Post by decocloud »

Hey there I am completely beyond stumped with this traceback error I'm getting every time I try to save my game.

Code: Select all

While running game code:
  File "renpy/common/00gamemenu.rpy", line 174, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 174, in <module>
    $ ui.interact()
  File "renpy/common/00action_file.rpy", line 414, in __call__
    renpy.save(fn, extra_info=save_name)
AttributeError: 'NoneType' object has no attribute 'encode'
I recently made tons of stylistic changes all over the game and have no idea what's causing it and windows is telling me I don't have an app installed to be able to open up any of the common/ rpy scripts to try and decipher this (even though I've been using VScode for everything else). Any idea where this might be coming from?

The full traceback report (some personal data scrubbed from file locations):

Code: Select all

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 174, in script
    $ ui.interact()
  File "C:\Users\renpy-8.2.1-sdk\renpy\ast.py", line 823, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\python.py", line 1178, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/00gamemenu.rpy", line 174, in <module>
    $ ui.interact()
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\ui.py", line 301, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\core.py", line 2165, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\core.py", line 3201, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Hibiya\Desktop\renpy-8.2.1-sdk\renpy\display\transition.py", line 53, in event
    return self.new_widget.event(ev, x, y, st) # E1101
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\screen.py", line 793, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Usersa\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 1426, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 288, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Hibiya\Desktop\renpy-8.2.1-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\behavior.py", line 1174, in event
    return handle_click(self.clicked)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\behavior.py", line 1095, in handle_click
    rv = run(action)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\behavior.py", line 388, in run
    new_rv = run(i, *args, **kwargs)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\display\behavior.py", line 395, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 414, in __call__
    renpy.save(fn, extra_info=save_name)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\loadsave.py", line 460, in save
    location.save(slotname, sr)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\savelocation.py", line 464, in save
    l.save(slotname, record)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\savelocation.py", line 161, in save
    record.write_file(filename)
  File "C:\Users\Desktop\renpy-8.2.1-sdk\renpy\loadsave.py", line 361, in write_file
    zf.writestr("extra_info", self.extra_info.encode("utf-8"))
AttributeError: 'NoneType' object has no attribute 'encode'

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2420
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Can't Save // Attribute Error: 'NoneType object has no attribute 'encode'

#2 Post by Ocelot »

What is the value of save_name variable, did you change it?
< < insert Rick Cook quote here > >

decocloud
Newbie
Posts: 11
Joined: Fri May 13, 2022 7:15 pm
Contact:

Re: Can't Save // Attribute Error: 'NoneType object has no attribute 'encode'

#3 Post by decocloud »

So seaching all my rpy scripts, save_name only comes up once on the screens script as part of the save/load screen as

Code: Select all

$ store.save_name = persistent.name
I edited stuff around this to make alpha masks + custom buttons but I don't think I edited it directly. Here's the full chunk:

Code: Select all

screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("PAGE {}"), auto=_("AUTO"), quick=_("QUICK"))

    use game_menu(title):

        fixed:
            order_reverse True
            button:
                style "page_label"

                key_events True
                xalign 0.5
                action page_name_value.Toggle()

                input:
                    style "page_nameValue"
                    value page_name_value

            grid gui.file_slot_cols gui.file_slot_rows:
                style_prefix "slot"                

                xpos 0
                ypos 200            

                spacing gui.slot_spacing

                for i in range(gui.file_slot_cols * gui.file_slot_rows):

                    $ slot = i + 1

                    button at button_glow,slot_rotation:
                        action FileAction(slot)

                        vbox:
                            xalign -0.10
                            yalign -0.22

                            $ store.save_name = persistent.name
                            add AlphaMask(FileScreenshot(slot), mask=Frame("gui/button/slot_alphamask2.png", 0, 0, 0, 0, tile=False)):  #changes I made for masking the image (it just makes rounded corners)
                                ypos -5
                            text FileTime(slot, format=_("{#file_time}%A \n%B %d %Y \n%H:%M"), empty=_("empty slot")):
                                style "slot_time_text"
                                size 32
                                xpos 370
                                ypos -160


                        key "save_delete" action FileDelete(slot)

            
            vbox:
                xpos 480
                ypos -71

                hbox:
                    style_prefix "page"

                    xpos 0.55 ypos 2
                
                    spacing gui.page_spacing

                    
                    imagebutton auto "gui/button/arrows/arrow_%s.png" focus_mask True action FilePagePrevious() hovered [Play ("sound", "audio/neonbuzz.ogg") ] ypos 1
                    if config.has_autosave:
                        textbutton _("{#auto_page}AUTO") action FilePage("auto") ypos -2

                    if config.has_quicksave:
                        textbutton _("{#quick_page}QUICK") action FilePage("quick") ypos -2

                    
                    for page in range(1, 7):
                        textbutton "[page]" action FilePage(page) ypos -2

                  
                    imagebutton auto "gui/button/arrows/Rarrow_%s.png" focus_mask True action FilePagePrevious() hovered [Play ("sound", "audio/neonbuzz.ogg") ] ypos 1

decocloud
Newbie
Posts: 11
Joined: Fri May 13, 2022 7:15 pm
Contact:

Re: Can't Save // Attribute Error: 'NoneType object has no attribute 'encode'

#4 Post by decocloud »

ACTUALLY i just realized this was changed, I got rid of the whole vbox containing

Code: Select all

$ store.save_name = persistent.name
and reverted to default, saves seem to be working again. Now to figure out how to reapply styling without stupidly breaking a core function.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]