Page 1 of 1

Game completely broken: TypeError: __init__() takes exactly 5 arguments (4 given)

Posted: Wed Mar 25, 2020 6:30 pm
by xelestial
Hi, I am pretty much a complete newbie to programming still, usually working alongside more experienced programmers for the past few years. I'm not sure how to explain my problem well, as I'm at a loss. I have been developing my game for awhile, and it suddenly has been crashing when I went to add a new script file. The odd thing is, that it was working completely fine prior and still works if I only use files that haven't been modified before the break I took (I took about a month break). Even just saving over an old working file without adding anything causes the game to suddenly break. I have tried just about everything in isolating the problem, and researched everywhere, and all I can tell is that the simple act of saving over a normal story script file causes the error.

The only changes I can think of is that I had taken a break off of it in order to work on a different Ren'py game with a similar codebase (like, I can see the saves from the other game, but can't load them) and during that time, the programmer I was working with had asked me to update Ren'py. However, the game still doesn't seem to work even if I use an old version. I even downloaded the game onto another computer and Ren'py, and it's giving me the same error. I've gotten it to say one other error, which I don't have, but it lists something in the ren'py common folder and "Action". I normally get the below error, though.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While parsing /Users/xelestial/Downloads/MDE Demo/game/script/9_story/Chapter 01/mde_chapter_01.rpy.
  File "game/script/0_general/customStatements.rpy", line 749, in parse_user_statement
    rv = renpy.ast.UserStatement(loc, l.text, l.subblock)
TypeError: __init__() takes exactly 5 arguments (4 given)

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

Full traceback:
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/bootstrap.py", line 316, in bootstrap
    renpy.main.main()
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/main.py", line 422, in main
    renpy.game.script.load_script()  # sets renpy.game.script.
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/script.py", line 275, in load_script
    self.load_appropriate_file(".rpyc", ".rpy", dir, fn, initcode)
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/script.py", line 751, in load_appropriate_file
    data, stmts = self.load_file(dir, fn + source)
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/script.py", line 572, in load_file
    stmts = renpy.parser.parse(fullfn)
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/parser.py", line 2872, in parse
    rv = parse_block(l)
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/parser.py", line 2834, in parse_block
    stmt = parse_statement(l)
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/parser.py", line 2818, in parse_statement
    return pf(l, loc)
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/parser.py", line 2325, in label_statement
    block = parse_block(l.subblock_lexer(init))
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/parser.py", line 2834, in parse_block
    stmt = parse_statement(l)
  File "/Users/xelestial/Downloads/renpy-7.3.5-sdk/renpy/parser.py", line 2818, in parse_statement
    return pf(l, loc)
  File "game/script/0_general/customStatements.rpy", line 749, in parse_user_statement
    rv = renpy.ast.UserStatement(loc, l.text, l.subblock)
TypeError: __init__() takes exactly 5 arguments (4 given)

Darwin-17.7.0-x86_64-i386-64bit
Ren'Py 7.3.5.606
 
Wed Mar 25 18:10:02 2020
This is the section/line 749 it's talking about:

Code: Select all

        # The function that is called to create an ast.UserStatement.
        def parse_user_statement(l, loc):
            renpy.exports.push_error_handler(l.error)
   
            try:
                rv = renpy.ast.UserStatement(loc, l.text, l.subblock)
                rv.translatable = translatable
               
                l.advance()
            finally:
                renpy.exports.pop_error_handler()
   
            if init and not l.init:
                rv = renpy.ast.Init(loc, [ rv ], 0)
   
            return rv
   
        renpy.parser.statements.add(name, parse_user_statement)
   
        # The function that is called to get our parse data.
        def parse_data(l):
            return (name, renpy.statements.registry[name]["parse"](l))
   
        renpy.statements.parsers.add(name, parse_data)
   
    ####################################################################
I did not change anything in my custom code at all and it was working fine for the past year. Thanks for any guidance you can give me.

Re: Game completely broken: TypeError: __init__() takes exactly 5 arguments (4 given)

Posted: Wed Mar 25, 2020 10:17 pm
by PyTom
game/script/0_general/customStatements.rpy is the problem. It's using an undocumented internal of Ren'Py that hasn't been updated to the newest version. I'd suggest avoiding using undocumented internals like that, to prevent a problem like this.

Re: Game completely broken: TypeError: __init__() takes exactly 5 arguments (4 given)

Posted: Thu Mar 26, 2020 1:32 am
by xelestial
PyTom wrote:
Wed Mar 25, 2020 10:17 pm
game/script/0_general/customStatements.rpy is the problem. It's using an undocumented internal of Ren'Py that hasn't been updated to the newest version. I'd suggest avoiding using undocumented internals like that, to prevent a problem like this.
Thanks, can confirm it was this...I had to replace the file with one that was working for my other game (the other coder I was previously working with may have updated that one) and that one works fine. That customStatements.rpy file was what a different coder left me with years ago, but going forward, I'll try to get away from the custom statements crutch, and back into learning default Ren'py because of the short-term viability of this.

Re: Game completely broken: TypeError: __init__() takes exactly 5 arguments (4 given)

Posted: Mon Mar 30, 2020 5:56 pm
by PyTom
Note that custom statements are fine, provided you use the documented APIs with the statements and their implementation. In the case of this, you're using undocumented internals inside a custom statement, and that's what causes problems. The reason why the internals are undocumented is because I sometimes change them, to improve Ren'Py.